Skip to Content
author's profile photo Former Member
Former Member

'BAPI_SALESORDER_CHANGE' - Adding new schedule line.

Hi All,

I am trying to add a new schedule line to a existing SALES order using the BAPI 'BAPI_SALESORDER_CHANGE'. But i am not getting the line inserted even if the run was successful. I wanted to know if there is any setting to be done for this. Below is the code i am trying to use.

Kindly guide me in how to achieve this.

thanks and regards

shilpa

REPORT Z_VA32_EDI1.

data: v_vbeln type BAPIVBELN-VBELN,

wa_order_header type BAPISDH1X,

i_sch_line type standard table of BAPISCHDL with header line,

i_sch type standard table of BAPISCHDLX with header line,

i_return type standard table of BAPIRET2 with header line.

v_vbeln = '0030001227'.

wa_order_header-UPDATEFLAG = 'U'.

i_sch-ITM_NUMBER = '000010'.

i_sch-UPDATEFLAG = 'I'.

i_sch-REQ_DATE = 'X'.

i_sch-REL_TYPE = 'X'.

i_sch-PLAN_SCHED_TYPE = 'X'.

i_sch-REQ_QTY = 'X'.

append i_Sch.

i_sch_line-ITM_NUMBER = '000010'.

i_sch_line-REQ_DATE = '20080127'.

i_sch_line-REL_TYPE = '2'.

i_sch_line-PLAN_SCHED_TYPE = '2'.

i_sch_line-REQ_QTY = '65'.

append i_Sch_line.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = v_vbeln

• ORDER_HEADER_IN =

order_header_inx = wa_order_header

• SIMULATION =

• BEHAVE_WHEN_ERROR = ' '

• INT_NUMBER_ASSIGNMENT = ' '

• LOGIC_SWITCH =

• NO_STATUS_BUF_INIT = ' '

tables

return = i_Return

• ORDER_ITEM_IN =

• ORDER_ITEM_INX =

• PARTNERS =

• PARTNERCHANGES =

• PARTNERADDRESSES =

• ORDER_CFGS_REF =

• ORDER_CFGS_INST =

• ORDER_CFGS_PART_OF =

• ORDER_CFGS_VALUE =

• ORDER_CFGS_BLOB =

• ORDER_CFGS_VK =

• ORDER_CFGS_REFINST =

SCHEDULE_LINES = i_sch_line[]

SCHEDULE_LINESX = i_sch[]

• ORDER_TEXT =

• ORDER_KEYS =

• CONDITIONS_IN =

• CONDITIONS_INX =

• EXTENSIONIN =

• NFMETALLITMS =

.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

write: 'Done'.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Feb 01, 2008 at 04:53 AM

    Hi

    You also need to pass ORDER_HEADER_IN parameter values.

    Best regards,

    Prashant

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 01, 2008 at 04:55 AM

    Hi

    Follow this code for 'BAPI_SALESORDER_CHANGE'.

    Hope it will help you.

    Pls reward if help.

    REPORT Z_SALES_ORDER_CHANGE

    NO STANDARD PAGE HEADING

    LINE-SIZE 132

    LINE-COUNT 65(0)

    MESSAGE-ID ZZ.

    TABLES: VBAP.

    DATA:

    V_FILEIN(90) TYPE C,

    V_RECIN TYPE I,

    V_RECVBAP TYPE I,

    V_RECORDER TYPE I,

    V_VBELN LIKE VBAP-VBELN,

    ORDERHEADERINX LIKE BAPISDH1X.

    DATA: BEGIN OF I_ORDERS OCCURS 0,

    VBELN LIKE VBAK-VBELN,

    POSNR LIKE VBAP-POSNR,

    BRGEW(18) TYPE C,

    VOLUM(18) TYPE C,

    END OF I_ORDERS.

    DATA: BEGIN OF I_OUTPUT OCCURS 0,

    VBELN LIKE VBAK-VBELN,

    POSNR LIKE VBAP-POSNR,

    • GEWEI LIKE VBAP-GEWEI,

    BRGEW LIKE VBAP-BRGEW,

    VOLUM LIKE VBAP-VOLUM,

    CKWGT TYPE C,

    CKVOL TYPE C,

    END OF I_OUTPUT.

    DATA: BEGIN OF ORDERITEMIN OCCURS 0.

    INCLUDE STRUCTURE BAPISDITM.

    DATA: END OF ORDERITEMIN.

    DATA: BEGIN OF ORDERITEMINX OCCURS 0.

    INCLUDE STRUCTURE BAPISDITMX.

    DATA: END OF ORDERITEMINX.

    DATA: BEGIN OF RETURN OCCURS 0.

    INCLUDE STRUCTURE BAPIRET2.

    DATA: END OF RETURN.

    DATA: BEGIN OF BAPIRETURN OCCURS 0.

    INCLUDE STRUCTURE BAPIRET2.

    DATA: END OF BAPIRETURN.

    PARAMETERS:

    P_PATH(45) TYPE C DEFAULT '/usr/users/ftpsapom/' LOWER CASE,

    P_FNAME(32) TYPE C DEFAULT '/sweetjo.txt' LOWER CASE.

    START-OF-SELECTION.

    • CONCATENATE PATH AND FILE NAME INTO ONE VARIABLE

    CONCATENATE P_PATH P_FNAME INTO V_FILEIN.

    • OPEN DATASET

    IF V_FILEIN IS INITIAL.

    MESSAGE E002 WITH 'FILE' V_FILEIN 'DOES NOT CONTAIN ANY DATA!'.

    • & & & &

    ELSE.

    OPEN DATASET V_FILEIN

    FOR INPUT

    IN TEXT MODE.

    IF SY-SUBRC = 0.

    • READ DATASET

    DO.

    READ DATASET V_FILEIN INTO I_ORDERS.

    IF SY-SUBRC = 0.

    APPEND I_ORDERS.

    ELSE.

    EXIT.

    ENDIF.

    ENDDO.

    • CLOSE DATASET

    CLOSE DATASET V_FILEIN.

    IF SY-SUBRC <> 0.

    MESSAGE E002 WITH 'ERROR - CLOSING' V_FILEIN.

    • & & & &

    ENDIF.

    ELSE.

    MESSAGE E002 WITH 'ERROR - COULD NOT OPEN' V_FILEIN.

    • & & & &

    ENDIF.

    ENDIF.

    • SORT AND REMOVE DUPLICATES FROM I_ORDERS

    SORT I_ORDERS BY VBELN POSNR.

    DELETE ADJACENT DUPLICATES FROM I_ORDERS.

    • POPULATE I_OUTPUT

    LOOP AT I_ORDERS.

    SHIFT I_ORDERS-POSNR LEFT DELETING LEADING SPACE.

    CONCATENATE '0' I_ORDERS-POSNR INTO I_ORDERS-POSNR.

    SELECT SINGLE BRGEW VOLUM

    FROM VBAP

    INTO (VBAP-BRGEW, VBAP-VOLUM)

    WHERE VBELN = I_ORDERS-VBELN

    AND POSNR = I_ORDERS-POSNR.

    IF SY-SUBRC = 0.

    IF VBAP-BRGEW = 0.

    I_OUTPUT-CKWGT = 'X'.

    ENDIF.

    IF VBAP-VOLUM = 0.

    I_OUTPUT-CKVOL = 'X'.

    ENDIF.

    I_OUTPUT-VBELN = I_ORDERS-VBELN.

    I_OUTPUT-POSNR = I_ORDERS-POSNR.

    • I_OUTPUT-GEWEI = 'ST'.

    I_OUTPUT-BRGEW = I_ORDERS-BRGEW.

    I_OUTPUT-VOLUM = I_ORDERS-VOLUM.

    APPEND I_OUTPUT.

    CLEAR: I_OUTPUT.

    ENDIF.

    V_RECIN = V_RECIN + 1.

    ENDLOOP.

    • POPULATE BAPI DATA AND RUN BAPI

    CLEAR: ORDERHEADERINX, ORDERITEMIN, ORDERITEMINX,

    RETURN, BAPIRETURN.

    REFRESH: ORDERITEMIN, ORDERITEMINX, RETURN, BAPIRETURN.

    ORDERHEADERINX-UPDATEFLAG = 'U'.

    LOOP AT I_OUTPUT WHERE CKWGT = 'X' OR CKVOL = 'X'.

    V_RECVBAP = V_RECVBAP + 1.

    IF I_OUTPUT-VBELN <> V_VBELN AND SY-TABIX <> 1.

    V_RECORDER = V_RECORDER + 1.

    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

    EXPORTING

    SALESDOCUMENT = V_VBELN

    ORDER_HEADER_INX = ORDERHEADERINX

    TABLES

    RETURN = RETURN

    ORDER_ITEM_IN = ORDERITEMIN

    ORDER_ITEM_INX = ORDERITEMINX.

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

    EXPORTING

    WAIT = 'X'

    IMPORTING

    RETURN = BAPIRETURN.

    • WRITE OUT RETURN

    LOOP AT RETURN.

    WRITE: / RETURN.

    ENDLOOP.

    WRITE: / BAPIRETURN.

    SKIP.

    CLEAR: ORDERITEMIN, ORDERITEMINX,

    RETURN, BAPIRETURN.

    REFRESH: ORDERITEMIN, ORDERITEMINX, RETURN, BAPIRETURN.

    ENDIF.

    ORDERITEMIN-ITM_NUMBER = I_OUTPUT-POSNR.

    • ORDERITEMIN-UNTOF_WGHT = I_OUTPUT-GEWEI.

    IF NOT I_OUTPUT-CKWGT IS INITIAL.

    ORDERITEMIN-GROSS_WGHT = I_OUTPUT-BRGEW.

    ORDERITEMINX-GROSS_WGHT = 'X'.

    ENDIF.

    IF NOT I_OUTPUT-CKVOL IS INITIAL.

    ORDERITEMIN-VOLUME = I_OUTPUT-VOLUM.

    ORDERITEMINX-VOLUME = 'X'.

    ENDIF.

    APPEND ORDERITEMIN.

    ORDERITEMINX-ITM_NUMBER = I_OUTPUT-POSNR.

    • ORDERITEMINX-UNTOF_WGHT = 'X'.

    ORDERITEMINX-UPDATEFLAG = 'U'.

    APPEND ORDERITEMINX.

    V_VBELN = I_OUTPUT-VBELN.

    ENDLOOP.

    • RUN BAPI ON LAST ORDER

    IF NOT ORDERITEMIN IS INITIAL.

    V_RECORDER = V_RECORDER + 1.

    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

    EXPORTING

    SALESDOCUMENT = V_VBELN

    ORDER_HEADER_INX = ORDERHEADERINX

    TABLES

    RETURN = RETURN

    ORDER_ITEM_IN = ORDERITEMIN

    ORDER_ITEM_INX = ORDERITEMINX.

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

    EXPORTING

    WAIT = 'X'

    IMPORTING

    RETURN = BAPIRETURN.

    • WRITE OUT RETURN

    LOOP AT RETURN.

    WRITE: / RETURN.

    ENDLOOP.

    WRITE: / BAPIRETURN.

    SKIP.

    ENDIF.

    • WRITE OUT RECORD COUNT FROM FILE

    WRITE: / 'RECORD COUNT FROM FILE ', V_RECIN.

    SKIP.

    • WRITE OUT RECORD COUNT FROM FILE

    WRITE: / 'RECORD COUNT OF LINES TO CHANGE ', V_RECVBAP.

    SKIP.

    • WRITE OUT RECORD COUNT FROM FILE

    WRITE: / 'RECORD COUNT OF ORDERS TO CHANGE ', V_RECORDER.

    SKIP.

    • TOP OF PAGE

    TOP-OF-PAGE.

    WRITE:/1(5) TEXT-H01, 6(8) SY-DATUM MM/DD/YY,

    100(8) TEXT-H02, 126(8) SY-PAGNO.

    WRITE:/1(5) TEXT-H03, 6(8) SY-UZEIT USING EDIT MASK '__:__:__',

    20(77) TEXT-H04,

    100(8) TEXT-H05, 108(25) SY-REPID.

    WRITE:/1(6) TEXT-H06, 8(12) SY-UNAME,

    20(4) TEXT-H07, 25(32) SY-HOST,

    100(13) TEXT-H08, 121(8) SY-SYSID,

    129 '/', 130(3) SY-MANDT.

    ULINE.

    SKIP.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.