1 FUNCTION zfm_pp_0009.
2 *"----------------------------------------------------------------------
3 *"*"本地接口:
4 *" EXPORTING
5 *" VALUE(EV_TYPE) TYPE CHAR1
6 *" VALUE(EV_MESSAGE) TYPE CHAR255
7 *" VALUE(EV_BOMNO) TYPE STNUM
8 *" TABLES
9 *" TI_INPUT STRUCTURE ZSPP_0007 OPTIONAL
10 *"----------------------------------------------------------------------
11
12 DATA:lv_material TYPE csap_mbom-matnr,
13 lv_bom_usage TYPE csap_mbom-stlan,
14 lv_plant TYPE csap_mbom-werks,
15 lv_alternative TYPE csap_mbom-stlal,
16 ls_stko TYPE stko_api01,
17 ls_stpo TYPE stpo_api03,
18 lt_stpo TYPE TABLE OF stpo_api03,
19 lv_date TYPE datuv_bi,
20 lt_stb TYPE TABLE OF stpox,
21 ls_stb TYPE stpox,
22 ls_topmat TYPE cstmat,
23 lv_capid TYPE tc04-capid,
24 lv_aennr TYPE csap_mbom-aennr,
25 lv_warn TYPE capiflag-flwarning.
26
27 CLEAR lv_material .
28 CLEAR lv_bom_usage .
29 CLEAR lv_plant .
30 CLEAR ls_stko .
31 CLEAR ls_stpo .
32 REFRESH lt_stpo .
33 CLEAR lv_date .
34 REFRESH lt_stb .
35 CLEAR ls_stb .
36 CLEAR ls_topmat .
37 CLEAR lv_capid .
38 CLEAR lv_aennr .
39 CLEAR lv_warn .
40
41 CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
42 EXPORTING
43 date_internal = sy-datum
44 IMPORTING
45 date_external = lv_date
46 EXCEPTIONS
47 date_internal_is_invalid = 1
48 OTHERS = 2.
49
50 LOOP AT ti_input ASSIGNING FIELD-SYMBOL(<fs_input>) .
51
52 CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
53 EXPORTING
54 input = <fs_input>-matnr
55 IMPORTING
56 output = <fs_input>-matnr
57 EXCEPTIONS
58 length_error = 1
59 OTHERS = 2.
60
61 CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
62 EXPORTING
63 input = <fs_input>-idnrk
64 IMPORTING
65 output = <fs_input>-idnrk
66 EXCEPTIONS
67 length_error = 1
68 OTHERS = 2.
69
70 ENDLOOP .
71
72 IF ti_input[] IS NOT INITIAL .
73
74 READ TABLE ti_input INTO DATA(ls_input) INDEX 1 .
75
76 IF ls_input-aennr IS NOT INITIAL .
77
78 SELECT SINGLE datuv
79 INTO @DATA(lv_datuv)
80 FROM aenr
81 WHERE aennr = @ls_input-aennr .
82 IF sy-subrc = 0 .
83
84 CLEAR lv_date .
85
86 CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
87 EXPORTING
88 date_internal = lv_datuv
89 IMPORTING
90 date_external = lv_date
91 EXCEPTIONS
92 date_internal_is_invalid = 1
93 OTHERS = 2.
94
95 ENDIF .
96
97 ENDIF .
98
99 IF ls_input-stlst = '01' .
100 lv_capid = 'PP01' .
101 ELSEIF ls_input-stlst = '02' .
102 lv_capid = 'ZP01' .
103 ENDIF .
104
105 CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
106 EXPORTING
107 * FTREL = ' '
108 * ALEKZ = ' '
109 * ALTVO = ' '
110 * AUFSW = ' '
111 aumgb = 'X'
112 * AUMNG = 0
113 * AUSKZ = ' '
114 * AMIND = ' '
115 * BAGRP = ' '
116 * BEIKZ = ' '
117 * BESSL = ' '
118 * BGIXO = ' '
119 * BREMS = ' '
120 capid = lv_capid
121 * CHLST = ' '
122 * COSPR = ' '
123 * CUOBJ = 000000000000000
124 * CUOVS = 0
125 * CUOLS = ' '
126 datuv = sy-datum
127 * DELNL = ' '
128 * DRLDT = ' '
129 ehndl = '1'
130 * EMENG = 0
131 * ERSKZ = ' '
132 * ERSSL = ' '
133 * FBSTP = ' '
134 * KNFBA = ' '
135 * KSBVO = ' '
136 * MBWLS = ' '
137 mktls = 'X'
138 mdmps = 'X'
139 * MEHRS = ' '
140 * MKMAT = ' '
141 * MMAPS = ' '
142 * SALWW = ' '
143 * SPLWW = ' '
144 * MMORY = ' '
145 mtnrv = ls_input-matnr
146 * NLINK = ' '
147 * POSTP = ' '
148 * RNDKZ = ' '
149 * RVREL = ' '
150 * SANFR = ' '
151 * SANIN = ' '
152 * SANKA = ' '
153 * SANKO = ' '
154 * SANVS = ' '
155 * SCHGT = ' '
156 * STKKZ = ' '
157 stlal = ls_input-stlal
158 stlan = ls_input-stlan
159 stpst = '0'
160 svwvo = 'X'
161 werks = ls_input-werks
162 * NORVL = ' '
163 * MDNOT = ' '
164 * PANOT = ' '
165 * QVERW = ' '
166 * VERID = ' '
167 vrsvo = 'X'
168 * SGT_SCAT =
169 * SGT_REL =
170 * CALLER_APP =
171 * BOM_VERSN =
172 IMPORTING
173 topmat = ls_topmat
174 * DSTST =
175 TABLES
176 stb = lt_stb
177 * MATCAT =
178 EXCEPTIONS
179 alt_not_found = 1
180 call_invalid = 2
181 material_not_found = 3
182 missing_authorization = 4
183 no_bom_found = 5
184 no_plant_data = 6
185 no_suitable_bom_found = 7
186 conversion_error = 8
187 OTHERS = 9.
188
189 ENDIF .
190
191 LOOP AT ti_input ASSIGNING <fs_input> .
192
193 AT FIRST .
194
195 lv_material = <fs_input>-matnr .
196 lv_plant = <fs_input>-werks .
197 lv_bom_usage = <fs_input>-stlan .
198 lv_alternative = <fs_input>-stlal .
199 lv_aennr = <fs_input>-aennr .
200
201 ls_stko-base_quan = <fs_input>-bmeng .
202 ls_stko-alt_text = <fs_input>-stktx .
203 ls_stko-bom_status = <fs_input>-stlst .
204 ls_stko-base_unit = <fs_input>-bmein .
205
206 ENDAT .
207
208 CLEAR ls_stpo .
209
210 IF <fs_input>-flag = 'N' .
211
212 ELSEIF <fs_input>-flag = 'C' .
213
214 READ TABLE lt_stb INTO ls_stb WITH KEY posnr = <fs_input>-posnr
215 idnrk = <fs_input>-idnrk .
216 IF sy-subrc = 0 .
217 ls_stpo-item_node = ls_stb-stlkn .
218 ls_stpo-item_count = ls_stb-stpoz .
219 ENDIF .
220
221 ELSEIF <fs_input>-flag = 'D' .
222
223 ls_stpo-fldelete = 'X' .
224 READ TABLE lt_stb INTO ls_stb WITH KEY posnr = <fs_input>-posnr
225 idnrk = <fs_input>-idnrk .
226 IF sy-subrc = 0 .
227 ls_stpo-item_node = ls_stb-stlkn .
228 ls_stpo-item_count = ls_stb-stpoz .
229 ENDIF .
230
231 ENDIF .
232
233 IF <fs_input>-flag IS NOT INITIAL .
234
235 ls_stpo-item_no = <fs_input>-posnr .
236 ls_stpo-item_categ = <fs_input>-postp .
237 ls_stpo-component = <fs_input>-idnrk .
238 ls_stpo-comp_qty = <fs_input>-menge .
239 ls_stpo-comp_unit = <fs_input>-meins .
240 ls_stpo-comp_scrap = <fs_input>-ausch .
241 ls_stpo-issue_loc = <fs_input>-lgort .
242 ls_stpo-co_product = <fs_input>-kzkup .
243 ls_stpo-ai_group = <fs_input>-alpgr .
244 ls_stpo-ai_prio = <fs_input>-alprf .
245 ls_stpo-usage_prob = <fs_input>-ewahr .
246 ls_stpo-ai_strateg = <fs_input>-alpst .
247 ls_stpo-rel_cost = <fs_input>-sanka .
248 ls_stpo-bulk_mat = <fs_input>-schgt .
249 ls_stpo-sortstring = <fs_input>-sortf .
250 ls_stpo-valid_from = <fs_input>-datuv .
251 ls_stpo-fixed_qty = <fs_input>-fmeng .
252 ls_stpo-item_text1 = <fs_input>-potx1 .
253 ls_stpo-item_text2 = <fs_input>-potx2 .
254 ls_stpo-op_scrap = <fs_input>-avoau .
255 ls_stpo-op_net_ind = <fs_input>-netau .
256
257 APPEND ls_stpo TO lt_stpo .
258
259 ENDIF .
260
261 ENDLOOP .
262
263 CALL FUNCTION 'CSAP_MAT_BOM_MAINTAIN'
264 EXPORTING
265 material = lv_material
266 plant = lv_plant
267 bom_usage = lv_bom_usage
268 alternative = lv_alternative
269 valid_from = lv_date
270 change_no = lv_aennr
271 * REVISION_LEVEL =
272 i_stko = ls_stko
273 * FL_NO_CHANGE_DOC = ' '
274 fl_commit_and_wait = 'X'
275 * FL_CAD = ' '
276 fl_bom_create = 'X'
277 fl_new_item = 'X'
278 fl_complete = 'X'
279 fl_default_values = ''
280 * FL_IDENTIFY_BY_GUID = ' '
281 * FL_RECURSIVE = ' '
282 IMPORTING
283 fl_warning = lv_warn
284 * O_STKO =
285 TABLES
286 t_stpo = lt_stpo
287 * T_DEP_DATA =
288 * T_DEP_DESCR =
289 * T_DEP_ORDER =
290 * T_DEP_SOURCE =
291 * T_DEP_DOC =
292 * T_DOC_LINK =
293 * T_DMU_TMX =
294 * T_LTX_LINE =
295 * T_STPU =
296 * T_FSH_BOMD =
297 * T_SGT_BOMC =
298 EXCEPTIONS
299 error = 1
300 OTHERS = 2.
301
302 IF sy-subrc <> 0.
303
304 CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
305 CALL FUNCTION 'MESSAGE_TEXT_BUILD'
306 EXPORTING
307 msgid = sy-msgid
308 msgnr = sy-msgno
309 msgv1 = sy-msgv1
310 msgv2 = sy-msgv2
311 msgv3 = sy-msgv3
312 msgv4 = sy-msgv4
313 IMPORTING
314 message_text_output = ev_message.
315 ev_type = 'E' .
316
317 ELSE .
318
319 CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
320 EXPORTING
321 wait = 'X'.
322 ev_type = 'S' .
323 ev_message = '修改成功' .
324 ev_bomno = ls_topmat-stlnr .
325
326 ENDIF.
327
328 ENDFUNCTION.
ABAP-CS02BOM批量修改
最新推荐文章于 2024-09-10 13:23:11 发布