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: 

help to change the price in sales order create bapi

Former Member
0 Kudos

hi all,

kindly do the needful, i am unable change the price of an item when i am creating salesorder using bapi salesorder create bapi.

here i am submitting the code.

<b>

report zmybapi1 .

data : my_order_header_in like bapisdhd1 occurs 0 with header line,

my_order_header_ix like bapisdhd1x occurs 0 with header line.

data : my_orderitemsin like bapisditm occurs 0 with header line,

my_orderitemsix like bapisditmx occurs 0 with header line.

data : my_order_partners like bapiparnr occurs 0 with header line.

data : my_return like bapiret2 occurs 0 with header line.

data : w_vbeln like bapivbeln-vbeln.

data:

my_orderschedulesin like bapischdl occurs 0 with header line,

my_orderschedulesinx like bapischdlx occurs 0 with header line.

data : my_orderconditionsin like bapicond occurs 0 with header line,

my_orderconditionsinx like bapicondx occurs 0 with header line.

start-of-selection.

  • this is to assign values to internal table my_order_header_in

my_order_header_in-doc_type = 'TA'.

my_order_header_in-sales_org = 'JNJ1'.

my_order_header_in-distr_chan = '02'.

my_order_header_in-division = 'J1'.

my_order_header_in-sales_off = 'JNJ1'.

my_order_header_in-purch_no_c = 'testbapipo'.

my_order_header_in-purch_date = sy-datum.

my_order_header_in-req_date_h = sy-datum.

append my_order_header_in.

  • this is to assign values to internal table my_orderitemsin

my_orderitemsin-material = '000000000000000727'.

my_orderitemsin-plant = 'JNJ1'.

my_orderitemsin-target_qu = 'EA'.

my_orderitemsin-target_qty = '10'.

append my_orderitemsin.

  • this is to assign values to internal table my_order_partners

my_order_partners-partn_role = 'AG'.

my_order_partners-partn_numb = '0000000011'.

append my_order_partners.

my_order_partners-partn_role = 'WE'.

my_order_partners-partn_numb = '0000000011'.

append my_order_partners.

  • This is to assign values to internal table my_orderschedulesin

  • my_orderschedulesin-itm_number = '10'.

my_orderschedulesin-req_qty = '10'.

my_orderschedulesin-SCHED_LINE = '0001'.

append my_orderschedulesin.

*This is to assign values to internal table my_orderconditionin

my_orderconditionsin-cond_type = 'ZPR1'.

my_orderconditionsin-cond_value = '40.00'.

append my_orderconditionsin.

my_order_header_ix-updateflag = 'I'.

my_order_header_ix-doc_type = 'X'.

my_order_header_ix-sales_org = 'X'.

my_order_header_ix-distr_chan = 'X'.

my_order_header_ix-division = 'X'.

my_order_header_ix-sales_off = 'X'.

my_order_header_ix-purch_no_c = 'X'.

my_order_header_ix-purch_date = 'X'.

my_order_header_ix-req_date_h = 'X'.

append my_order_header_ix.

my_orderitemsix-updateflag = 'I'.

my_orderitemsix-material = 'X'.

my_orderitemsix-target_qty = 'X'.

my_orderitemsix-plant = 'X'.

my_orderitemsix-target_qu = 'X'.

append my_orderitemsix.

my_orderschedulesinx-updateflag = 'I'.

my_orderschedulesinx-sched_line = '0001'.

my_orderschedulesinx-req_qty = 'x'.

append my_orderschedulesinx.

my_orderconditionsinx-updateflag = 'U'.

my_orderconditionsinx-cond_type = 'X'.

my_orderconditionsinx-cond_value = 'X'.

append my_orderconditionsinx.

call function 'BAPI_SALESORDER_CREATEFROMDAT2'

exporting

  • SALESDOCUMENTIN =

order_header_in = my_order_header_in

order_header_inx = my_order_header_ix

  • SENDER =

  • BINARY_RELATIONSHIPTYPE =

  • INT_NUMBER_ASSIGNMENT =

  • BEHAVE_WHEN_ERROR =

  • LOGIC_SWITCH =

  • TESTRUN =

  • CONVERT = ' '

importing

salesdocument = w_vbeln

tables

return = my_return

order_items_in = my_orderitemsin

order_items_inx = my_orderitemsix

order_partners = my_order_partners

ORDER_SCHEDULES_IN = my_orderschedulesin

order_schedules_inx = my_orderschedulesinx

ORDER_CONDITIONS_IN = my_orderconditionsin

ORDER_CONDITIONS_INX = my_orderconditionsinx

  • ORDER_CFGS_REF =

.

if sy-subrc ne 0.

write: my_return-message, my_return-number, my_return-type.

else.

call function 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • WAIT =

  • IMPORTING

  • RETURN =

.

write: my_return-message, my_return-number, my_return-type.

endif.</b>

i am getting error message

<b>standard sales order cannot changed 219 E</b>

regards,

pavan

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Can you try changing

my_orderconditionsinx-updateflag = 'U'.

to

my_orderconditionsinx-updateflag = 'I'.

If it still does not work, i would suggest using function module BAPISDORDER_GETDETAILEDLIST for a given sales order and determine how conditions table is populated and replicate the same format in your create BAPI routine

2 REPLIES 2

Former Member
0 Kudos

Can you try changing

my_orderconditionsinx-updateflag = 'U'.

to

my_orderconditionsinx-updateflag = 'I'.

If it still does not work, i would suggest using function module BAPISDORDER_GETDETAILEDLIST for a given sales order and determine how conditions table is populated and replicate the same format in your create BAPI routine

0 Kudos

hi naresh,

i did by changing the flag, but it won't works,

thanks for u r response

regards,

pavan

report zmybapi1 .

data : my_order_header_in like bapisdhd1 occurs 0 with header line,

my_order_header_ix like bapisdhd1x occurs 0 with header line.

data : my_orderitemsin like bapisditm occurs 0 with header line,

my_orderitemsix like bapisditmx occurs 0 with header line.

data : my_order_partners like bapiparnr occurs 0 with header line.

data : my_return like bapiret2 occurs 0 with header line.

data : w_vbeln like bapivbeln-vbeln.

data:

my_orderschedulesin like bapischdl occurs 0 with header line,

my_orderschedulesinx like bapischdlx occurs 0 with header line.

data : my_orderconditionsin like bapicond occurs 0 with header line,

my_orderconditionsinx like bapicondx occurs 0 with header line.

data : my_ordertext like bapisdtext occurs 0 with header line.

data : my_header like thead occurs 0 with header line.

data : my_tline like tline occurs 0 with header line.

start-of-selection.

  • this is to assign values to internal table my_order_header_in

my_order_header_in-doc_type = 'TA'.

my_order_header_in-sales_org = 'JNJ1'.

my_order_header_in-distr_chan = '02'.

my_order_header_in-division = 'J1'.

my_order_header_in-sales_off = 'JNJ1'.

my_order_header_in-purch_no_c = 'testbapipo'.

my_order_header_in-purch_date = sy-datum.

my_order_header_in-req_date_h = sy-datum.

append my_order_header_in.

  • this is to assign values to internal table my_orderitemsin

my_orderitemsin-material = '000000000000000727'.

my_orderitemsin-plant = 'JNJ1'.

my_orderitemsin-target_qu = 'EA'.

my_orderitemsin-target_qty = '10'.

append my_orderitemsin.

  • this is to assign values to internal table my_order_partners

my_order_partners-partn_role = 'AG'.

my_order_partners-partn_numb = '0000000011'.

append my_order_partners.

my_order_partners-partn_role = 'WE'.

my_order_partners-partn_numb = '0000000011'.

  • append my_order_partners.

  • This is to assign values to internal table my_orderschedulesin

my_orderschedulesin-itm_number = '10'.

my_orderschedulesin-itm_number = '000010'.

my_orderschedulesin-req_qty = '10'.

my_orderschedulesin-SCHED_LINE = '0001'.

append my_orderschedulesin.

*This is to assign values to internal table my_orderconditionin

  • my_orderconditionsin-itm_number = '000010'.

  • my_orderconditionsin-cond_type = 'ZPR1'.

  • my_orderconditionsin-cond_st_no = ''.

  • my_orderconditionsin-cond_count = '1'.

  • my_orderconditionsin-cond_value = '40'.

  • my_orderconditionsin-cond_p_unt = '1'.

  • my_orderconditionsin-currency = 'INR'.

  • append my_orderconditionsin.

*

my_ordertext-itm_number = '00010'.

my_ordertext-text_id = 'ST'.

my_ordertext-langu = 'EN'.

my_ordertext-langu_iso = 'EN'.

my_ordertext-text_line = 'This is for item note'.

my_ordertext-format_col = '*'.

my_ordertext-function = '009'.

*

append my_ordertext.

my_order_header_ix-updateflag = 'I'.

my_order_header_ix-doc_type = 'X'.

my_order_header_ix-sales_org = 'X'.

my_order_header_ix-distr_chan = 'X'.

my_order_header_ix-division = 'X'.

my_order_header_ix-sales_off = 'X'.

my_order_header_ix-purch_no_c = 'X'.

my_order_header_ix-purch_date = 'X'.

my_order_header_ix-req_date_h = 'X'.

append my_order_header_ix.

my_orderitemsix-updateflag = 'I'.

my_orderitemsix-material = 'X'.

my_orderitemsix-target_qty = 'X'.

my_orderitemsix-plant = 'X'.

my_orderitemsix-target_qu = 'X'.

append my_orderitemsix.

my_orderschedulesinx-updateflag = 'I'.

my_orderschedulesinx-sched_line = '0001'.

my_orderschedulesinx-req_qty = 'X'.

append my_orderschedulesinx.

  • my_orderconditionsinx-itm_number = '000010'.

  • my_orderconditionsinx-cond_type = 'ZPR1'.

  • my_orderconditionsinx-cond_st_no = 'X'.

  • my_orderconditionsinx-cond_count = 'X'.

  • my_orderconditionsinx-updateflag = 'U'.

  • my_orderconditionsinx-cond_value = 'X'.

  • my_orderconditionsinx-cond_p_unt = 'X'.

  • my_orderconditionsinx-currency = 'X'.

  • append my_orderconditionsinx.

call function 'BAPI_SALESORDER_CREATEFROMDAT2'

exporting

  • SALESDOCUMENTIN =

order_header_in = my_order_header_in

order_header_inx = my_order_header_ix

  • SENDER =

  • BINARY_RELATIONSHIPTYPE =

  • INT_NUMBER_ASSIGNMENT =

  • BEHAVE_WHEN_ERROR =

  • LOGIC_SWITCH =

  • TESTRUN =

  • CONVERT = ' '

importing

salesdocument = w_vbeln

tables

return = my_return

order_items_in = my_orderitemsin

order_items_inx = my_orderitemsix

order_partners = my_order_partners

ORDER_SCHEDULES_IN = my_orderschedulesin

order_schedules_inx = my_orderschedulesinx

  • ORDER_CONDITIONS_IN = my_orderconditionsin

  • ORDER_CONDITIONS_INX = my_orderconditionsinx

  • ORDER_CFGS_REF =

ORDER_TEXT = my_ordertext

.

if sy-subrc ne 0.

write: my_return-message, my_return-number, my_return-type.

else.

call function 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • WAIT =

  • IMPORTING

  • RETURN =

.

write: my_return-message, my_return-number, my_return-type.

endif.