Skip to Content
0
Former Member
Jan 18, 2008 at 01:12 AM

BAPI_SALESORDER_CHANGE

122 Views

Hi All,

Could some body tell me how to change plant,storage location and shipping point for a sales order using bapi_salesorder_change..

I have tried with the below code snippet and getting an error message in the RETURN table like 'Field 'WERKS' cannot be changed, VBAPKOM 000010 ready for input'.

CODE:

REPORT z_chg_so.

DATA: order_header_in LIKE bapisdh1,

order_header_inx LIKE bapisdh1x,

order_item_in LIKE bapisditm OCCURS 0 WITH HEADER LINE,

order_item_inx LIKE bapisditmx OCCURS 0 WITH HEADER LINE,

item_in LIKE bapisditm OCCURS 0 WITH HEADER LINE,

item_inx LIKE bapisditmx OCCURS 0 WITH HEADER LINE,

updateflag LIKE bapisditmx-updateflag VALUE 'U',

return LIKE bapiret2 OCCURS 0 WITH HEADER LINE,

schedule_lines LIKE bapischdl OCCURS 0 WITH HEADER LINE,

schedule_linesx LIKE bapischdlx OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF t_vbap,

vbeln LIKE vbap-vbeln,

matnr LIKE vbap-matnr,

posnr LIKE vbap-posnr,

END OF t_vbap.

PARAMETERS: vbeln LIKE vbap-vbeln DEFAULT '20000036',

matnr LIKE vbap-matnr DEFAULT '8200018',

posnr LIKE vbap-posnr DEFAULT '000010'.

SELECT SINGLE vbeln matnr posnr INTO t_vbap

FROM vbap

WHERE

vbeln = vbeln AND

matnr = matnr AND

posnr = posnr.

*Header

order_header_inx-updateflag = updateflag.

CLEAR item_in.

item_in-itm_number = t_vbap-posnr.

item_in-plant = 'US20'.

item_in-store_loc = '0003'.

item_in-ship_point = 'US20'.

APPEND item_in.

CLEAR item_inx.

item_inx-itm_number = t_vbap-posnr.

item_inx-updateflag = 'U'.

item_inx-store_loc = 'X'.

item_inx-ship_point = 'X'.

item_inx-plant = 'X'.

APPEND item_inx.

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

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = t_vbap-vbeln

order_header_in = order_header_in

order_header_inx = order_header_inx

TABLES

return = return

order_item_in = item_in

order_item_inx = item_inx.

DATA: return1 LIKE return .

READ TABLE return WITH KEY type = 'E'.

IF sy-subrc = 0.

ELSE.

BREAK-POINT.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

IMPORTING

return = return.

ENDIF.