Create Sales Order (BAPI_SALESORDER_CREATEFROMDAT2) with BAPI Extension By Ugur Baris Turkeli, Istanbul Our client had a requirement to create customer sales orders using BAPI function moduleBAPI_SALESORDER_CREATEFROMDAT2 with using custom fields (ZZ* or YY* fields) which are appended on VBAP table with using append structure. We can easily create sales order with using standard fields via BAPI but as per requirement we need to use extension of BAPI_SALESORDER_CREATEFROMDAT2 for 13 customize fields. Steps for BAPI Extension: Append ZAVBAP structure in VBAP table with 13 customize fields. Fields must begin with ZZ* or YY* naming .
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Create Sales Order (BAPI_SALESORDER_CREATEFROMDAT2) with BAPI Extension
By Ugur Baris Turkeli, Istanbul
Our client had a requirement to create customer sales orders using BAPI function moduleBAPI_SALESORDER_CREATEFROMDAT2 with using custom fields (ZZ* or YY* fields) which are appended on VBAP table with using append structure.
We can easily create sales order with using standard fields via BAPI but as per requirement we need to use extension of BAPI_SALESORDER_CREATEFROMDAT2 for 13 customize fields.
Steps for BAPI Extension:
Append ZAVBAP structure in VBAP table with 13 customize fields. Fields must begin with ZZ* or YY* naming .
In BAPI_SALESORDER_CREATEFROMDAT2 we need to use EXTENSIONIN parameter for BAPI extension
You can use this parameter to transfer user-specific enhancements to a BAPI. The customer has to complete the EXTENSION structure and the system automatically continues processing it. If you have not defined any user-specific fields, then you can transfer a blank EXTENSIONIN structure. You can use also this extension VBAK, VBAP, VBEP tables.
Because the BAPIs work with checkboxes, you must also define a customize structure (ZABAPE_VBAPX) checkbox for the customer structure. It should be structured like this
Define these customer structures in the structures VBAPKOZ and VBAPKOZX using INCLUDE or APPEND.
Add the customer structures to the BAPE_VBAP and BAPE_VBAPX BAPI structures using the APPEND technique.
Adjust the following structures for customer enhancements to table VBAP:
a) VBAPKOZ
b) VBAPKOZX
c) BAPE_VBAP
d) BAPE_VBAPX
If you need to use custom fields for VBAK you must adjust the following structures for customer enhancements to table VBAK:
a) VBAKKOZ
b) VBAKKOZX
c) BAPE_VBAK
d) BAPE_VBAKX
If you need to use custom fields for VBEP you must adjust the following structures for customer enhancements to table VBEP:
a) VBEPKOZ
b) VBEPKOZX
c) BAPE_VBEP
d) BAPE_VBEPX
Generally, the data should be added to the BAPI interface in the internal communication structures (VBAKKOM, and so on). There, you can process the data in the SD tables (VBAK, and so on).
If the EXTENSIONIN parameter contains customer data, you must complete at least the key fields in the relevant standard parameters.
This is a simple ABAP code how to use extension table with BAPI
data: lv_salesdocument like bapivbeln-vbeln, ls_order_header_in type bapisdhd1 , ls_order_header_inx type bapisdhd1x, lt_return type table of bapiret2 with header line, lt_items_in type table of bapisditm with header line, lt_items_inx type table of bapisditmx with header line, lt_partners type table of bapiparnr with header line, lt_schedules_in type table of bapischdl with header line, lt_schedules_inx type table of bapischdlx with header line, lt_order_conditions_in type table of bapicond with header line, lt_order_conditions_inx type table of bapicondx with header line, lt_extensionin type table of bapiparex with header line, lwa_extensionin type bapiparex , lt_bape_vbap type table of bape_vbap with header line, lwa_bape_vbap type bape_vbap, lt_bape_vbapx type table of bape_vbapx with header line, lwa_bape_vbapx type bape_vbapx.
move 'BAPE_VBAPX' to lwa_extensionin-structure. move lwa_bape_vbapx to lwa_extensionin-valuepart1. append lwa_extensionin to lt_extensionin. clear lt_extensionin.