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

Problem in BAPI 'BAPI_SALESORDER_CHANGE'

Former Member
0 Likes
407

Hi All,

I am facing a problem in BAPI 'BAPI_SALESORDER_CHANGE'. My requirement is as below.

For a particular type of Sales Order i have to update all the ship-to PO.Basically in all these PO's we have to suffix

'old'.

I am pasting the code which I used. I am actually displaying the return message in a table.

The message says 'Schedule Order is saved'.

When i go and check the SO the ship-to PO is not updated.

Also i have one more querry.

Is thsi BAPI to be run for each item or can i collect all items in t_item_in and then call the BAPI.

Please guide me on this.

Thanks in Advance,

Saket.

LOOP AT t_vbkd INTO wa_vbkd.

CONCATENATE wa_vbkd-bstkd_e '-' v_po INTO v_po_ref.

t_item_in-purch_no_c = v_po_ref.

t_item_inx-purch_no_c = v_po_ref.

t_item_inx-updateflag = 'X'.

APPEND t_item_in.

APPEND t_item_inx.

*LOOP AT t_vbak INTO wa_vbak.

v_vbeln = wa_vbkd-vbeln.

w_headerx-updateflag = 'U'.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

SALESDOCUMENT = v_vbeln

ORDER_HEADER_INX = w_headerx

TABLES

RETURN = t_return

ORDER_ITEM_IN = t_item_in

ORDER_ITEM_INX = t_item_inx.

READ TABLE t_return WITH KEY type = 'E'.

IF sy-subrc = 0.

t_output-rmks = t_return-message.

ELSE.

t_output-rmks = t_return-message.

ENDIF.

READ TABLE t_vbak INTO wa_vbak

WITH KEY vbeln = v_vbeln.

t_output-vbeln = v_vbeln.

t_output-auart = wa_vbak-auart.

t_output-vkorg = wa_vbak-vkorg.

t_output-bstkd_e_old = wa_vbkd-bstkd_e.

t_output-bstkd_e_new = t_item_in-purch_no_c.

APPEND t_output.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'

  • IMPORTING

  • RETURN =

.

ENDLOOP.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
359

you have to add some more fileds ...

t_item_in-ITM_NUMBER = you need to pass sales order item number also..

.t_item_in-purch_no_c = v_po_ref.

t_item_inx-purch_no_c = 'X'.

t_item_inX-ITM_NUMBER = you need to pass sales order item number also...

t_item_inx-updateflag = 'X'.

APPEND t_item_in.

APPEND t_item_inx.

2 REPLIES 2
Read only

Former Member
0 Likes
360

you have to add some more fileds ...

t_item_in-ITM_NUMBER = you need to pass sales order item number also..

.t_item_in-purch_no_c = v_po_ref.

t_item_inx-purch_no_c = 'X'.

t_item_inX-ITM_NUMBER = you need to pass sales order item number also...

t_item_inx-updateflag = 'X'.

APPEND t_item_in.

APPEND t_item_inx.

Read only

Former Member
0 Likes
359

Thanks for the reply.

This helped me solve the problem.