ABAP-MIGO批导(261移动类型)

 1 DATA:ls_head   TYPE bapi2017_gm_head_01,
 2      ls_code   TYPE bapi2017_gm_code,
 3      ls_item   TYPE bapi2017_gm_item_create,
 4      lt_item   TYPE TABLE OF bapi2017_gm_item_create,
 5      ls_return TYPE bapiret2,
 6      lt_return TYPE TABLE OF bapiret2.
 7 
 8 CLEAR ls_head .
 9 CLEAR ls_code .
10 CLEAR ls_item .
11 REFRESH lt_item .
12 CLEAR ls_return .
13 REFRESH lt_return .
14 
15 ls_head-pstng_date = is_input-budat .
16 ls_head-doc_date = is_input-bldat .
17 ls_head-header_txt = is_input-bktxt .
18 ls_head-ref_doc_no = is_input-xblnr .
19 
20 ls_code-gm_code = '03' .
21 
22 LOOP AT ti_item ASSIGNING FIELD-SYMBOL(<fs_item>) .
23 
24   CLEAR ls_item .
25   ls_item-material = <fs_item>-matnr .
26   ls_item-entry_qnt = <fs_item>-menge .
27   ls_item-base_uom = <fs_item>-meins .
28   ls_item-orderid = <fs_item>-aufnr .
29   ls_item-xstob = ''.
30   ls_item-move_type = '261' .
31   ls_item-plant = <fs_item>-werks .
32   ls_item-stge_loc = <fs_item>-lgort .
33   ls_item-batch = <fs_item>-charg .
34   ls_item-item_text = <fs_item>-sgtxt .
35   ls_item-sales_ord = <fs_item>-kdauf .
36   ls_item-s_ord_item = <fs_item>-kdpos .
37   ls_item-reserv_no = ls_resb-rsnum .
38   ls_item-res_item = ls_resb-rspos .
39   APPEND ls_item TO lt_item .
40 
41 ENDLOOP .
42 
43 IF es_output-type <> 'E' .
44 
45   CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
46     EXPORTING
47       goodsmvt_header  = ls_head
48       goodsmvt_code    = ls_code
49 *     TESTRUN          = ' '
50 *     GOODSMVT_REF_EWM =
51 *     GOODSMVT_PRINT_CTRL           =
52     IMPORTING
53 *     GOODSMVT_HEADRET =
54       materialdocument = es_output-mblnr
55 *     MATDOCUMENTYEAR  =
56     TABLES
57       goodsmvt_item    = lt_item
58 *     GOODSMVT_SERIALNUMBER         =
59       return           = lt_return
60 *     GOODSMVT_SERV_PART_DATA       =
61 *     EXTENSIONIN      =
62 *     GOODSMVT_ITEM_CWM             =
63     .
64 
65   IF es_output-mblnr IS INITIAL .
66 
67     es_output-type = 'E' .
68     LOOP AT lt_return INTO ls_return WHERE type = 'E' .
69 
70       es_output-message = ls_return-message && ';' && es_output-message .
71 
72     ENDLOOP .
73     CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
74     
75   ELSE .
76     
77     CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
78       EXPORTING
79         wait = 'X'.
80     es_output-type = 'S' .
81     es_output-message = '创建成功' .
82 
83   ENDIF .
84 
85 ENDIF .
posted @ 2023-05-20 10:37  TigerMan  阅读(190)  评论(0编辑  收藏  举报