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: 

Function Module or BAPI to update Sales Order (delivery Block)

Former Member
0 Kudos

Hi,

Is there a Function Module or BAPI available that can update the Delivery Block for a looping Sales Order?

Thanks,

John

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

check this sample code to update delivery block..


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

2 REPLIES 2

Former Member
0 Kudos

Hi,

You can use the BAPI BAPI_SALESORDER_CHANGE to update the delivery block for a given sales order

Thanks

Naren

Former Member
0 Kudos

Hi,

check this sample code to update delivery block..


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