I have to create sales order with reference to existing billing document. I have tried to following bapis. BAPISALESORDERCREATEed I have successfully created document with following details.-ORDERHEADERIN: DOCTYPE = ZRK SALESORG = 3000 DISTRCHAN = 00. 1.Go to T-code ‘SEGW’ and click on create an icon.Give the ‘Project name’ and ‘Description’. 2.Right click on Data model–Import–RFC 3.Give the Entity type name and Data sources.Give the name as function module ‘ BAPISALESORDERCREATEFROMDAT2 ‘.
BAPI_SALESORDER_CREATEFROMDAT2 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_SALESORDER_CREATEFROMDAT2 into the relevant SAP transaction such as SE37 or SE80.
Associated Function Group:2032
Released Date:02.12.1999
Processing type:Remote-Enabled
Released Date:02.12.1999
Processing type:Remote-Enabled
Pattern for FM BAPI_SALESORDER_CREATEFROMDAT2 - BAPI SALESORDER CREATEFROMDAT2
![Bapi sales order createfromdat2 create with reference Bapi sales order createfromdat2 create with reference](https://cdn.slidesharecdn.com/ss_thumbnails/youwe-sap-ecc-r3-hana-ecommerce-with-magento-mb2b-100717-1601-206-170710140253-thumbnail-4.jpg?cb=1499695603)
ABAP code example for Function Module BAPI_SALESORDER_CREATEFROMDAT2
The ABAP code below is a full code listing to execute function module BAPI_SALESORDER_CREATEFROMDAT2 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).
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_salesdocument | TYPE BAPIVBELN-VBELN , |
ld_salesdocumentin | TYPE BAPIVBELN-VBELN , |
it_return | TYPE STANDARD TABLE OF BAPIRET2 , |
wa_return | LIKE LINE OF it_return, |
ld_order_header_in | TYPE BAPISDHD1 , |
it_order_items_in | TYPE STANDARD TABLE OF BAPISDITM , |
wa_order_items_in | LIKE LINE OF it_order_items_in, |
ld_order_header_inx | TYPE BAPISDHD1X , |
it_order_items_inx | TYPE STANDARD TABLE OF BAPISDITMX , |
wa_order_items_inx | LIKE LINE OF it_order_items_inx, |
ld_sender | TYPE BAPI_SENDER , |
it_order_partners | TYPE STANDARD TABLE OF BAPIPARNR , |
wa_order_partners | LIKE LINE OF it_order_partners, |
it_order_schedules_in | TYPE STANDARD TABLE OF BAPISCHDL , |
wa_order_schedules_in | LIKE LINE OF it_order_schedules_in, |
ld_binary_relationshiptype | TYPE BAPIRELTYPE-RELTYPE , |
ld_int_number_assignment | TYPE BAPIFLAG-BAPIFLAG , |
it_order_schedules_inx | TYPE STANDARD TABLE OF BAPISCHDLX , |
wa_order_schedules_inx | LIKE LINE OF it_order_schedules_inx, |
ld_behave_when_error | TYPE BAPIFLAG-BAPIFLAG , |
it_order_conditions_in | TYPE STANDARD TABLE OF BAPICOND , |
wa_order_conditions_in | LIKE LINE OF it_order_conditions_in, |
ld_logic_switch | TYPE BAPISDLS , |
it_order_conditions_inx | TYPE STANDARD TABLE OF BAPICONDX , |
wa_order_conditions_inx | LIKE LINE OF it_order_conditions_inx, |
ld_testrun | TYPE BAPIFLAG-BAPIFLAG , |
it_order_cfgs_ref | TYPE STANDARD TABLE OF BAPICUCFG , |
wa_order_cfgs_ref | LIKE LINE OF it_order_cfgs_ref, |
ld_convert | TYPE BAPIFLAG-BAPIFLAG , |
it_order_cfgs_inst | TYPE STANDARD TABLE OF BAPICUINS , |
wa_order_cfgs_inst | LIKE LINE OF it_order_cfgs_inst, |
it_order_cfgs_part_of | TYPE STANDARD TABLE OF BAPICUPRT , |
wa_order_cfgs_part_of | LIKE LINE OF it_order_cfgs_part_of, |
it_order_cfgs_value | TYPE STANDARD TABLE OF BAPICUVAL , |
wa_order_cfgs_value | LIKE LINE OF it_order_cfgs_value, |
it_order_cfgs_blob | TYPE STANDARD TABLE OF BAPICUBLB , |
wa_order_cfgs_blob | LIKE LINE OF it_order_cfgs_blob, |
it_order_cfgs_vk | TYPE STANDARD TABLE OF BAPICUVK , |
wa_order_cfgs_vk | LIKE LINE OF it_order_cfgs_vk, |
it_order_cfgs_refinst | TYPE STANDARD TABLE OF BAPICUREF , |
wa_order_cfgs_refinst | LIKE LINE OF it_order_cfgs_refinst, |
it_order_ccard | TYPE STANDARD TABLE OF BAPICCARD , |
wa_order_ccard | LIKE LINE OF it_order_ccard, |
it_order_text | TYPE STANDARD TABLE OF BAPISDTEXT , |
wa_order_text | LIKE LINE OF it_order_text, |
it_order_keys | TYPE STANDARD TABLE OF BAPISDKEY , |
wa_order_keys | LIKE LINE OF it_order_keys, |
it_extensionin | TYPE STANDARD TABLE OF BAPIPAREX , |
wa_extensionin | LIKE LINE OF it_extensionin, |
it_partneraddresses | TYPE STANDARD TABLE OF BAPIADDR1 , |
wa_partneraddresses | LIKE LINE OF it_partneraddresses. |
ld_salesdocumentin = some text here
'populate fields of struture and append to itab
append wa_return to it_return.
ld_order_header_in = 'Check type of data required'.
'populate fields of struture and append to itab
append wa_order_items_in to it_order_items_in.
ld_order_header_inx = 'Check type of data required'.
'populate fields of struture and append to itab
append wa_order_items_inx to it_order_items_inx.
ld_sender = 'Check type of data required'.
'populate fields of struture and append to itab
append wa_order_partners to it_order_partners.
'populate fields of struture and append to itab
![Bapi_salesorder_createfromdat2 Bapi_salesorder_createfromdat2](http://saptechnical.com/Tutorials/BAPI/SalesOrder/Index.10.jpg)
append wa_order_schedules_in to it_order_schedules_in.
ld_binary_relationshiptype = some text here
ld_int_number_assignment = some text here
'populate fields of struture and append to itab
append wa_order_schedules_inx to it_order_schedules_inx.
ld_behave_when_error = some text here
'populate fields of struture and append to itab
append wa_order_conditions_in to it_order_conditions_in.
ld_logic_switch = 'Check type of data required'.
'populate fields of struture and append to itab
append wa_order_conditions_inx to it_order_conditions_inx.
ld_testrun = some text here
'populate fields of struture and append to itab
append wa_order_cfgs_ref to it_order_cfgs_ref.
ld_convert = some text here
'populate fields of struture and append to itab
append wa_order_cfgs_inst to it_order_cfgs_inst.
'populate fields of struture and append to itab
append wa_order_cfgs_part_of to it_order_cfgs_part_of.
'populate fields of struture and append to itab
append wa_order_cfgs_value to it_order_cfgs_value.
'populate fields of struture and append to itab
append wa_order_cfgs_blob to it_order_cfgs_blob.
'populate fields of struture and append to itab
append wa_order_cfgs_vk to it_order_cfgs_vk.
'populate fields of struture and append to itab
append wa_order_cfgs_refinst to it_order_cfgs_refinst.
'populate fields of struture and append to itab
append wa_order_ccard to it_order_ccard.
'populate fields of struture and append to itab
append wa_order_text to it_order_text.
'populate fields of struture and append to itab
append wa_order_keys to it_order_keys.
'populate fields of struture and append to itab
append wa_extensionin to it_extensionin.
'populate fields of struture and append to itab
append wa_partneraddresses to it_partneraddresses.
SAP Documentation for FM BAPI_SALESORDER_CREATEFROMDAT2
You can use this method to create sales orders.
You must enter at least sales order header data (via ORDER_HEADER_IN...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_SALESORDER_CREATEFROMDAT2 or its description.
BAPI_SALESORDER_CREATEFROMDAT2 - Sales order: Create Sales Order
BAPI_SALESORDER_CREATEFROMDAT1 - Sales order: Create Sales Order
BAPI_SALESORDER_CREATEBOS - Create Sales Order with BOS
BAPI_SALESORDER_CONFIRMDELVRY -
BAPI_SALESORDER_CHANGEBOS - Change sales order with BOS
BAPI_SALESORDER_CHANGE - Sales order: Change Sales Order
BAPI_SALESORDER_CREATEFROMDAT1 - Sales order: Create Sales Order
BAPI_SALESORDER_CREATEBOS - Create Sales Order with BOS
BAPI_SALESORDER_CONFIRMDELVRY -
BAPI_SALESORDER_CHANGEBOS - Change sales order with BOS
BAPI_SALESORDER_CHANGE - Sales order: Change Sales Order