Skip to Content
0
Former Member
Oct 23, 2007 at 05:20 AM

BAPI_SALESORDER_CHANGE

135 Views

Hi

I wants to change sales order text(order_text) using BAPI_SALESORDER_CHANGE can any body have source code please provide me

or I have written a code but this is not workin can any body please correct it

REPORT ztest_bapi.

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 BAPISDITEM occurs 0 with header line,

ITEM_INX like BAPISDITEMX occurs 0 with header line,

UPDATEFLAG1 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,

ORDER_TEXT LIKE BAPISDTEXT 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 '29',

MATNR like VBAP-MATNR default '24351',

POSNR like VBAP-POSNR default '2072'.

select single VBELN MATNR POSNR into t_vbap

from VBAP

where

VBELN = VBELN AND

MATNR = MATNR AND

POSNR = POSNR.

*Header

ORDER_HEADER_INX-UPDATEFLAG = UPDATEFLAG1.

ORDER_ITEM_IN-ITM_NUMBER = POSNR.

ORDER_ITEM_IN-MATERIAL = MATNR.

APPEND ORDER_ITEM_IN.

ORDER_ITEM_INX-ITM_NUMBER = POSNR.

ORDER_ITEM_INX-UPDATEFLAG = UPDATEFLAG1.

APPEND ORDER_ITEM_INX.

ORDER_TEXT-DOC_NUMBER = VBELN.

ORDER_TEXT-ITM_NUMBER = POSNR.

ORDER_TEXT-TEXT_ID = 'ZLB2'.

ORDER_TEXT-LANGU = 'EN'.

ORDER_TEXT-TEXT_LINE = '**'.

APPEND ORDER_TEXT.

  • INX - Schedule line item level

*SCHEDULE_LINESX-ITM_NUMBER = t_vbap-posnr.

*SCHEDULE_LINESX-SCHED_LINE = '0001'.

*SCHEDULE_LINESX-UPDATEFLAG = 'U'.

*SCHEDULE_LINESX-REQ_QTY = 'X'.

*append SCHEDULE_LINESX.

*clear SCHEDULE_LINESX.

*

**Item (Order QQuantity Field to be changed "KWMENG")

*SCHEDULE_LINES-ITM_NUMBER = t_vbap-posnr.

*SCHEDULE_LINES-SCHED_LINE = '0001'.

*SCHEDULE_LINES-REQ_QTY = '3'.

*append SCHEDULE_LINES.

*clear SCHEDULE_LINES.

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

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

SCHEDULE_LINES = SCHEDULE_LINES

SCHEDULE_LINESX = SCHEDULE_LINESX

ORDER_TEXT = ORDER_TEXT.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

IMPORTING

RETURN = RETURN .