Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

which is the field for Sold-to-party and ship-to-pary in BAPI

Former Member
0 Kudos

i am using BAPI_SALESORDER_CREATEFROMDAT1 This BAPI for sales order creation

but i want to pass sold-to-party and ship-to-party in Header Data

but i can't find that field in BAPI

so please suggest me

1 ACCEPTED SOLUTION

former_member188685
Active Contributor
0 Kudos

Use BAPI BAPI_SALESORDER_CREATEFROMDAT2, instead of the above BAPI.

Check this sample. Replace all the values with your test data and check it.

report  z_salesorder_create.
 
data:
  order_header_in type bapisdhd1,
  return type table of bapiret2,
  order_partners type table of bapiparnr,
  order_part     type bapiparnr,
  order_items_in type table of bapisditm,
  order_items type bapisditm,
  order_items_inx type table of bapisditmx,
  order_items_x   type bapisditmx,
  salesdocument type bapivbeln-vbeln,
  order_header_inx type bapisdhd1x.
 
order_header_inx-doc_type =   'X'.
order_header_inx-sales_org =  'X'.
order_header_inx-distr_chan = 'X'.
order_header_inx-division =   'X'.
order_header_inx-req_date_h = 'X'.
order_header_inx-purch_date = 'X'.
order_header_inx-doc_date  = 'X'.
order_header_inx-currency = 'X'.
order_header_inx-sd_doc_cat = 'X'.
 
order_header_in-doc_type =   'TA'.
order_header_in-sales_org =  '1000'.
order_header_in-distr_chan = '12'.
order_header_in-division =   '00'.
order_header_in-req_date_h = sy-datum + 7.
order_header_in-purch_date = sy-datum.
order_header_in-doc_date  = sy-datum.
order_header_in-currency = 'EUR'.
order_header_in-sd_doc_cat = 'C'.
 
order_items-itm_number = '000000'.
order_items-material = 'C-1030'.        "replace with your material and plant
order_items-plant = '1200'.
order_items-target_qty = '10'.
order_items-target_qu = 'M'.
order_items-sales_unit = 'M'.
append  order_items to order_items_in.
 
order_items_x-itm_number = '000000'.
order_items_x-material = 'X'.
order_items_x-plant = 'X'.
order_items_x-target_qty = 'X'.
order_items_x-target_qu = 'X'.
order_items_x-sales_unit = 'X'.
append  order_items_x to order_items_inx.
 
"Sold to party
order_part-partn_role =  'AG'.
order_part-partn_numb = '0000001033'.
order_part-itm_number = '000000'.
append order_part to order_partners.
 
"Ship-to party
order_part-partn_role =  'WE'.
order_part-partn_numb = '0000001033'.
order_part-itm_number = '000000'.  "<-----For header you need to mention the like this..
append order_part to order_partners.
 
call function 'BAPI_SALESORDER_CREATEFROMDAT2'
  exporting
    order_header_in               = order_header_in
    order_header_inx              = order_header_inx
 importing
   salesdocument                 = salesdocument
  tables
    return                        = return
    order_items_in                = order_items_in
    order_items_inx               = order_items_inx
    order_partners                = order_partners.
 
"Read the return with type 'S' if success then commit.
call function 'BAPI_TRANSACTION_COMMIT'

4 REPLIES 4

Former Member
0 Kudos

hii

you can refer to following link for example of this bapi

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/how%2bto%2bdefine%2bimport%2bdata%2bto%2...

regards

twinkal

Former Member
0 Kudos

Hi,

Fill one internal table of structgure 'bapiparnr' with Partner Function and Customer Number and pass this internal table to Order_partners of the tables paratmers of the FM.

Rgds,

Bujji

former_member188685
Active Contributor
0 Kudos

Use BAPI BAPI_SALESORDER_CREATEFROMDAT2, instead of the above BAPI.

Check this sample. Replace all the values with your test data and check it.

report  z_salesorder_create.
 
data:
  order_header_in type bapisdhd1,
  return type table of bapiret2,
  order_partners type table of bapiparnr,
  order_part     type bapiparnr,
  order_items_in type table of bapisditm,
  order_items type bapisditm,
  order_items_inx type table of bapisditmx,
  order_items_x   type bapisditmx,
  salesdocument type bapivbeln-vbeln,
  order_header_inx type bapisdhd1x.
 
order_header_inx-doc_type =   'X'.
order_header_inx-sales_org =  'X'.
order_header_inx-distr_chan = 'X'.
order_header_inx-division =   'X'.
order_header_inx-req_date_h = 'X'.
order_header_inx-purch_date = 'X'.
order_header_inx-doc_date  = 'X'.
order_header_inx-currency = 'X'.
order_header_inx-sd_doc_cat = 'X'.
 
order_header_in-doc_type =   'TA'.
order_header_in-sales_org =  '1000'.
order_header_in-distr_chan = '12'.
order_header_in-division =   '00'.
order_header_in-req_date_h = sy-datum + 7.
order_header_in-purch_date = sy-datum.
order_header_in-doc_date  = sy-datum.
order_header_in-currency = 'EUR'.
order_header_in-sd_doc_cat = 'C'.
 
order_items-itm_number = '000000'.
order_items-material = 'C-1030'.        "replace with your material and plant
order_items-plant = '1200'.
order_items-target_qty = '10'.
order_items-target_qu = 'M'.
order_items-sales_unit = 'M'.
append  order_items to order_items_in.
 
order_items_x-itm_number = '000000'.
order_items_x-material = 'X'.
order_items_x-plant = 'X'.
order_items_x-target_qty = 'X'.
order_items_x-target_qu = 'X'.
order_items_x-sales_unit = 'X'.
append  order_items_x to order_items_inx.
 
"Sold to party
order_part-partn_role =  'AG'.
order_part-partn_numb = '0000001033'.
order_part-itm_number = '000000'.
append order_part to order_partners.
 
"Ship-to party
order_part-partn_role =  'WE'.
order_part-partn_numb = '0000001033'.
order_part-itm_number = '000000'.  "<-----For header you need to mention the like this..
append order_part to order_partners.
 
call function 'BAPI_SALESORDER_CREATEFROMDAT2'
  exporting
    order_header_in               = order_header_in
    order_header_inx              = order_header_inx
 importing
   salesdocument                 = salesdocument
  tables
    return                        = return
    order_items_in                = order_items_in
    order_items_inx               = order_items_inx
    order_partners                = order_partners.
 
"Read the return with type 'S' if success then commit.
call function 'BAPI_TRANSACTION_COMMIT'

Former Member
0 Kudos

thankx everybody i got the answer