migo的BAPI示例BAPI_GOODSMVT_CREATE
阅读原文时间:2023年07月08日阅读:2

1 *&---------------------------------------------------------------------*
2 *& Report Z_BAPI_MIGO_1
3 *&
4 *&---------------------------------------------------------------------*
5 *&
6 *&
7 *&---------------------------------------------------------------------*
8
9 REPORT Z_BAPI_MIGO_1.
10
11 *使用BAPI需要用到的
12 DATA:GOODSMVT_HEADER TYPE BAPI2017_GM_HEAD_01,
13 GOODSMVT_CODE TYPE BAPI2017_GM_CODE,
14 GOODSMVT_HEADRET TYPE BAPI2017_GM_HEAD_RET,
15 MATERIALDOCUMENT TYPE BAPI2017_GM_HEAD_RET-MAT_DOC,
16 MATDOCUMENTYEAR TYPE BAPI2017_GM_HEAD_RET-DOC_YEAR,
17 GOODSMVT_ITEM TYPE STANDARD TABLE OF BAPI2017_GM_ITEM_CREATE,
18 W_GOODSMVT_ITEM TYPE BAPI2017_GM_ITEM_CREATE,
19 RETURN TYPE STANDARD TABLE OF BAPIRET2,
20 W_RETURN TYPE BAPIRET2.
21
22
23
24
25 MOVE sy-datum TO GOODSMVT_HEADER-PSTNG_DATE.
26 MOVE sy-datum TO GOODSMVT_HEADER-DOC_DATE.
27 MOVE '01' TO GOODSMVT_CODE.
28
29 CLEAR: GOODSMVT_HEADRET,MATERIALDOCUMENT,MATDOCUMENTYEAR,RETURN.
30 *以下部分是这里是填写Detail的部分了,其中’B’为与’01’对应使用
31 MOVE '1001' TO W_GOODSMVT_ITEM-PLANT."""""""""""""""""""""""""工?
32 MOVE '1000' TO W_GOODSMVT_ITEM-STGE_LOC.""""""""""""""""""""""库存地点Storage Location
33 MOVE '101' TO W_GOODSMVT_ITEM-MOVE_TYPE."""""""""""""""""""""移动类型
34 MOVE '100' TO W_GOODSMVT_ITEM-ENTRY_QNT."""""""""""""""""""""数量
35 MOVE 'KG' TO W_GOODSMVT_ITEM-ENTRY_UOM."""""""""""""""""""""?位
36 MOVE '4500000593' TO W_GOODSMVT_ITEM-PO_NUMBER.:"""""""""""""""""""采??
37 MOVE '00010' TO W_GOODSMVT_ITEM-PO_ITEM."""""""""""""""""""""""项目编号
38 MOVE 'B' TO W_GOODSMVT_ITEM-MVT_IND."""""""""""""""""""""""移动标识Movement Indicator
39 MOVE '20100101' TO W_GOODSMVT_ITEM-BATCH.
40 APPEND W_GOODSMVT_ITEM TO GOODSMVT_ITEM.
41 *以下部分是调用BAPI
42 CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
43 EXPORTING
44 GOODSMVT_HEADER = GOODSMVT_HEADER
45 GOODSMVT_CODE = GOODSMVT_CODE
46 * TESTRUN = ' '
47 * GOODSMVT_REF_EWM =
48 IMPORTING
49 GOODSMVT_HEADRET = GOODSMVT_HEADRET
50 MATERIALDOCUMENT = MATERIALDOCUMENT
51 MATDOCUMENTYEAR = MATDOCUMENTYEAR
52 TABLES
53 GOODSMVT_ITEM = GOODSMVT_ITEM
54 * GOODSMVT_SERIALNUMBER =
55 RETURN = RETURN
56 * GOODSMVT_SERV_PART_DATA =
57 * EXTENSIONIN =
58 .
59 *以下部分是检查BAPI是否成功,这里是判断Material
60 *Docuemnt
61 IF MATERIALDOCUMENT IS NOT INITIAL.
62 CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
63 * EXPORTING
64 * WAIT =
65 * IMPORTING
66 * RETURN =
67 .
68 WRITE:/ MATERIALDOCUMENT.
69 ELSE.
70 LOOP AT RETURN INTO W_RETURN.
71 WRITE:/ W_RETURN-TYPE,
72 W_RETURN-ID,
73 W_RETURN-NUMBER,
74 W_RETURN-MESSAGE.
75 ENDLOOP.
76 ENDIF.

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章