DATA: lv_msg TYPE string.
PERFORM frm_lock_likp_vbeln USING '4200001021' 'Z2' CHANGING lv_msg.
*&---------------------------------------------------------------------*
*& Form FRM_LOCK_LIKP_VBELN
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM frm_lock_likp_vbeln USING pv_vbeln
pv_lifsk
CHANGING pv_msg.
DATA: lt_return TYPE bapiret2_t,
ls_return TYPE bapiret2,
ls_header_data TYPE bapiobdlvhdrchg,
ls_header_control TYPE bapiobdlvhdrctrlchg.
DATA: lv_vbeln TYPE likp-vbeln.
DATA: lv_lifsk TYPE likp-lifsk.
DATA: lv_msg TYPE char50.
lv_vbeln = pv_vbeln.
lv_lifsk = pv_lifsk.
CLEAR: pv_msg.
ls_header_data-deliv_numb = lv_vbeln.
ls_header_data-dlv_block = lv_lifsk.
ls_header_control-deliv_numb = lv_vbeln.
ls_header_control-dlv_block_flg = 'X'.
* 调用BAPI修改交货单状态
CALL FUNCTION 'BAPI_OUTB_DELIVERY_CHANGE'
EXPORTING
header_data = ls_header_data
header_control = ls_header_control
delivery = lv_vbeln
TABLES
return = lt_return.
IF lt_return[] IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
LOOP AT lt_return INTO ls_return WHERE type = 'A' OR type = 'E'.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = ls_return-id
msgnr = ls_return-number
msgv1 = ls_return-message_v1
msgv2 = ls_return-message_v2
msgv3 = ls_return-message_v3
msgv4 = ls_return-message_v4
IMPORTING
message_text_output = lv_msg.
IF lv_msg IS INITIAL.
lv_msg = lv_msg .
ELSE.
lv_msg = lv_msg && lv_msg && '/' .
ENDIF.
ENDLOOP.
MESSAGE s001(00) WITH lv_vbeln ':' lv_msg '' DISPLAY LIKE 'E'.
ENDIF.
ENDFORM.