1 DATA:gt_task TYPE TABLE OF bapi1191_tsk_c,
2 gs_task TYPE bapi1191_tsk_c,
3 gt_materialtaskallocation TYPE TABLE OF bapi1191_mtk_c,
4 gs_materialtaskallocation TYPE bapi1191_mtk_c,
5 gt_return TYPE TABLE OF bapiret2,
6 gs_return TYPE bapiret2,
7 gt_operation TYPE TABLE OF bapi1191_opr_c,
8 gs_operation TYPE bapi1191_opr_c,
9 gt_inspcharacteristic TYPE TABLE OF bapi1191_cha_c,
10 gs_inspcharacteristic TYPE bapi1191_cha_c.
11
12 DATA: BEGIN OF gt_data OCCURS 0,
13 werks TYPE qpmk-werks,
14 matnr TYPE matnr,
15 maktx TYPE makt-maktx,
16 plnnr TYPE plnnr,
17 gueltigab TYPE qpmk-gueltigab,
18 verwe TYPE verwe,
19 statu TYPE statu,
20 merknr TYPE merknr,
21 verwmerkm TYPE qamv-verwmerkm,
22 kurztext TYPE qpmt-kurztext,
23 stichprver TYPE qamv-stichprver,
24 stellen TYPE qpmk-stellen,
25 masseinhsw TYPE qpmk-masseinhsw,
26 sollwert TYPE qsollwertc, "qkzsollpr,
27 toleranzun TYPE qtolunc, "qkztolun,
28 toleranzob TYPE qtolobc, "qkztolob,
29 lzeitkz TYPE qlzeitkz,
30 steuerkz TYPE qpmk-steuerkz,
31 meins TYPE mara-meins,
32 pmethode TYPE qpmz-pmethode,
33 werkpm TYPE qpmz-werkpm,
34 checkbox(1),
35 status(1),
36 message(255),
37 END OF gt_data .
38
39 DATA:gt_head LIKE TABLE OF gt_data .
40
41 SORT gt_head BY werks matnr plnnr gueltigab verwe statu .
42 DELETE ADJACENT DUPLICATES FROM gt_head COMPARING werks matnr plnnr gueltigab verwe statu.
43
44 LOOP AT gt_head ASSIGNING FIELD-SYMBOL(<fs_head>) WHERE checkbox = 'X' AND status <> 'E'.
45
46 REFRESH gt_task .
47 REFRESH gt_materialtaskallocation .
48 REFRESH gt_operation .
49 REFRESH gt_inspcharacteristic .
50 REFRESH gt_return.
51 CLEAR gs_task .
52 CLEAR gs_materialtaskallocation .
53 CLEAR gs_operation .
54 CLEAR gs_inspcharacteristic .
55 CLEAR gs_return.
56 CLEAR lv_plnnr .
57
58 gs_task-group_counter = '1'.
59 gs_task-valid_from = <fs_head>-gueltigab ."有效起始日
60 gs_task-valid_to_date = '99991231' .
61 gs_task-task_list_usage = <fs_head>-verwe ."用途
62 gs_task-plant = <fs_head>-werks."工厂
63 gs_task-task_list_status = <fs_head>-statu ."状态
64 gs_task-task_measure_unit = <fs_head>-meins ."基本单位
65 gs_task-lot_size_to = '99999999' .
66 gs_task-description = <fs_head>-maktx ."物料描述
67 APPEND gs_task TO gt_task .
68
69 gs_materialtaskallocation-material = <fs_head>-matnr ."物料编码
70 gs_materialtaskallocation-plant = <fs_head>-werks ."工厂
71 gs_materialtaskallocation-group_counter = '1'.
72 gs_materialtaskallocation-valid_from = <fs_head>-gueltigab ."有效起始日
73 APPEND gs_materialtaskallocation TO gt_materialtaskallocation .
74
75 gs_operation-group_counter = '1'.
76 gs_operation-valid_from = <fs_head>-gueltigab ."有效起始日
77 gs_operation-valid_to_date = '99991231' .
78 gs_operation-activity = '0010' .
79 gs_operation-control_key = 'QM01' .
80 gs_operation-plant = <fs_head>-werks ."工厂
81 gs_operation-operation_measure_unit = <fs_head>-meins ."基本单位
82 gs_operation-denominator = '1' .
83 gs_operation-nominator = '1' .
84 gs_operation-base_quantity = '1' .
85 APPEND gs_operation TO gt_operation .
86
87 LOOP AT gt_data ASSIGNING FIELD-SYMBOL(<fs_data>) WHERE werks = <fs_head>-werks AND
88 matnr = <fs_head>-matnr AND plnnr = <fs_head>-plnnr AND gueltigab = <fs_head>-gueltigab AND
89 verwe = <fs_head>-verwe AND statu = <fs_head>-statu .
90
91 CLEAR gs_inspcharacteristic .
92
93 gs_inspcharacteristic-group_counter = '1' .
94 gs_inspcharacteristic-activity = '0010' .
95 gs_inspcharacteristic-inspchar = <fs_data>-merknr ."特性序号
96 gs_inspcharacteristic-valid_from = <fs_data>-gueltigab ."有效起始日
97 gs_inspcharacteristic-valid_to_date = '99991231' .
98 gs_inspcharacteristic-mstr_char = <fs_data>-verwmerkm ."检验特性编码
99 gs_inspcharacteristic-pmstr_char = <fs_data>-werks ."工厂
100 gs_inspcharacteristic-cha_master_import_modus = 'N' .
101 gs_inspcharacteristic-char_descr = <fs_data>-kurztext ."特性名称
102 gs_inspcharacteristic-method = <fs_data>-pmethode .
103 gs_inspcharacteristic-pmethod = <fs_data>-werkpm .
104 gs_inspcharacteristic-scope_ind = '=' .
105 gs_inspcharacteristic-confirmation_category = 'X' .
106 gs_inspcharacteristic-sampling_procedure_ind = 'X' .
107 gs_inspcharacteristic-smpl_procedure = <fs_data>-stichprver ."采样过程
108 gs_inspcharacteristic-smpl_unit = <fs_data>-meins ."基本单位
109 gs_inspcharacteristic-smpl_quant = '1' .
110 gs_inspcharacteristic-long_term_insp_ind = <fs_data>-lzeitkz ."长期特性
111 gs_inspcharacteristic-dec_places = <fs_data>-stellen ."小数位
112 gs_inspcharacteristic-meas_unit = <fs_data>-masseinhsw ."计量单位
113 gs_inspcharacteristic-target_val = <fs_data>-sollwert ."目标值
114 gs_inspcharacteristic-up_tol_lmt = <fs_data>-toleranzob ."规范上限
115 gs_inspcharacteristic-lw_tol_lmt = <fs_data>-toleranzun ."规范下限
116 IF <fs_data>-sollwert <> '' .
117 gs_inspcharacteristic-target_val_check_ind = 'X' .
118 ENDIF.
119 IF <fs_data>-toleranzob <> '' .
120 gs_inspcharacteristic-up_tol_lmt_ind = 'X'.
121 ENDIF.
122 IF <fs_data>-toleranzun <> ''.
123 gs_inspcharacteristic-lw_tol_lmt_ind = 'X' .
124 ENDIF.
125 IF <fs_data>-steuerkz+0(2) = 'XX'.
126 gs_inspcharacteristic-quantitative_ind = 'X'.
127 gs_inspcharacteristic-meas_value_confirm_ind = 'X' .
128 gs_inspcharacteristic-result_recording_type = '+' .
129 ENDIF.
130 APPEND gs_inspcharacteristic TO gt_inspcharacteristic .
131 ENDLOOP .
132
133 CALL FUNCTION 'BAPI_INSPECTIONPLAN_CREATE'
134 * EXPORTING
135 * TESTRUN = ' '
136 * PROFILE =
137 IMPORTING
138 group = gv_group
139 groupcounter = gv_groupcounter
140 TABLES
141 task = gt_task
142 materialtaskallocation = gt_materialtaskallocation
143 operation = gt_operation
144 * REFERENCEOPERATION =
145 * PRODUCTIONRESOURCE =
146 inspcharacteristic = gt_inspcharacteristic
147 * TEXTALLOCATION =
148 * TEXT =
149 return = gt_return
150 * INSP_CHAR_VALUES =
151 .
152
153 READ TABLE gt_return INTO gs_return WITH KEY type = 'E' .
154 IF sy-subrc = 0 .
155
156 CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
157
158 ELSE.
159
160 CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
161 EXPORTING
162 wait = 'X'.
163
164 ENDIF.
165
166 ENDLOOP.
ABAP-QP01检验计划批导
最新推荐文章于 2023-11-22 11:22:08 发布