• WMS函数组:14.RDC入库2


    FUNCTION ZRFC_WMS_GOODSMVT_CREATE_D2.
    *"----------------------------------------------------------------------
    *"*"本地接口:
    *"  IMPORTING
    *"     VALUE(IT_ZMKPF002) LIKE  ZWMS_GOODSMOVE_HEAD STRUCTURE
    *"        ZWMS_GOODSMOVE_HEAD OPTIONAL
    *"  EXPORTING
    *"     VALUE(EP_SUBRC) TYPE  SY-SUBRC
    *"     VALUE(EP_MATERIALDOCUMENT) TYPE  BAPI2017_GM_HEAD_RET-MAT_DOC
    *"     VALUE(EP_MATDOCUMENTYEAR) TYPE  BAPI2017_GM_HEAD_RET-DOC_YEAR
    *"  TABLES
    *"      ET_LOG STRUCTURE  BAPIRET2 OPTIONAL
    *"      IT_DETAIL STRUCTURE  ZWMS_RDC_DETAIL OPTIONAL
    *"----------------------------------------------------------------------
    *GM_CODE 01: GOODS RECEIPT FOR PURCHASE ORDER
    *"----------------------------------------------------------------------
    DATA:
        GOODSMVT_CODE       LIKE  IT_ZMKPF002-GM_CODE,
        IP_GMHEAD           LIKE  BAPI2017_GM_HEAD_01     OCCURS    0
    WITH HEADER  LINE,
        IP_GMCODE           LIKE  BAPI2017_GM_CODE        OCCURS    0
    WITH HEADER  LINE,
        IP_MTHEAD           LIKE  BAPI2017_GM_HEAD_RET    OCCURS    0
    WITH HEADER  LINE,
        IP_MITEM            LIKE  BAPI2017_GM_ITEM_CREATE OCCURS    0
    WITH HEADER  LINE,
        EP_GOODSMVT_HEADRET LIKE  BAPI2017_GM_HEAD_RET OCCURS    0   WITH
    HEADER  LINE,
        I_ERROR_MESSAGES    LIKE  ARRANG_ERR,
        IT_LIPS             LIKE LIPS,
        I_LOG               LIKE  BAPIRET2        OCCURS 0 WITH HEADER LINE
    .
    CLEAR :
        IP_GMHEAD,
        IP_GMCODE ,
        IP_MTHEAD,
        IP_MITEM ,
        I_LOG,
        EP_GOODSMVT_HEADRET.
    REFRESH:
        IP_GMHEAD,
        IP_GMCODE ,
        IP_MTHEAD,
        IP_MITEM ,
        I_LOG,
        EP_GOODSMVT_HEADRET.
    **********  HEADER      凭证日期
    IF IT_ZMKPF002-DOC_DATE IS NOT INITIAL.
        IP_GMHEAD-DOC_DATE = IT_ZMKPF002-DOC_DATE    .
    ELSE.
        IP_GMHEAD-DOC_DATE  = SY-DATUM  .
    ENDIF.
    **********  HEADER      记帐日期
    IF IT_ZMKPF002-PSTNG_DATE IS NOT INITIAL.
        IP_GMHEAD-PSTNG_DATE = IT_ZMKPF002-PSTNG_DATE    .
    ELSE.
        IP_GMHEAD-PSTNG_DATE = SY-DATUM .
    ENDIF.
    ****特殊入库日期控制
    IF SY-DATUM BETWEEN '20161227' AND '20161231'.
        IP_GMHEAD-DOC_DATE = '20170101'.
        IP_GMHEAD-PSTNG_DATE = '20170101'.
    ENDIF.
    *******下面取渠道
      IP_GMHEAD-REF_DOC_NO = IT_ZMKPF002-LFSNR.
    **********  HEADER     凭证抬头文本
      IP_GMHEAD-HEADER_TXT = IT_ZMKPF002-HEADER_TXT   .
    **********  HEADER 事务代码
      GOODSMVT_CODE = IT_ZMKPF002-GM_CODE.
      IP_GMCODE-GM_CODE  = GOODSMVT_CODE.
    **********  HEADER    用户名
      IP_GMHEAD-PR_UNAME = SY-UNAME.
    DATA:TMP_LINE LIKE IP_MITEM-LINE_ID.
    ***********明细
    *------------CHA JWY 20170811
    SORT IT_DETAIL.
    *------------CHA JWY 20170811
    LOOP AT IT_DETAIL.
    SELECT SINGLE * INTO  IT_LIPS FROM LIPS WHERE VBELN =
    IT_DETAIL-VBELN AND POSNR = IT_DETAIL-POSNR.
        IP_MITEM-MATERIAL =  IT_LIPS-MATNR.
    *    IP_MITEM-PLANT =  IT_LIPS-WERKS.
    IF IT_DETAIL-LGOBE = '6700'.
          IP_MITEM-PLANT =  '6700'.
    ELSE.
          IP_MITEM-PLANT =  IT_LIPS-WERKS.
    ENDIF.
        IP_MITEM-STGE_LOC =  IT_DETAIL-LGOBE.
    IF IT_LIPS-CHARG IS NOT INITIAL.
          IP_MITEM-BATCH = IT_LIPS-CHARG.
    ELSE.
          IP_MITEM-BATCH = IT_DETAIL-CHARG.
    ENDIF.
    IF IT_LIPS-SOBKZ = 'Q' AND   IT_LIPS-PSTYV = 'NCCR'.
          IP_MITEM-MOVE_TYPE = '109'.
    ELSE.
          IP_MITEM-MOVE_TYPE = '101'.
    ENDIF.
        IP_MITEM-ENTRY_QNT = IT_DETAIL-ERFMG.
        IP_MITEM-PO_NUMBER = IT_LIPS-VGBEL.
        IP_MITEM-PO_ITEM = IT_LIPS-VGPOS.
        IP_MITEM-MVT_IND = 'B'.
        IP_MITEM-DELIV_NUMB_TO_SEARCH = IT_DETAIL-VBELN.
        IP_MITEM-DELIV_ITEM_TO_SEARCH = IT_DETAIL-POSNR.
        IP_MITEM-DELIV_NUMB =  IT_DETAIL-VBELN.
        IP_MITEM-DELIV_ITEM = IT_DETAIL-POSNR.
    PERFORM F_ADD_ZERO USING IP_MITEM-PO_NUMBER.
    PERFORM F_ADD_ZERO USING IP_MITEM-PO_ITEM.
    IF IP_MITEM-PO_NUMBER+0(1) = '4'.
    SELECT SINGLE WERKS LGORT INTO (IP_MITEM-PLANT,IP_MITEM-STGE_LOC)
    FROM EKPO
    WHERE    EBELN = IP_MITEM-PO_NUMBER AND EBELP = IP_MITEM-PO_ITEM.
    ENDIF.
    PERFORM F_ADD_ZERO USING IP_MITEM-DELIV_NUMB_TO_SEARCH.
    PERFORM F_ADD_ZERO USING IP_MITEM-DELIV_ITEM_TO_SEARCH.
    PERFORM F_ADD_ZERO USING  IP_MITEM-DELIV_NUMB.
    PERFORM F_ADD_ZERO USING IP_MITEM-DELIV_ITEM.
    SELECT SINGLE LIFNR INTO IP_MITEM-VENDOR FROM EKKO WHERE EBELN =
    IP_MITEM-PO_NUMBER.
    *=====行号===========================
    CLEAR TMP_LINE.
    DESCRIBE TABLE IP_MITEM LINES TMP_LINE .
        TMP_LINE = TMP_LINE + 1.
    PERFORM F_ADD_ZERO USING TMP_LINE.
        IP_MITEM-LINE_ID = TMP_LINE .
        IP_MITEM-PARENT_ID = '000000'.
    APPEND IP_MITEM.
    ENDLOOP.
    ***以下是进行过帐处理*******************************************
    *Append lines of IP_MITEM to IT_R. "显示输入参数便于调试
    CLEAR I_LOG[].
    ****************处理特殊移动类型
    DATA LV_MEMORY  TYPE CHAR30.
    CONCATENATE SY-UNAME SY-DATUM INTO LV_MEMORY .
    EXPORT IP_MITEM[] TO MEMORY ID LV_MEMORY.
    CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
    EXPORTING
          GOODSMVT_HEADER  = IP_GMHEAD
          GOODSMVT_CODE    = IP_GMCODE
    IMPORTING
          GOODSMVT_HEADRET = EP_GOODSMVT_HEADRET
          MATERIALDOCUMENT = EP_MATERIALDOCUMENT
          MATDOCUMENTYEAR  = EP_MATDOCUMENTYEAR
    TABLES
          GOODSMVT_ITEM    = IP_MITEM
    RETURN           = I_LOG.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
    WAIT = 'X'.
    CLEAR:IP_MITEM[].
    *------------CHA JWY 20170811
    SORT I_LOG.
    *------------CHA JWY 20170811
    LOOP AT I_LOG.
    IF I_LOG-TYPE = 'E'.
    CONCATENATE IT_ZMKPF002-LFSNR I_LOG-MESSAGE INTO ET_LOG-MESSAGE.
          ET_LOG-TYPE =  I_LOG-TYPE .
          ET_LOG-ID               = I_LOG-ID .
          ET_LOG-NUMBER           = I_LOG-NUMBER.
          ET_LOG-LOG_NO           = I_LOG-LOG_NO.
    APPEND  ET_LOG.
    ENDIF.
    ENDLOOP.
    CLEAR I_LOG[].
    READ  TABLE   I_LOG WITH  KEY  TYPE   = 'E'.
    IF  SY-SUBRC   =   0  .
        EP_SUBRC  =  -1.
    ENDIF.
    ENDFUNCTION.

  • 相关阅读:
    Picture
    wolf and rabbit
    十进制转换为二进制(一直不会算的)
    各种排序
    折线分割平面
    字母数
    1001
    Primes
    大数的减法神秘数
    转: Windows Internet WinINet 学习笔记(2)
  • 原文地址:https://www.cnblogs.com/twttafku/p/14327468.html
Copyright © 2020-2023  润新知