(BAPI_OUTB_DELIVERY_CONFIRM_DEC)發貨過帳

            CLEAR:str,lw_header_step4,lw_header_ctrl_step4,lt_item_step4,lt_item_ctrl_step4.
            REFRESH:lt_item_step4,lt_item_ctrl_step4.

            lw_header_step4-deliv_numb  = v_vbeln4 .
            lw_header_ctrl_step4-deliv_numb = v_vbeln4.
            lw_header_ctrl_step4-post_gi_flg ='X' .
            lw_header_ctrl_step4-deliv_date_flg 'X'.
            lw_header_ctrl_step4-gdsi_date_flg 'X'.
            lw_delivery = v_vbeln4.




            LOOP AT lt_ztreint008 INTO ls_ztreint008 WHERE zzcggs = ls_ztreint008-zzcggs
                                                       AND zzzzcw = ls_ztreint008-zzzzcw
                                                       AND lifnr = ls_ztreint008-lifnr
                                                       AND werks = ls_werks-werks
              .
              lt_item_step4-deliv_numb = v_vbeln4.
              lt_item_step4-material  = ls_ztreint008-matnr .
              lt_item_step4-dlv_qty = ls_ztreint008-labst .
              lt_item_step4-base_uom 'EA' .
post

             "在作部分數量發貨過帳時,加上FACT_UNIT_NOM、FACT_UNIT_DENOM這兩個字段
              "COLLECT lt_item_step4 .
              lt_item_step4-deliv_item = ls_ztreint008-ZSOSNR.
              APPEND lt_item_step4.
              lt_item_ctrl_step4-deliv_numb = v_vbeln4 .
              lt_item_ctrl_step4-deliv_item = ls_ztreint008-ZSOSNR.
              lt_item_ctrl_step4-volume_flg 'X' .
              APPEND lt_item_ctrl_step4 .
            ENDLOOP.

            LOOP AT LT_ZTRMS002 INTO LS_ZTRMS002.
              CLEAR LT_ITEM_SERIAL_NO.
              LT_ITEM_SERIAL_NO-DELIV_NUMB = v_vbeln4.
              LT_ITEM_SERIAL_NO-ITM_NUMBER = LS_ZTRMS002-ZSOSNR.
              LT_ITEM_SERIAL_NO-SERIALNO   = LS_ZTRMS002-SERIALNO.
              APPEND LT_ITEM_SERIAL_NO.
            ENDLOOP.


            CLEAR: l_tims,hdl.REFRESH: hdl.
            hdl-deliv_numb = v_vbeln4 .
            hdl-timetype 'WSHDRWADTI'"實際過帳日期
            CONCATENATE sy-datum sy-uzeit INTO l_tims.
            hdl-timestamp_utc = l_tims." I_BUDAT.
            APPEND hdl.
            hdl-deliv_numb = v_vbeln4.
            hdl-timetype 'WSHDRWADAT'"計劃日期
            CLEAR:l_tims.
            CONCATENATE sy-datum sy-uzeit INTO l_tims.
            hdl-timestamp_utc = l_tims.
            APPEND hdl.

            CALL FUNCTION 'BAPI_OUTB_DELIVERY_CONFIRM_DEC'
              EXPORTING
                header_data      = lw_header_step4
                header_control   = lw_header_ctrl_step4
                delivery         = lw_delivery
              TABLES
                header_deadlines = hdl
                ITEM_SERIAL_NO   = LT_ITEM_SERIAL_NO
                return           = lt_return.
            CALL FUNCTION 'DEQUEUE_ALL'.
            LOOP AT lt_return.
              IF lt_return-type 'E'.
                flag 'X'.
                CONCATENATE str lt_return-message INTO str SEPARATED BY cl_abap_char_utilities=>newline.
              ENDIF.
            ENDLOOP.
發貨過帳spa

相關文章
相關標籤/搜索