MB01 BAPI_GOODSMVT_CREATE退货

DATA: LT_HEADER                TYPE  BAPI2017_GM_HEAD_01,
      LT_MODE                  TYPE  BAPI2017_GM_CODE,
      LT_GOODSMVT_HEADRET      TYPE  BAPI2017_GM_HEAD_RET,
      LT_GOODSMVT_ITEM         TYPE STANDARD TABLE OF BAPI2017_GM_ITEM_CREATE WITH HEADER LINE,
      LT_GOODSMVT_SERIALNUMBER TYPE STANDARD TABLE OF BAPI2017_GM_SERIALNUMBER WITH HEADER LINE,
      LT_RETURN                TYPE STANDARD TABLE OF BAPIRET2 WITH HEADER LINE.

CLEAR:LT_HEADER.
LT_HEADER-PR_UNAME = SY-UNAME.  "用户名
LT_HEADER-DOC_DATE = '20200125'."LV_DATE.  "凭证日期
LT_HEADER-PSTNG_DATE = '20200125'."LV_DATE.  "过账日期
LT_HEADER-HEADER_TXT = '111'."LV_DATE.  "抬头文本
*    01:采购订单的收货
*    02:生产订单的收货
*    03:发货
*    04:转移发布
*    05:其他收货
*    06:货物移动的逆转
*    07:关于转包订单的后续调整

LT_MODE-GM_CODE = '01'.

CLEAR:LT_GOODSMVT_ITEM.
LT_GOODSMVT_ITEM-MATERIAL = '000000000000000111'."物料号
LT_GOODSMVT_ITEM-VENDOR = '0070001111'. "供应商编码
LT_GOODSMVT_ITEM-PO_NUMBER = '8300001111'. "采购订单
LT_GOODSMVT_ITEM-PO_ITEM = '10'. "采购订单
LT_GOODSMVT_ITEM-REF_DOC = '5005351111'. "参考凭证的凭证号
LT_GOODSMVT_ITEM-REF_DOC_IT = '1'. "参考凭证项目
LT_GOODSMVT_ITEM-ENTRY_QNT = '10'."数量
LT_GOODSMVT_ITEM-ENTRY_UOM = 'PC'."单位
LT_GOODSMVT_ITEM-PLANT    = '8011'. "生产工厂
LT_GOODSMVT_ITEM-STGE_LOC = '8611'."库存类型
LT_GOODSMVT_ITEM-MOVE_TYPE = '122'."移动类型
LT_GOODSMVT_ITEM-MVT_IND = 'B'."移动标识
LT_GOODSMVT_ITEM-BATCH = 'P11'."批次
LT_GOODSMVT_ITEM-MOVE_REAS = '0001'."移动原因
APPEND LT_GOODSMVT_ITEM.

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
  EXPORTING
    GOODSMVT_HEADER       = LT_HEADER
    GOODSMVT_CODE         = LT_MODE
  IMPORTING
    GOODSMVT_HEADRET      = LT_GOODSMVT_HEADRET
  TABLES
    GOODSMVT_ITEM         = LT_GOODSMVT_ITEM[]
    GOODSMVT_SERIALNUMBER = LT_GOODSMVT_SERIALNUMBER[]
    RETURN                = LT_RETURN.

IF LT_GOODSMVT_HEADRET IS NOT INITIAL.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      WAIT = 'X'.

ELSE.
  CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDIF.

 

 

你可能感兴趣的:(MB01 BAPI_GOODSMVT_CREATE退货)