• WMS函数组:15.WMS-RDC批量入库


    FUNCTION ZRFC_WMS_GOODSMVT_CREATE_RDC.
    *"----------------------------------------------------------------------
    *"*"本地接口:
    *"  TABLES
    *"      IT_HEAD STRUCTURE  ZWMS_RDC_HEAD OPTIONAL
    *"      IT_DETAIL STRUCTURE  ZWMS_RDC_DETAIL OPTIONAL
    *"      IT_RETURN STRUCTURE  ZINTERFACE_RETURN OPTIONAL
    *"      ET_LOG STRUCTURE  BAPIRET2 OPTIONAL
    *"----------------------------------------------------------------------
    DATA:
        MATERIALDOCUMENT LIKE        BAPI2017_GM_HEAD_RET-MAT_DOC,
        MATDOCUMENTYEAR  LIKE        BAPI2017_GM_HEAD_RET-DOC_YEAR.
    DATA:
        IT_ZMKPF2   LIKE ZWMS_GOODSMOVE_HEAD,
        I_LOG       LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE,
        IT_RET2     LIKE ZINTERFACE_RETURN OCCURS 0 WITH HEADER LINE,
        IT_DETAIL_D LIKE IT_DETAIL OCCURS 0 WITH HEADER LINE.
    *----------------CHA JWY_20170811
    SORT IT_HEAD.
    SORT IT_DETAIL.
    *----------------CHA JWY_20170811
    DATA: IT_LIPS LIKE LIPS OCCURS 0 WITH HEADER LINE.
    DATA: IT_EKBE LIKE EKBE OCCURS 0 WITH HEADER LINE.
    **  第一步,判断是否是WMS传进来的汇总项目
    DELETE  IT_DETAIL WHERE ERFMG = 0 .
    DATA: VBELN TYPE VBELN.
    LOOP AT IT_HEAD.
    SELECT SINGLE  VBELN INTO VBELN
    FROM VBUK
    WHERE VBELN = IT_HEAD-VBELN
    AND WBSTK = 'C' .
    CHECK SY-SUBRC = 0.
    LOOP AT IT_DETAIL WHERE  VBELN =  IT_HEAD-VBELN.
    CLEAR IT_LIPS[]. ""查出所有子项目
    SELECT VBELN POSNR CHARG
            VGBEL
            VGPOS
            LFIMG
    INTO CORRESPONDING FIELDS OF TABLE IT_LIPS
    FROM LIPS
    WHERE VBELN = IT_DETAIL-VBELN
    AND  ( POSNR = IT_DETAIL-POSNR OR UECHA = IT_DETAIL-POSNR )
    AND LFIMG > 0.
    CLEAR IT_EKBE[].
    LOOP AT IT_LIPS. "查找子项目的收货状态"
    CLEAR IT_EKBE.
    SELECT EBELN EBELP  VBELN_ST VBELP_ST MENGE BWART
    INTO CORRESPONDING FIELDS OF  IT_EKBE
    FROM EKBE
    WHERE EBELN = IT_LIPS-VGBEL
    AND EBELP = IT_LIPS-VGPOS
    AND BEWTP = 'E'
    AND VBELN_ST = IT_LIPS-VBELN
    AND VBELP_ST = IT_LIPS-POSNR
    .
    IF IT_EKBE-BWART = '101'.
                IT_LIPS-LFIMG = IT_LIPS-LFIMG - IT_EKBE-MENGE.
    ENDIF.
    IF IT_EKBE-BWART = '102'.
                IT_LIPS-LFIMG = IT_LIPS-LFIMG + IT_EKBE-MENGE.
    ENDIF.
    CLEAR IT_EKBE.
    ENDSELECT.
    MODIFY IT_LIPS.
    ENDLOOP.
    LOOP AT IT_LIPS. "分配数量"
    CHECK IT_DETAIL-ERFMG > 0.
            IT_DETAIL_D-VBELN = IT_DETAIL-VBELN.
            IT_DETAIL_D-POSNR = IT_LIPS-POSNR.
            IT_DETAIL_D-CHARG = IT_LIPS-CHARG.
    IF IT_DETAIL-ERFMG >= IT_LIPS-LFIMG.
              IT_DETAIL_D-ERFMG = IT_LIPS-LFIMG.
    ELSE.
              IT_DETAIL_D-ERFMG = IT_DETAIL-ERFMG.
    ENDIF.
    APPEND IT_DETAIL_D.
            IT_DETAIL-ERFMG = IT_DETAIL-ERFMG - IT_DETAIL_D-ERFMG.
    ENDLOOP.
    ENDLOOP.
    ENDLOOP.
    DATA: ITH LIKE ZTAB_RDC_HEAD OCCURS 0 WITH HEADER LINE.
    DATA: ITD LIKE ZTAB_RDC_DETAIL OCCURS 0 WITH HEADER LINE.
    LOOP AT IT_HEAD.
        IT_ZMKPF2-GM_CODE = '01'.
        IT_ZMKPF2-LFSNR = IT_HEAD-VBELN.
    MOVE-CORRESPONDING IT_HEAD TO ITH.
    MOVE IT_HEAD-WMSNO TO ITH-MKEY.
    IF IT_DETAIL_D[] IS INITIAL.
          IT_RETURN-BILLNO =  IT_HEAD-VBELN.
          IT_RETURN-SAPNO = '空物料'.
          IT_RETURN-SUBRC = '00'.
          IT_RETURN-MSG = '行项目不存在'.
    APPEND IT_RETURN.
    ELSE.
    LOOP AT IT_DETAIL_D WHERE CHARG IS INITIAL.
    CLEAR IT_LIPS.
    READ TABLE IT_LIPS WITH KEY VBELN = IT_DETAIL_D-VBELN POSNR = IT_DETAIL_D-POSNR.
    IF SY-SUBRC = 0.
    IF IT_LIPS-CHARG IS NOT INITIAL.
                IT_RETURN-BILLNO =  IT_HEAD-VBELN.
                IT_RETURN-SAPNO = '批次不正确'.
                IT_RETURN-SUBRC = '00'.
    CONCATENATE IT_DETAIL_D-VBELN '~'  IT_DETAIL_D-POSNR INTO  IT_RETURN-MSG .
    APPEND IT_RETURN.
    DELETE IT_DETAIL_D.
    ENDIF.
    ENDIF.
    ENDLOOP.
    APPEND ITH.
    ENDIF.
    CHECK     IT_DETAIL_D[] IS NOT INITIAL.
    MOVE-CORRESPONDING IT_DETAIL_D[] TO ITD[].
    LOOP AT ITH.
    LOOP AT ITD WHERE VBELN = ITH-VBELN.
            ITD-MKEY = ITH-MKEY.
            ITD-MPOS = SY-TABIX.
    MODIFY ITD.
    ENDLOOP.
    ENDLOOP.
    MODIFY ZTAB_RDC_HEAD FROM TABLE ITH.
    MODIFY ZTAB_RDC_DETAIL FROM TABLE ITD.
    CLEAR: MATERIALDOCUMENT,MATDOCUMENTYEAR.
    CALL FUNCTION 'ZRFC_WMS_GOODSMVT_CREATE_D2'
    EXPORTING
            IT_ZMKPF002         = IT_ZMKPF2
    IMPORTING
            EP_MATERIALDOCUMENT = MATERIALDOCUMENT
            EP_MATDOCUMENTYEAR  = MATDOCUMENTYEAR
    TABLES
            IT_DETAIL           = IT_DETAIL_D
            ET_LOG              = I_LOG.
    APPEND LINES OF I_LOG TO ET_LOG.
        IT_RETURN-BILLNO =  IT_HEAD-VBELN.
        IT_RETURN-SAPNO = MATERIALDOCUMENT.
    IF MATERIALDOCUMENT = ''.
          IT_RETURN-SUBRC = '01'.
          IT_RETURN-MSG = I_LOG-MESSAGE.
    ENDIF.
    APPEND IT_RETURN.
    CLEAR IT_ZMKPF2.
    ENDLOOP.
    ENDFUNCTION.
    *FORM GET_GUID USING AGUID.
    *  DATA: GD TYPE GUID_32.
    *  CALL FUNCTION 'GUID_CREATE'
    *    IMPORTING
    *      EV_GUID_32 = GD.
    *  MOVE GD TO AGUID.
    *ENDFORM.                    "ShowPB

  • 相关阅读:
    MVVMLight leaning note
    c# Random Class usage
    Learning note for Binding and validation
    Content Template & DataTemplate 区别
    ListBox mvvm 学习笔记
    spinlock自旋锁de使用
    linux 内核(驱动)常用函数
    linux 编译,链接和加载
    Linux 下多核CPU知识
    linux 内核调试
  • 原文地址:https://www.cnblogs.com/twttafku/p/14327481.html
Copyright © 2020-2023  润新知