BAPI_GOODSMVT_CREATE 的应用

货物移动的bapi  BAPI_GOODSMVT_CREATE
其中 参数 : GOODSMVT_CODE 有
GMCODE Table T158G - 01 - MB01 - Goods Receipts for Purchase Order
*                      02 - MB31 - Goods Receipts for Prod Order
*                      03 - MB1A - Goods Issue
*                      04 - MB1B - Transfer Posting
*                      05 - MB1C - Enter Other Goods Receipt
*                      06 - MB11
*                      07 - MB04

给个01的例子

DATA:goodsmvt_header  LIKE  bapi2017_gm_head_01,
     goodsmvt_headret LIKE  bapi2017_gm_head_ret,
     goodsmvt_item TYPE TABLE OF bapi2017_gm_item_create WITH HEADER LINE,
     gt_return  TYPE TABLE OF bapiret2 WITH HEADER LINE.
******省略
  LOOP AT lt_head INTO ls_head.
    CLEAR:goodsmvt_header,goodsmvt_headret,gt_return[],gt_return,return1[],return1.
    goodsmvt_header-doc_date   = sy-datum.
    goodsmvt_header-pstng_date = sy-datum.
    LOOP AT gt_data INTO gs_data WHERE ebeln = ls_head-ebeln .
      goodsmvt_item-plant      = gs_data-werks.
      goodsmvt_item-material   = gs_data-matnr.
      goodsmvt_item-move_type  = '101'.
      goodsmvt_item-mvt_ind    = 'B'.
      goodsmvt_item-entry_qnt  =  gs_data-menge3.
      SELECT SINGLE lgort INTO goodsmvt_item-stge_loc FROM ztmm001 WHERE werks = goodsmvt_item-plant.
      goodsmvt_item-po_number  =  gs_data-ebeln.
      goodsmvt_item-po_item    =  gs_data-ebelp.
      APPEND goodsmvt_item.
      CLEAR goodsmvt_item.
    ENDLOOP.

    CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
      EXPORTING
        goodsmvt_header  = goodsmvt_header
        goodsmvt_code    = '01'
      IMPORTING
        goodsmvt_headret = goodsmvt_headret
*       MATERIALDOCUMENT =
*       MATDOCUMENTYEAR  =
      TABLES
        goodsmvt_item    = goodsmvt_item
        return           = gt_return[].

    LOOP AT gt_return WHERE type = 'E' OR type = 'A'.
      MOVE-CORRESPONDING gt_return TO return1.
      APPEND return1.
      CLEAR:return1.
      error_flag = 'X'.
    ENDLOOP.
    IF erro_flag = 'X'.
      CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
      EXIT.
    ELSE.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait = 'X'.
    ENDIF.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值