SAP Function Modules

BAPI_PR_CREATE SAP Function module - Create Enjoy Purchase Requisition







BAPI_PR_CREATE is a standard SAP function module available within R/3 SAP systems depending on your version and release level. Below is the pattern details for this FM showing its interface including any import and export parameters, exceptions etc as well as any documentation contributions (Comments) specific to the object.

See here to view full function module documentation and code listing, simply by entering the name BAPI_PR_CREATE into the relevant SAP transaction such as SE37 or SE80.

Associated Function Group: 2105
Released Date: 17.03.2005
Processing type: Remote-Enabled
remote enabled module settings


Pattern for FM BAPI_PR_CREATE - BAPI PR CREATE





CALL FUNCTION 'BAPI_PR_CREATE' "Create Enjoy Purchase Requisition
* EXPORTING
*   prheader =                  " bapimereqheader  Transfer Structure for Enjoy Purchase Req. - Header
*   prheaderx =                 " bapimereqheaderx  Change Parameter for Enjoy Purchase Requisition - Header
*   testrun =                   " bapiflag-bapiflag  Test Indicator
  IMPORTING
    number =                    " bapimereqheader-preq_no  Purchase Requisition Number
    prheaderexp =               " bapimereqheader  Transfer Structure for Enjoy Purchase Req. - Header
  TABLES
*   return =                    " bapiret2      Return Parameters
    pritem =                    " bapimereqitemimp  Transfer Structure for Enjoy Purchase Req. - Item Data
*   pritemx =                   " bapimereqitemx  Change Parameter for Enjoy Purchase Requisition - Item Data
*   pritemexp =                 " bapimereqitem  Transfer Structure for Enjoy Purchase Req. - Item Data
*   pritemsource =              " bapimereqsource  Return Structure for Enjoy Purchase Req. - Source of Supply
*   praccount =                 " bapimereqaccount  Transfer Structure for Enjoy Purchase Req. - Acct Assignment
*   praccountproitsegment =     " bapimereqaccountprofitseg  Reservation Event Object: BAPI_PROFITABILITY_SEGMENT
*   praccountx =                " bapimereqaccountx  Change Toolbar for Enjoy Purchase Req. - Account Assignment
*   praddrdelivery =            " bapimerqaddrdelivery  PO Item: Address Structure BAPIADDR1 for Inbound Delivery
*   pritemtext =                " bapimereqitemtext  Transfer Structure for Enjoy Purchase Req. - Item Text
*   prheadertext =              " bapimereqheadtext  Change Toolbar for Enjoy Purchase Req. - Header Text
*   extensionin =               " bapiparex     Reference Structure for BAPI Parameters EXTENSIONIN/EXTENSIONOUT
*   extensionout =              " bapiparex     Reference Structure for BAPI Parameters EXTENSIONIN/EXTENSIONOUT
*   prversion =                 " bapimereqdcm  Version Data for Purchase Requisition Item (BAPI)
*   prversionx =                " bapimereqdcmx  Version Data for Purchase Requisition Item (BAPI)
*   allversions =               " bapimedcm_allversions  Version Management - All Version Data
*   prcomponents =              " bapimereqcomponent  BAPI Structure for Components
*   prcomponentsx =             " bapimereqcomponentx  Update Information for Components in BUS2012 API
*   serviceoutline =            " bapi_srv_outline
*   serviceoutlinex =           " bapi_srv_outlinex
*   servicelines =              " bapi_srv_service_line
*   servicelinesx =             " bapi_srv_service_linex
*   servicelimit =              " bapi_srv_limit_data
*   servicelimitx =             " bapi_srv_limit_datax
*   servicecontractlimits =     " bapi_srv_contract_limits
*   servicecontractlimitsx =    " bapi_srv_contract_limitsx
*   serviceaccount =            " bapi_srv_acc_data
*   serviceaccountx =           " bapi_srv_acc_datax
*   servicelongtexts =          " bapi_srv_longtexts
*   serialnumber =              " bapimereqserialno  Serial Numbers in Purchase Requisition BAPI
*   serialnumberx =             " bapimereqserialnox  Change Parameter: Serial Numbers in Purch. Requisition BAPI
    .  "  BAPI_PR_CREATE

ABAP code example for Function Module BAPI_PR_CREATE





The ABAP code below is a full code listing to execute function module BAPI_PR_CREATE including all data declarations. The code uses the latest in-line data DECLARATION SYNTAX but I have included an ABAP code snippet at the end to show how declarations would look using the original method of declaring data variables up front. This will allow you to compare and fully understand the new inline method. Please note some of the newer syntax such as the @DATA is not available until a later 4.70 service pack (SP8).

DATA:
ld_number  TYPE BAPIMEREQHEADER-PREQ_NO ,
ld_prheaderexp  TYPE BAPIMEREQHEADER ,
it_return  TYPE STANDARD TABLE OF BAPIRET2,"TABLES PARAM
wa_return  LIKE LINE OF it_return ,
it_pritem  TYPE STANDARD TABLE OF BAPIMEREQITEMIMP,"TABLES PARAM
wa_pritem  LIKE LINE OF it_pritem ,
it_pritemx  TYPE STANDARD TABLE OF BAPIMEREQITEMX,"TABLES PARAM
wa_pritemx  LIKE LINE OF it_pritemx ,
it_pritemexp  TYPE STANDARD TABLE OF BAPIMEREQITEM,"TABLES PARAM
wa_pritemexp  LIKE LINE OF it_pritemexp ,
it_pritemsource  TYPE STANDARD TABLE OF BAPIMEREQSOURCE,"TABLES PARAM
wa_pritemsource  LIKE LINE OF it_pritemsource ,
it_praccount  TYPE STANDARD TABLE OF BAPIMEREQACCOUNT,"TABLES PARAM
wa_praccount  LIKE LINE OF it_praccount ,
it_praccountproitsegment  TYPE STANDARD TABLE OF BAPIMEREQACCOUNTPROFITSEG,"TABLES PARAM
wa_praccountproitsegment  LIKE LINE OF it_praccountproitsegment ,
it_praccountx  TYPE STANDARD TABLE OF BAPIMEREQACCOUNTX,"TABLES PARAM
wa_praccountx  LIKE LINE OF it_praccountx ,
it_praddrdelivery  TYPE STANDARD TABLE OF BAPIMERQADDRDELIVERY,"TABLES PARAM
wa_praddrdelivery  LIKE LINE OF it_praddrdelivery ,
it_pritemtext  TYPE STANDARD TABLE OF BAPIMEREQITEMTEXT,"TABLES PARAM
wa_pritemtext  LIKE LINE OF it_pritemtext ,
it_prheadertext  TYPE STANDARD TABLE OF BAPIMEREQHEADTEXT,"TABLES PARAM
wa_prheadertext  LIKE LINE OF it_prheadertext ,
it_extensionin  TYPE STANDARD TABLE OF BAPIPAREX,"TABLES PARAM
wa_extensionin  LIKE LINE OF it_extensionin ,
it_extensionout  TYPE STANDARD TABLE OF BAPIPAREX,"TABLES PARAM
wa_extensionout  LIKE LINE OF it_extensionout ,
it_prversion  TYPE STANDARD TABLE OF BAPIMEREQDCM,"TABLES PARAM
wa_prversion  LIKE LINE OF it_prversion ,
it_prversionx  TYPE STANDARD TABLE OF BAPIMEREQDCMX,"TABLES PARAM
wa_prversionx  LIKE LINE OF it_prversionx ,
it_allversions  TYPE STANDARD TABLE OF BAPIMEDCM_ALLVERSIONS,"TABLES PARAM
wa_allversions  LIKE LINE OF it_allversions ,
it_prcomponents  TYPE STANDARD TABLE OF BAPIMEREQCOMPONENT,"TABLES PARAM
wa_prcomponents  LIKE LINE OF it_prcomponents ,
it_prcomponentsx  TYPE STANDARD TABLE OF BAPIMEREQCOMPONENTX,"TABLES PARAM
wa_prcomponentsx  LIKE LINE OF it_prcomponentsx ,
it_serviceoutline  TYPE STANDARD TABLE OF BAPI_SRV_OUTLINE,"TABLES PARAM
wa_serviceoutline  LIKE LINE OF it_serviceoutline ,
it_serviceoutlinex  TYPE STANDARD TABLE OF BAPI_SRV_OUTLINEX,"TABLES PARAM
wa_serviceoutlinex  LIKE LINE OF it_serviceoutlinex ,
it_servicelines  TYPE STANDARD TABLE OF BAPI_SRV_SERVICE_LINE,"TABLES PARAM
wa_servicelines  LIKE LINE OF it_servicelines ,
it_servicelinesx  TYPE STANDARD TABLE OF BAPI_SRV_SERVICE_LINEX,"TABLES PARAM
wa_servicelinesx  LIKE LINE OF it_servicelinesx ,
it_servicelimit  TYPE STANDARD TABLE OF BAPI_SRV_LIMIT_DATA,"TABLES PARAM
wa_servicelimit  LIKE LINE OF it_servicelimit ,
it_servicelimitx  TYPE STANDARD TABLE OF BAPI_SRV_LIMIT_DATAX,"TABLES PARAM
wa_servicelimitx  LIKE LINE OF it_servicelimitx ,
it_servicecontractlimits  TYPE STANDARD TABLE OF BAPI_SRV_CONTRACT_LIMITS,"TABLES PARAM
wa_servicecontractlimits  LIKE LINE OF it_servicecontractlimits ,
it_servicecontractlimitsx  TYPE STANDARD TABLE OF BAPI_SRV_CONTRACT_LIMITSX,"TABLES PARAM
wa_servicecontractlimitsx  LIKE LINE OF it_servicecontractlimitsx ,
it_serviceaccount  TYPE STANDARD TABLE OF BAPI_SRV_ACC_DATA,"TABLES PARAM
wa_serviceaccount  LIKE LINE OF it_serviceaccount ,
it_serviceaccountx  TYPE STANDARD TABLE OF BAPI_SRV_ACC_DATAX,"TABLES PARAM
wa_serviceaccountx  LIKE LINE OF it_serviceaccountx ,
it_servicelongtexts  TYPE STANDARD TABLE OF BAPI_SRV_LONGTEXTS,"TABLES PARAM
wa_servicelongtexts  LIKE LINE OF it_servicelongtexts ,
it_serialnumber  TYPE STANDARD TABLE OF BAPIMEREQSERIALNO,"TABLES PARAM
wa_serialnumber  LIKE LINE OF it_serialnumber ,
it_serialnumberx  TYPE STANDARD TABLE OF BAPIMEREQSERIALNOX,"TABLES PARAM
wa_serialnumberx  LIKE LINE OF it_serialnumberx .

DATA(ld_prheader) = 'Check type of data required'.
DATA(ld_prheaderx) = 'Check type of data required'.

DATA(ld_testrun) = some text here

"populate fields of struture and append to itab
append wa_return to it_return.

"populate fields of struture and append to itab
append wa_pritem to it_pritem.

"populate fields of struture and append to itab
append wa_pritemx to it_pritemx.

"populate fields of struture and append to itab
append wa_pritemexp to it_pritemexp.

"populate fields of struture and append to itab
append wa_pritemsource to it_pritemsource.

"populate fields of struture and append to itab
append wa_praccount to it_praccount.

"populate fields of struture and append to itab
append wa_praccountproitsegment to it_praccountproitsegment.

"populate fields of struture and append to itab
append wa_praccountx to it_praccountx.

"populate fields of struture and append to itab
append wa_praddrdelivery to it_praddrdelivery.

"populate fields of struture and append to itab
append wa_pritemtext to it_pritemtext.

"populate fields of struture and append to itab
append wa_prheadertext to it_prheadertext.

"populate fields of struture and append to itab
append wa_extensionin to it_extensionin.

"populate fields of struture and append to itab
append wa_extensionout to it_extensionout.

"populate fields of struture and append to itab
append wa_prversion to it_prversion.

"populate fields of struture and append to itab
append wa_prversionx to it_prversionx.

"populate fields of struture and append to itab
append wa_allversions to it_allversions.

"populate fields of struture and append to itab
append wa_prcomponents to it_prcomponents.

"populate fields of struture and append to itab
append wa_prcomponentsx to it_prcomponentsx.

"populate fields of struture and append to itab
append wa_serviceoutline to it_serviceoutline.

"populate fields of struture and append to itab
append wa_serviceoutlinex to it_serviceoutlinex.

"populate fields of struture and append to itab
append wa_servicelines to it_servicelines.

"populate fields of struture and append to itab
append wa_servicelinesx to it_servicelinesx.

"populate fields of struture and append to itab
append wa_servicelimit to it_servicelimit.

"populate fields of struture and append to itab
append wa_servicelimitx to it_servicelimitx.

"populate fields of struture and append to itab
append wa_servicecontractlimits to it_servicecontractlimits.

"populate fields of struture and append to itab
append wa_servicecontractlimitsx to it_servicecontractlimitsx.

"populate fields of struture and append to itab
append wa_serviceaccount to it_serviceaccount.

"populate fields of struture and append to itab
append wa_serviceaccountx to it_serviceaccountx.

"populate fields of struture and append to itab
append wa_servicelongtexts to it_servicelongtexts.

"populate fields of struture and append to itab
append wa_serialnumber to it_serialnumber.

"populate fields of struture and append to itab
append wa_serialnumberx to it_serialnumberx. . CALL FUNCTION 'BAPI_PR_CREATE' * EXPORTING * prheader = ld_prheader * prheaderx = ld_prheaderx * testrun = ld_testrun IMPORTING number = ld_number prheaderexp = ld_prheaderexp TABLES * return = it_return pritem = it_pritem * pritemx = it_pritemx * pritemexp = it_pritemexp * pritemsource = it_pritemsource * praccount = it_praccount * praccountproitsegment = it_praccountproitsegment * praccountx = it_praccountx * praddrdelivery = it_praddrdelivery * pritemtext = it_pritemtext * prheadertext = it_prheadertext * extensionin = it_extensionin * extensionout = it_extensionout * prversion = it_prversion * prversionx = it_prversionx * allversions = it_allversions * prcomponents = it_prcomponents * prcomponentsx = it_prcomponentsx * serviceoutline = it_serviceoutline * serviceoutlinex = it_serviceoutlinex * servicelines = it_servicelines * servicelinesx = it_servicelinesx * servicelimit = it_servicelimit * servicelimitx = it_servicelimitx * servicecontractlimits = it_servicecontractlimits * servicecontractlimitsx = it_servicecontractlimitsx * serviceaccount = it_serviceaccount * serviceaccountx = it_serviceaccountx * servicelongtexts = it_servicelongtexts * serialnumber = it_serialnumber * serialnumberx = it_serialnumberx . " BAPI_PR_CREATE
IF SY-SUBRC EQ 0. "All OK ENDIF.







ABAP code to compare 7.40 inline data declaration with original syntax

The below ABAP code uses the older none in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. It may also be useful if you are using an older version of SAP as some of the newer syntax above, such as the @DATA is not available until 4.70 EHP 8.

DATA:
ld_number  TYPE BAPIMEREQHEADER-PREQ_NO ,
ld_prheader  TYPE BAPIMEREQHEADER ,
it_return  TYPE STANDARD TABLE OF BAPIRET2 ,
wa_return  LIKE LINE OF it_return,
ld_prheaderexp  TYPE BAPIMEREQHEADER ,
ld_prheaderx  TYPE BAPIMEREQHEADERX ,
it_pritem  TYPE STANDARD TABLE OF BAPIMEREQITEMIMP ,
wa_pritem  LIKE LINE OF it_pritem,
ld_testrun  TYPE BAPIFLAG-BAPIFLAG ,
it_pritemx  TYPE STANDARD TABLE OF BAPIMEREQITEMX ,
wa_pritemx  LIKE LINE OF it_pritemx,
it_pritemexp  TYPE STANDARD TABLE OF BAPIMEREQITEM ,
wa_pritemexp  LIKE LINE OF it_pritemexp,
it_pritemsource  TYPE STANDARD TABLE OF BAPIMEREQSOURCE ,
wa_pritemsource  LIKE LINE OF it_pritemsource,
it_praccount  TYPE STANDARD TABLE OF BAPIMEREQACCOUNT ,
wa_praccount  LIKE LINE OF it_praccount,
it_praccountproitsegment  TYPE STANDARD TABLE OF BAPIMEREQACCOUNTPROFITSEG ,
wa_praccountproitsegment  LIKE LINE OF it_praccountproitsegment,
it_praccountx  TYPE STANDARD TABLE OF BAPIMEREQACCOUNTX ,
wa_praccountx  LIKE LINE OF it_praccountx,
it_praddrdelivery  TYPE STANDARD TABLE OF BAPIMERQADDRDELIVERY ,
wa_praddrdelivery  LIKE LINE OF it_praddrdelivery,
it_pritemtext  TYPE STANDARD TABLE OF BAPIMEREQITEMTEXT ,
wa_pritemtext  LIKE LINE OF it_pritemtext,
it_prheadertext  TYPE STANDARD TABLE OF BAPIMEREQHEADTEXT ,
wa_prheadertext  LIKE LINE OF it_prheadertext,
it_extensionin  TYPE STANDARD TABLE OF BAPIPAREX ,
wa_extensionin  LIKE LINE OF it_extensionin,
it_extensionout  TYPE STANDARD TABLE OF BAPIPAREX ,
wa_extensionout  LIKE LINE OF it_extensionout,
it_prversion  TYPE STANDARD TABLE OF BAPIMEREQDCM ,
wa_prversion  LIKE LINE OF it_prversion,
it_prversionx  TYPE STANDARD TABLE OF BAPIMEREQDCMX ,
wa_prversionx  LIKE LINE OF it_prversionx,
it_allversions  TYPE STANDARD TABLE OF BAPIMEDCM_ALLVERSIONS ,
wa_allversions  LIKE LINE OF it_allversions,
it_prcomponents  TYPE STANDARD TABLE OF BAPIMEREQCOMPONENT ,
wa_prcomponents  LIKE LINE OF it_prcomponents,
it_prcomponentsx  TYPE STANDARD TABLE OF BAPIMEREQCOMPONENTX ,
wa_prcomponentsx  LIKE LINE OF it_prcomponentsx,
it_serviceoutline  TYPE STANDARD TABLE OF BAPI_SRV_OUTLINE ,
wa_serviceoutline  LIKE LINE OF it_serviceoutline,
it_serviceoutlinex  TYPE STANDARD TABLE OF BAPI_SRV_OUTLINEX ,
wa_serviceoutlinex  LIKE LINE OF it_serviceoutlinex,
it_servicelines  TYPE STANDARD TABLE OF BAPI_SRV_SERVICE_LINE ,
wa_servicelines  LIKE LINE OF it_servicelines,
it_servicelinesx  TYPE STANDARD TABLE OF BAPI_SRV_SERVICE_LINEX ,
wa_servicelinesx  LIKE LINE OF it_servicelinesx,
it_servicelimit  TYPE STANDARD TABLE OF BAPI_SRV_LIMIT_DATA ,
wa_servicelimit  LIKE LINE OF it_servicelimit,
it_servicelimitx  TYPE STANDARD TABLE OF BAPI_SRV_LIMIT_DATAX ,
wa_servicelimitx  LIKE LINE OF it_servicelimitx,
it_servicecontractlimits  TYPE STANDARD TABLE OF BAPI_SRV_CONTRACT_LIMITS ,
wa_servicecontractlimits  LIKE LINE OF it_servicecontractlimits,
it_servicecontractlimitsx  TYPE STANDARD TABLE OF BAPI_SRV_CONTRACT_LIMITSX ,
wa_servicecontractlimitsx  LIKE LINE OF it_servicecontractlimitsx,
it_serviceaccount  TYPE STANDARD TABLE OF BAPI_SRV_ACC_DATA ,
wa_serviceaccount  LIKE LINE OF it_serviceaccount,
it_serviceaccountx  TYPE STANDARD TABLE OF BAPI_SRV_ACC_DATAX ,
wa_serviceaccountx  LIKE LINE OF it_serviceaccountx,
it_servicelongtexts  TYPE STANDARD TABLE OF BAPI_SRV_LONGTEXTS ,
wa_servicelongtexts  LIKE LINE OF it_servicelongtexts,
it_serialnumber  TYPE STANDARD TABLE OF BAPIMEREQSERIALNO ,
wa_serialnumber  LIKE LINE OF it_serialnumber,
it_serialnumberx  TYPE STANDARD TABLE OF BAPIMEREQSERIALNOX ,
wa_serialnumberx  LIKE LINE OF it_serialnumberx.

ld_prheader = 'Check type of data required'.

"populate fields of struture and append to itab
append wa_return to it_return.
ld_prheaderx = 'Check type of data required'.

"populate fields of struture and append to itab
append wa_pritem to it_pritem.

ld_testrun = some text here

"populate fields of struture and append to itab
append wa_pritemx to it_pritemx.

"populate fields of struture and append to itab
append wa_pritemexp to it_pritemexp.

"populate fields of struture and append to itab
append wa_pritemsource to it_pritemsource.

"populate fields of struture and append to itab
append wa_praccount to it_praccount.

"populate fields of struture and append to itab
append wa_praccountproitsegment to it_praccountproitsegment.

"populate fields of struture and append to itab
append wa_praccountx to it_praccountx.

"populate fields of struture and append to itab
append wa_praddrdelivery to it_praddrdelivery.

"populate fields of struture and append to itab
append wa_pritemtext to it_pritemtext.

"populate fields of struture and append to itab
append wa_prheadertext to it_prheadertext.

"populate fields of struture and append to itab
append wa_extensionin to it_extensionin.

"populate fields of struture and append to itab
append wa_extensionout to it_extensionout.

"populate fields of struture and append to itab
append wa_prversion to it_prversion.

"populate fields of struture and append to itab
append wa_prversionx to it_prversionx.

"populate fields of struture and append to itab
append wa_allversions to it_allversions.

"populate fields of struture and append to itab
append wa_prcomponents to it_prcomponents.

"populate fields of struture and append to itab
append wa_prcomponentsx to it_prcomponentsx.

"populate fields of struture and append to itab
append wa_serviceoutline to it_serviceoutline.

"populate fields of struture and append to itab
append wa_serviceoutlinex to it_serviceoutlinex.

"populate fields of struture and append to itab
append wa_servicelines to it_servicelines.

"populate fields of struture and append to itab
append wa_servicelinesx to it_servicelinesx.

"populate fields of struture and append to itab
append wa_servicelimit to it_servicelimit.

"populate fields of struture and append to itab
append wa_servicelimitx to it_servicelimitx.

"populate fields of struture and append to itab
append wa_servicecontractlimits to it_servicecontractlimits.

"populate fields of struture and append to itab
append wa_servicecontractlimitsx to it_servicecontractlimitsx.

"populate fields of struture and append to itab
append wa_serviceaccount to it_serviceaccount.

"populate fields of struture and append to itab
append wa_serviceaccountx to it_serviceaccountx.

"populate fields of struture and append to itab
append wa_servicelongtexts to it_servicelongtexts.

"populate fields of struture and append to itab
append wa_serialnumber to it_serialnumber.

"populate fields of struture and append to itab
append wa_serialnumberx to it_serialnumberx.

SAP Documentation for FM BAPI_PR_CREATE


You can use function module BAPI_PR_CREATE to create purchase requisitions. The BAPI uses the functionality of the single-screen ...See here for full SAP fm documentation

Contribute (Add Comments)

Please help keep this info upto date and use the comments section below to add useful hints, tips and information specific to this SAP function. This will then be available for you and other users to easily find by simply searching on the object name BAPI_PR_CREATE or its description.