Application Development 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: 

BAPI_SALESORDER_CHANGE changing ship-to party

Former Member
0 Kudos

Hi,

i want to change ship-to party for sale's order.how to do this using BAPI_SALESORDER_CHANGE.

thanks in advance.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

I believe you can do this by populating the table-parameter: <b>PARTNERCHANGES</b>

You can pass values like document no, item no, old partner number, update flag, new partner number, partner role and partner address number.

Message was edited by: Sam

4 REPLIES 4

Former Member
0 Kudos

loop at table PARTNERS table where PARTN_ROLE = 'SH'.

PARTNERS-PARTN_NUMB = 'your new number'.

modify PARTNERS.

endloop.

loop at table PARTNERCHANGES table where PARTN_ROLE = 'SH'.

PARTNERCHANGES-UPDATEFLAG = 'U'.

modify PARTNERCHANGES.

endloop.

And don't forgot to use BAPI_TRANSACTION_COMMIT.

former_member188685
Active Contributor
0 Kudos

P-SHIPTO = 'SHip to party'.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
       EXPORTING
            SALESDOCUMENT    = CMRTAB-NUMBER
            ORDER_HEADER_IN  = H1
            ORDER_HEADER_INX = H1X
       TABLES
            RETURN           = BAPIRETURN
            ORDER_ITEM_IN    = ITMFLD
            ORDER_ITEM_INX   = ITMUPD
        <b> PARTNERCHANGES       = P-SHIPTO</b>
            CONDITIONS_IN    = P-Z03X
            CONDITIONS_INX   = P-UPDATES
            ORDER_TEXT       = ORDTEXT
            EXTENSIONIN      = ORDATAB.

  IF SY-SUBRC = 0.                      "GOOD BAPI RETURN
    REFRESH BAPIRETURN.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
         EXPORTING
              WAIT   = 'X'  "WAIT FOR SALES ORDER SAVE
         IMPORTING
              RETURN = BAPIRETURN.

    LOOP AT BAPIRETURN WHERE TYPE = 'E'.
      WRITE: / BAPIRETURN.
    ENDLOOP.
     IF SY-SUBRC <> 0.
       CMRTAB-STATUS = 'X'.
       MODIFY CMRTAB.
     ENDIF.
  ELSE.
    WRITE: / 'ERROR IN COMMIT'.
  ENDIF.

Message was edited by: Vijay Babu Dudla

Former Member
0 Kudos

I believe you can do this by populating the table-parameter: <b>PARTNERCHANGES</b>

You can pass values like document no, item no, old partner number, update flag, new partner number, partner role and partner address number.

Message was edited by: Sam

0 Kudos

pradeep,

I still see this thread as open. Please review this code as a more clear solution.

REPORT ZR_SANDBOX_PROG.

data: vb like BAPIVBELN-VBELN.

data: cl like BAPISDH1X.

data: rt type table of BAPIRET2 with header line.

data: rt2 type BAPIRET2.

data: pt type table of BAPIPARNRC with header line.

vb = '0000153147'. " your sales order here

cl-updateflag = 'U'.

pt-DOCUMENT = vb.

pt-ITM_NUMBER = '000000'. "header line item = 000000

pt-UPDATEFLAG = 'U'.

pt-PARTN_ROLE = 'WE'.

pt-P_NUMB_OLD = '0003300744'.

pt-P_NUMB_NEW = '0003300074'.

append pt.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

SALESDOCUMENT = vb

ORDER_HEADER_INX = cl

TABLES

RETURN = rt

PARTNERCHANGES = pt.

loop at rt.

write: / rt-MESSAGE.

endloop.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'

IMPORTING

RETURN = rt2.

Reward points accordingly.