WMS函数组:21.交货单过账---公司间--单行--WMS
DATA: V_VBTYP LIKE TVLK-VBTYP.
DATA: V_KOMRL LIKE TVLP-KOMRL.
DATA: ILIPS LIKE LIPS OCCURS 0 WITH HEADER LINE.
DATA: XET_LOG LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.
DATA: ITK LIKE LIKP OCCURS 0 WITH HEADER LINE.
DATA: ITP LIKE LIPS OCCURS 0 WITH HEADER LINE.
FUNCTION ZRFC_WMS_VL02N.
*"----------------------------------------------------------------------
*"*"本地接口:
*" IMPORTING
*" REFERENCE(IP_VBELN) LIKE LIKP-VBELN
*" REFERENCE(IP_CHARG) LIKE LIPS-CHARG
*" REFERENCE(IP_LGORT) LIKE LIPS-LGORT
*" REFERENCE(IP_LFIMG) LIKE LIPSD-G_LFIMG
*" EXPORTING
*" REFERENCE(EX_VBELN) LIKE LIKP-VBELN
*" REFERENCE(EP_SUBRC) LIKE SY-SUBRC
*" TABLES
*" ET_LOG STRUCTURE BAPIRET2
*"----------------------------------------------------------------------
*TABLES: LIKP,LIPS.
*STO交货单过账---公司间--单行--WMS
TABLES: LIPS.
DATA: ITAB_LIPS LIKE LIPS OCCURS 0 WITH HEADER LINE.
DATA: DELNO TYPE VBELN, P_LGORT LIKE LIPS-LGORT.
MOVE IP_VBELN TO DELNO.
MOVE IP_LGORT TO P_LGORT.
CLEAR XET_LOG[].
SELECT VBELN POSNR MATNR
UECHA WERKS
VGBEL VGPOS
PSTYV
INTO CORRESPONDING FIELDS OF TABLE ITAB_LIPS
FROM LIPS
WHERE VBELN = DELNO
ORDER BY POSNR.
****取出交货单行项目
MOVE ITAB_LIPS[] TO ITP[]. "记录交货单行项目
DELETE ITAB_LIPS WHERE UECHA IS NOT INITIAL.
DATA: MV TYPE I.
MV = LINES( ITAB_LIPS ).
IF MV > 1.
WRITE '仅支持单行的STO交货单'.
RETURN.
ENDIF.
READ TABLE ITAB_LIPS INTO ILIPS INDEX 1.
MOVE IP_LFIMG TO ILIPS-LFIMG .
MOVE IP_LGORT TO ILIPS-LGORT.
***判断交货单类型和送达方(用于退货工厂取数)*
SELECT SINGLE VBELN LFART KUNNR INTO CORRESPONDING FIELDS OF ITK
FROM LIKP WHERE VBELN = DELNO.
***判断是否退货精类型交货单(H,T)*
SELECT SINGLE VBTYP INTO V_VBTYP FROM TVLK WHERE LFART = ITK-LFART.
****交货单是否需要减配
SELECT SINGLE KOMRL INTO V_KOMRL FROM TVLP WHERE PSTYV = ILIPS-PSTYV.
**第一步判读是否批次管理,
DATA: T_XCHPF LIKE MARA-XCHPF.
SELECT SINGLE XCHPF INTO T_XCHPF FROM MARA WHERE MATNR = ILIPS-MATNR .
IF T_XCHPF IS INITIAL.
PERFORM CHECK_NO_BATCH_POST USING ILIPS.
RETURN.
ENDIF.
***第二步: 删除原有子项目.
PERFORM DEL_CHILD USING DELNO P_LGORT.
***第三步如需要拣配,清空拣配数量,防止下步添加了项目时报错。
IF V_KOMRL = 'X'.
PERFORM GET_PICK0 USING DELNO.
ENDIF.
***第四步: 添加新项目
PERFORM ADD_CHILD USING DELNO P_LGORT .
DATA: VL_LFIMG LIKE ILIPS-LFIMG .
SELECT SUM( LFIMG ) INTO VL_LFIMG FROM LIPS WHERE VBELN = DELNO.
IF VL_LFIMG > 0." 数量更改失败
****第五步拣配
IF V_KOMRL = 'X'.
PERFORM GET_PICK USING DELNO.
ENDIF.
***直接过帐
PERFORM CHECK_POST USING DELNO P_LGORT.
ELSE.
XET_LOG-TYPE = 'E'.
CONCATENATE DELNO '数量更新失败' INTO XET_LOG-MESSAGE .
APPEND XET_LOG.
ENDIF.
MOVE XET_LOG[] TO ET_LOG[].
ENDFUNCTION.
FORM DEL_CHILD USING DELNO P_LGORT .
DATA : HEADER_DATA LIKE BAPIOBDLVHDRCHG. "Delivery header
DATA : HEADER_CONTROL LIKE BAPIOBDLVHDRCTRLCHG. "delivery header control
DATA : I_DELIVERY_NO LIKE BAPIOBDLVHDRCHG-DELIV_NUMB. "deliver number
DATA : TECHN_CONTROL LIKE BAPIDLVCONTROL. "TECHN_CONTROL
DATA : ITEM_DATA LIKE BAPIOBDLVITEMCHG OCCURS 0 WITH HEADER LINE. "ITEM_DATA delivery item
DATA : ITEM_CONTROL LIKE BAPIOBDLVITEMCTRLCHG OCCURS 0 WITH HEADER LINE. "ITEM_CONTROL
DATA : RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE. "Return
DATA: ITEM_DATA_SPL LIKE /SPE/BAPIOBDLVITEMCHG OCCURS 0 WITH HEADER LINE.
*Set Delivery Header data
MOVE DELNO TO I_DELIVERY_NO .
HEADER_DATA-DELIV_NUMB = I_DELIVERY_NO.
TECHN_CONTROL-UPD_IND = 'U'.
HEADER_CONTROL-DELIV_NUMB = I_DELIVERY_NO.
LOOP AT ITP WHERE UECHA IS NOT INITIAL.
ITEM_DATA-DELIV_NUMB = I_DELIVERY_NO.
ITEM_DATA-DELIV_ITEM = ITP-POSNR.
ITEM_DATA-FACT_UNIT_NOM = 1.
ITEM_DATA-FACT_UNIT_DENOM = 1.
ITEM_CONTROL-DELIV_NUMB = I_DELIVERY_NO.
ITEM_CONTROL-DELIV_ITEM = ITP-POSNR.
ITEM_CONTROL-DEL_ITEM = 'X'.
APPEND ITEM_DATA.
APPEND ITEM_CONTROL.
ENDLOOP.
CLEAR: ITEM_CONTROL,ITEM_DATA.
LOOP AT ITP WHERE UECHA IS INITIAL.
ITEM_DATA-DELIV_NUMB = I_DELIVERY_NO.
ITEM_DATA-DELIV_ITEM = ITP-POSNR.
ITEM_DATA-FACT_UNIT_NOM = 1.
ITEM_DATA-FACT_UNIT_DENOM = 1.
ITEM_CONTROL-DELIV_NUMB = I_DELIVERY_NO.
ITEM_CONTROL-DELIV_ITEM = ITP-POSNR.
APPEND ITEM_DATA.
APPEND ITEM_CONTROL.
ITEM_DATA_SPL-DELIV_NUMB = I_DELIVERY_NO.
ITEM_DATA_SPL-DELIV_ITEM = ITP-POSNR.
ITEM_DATA_SPL-STGE_LOC = P_LGORT.
APPEND ITEM_DATA_SPL.
ENDLOOP.
CALL FUNCTION 'BAPI_OUTB_DELIVERY_CHANGE'
EXPORTING
HEADER_DATA = HEADER_DATA
HEADER_CONTROL = HEADER_CONTROL
DELIVERY = I_DELIVERY_NO
TECHN_CONTROL = TECHN_CONTROL
TABLES
ITEM_DATA = ITEM_DATA
ITEM_CONTROL = ITEM_CONTROL
ITEM_DATA_SPL = ITEM_DATA_SPL
RETURN = RETURN.
IF SY-SUBRC EQ 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
ENDIF.
DATA: I_ERROR_MESSAGES LIKE ARRANG_ERR.
DATA: ET_LOG LIKE RETURN.
DATA S(200).
LOOP AT RETURN INTO ET_LOG.
MOVE ET_LOG-TYPE TO I_ERROR_MESSAGES-MSGTY.
MOVE ET_LOG-ID TO I_ERROR_MESSAGES-MSGID.
MOVE ET_LOG-NUMBER TO I_ERROR_MESSAGES-MSGNO.
CALL FUNCTION 'MM_ARRANG_GET_MESSAGE_TEXT'
EXPORTING
I_ERROR_MESSAGES = I_ERROR_MESSAGES
I_LANGU = SY-LANGU
IMPORTING
E_TEXT = ET_LOG-MESSAGE
EXCEPTIONS
PARAMETER_ERROR = 1
OTHERS = 2.
CONCATENATE ET_LOG-MESSAGE
ET_LOG-MESSAGE_V1 ET_LOG-MESSAGE_V2
ET_LOG-MESSAGE_V3 ET_LOG-MESSAGE_V4 INTO ET_LOG-MESSAGE.
WRITE / ET_LOG-MESSAGE.
APPEND ET_LOG TO XET_LOG.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ADD_CHILD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_DELNO text
*----------------------------------------------------------------------*
FORM ADD_CHILD USING P_DELNO P_LGORT .
DATA : HEADER_DATA LIKE BAPIOBDLVHDRCHG. "Delivery header
DATA : HEADER_CONTROL LIKE BAPIOBDLVHDRCTRLCHG. "delivery header control
DATA : I_DELIVERY_NO LIKE BAPIOBDLVHDRCHG-DELIV_NUMB. "deliver number
DATA : TECHN_CONTROL LIKE BAPIDLVCONTROL. "TECHN_CONTROL
DATA : ITEM_DATA LIKE BAPIOBDLVITEMCHG OCCURS 0 WITH HEADER LINE. "ITEM_DATA delivery item
DATA : ITEM_CONTROL LIKE BAPIOBDLVITEMCTRLCHG OCCURS 0 WITH HEADER LINE. "ITEM_CONTROL
DATA : RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE. "Return
DATA: IPK LIKE /SPE/BAPIOBDLVITEMCHG OCCURS 0 WITH HEADER LINE.
*Set Delivery Header data
MOVE P_DELNO TO I_DELIVERY_NO.
HEADER_DATA-DELIV_NUMB = I_DELIVERY_NO.
TECHN_CONTROL-UPD_IND = 'U'.
HEADER_CONTROL-DELIV_NUMB = I_DELIVERY_NO.
DATA: V_WERKS TYPE LGORT_D,V_LGORT TYPE LGORT_D.
V_WERKS = ILIPS-WERKS.
V_LGORT = ILIPS-LGORT.
IF V_VBTYP = 'H' OR V_VBTYP = 'T'. "退货
* MOVE ITK-KUNNR TO V_WERKS.
* SHIFT V_WERKS LEFT DELETING LEADING '0'.
SELECT SINGLE WERKS LGORT
INTO (V_WERKS ,V_LGORT)
FROM EKPO WHERE EBELN =
ILIPS-VGBEL AND EBELP = ILIPS-VGPOS.
* LOOP AT ITP .
* MOVE V_WERKS TO ITP-WERKS.
* MOVE V_LGORT TO ITP-LGORT.
* MODIFY ITP.
* ENDLOOP.
ENDIF.
*DATA: BEGIN OF ILIPS OCCURS 0,
* POSNR LIKE LIPS-POSNR,
* LGORT LIKE LIPS-LGORT,
* LFIMG LIKE LIPSD-G_LFIMG,
* END OF ILIPS.
LOOP AT ITP WHERE UECHA IS INITIAL.
ITEM_DATA-DELIV_NUMB = I_DELIVERY_NO.
ITEM_DATA-DELIV_ITEM = ITP-POSNR .
ITEM_DATA-HIERARITEM = ITP-POSNR. "The batch split record below delivery item hierary
* ITEM_DATA-USEHIERITM = '1'.
* ITEM_DATA-MATERIAL = ITP-MATNR.
* ITEM_DATA-BATCH = LT_MCHB-CHARG.
ITEM_DATA-DLV_QTY = 0.
*ITEM_DATA-DLV_QTY_IMUNIT = 1000.
ITEM_DATA-FACT_UNIT_NOM = 1.
ITEM_DATA-FACT_UNIT_DENOM = 1.
ITEM_CONTROL-DELIV_NUMB = I_DELIVERY_NO.
ITEM_CONTROL-DELIV_ITEM = ITEM_DATA-DELIV_ITEM.
ITEM_CONTROL-CHG_DELQTY = 'X'.
IPK-DELIV_NUMB = I_DELIVERY_NO.
IPK-DELIV_ITEM = ITEM_DATA-DELIV_ITEM.
IPK-STGE_LOC = P_LGORT.
APPEND IPK.
APPEND ITEM_CONTROL.
APPEND ITEM_DATA.
ENDLOOP.
DATA: LT_MCHB LIKE MCHB OCCURS 0 WITH HEADER LINE.
CLEAR LT_MCHB[].
SELECT CHARG CLABS MATNR WERKS LGORT
INTO CORRESPONDING FIELDS OF TABLE LT_MCHB
FROM MCHB AS M
FOR ALL ENTRIES IN ITP
WHERE MATNR = ITP-MATNR
AND WERKS = V_WERKS
AND LGORT = V_LGORT
AND CLABS > 0
.
DATA: V_OMENG LIKE VBBE-OMENG.
LOOP AT ITP WHERE UECHA IS INITIAL.
SORT LT_MCHB BY MATNR CHARG.
LOOP AT LT_MCHB WHERE MATNR = ITP-MATNR.
CLEAR V_OMENG.
SELECT SUM( OMENG ) INTO V_OMENG FROM VBBE
WHERE MATNR = LT_MCHB-MATNR
AND WERKS = LT_MCHB-WERKS
AND CHARG = LT_MCHB-CHARG
AND LGORT = LT_MCHB-LGORT.
LT_MCHB-CLABS = LT_MCHB-CLABS - V_OMENG.
CHECK LT_MCHB-CLABS > 0.
CHECK ILIPS-LFIMG > 0.
ITEM_DATA-DELIV_NUMB = I_DELIVERY_NO.
ITEM_DATA-DELIV_ITEM = '90000' + ITP-POSNR + SY-TABIX.
ITEM_DATA-HIERARITEM = ITP-POSNR. "The batch split record below delivery item hierary
ITEM_DATA-USEHIERITM = '1'.
ITEM_DATA-MATERIAL = ITP-MATNR.
ITEM_DATA-BATCH = LT_MCHB-CHARG.
IPK-DELIV_NUMB = I_DELIVERY_NO.
IPK-DELIV_ITEM = ITEM_DATA-DELIV_ITEM.
IPK-STGE_LOC = P_LGORT.
APPEND IPK.
IF ILIPS-LFIMG >= LT_MCHB-CLABS.
ITEM_DATA-DLV_QTY = LT_MCHB-CLABS.
ELSE.
ITEM_DATA-DLV_QTY = ILIPS-LFIMG.
ENDIF.
ITEM_DATA-DLV_QTY_IMUNIT = ITEM_DATA-DLV_QTY .
ITEM_DATA-FACT_UNIT_NOM = 1.
ITEM_DATA-FACT_UNIT_DENOM = 1.
ITEM_CONTROL-DELIV_NUMB = I_DELIVERY_NO.
ITEM_CONTROL-DELIV_ITEM = ITEM_DATA-DELIV_ITEM.
ITEM_CONTROL-CHG_DELQTY = 'X'.
APPEND ITEM_CONTROL.
APPEND ITEM_DATA.
IPK-DELIV_NUMB = I_DELIVERY_NO.
IPK-DELIV_ITEM = ITEM_DATA-DELIV_ITEM.
IPK-STGE_LOC = P_LGORT.
APPEND IPK.
ILIPS-LFIMG = ILIPS-LFIMG - ITEM_DATA-DLV_QTY.
ENDLOOP.
ENDLOOP.
CALL FUNCTION 'BAPI_OUTB_DELIVERY_CHANGE'
EXPORTING
HEADER_DATA = HEADER_DATA
HEADER_CONTROL = HEADER_CONTROL
DELIVERY = I_DELIVERY_NO
TECHN_CONTROL = TECHN_CONTROL
TABLES
ITEM_DATA = ITEM_DATA
ITEM_CONTROL = ITEM_CONTROL
ITEM_DATA_SPL = IPK[]
RETURN = RETURN.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
DATA: I_ERROR_MESSAGES LIKE ARRANG_ERR.
DATA S(200).
DATA: ET_LOG LIKE RETURN.
LOOP AT RETURN INTO ET_LOG.
MOVE ET_LOG-TYPE TO I_ERROR_MESSAGES-MSGTY.
MOVE ET_LOG-ID TO I_ERROR_MESSAGES-MSGID.
MOVE ET_LOG-NUMBER TO I_ERROR_MESSAGES-MSGNO.
CALL FUNCTION 'MM_ARRANG_GET_MESSAGE_TEXT'
EXPORTING
I_ERROR_MESSAGES = I_ERROR_MESSAGES
I_LANGU = SY-LANGU
IMPORTING
E_TEXT = ET_LOG-MESSAGE
EXCEPTIONS
PARAMETER_ERROR = 1
OTHERS = 2.
CONCATENATE ET_LOG-MESSAGE
ET_LOG-MESSAGE_V1
ET_LOG-MESSAGE_V2
ET_LOG-MESSAGE_V3
ET_LOG-MESSAGE_V4
INTO ET_LOG-MESSAGE.
WRITE / ET_LOG-MESSAGE.
APPEND ET_LOG TO XET_LOG.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form CHECK_POST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_DELNO text
*----------------------------------------------------------------------*
FORM CHECK_POST USING P_DELNO P_LGORT..
DATA:
HDATA LIKE BAPIOBDLVHDRCON,
HCTRL LIKE BAPIOBDLVHDRCTRLCON,
IPK LIKE TABLE OF /SPE/BAPIOBDLVITEMCONF WITH HEADER LINE,
RET LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE,
HDL LIKE TABLE OF BAPIDLVDEADLN WITH HEADER LINE.
DATA:
ITEM_DATA LIKE BAPIOBDLVITEMCON OCCURS 0 WITH HEADER LINE,
ITEM_CONTROL LIKE BAPIOBDLVITEMCTRLCON OCCURS 0 WITH HEADER LINE.
HDATA-DELIV_NUMB = P_DELNO.
HCTRL-DELIV_NUMB = P_DELNO.
HCTRL-POST_GI_FLG = 'X'.
"标记更更实际和计划的过账时间, 时间的值在 HEADER_DEADLINES 参数里添加(这个开始没注意看帮助,走了很多弯路,才找到)
HCTRL-DELIV_DATE_FLG = 'X'.
HCTRL-GDSI_DATE_FLG ='X'.
SELECT POSNR VBELN INTO (IPK-DELIV_ITEM,IPK-DELIV_NUMB) FROM LIPS WHERE VBELN = P_DELNO.
IPK-STGE_LOC = P_LGORT.
APPEND IPK.
ENDSELECT.
*“ 查 HEADER_DEADLINES 说明得到下面提示
*- WSHDRLFDAT Delivery date
*- WSHDRWADAT Goods issue date (planned)
*- WSHDRWADTI Goods issue date (actual)
*- WSHDRLDDAT Loading date
*- WSHDRTDDAT Transportation planning date
*- WSHDRKODAT Picking date
*hdl-DELIV_NUMB = delno.
*hdl-timetype = 'WSHDRWADTI'. "实际过账日期
*hdl-timestamp_utc = date1.
*append hdl.
*
*hdl-DELIV_NUMB = delno.
*hdl-timetype = 'WSHDRWADAT'. "计划日期
*hdl-timestamp_utc = date1.
*append hdl.
CALL FUNCTION 'BAPI_OUTB_DELIVERY_CONFIRM_DEC'
EXPORTING
HEADER_DATA = HDATA
HEADER_CONTROL = HCTRL
DELIVERY = P_DELNO
* TECHN_CONTROL =
* HEADER_DATA_SPL =
* HEADER_CONTROL_SPL =
TABLES
* HEADER_PARTNER =
* HEADER_PARTNER_ADDR =
HEADER_DEADLINES = HDL
* ITEM_DATA = ITEM_DATA
* ITEM_CONTROL = ITEM_CONTROL
* ITEM_SERIAL_NO =
* SUPPLIER_CONS_DATA =
* HANDLING_UNIT_HEADER =
* HANDLING_UNIT_ITEM =
* HANDLING_UNIT_SERNO =
* EXTENSION1 =
* EXTENSION2 =
ITEM_DATA_SPL = IPK[]
RETURN = RET
* TOKENREFERENCE =
* HANDLING_UNIT_HEADER_CROSS =
* ITEM_DATA_SPL =
* HANDLING_UNIT_IDENTIFIERS =
* HANDLING_UNIT_ITEM_SPL =
.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
DATA: I_ERROR_MESSAGES LIKE ARRANG_ERR.
DATA: ET_LOG LIKE RET.
DATA S(200).
LOOP AT RET INTO ET_LOG.
MOVE ET_LOG-TYPE TO I_ERROR_MESSAGES-MSGTY.
MOVE ET_LOG-ID TO I_ERROR_MESSAGES-MSGID.
MOVE ET_LOG-NUMBER TO I_ERROR_MESSAGES-MSGNO.
CALL FUNCTION 'MM_ARRANG_GET_MESSAGE_TEXT'
EXPORTING
I_ERROR_MESSAGES = I_ERROR_MESSAGES
I_LANGU = SY-LANGU
IMPORTING
E_TEXT = ET_LOG-MESSAGE
EXCEPTIONS
PARAMETER_ERROR = 1
OTHERS = 2.
CONCATENATE ET_LOG-MESSAGE
ET_LOG-MESSAGE_V1
ET_LOG-MESSAGE_V2
ET_LOG-MESSAGE_V3
ET_LOG-MESSAGE_V4
INTO ET_LOG-MESSAGE.
WRITE / ET_LOG-MESSAGE.
APPEND ET_LOG TO XET_LOG.
ENDLOOP.
ENDFORM.
FORM GET_PICK USING P_DELNO.
DATA:VBKOK_WA TYPE VBKOK,
VBPOK_TAB TYPE VBPOK OCCURS 0 WITH HEADER LINE.
VBKOK_WA-VBELN_VL = P_DELNO.
DATA: ITPS LIKE LIPS OCCURS 0 WITH HEADER LINE.
SELECT VBELN POSNR LFIMG UECHA
INTO CORRESPONDING FIELDS OF TABLE ITPS
FROM LIPS
WHERE VBELN = P_DELNO.
LOOP AT ITPS.
VBPOK_TAB-VBELN_VL = ITPS-VBELN.
VBPOK_TAB-POSNR_VL = ITPS-POSNR.
VBPOK_TAB-VBELN = ITPS-VBELN.
VBPOK_TAB-POSNN = ITPS-POSNR.
VBPOK_TAB-PIKMG = ITPS-LFIMG . "实际已交货量(按销售单位)
APPEND VBPOK_TAB.
ENDLOOP.
DATA: PROTT LIKE PROTT OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'SD_DELIVERY_UPDATE_PICKING'
EXPORTING
VBKOK_WA = VBKOK_WA
SYNCHRON = 'X'
TABLES
VBPOK_TAB = VBPOK_TAB
PROT = PROTT.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
ENDFORM.
FORM GET_PICK0 USING P_DELNO.
DATA:
CTU LIKE APQI-PUTACTIVE VALUE 'X',
UPDATE LIKE APQI-PUTACTIVE VALUE 'L',
I_ERROR_MESSAGES LIKE ARRANG_ERR,
ET_MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE,
GROUP LIKE APQI-GROUPID,
USER LIKE APQI-USERID,
KEEP LIKE APQI-QERASE,
HOLDDATE LIKE APQI-STARTDATE,
NODATA LIKE APQI-PUTACTIVE VALUE '/',
SUBRC LIKE SY-SUBRC,
MODE LIKE APQI-PUTACTIVE VALUE 'N',
I_LOG LIKE BAPIRETURN1 OCCURS 0 WITH HEADER LINE.
PERFORM BDC_NODATA USING NODATA.
PERFORM OPEN_GROUP USING GROUP USER KEEP HOLDDATE CTU.
PERFORM BDC_DYNPRO USING 'SAPMV50A' '4004'.
PERFORM BDC_FIELD USING 'BDC_CURSOR' 'LIKP-VBELN'.
PERFORM BDC_FIELD USING 'BDC_OKCODE' '/00'.
PERFORM BDC_FIELD USING 'LIKP-VBELN' P_DELNO.
PERFORM BDC_DYNPRO USING 'SAPMV50A' '1000'.
PERFORM BDC_FIELD USING 'BDC_OKCODE' '=SICH_T'.
PERFORM BDC_FIELD USING 'LIPSD-PIKMG(01)' ''.
PERFORM BDC_FIELD USING 'LIPS-CHARG(01)' ''.
PERFORM BDC_FIELD USING 'LIPS-LGORT(01)' ''.
PERFORM BDC_TRANSACTION TABLES ET_MESSTAB
USING 'VL02N' CTU MODE UPDATE.
PERFORM CLOSE_GROUP USING CTU.
COMMIT WORK.
DATA: ET_LOG LIKE BAPIRET2 .
DATA S(200).
LOOP AT ET_MESSTAB.
* CONCATENATE ' ET_MESSTAB-MSGID :' ET_MESSTAB-MSGID INTO S. WRITE / S.
* CONCATENATE ' ET_MESSTAB-MSGTYP: ' ET_MESSTAB-MSGTYP INTO S. WRITE / S.
* CONCATENATE ' ET_MESSTAB-MSGNR : ' ET_MESSTAB-MSGNR INTO S. WRITE / S.
* CONCATENATE ' ET_MESSTAB-MSGV1 : ' ET_MESSTAB-MSGV1 INTO S. WRITE / S.
* CONCATENATE ' ET_MESSTAB-MSGV2 : ' ET_MESSTAB-MSGV2 INTO S. WRITE / S.
* CONCATENATE ' ET_MESSTAB-MSGV3 : ' ET_MESSTAB-MSGV3 INTO S. WRITE / S.
* CONCATENATE ' ET_MESSTAB-MSGV4 : ' ET_MESSTAB-MSGV4 INTO S. WRITE / S.
* CLEAR ET_LOG[].
ET_LOG-TYPE = ET_MESSTAB-MSGTYP.
ET_LOG-ID = ET_MESSTAB-MSGID.
ET_LOG-NUMBER = ET_MESSTAB-MSGNR.
CALL FUNCTION 'MM_ARRANG_GET_MESSAGE_TEXT'
EXPORTING
I_ERROR_MESSAGES = I_ERROR_MESSAGES
I_LANGU = SY-LANGU
IMPORTING
E_TEXT = ET_LOG-MESSAGE
EXCEPTIONS
PARAMETER_ERROR = 1
OTHERS = 2.
CONCATENATE ET_LOG-MESSAGE ET_MESSTAB-MSGV1 ET_MESSTAB-MSGV2 ET_MESSTAB-MSGV3 ET_MESSTAB-MSGV4 INTO ET_LOG-MESSAGE.
* IF ET_MESSTAB-MSGNR = '311'.
* EX_VBELN = ET_MESSTAB-MSGV2.
** EP_SUBRC = 0.
* ENDIF.
APPEND ET_LOG TO XET_LOG.
ENDLOOP.
ENDFORM.
FORM CHECK_NO_BATCH_POST USING S_LIPS TYPE LIPS ."CHANGING IS_POST TYPE C.
DATA: BEGIN OF RECORD,
* data element: VBELN_VL
VBELN_001(025),
* data element: LGORT_D
LGORT_01_002(004),
* data element: LFIMG
G_LFIMG_01_003(017),
G_PIKMG_01_003(017),
* data element: CHARG_D
CHARG_01_004(010),
END OF RECORD.
* data element: VBELN_VL
RECORD-VBELN_001 = S_LIPS-VBELN.
* data element: LGORT_D
RECORD-LGORT_01_002 = S_LIPS-LGORT.
* data element: LFIMG
RECORD-G_LFIMG_01_003 = S_LIPS-LFIMG.
* data element: CHARG_D
* record-CHARG_01_004(010) = IP_CHARG.
RECORD-G_PIKMG_01_003 = S_LIPS-LFIMG.
DATA:
CTU LIKE APQI-PUTACTIVE VALUE 'X',
UPDATE LIKE APQI-PUTACTIVE VALUE 'L',
I_ERROR_MESSAGES LIKE ARRANG_ERR,
ET_MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE,
GROUP LIKE APQI-GROUPID,
USER LIKE APQI-USERID,
KEEP LIKE APQI-QERASE,
HOLDDATE LIKE APQI-STARTDATE,
NODATA LIKE APQI-PUTACTIVE VALUE '/',
SUBRC LIKE SY-SUBRC,
MODE LIKE APQI-PUTACTIVE VALUE 'N',
I_LOG LIKE BAPIRETURN1 OCCURS 0 WITH HEADER LINE.
PERFORM BDC_NODATA USING NODATA.
PERFORM OPEN_GROUP USING GROUP USER KEEP HOLDDATE CTU.
*perform bdc_dynpro using 'SAPMV50A' '4004'.
*perform bdc_field using 'BDC_CURSOR' 'LIKP-VBELN'.
*perform bdc_field using 'BDC_OKCODE' '/00'.
*perform bdc_field using 'LIKP-VBELN' IP_VBELN.
*perform bdc_dynpro using 'SAPMV50A' '1000'.
*perform bdc_field using 'BDC_OKCODE' '=WABU_T'.
*perform bdc_field using 'BDC_CURSOR' 'LIPS-CHARG(01)'.
*perform bdc_field using 'LIPS-LGORT(01)' IP_LGORT .
*perform bdc_field using 'LIPSD-G_LFIMG(01)' IP_LFIMG .
*perform bdc_field using 'LIPS-CHARG(01)' IP_CHARG.
PERFORM BDC_DYNPRO USING 'SAPMV50A' '4004'.
PERFORM BDC_FIELD USING 'BDC_CURSOR' 'LIKP-VBELN'.
PERFORM BDC_FIELD USING 'BDC_OKCODE' '/00'.
PERFORM BDC_FIELD USING 'LIKP-VBELN' S_LIPS-VBELN.
PERFORM BDC_DYNPRO USING 'SAPMV50A' '1000'.
* PERFORM BDC_FIELD USING 'BDC_CURSOR' 'LIPS-CHARG(01)'.
PERFORM BDC_FIELD USING 'LIPS-LGORT(01)' S_LIPS-LGORT.
PERFORM BDC_FIELD USING 'LIPSD-G_LFIMG(01)' RECORD-G_LFIMG_01_003 .
IF V_KOMRL = 'X'.
PERFORM BDC_FIELD USING 'LIPSD-PIKMG(01)' RECORD-G_LFIMG_01_003.
ENDIF.
* IF RECORD-CHARG_01_004 = ' '.
* ELSE.
* PERFORM BDC_FIELD USING 'LIPS-CHARG(01)' RECORD-CHARG_01_004.
* ENDIF.
PERFORM BDC_FIELD USING 'BDC_OKCODE' '=WABU_T'.
PERFORM BDC_TRANSACTION TABLES ET_MESSTAB
USING 'VL02N' CTU MODE UPDATE.
* WAIT UP TO 1 SECONDS.
PERFORM CLOSE_GROUP USING CTU.
COMMIT WORK AND WAIT.
"----------------------------------------------------------------------
DATA: ET_LOG LIKE BAPIRET2 .
DATA S(200).
LOOP AT ET_MESSTAB.
* CONCATENATE ' ET_MESSTAB-MSGID :' ET_MESSTAB-MSGID INTO S. WRITE / S.
* CONCATENATE ' ET_MESSTAB-MSGTYP: ' ET_MESSTAB-MSGTYP INTO S. WRITE / S.
* CONCATENATE ' ET_MESSTAB-MSGNR : ' ET_MESSTAB-MSGNR INTO S. WRITE / S.
* CONCATENATE ' ET_MESSTAB-MSGV1 : ' ET_MESSTAB-MSGV1 INTO S. WRITE / S.
* CONCATENATE ' ET_MESSTAB-MSGV2 : ' ET_MESSTAB-MSGV2 INTO S. WRITE / S.
* CONCATENATE ' ET_MESSTAB-MSGV3 : ' ET_MESSTAB-MSGV3 INTO S. WRITE / S.
* CONCATENATE ' ET_MESSTAB-MSGV4 : ' ET_MESSTAB-MSGV4 INTO S. WRITE / S.
* CLEAR ET_LOG[].
ET_LOG-TYPE = ET_MESSTAB-MSGTYP.
ET_LOG-ID = ET_MESSTAB-MSGID.
ET_LOG-NUMBER = ET_MESSTAB-MSGNR.
CALL FUNCTION 'MM_ARRANG_GET_MESSAGE_TEXT'
EXPORTING
I_ERROR_MESSAGES = I_ERROR_MESSAGES
I_LANGU = SY-LANGU
IMPORTING
E_TEXT = ET_LOG-MESSAGE
EXCEPTIONS
PARAMETER_ERROR = 1
OTHERS = 2.
CONCATENATE ET_LOG-MESSAGE ET_MESSTAB-MSGV1 ET_MESSTAB-MSGV2 ET_MESSTAB-MSGV3 ET_MESSTAB-MSGV4 INTO ET_LOG-MESSAGE.
* IF ET_MESSTAB-MSGNR = '311'.
* EX_VBELN = ET_MESSTAB-MSGV2.
** EP_SUBRC = 0.
* ENDIF.
APPEND ET_LOG TO XET_LOG.
ENDLOOP.
ENDFORM.
* INCLUDE BDCRECXY.