Application Development and Automation 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: 
Read only

BAPI_SALESORDER_CREATEFROMDAT2 Multiple Line Items

Former Member
0 Likes
1,384

Hi

How do I implement BAPI_SALESORDER_CREATEFROMDAT2 for multiple line items.

I am currently doing this to create a new SO:

loop at it_item into wa_item where group = wa_head-group.

add 10 to lv_item.

lw_item-itm_number = lv_item.

lw_item-material = wa_item-itemupc.

append lw_item to lt_item.

lw_schdl-itm_number = lv_item.

lw_schdl-sched_line = 1.

lw_schdl-req_date = sy-datum.

lw_schdl-req_qty = wa_item-itemqty.

append lw_schdl to lt_schdl.

endloop.

It's giving a message:

E |V4 |224 |Missing item number when you changed the <

Thanks!

6 REPLIES 6
Read only

Former Member
0 Likes
852

Hi,

Did you pass the schedule line X parameter ORDER_SCHEDULES_INX with the corresponding ITEM NUMBER (POSNR) and Schedule line number

Thanks

Naren

Read only

0 Likes
852

Hi Naren,

Yes I did. I have already tried passing order_itemx.

Thanks

Read only

0 Likes
852

Hi,

Can you paste your whole code.

Regards,

Atish

Read only

0 Likes
852

Here's part of the code the fills the BAPI tables

lw_head-doc_type = pa_auart.

lw_head-sales_org = pa_vkorg.

lw_head-distr_chan = pa_vtweg.

lw_head-division = pa_spart.

lw_head-purch_no_c = pa_file.

lw_head-purch_date = wa_head-postdate.

lw_headx-updateflag = 'I'.

clear lv_item.

loop at it_item into wa_item where group = wa_head-group.

add 10 to lv_item.

lw_item-itm_number = lv_item.

lw_item-material = wa_item-itemupc.

append lw_item to lt_item.

lw_schdl-itm_number = lv_item.

lw_schdl-sched_line = 1.

lw_schdl-req_date = sy-datum.

lw_schdl-req_qty = wa_item-itemqty.

append lw_schdl to lt_schdl.

endloop.

lw_part-partn_numb = lv_kunnr.

lw_part-partn_role = 'AG'.

append lw_part to lt_part.

call function 'BAPI_SALESORDER_CREATEFROMDAT2'

exporting

order_header_in = lw_head

order_header_inx = lw_headx

importing

salesdocument = lv_vbeln

tables

return = lt_ret

order_items_in = lt_item

order_partners = lt_part

order_schedules_in = lt_schdl.

Read only

Former Member
0 Likes
852

created the solution

Read only

0 Likes
852

Hi,

if u r having multiples items mantain two different flags & use command called move

one flag for header i.e 'H'

one flag for item i.e 'I'.

use loop at header table

if it_table-type data = 'H'.

move-corresponding it_ table to sales order header.

Append sales order header table.

else if it_table-typedata = 'I'

move corresponding it_table to sale sorder item.

append to sales order item.

i think it will help full for u.

reward is usefull.

thanks.

Patil.