ITPub博客

首页 > 应用开发 > IT综合 > 调用BAPI的简单例子(实现给工单发料的功能)

调用BAPI的简单例子(实现给工单发料的功能)

原创 IT综合 作者:seaman1978 时间:2007-12-07 08:45:01 0 删除 编辑

*****关于BAPI BAPI_GOODSMVT_CREATE的说明:

*CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
* EXPORTING
* GOODSMVT_HEADER =
* GOODSMVT_CODE =
** TESTRUN = ' '
** IMPORTING
** GOODSMVT_HEADRET =
** MATERIALDOCUMENT =
** MATDOCUMENTYEAR =
* TABLES
* GOODSMVT_ITEM =
** GOODSMVT_SERIALNUMBER =
* RETURN =
* .

* 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
*
* Domain: KZBEW - Movement Indicator
* Goods movement w/o reference
* B - Goods movement for purchase order
* F - Goods movement for production order
* L - Goods movement for delivery note
* K - Goods movement for kanban requirement (WM - internal only)
* O - Subsequent adjustment of "material-provided" consumption
* W - Subsequent adjustment of proportion/product unit material
*

[@more@]

*物料凭证的抬头数据
DATA:

LI_GM_HEAD TYPE STANDARD TABLE OF BAPI2017_GM_HEAD_01,
L_GM_HEAD LIKE BAPI2017_GM_HEAD_01,
*为BAPI货物移动分配事务代码
LI_GM_CODE TYPE STANDARD TABLE OF BAPI2017_GM_CODE,
L_GM_CODE LIKE BAPI2017_GM_CODE,

*返回单据号码
L_MAT_DOC LIKE BAPI2017_GM_HEAD_RET-MAT_DOC,

*凭证项目
LI_GM_ITEM TYPE STANDARD TABLE OF BAPI2017_GM_ITEM_CREATE,
L_GM_ITEM LIKE BAPI2017_GM_ITEM_CREATE,

*-------------------------
LI_RETURN TYPE STANDARD TABLE OF BAPIRET2,
L_RETURN TYPE BAPIRET2,
*Error flag
L_ERRFLAG(1) TYPE C.

FORM CALLBAPI.
*填写表头数据

L_GM_HEAD-PSTNG_DATE = SY-DATUM.
L_GM_HEAD-DOC_DATE = SY-DATUM.
APPEND L_GM_HEAD TO LI_GM_HEAD.
*分配事务代码
L_GM_CODE-GM_CODE = '03'.
APPEND L_GM_CODE TO LI_GM_CODE.

*发货明细
L_GM_ITEM-MATERIAL = '000000002000000280'. "10 410A
L_GM_ITEM-PLANT = 'P052'.
L_GM_ITEM-STGE_LOC = '410A'.
L_GM_ITEM-MOVE_TYPE = '261'. "移动类型(库存管理)
L_GM_ITEM-ENTRY_QNT = '1'.
L_GM_ITEM-ENTRY_UOM = 'PC'.
L_GM_ITEM-ORDERID = '001000000362'. "MO号
L_GM_ITEM-RESERV_NO = '0000001426'. "预留/相关需求的编号 RESB~RSNUM
L_GM_ITEM-RES_ITEM = '0001'. " 预留 / 相关需求的项目编号 RESB~RSPOS

APPEND L_GM_ITEM TO LI_GM_ITEM.

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
GOODSMVT_HEADER = L_GM_HEAD
GOODSMVT_CODE = '03'
* RETURN
IMPORTING
* GOODSMVT_HEADRET = L_MAT_DOC
MATERIALDOCUMENT = L_MAT_DOC
TABLES
GOODSMVT_ITEM = LI_GM_ITEM
RETURN = LI_RETURN
.
CLEAR L_ERRFLAG.
MESSAGE I005(YMESS) WITH L_MAT_DOC.

IF L_ERRFLAG IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ELSE.
MESSAGE I005(YMESS) WITH 'ERROR'.
ENDIF.
ENDFORM.

*调用函数

PERFORM CALLBAPI

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/240510/viewspace-989174/,如需转载,请注明出处,否则将追究法律责任。

下一篇: 转:公司间销售
请登录后发表评论 登录
全部评论

注册时间:2007-12-04

  • 博文量
    10
  • 访问量
    146732