DATA:DEL_HEADER TYPE BBP_INBD_L.
DATA:DEL_TAB TYPE TABLE OF BBP_INBD_D WITH HEADER LINE.
DATA:DEL_RET TYPE TABLE OF BAPIRETURN WITH HEADER LINE.
DATA:DEL_NO LIKE LIKP-VBELN.
LOOP AT INPUT.
MOVE-CORRESPONDING INPUT TO OUTPUT.
CLEAR DEL_HEADER.
DEL_HEADER-DELIV_DATE = INPUT-EINDT.
DEL_HEADER-DELIV_EXT = ''.
CLEAR DEL_TAB.
REFRESH DEL_TAB.
DEL_TAB-DELIV_QTY = INPUT-LFIMG.
SELECT SINGLE
MEINS
INTO DEL_TAB-UNIT
FROM EKPO
WHERE EBELN = INPUT-EBELN
AND EBELP = INPUT-EBELP.
DEL_TAB-PO_NUMBER = INPUT-EBELN.
DEL_TAB-PO_ITEM = INPUT-EBELP.
APPEND DEL_TAB.
CLEAR DEL_TAB.
CALL FUNCTION 'BBP_INB_DELIVERY_CREATE'
EXPORTING
IS_INB_DELIVERY_HEADER = DEL_HEADER
IMPORTING
EF_DELIVERY = DEL_NO
TABLES
IT_INB_DELIVERY_DETAIL = DEL_TAB
RETURN = DEL_RET.
IF SY-SUBRC = 0.
OUTPUT-VBELN = DEL_NO.
OUTPUT-FLAG = 'S'.
OUTPUT-MESSAGE = '创建内项交货成功!'.
ELSE.
OUTPUT-FLAG = 'E'.
OUTPUT-MESSAGE = '创建内项交货失败'.
ENDIF.
APPEND OUTPUT.
CLEAR OUTPUT.
ENDLOOP.