• WMS函数组: 7.交货单行项目除


    FUNCTION ZRFC_WMS_DELIVERY_DELETE.
    *"----------------------------------------------------------------------
    *"*"Local interface:
    *"  TABLES
    *"      ITAB_DETAIL STRUCTURE  ZVBPOK OPTIONAL
    *"      ITAB_RETURN STRUCTURE  ZINTERFACE_RETURN OPTIONAL
    *"      ET_LOG STRUCTURE  BAPIRET2 OPTIONAL
    *"----------------------------------------------------------------------




       DATA: WA_HDATA    LIKE BAPIOBDLVHDRCHG,
             WA_HCONT    LIKE BAPIOBDLVHDRCTRLCHG,
             D_DELIVY    LIKE BAPIOBDLVHDRCHG-DELIV_NUMB,
             ITEMCTRL LIKE BAPIOBDLVITEMCTRLCHG OCCURS 0 WITH HEADER LINE,
             ITEMDATA LIKE  BAPIOBDLVITEMCHG OCCURS 0 WITH HEADER LINE,
             IT_BAPIRET2 LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.




       DATA: ITAB_HEADER LIKE ZVBKOK OCCURS 0 WITH HEADER LINE,
             ITH LIKE ITAB_HEADER ,
             TBL_ITEMS LIKE ITAB_DETAIL,
             IP_VBELN TYPE VBELN,
             VIP TYPE VBELN,
             IP_POSNR TYPE POSNR.


    *--------------------CHA JWY_20170811
       SORT ITAB_DETAIL.
    *--------------------CHA JWY_20170811
       LOOP AT ITAB_DETAIL.
         MOVE ITAB_DETAIL-VBELN TO ITAB_HEADER-VBELN.
        MOVE ITAB_DETAIL-VBELN TO ITAB_HEADER-WMS_NO.

        MOVE ITAB_DETAIL-VBELN TO IP_VBELN.
         PERFORM F_ADD_ZERO USING IP_VBELN.

         MOVE ITAB_DETAIL-POSNR TO IP_POSNR.
         PERFORM F_ADD_ZERO USING IP_POSNR.

         SELECT SINGLE VBELN INTO VIP FROM LIPS WHERE VBELN = IP_VBELN AND POSNR = IP_POSNR.
         IF SY-SUBRC = 0.
          COLLECT ITAB_HEADER.
        ELSE.
           ITAB_RETURN-BILLNO = ITAB_DETAIL-VBELN.
          ITAB_RETURN-SAPNO = ITAB_DETAIL-POSNR.
          ITAB_RETURN-SUBRC = -1.
           ITAB_RETURN-MSG = '交货项目不存在'.
          APPEND ITAB_RETURN.
        ENDIF.
      ENDLOOP.

    *--------------------CHA JWY_20170811
       SORT ITAB_HEADER.
      SORT ITAB_DETAIL.
    *--------------------CHA JWY_20170811
       LOOP AT  ITAB_HEADER INTO ITH.

         CLEAR: WA_HDATA, WA_HCONT, D_DELIVY, IT_BAPIRET2.
         WA_HDATA-DELIV_NUMB = ITH-VBELN.
         WA_HCONT-DELIV_NUMB = ITH-VBELN.

         LOOP AT ITAB_DETAIL INTO TBL_ITEMS WHERE VBELN = ITH-VBELN .
          ITEMCTRL-DELIV_NUMB = ITH-VBELN.
           ITEMCTRL-DELIV_ITEM = TBL_ITEMS-POSNR.
          ITEMCTRL-DEL_ITEM = 'X'.
           APPEND ITEMCTRL.
           ITEMDATA-DELIV_NUMB = ITH-VBELN.
           ITEMDATA-DELIV_ITEM = TBL_ITEMS-POSNR.
          ITEMDATA-FACT_UNIT_NOM = 1.
           ITEMDATA-FACT_UNIT_DENOM = 1.
          APPEND ITEMDATA.
        ENDLOOP.


         CLEAR IT_BAPIRET2[].
    *     *---DELETING DELIVERY DOC (VL02N)
         CALL FUNCTION 'BAPI_OUTB_DELIVERY_CHANGE'
           EXPORTING
             HEADER_DATA    = WA_HDATA
             HEADER_CONTROL = WA_HCONT
             DELIVERY       = WA_HDATA-DELIV_NUMB
           TABLES
             ITEM_CONTROL   = ITEMCTRL
             ITEM_DATA      = ITEMDATA
             RETURN         = IT_BAPIRET2.

         CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
           EXPORTING
             WAIT = 'X'.


        MOVE SY-SUBRC TO ITAB_RETURN-SUBRC.

        IF SY-SUBRC  = 0.
           APPEND LINES OF IT_BAPIRET2 TO  ET_LOG.
           ITAB_RETURN-MSG = '成功'.
        ELSE.
           ITAB_RETURN-MSG = '失败'.
        ENDIF.

    *--------------------CHA JWY_20170811
         SORT ITEMDATA.
    *--------------------CHA JWY_20170811
         LOOP AT ITEMDATA.
           ITAB_RETURN-BILLNO = ITEMDATA-DELIV_NUMB.
          ITAB_RETURN-SAPNO = ITEMDATA-DELIV_ITEM.
           APPEND ITAB_RETURN.
         ENDLOOP.

        CLEAR VIP.
         SELECT SINGLE VBELN INTO VIP FROM LIPS WHERE VBELN = WA_HDATA-DELIV_NUMB.
        IF SY-SUBRC > 0. "删除空交货单
          WA_HCONT-DLV_DEL    = 'X'.
          CLEAR IT_BAPIRET2[].
    *---Deleting delivery doc (VL02n)
           CALL FUNCTION 'BAPI_OUTB_DELIVERY_CHANGE'
             EXPORTING
               HEADER_DATA    = WA_HDATA
               HEADER_CONTROL = WA_HCONT
               DELIVERY       = WA_HDATA-DELIV_NUMB
             TABLES
               RETURN         = IT_BAPIRET2.
    *---commit
          CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
             EXPORTING
               WAIT = 'X'.

        ENDIF.



       ENDLOOP.
    ENDFUNCTION.
     

    image

    image

    image

  • 相关阅读:
    July 22nd 2017 Week 29th Saturday
    July 21st 2017 Week 29th Friday
    社交类APP原型模板分享——QQ
    专访UI中国认证设计师卤大湿 | 一位UI大师关于UI设计的思考
    第十届Mockplus ▪ UXPA用户体验西南赛区决赛成功举行
    【附案例】UI交互设计不会做?设计大神带你开启动效灵感之路
    旅游类APP原型模板分享——爱彼迎
    有了这款自动标注/切图神器,攻城狮终于可以省心了
    设计师升职加薪必须知道的10个设计网站
    官网类原型模板分享——Apple
  • 原文地址:https://www.cnblogs.com/twttafku/p/14315960.html
Copyright © 2020-2023  润新知