SAP BAPI_GOODSMVT_CREATE创建物料凭证
程序员文章站
2022-05-18 14:18:20
...
示例:
"Import
DATA: GS_GOODSMVT_HEADER TYPE BAPI2017_GM_HEAD_01,
GV_GOODSMVT_CODE TYPE BAPI2017_GM_CODE.
"Export
DATA: GS_GOODSMVT_HEADREF TYPE BAPI2017_GM_HEAD_RET.
* gs_materialdocument TYPE BAPI2017_GM_HEAD_RET-MAT_DOC,
* gv_matdocumentyear TYPE BAPI2017_GM_HEAD_RET-DOC_YEAR.
"Table
DATA: GT_GOODSMVT_ITEM TYPE TABLE OF BAPI2017_GM_ITEM_CREATE,
WA_GOODSMVT_ITEM TYPE BAPI2017_GM_ITEM_CREATE,
GT_RETURN TYPE TABLE OF BAPIRET2,
WA_RETURN TYPE BAPIRET2.
DATA: LV_ERROR TYPE C.
START-OF-SELECTION.
"Goods Move
"Header
GS_GOODSMVT_HEADER-PSTNG_DATE = SY-DATUM.
GS_GOODSMVT_HEADER-DOC_DATE = SY-DATUM.
* GS_GOODSMVT_HEADER-HEADER_TXT = . "抬头文本
"GM Code
GV_GOODSMVT_CODE = '01'. "收货
"Item
WA_GOODSMVT_ITEM-MATERIAL = '1-11-01768-03AD'. "物料
WA_GOODSMVT_ITEM-PLANT = '3000'. "工厂
WA_GOODSMVT_ITEM-STGE_LOC = 'Z100'. "库存地点
* WA_GOODSMVT_ITEM-DELIV_NUMB = . "Outbound delivery 外向:企业-顾客
* WA_GOODSMVT_ITEM-DELIV_ITEM = . "Outbound delivery item
WA_GOODSMVT_ITEM-DELIV_NUMB_TO_SEARCH = '1800004785'. "Inbound delivery 内向:企业-供应商
WA_GOODSMVT_ITEM-DELIV_ITEM_TO_SEARCH = '10'. "Inbound delivery item
WA_GOODSMVT_ITEM-MOVE_TYPE = '101'. "移动类型 101
WA_GOODSMVT_ITEM-ENTRY_QNT = '100.000'. "交货数量
WA_GOODSMVT_ITEM-ENTRY_UOM = 'PC'. "销售单位
WA_GOODSMVT_ITEM-ENTRY_UOM_ISO = 'PC'. "基本的单位
WA_GOODSMVT_ITEM-MVT_IND = 'B'. "移动标识
WA_GOODSMVT_ITEM-PO_NUMBER = '4500002861'. "参考凭证 PO号
WA_GOODSMVT_ITEM-PO_ITEM = '10'. "参考项目 PO Item
* WA_GOODSMVT_ITEM-NO_MORE_GR = 'X'. "交货已完成”标识
* WA_GOODSMVT_ITEM-BATCH = . "批次
APPEND WA_GOODSMVT_ITEM TO GT_GOODSMVT_ITEM.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
GOODSMVT_HEADER = GS_GOODSMVT_HEADER
GOODSMVT_CODE = GV_GOODSMVT_CODE
IMPORTING
GOODSMVT_HEADRET = GS_GOODSMVT_HEADREF
TABLES
GOODSMVT_ITEM = GT_GOODSMVT_ITEM
RETURN = GT_RETURN.
LOOP AT GT_RETURN INTO WA_RETURN WHERE TYPE CA 'AEX'.
IF SY-SUBRC = 0.
LV_ERROR = 'E'.
EXIT.
ENDIF.
ENDLOOP.
IF LV_ERROR EQ 'E'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
MESSAGE '过账失败' TYPE 'I'.
LEAVE PROGRAM.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
MESSAGE '过账成功' TYPE 'I'.
LEAVE PROGRAM.
ENDIF.
上一篇: php项目中类的自动加载实例讲解
下一篇: FOR ALL ENTRIES