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_change

Former Member
0 Likes
643

HI,

I am using bapi_salesorder_change.

Iam having the requirement that i need to update the cancellation reasong for each item in the sales order .

for sales document i passed the sales document no

for order_header_inx-UPDATEFLAG i passed the 'U'.

How can i pass the cancellation reason for each item.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = salesdocument

order_header_inx = order_header_inx

TABLES

return = return

order_item_in = order_item_in

order_item_inx = order_item_inx

EXCEPTIONS

OTHERS = 1.

3 REPLIES 3
Read only

Former Member
0 Likes
540

Hi Soumya,

Use the following sample code.

LOOP AT t_orditm ."WHERE vbeln = t_order-vbeln .

CLEAR: it_item_in,it_item_inx,it_head_in.

REFRESH: it_item_in,it_item_inx.

it_item_in-itm_number = t_orditm-posnr.

it_item_in-reason_rej = '90'.

APPEND it_item_in.

it_item_inx-itm_number = t_orditm-posnr.

it_item_inx-reason_rej = 'X'.

it_item_inx-updateflag = 'U'.

APPEND it_item_inx.

it_head_in-updateflag = 'U'.

MOVE 'Y_STR_SO_SHORTCLOSING' TO m_repid .

EXPORT m_repid TO MEMORY ID 'M_REPID'.

WAIT UP TO 2 SECONDS.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = t_orditm-vbeln

order_header_inx = it_head_in

TABLES

return = it_msg2

order_item_in = it_item_in

order_item_inx = it_item_inx.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

LOOP AT it_msg2.

IF it_msg2-type = 'E' OR it_msg2-type = 'A'.

  • BAPI call failed

it_msg3-vbeln = t_orditm-vbeln .

it_msg3-posnr = t_orditm-posnr.

MOVE-CORRESPONDING it_msg2 TO it_msg3.

APPEND it_msg3.

ELSE.

it_msg3-vbeln = t_orditm-vbeln .

it_msg3-posnr = t_orditm-posnr.

MOVE-CORRESPONDING it_msg2 TO it_msg3.

APPEND it_msg3.

ENDIF.

ENDLOOP.

ENDLOOP.

If it is helpfull pls give reward pts.

Regards

Srimanta

Read only

Former Member
0 Likes
540

HI,

Pls check the following forums,

Hope this helps you.

Thanks and Regards,

Ruthra

Read only

Former Member
0 Likes
540

Hi

Try like this

Don't forget to move 'U' to bapisdh1x-updateflag must be replace by

Don't forget to move 'U' to BAPISCHDLX-updateflag.

**********************************************

Here is an exemple we use to update the 2 header fields "delivery block and billing block of the sales order :

*----


form maj_cmdes.

loop at t_vbak.

clear : s_bapisdh1 , s_bapisdh1x, s_bapiret2.

refresh t_bapiret2.

move 'U' to s_bapisdh1x-updateflag.

case t_vbak-errone.

when ' '.

move : ' ' to s_bapisdh1-dlv_block,

'X' to s_bapisdh1x-dlv_block,

' ' to s_bapisdh1-bill_block,

'X' to s_bapisdh1x-bill_block.

when 'X'.

move : p_lifsk to s_bapisdh1-dlv_block,

'X' to s_bapisdh1x-dlv_block.

endcase.

call function 'BAPI_SALESORDER_CHANGE'

exporting

salesdocument = t_vbak-vbeln

order_header_in = s_bapisdh1

order_header_inx = s_bapisdh1x

tables

return = t_bapiret2.

loop at t_bapiret2.

move-corresponding t_bapiret2 to t_bapiret.

append t_bapiret. clear t_bapiret.

endloop.

endloop.

call function 'BAPI_TRANSACTION_COMMIT'

exporting

wait = 'X'

importing

return = s_bapiret2.

move-corresponding s_bapiret2 to t_bapiret.

append t_bapiret. clear t_bapiret.

endform.

Regards

Pavan