cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI_SALESORDER_CREATEFROMDAT2

Former Member
0 Kudos

hi all

i am using BAPI_SALESORDER_CREATEFROMDAT2 .

at the end i am getting an error "Sales Document was not changed"

also what should be the mapping for SHIP-TO- PARTY and SOLD-TO PARTY.

thanks in advance

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

hi all

Can anyone plz mail me the code for BAPI_SALESORDER_CREATEFROMDAT2 where multiple item level data are used.

former_member186078
Active Participant
0 Kudos

Hi Neha,

Following the sample code for filling the Multiple items data for the required BAPI.

DATA:

lw_item TYPE i,

lfs_items LIKE bapisditm,

lfs_itemsx LIKE bapisditmx.

CONSTANTS:

lc_x TYPE c VALUE 'X'.

REFRESH:

t_bapisditm,

t_bapisditmx.

CLEAR:

w_matnr,

w_sernr.

LOOP AT pv_t_comar_items_m INTO fs_comar_items.

ADD c_10 TO lw_item.

MOVE:

lw_item TO lfs_items-itm_number,

lw_item TO lfs_itemsx-itm_number.

IF sy-tabix EQ c_1.

MOVE:

fs_comar_items-ordering_code TO w_matnr,

fs_comar_items-prod_serial_num TO w_sernr.

ENDIF. " IF SY-TABIX EQ C_1....

IF fs_comar_items-ordering_code IS NOT INITIAL.

MOVE:

fs_comar_items-ordering_code TO lfs_items-material,

lc_x TO lfs_itemsx-material.

ENDIF. " IF FS_COMAR_ITEMS-.....

IF fs_comar_items-quantity IS NOT INITIAL.

MOVE:

fs_comar_items-quantity TO lfs_items-target_qty,

lc_x TO lfs_itemsx-target_qty.

ENDIF. " IF FS_COMAR_ITEMS-.....

MOVE:

pv_plant TO lfs_items-plant,

lc_x TO lfs_itemsx-plant.

MOVE:

w_lgort TO lfs_items-store_loc,

lc_x TO lfs_itemsx-store_loc,

w_item_cat TO lfs_items-item_categ,

lc_x TO lfs_itemsx-item_categ.

APPEND lfs_items TO t_bapisditm.

APPEND lfs_itemsx TO t_bapisditmx.

ENDLOOP. " LOOP AT PV_T_COMAR_ITEMS_M....

In the above code, PV_T_COMAR_ITEMS_M is the internal table where I have filled all its Items. We need to pass these tables to BAPISDITM and BAPISDITMX structures. Hope, this might solve you doubt of passing the important fields to the function module. Please let me know if you require any more information.

Former Member
0 Kudos

can u plz simplify ur example....wat is the use of :

variable:- fs_itemsx LIKE bapisditmx.

Also help me tat we r not passing plant thru FM,but for creation of sales order plant is required....plz explaing me......with simple example with all variables decalarition with respective to multiple materials .

Also Ship to party is required when we create SAles order...but whil using this BAPI.....Sold to party & ship to party would be same.If we have to change the parties thn how to do

Former Member
0 Kudos

can u plz simplify ur example....wat is the use of :

variable:- fs_itemsx LIKE bapisditmx.

Also help me tat we r not passing plant thru FM,but for creation of sales order plant is required....plz explaing me......with simple example with all variables decalarition with respective to multiple materials .

Also Ship to party is required when we create SAles order...but whil using this BAPI.....Sold to party & ship to party would be same.If we have to change the parties thn how to do

Former Member
0 Kudos

Neha, Are you using the commit work command or the commit BAPI? Make sure that you call commit work after the BAPI , then and onlly then the data will be saved otherwise not. Let me know if you need more inputs.

Former Member
0 Kudos

Hi all

I am using Bapi_Salesorder_createFromdat2.

I have multiple item data so what should i do for this.

thanks in advance.

regards

neha kapoor

Former Member
0 Kudos

Hi,

For creating multiple items,you can pass data thro'

Tables parameter of ORDER_ITEMS_IN of this BAPI.

Regds,

Akshay

former_member181962
Active Contributor
0 Kudos

Here is some sample code:

  • Order header

l_order_header-doc_type = 'ZQBV'.

l_order_header-distr_chan = '10'.

l_order_header-division = '00'.

if g_qals-werk eq '1100'.

l_order_header-sales_org = '1000'.

else.

if g_qals-werk eq '3100'.

l_order_header-sales_org = '3000'.

else.

message i001(00) with text-005.

endif.

endif.

l_order_header-purch_no_c = g_qals-prueflos. " <= lot

  • Partner data

l_order_partners-partn_role = 'AG'.

l_order_partners-partn_numb = g_qals-kunnr.

append l_order_partners to it_order_partners.

  • Order items => only one

l_order_items-itm_number = 10.

l_order_items-material = g_qals-matnr.

l_order_items-target_qty = 1.

append l_order_items to it_order_items.

  • Schedules for quantity

l_order_schdl-itm_number = 10.

l_order_schdl-req_qty = 1. " <= only 1 !

append l_order_schdl to it_order_schdl.

  • Conditions for value

l_order_conditions-itm_number = 10.

l_order_conditions-cond_type = 'PR00'.

l_order_conditions-cond_value = g_effort_sum.

l_order_conditions-currency = g_effort_unit.

append l_order_conditions to it_order_conditions.

  • BAPI to create sales order

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'

EXPORTING

  • SALESDOCUMENTIN =

ORDER_HEADER_IN = l_order_header

  • ORDER_HEADER_INX =

  • SENDER =

  • BINARY_RELATIONSHIPTYPE =

  • INT_NUMBER_ASSIGNMENT =

  • BEHAVE_WHEN_ERROR =

  • LOGIC_SWITCH =

  • TESTRUN =

  • CONVERT = ' '

IMPORTING

SALESDOCUMENT = l_salesdocument

TABLES

RETURN = it_return

ORDER_ITEMS_IN = it_order_items

  • ORDER_ITEMS_INX =

ORDER_PARTNERS = it_order_partners

ORDER_SCHEDULES_IN = it_order_schdl

  • ORDER_SCHEDULES_INX =

ORDER_CONDITIONS_IN = it_order_conditions

  • ORDER_CONDITIONS_INX =

  • ORDER_CFGS_REF =

  • ORDER_CFGS_INST =

  • ORDER_CFGS_PART_OF =

  • ORDER_CFGS_VALUE =

  • ORDER_CFGS_BLOB =

  • ORDER_CFGS_VK =

  • ORDER_CFGS_REFINST =

  • ORDER_CCARD =

  • ORDER_TEXT =

  • ORDER_KEYS =

  • EXTENSIONIN =

  • PARTNERADDRESSES =

.

if not l_salesdocument is initial.

  • order successfully created

message i001(00) with text-001 l_salesdocument.

endif.

endif.

Regards,

Ravi

Former Member
0 Kudos

hi

good

herewith i am giving some of the links related to the BAPI_SALESORDER_CREATEFROMDAT2.

http://www.sapgenie.com/its/development.htm

http://www.henrikfrank.dk/abapexamples/Java/sapjava_createsalesorder.htm

THANKS

MRUTYUN

Former Member
0 Kudos

Hi,

SHIP-TO-PARTY & SOLD-TO-PARTY contains information of Partner.

Or may be Customers Numbers. This depends on the process your business is following.

Regarding the message,

Well I can just anticipate that you did not pass any new/changed data in the the BAPI for that document number.

Rohit

former_member181962
Active Contributor
0 Kudos

This is what, the FM documentation says:

<i><b>"Document Partner

Description

This table parameter is used to enter partners such as sold-to party, or ship-to party, both at header and item level.

The minimum requirement is that the sold-to party is entered at header level. Additional partner functions can then be automatically determined.

You can also enter different addresses in the structure.

"</b></i>

Regards,

Ravi