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

Former Member
0 Kudos
2,227

Dear Friends

I need to change a sales order delivery block VBAK-LIFSK.

I am providing the new LIFSK in the selection screen. From my analysis I have to use FM: BAPI_SALESORDER_CHANGE.

Please tell me what values I should pass to this FM to change my sales orders as above.

If there is any other FM please suggest that.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
129

Hi,

check this code


DATA: BAPISDH1X LIKE BAPISDH1X.
DATA: BAPISDH1 LIKE BAPISDH1.

PARAMETERS: P_VBELN LIKE VBAK-VBELN OBLIGATORY.
PARAMETERS: P_LIFSK  LIKE VBAK-LIFSK OBLIGATORY.

* Header 
BAPISDH1-DLV_BLOCK = p_lifsk.   " Delivery block

* header X
BAPISDH1X-DLV_BLOCK = 'X'.   " Delivery block
BAPISDH1X-UPDATEFLAG = 'U'.
 

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = P_VBELN
order_header_in   = BAPISDH1
order_header_inx = BAPISDH1X
tables
return = T_RETURN
.
 
LOOP AT T_RETURN WHERE TYPE = 'E' OR TYPE = 'A'.
  EXIT.
ENDLOOP.
 
* Check for error messages.
IF SY-SUBRC = 0.
  WRITE: / 'Sales order not updated', T_RETURN-MESSAGE.
 
ELSE.
 
* Successfully updated
  WRITE: / 'Sales order updated'.
ENDIF.
 
COMMIT WORK.

Thanks

Naren

6 REPLIES 6

Former Member
0 Kudos
129

Hi,

Just refer to the below link.

Hope it helps.

Regards,

Atish

Former Member
0 Kudos
129

hi

good

check with this code

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = P_VBELN

order_header_inx = BAPISDH1X

tables

return = T_RETURN

ORDER_ITEM_IN = T_ITEM

ORDER_ITEM_INX = T_ITEMX

.

LOOP AT T_RETURN WHERE TYPE = 'E' OR TYPE = 'A'.

EXIT.

ENDLOOP.

  • Check for error messages.

IF SY-SUBRC = 0.

WRITE: / 'Sales order not updated', T_RETURN-MESSAGE.

ELSE.

  • Successfully updated

WRITE: / 'Sales order updated'.

ENDIF.

thanks

mrutyun^

0 Kudos
129

Hi Mrutyun^

Thanks for the reply. Can you tell me what will be in

BAPISDH1X

T_ITEM

T_ITEMX

Please see I have to just change the delivery block. which is in the header table VBAK-LIFSK

Former Member
0 Kudos
130

Hi,

check this code


DATA: BAPISDH1X LIKE BAPISDH1X.
DATA: BAPISDH1 LIKE BAPISDH1.

PARAMETERS: P_VBELN LIKE VBAK-VBELN OBLIGATORY.
PARAMETERS: P_LIFSK  LIKE VBAK-LIFSK OBLIGATORY.

* Header 
BAPISDH1-DLV_BLOCK = p_lifsk.   " Delivery block

* header X
BAPISDH1X-DLV_BLOCK = 'X'.   " Delivery block
BAPISDH1X-UPDATEFLAG = 'U'.
 

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = P_VBELN
order_header_in   = BAPISDH1
order_header_inx = BAPISDH1X
tables
return = T_RETURN
.
 
LOOP AT T_RETURN WHERE TYPE = 'E' OR TYPE = 'A'.
  EXIT.
ENDLOOP.
 
* Check for error messages.
IF SY-SUBRC = 0.
  WRITE: / 'Sales order not updated', T_RETURN-MESSAGE.
 
ELSE.
 
* Successfully updated
  WRITE: / 'Sales order updated'.
ENDIF.
 
COMMIT WORK.

Thanks

Naren

Former Member
0 Kudos
129

Hi,

Please check my reply

Thanks

Naren

former_member219399
Active Participant
0 Kudos
129

Hi,

You can use the parameter

ORDER_HEADER_IN-DLV_BLOCK = 'X'. as export parameter.

With regards,

Vamsi

data order_header type BAPISDH1.

ORDER_HEADER-DLV_BLOCK = 'X'.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

SALESDOCUMENT = i_vbeln

ORDER_HEADER_IN = order_header

ORDER_HEADER_INX = 'U'

TABLES

RETURN = bapi_return

.