Skip to Content

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

BAPI_SALESORDER_CHANGE header changes

Hi all,

I want to update the sales office and sales group for existing open SO. I used BAPI_SALESORDER_CHANGE

for Update . But it won't change .

DATA:I_BAPI_VIEW LIKE ORDER_VIEW.

DATA:SALES_DOCUMENTS LIKE SALES_KEY OCCURS 0 WITH HEADER LINE.

DATA:ORDER_HEADERS_OUT LIKE BAPISDHD OCCURS 0 WITH HEADER LINE.

DATA:ORDER_HEADER_INX LIKE BAPISDH1X.

DATA:ORDER_HEADER_IN LIKE BAPISDH1." OCCURS 0 WITH HEADER LINE.

DATA:RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.

I_BAPI_VIEW-HEADER = 'X'.

*I_BAPI_VIEW-ITEM = 'X'.

SALES_DOCUMENTS-VBELN = '0001014088'.

APPEND SALES_DOCUMENTS.

CALL FUNCTION 'BAPISDORDER_GETDETAILEDLIST'

EXPORTING

I_BAPI_VIEW = I_BAPI_VIEW

TABLES

SALES_DOCUMENTS = SALES_DOCUMENTS

ORDER_HEADERS_OUT = ORDER_HEADERS_OUT.

BREAK-POINT.

*****my changes are going to update here

LOOP AT ORDER_HEADERS_OUT.

MOVE-CORRESPONDING ORDER_HEADERS_OUT TO ORDER_HEADER_IN.

IF ORDER_HEADERS_OUT-SALES_OFF = 'CN20'.

ORDER_HEADER_IN-SALES_OFF = 'SH10'.

ORDER_HEADER_INX-SALES_OFF = 'U'.

ORDER_HEADER_IN-SALES_GRP = 'SH1'.

ORDER_HEADER_INX-SALES_GRP = 'U'.

ENDIF.

ENDLOOP.

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

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

SALESDOCUMENT = SALES_DOCUMENTS

ORDER_HEADER_IN = ORDER_HEADER_IN

ORDER_HEADER_INX = ORDER_HEADER_INX

BEHAVE_WHEN_ERROR = 'P'

TABLES

RETURN = RETURN.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'.

COMMIT WORK.

How can i solve this....

Tags:

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question