Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

bapi FM to create new line item in the existing sale order

hello gurus,

I want to create new line item(s) in the existing SO.

i am not sure what bapi FM i need to use.

i am currently using BAPI_SALESORDER_CHANGE its creating new entry but did not update qty field.

i tried other FM bapi_salesorder_createfromdat1 also but that didt worked for me, the three star lines are for this FM.

below im sending my prg code also

data: salesdocument like bapivbeln occurs 0 with header line,

order_header_in like bapisdh1 occurs 0 with header line,

order_header_inx like bapisdh1x occurs 0 with header line,

order_item_in like bapisditm occurs 0 with header line,

order_item_inx like bapisditmx occurs 0 with header line,

partners like bapiparnr occurs 0 with header line,

schedule_lines like bapischdl occurs 0 with header line,

schedule_linesx like bapischdlx occurs 0 with header line,

partnerchanges like BAPIPARNRC occurs 0 with header line,

return like bapiret2 occurs 0 with header line.

***order_header_in like bapisdhead occurs 0 with header line,

***order_header_inx like bapisdh1x occurs 0 with header line,

***order_item_in like bapiitemin occurs 0 with header line,

***order_item_inx like bapisditmx occurs 0 with header line,

***partners like bapipartnr occurs 0 with header line,

***schedule_lines like bapischdl occurs 0 with header line,

***schedule_linesx like bapischdlx occurs 0 with header line,

***partnerchanges like BAPIPARNRC occurs 0 with header line,

***return like bapireturn1 occurs 0 with header line.

salesdocument-vbeln = '0001002356'.

append salesdocument.

order_header_inx-updateflag = 'U'.

append order_header_inx.

***order_header_in-sales_org = '1000'.

***order_header_in-distr_chan = '07'.

***order_header_in-division = '01'.

***order_header_in-doc_type = 'ZAIR'.

*order_header_in-purch_no_c = 'asadsa'.

*order_header_in-purch_date = '20060101'.

*order_header_in-req_date_h = '20060202'.

***append order_header_in.

order_item_inx-updateflag = 'I'.

order_item_inx-material = 'X'.

order_item_inx-plant = 'X'.

*ORDER_ITEM_INX-target_qty = 'X'.

*order_item_inx-target_qu = 'X'.

*order_item_inx-sales_unit = 'X'.

*order_item_inx-item_categ = 'X'.

*order_item_inx-part_dlv = 'X'.

order_item_inx-rnddlv_qty = 'X'.

order_item_inx-comp_quant = 'X'.

order_item_inx-comp_quant = 'X'.

order_item_inx-fixed_quan = 'X'.

order_item_inx-fixdat_qty = 'X'.

order_item_inx-ordcomp_in = 'X'.

order_item_inx-itm_number = '000130'. " "v_posnr.

append order_item_inx.

schedule_linesx-updateflag = 'I'.

schedule_linesx-req_qty = 'X'.

schedule_linesx-itm_number = '000130'. " " v_posnr.

*

SCHEDULE_LINESx-SCHED_LINE = '0001'.

*

append schedule_linesx.

order_item_in-itm_number = '000130'. "v_posnr.

order_item_in-material = 'CL300-CO'.

*order_item_in-material = 'LRX111:88308'.

order_item_in-target_qty = '3'.

*order_item_in-part_dlv = 'X'.

order_item_in-rnddlv_qty = '3'.

order_item_in-comp_quant = '3'.

order_item_in-comp_quant = '3'.

order_item_in-fixed_quan = 'X'.

order_item_in-fixdat_qty = 'X'.

order_item_in-ordcomp_in = 'X'.

ORDER_ITEM_IN-target_qu = '3'.

*order_item_in-sales_unit = 'EA'.

*order_item_in-item_categ = 'ZTAG'.

order_item_in-plant = '1003'.

append order_item_in.

schedule_lines-sched_line = '0001'.

schedule_lines-itm_number = '000130'. "v_posnr.

schedule_lines-req_qty = '3'.

*

append schedule_lines.

***partners-partn_role = 'SP'.

***partners-partn_numb = '10156'.

***

***append partners.

      • Calling the function module updating the salesorder.

**CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT1'

    • EXPORTING

    • ORDER_HEADER_IN = order_header_in

      • WITHOUT_COMMIT = ' '

      • CONVERT_PARVW_AUART = ' '

      • IMPORTING

      • SALESDOCUMENT =

      • SOLD_TO_PARTY =

      • SHIP_TO_PARTY =

      • BILLING_PARTY =

      • RETURN = return

      • TABLES

      • ORDER_ITEMS_IN = order_item_in

      • ORDER_PARTNERS = partners

.

call function 'BAPI_SALESORDER_CHANGE'

exporting

salesdocument = salesdocument

order_header_in = order_header_in

order_header_inx = order_header_inx

tables

return = return

order_item_in = order_item_in

order_item_inx = order_item_inx

SCHEDULE_LINES = schedule_lines

SCHEDULE_LINESX = schedule_linesx

i allready tried other threads but nothing useful.

will reward point

thanks

Mandy

Tags:
Former Member
replied

Please uncomment this:

ORDER_ITEM_INX-target_qty = 'X'.

You can check the 2nd example in this link for your reference.

http://sap4.com/wiki/index.php?title=BAPI_SALESORDER_CHANGE

Regards,

Naimesh Patel

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question