1 DATA:ls_orderdata TYPE bapi_pp_order_change,
2 ls_orderdatax TYPE bapi_pp_order_changex,
3 ls_return TYPE bapiret2,
4 ls_read TYPE bapiflag-bapiflag.
5
6 LOOP AT gt_data ASSIGNING FIELD-SYMBOL(<fs_add>) WHERE checkbox = 'X' .
7
8 CLEAR ls_orderdata .
9 CLEAR ls_orderdatax .
10 CLEAR ls_return .
11 CLEAR ls_read .
12
13 "afpo~verid
14 ls_orderdata-prod_version = <fs_add>-verid1 . "生产版本
15 ls_orderdata-explosion_date = sy-datum .
16 ls_orderdata-explode_new = 'X' .
17
18 ls_orderdatax-prod_version = 'X' .
19 ls_orderdatax-explosion_date = 'X' .
20 ls_orderdatax-routing = 'X' .
21
22 CALL FUNCTION 'BAPI_PRODORD_CHANGE'
23 EXPORTING
24 "aufk~aufnr
25 number = <fs_add>-aufnr "生产订单号
26 orderdata = ls_orderdata
27 orderdatax = ls_orderdatax
28 IMPORTING
29 return = ls_return
30 * ORDER_TYPE =
31 * ORDER_STATUS =
32 "重读主数据成功就会返回X,否则为空
33 master_data_read = ls_read
34 * TABLES
35 * FSH_BUNDLES =
36 .
37 IF ls_return-type = 'E' AND ls_read = '' .
38
39 <fs_add>-type = icon_red_light .
40 <fs_add>-message = '读取主数据失败,请检查订单状态及投料报工入库记录。' && ls_return-message .
41 CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
42
43 ELSE .
44
45 <fs_add>-verid = <fs_add>-verid1 .
46 <fs_add>-type = icon_green_light .
47 <fs_add>-message = '读取主数据成功' .
48 CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
49 EXPORTING
50 wait = 'X'.
51
52 ENDIF .
53
54 ENDLOOP .