[Home] [Help]
PACKAGE BODY: APPS.INV_EBI_CHANGE_ORDER_HELPER
Source
1 PACKAGE BODY INV_EBI_CHANGE_ORDER_HELPER AS
2 /* $Header: INVEIHCOB.pls 120.57.12020000.3 2012/07/20 15:20:28 smukka ship $ */
3
4 /************************************************************************************
5 -- API name : set_assign_item
6 -- Type : Private
7 -- Function :
8 ************************************************************************************/
9 PROCEDURE set_assign_item(
10 p_assign_item IN VARCHAR2
11 ) IS
12 BEGIN
13 G_ASSIGN_ITEM := p_assign_item;
14 END set_assign_item;
15
16 /************************************************************************************
17 -- API name : get_assign_item
18 -- Type : Private
19 -- Function :
20 ************************************************************************************/
21 FUNCTION get_assign_item RETURN VARCHAR2
22 IS
23 BEGIN
24 RETURN G_ASSIGN_ITEM ;
25 END get_assign_item;
26
27 /************************************************************************************
28 -- API name : get_change_order_uda
29 -- Type : Private
30 -- Function :
31 -- Bug 7240247
32 ************************************************************************************/
33 PROCEDURE get_change_order_uda(
34 p_change_id IN NUMBER ,
35 x_change_uda OUT NOCOPY inv_ebi_uda_input_obj,
36 x_return_status OUT NOCOPY VARCHAR2,
37 x_msg_count OUT NOCOPY NUMBER,
38 x_msg_data OUT NOCOPY VARCHAR2
39 ) IS
40 l_count NUMBER :=0;
41 l_attr_group_count NUMBER :=0;
42 l_change_order_type_id NUMBER;
43 l_application_id NUMBER;
44 l_attr_group_id_tbl FND_TABLE_OF_NUMBER;
45 l_pkdata EGO_COL_NAME_VALUE_PAIR_ARRAY;
46 l_uda_output_obj inv_ebi_eco_output_obj;
47 l_output_status inv_ebi_output_status;
48
49 CURSOR c_attr_group_id IS
50
51 SELECT DISTINCT attr_group_id
52 FROM ENG_CHANGES_EXT_B
53 WHERE change_id = p_change_id;
54
55 BEGIN
56 INV_EBI_UTIL.debug_line('STEP 10: START INSIDE INV_EBI_CHANGE_ORDER_HELPER.get_change_order_uda ');
57 INV_EBI_UTIL.debug_line('STEP 20: ECO NUMBER: '|| p_change_id);
58 x_return_status := FND_API.g_ret_sts_success;
59 l_output_status := inv_ebi_output_status(fnd_api.g_ret_sts_success,NULL,NULL,NULL);
60 l_uda_output_obj := inv_ebi_eco_output_obj(NULL,NULL,NULL,NULL,l_output_status,NULL,NULL);
61
62 IF(p_change_id IS NOT NULL ) THEN
63
64 IF c_attr_group_id%ISOPEN THEN
65 CLOSE c_attr_group_id;
66 END IF;
67
68 OPEN c_attr_group_id ;
69 FETCH c_attr_group_id BULK COLLECT INTO l_attr_group_id_tbl ;
70 CLOSE c_attr_group_id;
71
72 IF(l_attr_group_id_tbl IS NOT NULL AND l_attr_group_id_tbl.COUNT > 0) THEN
73 l_pkdata := EGO_COL_NAME_VALUE_PAIR_ARRAY();
74 l_pkdata.extend(1);
75 l_pkdata(1) := EGO_COL_NAME_VALUE_PAIR_OBJ('CHANGE_ID',p_change_id);
76
77 SELECT change_order_type_id INTO l_change_order_type_id
78 FROM eng_engineering_changes
79 WHERE change_id = p_change_id;
80
81 l_application_id:= INV_EBI_UTIL.get_application_id(
82 p_application_short_name => 'ENG'
83 );
84
85 IF(l_application_id IS NULL ) THEN
86 FND_MESSAGE.set_name('INV','INV_EBI_APP_INVALID');
87 FND_MESSAGE.set_token('COL_VALUE', 'ENG');
88 FND_MSG_PUB.add;
89 RAISE FND_API.g_exc_error;
90 END IF;
91 INV_EBI_UTIL.debug_line('STEP 30: BEFORE CALLING INV_EBI_ITEM_HELPER.get_uda_attributes');
92 INV_EBI_ITEM_HELPER.get_uda_attributes(
93 p_classification_id => l_change_order_type_id,
94 p_attr_group_type => INV_EBI_UTIL.G_ENG_CHANGEMGMT_GROUP,
95 p_application_id => l_application_id,
96 p_attr_grp_id_tbl => l_attr_group_id_tbl,
97 p_data_level => INV_EBI_UTIL.G_CHANGE_LEVEL,
98 p_revision_id => NULL,
99 p_object_name => INV_EBI_UTIL.G_CHANGE_OBJ_NAME,
100 p_pk_data => l_pkdata,
101 x_uda_obj => x_change_uda,
102 x_uda_output_obj => l_uda_output_obj );
103 INV_EBI_UTIL.debug_line('STEP 40: END CALLING INV_EBI_ITEM_HELPER.get_uda_attributes STATUS: '|| l_uda_output_obj.output_status.return_status);
104 IF(l_uda_output_obj.output_status.return_status <> FND_API.G_RET_STS_SUCCESS) THEN
105 x_msg_data := l_uda_output_obj.output_status.msg_data ;
106 RAISE FND_API.g_exc_unexpected_error;
107 END IF;
108 END IF;
109 END IF;
110 INV_EBI_UTIL.debug_line('STEP 50: END INSIDE INV_EBI_CHANGE_ORDER_HELPER.get_change_order_uda ');
111 EXCEPTION
112 WHEN FND_API.g_exc_unexpected_error THEN
113
114 IF c_attr_group_id%ISOPEN THEN
115 CLOSE c_attr_group_id;
116 END IF;
117
118 x_return_status := FND_API.g_ret_sts_unexp_error;
119 IF(x_msg_data IS NULL) THEN
120 fnd_msg_pub.count_and_get(
121 p_encoded => FND_API.g_false
122 ,p_count => x_msg_count
123 ,p_data => x_msg_data
124 );
125 END IF;
126 WHEN OTHERS THEN
127
128 IF c_attr_group_id%ISOPEN THEN
129 CLOSE c_attr_group_id;
130 END IF;
131
132 x_return_status := FND_API.g_ret_sts_unexp_error;
133 IF (x_msg_data IS NOT NULL) THEN
134 x_msg_data := x_msg_data||' ->INV_EBI_CHANGE_ORDER_HELPER.get_change_order_uda ';
135 ELSE
136 x_msg_data := SQLERRM||'INV_EBI_CHANGE_ORDER_HELPER.get_change_order_uda ';
137 END IF;
138 END get_change_order_uda;
139
140 /************************************************************************************
141 -- API name : get_structure_header_uda
142 -- Type : Private
143 -- Function :
144 -- Bug 7240247
145 ************************************************************************************/
146
147 PROCEDURE get_structure_header_uda(
148 p_assembly_item_id IN NUMBER ,
149 p_alternate_bom_code IN VARCHAR2,
150 p_organization_id IN NUMBER,
151 x_structure_header_uda OUT NOCOPY inv_ebi_uda_input_obj,
152 x_return_status OUT NOCOPY VARCHAR2,
153 x_msg_count OUT NOCOPY NUMBER,
154 x_msg_data OUT NOCOPY VARCHAR2
155 ) IS
156
157 l_bom_count NUMBER :=0;
158 l_uda_count NUMBER :=0;
159 l_attr_group_count NUMBER :=0;
160
161 l_application_id NUMBER;
162 l_attr_group_id_tbl FND_TABLE_OF_NUMBER;
163 l_pkdata EGO_COL_NAME_VALUE_PAIR_ARRAY;
164 l_uda_output_obj inv_ebi_eco_output_obj;
165 l_output_status inv_ebi_output_status;
166 l_structure_type_id NUMBER;
167 l_bill_sequence_id NUMBER;
168
169 CURSOR c_attr_group_id(
170 p_bill_sequence_id NUMBER,
171 p_structure_type_id NUMBER
172 ) IS
173 SELECT DISTINCT attr_group_id
174 FROM bom_structures_ext_b
175 WHERE
176 bill_sequence_id = p_bill_sequence_id AND
177 structure_type_id = p_structure_type_id;
178
179 CURSOR c_bom_count
180 IS
181
182 SELECT bill_sequence_id,structure_type_id
183 FROM bom_bill_of_materials
184 WHERE
185 assembly_item_id = p_assembly_item_id
186 AND organization_id = p_organization_id
187 AND NVL(alternate_bom_designator, 'NONE') = DECODE(p_alternate_bom_code,FND_API.G_MISS_CHAR,'NONE',NULL,'NONE',p_alternate_bom_code) ;
188
189
190 BEGIN
191 INV_EBI_UTIL.debug_line('STEP 10: START INSIDE INV_EBI_CHANGE_ORDER_HELPER.get_structure_header_uda');
192 INV_EBI_UTIL.debug_line('STEP 20: ASSY ITEM ID :' || p_assembly_item_id || 'ORG ID: '|| p_organization_id );
193 x_return_status := FND_API.g_ret_sts_success;
194 l_output_status := inv_ebi_output_status(fnd_api.g_ret_sts_success,NULL,NULL,NULL);
195 l_uda_output_obj := inv_ebi_eco_output_obj(NULL,NULL,NULL,NULL,l_output_status,NULL,NULL);
196
197 IF( p_assembly_item_id IS NOT NULL AND
198 p_organization_id IS NOT NULL) THEN
199
200 IF c_bom_count%ISOPEN THEN
201 CLOSE c_bom_count;
202 END IF;
203
204 OPEN c_bom_count;
205 FETCH c_bom_count INTO l_bill_sequence_id,l_structure_type_id;
206
207 IF(c_bom_count % ROWCOUNT > 0) THEN
208
209 IF c_attr_group_id%ISOPEN THEN
210 CLOSE c_attr_group_id;
211 END IF;
212
213 OPEN c_attr_group_id(l_bill_sequence_id,l_structure_type_id) ;
214 FETCH c_attr_group_id BULK COLLECT INTO l_attr_group_id_tbl ;
215
216 IF(c_attr_group_id % ROWCOUNT > 0) THEN
217
218
219 l_pkdata := EGO_COL_NAME_VALUE_PAIR_ARRAY();
220 l_pkdata.extend(1);
221 l_pkdata(1) := EGO_COL_NAME_VALUE_PAIR_OBJ('BILL_SEQUENCE_ID',l_bill_sequence_id);
222
223 l_application_id:= INV_EBI_UTIL.get_application_id(
224 p_application_short_name => 'BOM'
225 );
226 IF(l_application_id IS NULL ) THEN
227
228 FND_MESSAGE.set_name('INV','INV_EBI_APP_INVALID');
229 FND_MESSAGE.set_token('COL_VALUE', 'BOM');
230 FND_MSG_PUB.add;
231 RAISE FND_API.g_exc_error;
232 END IF;
233 INV_EBI_UTIL.debug_line('STEP 30: BEFORE CALLING INV_EBI_ITEM_HELPER.get_uda_attributes');
234 INV_EBI_ITEM_HELPER.get_uda_attributes(
235 p_classification_id => l_structure_type_id,
236 p_attr_group_type => INV_EBI_UTIL.G_BOM_STRUCTUREMGMT_GROUP,
237 p_application_id => l_application_id,
238 p_attr_grp_id_tbl => l_attr_group_id_tbl,
239 p_data_level => INV_EBI_UTIL.G_STRUCTURES_LEVEL,
240 p_revision_id => NULL,
241 p_object_name => INV_EBI_UTIL.G_BOM_STRUCTURE_OBJ_NAME,
242 p_pk_data => l_pkdata,
243 x_uda_obj => x_structure_header_uda,
244 x_uda_output_obj => l_uda_output_obj
245 );
246 INV_EBI_UTIL.debug_line('STEP 40: END CALLING INV_EBI_ITEM_HELPER.get_uda_attributes STATUS: ' || l_uda_output_obj.output_status.return_status );
247 IF(l_uda_output_obj.output_status.return_status <> FND_API.G_RET_STS_SUCCESS) THEN
248 x_msg_data := l_uda_output_obj.output_status.msg_data ;
249 RAISE FND_API.g_exc_unexpected_error;
250 END IF;
251 END IF;
252 CLOSE c_attr_group_id;
253 END IF;
254 CLOSE c_bom_count;
255 END IF;
256 INV_EBI_UTIL.debug_line('STEP 50: END INSIDE INV_EBI_CHANGE_ORDER_HELPER.get_structure_header_uda');
257 EXCEPTION
258 WHEN FND_API.g_exc_unexpected_error THEN
259
260 IF c_attr_group_id%ISOPEN THEN
261 CLOSE c_attr_group_id;
262 END IF;
263
264 IF c_bom_count%ISOPEN THEN
265 CLOSE c_bom_count;
266 END IF;
267
268 x_return_status := FND_API.g_ret_sts_unexp_error;
269 IF(x_msg_data IS NULL) THEN
270 fnd_msg_pub.count_and_get(
271 p_encoded => FND_API.g_false
272 ,p_count => x_msg_count
273 ,p_data => x_msg_data
274 );
275 END IF;
276 WHEN OTHERS THEN
277
278 IF c_attr_group_id%ISOPEN THEN
279 CLOSE c_attr_group_id;
280 END IF;
281
282 IF c_bom_count%ISOPEN THEN
283 CLOSE c_bom_count;
284 END IF;
285
286 x_return_status := FND_API.g_ret_sts_unexp_error;
287 IF (x_msg_data IS NOT NULL) THEN
288 x_msg_data := x_msg_data||' ->INV_EBI_CHANGE_ORDER_HELPER.get_structure_header_uda ';
289 ELSE
290 x_msg_data := SQLERRM||'INV_EBI_CHANGE_ORDER_HELPER.get_structure_header_uda ';
291 END IF;
292 END get_structure_header_uda;
293
294 /************************************************************************************
295 -- API name : get_component_item_uda
296 -- Type : Private
297 -- Function :
298 -- Bug 7240247
299 ************************************************************************************/
300
301 PROCEDURE get_component_item_uda(
302 p_eco_name IN VARCHAR2,
303 p_revised_item_id IN NUMBER,
304 p_component_item_name IN VARCHAR2,
305 p_alternate_bom_code IN VARCHAR2,
306 p_organization_id IN NUMBER,
307 x_comp_item_uda OUT NOCOPY inv_ebi_uda_input_obj,
308 x_return_status OUT NOCOPY VARCHAR2,
309 x_msg_count OUT NOCOPY NUMBER,
310 x_msg_data OUT NOCOPY VARCHAR2
311 ) IS
312
313 l_bom_count NUMBER :=0;
314 l_uda_count NUMBER :=0;
315 l_attr_group_count NUMBER :=0;
316 l_application_id NUMBER;
317 l_attr_group_id_tbl FND_TABLE_OF_NUMBER;
318 l_pkdata EGO_COL_NAME_VALUE_PAIR_ARRAY;
319 l_uda_output_obj inv_ebi_eco_output_obj;
320 l_output_status inv_ebi_output_status;
321 l_structure_type_id NUMBER;
322 l_bill_sequence_id NUMBER;
323 l_component_item_id NUMBER;
324 l_component_sequence_id NUMBER;
325 l_component_count NUMBER := 0;
326
327
328 CURSOR c_attr_group_id(
329 p_bill_sequence_id NUMBER,
330 p_structure_type_id NUMBER
331 ) IS
332 SELECT DISTINCT attr_group_id
333 FROM bom_components_ext_b
334 WHERE bill_sequence_id = p_bill_sequence_id
335 AND structure_type_id = p_structure_type_id;
336
337 CURSOR c_bom_count
338 IS
339
340 SELECT bill_sequence_id,structure_type_id
341 FROM bom_bill_of_materials
342 WHERE
343 assembly_item_id = p_revised_item_id
344 AND organization_id = p_organization_id
345 AND NVL(alternate_bom_designator, 'NONE') = DECODE(p_alternate_bom_code,FND_API.G_MISS_CHAR,'NONE',NULL,'NONE',p_alternate_bom_code) ;
346
347 CURSOR c_comp_count(
348 p_bill_sequence_id NUMBER,
349 p_component_item_id NUMBER
350 ) IS
351 SELECT component_sequence_id
352 FROM bom_components_b
353 WHERE
354 bill_sequence_id = p_bill_sequence_id AND
355 component_item_id = p_component_item_id AND
356 change_notice = p_eco_name;
357
358 BEGIN
359 INV_EBI_UTIL.debug_line('STEP 10: START INSIDE INV_EBI_CHANGE_ORDER_HELPER.get_component_item_uda');
360 INV_EBI_UTIL.debug_line('STEP 20: ECO NAME: '|| p_eco_name || 'REVISED ITEM ID: '|| p_revised_item_id ||
361 'COMPONENT NAME: '|| p_component_item_name ||'ORG ID: ' || p_organization_id);
362 x_return_status := FND_API.g_ret_sts_success;
363 l_output_status := inv_ebi_output_status(fnd_api.g_ret_sts_success,NULL,NULL,NULL);
364 l_uda_output_obj := inv_ebi_eco_output_obj(NULL,NULL,NULL,NULL,l_output_status,NULL,NULL);
365
366 IF( p_revised_item_id IS NOT NULL AND
367 p_organization_id IS NOT NULL) THEN
368
369 IF c_bom_count%ISOPEN THEN
370 CLOSE c_bom_count;
371 END IF;
372
373 OPEN c_bom_count;
374 FETCH c_bom_count INTO l_bill_sequence_id,l_structure_type_id;
375
376 IF(c_bom_count % ROWCOUNT > 0) THEN
377
378 l_component_item_id := INV_EBI_ITEM_HELPER.get_inventory_item_id (
379 p_organization_id => p_organization_id
380 ,p_item_number => p_component_item_name
381 );
382 INV_EBI_UTIL.debug_line('STEP 30: COMPONENT ITEM ID: '|| l_component_item_id );
383 IF c_comp_count%ISOPEN THEN
384 CLOSE c_comp_count;
385 END IF;
386
387 OPEN c_comp_count(l_bill_sequence_id,l_component_item_id);
388 FETCH c_comp_count INTO l_component_sequence_id;
389
390 IF(c_comp_count % ROWCOUNT > 0) THEN
391
392 IF c_attr_group_id%ISOPEN THEN
393 CLOSE c_attr_group_id;
394 END IF;
395
396 OPEN c_attr_group_id(l_bill_sequence_id,l_structure_type_id) ;
397 FETCH c_attr_group_id BULK COLLECT INTO l_attr_group_id_tbl ;
398
399 IF(c_attr_group_id % ROWCOUNT > 0) THEN
400
401 l_pkdata := EGO_COL_NAME_VALUE_PAIR_ARRAY();
402 l_pkdata.extend(2);
403 l_pkdata(1) := EGO_COL_NAME_VALUE_PAIR_OBJ('BILL_SEQUENCE_ID',l_bill_sequence_id);
404 l_pkdata(2) := EGO_COL_NAME_VALUE_PAIR_OBJ('COMPONENT_SEQUENCE_ID',l_component_sequence_id);
405
406 l_application_id:= INV_EBI_UTIL.get_application_id(
407 p_application_short_name => 'BOM'
408 );
409
410 IF(l_application_id IS NULL ) THEN
411 FND_MESSAGE.set_name('INV','INV_EBI_APP_INVALID');
412 FND_MESSAGE.set_token('COL_VALUE', 'BOM');
413 FND_MSG_PUB.add;
414 RAISE FND_API.g_exc_error;
415 END IF;
416 INV_EBI_UTIL.debug_line('STEP 40: BEFORE CALLING INV_EBI_ITEM_HELPER.get_uda_attributes');
417 INV_EBI_ITEM_HELPER.get_uda_attributes(
418 p_classification_id => l_structure_type_id,
419 p_attr_group_type => INV_EBI_UTIL.G_BOM_COMPONENTMGMT_GROUP,
420 p_application_id => l_application_id,
421 p_attr_grp_id_tbl => l_attr_group_id_tbl,
422 p_data_level => INV_EBI_UTIL.G_COMPONENTS_LEVEL,
423 p_revision_id => NULL,
424 p_object_name => INV_EBI_UTIL.G_BOM_COMPONENTS_OBJ_NAME,
425 p_pk_data => l_pkdata,
426 x_uda_obj => x_comp_item_uda,
427 x_uda_output_obj => l_uda_output_obj
428 );
429 INV_EBI_UTIL.debug_line('STEP 50: END CALLING INV_EBI_ITEM_HELPER.get_uda_attributes STATUS: '|| l_uda_output_obj.output_status.return_status);
430 IF(l_uda_output_obj.output_status.return_status <> FND_API.G_RET_STS_SUCCESS) THEN
431 x_msg_data := l_uda_output_obj.output_status.msg_data ;
432 RAISE FND_API.g_exc_unexpected_error;
433 END IF;
434 END IF;
435 CLOSE c_attr_group_id;
436 END IF;
437 CLOSE c_comp_count;
438 END IF;
439 CLOSE c_bom_count;
440 END IF;
441 INV_EBI_UTIL.debug_line('STEP 60: END INSIDE INV_EBI_CHANGE_ORDER_HELPER.get_component_item_uda');
442 EXCEPTION
443 WHEN FND_API.g_exc_unexpected_error THEN
444
445 IF c_attr_group_id%ISOPEN THEN
446 CLOSE c_attr_group_id;
447 END IF;
448
449 IF c_bom_count%ISOPEN THEN
450 CLOSE c_bom_count;
451 END IF;
452
453 IF c_comp_count%ISOPEN THEN
454 CLOSE c_comp_count;
455 END IF;
456
457 x_return_status := FND_API.g_ret_sts_unexp_error;
458 IF(x_msg_data IS NULL) THEN
459 fnd_msg_pub.count_and_get(
460 p_encoded => FND_API.g_false
461 ,p_count => x_msg_count
462 ,p_data => x_msg_data
463 );
464 END IF;
465 WHEN OTHERS THEN
466
467 IF c_attr_group_id%ISOPEN THEN
468 CLOSE c_attr_group_id;
469 END IF;
470
471 IF c_bom_count%ISOPEN THEN
472 CLOSE c_bom_count;
473 END IF;
474
475 IF c_comp_count%ISOPEN THEN
476 CLOSE c_comp_count;
477 END IF;
478
479 x_return_status := FND_API.g_ret_sts_unexp_error;
480 IF (x_msg_data IS NOT NULL) THEN
481 x_msg_data := x_msg_data||' ->INV_EBI_CHANGE_ORDER_HELPER.get_component_item_uda ';
482 ELSE
483 x_msg_data := SQLERRM||'INV_EBI_CHANGE_ORDER_HELPER.get_component_item_uda ';
484 END IF;
485 END get_component_item_uda;
486
487 /************************************************************************************
488 -- API name : get_latest_effectivity_date
489 -- Type : Private
490 -- Function :
491 -- This API is used to return effectivity date of the lastest created revision
492 -- Bug 7197943
493 ************************************************************************************/
494 FUNCTION get_latest_effectivity_date(
495 p_inventory_item_id IN NUMBER,
496 p_organization_id IN NUMBER,
497 p_new_revision IN VARCHAR2 := NULL -- Added for bug 14032254,the NULL default value
498 -- is for compatibility consideration
499 ) RETURN DATE IS
500
501 l_effectivity_date DATE;
502
503 CURSOR c_efectivity_date IS
504 SELECT
505 effectivity_date
506 FROM
507 mtl_item_revisions_b
508 WHERE
509 inventory_item_id = p_inventory_item_id AND
510 organization_id = p_organization_id AND
511 (p_new_revision IS NULL -- Added for bug 14032254,the "IS NULL" condition along with
512 OR revision <= UPPER(p_new_revision)) -- the NULL default value is for compatibility consideration
513 ORDER BY
514 effectivity_date DESC, revision DESC;
515
516 BEGIN
517 IF c_efectivity_date%ISOPEN THEN
518 CLOSE c_efectivity_date;
519 END IF;
520
521 OPEN c_efectivity_date;
522 FETCH c_efectivity_date INTO l_effectivity_date;
523 CLOSE c_efectivity_date;
524 RETURN l_effectivity_date;
525 EXCEPTION
526 WHEN OTHERS THEN
527 IF c_efectivity_date%ISOPEN THEN
528 CLOSE c_efectivity_date;
529 END IF;
530 NULL;
531 END get_latest_effectivity_date;
532
533 /************************************************************************************
534 -- API name : transform_substitute_comp_info
535 -- Type : Public
536 -- procedure : Prepare component,substitute components
537 -- for Replicate bom
538 -- Added this API for Bug 8397083
539 ************************************************************************************/
540 PROCEDURE transform_substitute_comp_info(
541 p_sub_component_tbl IN inv_ebi_sub_comp_tbl
542 ,p_component_item IN inv_ebi_rev_comp_obj
543 ,x_component_item OUT NOCOPY inv_ebi_rev_comp_obj
544 ,x_out OUT NOCOPY inv_ebi_eco_output_obj
545 ) IS
546
547 l_sub_comp_tbl inv_ebi_sub_comp_tbl;
548 l_component_item inv_ebi_rev_comp_obj;
549 l_sub_comp_count NUMBER := 0;
550 l_output_status inv_ebi_output_status;
551
552 BEGIN
553
554 l_output_status := inv_ebi_output_status(fnd_api.g_ret_sts_success,NULL,NULL,NULL);
555 x_out := inv_ebi_eco_output_obj(NULL,NULL,NULL,NULL,l_output_status,NULL,NULL);
556
557 INV_EBI_UTIL.debug_line('STEP 10: INSIDE INV_EBI_CHANGE_ORDER_HELPER.transform_substitute_comp_info');
558 l_component_item := p_component_item;
559 IF(p_sub_component_tbl IS NOT NULL AND p_sub_component_tbl.COUNT > 0 ) THEN
560
561 l_sub_comp_tbl := inv_ebi_sub_comp_tbl();
562
563 FOR i IN 1..p_sub_component_tbl.COUNT LOOP
564
565 IF(p_sub_component_tbl(i).acd_type = 1) THEN
566
567 l_sub_comp_count := l_sub_comp_count + 1;
568 l_sub_comp_tbl.EXTEND(1);
569 l_sub_comp_tbl(l_sub_comp_count) := p_sub_component_tbl(i);
570
571 ELSIF(p_sub_component_tbl(i).acd_type = 2) THEN
572
573 l_sub_comp_count := l_sub_comp_count + 1;
574 l_sub_comp_tbl.EXTEND(1);
575 l_sub_comp_tbl(l_sub_comp_count) := p_sub_component_tbl(i);
576 l_sub_comp_tbl(l_sub_comp_count).acd_type := 1;
577
578 END IF;
579
580 END LOOP;
581
582 IF(l_sub_comp_tbl IS NOT NULL AND l_sub_comp_tbl.COUNT > 0) THEN
583 l_component_item.substitute_component_tbl := l_sub_comp_tbl;
584 END IF;
585
586 END IF;
587 INV_EBI_UTIL.debug_line('STEP 20: END INV_EBI_CHANGE_ORDER_HELPER.transform_substitute_comp_info STATUS: ' || x_out.output_status.return_status);
588 x_component_item := l_component_item;
589 EXCEPTION
590 WHEN OTHERS THEN
591
592 x_out.output_status.return_status := FND_API.g_ret_sts_unexp_error;
593 IF (x_out.output_status.msg_data IS NOT NULL) THEN
594 x_out.output_status.msg_data := x_out.output_status.msg_data||' ->INV_EBI_CHANGE_ORDER_HELPER.transform_substitute_comp_info ';
595 ELSE
596 x_out.output_status.msg_data := SQLERRM||'INV_EBI_CHANGE_ORDER_HELPER.transform_substitute_comp_info ';
597 END IF;
598
599 END transform_substitute_comp_info;
600
601 /************************************************************************************
602 -- API name : transform_reference_designators
603 -- Type : Private
604 -- procedure : Prepare Reference Designators for Replicate bom
605 -- Added this API for Bug 8397083
606 ************************************************************************************/
607
608 PROCEDURE transform_ref_desg(
609 p_ref_desg_tbl IN inv_ebi_ref_desg_tbl
610 ,p_component_item IN inv_ebi_rev_comp_obj
611 ,x_component_item OUT NOCOPY inv_ebi_rev_comp_obj
612 ,x_out OUT NOCOPY inv_ebi_eco_output_obj
613 ) IS
614 l_output_status inv_ebi_output_status;
615 l_ref_desg_tbl inv_ebi_ref_desg_tbl;
616 l_component_item inv_ebi_rev_comp_obj;
617 l_ref_desg_count NUMBER := 0;
618 BEGIN
619
620 l_output_status := inv_ebi_output_status(fnd_api.g_ret_sts_success,NULL,NULL,NULL);
621 x_out := inv_ebi_eco_output_obj(NULL,NULL,NULL,NULL,l_output_status,NULL,NULL);
622 INV_EBI_UTIL.debug_line('STEP 10: INSIDE INV_EBI_CHANGE_ORDER_HELPER.transform_ref_desg');
623 l_component_item := p_component_item;
624
625 IF(p_ref_desg_tbl IS NOT NULL AND p_ref_desg_tbl.COUNT > 0 ) THEN
626
627 l_ref_desg_tbl := inv_ebi_ref_desg_tbl();
628
629 FOR i IN 1..p_ref_desg_tbl.COUNT LOOP
630
631 IF(p_ref_desg_tbl(i).acd_type = 1) THEN
632
633 l_ref_desg_count := l_ref_desg_count + 1;
634 l_ref_desg_tbl.EXTEND(1);
635 l_ref_desg_tbl(l_ref_desg_count) := p_ref_desg_tbl(i);
636
637 ELSIF(p_ref_desg_tbl(i).acd_type = 2) THEN
638
639 l_ref_desg_count := l_ref_desg_count + 1;
640 l_ref_desg_tbl.EXTEND(1);
641 l_ref_desg_tbl(l_ref_desg_count) := p_ref_desg_tbl(i);
642 l_ref_desg_tbl(l_ref_desg_count).acd_type := 1;
643
644 END IF;
645
646 END LOOP;
647
648 IF(l_ref_desg_tbl IS NOT NULL AND l_ref_desg_tbl.COUNT > 0) THEN
649 l_component_item.reference_designator_tbl := l_ref_desg_tbl;
650 END IF;
651
652 END IF;
653 INV_EBI_UTIL.debug_line('STEP 20: END INV_EBI_CHANGE_ORDER_HELPER.transform_ref_desg STATUS: ' || x_out.output_status.return_status);
654 x_component_item := l_component_item;
655 EXCEPTION
656 WHEN OTHERS THEN
657
658 x_out.output_status.return_status := FND_API.g_ret_sts_unexp_error;
659 IF (x_out.output_status.msg_data IS NOT NULL) THEN
660 x_out.output_status.msg_data := x_out.output_status.msg_data||' ->INV_EBI_CHANGE_ORDER_HELPER.transform_ref_desg ';
661 ELSE
662 x_out.output_status.msg_data := SQLERRM||'INV_EBI_CHANGE_ORDER_HELPER.transform_ref_desg ';
663 END IF;
664
665 END transform_ref_desg;
666
667 /************************************************************************************
668 -- API name : merge_subcomp_refdesg_info
669 -- Type : private
670 -- procedure : Merge substitute components,Reference Designators
671 -- for Replicate bom
672 -- Added this API for Bug 8397083
673 ************************************************************************************/
674 PROCEDURE merge_subcomp_refdesg_info(
675 p_src_component_item IN inv_ebi_rev_comp_obj
676 ,p_dest_component_item IN inv_ebi_rev_comp_obj
677 ,x_dest_component_item OUT NOCOPY inv_ebi_rev_comp_obj
678 ,x_out OUT NOCOPY inv_ebi_eco_output_obj
679 ) IS
680
681 l_output_status inv_ebi_output_status;
682 l_src_ref_desg_tbl inv_ebi_ref_desg_tbl;
683 l_dest_ref_desg_tbl inv_ebi_ref_desg_tbl;
684 l_dest_sub_comp_tbl inv_ebi_sub_comp_tbl;
685 l_src_sub_comp_tbl inv_ebi_sub_comp_tbl;
686 l_src_component_item inv_ebi_rev_comp_obj;
687 l_dest_component_item inv_ebi_rev_comp_obj;
688 l_ref_desg_count NUMBER := 0;
689 l_sub_comp_exists BOOLEAN;
690 l_sub_comp_count NUMBER :=0;
691 l_ref_desg_exists BOOLEAN;
692 l_is_sub_comp_tbl_new BOOLEAN := FALSE;
693 l_is_ref_desg_tbl_new BOOLEAN := FALSE;
694
695 BEGIN
696 l_output_status := inv_ebi_output_status(fnd_api.g_ret_sts_success,NULL,NULL,NULL);
697 x_out := inv_ebi_eco_output_obj(NULL,NULL,NULL,NULL,l_output_status,NULL,NULL);
698
699 INV_EBI_UTIL.debug_line('STEP 10: INSIDE INV_EBI_CHANGE_ORDER_HELPER.merge_subcomp_refdesg_info');
700 l_dest_component_item := p_dest_component_item;
701 l_src_sub_comp_tbl := p_src_component_item.substitute_component_tbl;
702 l_src_ref_desg_tbl := p_src_component_item.reference_designator_tbl;
703 l_dest_sub_comp_tbl := l_dest_component_item.substitute_component_tbl;
704 l_dest_ref_desg_tbl := l_dest_component_item.reference_designator_tbl;
705
706 IF(l_src_sub_comp_tbl IS NOT NULL AND l_src_sub_comp_tbl.COUNT > 0) THEN
707 FOR i IN 1..l_src_sub_comp_tbl.COUNT LOOP
708 IF(l_src_sub_comp_tbl(i).acd_type <> 3) THEN
709
710 IF(l_dest_component_item.substitute_component_tbl IS NULL) THEN
711 l_dest_sub_comp_tbl := inv_ebi_sub_comp_tbl();
712 l_dest_sub_comp_tbl.EXTEND(1);
713 l_is_sub_comp_tbl_new := TRUE;
714 END IF;
715
716 l_sub_comp_exists := FALSE;
717
718 FOR j IN 1..l_dest_sub_comp_tbl.COUNT LOOP
719 IF NOT l_sub_comp_exists THEN
720 IF( l_src_sub_comp_tbl(i).substitute_component_name =
721 l_dest_sub_comp_tbl(j).substitute_component_name ) THEN
722
723 l_sub_comp_exists := TRUE;
724
725 END IF;
726 END IF;
727 END LOOP;
728
729 IF NOT l_sub_comp_exists THEN
730
731 IF NOT l_is_sub_comp_tbl_new THEN
732 l_sub_comp_count := l_dest_sub_comp_tbl.COUNT;
733 l_sub_comp_count := l_sub_comp_count +1;
734 l_dest_sub_comp_tbl.EXTEND(1);
735 ELSE
736 l_sub_comp_count := l_dest_sub_comp_tbl.COUNT;
737 l_is_sub_comp_tbl_new := FALSE;
738 END IF;
739
740 l_dest_sub_comp_tbl(l_sub_comp_count) := l_src_sub_comp_tbl(i);
741 l_sub_comp_exists := TRUE;
742
743 END IF;
744 END IF;
745 END LOOP;
746 END IF;
747
748 INV_EBI_UTIL.debug_line('STEP 20: AFTER Merging Substitute Components');
749 l_dest_component_item.substitute_component_tbl := l_dest_sub_comp_tbl;
750
751 IF( l_src_ref_desg_tbl IS NOT NULL AND l_src_ref_desg_tbl.COUNT > 0) THEN
752 FOR i IN 1..l_src_ref_desg_tbl.COUNT LOOP
753 IF(l_src_ref_desg_tbl(i).acd_type <> 3) THEN
754
755 IF(l_dest_component_item.reference_designator_tbl IS NULL) THEN
756 l_dest_ref_desg_tbl := inv_ebi_ref_desg_tbl();
757 l_dest_ref_desg_tbl.EXTEND(1);
758 l_is_ref_desg_tbl_new := TRUE;
759 END IF;
760
761 l_ref_desg_exists := FALSE;
762
763 FOR j IN 1..l_dest_ref_desg_tbl.COUNT LOOP
764 IF NOT l_ref_desg_exists THEN
765 IF( l_dest_ref_desg_tbl(j).reference_designator_name =
766 l_src_ref_desg_tbl(i).reference_designator_name ) THEN
767
768 l_ref_desg_exists := TRUE;
769 END IF;
770 END IF;
771 END LOOP;
772
773 IF NOT l_ref_desg_exists THEN
774
775 IF NOT l_is_ref_desg_tbl_new THEN
776 l_ref_desg_count := l_dest_ref_desg_tbl.COUNT;
777 l_ref_desg_count := l_ref_desg_count +1 ;
778 l_dest_ref_desg_tbl.EXTEND(1);
779 ELSE
780 l_ref_desg_count := l_dest_ref_desg_tbl.COUNT;
781 l_is_ref_desg_tbl_new := FALSE;
782 END IF;
783
784 l_dest_ref_desg_tbl(l_ref_desg_count) := l_src_ref_desg_tbl(i);
785 l_ref_desg_exists := TRUE;
786
787 END IF;
788 END IF;
789 END LOOP;
790 END IF;
791 INV_EBI_UTIL.debug_line('STEP 30: AFTER Merging Reference Designators');
792 l_dest_component_item.reference_designator_tbl := l_dest_ref_desg_tbl;
793 INV_EBI_UTIL.debug_line('STEP 40: END merge_subcomp_refdesg_info STATUS: ' || x_out.output_status.return_status);
794 x_dest_component_item := l_dest_component_item;
795 EXCEPTION
796
797 WHEN OTHERS THEN
798 x_out.output_status.return_status := FND_API.g_ret_sts_unexp_error;
799 IF (x_out.output_status.msg_data IS NOT NULL) THEN
800 x_out.output_status.msg_data := x_out.output_status.msg_data||' ->INV_EBI_CHANGE_ORDER_HELPER.merge_subcomp_refdesg_info ';
801 ELSE
802 x_out.output_status.msg_data := SQLERRM||'INV_EBI_CHANGE_ORDER_HELPER.merge_subcomp_refdesg_info ';
803 END IF;
804 END merge_subcomp_refdesg_info;
805
806
807 /************************************************************************************
808 -- API name : transform_replicate_bom_info
809 -- Type : Public
810 -- procedure : Prepare component,substitute components,Reference Designators
811 -- for Replicate bom
812 -- Added this API for Bug 8397083
813 ************************************************************************************/
814 PROCEDURE transform_replicate_bom_info(
815 p_eco_obj_list IN inv_ebi_eco_obj_tbl
816 ,p_revised_item_obj IN inv_ebi_revised_item_obj
817 ,x_revised_item_obj OUT NOCOPY inv_ebi_revised_item_obj
818 ,x_out OUT NOCOPY inv_ebi_eco_output_obj
819 ) IS
820
821 l_output_status inv_ebi_output_status;
822 l_comp_item_tbl inv_ebi_rev_comp_tbl;
823 l_revised_item_obj inv_ebi_revised_item_obj;
824 l_comp_exists BOOLEAN;
825 l_comp_count NUMBER := 0;
826 l_config_view_scope VARCHAR2(30) := 'ALL';
827 l_config_impl_scope VARCHAR2(30) := 'ALL';
828 l_as_of_date DATE;
829 l_effectivity_date DATE;
830 l_inventory_item_id NUMBER;
831 l_organization_id NUMBER;
832 l_rev_item_eff_date DATE;
833 l_is_comp_tbl_new BOOLEAN := FALSE;
834
835 BEGIN
836
837 l_output_status := inv_ebi_output_status(fnd_api.g_ret_sts_success,NULL,NULL,NULL);
838 x_out := inv_ebi_eco_output_obj(NULL,NULL,NULL,NULL,l_output_status,NULL,NULL);
839
840 l_revised_item_obj := p_revised_item_obj;
841 l_comp_item_tbl := inv_ebi_rev_comp_tbl();
842 INV_EBI_UTIL.debug_line('STEP 10: INSIDE INV_EBI_CHANGE_ORDER_HELPER.transform_replicate_bom_info');
843 FOR i IN 1..p_eco_obj_list.COUNT LOOP
844 IF(p_eco_obj_list(i).eco_revised_item_type IS NOT NULL AND p_eco_obj_list(i).eco_revised_item_type.COUNT > 0) THEN
845
846 FOR j IN 1..p_eco_obj_list(i).eco_revised_item_type.COUNT LOOP
847 INV_EBI_UTIL.debug_line('STEP 20: ITEM NAME: '|| l_revised_item_obj.orignal_bom_reference.item_name ||
848 'ORG CODE: '|| l_revised_item_obj.orignal_bom_reference.ORGANIZATION_CODE);
849 IF( p_eco_obj_list(i).eco_revised_item_type(j).revised_item_name = l_revised_item_obj.orignal_bom_reference.item_name
850 AND p_eco_obj_list(i).eco_change_order_type.organization_code = l_revised_item_obj.orignal_bom_reference.ORGANIZATION_CODE) THEN
851 IF(p_eco_obj_list(i).eco_revised_item_type(j).component_item_tbl IS NOT NULL AND p_eco_obj_list(i).eco_revised_item_type(j).component_item_tbl.COUNT > 0) THEN
852
853
854 l_comp_item_tbl := p_eco_obj_list(i).eco_revised_item_type(j).component_item_tbl;
855
856
857 l_config_view_scope := INV_EBI_UTIL.get_config_param_value (
858 p_config_tbl => p_eco_obj_list(i).name_value_tbl
859 ,p_config_param_name => 'REPLICATE_BOM_VIEW_SCOPE'
860 );
861
862
863 l_config_impl_scope := INV_EBI_UTIL.get_config_param_value (
864 p_config_tbl => p_eco_obj_list(i).name_value_tbl
865 ,p_config_param_name => 'REPLICATE_BOM_IMPLEMENTATION_SCOPE'
866 );
867 l_as_of_date := l_revised_item_obj.orignal_bom_reference.as_of_date;
868
869 l_organization_id := INV_EBI_ITEM_HELPER.get_organization_id (
870 p_organization_code => p_eco_obj_list(i).eco_change_order_type.organization_code
871 );
872
873 l_inventory_item_id := INV_EBI_ITEM_HELPER.get_inventory_item_id(
874 p_organization_id => l_organization_id
875 ,p_item_number => p_eco_obj_list(i).eco_revised_item_type(j).revised_item_name
876 ) ;
877
878 l_effectivity_date := get_latest_effectivity_date(
879 p_inventory_item_id => l_inventory_item_id,
880 p_organization_id => l_organization_id
881 );
882 INV_EBI_UTIL.debug_line('STEP 30: ORG ID: '|| l_organization_id || 'INV ITEM ID: ' || l_inventory_item_id || 'EFFECTIVITY DATE: '|| l_effectivity_date);
883 IF(l_effectivity_date < SYSDATE ) THEN
884 l_effectivity_date := SYSDATE;
885 END IF;
886
887 IF( p_eco_obj_list(i).eco_revised_item_type(j).start_effective_date IS NULL
888 OR p_eco_obj_list(i).eco_revised_item_type(j).start_effective_date = fnd_api.g_miss_date
889 OR p_eco_obj_list(i).eco_revised_item_type(j).start_effective_date < l_effectivity_date)
890 THEN
891 l_rev_item_eff_date := l_effectivity_date;
892 ELSE
893 l_rev_item_eff_date := p_eco_obj_list(i).eco_revised_item_type(j).start_effective_date;
894 END IF;
895
896 IF (l_as_of_date IS NULL OR l_as_of_date = fnd_api.g_miss_date) THEN
897 l_as_of_date := SYSDATE;
898 END IF;
899
900 END IF;
901 END IF;
902 END LOOP;
903 END IF;
904 END LOOP;
905
906 IF(l_comp_item_tbl IS NOT NULL AND l_comp_item_tbl.COUNT > 0) THEN
907 FOR i IN 1..l_comp_item_tbl.COUNT LOOP
908 IF(l_comp_item_tbl(i).acd_type <> 3) THEN
909
910 IF(l_revised_item_obj.component_item_tbl IS NULL) THEN
911 l_revised_item_obj.component_item_tbl := inv_ebi_rev_comp_tbl();
912 l_revised_item_obj.component_item_tbl.EXTEND(1);
913 l_is_comp_tbl_new := TRUE;
914 END IF;
915
916 l_comp_exists := FALSE;
917
918 FOR j IN 1..l_revised_item_obj.component_item_tbl.COUNT LOOP
919
920 IF NOT l_comp_exists THEN
921
922 IF( l_revised_item_obj.component_item_tbl(j).component_item_name = l_comp_item_tbl(i).component_item_name
923 AND l_revised_item_obj.component_item_tbl(j).operation_sequence_number = l_comp_item_tbl(i).operation_sequence_number
924 ) THEN
925
926 l_comp_exists := TRUE;
927
928 INV_EBI_UTIL.debug_line('STEP 40: BEFORE CALLING INV_EBI_CHANGE_ORDER_HELPER.merge_subcomp_refdesg_info');
929 INV_EBI_UTIL.debug_line('STEP 50: COMPONENT ITEM NAME '|| l_comp_item_tbl(i).component_item_name);
930 merge_subcomp_refdesg_info(
931 p_src_component_item => l_comp_item_tbl(i)
932 ,p_dest_component_item => l_revised_item_obj.component_item_tbl(j)
933 ,x_dest_component_item => l_revised_item_obj.component_item_tbl(j)
934 ,x_out => x_out
935 );
936 INV_EBI_UTIL.debug_line('STEP 60: AFTER CALLING INV_EBI_CHANGE_ORDER_HELPER.merge_subcomp_refdesg_info STATUS: '|| x_out.output_status.return_status);
937
938 IF(x_out.output_status.return_status <> fnd_api.g_ret_sts_success) THEN
939 RAISE FND_API.g_exc_unexpected_error;
940 END IF;
941 END IF;
942 END IF;
943 END LOOP;
944
945 IF NOT l_comp_exists THEN
946 IF(l_config_impl_scope = G_IMPLEMENT_SCOPE_UNIMPLEMENT OR l_config_impl_scope = G_VIEW_SCOPE_ALL) THEN
947
948 IF( ( l_config_view_scope = G_VIEW_SCOPE_CURRENT
949 AND l_rev_item_eff_date <= l_as_of_date
950 AND ( l_comp_item_tbl(i).disable_date > l_as_of_date
951 OR l_comp_item_tbl(i).disable_date IS NULL
952 OR l_comp_item_tbl(i).disable_date = fnd_api.g_miss_date
953 )
954 )
955 OR ( l_config_view_scope = G_VIEW_SCOPE_CURR_FUTURE
956 AND ( l_comp_item_tbl(i).disable_date > l_as_of_date
957 OR l_comp_item_tbl(i).disable_date IS NULL
958 OR l_comp_item_tbl(i).disable_date = fnd_api.g_miss_date
959 )
960 )
961 OR( l_config_view_scope = G_VIEW_SCOPE_ALL )
962
963 ) THEN
964
965
966 IF(l_comp_item_tbl(i).acd_type = 1 ) THEN
967
968 IF NOT l_is_comp_tbl_new THEN
969 l_comp_count := l_revised_item_obj.component_item_tbl.COUNT;
970 l_revised_item_obj.component_item_tbl.EXTEND(1);
971 l_comp_count := l_comp_count + 1;
972
973 ELSE
974 l_comp_count := l_revised_item_obj.component_item_tbl.COUNT;
975 l_is_comp_tbl_new := FALSE;
976 END IF;
977
978 l_revised_item_obj.component_item_tbl(l_comp_count) := l_comp_item_tbl(i);
979 l_comp_exists := TRUE;
980
981
982 ELSIF(l_comp_item_tbl(i).acd_type = 2) THEN
983
984 IF NOT l_is_comp_tbl_new THEN
985 l_comp_count := l_revised_item_obj.component_item_tbl.COUNT;
986 l_revised_item_obj.component_item_tbl.EXTEND(1);
987 l_comp_count := l_comp_count + 1;
988
989 ELSE
990 l_comp_count := l_revised_item_obj.component_item_tbl.COUNT;
991 l_is_comp_tbl_new := FALSE;
992 END IF;
993
994 l_revised_item_obj.component_item_tbl(l_comp_count) := l_comp_item_tbl(i);
995 l_revised_item_obj.component_item_tbl(l_comp_count).acd_type := 1;
996 l_revised_item_obj.component_item_tbl(l_comp_count).substitute_component_tbl := NULL;
997 l_revised_item_obj.component_item_tbl(l_comp_count).reference_designator_tbl := NULL;
998 INV_EBI_UTIL.debug_line('STEP 70: BEFORE CALLING INV_EBI_CHANGE_ORDER_HELPER.transform_substitute_comp_info');
999 transform_substitute_comp_info(
1000 p_sub_component_tbl => l_comp_item_tbl(i).substitute_component_tbl
1001 ,p_component_item => l_revised_item_obj.component_item_tbl(l_comp_count)
1002 ,x_component_item => l_revised_item_obj.component_item_tbl(l_comp_count)
1003 ,x_out => x_out
1004 );
1005 INV_EBI_UTIL.debug_line('STEP 80: AFTER CALLING INV_EBI_CHANGE_ORDER_HELPER.transform_substitute_comp_info STATUS: ' || x_out.output_status.return_status);
1006 IF(x_out.output_status.return_status <> fnd_api.g_ret_sts_success) THEN
1007 RAISE FND_API.g_exc_unexpected_error;
1008 END IF;
1009 INV_EBI_UTIL.debug_line('STEP 90: BEFORE CALLING INV_EBI_CHANGE_ORDER_HELPER.transform_ref_desg');
1010 transform_ref_desg(
1011 p_ref_desg_tbl => l_comp_item_tbl(i).reference_designator_tbl
1012 ,p_component_item => l_revised_item_obj.component_item_tbl(i)
1013 ,x_component_item => l_revised_item_obj.component_item_tbl(i)
1014 ,x_out => x_out
1015 );
1016 INV_EBI_UTIL.debug_line('STEP 100: AFTER CALLING INV_EBI_CHANGE_ORDER_HELPER.transform_ref_desg STATUS: '|| x_out.output_status.return_status);
1017 IF(x_out.output_status.return_status <> fnd_api.g_ret_sts_success) THEN
1018 RAISE FND_API.g_exc_unexpected_error;
1019 END IF;
1020 l_comp_exists := TRUE;
1021 END IF;
1022 END IF;
1023 END IF;
1024 END IF;
1025 END IF;
1026 END LOOP;
1027 END IF;
1028 x_revised_item_obj := l_revised_item_obj;
1029 INV_EBI_UTIL.debug_line('STEP 110: END INV_EBI_CHANGE_ORDER_HELPER.transform_replicate_bom_info STATUS: '|| x_out.output_status.return_status);
1030 EXCEPTION
1031 WHEN FND_API.g_exc_unexpected_error THEN
1032 x_out.output_status.return_status := FND_API.g_ret_sts_unexp_error;
1033
1034 IF(x_out.output_status.msg_data IS NULL) THEN
1035 fnd_msg_pub.count_and_get(
1036 p_encoded => FND_API.g_false
1037 ,p_count => x_out.output_status.msg_count
1038 ,p_data => x_out.output_status.msg_data
1039 );
1040 END IF;
1041 WHEN OTHERS THEN
1042
1043 x_out.output_status.return_status := FND_API.g_ret_sts_unexp_error;
1044 IF (x_out.output_status.msg_data IS NOT NULL) THEN
1045 x_out.output_status.msg_data := x_out.output_status.msg_data||' ->INV_EBI_CHANGE_ORDER_HELPER.transform_replicate_bom_info ';
1046 ELSE
1047 x_out.output_status.msg_data := SQLERRM||'INV_EBI_CHANGE_ORDER_HELPER.transform_replicate_bom_info ';
1048 END IF;
1049 END transform_replicate_bom_info;
1050 /************************************************************************************
1051 -- API name : prepare_substitute_components
1052 -- Type : Private
1053 -- Function : Prepare substitute components for Replicate bom
1054 ************************************************************************************/
1055 PROCEDURE prepare_substitute_components(
1056 p_component_item IN inv_ebi_rev_comp_obj
1057 ,p_from_sequence_id IN NUMBER
1058 ,p_reference_org_id IN NUMBER
1059 ,x_component_item OUT NOCOPY inv_ebi_rev_comp_obj
1060 ,x_out OUT NOCOPY inv_ebi_eco_output_obj
1061 ) IS
1062
1063 CURSOR c_comp_sequence_id
1064 IS
1065 SELECT
1066 bic.component_sequence_id
1067 FROM
1068 bom_inventory_components bic,
1069 mtl_system_items_kfv it
1070 WHERE
1071 bic.bill_sequence_id = p_from_sequence_id
1072 AND bic.component_item_id = it.inventory_item_id
1073 AND it.organization_id = p_reference_org_id
1074 AND it.concatenated_segments = p_component_item.component_item_name;
1075
1076 CURSOR c_copied_substitute_comps (p_component_sequence_id IN NUMBER)
1077 IS
1078 SELECT
1079 sc.substitute_component_id,
1080 it.concatenated_segments substitute_component_name
1081 FROM
1082 bom_substitute_components sc,
1083 mtl_system_items_kfv it
1084 WHERE
1085 sc.substitute_component_id = it.inventory_item_id
1086 AND it.organization_id = p_reference_org_id
1087 AND sc.component_sequence_id = p_component_sequence_id
1088 AND NVL(sc.acd_type,1) = 1; --Only added components are taken
1089
1090 l_copied_substitute_comp c_copied_substitute_comps%ROWTYPE;
1091
1092 CURSOR c_merged_substitute_comp (
1093 p_new_substitute_comp IN inv_ebi_sub_comp_obj
1094 ,p_component_sequence_id IN NUMBER
1095 ,p_substitute_component_name IN VARCHAR2
1096 ) IS
1097 SELECT
1098 DECODE(p_new_substitute_comp ,NULL ,NVL(sc.acd_type,1) ,DECODE(p_new_substitute_comp.acd_type
1099 ,fnd_api.g_miss_num ,NVL(sc.acd_type,1) ,p_new_substitute_comp.acd_type)) acd_type
1100 ,DECODE(p_new_substitute_comp ,NULL ,sc.substitute_item_quantity ,DECODE(p_new_substitute_comp.substitute_item_quantity
1101 ,fnd_api.g_miss_num ,sc.substitute_item_quantity ,p_new_substitute_comp.substitute_item_quantity)) substitute_item_quantity
1102 ,DECODE(p_new_substitute_comp ,NULL ,sc.attribute_category ,DECODE(p_new_substitute_comp.attribute_category
1103 ,fnd_api.g_miss_char ,sc.attribute_category ,p_new_substitute_comp.attribute_category )) attribute_category
1104 ,DECODE(p_new_substitute_comp ,NULL ,sc.attribute1 ,DECODE(p_new_substitute_comp.attribute1
1105 ,fnd_api.g_miss_char ,sc.attribute1 ,p_new_substitute_comp.attribute1 )) attribute1
1106 ,DECODE(p_new_substitute_comp ,NULL ,sc.attribute2 ,DECODE(p_new_substitute_comp.attribute2
1107 ,fnd_api.g_miss_char ,sc.attribute2 ,p_new_substitute_comp.attribute2 )) attribute2
1108 ,DECODE(p_new_substitute_comp ,NULL ,sc.attribute3 ,DECODE(p_new_substitute_comp.attribute3
1109 ,fnd_api.g_miss_char ,sc.attribute3 ,p_new_substitute_comp.attribute3 )) attribute3
1110 ,DECODE(p_new_substitute_comp ,NULL ,sc.attribute4 ,DECODE(p_new_substitute_comp.attribute4
1111 ,fnd_api.g_miss_char ,sc.attribute4 ,p_new_substitute_comp.attribute4 )) attribute4
1112 ,DECODE(p_new_substitute_comp ,NULL ,sc.attribute5 ,DECODE(p_new_substitute_comp.attribute5
1113 ,fnd_api.g_miss_char ,sc.attribute5 ,p_new_substitute_comp.attribute5 )) attribute5
1114 ,DECODE(p_new_substitute_comp ,NULL ,sc.attribute6 ,DECODE(p_new_substitute_comp.attribute6
1115 ,fnd_api.g_miss_char ,sc.attribute6 ,p_new_substitute_comp.attribute6 )) attribute6
1116 ,DECODE(p_new_substitute_comp ,NULL ,sc.attribute7 ,DECODE(p_new_substitute_comp.attribute7
1117 ,fnd_api.g_miss_char ,sc.attribute7 ,p_new_substitute_comp.attribute7 )) attribute7
1118 ,DECODE(p_new_substitute_comp ,NULL ,sc.attribute8 ,DECODE(p_new_substitute_comp.attribute8
1119 ,fnd_api.g_miss_char ,sc.attribute8 ,p_new_substitute_comp.attribute8 )) attribute8
1120 ,DECODE(p_new_substitute_comp ,NULL ,sc.attribute9 ,DECODE(p_new_substitute_comp.attribute9
1121 ,fnd_api.g_miss_char ,sc.attribute9 ,p_new_substitute_comp.attribute9 )) attribute9
1122 ,DECODE(p_new_substitute_comp ,NULL ,sc.attribute10 ,DECODE(p_new_substitute_comp.attribute10
1123 ,fnd_api.g_miss_char ,sc.attribute10 ,p_new_substitute_comp.attribute10 )) attribute10
1124 ,DECODE(p_new_substitute_comp ,NULL ,sc.attribute11 ,DECODE(p_new_substitute_comp.attribute11
1125 ,fnd_api.g_miss_char ,sc.attribute11 ,p_new_substitute_comp.attribute11 )) attribute11
1126 ,DECODE(p_new_substitute_comp ,NULL ,sc.attribute12 ,DECODE(p_new_substitute_comp.attribute12
1127 ,fnd_api.g_miss_char ,sc.attribute12 ,p_new_substitute_comp.attribute12 )) attribute12
1128 ,DECODE(p_new_substitute_comp ,NULL ,sc.attribute13 ,DECODE(p_new_substitute_comp.attribute13
1129 ,fnd_api.g_miss_char ,sc.attribute13 ,p_new_substitute_comp.attribute13 )) attribute13
1130 ,DECODE(p_new_substitute_comp ,NULL ,sc.attribute14 ,DECODE(p_new_substitute_comp.attribute14
1131 ,fnd_api.g_miss_char ,sc.attribute14 ,p_new_substitute_comp.attribute14 )) attribute14
1132 ,DECODE(p_new_substitute_comp ,NULL ,sc.attribute15 ,DECODE(p_new_substitute_comp.attribute15
1133 ,fnd_api.g_miss_char ,sc.attribute15 ,p_new_substitute_comp.attribute15 )) attribute15
1134 ,DECODE(p_new_substitute_comp ,NULL ,sc.original_system_reference ,DECODE(p_new_substitute_comp.original_system_reference
1135 ,fnd_api.g_miss_char ,sc.original_system_reference ,p_new_substitute_comp.original_system_reference)) original_system_reference
1136 ,DECODE(p_new_substitute_comp ,NULL ,sc.enforce_int_requirements ,DECODE(p_new_substitute_comp.enforce_int_requirements
1137 ,fnd_api.g_miss_num ,sc.enforce_int_requirements ,p_new_substitute_comp.enforce_int_requirements)) enforce_int_requirements
1138 ,DECODE(p_new_substitute_comp ,NULL ,NULL ,p_new_substitute_comp.start_effective_date) start_effective_date
1139 ,DECODE(p_new_substitute_comp ,NULL ,NULL ,p_new_substitute_comp.new_substitute_component_name ) new_substitute_component_name
1140 ,DECODE(p_new_substitute_comp ,NULL ,NULL ,p_new_substitute_comp.from_end_item_unit_number) from_end_item_unit_number
1141 ,DECODE(p_new_substitute_comp ,NULL ,NULL ,p_new_substitute_comp.new_routing_revision) new_routing_revision
1142 ,DECODE(p_new_substitute_comp ,NULL ,NULL ,p_new_substitute_comp.return_status) return_status
1143 ,DECODE(p_new_substitute_comp ,NULL ,NULL ,p_new_substitute_comp.inverse_quantity) inverse_quantity
1144 ,DECODE(p_new_substitute_comp ,NULL ,NULL ,p_new_substitute_comp.row_identifier ) row_identifier
1145 ,DECODE(p_new_substitute_comp ,NULL ,NULL ,p_new_substitute_comp.program_id) program_id
1146 FROM
1147 bom_substitute_components sc,
1148 mtl_system_items_kfv it
1149 WHERE
1150 sc.substitute_component_id = it.inventory_item_id AND
1151 it.organization_id = p_reference_org_id AND
1152 it.concatenated_segments = p_substitute_component_name AND
1153 sc.component_sequence_id = p_component_sequence_id;
1154
1155 l_component_sequence_id NUMBER;
1156 i NUMBER := 0;
1157 l_component_item inv_ebi_rev_comp_obj;
1158 l_Found BOOLEAN;
1159 l_merged_subst_comp c_Merged_Substitute_Comp%ROWTYPE;
1160 l_substitute_comp_tbl inv_ebi_sub_comp_tbl;
1161 l_sub_comp_count NUMBER := 1;
1162 l_output_status inv_ebi_output_status;
1163 BEGIN
1164 l_output_status := inv_ebi_output_status(fnd_api.g_ret_sts_success,NULL,NULL,NULL);
1165 x_out := inv_ebi_eco_output_obj(NULL,NULL,NULL,NULL,l_output_status,NULL,NULL);
1166 INV_EBI_UTIL.debug_line('STEP 10: START INSIDE INV_EBI_CHANGE_ORDER_HELPER.prepare_substitute_components');
1167 OPEN c_comp_sequence_id;
1168 FETCH c_comp_sequence_id INTO l_component_sequence_id;
1169 CLOSE c_comp_sequence_id;
1170
1171 l_component_item := p_component_item;
1172
1173 IF p_component_item.substitute_component_tbl IS NOT NULL THEN
1174 l_substitute_comp_tbl := inv_ebi_sub_comp_tbl();
1175 FOR i IN 1..p_component_item.substitute_component_tbl.COUNT LOOP
1176 IF p_component_item.substitute_component_tbl(i).transaction_type <> ENG_GLOBALS.g_opr_delete THEN
1177 l_substitute_comp_tbl.EXTEND(1);
1178 l_substitute_comp_tbl(l_sub_comp_count) := p_component_item.substitute_component_tbl(i);
1179 l_sub_comp_count := l_sub_comp_count + 1;
1180 END IF;
1181 END LOOP;
1182 l_component_item.substitute_component_tbl := l_Substitute_Comp_Tbl;
1183 END IF;
1184
1185
1186 OPEN c_copied_substitute_comps(l_Component_Sequence_Id);
1187 LOOP
1188 FETCH c_copied_substitute_comps INTO l_copied_substitute_comp;
1189 EXIT WHEN c_copied_substitute_comps%NOTFOUND;
1190 l_Found := FALSE;
1191 IF p_component_item.substitute_component_tbl IS NOT NULL THEN
1192 FOR i IN 1..p_component_item.substitute_component_tbl.COUNT LOOP
1193 INV_EBI_UTIL.debug_line('STEP 20: SUBSTITUTE COMPONENT NAME: '|| p_component_item.substitute_component_tbl(i).substitute_component_name);
1194 IF l_copied_substitute_comp.substitute_component_name = p_component_item.substitute_component_tbl(i).substitute_component_name THEN
1195 l_Found := TRUE;
1196 END IF;
1197 END LOOP;
1198 END IF;
1199
1200 IF NOT l_Found THEN
1201 OPEN c_merged_substitute_comp(p_new_substitute_comp => NULL
1202 ,p_substitute_component_name => l_copied_substitute_comp.substitute_component_name
1203 ,p_component_sequence_id => l_Component_Sequence_Id
1204 );
1205 FETCH c_merged_substitute_comp INTO l_merged_subst_comp;
1206 IF l_component_item.substitute_component_tbl IS NULL THEN
1207 l_component_item.substitute_component_tbl := inv_ebi_sub_comp_tbl();
1208 END IF;
1209
1210 l_component_item.substitute_component_tbl.EXTEND(1);
1211 l_component_item.substitute_component_tbl(l_component_item.substitute_component_tbl.COUNT) := inv_ebi_sub_comp_obj(
1212 l_component_item.start_effective_date
1213 ,l_copied_substitute_comp.substitute_component_name
1214 ,l_merged_subst_comp.new_substitute_component_name
1215 ,l_merged_subst_comp.acd_type
1216 ,l_merged_subst_comp.substitute_item_quantity
1217 ,l_merged_subst_comp.attribute_category
1218 ,l_merged_subst_comp.attribute1
1219 ,l_merged_subst_comp.attribute2
1220 ,l_merged_subst_comp.attribute3
1221 ,l_merged_subst_comp.attribute4
1222 ,l_merged_subst_comp.attribute5
1223 ,l_merged_subst_comp.attribute6
1224 ,l_merged_subst_comp.attribute7
1225 ,l_merged_subst_comp.attribute8
1226 ,l_merged_subst_comp.attribute9
1227 ,l_merged_subst_comp.attribute10
1228 ,l_merged_subst_comp.attribute11
1229 ,l_merged_subst_comp.attribute12
1230 ,l_merged_subst_comp.attribute13
1231 ,l_merged_subst_comp.attribute14
1232 ,l_merged_subst_comp.attribute15
1233 ,l_merged_subst_comp.original_system_reference
1234 ,l_merged_subst_comp.from_end_item_unit_number
1235 ,l_merged_subst_comp.new_routing_revision
1236 ,l_merged_subst_comp.enforce_int_requirements
1237 ,l_merged_subst_comp.return_status
1238 ,ENG_GLOBALS.g_opr_create
1239 ,l_merged_subst_comp.row_identifier
1240 ,l_merged_subst_comp.inverse_quantity
1241 ,l_Merged_Subst_Comp.program_id
1242 ,NULL);
1243 CLOSE c_merged_substitute_comp;
1244 END IF;
1245 END LOOP;
1246 CLOSE c_copied_substitute_comps;
1247
1248
1249 IF l_component_item.substitute_component_tbl IS NOT NULL THEN
1250 FOR i IN 1..l_component_item.substitute_component_tbl.COUNT LOOP
1251 IF l_component_item.substitute_component_tbl(i).transaction_type = ENG_GLOBALS.g_opr_update THEN
1252 OPEN c_merged_substitute_comp(p_new_substitute_comp => l_component_item.substitute_component_tbl(i)
1253 ,p_substitute_component_name => l_component_item.substitute_component_tbl(i).substitute_component_name
1254 ,p_Component_Sequence_Id => l_Component_Sequence_Id);
1255 FETCH c_merged_substitute_comp INTO l_Merged_Subst_Comp;
1256 IF c_merged_substitute_comp%FOUND THEN
1257 l_component_item.substitute_component_tbl(i) := inv_ebi_sub_comp_obj(
1258 l_merged_subst_comp.start_effective_date
1259 ,l_component_item.substitute_component_tbl(i).substitute_component_name
1260 ,l_merged_subst_comp.new_substitute_component_name
1261 ,l_merged_subst_comp.acd_type
1262 ,l_merged_subst_comp.substitute_item_quantity
1263 ,l_merged_subst_comp.attribute_category
1264 ,l_merged_subst_comp.attribute1
1265 ,l_merged_subst_comp.attribute2
1266 ,l_merged_subst_comp.attribute3
1267 ,l_merged_subst_comp.attribute4
1268 ,l_merged_subst_comp.attribute5
1269 ,l_merged_subst_comp.attribute6
1270 ,l_merged_subst_comp.attribute7
1271 ,l_merged_subst_comp.attribute8
1272 ,l_merged_subst_comp.attribute9
1273 ,l_merged_subst_comp.attribute10
1274 ,l_merged_subst_comp.attribute11
1275 ,l_merged_subst_comp.attribute12
1276 ,l_merged_subst_comp.attribute13
1277 ,l_merged_subst_comp.attribute14
1278 ,l_merged_subst_comp.attribute15
1279 ,l_merged_subst_comp.original_system_reference
1280 ,l_merged_subst_comp.from_end_item_unit_number
1281 ,l_merged_subst_comp.new_routing_revision
1282 ,l_merged_subst_comp.enforce_int_requirements
1283 ,l_merged_subst_comp.return_status
1284 ,ENG_GLOBALS.g_opr_create
1285 ,l_merged_subst_comp.row_identifier
1286 ,l_merged_subst_comp.inverse_quantity
1287 ,l_merged_subst_comp.program_id
1288 ,NULL);
1289 END IF;
1290 CLOSE c_merged_substitute_comp;
1291 END IF;
1292 END LOOP;
1293 END IF;
1294
1295 x_component_item := l_component_item;
1296 INV_EBI_UTIL.debug_line('STEP 30: END INSIDE INV_EBI_CHANGE_ORDER_HELPER.prepare_substitute_components STATUS : '|| x_out.output_status.return_status );
1297
1298 EXCEPTION
1299 WHEN FND_API.g_exc_unexpected_error THEN
1300 IF c_Merged_Substitute_Comp%ISOPEN THEN
1301 CLOSE c_merged_substitute_comp;
1302 END IF;
1303 IF c_copied_substitute_comps%ISOPEN THEN
1304 CLOSE c_copied_substitute_comps;
1305 END IF;
1306 x_out.output_status.return_status := FND_API.g_ret_sts_unexp_error;
1307 IF(x_out.output_status.msg_data IS NULL) THEN
1308 fnd_msg_pub.count_and_get(
1309 p_encoded => FND_API.g_false
1310 ,p_count => x_out.output_status.msg_count
1311 ,p_data => x_out.output_status.msg_data
1312 );
1313 END IF;
1314 WHEN OTHERS THEN
1315 IF c_merged_substitute_comp%ISOPEN THEN
1316 CLOSE c_merged_substitute_comp;
1317 END IF;
1318 IF c_copied_substitute_comps%ISOPEN THEN
1319 CLOSE c_copied_substitute_comps;
1320 END IF;
1321 x_out.output_status.return_status := FND_API.g_ret_sts_unexp_error;
1322 IF (x_out.output_status.msg_data IS NOT NULL) THEN
1323 x_out.output_status.msg_data := x_out.output_status.msg_data||' ->INV_EBI_CHANGE_ORDER_HELPER.prepare_substitute_components ';
1324 ELSE
1325 x_out.output_status.msg_data := SQLERRM||'INV_EBI_CHANGE_ORDER_HELPER.prepare_substitute_components ';
1326 END IF;
1327 END prepare_substitute_components;
1328
1329 /************************************************************************************
1330 -- API name : prepare_reference_designators
1331 -- Type : Private
1332 -- Function : Prepare reference_designators for Replicate bom
1333 ************************************************************************************/
1334 PROCEDURE prepare_reference_designators(
1335 p_component_item IN inv_ebi_rev_comp_obj
1336 ,p_from_sequence_id IN NUMBER
1337 ,p_reference_org_id IN NUMBER
1338 ,x_component_item OUT NOCOPY inv_ebi_rev_comp_obj
1339 ,x_out OUT NOCOPY inv_ebi_eco_output_obj
1340 ) IS
1341
1342 CURSOR c_comp_sequence_id
1343 IS
1344 SELECT
1345 bic.component_sequence_id
1346 FROM
1347 bom_inventory_components bic,
1348 mtl_system_items_kfv it
1349 WHERE
1350 bic.bill_sequence_id = p_from_sequence_id
1351 AND bic.component_item_id = it.inventory_item_id
1352 AND it.organization_id = p_reference_org_id
1353 AND it.concatenated_segments = p_component_item.component_item_name;
1354
1355 CURSOR c_copied_ref_designators (p_component_sequence_id IN NUMBER)
1356 IS
1357 SELECT
1358 component_reference_designator reference_designator_name
1359 FROM
1360 bom_reference_designators
1361 WHERE
1362 component_sequence_id = p_component_sequence_id
1363 AND NVL(acd_type,1) = 1; --Only added components are taken
1364
1365
1366 CURSOR c_merged_ref_designators (
1367 p_new_ref_designator IN inv_ebi_ref_desg_obj
1368 ,p_component_sequence_id IN NUMBER
1369 ,p_ref_designator_name IN VARCHAR2
1370 ) IS
1371 SELECT
1372 DECODE(p_new_ref_designator ,NULL ,NVL(acd_type,1) ,DECODE(p_new_ref_designator.acd_type
1373 ,fnd_api.g_miss_num ,NVL(acd_type,1) ,p_new_ref_designator.acd_type)) acd_type
1374 ,DECODE(p_new_ref_designator ,NULL ,attribute_category ,DECODE(p_new_ref_designator.attribute_category
1375 ,fnd_api.g_miss_char ,attribute_category ,p_new_ref_designator.attribute_category )) attribute_category
1376 ,DECODE(p_new_ref_designator ,NULL ,attribute1 ,DECODE(p_new_ref_designator.attribute1
1377 ,fnd_api.g_miss_char ,attribute1 ,p_new_ref_designator.attribute1 )) attribute1
1378 ,DECODE(p_new_ref_designator ,NULL ,attribute2 ,DECODE(p_new_ref_designator.attribute2
1379 ,fnd_api.g_miss_char ,attribute2 ,p_new_ref_designator.attribute2 )) attribute2
1380 ,DECODE(p_new_ref_designator ,NULL ,attribute3 ,DECODE(p_new_ref_designator.attribute3
1381 ,fnd_api.g_miss_char ,attribute3 ,p_new_ref_designator.attribute3 )) attribute3
1382 ,DECODE(p_new_ref_designator ,NULL ,attribute4 ,DECODE(p_new_ref_designator.attribute4
1383 ,fnd_api.g_miss_char ,attribute4 ,p_new_ref_designator.attribute4 )) attribute4
1384 ,DECODE(p_new_ref_designator ,NULL ,attribute5 ,DECODE(p_new_ref_designator.attribute5
1385 ,fnd_api.g_miss_char ,attribute5 ,p_new_ref_designator.attribute5 )) attribute5
1386 ,DECODE(p_new_ref_designator ,NULL ,attribute6 ,DECODE(p_new_ref_designator.attribute6
1387 ,fnd_api.g_miss_char ,attribute6 ,p_new_ref_designator.attribute6 )) attribute6
1388 ,DECODE(p_new_ref_designator ,NULL ,attribute7 ,DECODE(p_new_ref_designator.attribute7
1389 ,fnd_api.g_miss_char ,attribute7 ,p_new_ref_designator.attribute7 )) attribute7
1390 ,DECODE(p_new_ref_designator ,NULL ,attribute8 ,DECODE(p_new_ref_designator.attribute8
1391 ,fnd_api.g_miss_char ,attribute8 ,p_new_ref_designator.attribute8 )) attribute8
1392 ,DECODE(p_new_ref_designator ,NULL ,attribute9 ,DECODE(p_new_ref_designator.attribute9
1393 ,fnd_api.g_miss_char ,attribute9 ,p_new_ref_designator.attribute9 )) attribute9
1394 ,DECODE(p_new_ref_designator ,NULL ,attribute10 ,DECODE(p_new_ref_designator.attribute10
1395 ,fnd_api.g_miss_char ,attribute10 ,p_new_ref_designator.attribute10 )) attribute10
1396 ,DECODE(p_new_ref_designator ,NULL ,attribute11 ,DECODE(p_new_ref_designator.attribute11
1397 ,fnd_api.g_miss_char ,attribute11 ,p_new_ref_designator.attribute11 )) attribute11
1398 ,DECODE(p_new_ref_designator ,NULL ,attribute12 ,DECODE(p_new_ref_designator.attribute12
1399 ,fnd_api.g_miss_char ,attribute12 ,p_new_ref_designator.attribute12 )) attribute12
1400 ,DECODE(p_new_ref_designator ,NULL ,attribute13 ,DECODE(p_new_ref_designator.attribute13
1401 ,fnd_api.g_miss_char ,attribute13 ,p_new_ref_designator.attribute13 )) attribute13
1402 ,DECODE(p_new_ref_designator ,NULL ,attribute14 ,DECODE(p_new_ref_designator.attribute14
1403 ,fnd_api.g_miss_char ,attribute14 ,p_new_ref_designator.attribute14 )) attribute14
1404 ,DECODE(p_new_ref_designator ,NULL ,attribute15 ,DECODE(p_new_ref_designator.attribute15
1405 ,fnd_api.g_miss_char ,attribute15 ,p_new_ref_designator.attribute15 )) attribute15
1406 ,DECODE(p_new_ref_designator ,NULL ,original_system_reference ,DECODE(p_new_ref_designator.original_system_reference
1407 ,fnd_api.g_miss_char ,original_system_reference ,p_new_ref_designator.original_system_reference)) original_system_reference
1408 ,DECODE(p_new_ref_designator ,NULL ,ref_designator_comment ,DECODE(p_new_ref_designator.ref_designator_comment
1409 ,fnd_api.g_miss_char ,ref_designator_comment ,p_new_ref_designator.ref_designator_comment )) ref_designator_comment
1410 ,DECODE(p_new_ref_designator ,NULL ,NULL ,p_new_ref_designator.start_effective_date) start_effective_date
1411 ,DECODE(p_new_ref_designator ,NULL ,NULL ,p_new_ref_designator.new_reference_designator ) new_reference_designator
1412 ,DECODE(p_new_ref_designator ,NULL ,NULL ,p_new_ref_designator.from_end_item_unit_number) from_end_item_unit_number
1413 ,DECODE(p_new_ref_designator ,NULL ,NULL ,p_new_ref_designator.new_routing_revision) new_routing_revision
1414 ,DECODE(p_new_ref_designator ,NULL ,NULL ,p_new_ref_designator.return_status) return_status
1415 ,DECODE(p_new_ref_designator ,NULL ,NULL ,p_new_ref_designator.row_identifier ) row_identifier
1416 FROM
1417 bom_reference_designators
1418 WHERE
1419 component_reference_designator = p_ref_designator_name AND
1420 component_sequence_id = p_component_sequence_id;
1421
1422 i NUMBER := 0;
1423 l_merged_ref_designator c_merged_ref_designators%ROWTYPE;
1424 l_copied_ref_designator c_copied_ref_designators%ROWTYPE;
1425 l_component_sequence_id NUMBER;
1426 l_component_item inv_ebi_rev_comp_obj;
1427 l_Found BOOLEAN;
1428 l_ref_designator_tbl inv_ebi_ref_desg_tbl;
1429 l_ref_dsgn_count NUMBER := 1;
1430 l_output_status inv_ebi_output_status;
1431
1432 BEGIN
1433 l_output_status := inv_ebi_output_status(fnd_api.g_ret_sts_success,NULL,NULL,NULL);
1434 x_out := inv_ebi_eco_output_obj(NULL,NULL,NULL,NULL,l_output_status,NULL,NULL);
1435 INV_EBI_UTIL.debug_line('STEP 10: START INSIDE INV_EBI_CHANGE_ORDER_HELPER.prepare_reference_designators');
1436 OPEN c_comp_sequence_id;
1437 FETCH c_comp_sequence_id INTO l_component_sequence_id;
1438 CLOSE c_comp_sequence_id;
1439
1440 l_component_item := p_component_item;
1441
1442 IF p_component_item.reference_designator_tbl IS NOT NULL THEN
1443 l_ref_designator_tbl := inv_ebi_ref_desg_tbl();
1444 FOR i IN 1..p_component_item.reference_designator_tbl.COUNT LOOP
1445 IF p_component_item.reference_designator_tbl(i).transaction_type <> ENG_GLOBALS.g_opr_delete THEN
1446 l_ref_designator_tbl.EXTEND(1);
1447 l_ref_designator_tbl(l_ref_dsgn_count) := p_component_item.reference_designator_tbl(i);
1448 l_ref_dsgn_count := l_ref_dsgn_count + 1;
1449 END IF;
1450 END LOOP;
1451 l_component_item.reference_designator_tbl := l_ref_designator_tbl;
1452 END IF;
1453
1454 OPEN c_copied_ref_designators(l_Component_Sequence_Id);
1455 LOOP
1456 FETCH c_copied_ref_designators INTO l_copied_ref_designator;
1457 EXIT WHEN c_copied_ref_designators%NOTFOUND;
1458 l_Found := FALSE;
1459 IF p_component_item.reference_designator_tbl IS NOT NULL THEN
1460 FOR i IN 1..p_component_item.reference_designator_tbl.COUNT LOOP
1461 IF l_copied_ref_designator.reference_designator_name = p_component_item.reference_designator_tbl(i).reference_designator_name THEN
1462 l_Found := TRUE;
1463 END IF;
1464 END LOOP;
1465 END IF;
1466
1467 IF NOT l_Found THEN
1468 OPEN c_merged_ref_designators(p_New_Ref_Designator => NULL
1469 ,p_ref_designator_name => l_copied_ref_designator.reference_designator_name
1470 ,p_component_sequence_id => l_component_sequence_id
1471 );
1472 FETCH c_merged_ref_designators INTO l_merged_ref_designator;
1473 IF l_component_item.reference_designator_tbl IS NULL THEN
1474 l_component_item.reference_designator_tbl := inv_ebi_ref_desg_tbl();
1475 END IF;
1476 l_component_item.reference_designator_tbl.EXTEND(1);
1477
1478 l_component_item.reference_designator_tbl(l_component_item.reference_designator_tbl.COUNT) := inv_ebi_ref_desg_obj(
1479 l_component_item.start_effective_date
1480 ,l_copied_ref_designator.reference_designator_name
1481 ,l_merged_ref_designator.acd_type
1482 ,l_merged_ref_designator.ref_designator_comment
1483 ,l_merged_ref_designator.attribute_category
1484 ,l_merged_ref_designator.attribute1
1485 ,l_merged_ref_designator.attribute2
1486 ,l_merged_ref_designator.attribute3
1487 ,l_merged_ref_designator.attribute4
1488 ,l_merged_ref_designator.attribute5
1489 ,l_merged_ref_designator.attribute6
1490 ,l_merged_ref_designator.attribute7
1491 ,l_merged_ref_designator.attribute8
1492 ,l_merged_ref_designator.attribute9
1493 ,l_merged_ref_designator.attribute10
1494 ,l_merged_ref_designator.attribute11
1495 ,l_merged_ref_designator.attribute12
1496 ,l_merged_ref_designator.attribute13
1497 ,l_merged_ref_designator.attribute14
1498 ,l_merged_ref_designator.attribute15
1499 ,l_merged_ref_designator.original_system_reference
1500 ,l_merged_ref_designator.new_reference_designator
1501 ,l_merged_ref_designator.from_end_item_unit_number
1502 ,l_merged_ref_designator.new_routing_revision
1503 ,l_merged_ref_designator.return_status
1504 ,ENG_GLOBALS.g_opr_create
1505 ,l_merged_ref_designator.row_identifier
1506 ,NULL);
1507 CLOSE c_merged_ref_designators;
1508 END IF;
1509 END LOOP;
1510 CLOSE c_copied_ref_designators;
1511
1512 IF l_component_item.reference_designator_tbl IS NOT NULL THEN
1513
1514 FOR i IN 1..l_component_item.reference_designator_tbl.COUNT LOOP
1515 IF l_component_item.reference_designator_tbl(i).transaction_type = ENG_GLOBALS.g_opr_update THEN
1516 OPEN c_merged_ref_designators(p_new_ref_designator => l_component_item.reference_designator_tbl(i)
1517 ,p_ref_designator_name => l_component_item.reference_designator_tbl(i).reference_designator_name
1518 ,p_component_sequence_id => l_Component_Sequence_Id);
1519 FETCH c_merged_ref_designators INTO l_merged_ref_designator;
1520 l_component_item.reference_designator_tbl(i) := inv_ebi_ref_desg_obj(
1521 l_merged_ref_designator.start_effective_date
1522 ,l_component_item.reference_designator_tbl(i).reference_designator_name
1523 ,l_merged_ref_designator.acd_type
1524 ,l_merged_ref_designator.ref_designator_comment
1525 ,l_merged_ref_designator.attribute_category
1526 ,l_merged_ref_designator.attribute1
1527 ,l_merged_ref_designator.attribute2
1528 ,l_merged_ref_designator.attribute3
1529 ,l_merged_ref_designator.attribute4
1530 ,l_merged_ref_designator.attribute5
1531 ,l_merged_ref_designator.attribute6
1532 ,l_merged_ref_designator.attribute7
1533 ,l_merged_ref_designator.attribute8
1534 ,l_merged_ref_designator.attribute9
1535 ,l_merged_ref_designator.attribute10
1536 ,l_merged_ref_designator.attribute11
1537 ,l_merged_ref_designator.attribute12
1538 ,l_merged_ref_designator.attribute13
1539 ,l_merged_ref_designator.attribute14
1540 ,l_merged_ref_designator.attribute15
1541 ,l_merged_ref_designator.original_system_reference
1542 ,l_merged_ref_designator.new_reference_designator
1543 ,l_merged_ref_designator.from_end_item_unit_number
1544 ,l_merged_ref_designator.new_routing_revision
1545 ,l_merged_ref_designator.return_status
1546 ,ENG_GLOBALS.g_opr_create
1547 ,l_merged_ref_designator.row_identifier
1548 ,NULL);
1549 CLOSE c_merged_ref_designators;
1550 END IF;
1551 END LOOP;
1552 END IF;
1553
1554 x_component_item := l_component_item;
1555 INV_EBI_UTIL.debug_line('STEP 20: END INSIDE INV_EBI_CHANGE_ORDER_HELPER.prepare_reference_designators STATUS: ' || x_out.output_status.return_status);
1556
1557 EXCEPTION
1558 WHEN FND_API.g_exc_unexpected_error THEN
1559 IF c_merged_ref_designators%ISOPEN THEN
1560 CLOSE c_merged_ref_designators;
1561 END IF;
1562 IF c_copied_ref_designators%ISOPEN THEN
1563 CLOSE c_copied_ref_designators;
1564 END IF;
1565 x_out.output_status.return_status := FND_API.g_ret_sts_unexp_error;
1566 IF(x_out.output_status.msg_data IS NULL) THEN
1567 fnd_msg_pub.count_and_get(
1568 p_encoded => FND_API.g_false
1569 ,p_count => x_out.output_status.msg_count
1570 ,p_data => x_out.output_status.msg_data
1571 );
1572 END IF;
1573 WHEN OTHERS THEN
1574 IF c_merged_ref_designators%ISOPEN THEN
1575 CLOSE c_merged_ref_designators;
1576 END IF;
1577 IF c_copied_ref_designators%ISOPEN THEN
1578 CLOSE c_copied_ref_designators;
1579 END IF;
1580 x_out.output_status.return_status := FND_API.g_ret_sts_unexp_error;
1581 IF (x_out.output_status.msg_data IS NOT NULL) THEN
1582 x_out.output_status.msg_data := x_out.output_status.msg_data||' ->INV_EBI_CHANGE_ORDER_HELPER.prepare_reference_designators ';
1583 ELSE
1584 x_out.output_status.msg_data := SQLERRM||'INV_EBI_CHANGE_ORDER_HELPER.prepare_reference_designators ';
1585 END IF;
1586 END prepare_reference_designators;
1587
1588
1589 /************************************************************************************
1590 -- API name : prepare_component_items
1591 -- Type : Private
1592 -- Function : Prepare component_items for Replicate bom
1593 ************************************************************************************/
1594 PROCEDURE prepare_component_items(
1595 p_revised_item IN inv_ebi_revised_item_obj
1596 ,p_from_item_id IN NUMBER
1597 ,p_to_item_id IN NUMBER
1598 ,p_from_sequence_id IN NUMBER
1599 ,p_reference_org_id IN NUMBER
1600 ,p_view_scope IN VARCHAR2 := 'ALL'
1601 ,p_implementation_scope IN VARCHAR2 := 'ALL'
1602 ,p_as_of_date IN DATE
1603 ,x_revised_item OUT NOCOPY inv_ebi_revised_item_obj
1604 ,x_out OUT NOCOPY inv_ebi_eco_output_obj
1605 ) IS
1606 l_unit_assembly VARCHAR2(1);
1607 l_bom_item_type NUMBER;
1608 l_base_item_flag NUMBER;
1609 i NUMBER := 0;
1610
1611 CURSOR c_copied_comps (
1612 p_unit_assembly IN VARCHAR2,
1613 p_itm_type IN NUMBER,
1614 p_base_item_flag IN NUMBER,
1615 p_unit_number IN VARCHAR2
1616 )
1617 IS
1618 SELECT
1619 msi.concatenated_segments component_item_name,
1620 bic.component_item_id,
1621 bic.operation_seq_num
1622 FROM bom_inventory_components bic,
1623 mtl_system_items_kfv msi
1624 WHERE bic.bill_sequence_id = p_from_sequence_id
1625 AND bic.component_item_id = msi.inventory_item_id
1626 AND bic.component_item_id <> p_to_item_id
1627 AND NVL (bic.eco_for_production, 2) = 2
1628 AND msi.organization_id = p_reference_org_id
1629 AND ((p_unit_assembly = 'N'
1630 AND ((UPPER(p_view_scope) = G_VIEW_SCOPE_ALL) -- ALL
1631 OR (UPPER(p_view_scope) = G_VIEW_SCOPE_CURRENT
1632 AND (effectivity_date <= p_as_of_date
1633 AND
1634 ( (disable_date > p_as_of_date
1635 AND disable_date > SYSDATE
1636 )
1637 OR disable_date IS NULL
1638 )
1639 )
1640 )
1641 OR -- CURRENT
1642 (UPPER(p_view_scope ) = G_VIEW_SCOPE_CURR_FUTURE
1643 AND
1644 ( (disable_date > p_as_of_date
1645 AND disable_date > SYSDATE
1646 )
1647 OR disable_date IS NULL
1648 )
1649 )
1650 ) -- CURRENT + FUTURE
1651 )
1652 OR (p_unit_assembly = 'Y'
1653 AND ((UPPER(p_view_scope) = G_VIEW_SCOPE_ALL) -- ALL
1654 OR (UPPER(p_view_scope) = G_VIEW_SCOPE_CURRENT
1655 AND disable_date IS NULL
1656 AND (from_end_item_unit_number <= p_unit_number
1657 AND (to_end_item_unit_number >=
1658 p_unit_number
1659 OR to_end_item_unit_number IS NULL
1660 )
1661 )
1662 )
1663 OR -- CURRENT
1664 (UPPER(p_view_scope) = G_VIEW_SCOPE_CURR_FUTURE
1665 AND disable_date IS NULL
1666 AND (to_end_item_unit_number >= p_unit_number
1667 OR to_end_item_unit_number IS NULL
1668 )
1669 )
1670 ) -- CURRENT + FUTURE
1671 )
1672 )
1673 AND ((p_base_item_flag = -1
1674 AND p_itm_type = 4
1675 AND msi.bom_item_type = 4
1676 )
1677 OR p_base_item_flag <> -1
1678 OR p_itm_type <> 4
1679 )
1680 AND (UPPER(p_implementation_scope) = G_VIEW_SCOPE_ALL OR
1681 (UPPER(p_implementation_scope) = G_IMPLEMENT_SCOPE_IMPLEMENT AND implementation_date IS NOT NULL) OR
1682 (UPPER(p_implementation_scope) = G_IMPLEMENT_SCOPE_UNIMPLEMENT AND implementation_date IS NULL));
1683
1684 CURSOR c_merged_component (
1685 p_new_comp_item IN inv_ebi_rev_comp_obj
1686 ,p_component_item_name IN VARCHAR2
1687 ,p_operation_sequence_number IN NUMBER
1688 ,p_bill_sequence_id IN NUMBER
1689 ) IS
1690 SELECT
1691 DECODE(p_new_comp_item ,NULL ,bic.disable_date ,DECODE(p_new_comp_item.disable_date
1692 ,fnd_api.g_miss_date ,bic.disable_date ,p_new_comp_item.disable_date)) disable_date
1693 ,DECODE(p_new_comp_item ,NULL ,NVL(bic.acd_type,1) ,DECODE(p_new_comp_item.acd_type
1694 ,fnd_api.g_miss_char ,NVL(bic.acd_type,1) ,p_new_comp_item.acd_type)) acd_type
1695 ,DECODE(p_new_comp_item ,NULL ,bic.basis_type ,DECODE(p_new_comp_item.basis_type
1696 ,fnd_api.g_miss_num ,bic.basis_type ,p_new_comp_item.basis_type)) basis_type
1697 ,DECODE(p_new_comp_item ,NULL ,bic.component_quantity ,DECODE(p_new_comp_item.quantity_per_assembly
1698 ,fnd_api.g_miss_num ,bic.component_quantity ,p_new_comp_item.quantity_per_assembly )) quantity_per_assembly
1699 ,DECODE(p_new_comp_item ,NULL ,bic.component_quantity ,DECODE(p_new_comp_item.inverse_quantity
1700 ,fnd_api.g_miss_num ,bic.component_quantity ,p_new_comp_item.inverse_quantity )) inverse_quantity
1701 ,DECODE(p_new_comp_item ,NULL ,bic.include_in_cost_rollup ,DECODE(p_new_comp_item.include_in_cost_rollup
1702 ,fnd_api.g_miss_num ,bic.include_in_cost_rollup ,p_new_comp_item.include_in_cost_rollup)) include_in_cost_rollup
1703 ,DECODE(p_new_comp_item ,NULL ,bic.wip_supply_type ,DECODE(p_new_comp_item.wip_supply_type
1704 ,fnd_api.g_miss_num ,bic.wip_supply_type ,p_new_comp_item.wip_supply_type)) wip_supply_type
1705 ,DECODE(p_new_comp_item ,NULL ,bic.so_basis ,DECODE(p_new_comp_item.so_basis
1706 ,fnd_api.g_miss_num ,bic.so_basis ,p_new_comp_item.so_basis)) so_basis
1707 ,DECODE(p_new_comp_item ,NULL ,bic.optional ,DECODE(p_new_comp_item.optional
1708 ,fnd_api.g_miss_num ,bic.optional ,p_new_comp_item.optional)) optional
1709 ,DECODE(p_new_comp_item ,NULL ,bic.mutually_exclusive_options ,DECODE(p_new_comp_item.mutually_exclusive
1710 ,fnd_api.g_miss_num ,bic.mutually_exclusive_options ,p_new_comp_item.mutually_exclusive)) mutually_exclusive
1711 ,DECODE(p_new_comp_item ,NULL ,bic.check_atp ,DECODE(p_new_comp_item.check_atp
1712 ,fnd_api.g_miss_num ,bic.check_atp ,p_new_comp_item.check_atp)) check_atp
1713 ,DECODE(p_new_comp_item ,NULL ,bic.shipping_allowed ,DECODE(p_new_comp_item.shipping_allowed
1714 ,fnd_api.g_miss_num ,bic.shipping_allowed ,p_new_comp_item.shipping_allowed)) shipping_allowed
1715 ,DECODE(p_new_comp_item ,NULL ,bic.required_to_ship ,DECODE(p_new_comp_item.required_to_ship
1716 ,fnd_api.g_miss_num ,bic.required_to_ship ,p_new_comp_item.required_to_ship)) required_to_ship
1717 ,DECODE(p_new_comp_item ,NULL ,bic.required_for_revenue ,DECODE(p_new_comp_item.required_for_revenue
1718 ,fnd_api.g_miss_num ,bic.required_for_revenue ,p_new_comp_item.required_for_revenue)) required_for_revenue
1719 ,DECODE(p_new_comp_item ,NULL ,bic.include_on_ship_docs ,DECODE(p_new_comp_item.include_on_ship_docs
1720 ,fnd_api.g_miss_num ,bic.include_on_ship_docs ,p_new_comp_item.include_on_ship_docs)) include_on_ship_docs
1721 ,DECODE(p_new_comp_item ,NULL ,bic.quantity_related ,DECODE(p_new_comp_item.quantity_related
1722 ,fnd_api.g_miss_num ,bic.quantity_related ,p_new_comp_item.quantity_related)) quantity_related
1723 ,DECODE(p_new_comp_item ,NULL ,bic.supply_subinventory ,DECODE(p_new_comp_item.supply_subinventory
1724 ,fnd_api.g_miss_char ,bic.supply_subinventory ,p_new_comp_item.supply_subinventory)) supply_subinventory
1725 ,DECODE(p_new_comp_item ,NULL ,bic.attribute_category ,DECODE(p_new_comp_item.attribute_category
1726 ,fnd_api.g_miss_char ,bic.attribute_category ,p_new_comp_item.attribute_category)) attribute_category
1727 ,DECODE(p_new_comp_item ,NULL ,bic.attribute1 ,DECODE(p_new_comp_item.attribute1
1728 ,fnd_api.g_miss_char ,bic.attribute1 ,p_new_comp_item.attribute1)) attribute1
1729 ,DECODE(p_new_comp_item ,NULL ,bic.attribute2 ,DECODE(p_new_comp_item.attribute2
1730 ,fnd_api.g_miss_char ,bic.attribute2 ,p_new_comp_item.attribute2)) attribute2
1731 ,DECODE(p_new_comp_item ,NULL ,bic.attribute3 ,DECODE(p_new_comp_item.attribute3
1732 ,fnd_api.g_miss_char ,bic.attribute3 ,p_new_comp_item.attribute3)) attribute3
1733 ,DECODE(p_new_comp_item ,NULL ,bic.attribute4 ,DECODE(p_new_comp_item.attribute4
1734 ,fnd_api.g_miss_char ,bic.attribute4 ,p_new_comp_item.attribute4)) attribute4
1735 ,DECODE(p_new_comp_item ,NULL ,bic.attribute5 ,DECODE(p_new_comp_item.attribute5
1736 ,fnd_api.g_miss_char ,bic.attribute5 ,p_new_comp_item.attribute5)) attribute5
1737 ,DECODE(p_new_comp_item ,NULL ,bic.attribute6 ,DECODE(p_new_comp_item.attribute6
1738 ,fnd_api.g_miss_char ,bic.attribute6 ,p_new_comp_item.attribute6)) attribute6
1739 ,DECODE(p_new_comp_item ,NULL ,bic.attribute7 ,DECODE(p_new_comp_item.attribute7
1740 ,fnd_api.g_miss_char ,bic.attribute7 ,p_new_comp_item.attribute7)) attribute7
1741 ,DECODE(p_new_comp_item ,NULL ,bic.attribute8 ,DECODE(p_new_comp_item.attribute8
1742 ,fnd_api.g_miss_char ,bic.attribute8 ,p_new_comp_item.attribute8)) attribute8
1743 ,DECODE(p_new_comp_item ,NULL ,bic.attribute9 ,DECODE(p_new_comp_item.attribute9
1744 ,fnd_api.g_miss_char ,bic.attribute9 ,p_new_comp_item.attribute9)) attribute9
1745 ,DECODE(p_new_comp_item ,NULL ,bic.attribute10 ,DECODE(p_new_comp_item.attribute10
1746 ,fnd_api.g_miss_char ,bic.attribute10 ,p_new_comp_item.attribute10)) attribute10
1747 ,DECODE(p_new_comp_item ,NULL ,bic.attribute11 ,DECODE(p_new_comp_item.attribute11
1748 ,fnd_api.g_miss_char ,bic.attribute11 ,p_new_comp_item.attribute11)) attribute11
1749 ,DECODE(p_new_comp_item ,NULL ,bic.attribute12 ,DECODE(p_new_comp_item.attribute12
1750 ,fnd_api.g_miss_char ,bic.attribute12 ,p_new_comp_item.attribute12)) attribute12
1751 ,DECODE(p_new_comp_item ,NULL ,bic.attribute13 ,DECODE(p_new_comp_item.attribute13
1752 ,fnd_api.g_miss_char ,bic.attribute13 ,p_new_comp_item.attribute13)) attribute13
1753 ,DECODE(p_new_comp_item ,NULL ,bic.attribute14 ,DECODE(p_new_comp_item.attribute14
1754 ,fnd_api.g_miss_char ,bic.attribute14 ,p_new_comp_item.attribute14)) attribute14
1755 ,DECODE(p_new_comp_item ,NULL ,bic.attribute15 ,DECODE(p_new_comp_item.attribute15
1756 ,fnd_api.g_miss_char ,bic.attribute15 ,p_new_comp_item.attribute15)) attribute15
1757 ,DECODE(p_new_comp_item ,NULL ,bic.from_end_item_unit_number ,DECODE(p_new_comp_item.from_end_item_unit_number
1758 ,fnd_api.g_miss_char ,bic.from_end_item_unit_number ,p_new_comp_item.from_end_item_unit_number)) from_end_item_unit_number
1759 ,DECODE(p_new_comp_item ,NULL ,bic.to_end_item_unit_number ,DECODE(p_new_comp_item.to_end_item_unit_number
1760 ,fnd_api.g_miss_char ,bic.to_end_item_unit_number ,p_new_comp_item.to_end_item_unit_number)) to_end_item_unit_number
1761 ,DECODE(p_new_comp_item ,NULL ,bic.enforce_int_requirements ,DECODE(p_new_comp_item.enforce_int_requirements
1762 ,fnd_api.g_miss_char ,bic.enforce_int_requirements ,p_new_comp_item.enforce_int_requirements)) enforce_int_requirements
1763 ,DECODE(p_new_comp_item ,NULL ,bic.auto_request_material ,DECODE(p_new_comp_item.auto_request_material
1764 ,fnd_api.g_miss_char ,bic.auto_request_material ,p_new_comp_item.auto_request_material)) auto_request_material
1765 ,DECODE(p_new_comp_item ,NULL ,bic.suggested_vendor_name ,DECODE(p_new_comp_item.suggested_vendor_name
1766 ,fnd_api.g_miss_char ,bic.suggested_vendor_name ,p_new_comp_item.suggested_vendor_name)) suggested_vendor_name
1767 ,DECODE(p_new_comp_item ,NULL ,bic.unit_price ,DECODE(p_new_comp_item.unit_price
1768 ,fnd_api.g_miss_num ,bic.unit_price ,p_new_comp_item.unit_price)) unit_price
1769 ,DECODE(p_new_comp_item ,NULL ,bic.original_system_reference ,DECODE(p_new_comp_item.original_system_reference
1770 ,fnd_api.g_miss_num ,bic.original_system_reference ,p_new_comp_item.original_system_reference)) original_system_reference
1771 ,DECODE(p_new_comp_item ,NULL ,SYSDATE ,DECODE(p_new_comp_item.start_effective_date
1772 ,fnd_api.g_miss_date ,bic.effectivity_date ,p_new_comp_item.start_effective_date)) start_effective_date
1773 ,DECODE(p_new_comp_item ,NULL ,bic.item_num ,DECODE(p_new_comp_item.item_sequence_number
1774 ,fnd_api.g_miss_num ,bic.item_num ,p_new_comp_item.item_sequence_number)) item_sequence_number
1775 ,DECODE(p_new_comp_item ,NULL ,bic.planning_factor ,DECODE(p_new_comp_item.planning_percent
1776 ,fnd_api.g_miss_num ,bic.planning_factor ,p_new_comp_item.planning_percent)) planning_percent
1777 ,DECODE(p_new_comp_item ,NULL ,bic.component_yield_factor ,DECODE(p_new_comp_item.projected_yield
1778 ,fnd_api.g_miss_num ,bic.component_yield_factor ,p_new_comp_item.projected_yield)) projected_yield
1779 ,DECODE(p_new_comp_item ,NULL ,bic.high_quantity ,DECODE(p_new_comp_item.maximum_allowed_quantity
1780 ,fnd_api.g_miss_num ,bic.high_quantity ,p_new_comp_item.maximum_allowed_quantity)) maximum_allowed_quantity
1781 ,DECODE(p_new_comp_item ,NULL ,bic.low_quantity ,DECODE(p_new_comp_item.minimum_allowed_quantity
1782 ,fnd_api.g_miss_num ,bic.low_quantity ,p_new_comp_item.minimum_allowed_quantity)) minimum_allowed_quantity
1783 ,DECODE(p_new_comp_item ,NULL ,bic.component_remarks ,DECODE(p_new_comp_item.comments
1784 ,fnd_api.g_miss_char ,component_remarks ,p_new_comp_item.comments)) comments
1785 ,DECODE(p_new_comp_item ,NULL ,NULL ,p_new_comp_item.new_effectivity_date) new_effectivity_date
1786 ,DECODE(p_new_comp_item ,NULL ,NULL ,p_new_comp_item.old_effectivity_date) old_effectivity_date
1787 ,DECODE(p_new_comp_item ,NULL ,1 ,p_new_comp_item.old_operation_sequence_number) old_operation_sequence_number
1788 ,DECODE(p_new_comp_item ,NULL ,1 ,p_new_comp_item.new_operation_sequence_number) new_operation_sequence_number
1789 ,DECODE(p_new_comp_item ,NULL ,NULL ,p_new_comp_item.location_name) location_name
1790 ,DECODE(p_new_comp_item ,NULL ,NULL ,p_new_comp_item.cancel_comments) cancel_comments
1791 ,DECODE(p_new_comp_item ,NULL ,NULL ,p_new_comp_item.old_from_end_item_unit_number) old_from_end_item_unit_number
1792 ,DECODE(p_new_comp_item ,NULL ,NULL ,p_new_comp_item.new_from_end_item_unit_number) new_from_end_item_unit_number
1793 ,DECODE(p_new_comp_item ,NULL ,NULL ,p_new_comp_item.new_routing_revision) new_routing_revision
1794 ,DECODE(p_new_comp_item ,NULL ,NULL ,p_new_comp_item.return_status) return_status
1795 FROM
1796 bom_inventory_components bic,
1797 mtl_system_items_kfv it
1798 WHERE
1799 bic.component_item_id = it.inventory_item_id AND
1800 it.organization_id = p_reference_org_id AND
1801 it.concatenated_segments = p_component_item_name AND
1802 bic.operation_seq_num = nvl(p_operation_sequence_number,1) AND
1803 bic.bill_sequence_id = p_bill_sequence_id;
1804
1805 l_merged_comp c_merged_component%ROWTYPE;
1806 l_copied_comp c_copied_comps%ROWTYPE;
1807 l_revised_item inv_ebi_revised_item_obj;
1808 l_found BOOLEAN;
1809 l_revised_comp_tbl inv_ebi_rev_comp_tbl;
1810 l_revised_comp_count NUMBER := 1;
1811 l_output_status inv_ebi_output_status;
1812 BEGIN
1813 l_output_status := inv_ebi_output_status(fnd_api.g_ret_sts_success,NULL,NULL,NULL);
1814 x_out := inv_ebi_eco_output_obj(NULL,NULL,NULL,NULL,l_output_status,NULL,NULL);
1815 INV_EBI_UTIL.debug_line('STEP 10: START INSIDE INV_EBI_CHANGE_ORDER_HELPER.prepare_component_items');
1816 IF (bom_eamutil.enabled = 'Y'
1817 AND bom_eamutil.serial_effective_item (item_id => p_from_item_id,
1818 org_id => p_reference_org_id
1819 ) = 'Y'
1820 )
1821 OR (pjm_unit_eff.enabled = 'Y'
1822 AND pjm_unit_eff.unit_effective_item
1823 (x_item_id => p_from_item_id,
1824 x_organization_id => p_reference_org_id
1825 ) = 'Y'
1826 )
1827 THEN
1828 l_unit_assembly := 'Y';
1829 ELSE
1830 l_unit_assembly := 'N';
1831 END IF;
1832
1833
1834 SELECT
1835 bom_item_type
1836 ,DECODE (base_item_id, NULL, -1, 0) base_item_id
1837 INTO
1838 l_bom_item_type
1839 ,l_base_item_flag
1840 FROM
1841 mtl_system_items_b
1842 WHERE
1843 inventory_item_id = p_from_item_id AND
1844 organization_id = p_reference_org_id;
1845
1846 l_revised_item := p_revised_item;
1847 IF p_revised_item.component_item_tbl IS NOT NULL THEN
1848 l_revised_comp_tbl := inv_ebi_rev_comp_tbl();
1849 FOR i IN 1..p_revised_item.component_item_tbl.COUNT LOOP
1850 IF p_revised_item.component_item_tbl(i).transaction_type <> ENG_GLOBALS.g_opr_delete THEN
1851 l_revised_comp_tbl.EXTEND(1);
1852 l_revised_comp_tbl(l_revised_comp_count) := p_revised_item.component_item_tbl(i);
1853 l_revised_comp_count := l_revised_comp_count + 1;
1854 END IF;
1855 END LOOP;
1856 l_revised_item.component_item_tbl := l_revised_comp_tbl;
1857 END IF;
1858
1859
1860 OPEN c_copied_comps(p_itm_type => l_bom_item_type
1861 ,p_base_item_flag => l_base_item_flag
1862 ,p_unit_number => NULL
1863 ,p_unit_assembly => l_unit_assembly) ;
1864 LOOP
1865 FETCH c_copied_comps INTO l_copied_comp;
1866 EXIT WHEN c_copied_comps%NOTFOUND;
1867 l_Found := FALSE;
1868 IF p_revised_item.component_item_tbl IS NOT NULL THEN
1869 FOR i IN 1..p_revised_item.component_item_tbl.COUNT LOOP
1870 INV_EBI_UTIL.debug_line('STEP 20: COMPONENT ITEM NAME: '|| p_revised_item.component_item_tbl(i).component_item_name);
1871 IF l_copied_comp.component_item_name = p_revised_item.component_item_tbl(i).component_item_name
1872 AND l_copied_comp.operation_seq_num = p_revised_item.component_item_tbl(i).operation_sequence_number THEN
1873 l_Found := TRUE;
1874 END IF;
1875 END LOOP;
1876 END IF;
1877
1878 IF NOT l_Found THEN
1879 OPEN c_merged_component(p_new_comp_item => NULL
1880 ,p_component_item_name => l_copied_comp.component_item_name
1881 ,p_operation_sequence_number => l_copied_comp.operation_seq_num
1882 ,p_bill_sequence_id => p_from_sequence_id);
1883 FETCH c_merged_component INTO l_Merged_Comp;
1884 IF l_revised_item.component_item_tbl IS NULL THEN
1885 l_revised_item.component_item_tbl := inv_ebi_rev_comp_tbl();
1886 END IF;
1887 l_revised_item.component_item_tbl.EXTEND(1);
1888
1889 l_revised_item.component_item_tbl(l_revised_item.component_item_tbl.COUNT) := inv_ebi_rev_comp_obj(
1890 p_revised_item.start_effective_date
1891 ,p_revised_item.start_effective_date
1892 ,l_merged_comp.disable_date
1893 ,l_copied_comp.operation_seq_num
1894 ,l_copied_comp.component_item_name
1895 ,NULL
1896 ,NULL
1897 ,l_merged_comp.acd_type
1898 ,l_merged_comp.old_effectivity_date
1899 ,l_merged_comp.old_operation_sequence_number
1900 ,l_merged_comp.new_operation_sequence_number
1901 ,NULL
1902 ,l_merged_comp.basis_type
1903 ,l_merged_comp.quantity_per_assembly
1904 ,l_merged_comp.inverse_quantity
1905 ,l_merged_comp.planning_percent
1906 ,l_merged_comp.projected_yield
1907 ,l_merged_comp.include_in_cost_rollup
1908 ,l_merged_comp.wip_supply_type
1909 ,l_merged_comp.so_basis
1910 ,l_merged_comp.optional
1911 ,l_merged_comp.mutually_exclusive
1912 ,l_merged_comp.check_atp
1913 ,l_merged_comp.shipping_allowed
1914 ,l_merged_comp.required_to_ship
1915 ,l_merged_comp.required_for_revenue
1916 ,l_merged_comp.include_on_ship_docs
1917 ,l_merged_comp.quantity_related
1918 ,l_merged_comp.supply_subinventory
1919 ,l_merged_comp.location_name
1920 ,l_merged_comp.minimum_allowed_quantity
1921 ,l_merged_comp.maximum_allowed_quantity
1922 ,l_merged_comp.comments
1923 ,l_merged_comp.cancel_comments
1924 ,l_merged_comp.attribute_category
1925 ,l_merged_comp.attribute1
1926 ,l_merged_comp.attribute2
1927 ,l_merged_comp.attribute3
1928 ,l_merged_comp.attribute4
1929 ,l_merged_comp.attribute5
1930 ,l_merged_comp.attribute6
1931 ,l_merged_comp.attribute7
1932 ,l_merged_comp.attribute8
1933 ,l_merged_comp.attribute9
1934 ,l_merged_comp.attribute10
1935 ,l_merged_comp.attribute11
1936 ,l_merged_comp.attribute12
1937 ,l_merged_comp.attribute13
1938 ,l_merged_comp.attribute14
1939 ,l_merged_comp.attribute15
1940 ,l_merged_comp.from_end_item_unit_number
1941 ,l_merged_comp.old_from_end_item_unit_number
1942 ,l_merged_comp.new_from_end_item_unit_number
1943 ,l_merged_comp.to_end_item_unit_number
1944 ,l_merged_comp.new_routing_revision
1945 ,l_merged_comp.enforce_int_requirements
1946 ,l_merged_comp.auto_request_material
1947 ,l_merged_comp.suggested_vendor_name
1948 ,l_merged_comp.unit_price
1949 ,l_merged_comp.original_system_reference
1950 ,l_merged_comp.return_status
1951 ,ENG_GLOBALS.g_opr_create
1952 ,NULL
1953 ,NULL
1954 ,NULL
1955 ,NULL
1956 ,NULL
1957 ,NULL);
1958
1959 CLOSE c_merged_component;
1960 END IF;
1961 END LOOP;
1962 CLOSE c_copied_comps;
1963
1964 IF l_revised_item.component_item_tbl IS NOT NULL THEN
1965 FOR i IN 1..l_revised_item.component_item_tbl.COUNT LOOP
1966 IF l_revised_item.component_item_tbl(i).transaction_type = ENG_GLOBALS.g_opr_update THEN
1967 OPEN c_merged_component(p_new_comp_item => l_revised_item.component_item_tbl(i)
1968 ,p_component_item_name => l_revised_item.component_item_tbl(i).component_item_name
1969 ,p_operation_sequence_number => l_revised_item.component_item_tbl(i).operation_sequence_number
1970 ,p_bill_sequence_id => p_from_sequence_id);
1971 FETCH c_merged_component INTO l_Merged_Comp;
1972 l_revised_item.component_item_tbl(i) := inv_ebi_rev_comp_obj(
1973 l_merged_comp.start_effective_date
1974 ,l_merged_comp.new_effectivity_date
1975 ,l_merged_comp.disable_date
1976 ,l_revised_item.component_item_tbl(i).operation_sequence_number
1977 ,l_revised_item.component_item_tbl(i).component_item_name
1978 ,l_revised_item.component_item_tbl(i).substitute_component_tbl
1979 ,l_revised_item.component_item_tbl(i).reference_designator_tbl
1980 ,l_merged_comp.acd_type
1981 ,l_merged_comp.old_effectivity_date
1982 ,l_merged_comp.old_operation_sequence_number
1983 ,l_merged_comp.new_operation_sequence_number
1984 ,l_merged_comp.item_sequence_number
1985 ,l_merged_comp.basis_type
1986 ,l_merged_comp.quantity_per_assembly
1987 ,l_merged_comp.inverse_quantity
1988 ,l_merged_comp.planning_percent
1989 ,l_merged_comp.projected_yield
1990 ,l_merged_comp.include_in_cost_rollup
1991 ,l_merged_comp.wip_supply_type
1992 ,l_merged_comp.so_basis
1993 ,l_merged_comp.optional
1994 ,l_merged_comp.mutually_exclusive
1995 ,l_merged_comp.check_atp
1996 ,l_merged_comp.shipping_allowed
1997 ,l_merged_comp.required_to_ship
1998 ,l_merged_comp.required_for_revenue
1999 ,l_merged_comp.include_on_ship_docs
2000 ,l_merged_comp.quantity_related
2001 ,l_merged_comp.supply_subinventory
2002 ,l_merged_comp.location_name
2003 ,l_merged_comp.minimum_allowed_quantity
2004 ,l_merged_comp.maximum_allowed_quantity
2005 ,l_merged_comp.comments
2006 ,l_merged_comp.cancel_comments
2007 ,l_merged_comp.attribute_category
2008 ,l_merged_comp.attribute1
2009 ,l_merged_comp.attribute2
2010 ,l_merged_comp.attribute3
2011 ,l_merged_comp.attribute4
2012 ,l_merged_comp.attribute5
2013 ,l_merged_comp.attribute6
2014 ,l_merged_comp.attribute7
2015 ,l_merged_comp.attribute8
2016 ,l_merged_comp.attribute9
2017 ,l_merged_comp.attribute10
2018 ,l_merged_comp.attribute11
2019 ,l_merged_comp.attribute12
2020 ,l_merged_comp.attribute13
2021 ,l_merged_comp.attribute14
2022 ,l_merged_comp.attribute15
2023 ,l_merged_comp.from_end_item_unit_number
2024 ,l_merged_comp.old_from_end_item_unit_number
2025 ,l_merged_comp.new_from_end_item_unit_number
2026 ,l_merged_comp.to_end_item_unit_number
2027 ,l_merged_comp.new_routing_revision
2028 ,l_merged_comp.enforce_int_requirements
2029 ,l_merged_comp.auto_request_material
2030 ,l_merged_comp.suggested_vendor_name
2031 ,l_merged_comp.unit_price
2032 ,l_merged_comp.original_system_reference
2033 ,l_merged_comp.return_status
2034 ,ENG_GLOBALS.g_opr_create
2035 ,NULL
2036 ,l_revised_item.component_item_tbl(i).component_revision_uda
2037 ,NULL
2038 ,NULL
2039 ,NULL
2040 ,NULL);
2041 CLOSE c_merged_component;
2042 END IF;
2043 END LOOP;
2044 END IF;
2045 INV_EBI_UTIL.debug_line('STEP 30: END INSIDE INV_EBI_CHANGE_ORDER_HELPER.prepare_component_items'|| ' OUTPUT STATUS: '|| x_out.output_status.return_status);
2046 x_revised_item := l_revised_item;
2047
2048
2049 EXCEPTION
2050 WHEN FND_API.g_exc_unexpected_error THEN
2051 IF c_copied_comps%ISOPEN THEN
2052 CLOSE c_copied_comps;
2053 END IF;
2054 IF c_merged_component%ISOPEN THEN
2055 CLOSE c_merged_component;
2056 END IF;
2057 x_out.output_status.return_status := FND_API.g_ret_sts_unexp_error;
2058 IF(x_out.output_status.msg_data IS NULL) THEN
2059 fnd_msg_pub.count_and_get(
2060 p_encoded => FND_API.g_false
2061 ,p_count => x_out.output_status.msg_count
2062 ,p_data => x_out.output_status.msg_data
2063 );
2064 END IF;
2065 WHEN OTHERS THEN
2066 IF c_copied_comps%ISOPEN THEN
2067 CLOSE c_copied_comps;
2068 END IF;
2069 IF c_merged_component%ISOPEN THEN
2070 CLOSE c_merged_component;
2071 END IF;
2072 x_out.output_status.return_status := FND_API.g_ret_sts_unexp_error;
2073 IF (x_out.output_status.msg_data IS NOT NULL) THEN
2074 x_out.output_status.msg_data := x_out.output_status.msg_data||' ->INV_EBI_CHANGE_ORDER_HELPER.prepare_component_items ';
2075 ELSE
2076 x_out.output_status.msg_data := SQLERRM||'INV_EBI_CHANGE_ORDER_HELPER.prepare_component_items ';
2077 END IF;
2078 END prepare_component_items;
2079
2080 /************************************************************************************
2081 -- API name : Is_BOM_Exists
2082 -- Type : Private
2083 -- Function :
2084 ************************************************************************************/
2085
2086 FUNCTION Is_BOM_Exists(
2087 p_Item_Number IN VARCHAR2
2088 ,p_Organization_Code IN VARCHAR2
2089 ,p_alternate_bom_code IN VARCHAR2
2090 ) RETURN VARCHAR2 IS
2091 l_Count NUMBER := 0;
2092 BEGIN
2093 INV_EBI_UTIL.debug_line('STEP 10: START INSIDE INV_EBI_CHANGE_ORDER_HELPER.Is_BOM_Exists');
2094 INV_EBI_UTIL.debug_line('STEP 20: ITEM NUMBER: '|| p_Item_Number || ' ORG CODE: '|| p_Organization_Code);
2095 SELECT
2096 COUNT(1)
2097 INTO
2098 l_Count
2099 FROM
2100 bom_bill_of_materials bb,
2101 mtl_system_items_kfv it,
2102 mtl_parameters mp
2103 WHERE
2104 bb.assembly_item_id = it.inventory_item_id AND
2105 it.organization_id = bb.organization_id AND
2106 bb.organization_id = mp.organization_id AND
2107 mp.organization_code = p_Organization_Code AND
2108 it.concatenated_segments = p_Item_Number AND
2109 ((p_alternate_bom_code IS NULL AND bb.alternate_bom_designator IS NULL) OR
2110 (bb.alternate_bom_designator = p_alternate_bom_code));
2111
2112 IF l_Count = 1 THEN
2113 INV_EBI_UTIL.debug_line('STEP 30: RETURN STATUS '|| FND_API.g_true);
2114 RETURN FND_API.g_true;
2115 END IF;
2116 INV_EBI_UTIL.debug_line('STEP 40: RETURN STATUS ' || FND_API.g_false);
2117 INV_EBI_UTIL.debug_line('STEP 50: END INSIDE INV_EBI_CHANGE_ORDER_HELPER.Is_BOM_Exists');
2118 RETURN FND_API.g_false;
2119
2120 EXCEPTION
2121 WHEN OTHERS THEN
2122 RETURN FND_API.g_false;
2123 END Is_BOM_Exists;
2124
2125 /************************************************************************************
2126 -- API name : Is_BOM_Already_Commoned
2127 -- Type : Private
2128 -- Function : Bug 13340150
2129 ************************************************************************************/
2130
2131 FUNCTION Is_BOM_Already_Commoned(
2132 p_Item_Number IN VARCHAR2
2133 ,p_Organization_Code IN VARCHAR2
2134 ,p_alternate_bom_code IN VARCHAR2
2135 ) RETURN VARCHAR2 IS
2136
2137 l_bill_sequence_id NUMBER;
2138 l_src_bill_sequence_id NUMBER;
2139
2140 BEGIN
2141 INV_EBI_UTIL.debug_line('STEP 10: START INSIDE INV_EBI_CHANGE_ORDER_HELPER.Is_BOM_Already_Commoned');
2142 INV_EBI_UTIL.debug_line('STEP 20: ITEM NUMBER: '|| p_Item_Number || ' ORG CODE: '|| p_Organization_Code);
2143
2144 SELECT bill_sequence_id, source_bill_sequence_id INTO l_bill_sequence_id, l_src_bill_sequence_id
2145 FROM BOM_BILL_OF_MATERIALS bb,
2146 mtl_system_items_kfv it,
2147 mtl_parameters mp
2148 WHERE bb.assembly_item_id = it.inventory_item_id
2149 AND it.organization_id = bb.organization_id
2150 AND bb.organization_id = mp.organization_id
2151 AND mp.organization_code = p_Organization_Code
2152 AND it.concatenated_segments = p_Item_Number
2153 AND NVL(bb.alternate_bom_designator, 'NONE') = DECODE(p_alternate_bom_code,FND_API.G_MISS_CHAR,'NONE',NULL,'NONE',p_alternate_bom_code) ;
2154
2155 IF( l_bill_sequence_id <> l_src_bill_sequence_id) THEN
2156
2157 INV_EBI_UTIL.debug_line('STEP 30: RETURN STATUS ' || FND_API.g_true);
2158 RETURN fnd_api.g_true;
2159
2160 END IF;
2161
2162 INV_EBI_UTIL.debug_line('STEP 40: RETURN STATUS ' || FND_API.g_false);
2163 INV_EBI_UTIL.debug_line('STEP 50: END INSIDE INV_EBI_CHANGE_ORDER_HELPER.Is_BOM_ALready_Commoned');
2164 RETURN FND_API.g_false;
2165
2166 EXCEPTION
2167 WHEN OTHERS THEN
2168 RETURN FND_API.g_false;
2169 END Is_BOM_ALready_Commoned;
2170
2171
2172 /************************************************************************************
2173 -- API name : is_new_revision_exists
2174 -- Type : Private
2175 -- Function : This api is used to find if a change already exists for the
2176 -- revsied items revision.
2177 -- Bug 7119898
2178 ************************************************************************************/
2179
2180 FUNCTION is_new_revision_exists(
2181 p_item_number IN VARCHAR2
2182 ,p_revision IN VARCHAR2
2183 ,p_org_code IN VARCHAR2
2184 ) RETURN VARCHAR2 IS
2185
2186 l_Count NUMBER := 0;
2187
2188 BEGIN
2189 INV_EBI_UTIL.debug_line('STEP 10: START INSIDE INV_EBI_CHANGE_ORDER_HELPER.is_new_revision_exists');
2190 INV_EBI_UTIL.debug_line('STEP 20: ITEM NUMBER: '|| p_Item_Number || ' REVISION: '|| p_revision || ' ORG CODE: '|| p_org_code);
2191 SELECT COUNT(1) INTO l_Count
2192 FROM
2193 eng_revised_items eri,
2194 mtl_system_items_kfv msi,
2195 mtl_parameters mp
2196 WHERE
2197 eri.revised_item_id = msi.inventory_item_id AND
2198 msi.organization_id = eri.organization_id AND
2199 eri.organization_id = mp.organization_id AND
2200 mp.organization_code = p_org_code AND
2201 msi.concatenated_segments = p_item_number AND
2202 eri.new_item_revision = p_revision ;
2203
2204 IF l_Count >=1 THEN
2205 INV_EBI_UTIL.debug_line('STEP 30: RETURN STATUS '|| FND_API.g_true);
2206 RETURN FND_API.g_true;
2207 END IF;
2208 INV_EBI_UTIL.debug_line('STEP 40: RETURN STATUS '|| FND_API.g_false);
2209 INV_EBI_UTIL.debug_line('STEP 50: END INSIDE INV_EBI_CHANGE_ORDER_HELPER.is_new_revision_exists');
2210 RETURN FND_API.g_false;
2211
2212 EXCEPTION
2213 WHEN OTHERS THEN
2214 RETURN FND_API.g_false;
2215 END is_new_revision_exists;
2216
2217 /*******************************************************************************
2218 API name : is_child_org
2219 Type : Private
2220 Purpose : Checks if the organization is master org or child org.
2221 --Bug 7197943
2222 ********************************************************************************/
2223 FUNCTION is_child_org (
2224 p_organization_id IN NUMBER
2225 ) RETURN VARCHAR2 IS
2226
2227 l_master_org NUMBER;
2228
2229 BEGIN
2230
2231 SELECT master_organization_id INTO l_master_org
2232 FROM mtl_parameters
2233 WHERE organization_id= p_organization_id;
2234
2235 IF(l_master_org <> p_organization_id) THEN
2236 RETURN FND_API.g_true;
2237 ELSE
2238 RETURN FND_API.g_false;
2239 END IF;
2240
2241 EXCEPTION
2242 WHEN OTHERS THEN
2243 RETURN NULL;
2244 END is_child_org;
2245
2246 /************************************************************************************
2247 -- API name : get_bill_sequence_id
2248 -- Type : Private
2249 -- Function : This function returns the bill sequence id corresponding to
2250 -- the given assembly item id,org id and alternate bom code.
2251 ************************************************************************************/
2252
2253 FUNCTION get_bill_sequence_id(
2254 p_assembly_item_id IN NUMBER ,
2255 p_organization_id IN NUMBER,
2256 p_alternate_bom_code IN VARCHAR2
2257 ) RETURN NUMBER IS
2258
2259 l_bill_sequence_id NUMBER;
2260
2261 BEGIN
2262
2263 SELECT bill_sequence_id INTO l_bill_sequence_id
2264 FROM
2265 bom_bill_of_materials
2266 WHERE
2267 assembly_item_id = p_assembly_item_id AND
2268 organization_id = p_organization_id AND
2269 NVL(alternate_bom_designator, 'NONE') =
2270 decode(p_alternate_bom_code,FND_API.G_MISS_CHAR,'NONE',NULL,'NONE',p_alternate_bom_code);
2271
2272 RETURN l_bill_sequence_id;
2273
2274 EXCEPTION
2275 WHEN OTHERS THEN
2276 RETURN NULL;
2277 END get_bill_sequence_id;
2278
2279 /************************************************************************************
2280 -- API name : process_replicate_bom
2281 -- Type : Public
2282 -- Function :
2283 -- The following processing is done in this API
2284 -- 1. Check if the item has a BOM defined in the currentcontext organization
2285 -- 2. Also check that the reference org has a BOM defined.
2286 -- 3. Modify the component tbl as per the following logic
2287 * Remove the components which have transaction type as 'DELETE'
2288 * Find the components which are present only in the reference organization
2289 and add them to the list with transaction type as 'CREATE'
2290 * Modify the transaction type of the components which have 'UPDATE' as the
2291 transaction type to 'CREATE'
2292 -- 4. For each component item the above processing will be done for substitute
2293 components and reference designators
2294 ************************************************************************************/
2295 PROCEDURE process_replicate_bom(
2296 p_organization_code IN VARCHAR2
2297 ,p_revised_item_obj IN inv_ebi_revised_item_obj
2298 ,p_name_value_tbl IN inv_ebi_name_value_tbl
2299 ,x_revised_item_obj OUT NOCOPY inv_ebi_revised_item_obj
2300 ,x_out OUT NOCOPY inv_ebi_eco_output_obj
2301 ) IS
2302 l_revised_item inv_ebi_revised_item_obj;
2303 l_revised_item1 inv_ebi_revised_item_obj;
2304 l_context_org_bom_exists VARCHAR2(1) := FND_API.g_false;
2305 l_ref_org_bom_exists VARCHAR2(1) := FND_API.g_false;
2306 l_context_org_code mtl_parameters.organization_code%TYPE;
2307 l_pk_col_name_val_pairs INV_EBI_ITEM_HELPER.inv_ebi_name_value_pair_tbl;
2308 l_component_item inv_ebi_rev_comp_obj;
2309 l_component_item1 inv_ebi_rev_comp_obj;
2310 l_eco_obj inv_ebi_eco_obj;
2311 l_from_item_id NUMBER;
2312 l_to_item_id NUMBER;
2313 l_from_sequence_id NUMBER;
2314 l_from_org_id NUMBER;
2315 l_to_org_id NUMBER;
2316 l_view_scope VARCHAR2(30) ;
2317 l_impl_scope VARCHAR2(30) ;
2318 l_config_view_scope VARCHAR2(30) := 'ALL';
2319 l_config_impl_scope VARCHAR2(30) := 'ALL';
2320 l_return_status VARCHAR2(10);
2321 l_msg_Count NUMBER;
2322 l_reference_item_num mtl_system_items_kfv.concatenated_segments%TYPE;
2323 l_reference_org_code mtl_parameters.organization_code%TYPE;
2324 l_as_of_date DATE;
2325 l_alternate_bom_code bom_bill_of_materials.alternate_bom_designator%TYPE;
2326 l_output_status inv_ebi_output_status;
2327
2328 BEGIN
2329 SAVEPOINT process_replicate_bom_save_pnt;
2330 l_output_status := inv_ebi_output_status(fnd_api.g_ret_sts_success,NULL,NULL,NULL);
2331 x_out := inv_ebi_eco_output_obj(NULL,NULL,NULL,NULL,l_output_status,NULL,NULL);
2332 INV_EBI_UTIL.debug_line('STEP 10: START INSIDE INV_EBI_CHANGE_ORDER_HELPER.process_replicate_bom');
2333 INV_EBI_UTIL.debug_line('STEP 20: ORG_CODE: '|| p_organization_code || ' REVISED ITEM NAME: '|| p_revised_item_obj.revised_item_name);
2334 l_context_org_code:= p_organization_code;
2335
2336
2337 l_config_view_scope := INV_EBI_UTIL.get_config_param_value (
2338 p_config_tbl => p_name_value_tbl
2339 ,p_config_param_name => 'REPLICATE_BOM_VIEW_SCOPE'
2340 );
2341
2342
2343 l_config_impl_scope := INV_EBI_UTIL.get_config_param_value (
2344 p_config_tbl => p_name_value_tbl
2345 ,p_config_param_name => 'REPLICATE_BOM_IMPLEMENTATION_SCOPE'
2346 );
2347
2348 --IF l_eco_obj.eco_revised_item_type IS NOT NULL THEN
2349 --FOR i IN 1..l_eco_obj.eco_revised_item_type.COUNT LOOP
2350 l_revised_item := p_revised_item_obj;
2351
2352 IF (l_revised_item.orignal_bom_reference IS NOT NULL AND
2353 (l_revised_item.orignal_bom_reference.organization_id IS NOT NULL OR
2354 l_revised_item.orignal_bom_reference.organization_code IS NOT NULL )) THEN
2355
2356 l_from_org_id := l_revised_item.orignal_bom_reference.organization_id;
2357 l_reference_org_code := l_revised_item.orignal_bom_reference.organization_code;
2358 IF l_from_org_id IS NULL OR l_from_org_id = fnd_api.g_miss_num THEN
2359 l_from_org_id := INV_EBI_ITEM_HELPER.get_organization_id( p_organization_code => l_reference_org_code);
2360 ELSIF l_reference_org_code IS NULL OR l_reference_org_code = fnd_api.g_miss_char THEN
2361 SELECT
2362 organization_code
2363 INTO
2364 l_reference_org_code
2365 FROM
2366 mtl_parameters
2367 WHERE
2368 organization_id = l_from_org_id;
2369 END IF;
2370
2371 l_reference_item_num := l_revised_item.revised_item_name;
2372 IF l_revised_item.orignal_bom_reference.item_name IS NOT NULL THEN
2373 l_reference_item_num := l_revised_item.orignal_bom_reference.item_name;
2374 ELSIF l_revised_item.orignal_bom_reference.inventory_item_id IS NOT NULL THEN
2375 l_from_item_id := l_revised_item.orignal_bom_reference.inventory_item_id;
2376 SELECT
2377 concatenated_segments
2378 INTO
2379 l_reference_item_num
2380 FROM
2381 mtl_system_items_kfv
2382 WHERE
2383 inventory_item_id = l_from_item_id AND
2384 organization_id = l_from_org_id;
2385 END IF;
2386
2387 IF l_from_item_id IS NULL THEN
2388 l_from_item_id := INV_EBI_ITEM_HELPER.get_inventory_item_id ( p_organization_id => l_from_org_id
2389 ,p_item_number => l_reference_item_num);
2390 INV_EBI_UTIL.debug_line('STEP 30: FROM ITEM ID: '|| l_from_item_id);
2391 END IF;
2392
2393 l_to_org_id := INV_EBI_ITEM_HELPER.get_organization_id ( p_organization_code => l_context_org_code);
2394 l_to_item_id := INV_EBI_ITEM_HELPER.get_inventory_item_id ( p_organization_id => l_to_org_id
2395 ,p_item_number => l_revised_item.revised_item_name) ;
2396 INV_EBI_UTIL.debug_line('STEP 40: TO ORG ID: '|| l_to_org_id || ' TO ITEM ID: '|| l_to_item_id);
2397 l_context_org_bom_exists := Is_BOM_Exists(
2398 p_item_number => l_revised_item.revised_item_name
2399 ,p_organization_code => l_context_org_code
2400 ,p_alternate_bom_code => l_revised_item.orignal_bom_reference.alternate_bom_code
2401 );
2402
2403 l_ref_org_bom_exists := Is_BOM_Exists(
2404 p_item_number => l_reference_item_num
2405 ,p_organization_code => l_reference_org_code
2406 ,p_alternate_bom_code => l_revised_item.orignal_bom_reference.alternate_bom_code
2407 );
2408 IF (NOT FND_API.To_Boolean(l_context_org_bom_exists)) AND FND_API.To_Boolean(l_ref_org_bom_exists) THEN
2409 SELECT
2410 bill_sequence_id
2411 INTO
2412 l_from_sequence_id
2413 FROM
2414 bom_bill_of_materials
2415 WHERE
2416 assembly_item_id = l_from_item_id AND
2417 organization_id = l_from_org_id AND
2418 ((l_revised_item.alternate_bom_code IS NULL AND alternate_bom_designator IS NULL) OR
2419 (alternate_bom_designator = l_revised_item.alternate_bom_code));
2420 l_view_scope := l_revised_item.orignal_bom_reference.view_scope;
2421 IF l_view_scope IS NULL OR l_view_scope = fnd_api.g_miss_char THEN
2422 l_view_scope := l_config_view_scope;
2423 END IF;
2424
2425 l_impl_scope := l_revised_item.orignal_bom_reference.implementation_scope;
2426 IF l_impl_scope IS NULL OR l_impl_scope = fnd_api.g_miss_char THEN
2427 l_impl_scope := l_config_impl_scope;
2428 END IF;
2429
2430 l_as_of_date := l_revised_item.orignal_bom_reference.as_of_date;
2431 IF l_as_of_date IS NULL OR l_as_of_date = fnd_api.g_miss_date THEN
2432 l_as_of_date := SYSDATE;
2433 END IF;
2434 l_revised_item1 := l_revised_item;
2435 INV_EBI_UTIL.debug_line('STEP 50: BEFORE CALLING INV_EBI_CHANGE_ORDER_HELPER.prepare_component_items ');
2436 prepare_component_items (
2437 p_revised_item => l_revised_item1
2438 ,p_from_item_id => l_from_item_id
2439 ,p_to_item_id => l_to_item_id
2440 ,p_from_sequence_id => l_from_sequence_id
2441 ,p_reference_org_id => l_from_org_id
2442 ,p_view_scope => l_view_scope
2443 ,p_implementation_scope => l_impl_scope
2444 ,p_as_of_date => l_as_of_date
2445 ,x_revised_item => l_revised_item
2446 ,x_out => x_out
2447 );
2448 INV_EBI_UTIL.debug_line('STEP 60: AFTER CALLING INV_EBI_CHANGE_ORDER_HELPER.prepare_component_items STATUS: ' || x_out.output_status.return_status);
2449 IF (x_out.output_status.return_status <> FND_API.g_ret_sts_success) THEN
2450 RAISE FND_API.g_exc_unexpected_error;
2451 END IF;
2452
2453 IF l_revised_item.component_item_tbl IS NOT NULL THEN
2454 FOR j IN 1..l_revised_item.component_item_tbl.COUNT LOOP
2455 INV_EBI_UTIL.debug_line('STEP 70: BEFORE CALLING INV_EBI_CHANGE_ORDER_HELPER.prepare_substitute_components ');
2456 prepare_substitute_components (
2457 p_component_item => l_revised_item.component_item_tbl(j)
2458 ,p_from_sequence_id => l_from_sequence_id
2459 ,p_reference_org_id => l_from_org_id
2460 ,x_component_item => l_component_item
2461 ,x_out => x_out
2462 );
2463 INV_EBI_UTIL.debug_line('STEP 80: AFTER CALLING INV_EBI_CHANGE_ORDER_HELPER.prepare_substitute_components STATUS: '|| x_out.output_status.return_status);
2464 IF (x_out.output_status.return_status <> FND_API.g_ret_sts_success) THEN
2465 RAISE FND_API.g_exc_unexpected_error;
2466 END IF;
2467 INV_EBI_UTIL.debug_line('STEP 90: BEFORE CALLING INV_EBI_CHANGE_ORDER_HELPER.prepare_reference_designators'||'COMP ITEM NAME: '||l_component_item.component_item_name);
2468 prepare_reference_designators (
2469 p_component_item => l_component_item
2470 ,p_from_sequence_id => l_from_sequence_id
2471 ,p_reference_org_id => l_from_org_id
2472 ,x_component_item => l_component_item1
2473 ,x_out => x_out
2474 );
2475 INV_EBI_UTIL.debug_line('STEP 100: AFTER CALLING INV_EBI_CHANGE_ORDER_HELPER.prepare_reference_designators STATUS: '|| x_out.output_status.return_status);
2476 IF (x_out.output_status.return_status <> FND_API.g_ret_sts_success) THEN
2477 RAISE FND_API.g_exc_unexpected_error;
2478 END IF;
2479
2480 l_revised_item.component_item_tbl(j) := l_component_item1;
2481 END LOOP;
2482 END IF;
2483 --l_eco_obj.eco_revised_item_type(i) := l_revised_item;
2484 END IF;
2485 END IF;
2486 --END LOOP;
2487 --END IF;
2488 x_revised_item_obj := l_revised_item;
2489 INV_EBI_UTIL.debug_line('STEP 110: END INSIDE INV_EBI_CHANGE_ORDER_HELPER.process_replicate_bom ');
2490 EXCEPTION
2491 WHEN FND_API.g_exc_unexpected_error THEN
2492 ROLLBACK TO process_replicate_bom_save_pnt;
2493 x_out.output_status.return_status := FND_API.g_ret_sts_unexp_error;
2494 IF(x_out.output_status.msg_data IS NULL) THEN
2495 fnd_msg_pub.count_and_get(
2496 p_encoded => FND_API.g_false
2497 ,p_count => x_out.output_status.msg_count
2498 ,p_data => x_out.output_status.msg_data
2499 );
2500 END IF;
2501 WHEN OTHERS THEN
2502 ROLLBACK TO process_replicate_bom_save_pnt;
2503 x_out.output_status.return_status := FND_API.g_ret_sts_unexp_error;
2504 IF (x_out.output_status.msg_data IS NOT NULL) THEN
2505 x_out.output_status.msg_data := x_out.output_status.msg_data||' ->INV_EBI_CHANGE_ORDER_HELPER.process_replicate_bom ';
2506 ELSE
2507 x_out.output_status.msg_data := SQLERRM||'INV_EBI_CHANGE_ORDER_HELPER.process_replicate_bom ';
2508 END IF;
2509 END process_replicate_bom;
2510
2511 /************************************************************************************
2512 -- API name : process_uda
2513 -- Type : Public
2514 -- Function :
2515 --
2516 ************************************************************************************/
2517 PROCEDURE process_uda (
2518 p_commit IN VARCHAR2 := FND_API.g_false
2519 ,p_api_version IN NUMBER DEFAULT 1.0
2520 ,p_uda_input_obj IN inv_ebi_uda_input_obj
2521 ,p_object_name IN VARCHAR2
2522 ,p_data_level IN VARCHAR2
2523 ,p_pk_column_name_value_pairs IN EGO_COL_NAME_VALUE_PAIR_ARRAY
2524 ,p_class_code_name_value_pairs IN EGO_COL_NAME_VALUE_PAIR_ARRAY
2525 ,x_uda_output_obj OUT NOCOPY inv_ebi_eco_output_obj
2526 )
2527 IS
2528 l_attributes_row_table ego_user_attr_row_table;
2529 l_attributes_data_table ego_user_attr_data_table;
2530 l_attributes_row_obj ego_user_attr_row_obj;
2531 l_transaction_type VARCHAR2(20);
2532 l_uda_out inv_ebi_uda_output_obj;
2533 l_output_status inv_ebi_output_status;
2534 BEGIN
2535 SAVEPOINT inv_ebi_process_uda_save_pnt;
2536 INV_EBI_UTIL.debug_line('STEP 10: START INSIDE INV_EBI_CHANGE_ORDER_HELPER.process_uda');
2537 l_uda_out := inv_ebi_uda_output_obj(NULL,NULL);
2538 l_output_status := inv_ebi_output_status(fnd_api.g_ret_sts_success,NULL,NULL,NULL);
2539 x_uda_output_obj := inv_ebi_eco_output_obj(NULL,NULL,NULL,NULL,l_output_status,NULL,l_uda_out);
2540 INV_EBI_UTIL.debug_line('STEP 20: BEFORE CALLING INV_EBI_UTIL.transform_uda');
2541 --To convert inv_ebi uda objects to ego uda compatible objects
2542 INV_EBI_UTIL.transform_uda (
2543 p_uda_input_obj => p_uda_input_obj
2544 ,x_attributes_row_table => l_attributes_row_table
2545 ,x_attributes_data_table => l_attributes_data_table
2546 ,x_return_status => x_uda_output_obj.output_status.return_status
2547 ,x_msg_count => x_uda_output_obj.output_status.msg_count
2548 ,x_msg_data => x_uda_output_obj.output_status.msg_data
2549 );
2550 INV_EBI_UTIL.debug_line('STEP 30: AFTER CALLING INV_EBI_UTIL.transform_uda STATUS: '|| x_uda_output_obj.output_status.return_status);
2551 IF (x_uda_output_obj.output_status.return_status <> FND_API.g_ret_sts_success) THEN
2552 RAISE FND_API.g_exc_unexpected_error;
2553 END IF;
2554
2555 FOR i in 1..l_attributes_row_table.COUNT
2556 LOOP
2557 l_attributes_row_obj := l_attributes_row_table(i);
2558 IF(l_attributes_row_table(i).transaction_type IS NULL) THEN
2559 l_transaction_type := ego_user_attrs_data_pvt.g_sync_mode;
2560 ELSE
2561 l_transaction_type := l_attributes_row_table(i).transaction_type;
2562 END IF;
2563 l_attributes_row_obj := EGO_USER_ATTRS_DATA_PUB.build_attr_group_row_object(
2564 p_row_identifier => i
2565 ,p_attr_group_id => l_attributes_row_obj.attr_group_id
2566 ,p_attr_group_app_id => l_attributes_row_obj.attr_group_app_id
2567 ,p_attr_group_type => l_attributes_row_obj.attr_group_type
2568 ,p_attr_group_name => l_attributes_row_obj.attr_group_name
2569 ,p_data_level => p_data_level
2570 ,p_data_level_1 => l_attributes_row_obj.data_level_1
2571 ,p_data_level_2 => l_attributes_row_obj.data_level_2
2572 ,p_data_level_3 => l_attributes_row_obj.data_level_3
2573 ,p_data_level_4 => l_attributes_row_obj.data_level_4
2574 ,p_data_level_5 => l_attributes_row_obj.data_level_5
2575 ,p_transaction_type => l_attributes_row_obj.transaction_type
2576 );
2577
2578 l_attributes_row_table(i) := l_attributes_row_obj;
2579 END LOOP;
2580 INV_EBI_UTIL.debug_line('STEP 40: BEFORE CALLING ego_user_attrs_data_pub.process_user_attrs_data');
2581 --To process uda
2582 ego_user_attrs_data_pub.process_user_attrs_data(
2583 p_api_version => p_api_version
2584 ,p_object_name => p_object_name
2585 ,p_attributes_row_table => l_attributes_row_table
2586 ,p_attributes_data_table => l_attributes_data_table
2587 ,p_pk_column_name_value_pairs => p_pk_column_name_value_pairs
2588 ,p_class_code_name_value_pairs => p_class_code_name_value_pairs
2589 ,p_user_privileges_on_object => p_uda_input_obj.user_privileges_on_object
2590 ,p_entity_id => p_uda_input_obj.entity_id
2591 ,p_entity_index => p_uda_input_obj.entity_index
2592 ,p_entity_code => p_uda_input_obj.entity_code
2593 ,p_debug_level => p_uda_input_obj.debug_level
2594 ,p_init_error_handler => p_uda_input_obj.init_error_handler
2595 ,p_write_to_concurrent_log => p_uda_input_obj.write_to_concurrent_log
2596 ,p_init_fnd_msg_list => p_uda_input_obj.init_fnd_msg_list
2597 ,p_log_errors => p_uda_input_obj.log_errors
2598 ,p_add_errors_to_fnd_stack => p_uda_input_obj.add_errors_to_fnd_stack
2599 ,p_commit => p_commit
2600 ,x_failed_row_id_list => x_uda_output_obj.uda_output.failed_row_id_list
2601 ,x_return_status => x_uda_output_obj.output_status.return_status
2602 ,x_errorcode => x_uda_output_obj.uda_output.errorcode
2603 ,x_msg_count => x_uda_output_obj.output_status.msg_count
2604 ,x_msg_data => x_uda_output_obj.output_status.msg_data
2605 );
2606 INV_EBI_UTIL.debug_line('STEP 50: AFTER CALLING ego_user_attrs_data_pub.process_user_attrs_data STATUS: ' || x_uda_output_obj.output_status.return_status);
2607 IF (x_uda_output_obj.output_status.return_status <> FND_API.g_ret_sts_success) THEN
2608 RAISE FND_API.g_exc_unexpected_error;
2609 END IF;
2610
2611 IF FND_API.To_Boolean(p_commit) THEN
2612 COMMIT;
2613 END IF;
2614 INV_EBI_UTIL.debug_line('STEP 60: END CALLING INV_EBI_CHANGE_ORDER_HELPER.process_uda');
2615 EXCEPTION
2616 WHEN FND_API.g_exc_unexpected_error THEN
2617 ROLLBACK TO inv_ebi_process_uda_save_pnt;
2618 x_uda_output_obj.output_status.return_status := FND_API.g_ret_sts_error;
2619
2620 IF(x_uda_output_obj.output_status.msg_data IS NULL) THEN
2621 fnd_msg_pub.count_and_get(
2622 p_encoded => FND_API.g_false
2623 ,p_count => x_uda_output_obj.output_status.msg_count
2624 ,p_data => x_uda_output_obj.output_status.msg_data
2625 );
2626 END IF;
2627
2628 WHEN OTHERS THEN
2629 ROLLBACK TO inv_ebi_process_uda_save_pnt;
2630 x_uda_output_obj.output_status.return_status := FND_API.g_ret_sts_unexp_error;
2631 IF (x_uda_output_obj.output_status.msg_data IS NOT NULL) THEN
2632 x_uda_output_obj.output_status.msg_data := x_uda_output_obj.output_status.msg_data ||' -> INV_EBI_CHANGE_ORDER_HELPER.process_uda ';
2633 ELSE
2634 x_uda_output_obj.output_status.msg_data := SQLERRM||' at INV_EBI_CHANGE_ORDER_HELPER.process_uda ';
2635 END IF;
2636 END process_uda;
2637 /************************************************************************************
2638 -- API name : process_change_order_uda
2639 -- Type : Private
2640 -- Function :
2641 -- This API is used to process Component Level and Structure header udas
2642 --
2643 ************************************************************************************/
2644 PROCEDURE process_change_order_uda(
2645 p_commit IN VARCHAR2
2646 ,p_organization_code IN VARCHAR2
2647 ,p_eco_name IN VARCHAR2
2648 ,p_alternate_bom_code IN VARCHAR2
2649 ,p_revised_item_name IN VARCHAR2
2650 ,p_component_tbl IN inv_ebi_rev_comp_tbl
2651 ,p_structure_header IN inv_ebi_structure_header_obj
2652 ,x_out OUT NOCOPY inv_ebi_eco_output_obj
2653 )IS
2654 l_pkdata ego_col_name_value_pair_array;
2655 l_pkcode ego_col_name_value_pair_array;
2656 l_bill_sequence_id NUMBER;
2657 l_component_sequence_id NUMBER;
2658 l_assembly_item_id NUMBER;
2659 l_organization_id NUMBER;
2660 l_structure_type_id NUMBER;
2661 l_revised_item_sequence_id NUMBER;
2662 l_component_item_id NUMBER;
2663 l_msg_data VARCHAR2(32000);
2664 l_return_status VARCHAR2(3);
2665 l_Error_Table Error_Handler.Error_Tbl_Type;
2666 l_count NUMBER:=0;
2667 l_uda_out inv_ebi_uda_output_obj;
2668 l_output_status inv_ebi_output_status;
2669 BEGIN
2670 SAVEPOINT inv_ebi_chg_order_uda_save_pnt;
2671 INV_EBI_UTIL.debug_line('STEP 10: START INSIDE INV_EBI_CHANGE_ORDER_HELPER.process_change_order_uda');
2672 INV_EBI_UTIL.debug_line('STEP 20: ORG CODE: '|| p_organization_code || ' ECO NAME: '|| p_eco_name || ' REVISED ITEM NAME: '|| p_revised_item_name);
2673 l_uda_out := inv_ebi_uda_output_obj(NULL,NULL);
2674 l_output_status := inv_ebi_output_status(fnd_api.g_ret_sts_success,NULL,NULL,NULL);
2675 x_out := inv_ebi_eco_output_obj(NULL,NULL,NULL,NULL,l_output_status,NULL,NULL);
2676
2677 Error_Handler.initialize;
2678 IF(p_organization_code IS NOT NULL) THEN
2679
2680 l_organization_id := INV_EBI_ITEM_HELPER.get_organization_id(
2681 p_organization_code => p_organization_code
2682 );
2683 END IF;
2684 IF (p_revised_item_name IS NOT NULL) THEN
2685 l_assembly_item_id := INV_EBI_ITEM_HELPER.get_inventory_item_id (
2686 p_organization_id => l_organization_id
2687 ,p_item_number => p_revised_item_name
2688 );
2689
2690 END IF;
2691 INV_EBI_UTIL.debug_line('STEP 30: ORG ID: '|| l_organization_id || ' ASSY ITEM ID: '|| l_assembly_item_id);
2692 IF (p_component_tbl IS NOT NULL AND p_component_tbl.COUNT > 0) THEN
2693 FOR i in 1..p_component_tbl.COUNT
2694 LOOP
2695 IF(p_component_tbl(i).component_revision_uda IS NOT NULL AND p_component_tbl(i).component_revision_uda.attribute_group_tbl.COUNT > 0) THEN
2696 IF(p_component_tbl(i).component_item_name IS NOT NULL) THEN
2697 INV_EBI_UTIL.debug_line('STEP 40: COMPONENT ITEM NAME: '|| p_component_tbl(i).component_item_name);
2698 l_component_item_id := INV_EBI_ITEM_HELPER.get_inventory_item_id (
2699 p_organization_id => l_organization_id
2700 ,p_item_number => p_component_tbl(i).component_item_name
2701 );
2702
2703 END IF;
2704
2705 SELECT bill_sequence_id,structure_type_id INTO l_bill_sequence_id,l_structure_type_id
2706 FROM bom_bill_of_materials
2707 WHERE assembly_item_id = l_assembly_item_id
2708 AND organization_id = l_organization_id
2709 AND NVL(alternate_bom_designator, 'NONE') = DECODE(p_alternate_bom_code,FND_API.G_MISS_CHAR,'NONE',NULL,'NONE',p_alternate_bom_code) ;
2710
2711 SELECT component_sequence_id INTO l_component_sequence_id
2712 FROM bom_components_b
2713 WHERE bill_sequence_id = l_bill_sequence_id
2714 AND component_item_id = l_component_item_id
2715 AND change_notice = p_eco_name;
2716
2717 l_pkdata := ego_col_name_value_pair_array();
2718 l_pkdata.extend(2);
2719 l_pkdata(1) := ego_col_name_value_pair_obj('COMPONENT_SEQUENCE_ID',l_component_sequence_id);
2720 l_pkdata(2) := ego_col_name_value_pair_obj('BILL_SEQUENCE_ID',l_bill_sequence_id);
2721 l_pkcode := ego_col_name_value_pair_array();
2722 l_pkcode.extend();
2723 l_pkcode(1) := ego_col_name_value_pair_obj('STRUCTURE_TYPE_ID',l_structure_type_id);
2724 INV_EBI_UTIL.debug_line('STEP 50: BEFORE CALLING INV_EBI_CHANGE_ORDER_HELPER.process_uda');
2725 process_uda(
2726 p_commit => p_commit
2727 ,p_uda_input_obj => p_component_tbl(i).component_revision_uda
2728 ,p_object_name => 'BOM_COMPONENTS'
2729 ,p_data_level => 'COMPONENTS_LEVEL'
2730 ,p_pk_column_name_value_pairs => l_pkdata
2731 ,p_class_code_name_value_pairs => l_pkcode
2732 ,x_uda_output_obj => x_out
2733 );
2734 INV_EBI_UTIL.debug_line('STEP 60: AFTER CALLING INV_EBI_CHANGE_ORDER_HELPER.process_uda STATUS: '|| x_out.output_status.return_status);
2735 IF(x_out.output_status.return_status <> FND_API.g_ret_sts_success) THEN
2736 RAISE FND_API.g_exc_unexpected_error;
2737 END IF;
2738 END IF;
2739 END LOOP;
2740 END IF;
2741
2742 IF(p_structure_header IS NOT NULL AND p_structure_header.structure_header_uda IS NOT NULL AND p_structure_header.structure_header_uda.attribute_group_tbl.COUNT > 0) THEN
2743
2744 SELECT bill_sequence_id,structure_type_id INTO l_bill_sequence_id,l_structure_type_id
2745 FROM bom_bill_of_materials
2746 WHERE assembly_item_id = l_assembly_item_id
2747 AND organization_id = l_organization_id
2748 AND NVL(alternate_bom_designator, 'NONE') = DECODE(p_alternate_bom_code,FND_API.G_MISS_CHAR,'NONE',NULL,'NONE',p_alternate_bom_code) ;
2749
2750 l_pkdata := ego_col_name_value_pair_array();
2751 l_pkdata.extend();
2752 l_pkdata(1) := ego_col_name_value_pair_obj('BILL_SEQUENCE_ID',l_bill_sequence_id);
2753 l_pkcode := ego_col_name_value_pair_array();
2754 l_pkcode.extend();
2755 l_pkcode(1) := ego_col_name_value_pair_obj('STRUCTURE_TYPE_ID',l_structure_type_id);
2756 INV_EBI_UTIL.debug_line('STEP 70: BEFORE CALLING INV_EBI_CHANGE_ORDER_HELPER.process_uda FOR STRUCTURE HEADER');
2757 process_uda(
2758 p_uda_input_obj => p_structure_header.structure_header_uda
2759 ,p_commit => p_commit
2760 ,p_object_name => 'BOM_STRUCTURE'
2761 ,p_data_level => 'STRUCTURES_LEVEL'
2762 ,p_pk_column_name_value_pairs => l_pkdata
2763 ,p_class_code_name_value_pairs => l_pkcode
2764 ,x_uda_output_obj => x_out
2765 );
2766 INV_EBI_UTIL.debug_line('STEP 80: AFTER CALLING INV_EBI_CHANGE_ORDER_HELPER.process_uda STATUS: '|| x_out.output_status.return_status);
2767 IF(x_out.output_status.return_status <> FND_API.g_ret_sts_success) THEN
2768 RAISE FND_API.g_exc_unexpected_error;
2769 END IF;
2770 END IF;
2771
2772 IF FND_API.To_Boolean(p_commit) THEN
2773 COMMIT;
2774 END IF;
2775 INV_EBI_UTIL.debug_line('STEP 90: END CALLING INV_EBI_CHANGE_ORDER_HELPER.process_change_order_uda');
2776 EXCEPTION
2777 WHEN FND_API.g_exc_unexpected_error THEN
2778 ROLLBACK TO inv_ebi_chg_order_uda_save_pnt;
2779 x_out.output_status.return_status := FND_API.g_ret_sts_error;
2780 IF(x_out.output_status.msg_data IS NULL) THEN
2781 fnd_msg_pub.count_and_get(
2782 p_encoded => FND_API.g_false
2783 ,p_count => x_out.output_status.msg_count
2784 ,p_data => x_out.output_status.msg_data
2785 );
2786 END IF;
2787 WHEN OTHERS THEN
2788 ROLLBACK TO inv_ebi_chg_order_uda_save_pnt;
2789 x_out.output_status.return_status := FND_API.g_ret_sts_unexp_error;
2790 IF (x_out.output_status.msg_data IS NOT NULL) THEN
2791 x_out.output_status.msg_data := x_out.output_status.msg_data ||' -> INV_EBI_CHANGE_ORDER_HELPER.process_change_order_uda';
2792 ELSE
2793 x_out.output_status.msg_data := SQLERRM||' at INV_EBI_CHANGE_ORDER_HELPER.process_change_order_uda';
2794 END IF;
2795 END process_change_order_uda;
2796
2797 /*******************************************************************************
2798 API name : Check_Workflow_Process
2799 Type : Private
2800 Purpose : Checks if there is worflow process for the ECO.
2801 ********************************************************************************/
2802 FUNCTION Check_Workflow_Process(
2803 p_change_order_type_id IN NUMBER
2804 ,p_priority_code IN VARCHAR2 ) RETURN BOOLEAN
2805 IS
2806 l_count NUMBER;
2807 BEGIN
2808 SELECT count(1)
2809 INTO l_count
2810 FROM eng_change_type_processes
2811 WHERE change_order_type_id = p_change_order_type_id
2812 AND NVL(eng_change_priority_code,'X') = NVL(p_priority_code, 'X');
2813
2814 IF (l_count > 0) THEN
2815 RETURN TRUE;
2816 ELSE
2817 RETURN FALSE;
2818 END IF;
2819
2820 EXCEPTION
2821 WHEN OTHERS THEN
2822 RETURN FALSE;
2823 END Check_Workflow_Process;
2824
2825 /*******************************************************************************
2826 API name : Check_Workflow_In_PLM
2827 Type : Public
2828 Purpose : Checks if there is worflow associated for the ECO.
2829 Added for bug 13893810
2830 ********************************************************************************/
2831 FUNCTION Check_Workflow_In_PLM(
2832 p_change_id IN NUMBER ) RETURN BOOLEAN
2833 IS
2834
2835 CURSOR c_workflow(p_change_id NUMBER) IS
2836 SELECT sequence_number, change_lifecycle_status_id,change_wf_route_template_id, workflow_status, change_wf_route_id
2837 FROM eng_lifecycle_statuses
2838 WHERE entity_name = 'ENG_CHANGE_TYPE'
2839 AND entity_id1 = p_change_id
2840 ORDER BY sequence_number;
2841
2842 BEGIN
2843 FOR i IN c_workflow(p_change_id) LOOP
2844 IF i.change_wf_route_template_id IS NOT NULL OR i.change_wf_route_id IS NOT NULL THEN
2845
2846 RETURN TRUE;
2847
2848 END IF;
2849 END LOOP;
2850 RETURN FALSE;
2851
2852 EXCEPTION
2853 WHEN OTHERS THEN
2854 IF c_workflow% ISOPEN THEN
2855 CLOSE c_workflow;
2856 END IF;
2857 RETURN FALSE;
2858 END Check_Workflow_In_PLM;
2859 /*******************************************************************************
2860 API name : is_task_template_set
2861 Type : Public
2862 Purpose : Checks if there is task template associated .
2863 Bug 7218542
2864 ********************************************************************************/
2865
2866 FUNCTION is_task_template_set(
2867 p_change_order_type_id IN NUMBER
2868 ,p_organization_id IN NUMBER
2869 ,p_status_code IN NUMBER
2870 ) RETURN BOOLEAN
2871 IS
2872 l_count NUMBER;
2873 BEGIN
2874 SELECT COUNT(1) INTO l_count
2875 FROM
2876 eng_change_tasks_vl tsk,
2877 eng_change_type_org_tasks typtsk
2878 WHERE
2879 tsk.organization_id = typtsk.organization_id AND
2880 typtsk.organization_id = p_organization_id AND
2881 tsk.change_template_id = typtsk.change_template_or_task_id AND
2882 typtsk.template_or_task_flag ='E' AND
2883 typtsk.change_type_id = p_change_order_type_id AND
2884 typtsk.complete_before_status_code = p_status_code;
2885
2886 IF (l_count > 0) THEN
2887 RETURN TRUE;
2888 ELSE
2889 RETURN FALSE;
2890 END IF;
2891
2892 EXCEPTION
2893 WHEN OTHERS THEN
2894 RETURN FALSE;
2895 END is_task_template_set;
2896
2897 /*******************************************************************************
2898 API name : get_status_name
2899 Type : Private
2900 Purpose : Get the status name based on look up type and lookup code.
2901 ********************************************************************************/
2902 FUNCTION get_status_name(
2903 p_lookup_type IN VARCHAR2
2904 ,p_lookup_code IN VARCHAR2 ) RETURN VARCHAR2
2905 IS
2906 l_meaning varchar2(240);
2907 CURSOR c_lkp IS
2908 SELECT meaning
2909 FROM FND_LOOKUP_VALUES_VL
2910 WHERE lookup_type = p_lookup_type
2911 AND lookup_code = p_lookup_code;
2912 BEGIN
2913 IF (c_lkp%ISOPEN) THEN
2914 CLOSE c_lkp;
2915 END IF;
2916 OPEN c_lkp;
2917 FETCH c_lkp INTO l_meaning;
2918 CLOSE c_lkp;
2919 RETURN l_meaning;
2920 EXCEPTION
2921 WHEN OTHERS THEN
2922 IF (c_lkp%ISOPEN) THEN
2923 CLOSE c_lkp;
2924 END IF;
2925 NULL;
2926 END get_status_name;
2927 /*******************************************************************************
2928 API name : GET_EXISTING_COMPONENT_ATTR
2929 Type : Private
2930 Purpose : Get the ATTRIBUTE OF EXISTING COMPONENT IN CASE OF ACD TYPE(2,3).
2931 ********************************************************************************/
2932
2933 PROCEDURE get_existing_component_attr(
2934 p_organization_id IN NUMBER
2935 , p_revised_item_name IN VARCHAR2
2936 , p_component_item_name IN VARCHAR2
2937 , p_op_sequence_number IN VARCHAR2
2938 , p_alternate_bom_code IN VARCHAR2
2939 , p_bom_update_without_eco IN VARCHAR2
2940 , p_allow_unimp_bom_updates IN VARCHAR2
2941 , p_effectivity_date IN DATE
2942 , x_old_effectivity_date OUT NOCOPY DATE
2943 , x_old_op_sequence_num OUT NOCOPY VARCHAR2
2944 , x_old_fm_end_item_unit OUT NOCOPY VARCHAR2
2945 )
2946 IS
2947 CURSOR C_Bill_seq (p_assembly_item_id NUMBER) IS
2948 SELECT bill_sequence_id
2949 FROM bom_bill_of_materials
2950 WHERE assembly_item_id = p_assembly_item_id
2951 AND organization_id = p_organization_id
2952 AND nvl(alternate_bom_designator,'x') = nvl(p_alternate_bom_code,'x');
2953
2954 --This cursor is for redlining of Unimplemented BOM Components.
2955 -- This is added as part of Bug 10423301
2956 Cursor c_unimplemented_component(p_rev_item_id NUMBER, p_component_item_id NUMBER, p_bill_sequence_id NUMBER) IS
2957 SELECT bic.effectivity_date, bic.operation_seq_num, bic.from_end_item_unit_number
2958 FROM bom_inventory_components bic
2959 ,eng_revised_items eri
2960 WHERE eri.revised_item_id = p_rev_item_id
2961 AND eri.organization_id = p_organization_id
2962 AND eri.bill_sequence_id = p_bill_sequence_id
2963 AND bic.component_item_id = p_component_item_id
2964 AND bic.operation_seq_num = p_op_sequence_number
2965 AND bic.bill_sequence_id = eri.bill_sequence_id
2966 AND bic.revised_item_sequence_id = eri.revised_item_sequence_id
2967 AND eri.scheduled_date = (SELECT MAX(erj.scheduled_date)
2968 FROM bom_inventory_components bcc
2969 ,eng_revised_items erj
2970 WHERE erj.revised_item_id = p_rev_item_id
2971 AND erj.organization_id = p_organization_id
2972 AND erj.bill_sequence_id = p_bill_sequence_id
2973 AND bcc.component_item_id = p_component_item_id
2974 AND bcc.operation_seq_num = p_op_sequence_number
2975 AND bcc.bill_sequence_id = erj.bill_sequence_id
2976 AND bcc.revised_item_sequence_id = erj.revised_item_sequence_id
2977 --Start of Bug 13587336
2978 AND ( bic.disable_date > p_effectivity_date OR bic.disable_date IS NULL)
2979 AND bic.effectivity_date <= p_effectivity_date);
2980 --End of Bug 13587336
2981
2982 --This cursor is for redlining of Implemented BOM Components.
2983 Cursor c_implemented_component(p_rev_item_id NUMBER, p_component_item_id NUMBER, p_bill_sequence_id NUMBER) IS
2984 SELECT bic.effectivity_date, bic.operation_seq_num, bic.from_end_item_unit_number
2985 FROM bom_inventory_components bic
2986 ,eng_revised_items eri
2987 WHERE eri.revised_item_id = p_rev_item_id
2988 AND eri.organization_id = p_organization_id
2989 AND eri.bill_sequence_id = p_bill_sequence_id
2990 AND bic.component_item_id = p_component_item_id
2991 AND bic.operation_seq_num = p_op_sequence_number
2992 AND bic.bill_sequence_id = eri.bill_sequence_id
2993 AND bic.revised_item_sequence_id = eri.revised_item_sequence_id
2994 AND eri.implementation_date = (SELECT MAX(erj.implementation_date)
2995 FROM bom_inventory_components bcc
2996 ,eng_revised_items erj
2997 WHERE erj.revised_item_id = p_rev_item_id
2998 AND erj.organization_id = p_organization_id
2999 AND erj.bill_sequence_id = p_bill_sequence_id
3000 AND bcc.component_item_id = p_component_item_id
3001 AND bcc.operation_seq_num = p_op_sequence_number
3002 AND bcc.bill_sequence_id = erj.bill_sequence_id
3003 AND bcc.revised_item_sequence_id = erj.revised_item_sequence_id
3004 AND erj.implementation_date IS NOT NULL
3005 --Start of Bug 13587336
3006 AND ( bic.disable_date > p_effectivity_date OR bic.disable_date IS NULL)
3007 AND bic.effectivity_date <= p_effectivity_date);
3008 --End of Bug 13587336
3009
3010 --Bug 8340804
3011 CURSOR c_bom_components( p_component_item_id NUMBER,
3012 p_bill_sequence_id NUMBER) IS
3013
3014 SELECT bic.effectivity_date, bic.operation_seq_num, bic.from_end_item_unit_number
3015 FROM bom_inventory_components bic
3016 WHERE bic.component_item_id = p_component_item_id
3017 AND bic.bill_sequence_id = p_bill_sequence_id
3018 AND bic.operation_seq_num = p_op_sequence_number
3019 --Start of Bug 13351524
3020 AND ( bic.disable_date > p_effectivity_date OR bic.disable_date IS NULL)
3021 AND bic.effectivity_date <= p_effectivity_date
3022 ORDER BY bic.effectivity_date DESC;
3023 --End of Bug 13351524
3024
3025 l_bill_sequence_id NUMBER;
3026 l_assembly_item_id NUMBER;
3027 l_organization_id NUMBER;
3028 l_component_item_id NUMBER;
3029 l_component_cur c_unimplemented_component%ROWTYPE;
3030 l_count NUMBER;
3031 l_eco_exist VARCHAR2(1) := FND_API.G_FALSE ;
3032 l_allow_unimp_bom_update VARCHAR2(1) := FND_API.G_FALSE;
3033 l_bom_comp_exist_without_eco VARCHAR2(1) := FND_API.G_FALSE; --Added of Bug 13587336
3034
3035 BEGIN
3036 INV_EBI_UTIL.debug_line('STEP 10: START INSIDE INV_EBI_CHANGE_ORDER_HELPER.get_existing_component_attr');
3037 -- To Retrive revisied item id
3038 l_assembly_item_id := INV_EBI_ITEM_HELPER.get_inventory_item_id
3039 (p_organization_id => p_organization_id
3040 ,p_item_number => p_revised_item_name);
3041 INV_EBI_UTIL.debug_line('STEP 20: ASSY ITEM ID: ' || l_assembly_item_id);
3042
3043 -- Start of Bug 10423301
3044 -- IF UNIMPLEMENTED_BOM_UPDATES_ALLOWED aia config property value is passed from aia layer honour it
3045 -- otherwise retrieve value from global variable INV_EBI_FLAGS.G_ALLOW_UNIMP_BOM_UPDATES
3046 -- For SUN AIT this variable value will be 'T'.Post 2.5 RUP5 this value will be passed from aia layer,unitll then
3047 -- not to disturb current functionality global variable should be set to 'F' i.e do not allow unimplemented BOM changes
3048
3049 INV_EBI_UTIL.debug_line('STEP 30: p_allow_unimp_bom_updates ' || p_allow_unimp_bom_updates);
3050
3051 l_allow_unimp_bom_update := p_allow_unimp_bom_updates;
3052
3053 IF (l_allow_unimp_bom_update IS NULL OR l_allow_unimp_bom_update = fnd_api.g_miss_char) THEN
3054
3055 l_allow_unimp_bom_update := INV_EBI_FLAGS.get_allow_unimp_bom_updates;
3056
3057 END IF;
3058
3059 INV_EBI_UTIL.debug_line('STEP 40: l_allow_unimp_bom_update ' || l_allow_unimp_bom_update);
3060 -- End of Bug 10423301
3061
3062 -- Cursor to retrive the bill sequence id
3063 FOR i in C_Bill_seq(l_assembly_item_id) LOOP
3064 l_bill_sequence_id := i.bill_sequence_id;
3065 INV_EBI_UTIL.debug_line('STEP 50: BILL SEQ ID: '|| l_bill_sequence_id);
3066 EXIT;
3067 END LOOP;
3068
3069 --To Retrive Component Item Id
3070 l_component_item_id := INV_EBI_ITEM_HELPER.get_inventory_item_id
3071 ( p_organization_id => p_organization_id
3072 ,p_item_number => p_component_item_name);
3073
3074 INV_EBI_UTIL.debug_line('STEP 60: COMP ITEM ID: '|| l_component_item_id);
3075
3076 --Start of Bug 10423301
3077 --If Unimplemented BOM updates are not allowed then open cursor c_implemented_component
3078 --else open cursor c_unimplemented_component
3079
3080 IF( l_allow_unimp_bom_update = FND_API.G_FALSE) THEN
3081 --To Retrive old effectivity date if BOM Components are implemented
3082 INV_EBI_UTIL.debug_line('STEP 70: Opening Cursor for implemented BOM Components');
3083 IF c_implemented_component%ISOPEN THEN
3084 CLOSE c_implemented_component;
3085 END IF;
3086
3087 OPEN c_implemented_component(l_assembly_item_id, l_component_item_id, l_bill_sequence_id) ;
3088 FETCH c_implemented_component INTO l_component_cur;
3089
3090 IF(c_implemented_component % ROWCOUNT > 0) THEN
3091 INV_EBI_UTIL.debug_line('STEP 80: Implemented BOM Components Exists');
3092 x_old_effectivity_date := l_component_cur.effectivity_date;
3093 x_old_op_sequence_num := l_component_cur.operation_seq_num;
3094 x_old_fm_end_item_unit := l_component_cur.from_end_item_unit_number;
3095
3096 l_eco_exist := FND_API.G_TRUE;
3097 END IF;
3098 CLOSE c_implemented_component;
3099 ELSE
3100 INV_EBI_UTIL.debug_line('STEP 90: Opening Cursor for Unimplemented BOM Components');
3101 -- This block will be executed for SUN AIT
3102 IF c_unimplemented_component%ISOPEN THEN
3103 CLOSE c_unimplemented_component;
3104 END IF;
3105
3106 OPEN c_unimplemented_component(l_assembly_item_id, l_component_item_id, l_bill_sequence_id) ;
3107 FETCH c_unimplemented_component INTO l_component_cur;
3108
3109 IF(c_unimplemented_component % ROWCOUNT > 0) THEN
3110 INV_EBI_UTIL.debug_line('STEP 100: Unimplemented BOM Components Exists');
3111 x_old_effectivity_date := l_component_cur.effectivity_date;
3112 x_old_op_sequence_num := l_component_cur.operation_seq_num;
3113 x_old_fm_end_item_unit := l_component_cur.from_end_item_unit_number;
3114
3115 l_eco_exist := FND_API.G_TRUE;
3116 END IF;
3117 CLOSE c_unimplemented_component;
3118 END IF;-- End of Bug 10423301
3119
3120 /*Start of Bug :8340804 If Item has BOM and no Change Order then retrieve old values from
3121 bom_inventory_components table */
3122
3123
3124 IF(l_eco_exist <> FND_API.G_TRUE AND p_bom_update_without_eco = FND_API.G_TRUE) THEN
3125
3126 /*SELECT COUNT(1) INTO l_count
3127 FROM eng_revised_items
3128 WHERE revised_item_id = l_assembly_item_id
3129 AND organization_id = p_organization_id;*/ -- Commented this query for Bug 9527466
3130
3131 /*Above query was returning a row if item has Change Order associated,but we need
3132 to check if the BOM component is associated with the CO,if not query the required
3133 data from bom_inventory_components.So below query is incorporated*/
3134 INV_EBI_UTIL.debug_line('STEP 110:BOM exists without Change Order and p_bom_update_without_eco ' || p_bom_update_without_eco);
3135
3136 --Start of Bug 9527466
3137 SELECT COUNT(1) INTO l_count
3138 FROM eng_revised_items eri,
3139 bom_inventory_components bic
3140 WHERE eri.revised_item_id = l_assembly_item_id
3141 AND eri.organization_id = p_organization_id
3142 AND eri.bill_sequence_id = l_bill_sequence_id
3143 AND bic.component_item_id = l_component_item_id
3144 AND bic.operation_seq_num = p_op_sequence_number
3145 AND bic.bill_sequence_id = eri.bill_sequence_id
3146 AND bic.revised_item_sequence_id = eri.revised_item_sequence_id
3147 AND bic.change_notice IS NOT NULL;
3148 --End of Bug 9527466
3149
3150 IF (l_count = 0) THEN
3151
3152 FOR l_bom_comps IN c_bom_components(l_component_item_id,l_bill_sequence_id)
3153 LOOP
3154
3155 l_bom_comp_exist_without_eco := FND_API.G_TRUE;
3156 x_old_effectivity_date := l_bom_comps.effectivity_date;
3157 x_old_op_sequence_num := l_bom_comps.operation_seq_num;
3158 x_old_fm_end_item_unit := l_bom_comps.from_end_item_unit_number;
3159 EXIT;
3160
3161 END LOOP;
3162 END IF;
3163
3164 --Start of Bug 13582896
3165 IF(l_bom_comp_exist_without_eco = FND_API.G_FALSE) THEN
3166 SELECT COUNT(1) INTO l_count
3167 FROM bom_inventory_components bic
3168 WHERE bic.bill_sequence_id = l_bill_sequence_id
3169 AND bic.component_item_id = l_component_item_id
3170 AND bic.operation_seq_num = p_op_sequence_number
3171 AND bic.change_notice IS NULL;
3172
3173 IF (l_count > 0) THEN
3174 FOR l_bom_comps IN c_bom_components(l_component_item_id,l_bill_sequence_id)
3175 LOOP
3176
3177 x_old_effectivity_date := l_bom_comps.effectivity_date;
3178 x_old_op_sequence_num := l_bom_comps.operation_seq_num;
3179 x_old_fm_end_item_unit := l_bom_comps.from_end_item_unit_number;
3180 EXIT;
3181
3182 END LOOP;
3183 END IF;
3184 END IF;
3185 --End of Bug 13582896
3186 END IF;
3187 -- END of Bug 8340804
3188 INV_EBI_UTIL.debug_line('STEP 50: END INSIDE INV_EBI_CHANGE_ORDER_HELPER.get_existing_component_attr');
3189 EXCEPTION
3190 WHEN OTHERS THEN
3191 IF c_implemented_component%ISOPEN THEN
3192 CLOSE c_implemented_component;
3193 END IF;
3194
3195 IF c_unimplemented_component%ISOPEN THEN
3196 CLOSE c_unimplemented_component;
3197 END IF;
3198 NULL;
3199 END get_existing_component_attr;
3200
3201 /************************************************************************************
3202 -- API name : get_current_item_revision
3203 -- Type : Private
3204 -- Function :
3205 -- This API is used to return Current revision record of an item
3206 -- Bug 7197943
3207 ************************************************************************************/
3208 FUNCTION get_current_item_revision(
3209 p_inventory_item_id IN NUMBER,
3210 p_organization_id IN NUMBER,
3211 p_date IN DATE
3212 ) RETURN VARCHAR2 IS
3213 l_revision VARCHAR2(3);
3214 CURSOR c_item_rev(
3215 p_inventory_item_id IN NUMBER,
3216 p_organization_id IN NUMBER,
3217 p_revision_date IN DATE
3218 ) IS
3219 SELECT
3220 revision
3221 FROM
3222 mtl_item_revisions_b
3223 WHERE
3224 inventory_item_id = p_inventory_item_id AND
3225 organization_id = p_organization_id AND
3226 effectivity_date <= p_revision_date AND
3227 implementation_date IS NOT NULL
3228 ORDER BY
3229 effectivity_date DESC, revision DESC;
3230
3231 l_item_rev c_item_rev%ROWTYPE;
3232
3233 BEGIN
3234 INV_EBI_UTIL.debug_line('STEP 10: START INSIDE INV_EBI_CHANGE_ORDER_HELPER.get_current_item_revision');
3235 INV_EBI_UTIL.debug_line('STEP 20: INV ITEM ID: '|| p_inventory_item_id || ' ORG ID: '|| p_organization_id);
3236 IF c_item_rev%ISOPEN THEN
3237 CLOSE c_item_rev;
3238 END IF;
3239
3240 OPEN c_item_rev(
3241 p_inventory_item_id => p_inventory_item_id,
3242 p_organization_id => p_organization_id,
3243 p_revision_date => sysdate
3244 );
3245 FETCH c_item_rev INTO l_revision;
3246 CLOSE c_item_rev;
3247 INV_EBI_UTIL.debug_line('STEP 30: END INSIDE INV_EBI_CHANGE_ORDER_HELPER.get_current_item_revision RETURN VALUE: '|| l_revision);
3248 RETURN l_revision;
3249 EXCEPTION
3250 WHEN OTHERS THEN
3251 IF c_item_rev%ISOPEN THEN
3252 CLOSE c_item_rev;
3253 END IF;
3254 NULL;
3255 END get_current_item_revision;
3256
3257 /************************************************************************************
3258 -- API name : process_assign_items
3259 -- Type : Private
3260 -- Function :
3261 -- This API is used to Assign items to child org if it exists in master org
3262 -- Other wise raises an exception
3263 __ BUG 7143083
3264 ************************************************************************************/
3265
3266 PROCEDURE process_assign_items(
3267 p_organization_id IN NUMBER ,
3268 p_item_name IN VARCHAR2,
3269 x_return_status OUT NOCOPY VARCHAR2 ,
3270 x_msg_data OUT NOCOPY VARCHAR2,
3271 x_msg_count OUT NOCOPY NUMBER
3272 ) IS
3273 l_is_item_exists VARCHAR2(3);
3274 l_master_org NUMBER;
3275 l_approval_status VARCHAR2(30);
3276 l_inventory_item_id NUMBER;
3277 l_count NUMBER := 0;
3278 l_item_catalog_group_id NUMBER;
3279 l_effectivity_date DATE;
3280 CURSOR c_master_item_rev(
3281 p_inventory_item_id IN NUMBER,
3282 p_organization_id IN NUMBER,
3283 p_revision_date IN DATE
3284 ) IS
3285 SELECT
3286 revision,
3287 revision_id ,
3288 revision_label,
3289 revision_reason,
3290 description,
3291 attribute_category,
3292 attribute1 ,
3293 attribute2 ,
3294 attribute3 ,
3295 attribute4 ,
3296 attribute5 ,
3297 attribute6 ,
3298 attribute7 ,
3299 attribute8 ,
3300 attribute9 ,
3301 attribute10,
3302 attribute11,
3303 attribute12,
3304 attribute13,
3305 attribute14,
3306 attribute15
3307 FROM
3308 mtl_item_revisions_b
3309 WHERE
3310 inventory_item_id = p_inventory_item_id AND
3311 organization_id = p_organization_id AND
3312 effectivity_date <= p_revision_date AND
3313 implementation_date IS NOT NULL
3314 ORDER BY
3315 effectivity_date DESC, revision DESC;
3316
3317 l_master_item_rev c_master_item_rev%ROWTYPE;
3318
3319 BEGIN
3320 SAVEPOINT inv_ebi_assign_item_save_pnt;
3321 INV_EBI_UTIL.debug_line('STEP 10: START INSIDE INV_EBI_CHANGE_ORDER_HELPER.process_assign_items');
3322 INV_EBI_UTIL.debug_line('STEP 20: ORG ID : '|| p_organization_id || ' ITEM NAME: '|| p_item_name);
3323
3324 x_return_status := FND_API.G_RET_STS_SUCCESS;
3325 l_is_item_exists := INV_EBI_ITEM_HELPER.is_item_exists(
3326 p_organization_id => p_organization_id
3327 ,p_item_number => p_item_name
3328 );
3329 IF (l_is_item_exists = FND_API.g_false) THEN
3330
3331 l_master_org := INV_EBI_UTIL.get_master_organization(
3332 p_organization_id => p_organization_id
3333 );
3334 l_is_item_exists := INV_EBI_ITEM_HELPER.is_item_exists(
3335 p_organization_id => l_master_org
3336 ,p_item_number => p_item_name
3337 );
3338
3339 /* If Item does not exist in context org(child org) and it exists in master org
3340 and if it approved in master org and ASSIGN_ITEM_TO_CHILD_ORG is set
3341 to true then item should be assigned to context org */
3342
3343 IF(l_is_item_exists = FND_API.g_true ) THEN
3344 IF(get_assign_item = FND_API.g_true ) THEN
3345 IF(INV_EBI_UTIL.is_pim_installed) THEN
3346 SELECT item_catalog_group_id, approval_status
3347 INTO l_item_catalog_group_id, l_approval_status
3348 FROM mtl_system_items_kfv
3349 WHERE organization_id = l_master_org
3350 AND concatenated_segments = p_item_name;
3351 IF (INV_EBI_ITEM_HELPER.is_new_item_request_reqd( l_item_catalog_group_id ) = FND_API.g_true) AND l_approval_status <> 'A'
3352 THEN
3353 FND_MSG_PUB.initialize();
3354 FND_MESSAGE.set_name('INV','INV_EBI_INVALID_APROVAL_STS');
3355 FND_MESSAGE.set_token('ITEM_NUMBER',p_item_name);
3356 FND_MESSAGE.set_token('ORGANIZATION_ID',l_master_org);
3357 FND_MESSAGE.set_token('CHILD_ORGANIZATION_ID',p_organization_id);
3358 FND_MSG_PUB.add;
3359 RAISE FND_API.g_exc_unexpected_error;
3360 END IF;
3361 END IF;
3362 INV_EBI_UTIL.debug_line('STEP 30: BEFORE CALLING EGO_ITEM_PUB.assign_item_to_org');
3363 EGO_ITEM_PUB.assign_item_to_org(
3364 p_api_version => 1.0
3365 ,p_commit => FND_API.g_false
3366 ,p_Item_Number => p_item_name
3367 ,p_Organization_Id => p_organization_id
3368 ,x_return_status => x_return_status
3369 ,x_msg_count => x_msg_count
3370 );
3371 INV_EBI_UTIL.debug_line('STEP 40: AFTER CALLING EGO_ITEM_PUB.assign_item_to_org STATUS: ' || x_return_status);
3372 IF (x_return_status <> FND_API.g_ret_sts_success) THEN
3373 RAISE FND_API.g_exc_unexpected_error;
3374 END IF;
3375 l_inventory_item_id := INV_EBI_ITEM_HELPER.get_inventory_item_id (
3376 p_organization_id => l_master_org
3377 ,p_item_number => p_item_name
3378 );
3379 INV_EBI_UTIL.debug_line('STEP 50: INV ITEM ID: '||l_inventory_item_id);
3380 --To get effectivity date of recently created revision in context org
3381 l_effectivity_date := get_latest_effectivity_date(
3382 p_inventory_item_id => l_inventory_item_id,
3383 p_organization_id => p_organization_id
3384 );
3385
3386 --To get current revision from master org
3387 IF c_master_item_rev%ISOPEN THEN
3388 CLOSE c_master_item_rev;
3389 END IF;
3390
3391 OPEN c_master_item_rev(
3392 p_inventory_item_id => l_inventory_item_id,
3393 p_organization_id => l_master_org,
3394 p_revision_date => sysdate
3395 );
3396 FETCH c_master_item_rev INTO l_master_item_rev;
3397 CLOSE c_master_item_rev;
3398
3399 --To check if master orgs current reviison is already there in context org
3400 SELECT COUNT(1) INTO l_count
3401 FROM
3402 mtl_item_revisions_b mir,
3403 mtl_system_items_kfv msi
3404 WHERE
3405 mir.organization_id = msi.organization_id AND
3406 msi.organization_id = p_organization_id AND
3407 mir.inventory_item_id = msi.inventory_item_id AND
3408 msi.concatenated_segments = p_item_name AND
3409 mir.revision = l_master_item_rev.revision;
3410
3411 --If master orgs current revision is not there in context org,create it
3412 IF(l_count = 0) THEN
3413 l_effectivity_date := l_effectivity_date + 1/86400; -- To keep efectivity date of next rev 1 sec higher than earlier rev
3414 INV_EBI_UTIL.debug_line('STEP 60: BEFORE CALLING EGO_ITEM_PUB.Process_Item_Revision');
3415 EGO_ITEM_PUB.Process_Item_Revision(
3416 p_api_version => 1.0
3417 ,p_init_msg_list => FND_API.g_false
3418 ,p_commit => FND_API.g_false
3419 ,p_transaction_type => INV_EBI_ITEM_PUB.g_otype_create
3420 ,p_inventory_item_id => NULL
3421 ,p_item_number => p_item_name
3422 ,p_organization_id => p_organization_id
3423 ,p_Organization_Code => NULL
3424 ,p_revision => l_master_item_rev.revision
3425 ,p_description => l_master_item_rev.description
3426 ,p_effectivity_date => l_effectivity_date
3427 ,p_revision_label => l_master_item_rev.revision_label
3428 ,p_revision_reason => l_master_item_rev.revision_reason
3429 ,p_lifecycle_id => NULL
3430 ,p_current_phase_id => NULL
3431 ,p_attribute_category => l_master_item_rev.attribute_category
3432 ,p_attribute1 => l_master_item_rev.attribute1
3433 ,p_attribute2 => l_master_item_rev.attribute2
3434 ,p_attribute3 => l_master_item_rev.attribute3
3435 ,p_attribute4 => l_master_item_rev.attribute4
3436 ,p_attribute5 => l_master_item_rev.attribute5
3437 ,p_attribute6 => l_master_item_rev.attribute6
3438 ,p_attribute7 => l_master_item_rev.attribute7
3439 ,p_attribute8 => l_master_item_rev.attribute8
3440 ,p_attribute9 => l_master_item_rev.attribute9
3441 ,p_attribute10 => l_master_item_rev.attribute10
3442 ,p_attribute11 => l_master_item_rev.attribute11
3443 ,p_attribute12 => l_master_item_rev.attribute12
3444 ,p_attribute13 => l_master_item_rev.attribute13
3445 ,p_attribute14 => l_master_item_rev.attribute14
3446 ,p_attribute15 => l_master_item_rev.attribute15
3447 ,x_return_status => x_return_status
3448 ,x_msg_count => x_msg_count
3449 ,x_msg_data => x_msg_data
3450 ) ;
3451 INV_EBI_UTIL.debug_line('STEP 70: AFTER CALLING EGO_ITEM_PUB.Process_Item_Revision STATUS: '|| x_return_status);
3452 IF (x_return_status <> FND_API.g_ret_sts_success) THEN
3453 x_msg_data := x_msg_data || ' -> Item Number:' || p_item_name || ' -> Org Id: ' || p_organization_id;
3454 RAISE FND_API.g_exc_unexpected_error;
3455 END IF;
3456 END IF;
3457 END IF;
3458 ELSE
3459 FND_MESSAGE.set_name('INV','INV_EBI_ITEM_NO_MASTER_ORG');
3460 FND_MESSAGE.set_token('ITEM', p_item_name);
3461 FND_MSG_PUB.add;
3462 RAISE FND_API.g_exc_error;
3463 END IF;
3464 END IF;
3465 INV_EBI_UTIL.debug_line('STEP 80: END INSIDE INV_EBI_CHANGE_ORDER_HELPER.process_assign_items ');
3466 EXCEPTION
3467 WHEN FND_API.g_exc_unexpected_error THEN
3468 ROLLBACK TO inv_ebi_assign_item_save_pnt;
3469 x_return_status := FND_API.g_ret_sts_unexp_error;
3470
3471 IF c_master_item_rev%ISOPEN THEN
3472 CLOSE c_master_item_rev;
3473 END IF;
3474 IF(x_msg_data IS NULL) THEN
3475 fnd_msg_pub.count_and_get(
3476 p_encoded => FND_API.g_false
3477 ,p_count => x_msg_count
3478 ,p_data => x_msg_data
3479 );
3480 END IF;
3481 WHEN FND_API.g_exc_error THEN
3482 ROLLBACK TO inv_ebi_assign_item_save_pnt;
3483 x_return_status := FND_API.g_ret_sts_error;
3484
3485 IF c_master_item_rev%ISOPEN THEN
3486 CLOSE c_master_item_rev;
3487 END IF;
3488 IF(x_msg_data IS NULL) THEN
3489 FND_MSG_PUB.count_and_get(
3490 p_encoded => FND_API.g_false
3491 ,p_count => x_msg_count
3492 ,p_data => x_msg_data
3493 );
3494 END IF;
3495 WHEN OTHERS THEN
3496 ROLLBACK TO inv_ebi_assign_item_save_pnt;
3497 x_return_status := FND_API.g_ret_sts_unexp_error;
3498
3499 IF c_master_item_rev%ISOPEN THEN
3500 CLOSE c_master_item_rev;
3501 END IF;
3502 IF (x_msg_data IS NOT NULL) THEN
3503 x_msg_data := x_msg_data||' -> INV_EBI_CHANGE_ORDER_HELPER.process_assign_items ';
3504 ELSE
3505 x_msg_data := SQLERRM||' INV_EBI_CHANGE_ORDER_HELPER.process_assign_items ';
3506 END IF;
3507 END process_assign_items;
3508
3509 /************************************************************************************
3510 -- API name : get_change_type_code
3511 -- Type : Public
3512 -- Function :
3513 -- This API is used to return change_type_code based on change_order_type_id
3514 -- From DVM
3515 ************************************************************************************/
3516 FUNCTION get_change_type_code(p_change_type_id IN NUMBER )
3517 RETURN VARCHAR2
3518 IS
3519 l_change_type_code VARCHAR2(80);
3520 BEGIN
3521
3522 SELECT type_name
3523 INTO l_change_type_code
3524 FROM eng_change_order_types_vl
3525 WHERE change_order_type_id = p_change_type_id
3526 AND change_mgmt_type_code = 'CHANGE_ORDER'
3527 AND type_classification='HEADER';
3528
3529 RETURN l_change_type_code;
3530 EXCEPTION
3531 WHEN OTHERS THEN
3532 RETURN NULL;
3533 END get_change_type_code;
3534
3535 /************************************************************************************
3536 -- API name : get_eco_status_name
3537 -- Type : Public
3538 -- Function :
3539 -- This API is used to return ECO status_name based on status_CODE
3540 -- From DVM
3541 ************************************************************************************/
3542
3543 FUNCTION get_eco_status_name(p_status_code IN NUMBER)
3544 RETURN VARCHAR2
3545 IS
3546 l_status_name VARCHAR2(30);
3547 BEGIN
3548
3549 SELECT status_name
3550 INTO l_status_name
3551 FROM eng_change_statuses_vl
3552 WHERE status_code = p_status_code;
3553
3554 RETURN l_status_name;
3555 EXCEPTION
3556 WHEN OTHERS THEN
3557 NULL;
3558 END get_eco_status_name;
3559
3560 /************************************************************************************
3561 -- API name : process_common_comps
3562 -- Type : Private
3563 -- Function :
3564 -- This API is used to find the components and substitute comps attached to the
3565 -- common bom. Bug 7127027
3566 ************************************************************************************/
3567
3568 PROCEDURE process_common_comps(
3569 p_assembly_item_id IN NUMBER,
3570 p_organization_id IN NUMBER,
3571 p_src_organization_id IN NUMBER,
3572 p_src_bill_sequence_id IN NUMBER,
3573 x_return_status OUT NOCOPY VARCHAR2 ,
3574 x_msg_data OUT NOCOPY VARCHAR2,
3575 x_msg_count OUT NOCOPY NUMBER
3576 ) IS
3577
3578 l_bom_item_type NUMBER;
3579 l_base_item_flag NUMBER;
3580 l_replenish_to_order_flag VARCHAR2(1);
3581 l_pick_components_flag VARCHAR2(1);
3582 l_assm_type NUMBER;
3583 l_master_org NUMBER;
3584
3585 CURSOR c_common_comps (
3586 p_assy_type IN NUMBER,
3587 p_item_type IN NUMBER,
3588 p_base_item_flag IN NUMBER,
3589 p_pick_components_flag IN VARCHAR2,
3590 p_replenish_to_order_flag IN VARCHAR2
3591 ) IS
3592
3593 SELECT
3594 msi.concatenated_segments component_item_name ,
3595 bic.component_item_id
3596 FROM
3597 bom_inventory_components bic,
3598 mtl_system_items_kfv msi
3599 WHERE
3600 bic.bill_sequence_id = p_src_bill_sequence_id AND
3601 bic.component_item_id = msi.inventory_item_id AND
3602 msi.organization_id = p_src_organization_id AND
3603 NVL(bic.disable_date, sysdate + 1) >= sysdate AND
3604 NOT EXISTS
3605 ( SELECT 'x'
3606 FROM mtl_system_items_kfv s
3607 WHERE s.organization_id = p_organization_id
3608 AND s.inventory_item_id = bic.component_item_id
3609 AND ((p_assy_type = 1 AND s.eng_item_flag = 'N')
3610 OR (p_assy_type = 2)
3611 )
3612 AND s.inventory_item_id <> p_assembly_item_id
3613 AND ((p_item_type = 1 AND s.bom_item_type <> 3)
3614 OR (p_item_type = 2 AND s.bom_item_type <> 3)
3615 OR (p_item_type = 3)
3616 OR (p_item_type = 4
3617 AND (s.bom_item_type = 4
3618 OR(
3619 s.bom_item_type IN (2, 1)
3620 AND s.replenish_to_order_flag = 'Y'
3621 AND p_base_item_flag IS NOT NULL
3622 AND p_replenish_to_order_flag = 'Y'
3623 )
3624 )
3625 )
3626 )
3627 AND (p_item_type = 3
3628 OR
3629 p_pick_components_flag = 'Y'
3630 OR
3631 s.pick_components_flag = 'N'
3632 )
3633 AND (p_item_type = 3
3634 OR
3635 NVL(s.bom_item_type, 4) <> 2
3636 OR
3637 (s.bom_item_type = 2
3638 AND (( p_pick_components_flag = 'Y'
3639 AND s.pick_components_flag = 'Y'
3640 )
3641 OR ( p_replenish_to_order_flag = 'Y'
3642 AND s.replenish_to_order_flag = 'Y'
3643 )
3644 )
3645 )
3646 )
3647 AND NOT( p_item_type = 4
3648 AND p_pick_components_flag = 'Y'
3649 AND s.bom_item_type = 4
3650 AND s.replenish_to_order_flag = 'Y'
3651 )
3652 );
3653 l_common_comps c_common_comps%ROWTYPE;
3654
3655 CURSOR c_common_sub_comps(
3656 p_assy_type IN NUMBER,
3657 p_item_type IN NUMBER,
3658 p_base_item_flag IN NUMBER,
3659 p_pick_components_flag IN VARCHAR2,
3660 p_replenish_to_order_flag IN VARCHAR2
3661 ) IS
3662
3663 SELECT
3664 msi.concatenated_segments sub_comp_item_name ,
3665 bsc.substitute_component_id
3666 FROM bom_inventory_components bic,
3667 bom_substitute_components bsc,
3668 mtl_system_items_kfv msi
3669 WHERE bic.bill_sequence_id = p_src_bill_sequence_id
3670 AND bic.component_sequence_id = bsc.component_sequence_id
3671 AND bsc.substitute_component_id = msi.inventory_item_id
3672 AND msi.organization_id = p_src_organization_id
3673 AND bsc.substitute_component_id NOT IN
3674 (SELECT msi1.inventory_item_id
3675 FROM mtl_system_items msi1, mtl_system_items msi2
3676 WHERE msi1.organization_id = p_organization_id
3677 AND msi1.inventory_item_id = bsc.substitute_component_id
3678 AND msi2.organization_id = p_src_organization_id
3679 AND msi2.inventory_item_id = msi1.inventory_item_id
3680 AND ((p_assy_type = 1 AND msi1.eng_item_flag = 'N')
3681 OR (p_assy_type = 2)
3682 )
3683 AND msi1.inventory_item_id <> p_assembly_item_id
3684 AND ( (p_item_type = 1 AND msi1.bom_item_type <> 3)
3685 OR (p_item_type = 2 AND msi1.bom_item_type <> 3)
3686 OR (p_item_type = 3)
3687 OR ( p_item_type = 4
3688 AND ( msi1.bom_item_type = 4
3689 OR ( msi1.bom_item_type IN (2, 1)
3690 AND msi1.replenish_to_order_flag = 'Y'
3691 AND p_base_item_flag IS NOT NULL
3692 AND p_replenish_to_order_flag = 'Y'
3693 )
3694 )
3695 )
3696 )
3697 AND (p_item_type = 3
3698 OR
3699 p_pick_components_flag = 'Y'
3700 OR
3701 msi1.pick_components_flag = 'N'
3702 )
3703 AND (p_item_type = 3
3704 OR
3705 NVL(msi1.bom_item_type, 4) <> 2
3706 OR
3707 (msi1.bom_item_type = 2
3708 AND (( p_pick_components_flag = 'Y'
3709 AND msi1.pick_components_flag = 'Y'
3710 )
3711 OR ( p_replenish_to_order_flag = 'Y'
3712 AND msi1.replenish_to_order_flag = 'Y'
3713 )
3714 )
3715 )
3716 )
3717 AND NOT( p_item_type = 4
3718 AND p_pick_components_flag = 'Y'
3719 AND msi1.bom_item_type = 4
3720 AND msi1.replenish_to_order_flag = 'Y'
3721 )
3722 );
3723
3724 l_common_sub_comps c_common_sub_comps%ROWTYPE;
3725 BEGIN
3726 INV_EBI_UTIL.DEBUG_LINE('STEP 10: START INSIDE INV_EBI_CHANGE_ORDER_HELPER.process_common_comps');
3727 INV_EBI_UTIL.DEBUG_LINE('STEP 20: ASSY ITEM ID: '|| p_assembly_item_id || ' ORG ID: '|| p_organization_id || ' SRC ORG ID: '|| p_src_organization_id);
3728 SAVEPOINT inv_ebi_comm_comp_save_pnt;
3729 x_return_status := FND_API.G_RET_STS_SUCCESS;
3730
3731 SELECT
3732 bom_item_type,
3733 base_item_id,
3734 replenish_to_order_flag,
3735 pick_components_flag ,
3736 DECODE(eng_item_flag, 'Y', 2, 1)
3737 INTO
3738 l_bom_item_type,
3739 l_base_item_flag,
3740 l_replenish_to_order_flag,
3741 l_pick_components_flag,
3742 l_assm_type
3743 FROM
3744 mtl_system_items
3745 WHERE
3746 inventory_item_id = p_assembly_item_id AND
3747 organization_id = p_organization_id;
3748
3749 OPEN c_common_comps(
3750 p_assy_type => l_assm_type ,
3751 p_item_type => l_bom_item_type,
3752 p_base_item_flag => l_base_item_flag,
3753 p_pick_components_flag => l_pick_components_flag,
3754 p_replenish_to_order_flag => l_replenish_to_order_flag
3755 );
3756 LOOP
3757
3758 FETCH c_common_comps INTO l_common_comps;
3759 EXIT WHEN c_common_comps%NOTFOUND;
3760 INV_EBI_UTIL.DEBUG_LINE('STEP 30: BEFORE CALLING INV_EBI_CHANGE_ORDER_HELPER.process_assign_items ');
3761 INV_EBI_UTIL.DEBUG_LINE('STEP 40: COMPONENT ITEM NAME: '|| l_common_comps.component_item_name);
3762 process_assign_items(
3763 p_organization_id => p_organization_id,
3764 p_item_name => l_common_comps.component_item_name,
3765 x_return_status => x_return_status ,
3766 x_msg_data => x_msg_data ,
3767 x_msg_count => x_msg_count
3768 );
3769 INV_EBI_UTIL.debug_line('STEP 50: AFTER CALLING INV_EBI_CHANGE_ORDER_HELPER.process_assign_items STATUS: '|| x_return_status);
3770 IF (x_return_status <> FND_API.g_ret_sts_success) THEN
3771 RAISE FND_API.g_exc_unexpected_error;
3772 END IF;
3773 END LOOP;
3774 CLOSE c_common_comps;
3775
3776 OPEN c_common_sub_comps(
3777 p_assy_type => l_assm_type ,
3778 p_item_type => l_bom_item_type,
3779 p_base_item_flag => l_base_item_flag,
3780 p_pick_components_flag => l_pick_components_flag,
3781 p_replenish_to_order_flag => l_replenish_to_order_flag
3782 );
3783 LOOP
3784
3785 FETCH c_common_sub_comps INTO l_common_sub_comps;
3786 EXIT WHEN c_common_sub_comps%NOTFOUND;
3787 INV_EBI_UTIL.DEBUG_LINE('STEP 60: BEFORE CALLING INV_EBI_CHANGE_ORDER_HELPER.process_assign_items for substitute components');
3788 INV_EBI_UTIL.DEBUG_LINE('STEP 70: SUBSTITUTE COMP NAME: '|| l_common_sub_comps.sub_comp_item_name);
3789 process_assign_items(
3790 p_organization_id => p_organization_id,
3791 p_item_name => l_common_sub_comps.sub_comp_item_name,
3792 x_return_status => x_return_status ,
3793 x_msg_data => x_msg_data ,
3794 x_msg_count => x_msg_count
3795 );
3796 INV_EBI_UTIL.DEBUG_LINE('STEP 80: AFTER CALLING INV_EBI_CHANGE_ORDER_HELPER.process_assign_items for substitute components STATUS :' || x_return_status);
3797
3798 IF (x_return_status <> FND_API.g_ret_sts_success) THEN
3799 RAISE FND_API.g_exc_unexpected_error;
3800 END IF;
3801 END LOOP;
3802 CLOSE c_common_sub_comps ;
3803 INV_EBI_UTIL.debug_line('STEP 90: END INSIDE INV_EBI_CHANGE_ORDER_HELPER.process_common_comps');
3804 EXCEPTION
3805 WHEN FND_API.g_exc_unexpected_error THEN
3806 ROLLBACK TO inv_ebi_comm_comp_save_pnt;
3807 IF (c_common_comps%ISOPEN) THEN
3808 CLOSE c_common_comps;
3809 END IF;
3810 IF (c_common_sub_comps%ISOPEN) THEN
3811 CLOSE c_common_sub_comps;
3812 END IF;
3813 x_return_status := FND_API.g_ret_sts_error;
3814 IF(x_msg_data IS NULL) THEN
3815 fnd_msg_pub.count_and_get(
3816 p_encoded => FND_API.g_false
3817 ,p_count => x_msg_count
3818 ,p_data => x_msg_data
3819 );
3820 END IF;
3821 WHEN OTHERS THEN
3822 ROLLBACK TO inv_ebi_comm_comp_save_pnt;
3823 IF (c_common_comps%ISOPEN) THEN
3824 CLOSE c_common_comps;
3825 END IF;
3826 IF (c_common_sub_comps%ISOPEN) THEN
3827 CLOSE c_common_sub_comps;
3828 END IF;
3829 x_return_status := FND_API.g_ret_sts_unexp_error;
3830 IF (x_msg_data IS NOT NULL) THEN
3831 x_msg_data := x_msg_data||' -> INV_EBI_CHANGE_ORDER_HELPER.process_common_comps ';
3832 ELSE
3833 x_msg_data := SQLERRM||' INV_EBI_CHANGE_ORDER_HELPER.process_common_comps ';
3834 END IF;
3835 END process_common_comps;
3836
3837
3838 /************************************************************************************
3839 -- API name : process_common_bom
3840 -- Type : Private
3841 -- Function :
3842 -- This API is used to determine the coomon bill sequence id and detremine the
3843 -- Common comps and common susbstitute comps.
3844 -- Bug 7127027
3845 ************************************************************************************/
3846
3847 PROCEDURE process_common_bom(
3848 p_organization_code IN VARCHAR2
3849 ,p_assembly_item_name IN VARCHAR2
3850 ,p_alternate_bom_code IN VARCHAR2
3851 ,p_common_assembly_item_name IN VARCHAR2
3852 ,p_common_organization_code IN VARCHAR2
3853 ,x_return_status OUT NOCOPY VARCHAR2
3854 ,x_msg_data OUT NOCOPY VARCHAR2
3855 ,x_msg_count OUT NOCOPY NUMBER
3856 )
3857 IS
3858 l_src_bill_sequence_id NUMBER;
3859 l_src_assembly_item_id NUMBER;
3860 l_src_organization_id NUMBER;
3861 l_assembly_item_id NUMBER;
3862 l_organization_id NUMBER;
3863
3864
3865 BEGIN
3866 SAVEPOINT inv_ebi_comm_bom_save_pnt;
3867 x_return_status := FND_API.G_RET_STS_SUCCESS;
3868 INV_EBI_UTIL.debug_line('STEP 10: START INSIDE INV_EBI_CHANGE_ORDER_HELPER.process_common_bom');
3869 INV_EBI_UTIL.debug_line('STEP 20: ORG CODE : '|| p_organization_code || ' ASSY ITEM NAME: '|| p_assembly_item_name ||
3870 ' COMMON ASSY ITEM NAME: '|| p_common_assembly_item_name || ' COMMON ORG CODE: '|| p_common_organization_code);
3871 l_src_organization_id := INV_EBI_ITEM_HELPER.get_organization_id(
3872 p_organization_code => p_common_organization_code
3873 );
3874 l_src_assembly_item_id := INV_EBI_ITEM_HELPER.get_inventory_item_id (
3875 p_organization_id => l_src_organization_id
3876 ,p_item_number => p_common_assembly_item_name
3877 );
3878 l_src_bill_sequence_id := get_bill_sequence_id(
3879 p_assembly_item_id => l_src_assembly_item_id,
3880 p_organization_id => l_src_organization_id,
3881 p_alternate_bom_code => p_alternate_bom_code
3882 );
3883 INV_EBI_UTIL.debug_line('STEP 30: ORG ID '|| l_src_organization_id || ' ASSY ITEM ID: '|| l_src_assembly_item_id ||
3884 'BILL SEQUENCE ID: '|| l_src_bill_sequence_id);
3885 IF(l_src_bill_sequence_id IS NULL ) THEN
3886 FND_MESSAGE.set_name('INV','INV_EBI_COMMON_BILL_NOT_FOUND');
3887 FND_MESSAGE.set_token('ASSY_ITEM', p_common_assembly_item_name);
3888 FND_MSG_PUB.add;
3889 RAISE FND_API.g_exc_error;
3890 END IF;
3891
3892 l_organization_id := INV_EBI_ITEM_HELPER.get_organization_id(
3893 p_organization_code => p_organization_code
3894 );
3895
3896 l_assembly_item_id := INV_EBI_ITEM_HELPER.get_inventory_item_id (
3897 p_organization_id => l_organization_id
3898 ,p_item_number => p_assembly_item_name
3899 );
3900 INV_EBI_UTIL.debug_line('STEP 40: ASST ITEM ID: '|| l_assembly_item_id || 'ORG ID: '|| l_organization_id );
3901 INV_EBI_UTIL.debug_line('STEP 50: BEFORE CALLING INV_EBI_CHANGE_ORDER_HELPER.process_common_comps ');
3902 process_common_comps(
3903 p_assembly_item_id => l_assembly_item_id,
3904 p_organization_id => l_organization_id,
3905 p_src_organization_id => l_src_organization_id,
3906 p_src_bill_sequence_id => l_src_bill_sequence_id,
3907 x_return_status => x_return_status,
3908 x_msg_data => x_msg_data,
3909 x_msg_count => x_msg_count
3910 );
3911 INV_EBI_UTIL.debug_line('STEP 60: AFTER CALLING INV_EBI_CHANGE_ORDER_HELPER.process_common_comps STATUS: '|| x_return_status);
3912 IF (x_return_status <> FND_API.g_ret_sts_success) THEN
3913 RAISE FND_API.g_exc_unexpected_error;
3914 END IF;
3915 INV_EBI_UTIL.debug_line('STEP 70: END INSIDE INV_EBI_CHANGE_ORDER_HELPER.process_common_bom ');
3916 EXCEPTION
3917 WHEN FND_API.g_exc_unexpected_error THEN
3918 ROLLBACK TO inv_ebi_comm_bom_save_pnt;
3919 x_return_status := FND_API.g_ret_sts_unexp_error;
3920 IF(x_msg_data IS NULL) THEN
3921 fnd_msg_pub.count_and_get(
3922 p_encoded => FND_API.g_false
3923 ,p_count => x_msg_count
3924 ,p_data => x_msg_data
3925 );
3926 END IF;
3927 WHEN FND_API.g_exc_error THEN
3928 ROLLBACK TO inv_ebi_comm_bom_save_pnt;
3929 x_return_status := FND_API.g_ret_sts_error;
3930 IF(x_msg_data IS NULL) THEN
3931 FND_MSG_PUB.count_and_get(
3932 p_encoded => FND_API.g_false
3933 ,p_count => x_msg_count
3934 ,p_data => x_msg_data
3935 );
3936 END IF;
3937 WHEN OTHERS THEN
3938 ROLLBACK TO inv_ebi_comm_bom_save_pnt;
3939 x_return_status := FND_API.g_ret_sts_unexp_error;
3940 IF (x_msg_data IS NOT NULL) THEN
3941 x_msg_data := x_msg_data ||' -> INV_EBI_CHANGE_ORDER_HELPER.process_common_bom ';
3942 ELSE
3943 x_msg_data := SQLERRM||' INV_EBI_CHANGE_ORDER_HELPER.process_common_bom ';
3944 END IF;
3945 END process_common_bom;
3946
3947 /************************************************************************************
3948 -- API name : get_common_bom_orgs
3949 -- Type : Private
3950 -- Function :
3951 -- This API is used to get orgs list to which a bom is commoned
3952 -- Bug 7196996
3953 ************************************************************************************/
3954 PROCEDURE get_common_bom_orgs(
3955 p_assembly_item_name IN VARCHAR2,
3956 p_organization_code IN VARCHAR2,
3957 p_alternate_bom_code IN VARCHAR2,
3958 x_common_orgs OUT NOCOPY inv_ebi_org_tbl,
3959 x_return_status OUT NOCOPY VARCHAR2,
3960 x_msg_data OUT NOCOPY VARCHAR2,
3961 x_msg_count OUT NOCOPY NUMBER
3962 ) IS
3963 l_bill_sequence_id NUMBER;
3964 l_organization_id NUMBER;
3965 l_assembly_item_id NUMBER;
3966 l_org_count NUMBER := 0;
3967
3968 CURSOR c_common_orgs(
3969 p_bill_sequence_id IN NUMBER,
3970 p_common_assy_item_id IN NUMBER,
3971 p_common_org_id IN NUMBER
3972 ) IS
3973
3974 SELECT organization_id
3975 FROM bom_bill_of_materials
3976 WHERE
3977 common_bill_sequence_id = p_bill_sequence_id AND
3978 common_assembly_item_id = p_common_assy_item_id AND
3979 common_organization_id = p_common_org_id;
3980
3981 BEGIN
3982 INV_EBI_UTIL.debug_line('STEP 10: START INSIDE INV_EBI_CHANGE_ORDER_HELPER.get_common_bom_orgs');
3983 INV_EBI_UTIL.debug_line('STEP 20: ASSY ITEM NAME: '|| p_assembly_item_name ||' ORG CODE: '|| p_organization_code);
3984
3985 x_return_status := FND_API.G_RET_STS_SUCCESS;
3986 l_organization_id := INV_EBI_ITEM_HELPER.get_organization_id(
3987 p_organization_code => p_organization_code
3988 );
3989
3990 l_assembly_item_id := INV_EBI_ITEM_HELPER.get_inventory_item_id (
3991 p_organization_id => l_organization_id
3992 ,p_item_number => p_assembly_item_name);
3993
3994 l_bill_sequence_id := get_bill_sequence_id(
3995 p_assembly_item_id => l_assembly_item_id,
3996 p_organization_id => l_organization_id,
3997 p_alternate_bom_code => p_alternate_bom_code
3998 );
3999 INV_EBI_UTIL.debug_line('STEP 30: ORG ID '|| l_organization_id || ' ASSY ITEM ID: '|| l_assembly_item_id || ' BILL SEQ ID: '|| l_bill_sequence_id);
4000 x_common_orgs := inv_ebi_org_tbl();
4001 FOR l_common_orgs IN c_common_orgs(
4002 p_bill_sequence_id => l_bill_sequence_id,
4003 p_common_assy_item_id => l_assembly_item_id,
4004 p_common_org_id => l_organization_id
4005 )
4006 LOOP
4007 IF(l_common_orgs.organization_id <> l_organization_id) THEN
4008 l_org_count := l_org_count + 1;
4009 x_common_orgs.extend();
4010 x_common_orgs(l_org_count) := inv_ebi_org_obj(NULL,NULL);
4011 x_common_orgs(l_org_count).org_id := l_common_orgs.organization_id;
4012 END IF;
4013 END LOOP;
4014 INV_EBI_UTIL.debug_line('STEP 40: END INSIDE INV_EBI_CHANGE_ORDER_HELPER.get_common_bom_orgs STATUS: '|| x_return_status);
4015 EXCEPTION
4016 WHEN OTHERS THEN
4017 x_return_status := FND_API.g_ret_sts_unexp_error;
4018 IF (x_msg_data IS NOT NULL) THEN
4019 x_msg_data := x_msg_data ||' -> INV_EBI_CHANGE_ORDER_HELPER.get_common_bom_orgs ';
4020 ELSE
4021 x_msg_data := SQLERRM||' INV_EBI_CHANGE_ORDER_HELPER.get_common_bom_orgs ';
4022 END IF;
4023 END get_common_bom_orgs;
4024
4025 /************************************************************************************
4026 -- API name : process_common_bom_orgs
4027 -- Type : Private
4028 -- Function :
4029 -- This API is used to Process bom and common bom.
4030 -- Bug 7196996
4031 ************************************************************************************/
4032 PROCEDURE process_common_bom_orgs(
4033 p_assembly_item_name IN VARCHAR2,
4034 p_organization_code IN VARCHAR2,
4035 p_alternate_bom_code IN VARCHAR2,
4036 p_component_item_tbl IN inv_ebi_rev_comp_tbl,
4037 x_out OUT NOCOPY inv_ebi_eco_output_obj
4038 ) IS
4039 l_common_orgs inv_ebi_org_tbl;
4040 l_output_status inv_ebi_output_status;
4041 l_count NUMBER;
4042 BEGIN
4043 SAVEPOINT inv_ebi_common_orgs_save_pnt;
4044 INV_EBI_UTIL.debug_line('STEP 10: START INSIDE INV_EBI_CHANGE_ORDER_HELPER.process_common_bom_orgs');
4045 INV_EBI_UTIL.debug_line('STEP 20: ASSY ITEM NAME: '|| p_assembly_item_name || ' ORG CODE: '|| p_organization_code);
4046
4047 l_output_status := inv_ebi_output_status(fnd_api.g_ret_sts_success,NULL,NULL,NULL);
4048 x_out := inv_ebi_eco_output_obj(NULL,NULL,NULL,NULL,l_output_status,NULL,NULL);
4049 l_common_orgs := inv_ebi_org_tbl();
4050
4051 --Get the list of orgs to which particular bom is commoned
4052 INV_EBI_UTIL.debug_line('STEP 30: BEFORE CALLING INV_EBI_CHANGE_ORDER_HELPER.get_common_bom_orgs');
4053 get_common_bom_orgs(
4054 p_assembly_item_name => p_assembly_item_name,
4055 p_organization_code => p_organization_code,
4056 p_alternate_bom_code => p_alternate_bom_code,
4057 x_common_orgs => l_common_orgs,
4058 x_return_status => x_out.output_status.return_status ,
4059 x_msg_data => x_out.output_status.msg_data ,
4060 x_msg_count => x_out.output_status.msg_count
4061 ) ;
4062 INV_EBI_UTIL.debug_line('STEP 40: AFTER CALLING INV_EBI_CHANGE_ORDER_HELPER.get_common_bom_orgs STATUS: '|| x_out.output_status.return_status);
4063 IF (x_out.output_status.return_status <> FND_API.g_ret_sts_success) THEN
4064 RAISE FND_API.g_exc_unexpected_error;
4065 END IF;
4066
4067 FOR i IN 1..l_common_orgs.COUNT LOOP
4068 IF(p_component_item_tbl IS NOT NULL AND p_component_item_tbl.COUNT > 0) THEN
4069 FOR j IN 1..p_component_item_tbl.COUNT LOOP
4070 IF( p_component_item_tbl(j).acd_type = 1 ) THEN
4071
4072 /*After commoning a bom to other orgs if components or sub com are added
4073 to source ensure that those comps and sub comps exists in all the commoned orgs */
4074 INV_EBI_UTIL.debug_line('STEP 50: BEFORE CALLING INV_EBI_CHANGE_ORDER_HELPER.process_assign_items');
4075 INV_EBI_UTIL.debug_line('STEP 60: ORG ID: '|| l_common_orgs(i).org_id || 'COMP ITEM NAME: '|| p_component_item_tbl(j).component_item_name);
4076 process_assign_items(
4077 p_organization_id => l_common_orgs(i).org_id,
4078 p_item_name => p_component_item_tbl(j).component_item_name,
4079 x_return_status => x_out.output_status.return_status ,
4080 x_msg_data => x_out.output_status.msg_data ,
4081 x_msg_count => x_out.output_status.msg_count
4082 );
4083 INV_EBI_UTIL.debug_line('STEP 70: AFTER CALLING INV_EBI_CHANGE_ORDER_HELPER.process_assign_items STATUS: '|| x_out.output_status.return_status);
4084 IF (x_out.output_status.return_status <> FND_API.g_ret_sts_success) THEN
4085 RAISE FND_API.g_exc_unexpected_error;
4086 END IF;
4087 END IF;
4088
4089 IF( p_component_item_tbl(j).substitute_component_tbl IS NOT NULL AND
4090 p_component_item_tbl(j).substitute_component_tbl .COUNT > 0) THEN
4091 FOR k IN 1..p_component_item_tbl(j).substitute_component_tbl.COUNT LOOP
4092
4093 IF(p_component_item_tbl(j).substitute_component_tbl(k).acd_type = 1) THEN
4094 INV_EBI_UTIL.debug_line('STEP 80: BEFORE CALLING INV_EBI_CHANGE_ORDER_HELPER.process_assign_items FOR SUBSTITUTE COMPONENTS');
4095 INV_EBI_UTIL.debug_line('STEP 90: SUBS COMP ITEM NAME: '|| p_component_item_tbl(j).substitute_component_tbl(k).substitute_component_name);
4096 process_assign_items(
4097 p_organization_id => l_common_orgs(i).org_id,
4098 p_item_name => p_component_item_tbl(j).substitute_component_tbl(k).substitute_component_name,
4099 x_return_status => x_out.output_status.return_status ,
4100 x_msg_data => x_out.output_status.msg_data ,
4101 x_msg_count => x_out.output_status.msg_count
4102 );
4103 INV_EBI_UTIL.debug_line('STEP 100: AFTER CALLING INV_EBI_CHANGE_ORDER_HELPER.process_assign_items STATUS: '|| x_out.output_status.return_status);
4104 IF (x_out.output_status.return_status <> FND_API.g_ret_sts_success) THEN
4105 RAISE FND_API.g_exc_unexpected_error;
4106 END IF;
4107 END IF;
4108 END LOOP;
4109 END IF;
4110 END LOOP;
4111 END IF;
4112 END LOOP;
4113 INV_EBI_UTIL.debug_line('STEP 110: END INSIDE INV_EBI_CHANGE_ORDER_HELPER.process_common_bom_orgs ');
4114 EXCEPTION
4115 WHEN FND_API.g_exc_unexpected_error THEN
4116 ROLLBACK TO inv_ebi_common_orgs_save_pnt;
4117 x_out.output_status.return_status := FND_API.g_ret_sts_unexp_error;
4118 IF(x_out.output_status.msg_data IS NULL) THEN
4119 fnd_msg_pub.count_and_get(
4120 p_encoded => FND_API.g_false
4121 ,p_count => x_out.output_status.msg_count
4122 ,p_data => x_out.output_status.msg_data
4123 );
4124 END IF;
4125 WHEN OTHERS THEN
4126 ROLLBACK TO inv_ebi_common_orgs_save_pnt;
4127 x_out.output_status.return_status := FND_API.g_ret_sts_unexp_error;
4128 IF (x_out.output_status.msg_data IS NOT NULL) THEN
4129 x_out.output_status.msg_data := x_out.output_status.msg_data||' -> INV_EBI_CHANGE_ORDER_HELPER.process_common_bom_orgs ';
4130 ELSE
4131 x_out.output_status.msg_data := SQLERRM||' INV_EBI_CHANGE_ORDER_HELPER.process_common_bom_orgs ';
4132 END IF;
4133 END process_common_bom_orgs;
4134
4135 /************************************************************************************
4136 -- API name : process_eco
4137 -- Type : Private
4138 -- Function :
4139 -- This API is used to create the change order.
4140 --
4141 ************************************************************************************/
4142 PROCEDURE process_eco(
4143 p_commit IN VARCHAR2 := FND_API.G_FALSE
4144 ,p_change_order IN inv_ebi_change_order_obj
4145 ,p_revision_type_tbl IN inv_ebi_eco_revision_tbl
4146 ,p_revised_item_type_tbl IN inv_ebi_revised_item_tbl
4147 ,p_name_val_list IN inv_ebi_name_value_list
4148 ,x_out OUT NOCOPY inv_ebi_eco_output_obj
4149 ) IS
4150 l_eco_rec ENG_ECO_PUB.eco_rec_type;
4151 l_eco_revision_tbl ENG_ECO_PUB.eco_revision_tbl_type;
4152 l_revised_item_tbl ENG_ECO_PUB.revised_item_tbl_type;
4153 l_revised_item_tbl_count NUMBER := 1;
4154 l_rev_component_tbl BOM_BO_PUB.rev_component_tbl_type;
4155 l_rev_component_tbl_count NUMBER :=1;
4156 l_ref_designator_tbl BOM_BO_PUB.ref_designator_tbl_type;
4157 l_ref_designator_tbl_count NUMBER :=1;
4158 l_sub_component_tbl BOM_BO_PUB.sub_component_tbl_type;
4159 l_sub_component_tbl_count NUMBER :=1;
4160 l_rev_operation_tbl BOM_RTG_PUB.rev_operation_tbl_type;
4161 l_rev_operation_tbl_count NUMBER :=1;
4162 l_rev_op_resource_tbl BOM_RTG_PUB.rev_op_resource_tbl_type;
4163 l_rev_op_resource_tbl_count NUMBER :=1;
4164 l_rev_sub_resource_tbl BOM_RTG_PUB.rev_sub_resource_tbl_type;
4165 l_rev_sub_resource_tbl_count NUMBER :=1;
4166 l_change_line_tbl ENG_ECO_PUB.change_line_tbl_type;
4167 l_revision VARCHAR2(3);
4168 l_is_component_item_exists VARCHAR2(3);
4169 l_api_version NUMBER:=1.0;
4170 l_item_org_assignment_rec EGO_ITEM_PUB.item_org_assignment_rec_type;
4171 l_item_org_assignment_tbl EGO_ITEM_PUB.item_org_assignment_tbl_type;
4172 l_inventory_item_id NUMBER;
4173 l_organization_id NUMBER;
4174 l_component_item_name VARCHAR2(240);
4175 l_master_org NUMBER;
4176 l_pk_col_name_val_pairs INV_EBI_ITEM_HELPER.inv_ebi_name_value_pair_tbl;
4177 l_subst_comp_name mtl_system_items_kfv.concatenated_segments%TYPE;
4178 l_return_status VARCHAR2(10);
4179 l_msg_count NUMBER;
4180 l_output_status inv_ebi_output_status;
4181 l_status_type NUMBER;
4182 l_priority_code VARCHAR2(10);
4183 l_is_wf_Set BOOLEAN;
4184 l_approval_status NUMBER :=0;
4185 l_plm_or_erp VARCHAR2(1):=FND_API.G_TRUE;
4186 l_old_effectivity_date DATE;
4187 l_old_op_sequence_num NUMBER;
4188 l_old_fm_end_item_unit NUMBER;
4189 l_acd_update CONSTANT NUMBER :=2;
4190 l_acd_delete CONSTANT NUMBER :=3;
4191 l_revised_item_id NUMBER;
4192 l_effectivity_date DATE;
4193 l_change_type_code VARCHAR2(80);
4194 l_status_name VARCHAR2(30);
4195 l_bom_update_without_eco VARCHAR2(1) := FND_API.G_TRUE;
4196 l_allow_unimp_bom_update VARCHAR2(1) := NULL;
4197
4198 BEGIN
4199 SAVEPOINT inv_ebi_proc_eco_save_pnt;
4200 INV_EBI_UTIL.debug_line('STEP 10: START INSIDE INV_EBI_CHANGE_ORDER_HELPER.process_eco');
4201 INV_EBI_UTIL.debug_line('STEP 20: ECO NUMBER: '|| p_change_order.eco_name || ' ORG CODE: '|| p_change_order.organization_code);
4202
4203 l_output_status := inv_ebi_output_status(fnd_api.g_ret_sts_success,NULL,NULL,NULL);
4204 x_out := inv_ebi_eco_output_obj(NULL,NULL,NULL,NULL,l_output_status,NULL,NULL);
4205
4206 l_pk_col_name_val_pairs := INV_EBI_ITEM_HELPER.inv_ebi_name_value_pair_tbl();
4207 l_pk_col_name_val_pairs.EXTEND(1);
4208 l_pk_col_name_val_pairs(1).name := 'organization_code';
4209 l_pk_col_name_val_pairs(1).value := p_change_order.organization_code;
4210
4211 l_organization_id := INV_EBI_ITEM_HELPER.value_to_id(
4212 p_pk_col_name_val_pairs => l_pk_col_name_val_pairs
4213 ,p_entity_name => INV_EBI_ITEM_HELPER.G_ORGANIZATION
4214 );
4215 l_pk_col_name_val_pairs.TRIM(1);
4216
4217 IF (l_organization_id IS NULL) THEN
4218 FND_MESSAGE.set_name('INV','INV_EBI_ORG_CODE_INVALID');
4219 FND_MESSAGE.set_token('COL_VALUE', p_change_order.organization_code);
4220 FND_MSG_PUB.add;
4221 RAISE FND_API.g_exc_unexpected_error;
4222 END IF;
4223
4224 -- Code to incorporate the DVM changes
4225 -- ECO_TYPECODE
4226 l_change_type_code := p_change_order.change_type_code;
4227
4228 IF( p_change_order.change_type_id IS NOT NULL AND
4229 p_change_order.change_type_id <> fnd_api.g_miss_num) THEN
4230 l_change_type_code := get_change_type_code(p_change_type_id => p_change_order.change_type_id);
4231 END IF;
4232
4233 -- ECO_STATUS_CODE
4234
4235 l_status_name := p_change_order.status_name;
4236
4237 IF( p_change_order.status_code IS NOT NULL AND
4238 p_change_order.status_code <> fnd_api.g_miss_num) THEN
4239 l_status_name := get_eco_status_name(p_status_code => p_change_order.status_code);
4240 END IF;
4241
4242 IF p_name_val_list.name_value_table IS NOT NULL THEN
4243 FOR i in p_name_val_list.name_value_table.FIRST..p_name_val_list.name_value_table.LAST LOOP
4244
4245 IF (UPPER(p_name_val_list.name_value_table(i).param_name) = G_PLM_OR_ERP_CHANGE) THEN
4246
4247 l_plm_or_erp := p_name_val_list.name_value_table(i).param_value;
4248
4249 --Bug 8340804
4250 ELSIF(UPPER(p_name_val_list.name_value_table(i).param_name) = G_BOM_UPDATES_ALLOWED) THEN
4251
4252 l_bom_update_without_eco := p_name_val_list.name_value_table(i).param_value;
4253
4254 -- Bug 10423301
4255 ELSIF(UPPER(p_name_val_list.name_value_table(i).param_name) = G_ALLOW_UNIMP_BOM_UPDATES) THEN
4256
4257 l_allow_unimp_bom_update := p_name_val_list.name_value_table(i).param_value;
4258
4259 END IF;
4260 END LOOP;
4261 END IF;
4262
4263 l_is_wf_Set := Check_Workflow_Process(p_change_order_type_id => p_change_order.change_type_id
4264 ,p_priority_code => p_change_order.priority_code
4265 );
4266 IF (p_change_order IS NOT NULL) THEN
4267 l_eco_rec.eco_name := p_change_order.eco_name;
4268 l_eco_rec.change_notice_prefix := p_change_order.change_notice_prefix;
4269 l_eco_rec.change_notice_number := p_change_order.change_notice_number;
4270 l_eco_rec.organization_code := p_change_order.organization_code ;
4271 l_eco_rec.change_name := p_change_order.change_name;
4272 l_eco_rec.description := p_change_order.description;
4273 l_eco_rec.cancellation_comments := p_change_order.cancellation_comments ;
4274 BEGIN
4275 IF (l_is_wf_Set) THEN
4276 SELECT status_name, status_type
4277 INTO l_eco_rec.status_name, l_status_type
4278 FROM eng_change_statuses_vl
4279 WHERE status_code = 1; -- ECO Status Set to 'Open';
4280 l_eco_rec.approval_status_name := get_status_name(p_lookup_type => 'ENG_ECN_APPROVAL_STATUS'
4281 ,p_lookup_code => 1 ); -- Not submitted for approval
4282 ELSE
4283 l_eco_rec.status_name := l_status_name;
4284 IF (l_eco_rec.status_name = 'Implemented' ) THEN
4285 SELECT status_name, status_type
4286 INTO l_eco_rec.status_name, l_status_type
4287 FROM eng_change_statuses_vl
4288 WHERE status_code = 4; -- Scheduled
4289 END IF;
4290 l_eco_rec.approval_status_name := get_status_name(p_lookup_type => 'ENG_ECN_APPROVAL_STATUS'
4291 ,p_lookup_code => 5 ); -- Approved
4292 END IF;
4293 EXCEPTION
4294 WHEN OTHERS THEN
4295 NULL;
4296 END;
4297 l_eco_rec.priority_code := p_change_order.priority_code ;
4298 l_eco_rec.reason_code := p_change_order.reason_code;
4299 l_eco_rec.eng_implementation_cost := p_change_order.eng_implementation_cost;
4300 l_eco_rec.mfg_implementation_cost := p_change_order.mfg_implementation_cost;
4301 l_eco_rec.requestor := p_change_order.requestor;
4302 l_eco_rec.attribute_category := p_change_order.attribute_category ;
4303 l_eco_rec.attribute1 := p_change_order.attribute1 ;
4304 l_eco_rec.attribute2 := p_change_order.attribute2 ;
4305 l_eco_rec.attribute3 := p_change_order.attribute3 ;
4306 l_eco_rec.attribute4 := p_change_order.attribute4 ;
4307 l_eco_rec.attribute5 := p_change_order.attribute5 ;
4308 l_eco_rec.attribute6 := p_change_order.attribute6 ;
4309 l_eco_rec.attribute7 := p_change_order.attribute7 ;
4310 l_eco_rec.attribute8 := p_change_order.attribute8 ;
4311 l_eco_rec.attribute9 := p_change_order.attribute9 ;
4312 l_eco_rec.attribute10 := p_change_order.attribute10;
4313 l_eco_rec.attribute11 := p_change_order.attribute11 ;
4314 l_eco_rec.attribute12 := p_change_order.attribute12;
4315 l_eco_rec.attribute13 := p_change_order.attribute13;
4316 l_eco_rec.attribute14 := p_change_order.attribute14;
4317 l_eco_rec.attribute15 := p_change_order.attribute15;
4318 l_eco_rec.ddf_context := p_change_order.ddf_context ;
4319 l_eco_rec.approval_list_name := p_change_order.approval_list_name ;
4320 l_eco_rec.approval_date := p_change_order.approval_date;
4321 l_eco_rec.approval_request_date := p_change_order.approval_request_date ;
4322 l_eco_rec.change_type_code := l_change_type_code ;
4323 l_eco_rec.change_management_type := p_change_order.change_management_type ;
4324 l_eco_rec.original_system_reference := p_change_order.original_system_reference;
4325 l_eco_rec.organization_hierarchy := p_change_order.organization_hierarchy;
4326 l_eco_rec.assignee := p_change_order.assignee ;
4327 l_eco_rec.project_name := p_change_order.project_name ;
4328 l_eco_rec.task_number := p_change_order.task_number;
4329 l_eco_rec.source_type := p_change_order.source_type;
4330 l_eco_rec.source_name := p_change_order.source_name ;
4331 l_eco_rec.need_by_date := p_change_order.need_by_date ;
4332 l_eco_rec.effort := p_change_order.effort;
4333 l_eco_rec.eco_department_name := p_change_order.eco_department_name;
4334 l_eco_rec.transaction_id := p_change_order.transaction_id;
4335 l_eco_rec.transaction_type := p_change_order.transaction_type ;
4336 l_eco_rec.internal_use_only := p_change_order.internal_use_only ;
4337 l_eco_rec.return_status := p_change_order.return_status ;
4338 IF (p_change_order.plm_or_erp_change IS NOT NULL AND p_change_order.plm_or_erp_change <> fnd_api.g_miss_char ) THEN
4339 l_eco_rec.plm_or_erp_change := p_change_order.plm_or_erp_change ;
4340 ELSE
4341 IF (l_plm_or_erp = FND_API.G_FALSE) THEN
4342 l_eco_rec.plm_or_erp_change := 'PLM';
4343 ELSE
4344 l_eco_rec.plm_or_erp_change := 'ERP';
4345 END IF;
4346 END IF;
4347 l_eco_rec.pk1_name := p_change_order.pk1_name ;
4348 l_eco_rec.pk2_name := p_change_order.pk2_name;
4349 l_eco_rec.pk3_name := p_change_order.pk3_name;
4350 l_eco_rec.employee_number := p_change_order.employee_number;
4351 END IF;
4352 IF(p_revision_type_tbl IS NOT NULL AND p_revision_type_tbl.COUNT > 0) THEN
4353 FOR i IN 1..p_revision_type_tbl.COUNT
4354 LOOP
4355
4356 l_eco_revision_tbl(i).eco_name := p_change_order.eco_name ;
4357 l_eco_revision_tbl(i).organization_code := p_change_order.organization_code ;
4358 l_eco_revision_tbl(i).revision := p_revision_type_tbl(i).revision ;
4359 l_eco_revision_tbl(i).new_revision := p_revision_type_tbl(i).new_revision ;
4360 l_eco_revision_tbl(i).comments := p_revision_type_tbl(i).comments;
4361 l_eco_revision_tbl(i).attribute_category := p_revision_type_tbl(i).attribute_category ;
4362 l_eco_revision_tbl(i).attribute1 := p_revision_type_tbl(i).attribute1 ;
4363 l_eco_revision_tbl(i).attribute2 := p_revision_type_tbl(i).attribute2 ;
4364 l_eco_revision_tbl(i).attribute3 := p_revision_type_tbl(i).attribute3 ;
4365 l_eco_revision_tbl(i).attribute4 := p_revision_type_tbl(i).attribute4 ;
4366 l_eco_revision_tbl(i).attribute5 := p_revision_type_tbl(i).attribute5 ;
4367 l_eco_revision_tbl(i).attribute6 := p_revision_type_tbl(i).attribute6 ;
4368 l_eco_revision_tbl(i).attribute7 := p_revision_type_tbl(i).attribute7 ;
4369 l_eco_revision_tbl(i).attribute8 := p_revision_type_tbl(i).attribute8 ;
4370 l_eco_revision_tbl(i).attribute9 := p_revision_type_tbl(i).attribute9 ;
4371 l_eco_revision_tbl(i).attribute10 := p_revision_type_tbl(i).attribute10;
4372 l_eco_revision_tbl(i).attribute11 := p_revision_type_tbl(i).attribute11 ;
4373 l_eco_revision_tbl(i).attribute12 := p_revision_type_tbl(i).attribute12 ;
4374 l_eco_revision_tbl(i).attribute13 := p_revision_type_tbl(i).attribute13 ;
4375 l_eco_revision_tbl(i).attribute14 := p_revision_type_tbl(i).attribute14 ;
4376 l_eco_revision_tbl(i).attribute15 := p_revision_type_tbl(i).attribute15 ;
4377 l_eco_revision_tbl(i).change_management_type := p_revision_type_tbl(i).change_management_type ;
4378 l_eco_revision_tbl(i).original_system_reference := p_revision_type_tbl(i).original_system_reference ;
4379 l_eco_revision_tbl(i).return_status := p_revision_type_tbl(i).return_status ;
4380 l_eco_revision_tbl(i).transaction_type := p_revision_type_tbl(i).transaction_type ;
4381 l_eco_revision_tbl(i).transaction_id := p_revision_type_tbl(i).transaction_id ;
4382 END LOOP;
4383 END IF;
4384 IF(p_revised_item_type_tbl IS NOT NULL AND p_revised_item_type_tbl.COUNT > 0) THEN
4385 FOR i IN p_revised_item_type_tbl.FIRST..p_revised_item_type_tbl.LAST
4386 LOOP
4387 l_inventory_item_id := INV_EBI_ITEM_HELPER.get_inventory_item_id (
4388 p_organization_id => l_organization_id
4389 ,p_item_number => p_revised_item_type_tbl(i).revised_item_name
4390 );
4391 -- To get effectivty date of recently created revision Bug 7197943
4392
4393 l_effectivity_date := get_latest_effectivity_date(
4394 p_inventory_item_id => l_inventory_item_id,
4395 p_organization_id => l_organization_id,
4396 p_new_revision => p_revised_item_type_tbl(i).new_revised_item_revision -- Added for bug 14032254
4397 );
4398
4399 -- Bug# 7662420
4400 -- If the effective date that we get from the DB is less then the sysdate
4401 -- If the incomming date from end system is null or miss date
4402 -- Then take the max of sysdate or effective date.
4403
4404 IF(l_effectivity_date < SYSDATE ) THEN
4405 l_effectivity_date := SYSDATE ;
4406 END IF;
4407
4408 l_revised_item_tbl(l_revised_item_tbl_count).eco_name := p_change_order.eco_name ;
4409 l_revised_item_tbl(l_revised_item_tbl_count).organization_code := p_change_order.organization_code ;
4410 l_revised_item_tbl(l_revised_item_tbl_count).revised_item_name := p_revised_item_type_tbl(i).revised_item_name ;
4411
4412 IF(p_revised_item_type_tbl(i).new_revised_item_revision = p_revised_item_type_tbl(i).from_item_revision) THEN
4413 --Bug 7119898 If a change order already exists for the revision being sent in, set the revision to NULL
4414 IF (is_new_revision_exists(
4415 p_item_number => l_revised_item_tbl(l_revised_item_tbl_count).revised_item_name,
4416 p_revision => p_revised_item_type_tbl(i).new_revised_item_revision,
4417 p_org_code => l_revised_item_tbl(l_revised_item_tbl_count).organization_code
4418 ) = FND_API.g_true ) THEN
4419 l_revised_item_tbl(l_revised_item_tbl_count).new_revised_item_revision := NULL;
4420 l_revised_item_tbl(l_revised_item_tbl_count).from_item_revision := p_revised_item_type_tbl(i).from_item_revision ;
4421 ELSE
4422 l_revised_item_tbl(l_revised_item_tbl_count).new_revised_item_revision := p_revised_item_type_tbl(i).new_revised_item_revision;
4423 l_revised_item_tbl(l_revised_item_tbl_count).from_item_revision := NULL ;
4424 END IF;
4425 ELSE
4426 l_revised_item_tbl(l_revised_item_tbl_count).new_revised_item_revision := p_revised_item_type_tbl(i).new_revised_item_revision;
4427 l_revised_item_tbl(l_revised_item_tbl_count).from_item_revision := p_revised_item_type_tbl(i).from_item_revision ;
4428 END IF;
4429
4430 l_revised_item_tbl(l_revised_item_tbl_count).new_revised_item_rev_desc := p_revised_item_type_tbl(i).new_revised_item_rev_desc;
4431 l_revised_item_tbl(l_revised_item_tbl_count).updated_revised_item_revision := p_revised_item_type_tbl(i).upd_revised_item_revision;
4432 IF (p_revised_item_type_tbl(i).start_effective_date < l_effectivity_date
4433 OR p_revised_item_type_tbl(i).start_effective_date IS NULL
4434 OR p_revised_item_type_tbl(i).start_effective_date = fnd_api.g_miss_date) THEN
4435 l_revised_item_tbl(l_revised_item_tbl_count).start_effective_date := l_effectivity_date + 1/86400; -- BUG 7197943 To keep efectivity date of next rev 1 sec higher than earlier rev
4436 ELSE
4437 l_revised_item_tbl(l_revised_item_tbl_count).start_effective_date := p_revised_item_type_tbl(i).start_effective_date;
4438 END IF;
4439 IF (p_revised_item_type_tbl(i).new_effective_date < l_effectivity_date
4440 OR p_revised_item_type_tbl(i).new_effective_date IS NULL
4441 OR p_revised_item_type_tbl(i).new_effective_date = fnd_api.g_miss_date) THEN
4442 l_revised_item_tbl(l_revised_item_tbl_count).new_effective_date := l_effectivity_date + 1/86400; --BUG 7197943 To keep efectivity date of next rev 1 sec higher than earlier rev
4443 ELSE
4444 l_revised_item_tbl(l_revised_item_tbl_count).new_effective_date := p_revised_item_type_tbl(i).new_effective_date ;
4445 END IF;
4446 l_revised_item_tbl(l_revised_item_tbl_count).alternate_bom_code := p_revised_item_type_tbl(i).alternate_bom_code ;
4447
4448 -- To set the status of revisied Item based on the ECO status:
4449 l_revised_item_tbl(l_revised_item_tbl_count).status_type := l_status_type;
4450
4451 l_revised_item_tbl(l_revised_item_tbl_count).mrp_active := p_revised_item_type_tbl(i).mrp_active ;
4452 l_revised_item_tbl(l_revised_item_tbl_count).earliest_effective_date := p_revised_item_type_tbl(i).earliest_effective_date ;
4453 l_revised_item_tbl(l_revised_item_tbl_count).use_up_item_name := p_revised_item_type_tbl(i).use_up_item_name;
4454 l_revised_item_tbl(l_revised_item_tbl_count).use_up_plan_name := p_revised_item_type_tbl(i).use_up_plan_name ;
4455 l_revised_item_tbl(l_revised_item_tbl_count).requestor := p_revised_item_type_tbl(i).requestor ;
4456 l_revised_item_tbl(l_revised_item_tbl_count).disposition_type := p_revised_item_type_tbl(i).disposition_type ;
4457 l_revised_item_tbl(l_revised_item_tbl_count).update_wip := p_revised_item_type_tbl(i).up_wip ;
4458 l_revised_item_tbl(l_revised_item_tbl_count).cancel_comments := p_revised_item_type_tbl(i).cancel_comments ;
4459 l_revised_item_tbl(l_revised_item_tbl_count).change_description := p_revised_item_type_tbl(i).change_description;
4460 l_revised_item_tbl(l_revised_item_tbl_count).attribute_category := p_revised_item_type_tbl(i).attribute_category;
4461 l_revised_item_tbl(l_revised_item_tbl_count).attribute1 := p_revised_item_type_tbl(i).attribute1;
4462 l_revised_item_tbl(l_revised_item_tbl_count).attribute2 := p_revised_item_type_tbl(i).attribute2 ;
4463 l_revised_item_tbl(l_revised_item_tbl_count).attribute3 := p_revised_item_type_tbl(i).attribute3 ;
4464 l_revised_item_tbl(l_revised_item_tbl_count).attribute4 := p_revised_item_type_tbl(i).attribute4;
4465 l_revised_item_tbl(l_revised_item_tbl_count).attribute5 := p_revised_item_type_tbl(i).attribute5;
4466 l_revised_item_tbl(l_revised_item_tbl_count).attribute6 := p_revised_item_type_tbl(i).attribute6;
4467 l_revised_item_tbl(l_revised_item_tbl_count).attribute7 := p_revised_item_type_tbl(i).attribute7;
4468 l_revised_item_tbl(l_revised_item_tbl_count).attribute8 := p_revised_item_type_tbl(i).attribute8;
4469 l_revised_item_tbl(l_revised_item_tbl_count).attribute9 := p_revised_item_type_tbl(i).attribute9 ;
4470 l_revised_item_tbl(l_revised_item_tbl_count).attribute10 := p_revised_item_type_tbl(i).attribute10;
4471 l_revised_item_tbl(l_revised_item_tbl_count).attribute11 := p_revised_item_type_tbl(i).attribute11;
4472 l_revised_item_tbl(l_revised_item_tbl_count).attribute12 := p_revised_item_type_tbl(i).attribute12;
4473 l_revised_item_tbl(l_revised_item_tbl_count).attribute13 := p_revised_item_type_tbl(i).attribute13;
4474 l_revised_item_tbl(l_revised_item_tbl_count).attribute14 := p_revised_item_type_tbl(i).attribute14;
4475 l_revised_item_tbl(l_revised_item_tbl_count).attribute15 := p_revised_item_type_tbl(i).attribute15 ;
4476 l_revised_item_tbl(l_revised_item_tbl_count).from_end_item_unit_number := p_revised_item_type_tbl(i).from_end_item_unit_number;
4477 l_revised_item_tbl(l_revised_item_tbl_count).new_from_end_item_unit_number := p_revised_item_type_tbl(i).new_from_end_item_unit_number ;
4478 l_revised_item_tbl(l_revised_item_tbl_count).original_system_reference := p_revised_item_type_tbl(i).original_system_reference ;
4479 l_revised_item_tbl(l_revised_item_tbl_count).return_status := p_revised_item_type_tbl(i).return_status ;
4480 l_revised_item_tbl(l_revised_item_tbl_count).transaction_type := p_revised_item_type_tbl(i).transaction_type ;
4481 l_revised_item_tbl(l_revised_item_tbl_count).transaction_id := p_revised_item_type_tbl(i).transaction_id ;
4482 l_revised_item_tbl(l_revised_item_tbl_count).from_work_order := p_revised_item_type_tbl(i).from_work_order ;
4483 l_revised_item_tbl(l_revised_item_tbl_count).to_work_order := p_revised_item_type_tbl(i).to_work_order;
4484 l_revised_item_tbl(l_revised_item_tbl_count).from_cumulative_quantity := p_revised_item_type_tbl(i).from_cumulative_quantity ;
4485 l_revised_item_tbl(l_revised_item_tbl_count).lot_number := p_revised_item_type_tbl(i).lot_number ;
4486 l_revised_item_tbl(l_revised_item_tbl_count).completion_subinventory := p_revised_item_type_tbl(i).completion_subinventory ;
4487 l_revised_item_tbl(l_revised_item_tbl_count).completion_location_name := p_revised_item_type_tbl(i).completion_location_name;
4488 l_revised_item_tbl(l_revised_item_tbl_count).priority := p_revised_item_type_tbl(i).priority ;
4489 l_revised_item_tbl(l_revised_item_tbl_count).ctp_flag := p_revised_item_type_tbl(i).ctp_flag;
4490 l_revised_item_tbl(l_revised_item_tbl_count).new_routing_revision := p_revised_item_type_tbl(i).new_routing_revision ;
4491 l_revised_item_tbl(l_revised_item_tbl_count).updated_routing_revision := p_revised_item_type_tbl(i).upd_routing_revision ;
4492 l_revised_item_tbl(l_revised_item_tbl_count).routing_comment := p_revised_item_type_tbl(i).routing_comment ;
4493 l_revised_item_tbl(l_revised_item_tbl_count).eco_for_production := p_revised_item_type_tbl(i).eco_for_production;
4494 l_revised_item_tbl(l_revised_item_tbl_count).change_management_type := p_revised_item_type_tbl(i).change_management_type;
4495 l_revised_item_tbl(l_revised_item_tbl_count).transfer_or_copy := p_revised_item_type_tbl(i).transfer_or_copy;
4496 l_revised_item_tbl(l_revised_item_tbl_count).transfer_or_copy_item := p_revised_item_type_tbl(i).transfer_or_copy_item ;
4497 l_revised_item_tbl(l_revised_item_tbl_count).transfer_or_copy_bill := p_revised_item_type_tbl(i).transfer_or_copy_bill ;
4498 l_revised_item_tbl(l_revised_item_tbl_count).transfer_or_copy_routing := p_revised_item_type_tbl(i).transfer_or_copy_routing;
4499 l_revised_item_tbl(l_revised_item_tbl_count).copy_to_item := p_revised_item_type_tbl(i).copy_to_item ;
4500 l_revised_item_tbl(l_revised_item_tbl_count).copy_to_item_desc := p_revised_item_type_tbl(i).copy_to_item_desc ;
4501 l_revised_item_tbl(l_revised_item_tbl_count).parent_revised_item_name := p_revised_item_type_tbl(i).parent_revised_item_name;
4502 l_revised_item_tbl(l_revised_item_tbl_count).parent_alternate_name := p_revised_item_type_tbl(i).parent_alternate_name;
4503 l_revised_item_tbl(l_revised_item_tbl_count).selection_option := p_revised_item_type_tbl(i).selection_option ;
4504 l_revised_item_tbl(l_revised_item_tbl_count).selection_date := p_revised_item_type_tbl(i).selection_date ;
4505 l_revised_item_tbl(l_revised_item_tbl_count).selection_unit_number := p_revised_item_type_tbl(i).selection_unit_number;
4506 l_revised_item_tbl(l_revised_item_tbl_count).current_lifecycle_phase_name := p_revised_item_type_tbl(i).current_lifecycle_phase_name ;
4507 l_revised_item_tbl(l_revised_item_tbl_count).new_lifecycle_phase_name := p_revised_item_type_tbl(i).new_lifecycle_phase_name ;
4508 l_revised_item_tbl(l_revised_item_tbl_count).from_end_item_revision := p_revised_item_type_tbl(i).from_end_item_revision;
4509 l_revised_item_tbl(l_revised_item_tbl_count).from_end_item_strc_rev := p_revised_item_type_tbl(i).from_end_item_strc_rev ;
4510 l_revised_item_tbl(l_revised_item_tbl_count).enable_item_in_local_org := p_revised_item_type_tbl(i).enable_item_in_local_org ;
4511 l_revised_item_tbl(l_revised_item_tbl_count).create_bom_in_local_org := p_revised_item_type_tbl(i).create_bom_in_local_org ;
4512 l_revised_item_tbl(l_revised_item_tbl_count).new_structure_revision := p_revised_item_type_tbl(i).new_structure_revision ;
4513 l_revised_item_tbl(l_revised_item_tbl_count).plan_level := p_revised_item_type_tbl(i).plan_level ;
4514 l_revised_item_tbl(l_revised_item_tbl_count).from_end_item_name := p_revised_item_type_tbl(i).from_end_item_name ;
4515 l_revised_item_tbl(l_revised_item_tbl_count).from_end_item_alternate := p_revised_item_type_tbl(i).from_end_item_alternate ;
4516 l_revised_item_tbl(l_revised_item_tbl_count).current_structure_rev_name := p_revised_item_type_tbl(i).current_structure_rev_name;
4517 l_revised_item_tbl(l_revised_item_tbl_count).reschedule_comments := p_revised_item_type_tbl(i).reschedule_comments ;
4518
4519 l_revised_item_tbl(l_revised_item_tbl_count).new_revision_label := p_revised_item_type_tbl(i).new_revision_label ;
4520 l_revised_item_tbl(l_revised_item_tbl_count).new_revision_reason := p_revised_item_type_tbl(i).new_revision_reason;
4521 l_revised_item_tbl(l_revised_item_tbl_count).structure_type_name := p_revised_item_type_tbl(i).structure_type_name ;
4522
4523
4524 IF(p_revised_item_type_tbl(i).component_item_tbl IS NOT NULL AND p_revised_item_type_tbl(i).component_item_tbl.COUNT > 0) THEN
4525
4526 -- If BOM already commoned create component in all commoned orgs
4527 INV_EBI_UTIL.debug_line('STEP 30: BEFORE CALLING INV_EBI_CHANGE_ORDER_HELPER.process_common_bom_orgs '||
4528 'REVISED ITEM NAME: '|| l_revised_item_tbl(l_revised_item_tbl_count).revised_item_name ||
4529 'ORG CODE: '|| l_revised_item_tbl(l_revised_item_tbl_count).organization_code);
4530 process_common_bom_orgs(
4531 p_assembly_item_name => l_revised_item_tbl(l_revised_item_tbl_count).revised_item_name,
4532 p_organization_code => l_revised_item_tbl(l_revised_item_tbl_count).organization_code,
4533 p_alternate_bom_code => l_revised_item_tbl(l_revised_item_tbl_count).alternate_bom_code,
4534 p_component_item_tbl => p_revised_item_type_tbl(i).component_item_tbl,
4535 x_out => x_out
4536 );
4537 INV_EBI_UTIL.debug_line('STEP 40: AFTER CALLING INV_EBI_CHANGE_ORDER_HELPER.process_common_bom_orgs STATUS: '|| x_out.output_status.return_status);
4538 IF (x_out.output_status.return_status <> FND_API.g_ret_sts_success) THEN
4539 RAISE FND_API.g_exc_unexpected_error;
4540 END IF;
4541
4542 FOR j IN p_revised_item_type_tbl(i).component_item_tbl.FIRST..p_revised_item_type_tbl(i).component_item_tbl.LAST
4543 LOOP
4544 --If context org is child org and components does not exist,item assignment should be done
4545 INV_EBI_UTIL.debug_line('STEP 50: BEFORE CALLING INV_EBI_CHANGE_ORDER_HELPER.process_assign_items '||
4546 ' ORG ID: '|| l_organization_id || ' COMP ITEM NAME: '|| p_revised_item_type_tbl(i).component_item_tbl(j).component_item_name);
4547 process_assign_items(
4548 p_organization_id => l_organization_id,
4549 p_item_name => p_revised_item_type_tbl(i).component_item_tbl(j).component_item_name,
4550 x_return_status => x_out.output_status.return_status ,
4551 x_msg_data => x_out.output_status.msg_data ,
4552 x_msg_count => x_out.output_status.msg_count
4553 );
4554 INV_EBI_UTIL.debug_line('STEP 60: AFTER CALLING INV_EBI_CHANGE_ORDER_HELPER.process_assign_items STATUS: '|| x_out.output_status.return_status);
4555 IF (x_out.output_status.return_status <> FND_API.g_ret_sts_success) THEN
4556 RAISE FND_API.g_exc_unexpected_error;
4557 END IF;
4558
4559 l_rev_component_tbl(l_rev_component_tbl_count).eco_name := p_change_order.eco_name;
4560 l_rev_component_tbl(l_rev_component_tbl_count).organization_code := p_change_order.organization_code ;
4561 l_rev_component_tbl(l_rev_component_tbl_count).revised_item_name := p_revised_item_type_tbl(i).revised_item_name;
4562 l_rev_component_tbl(l_rev_component_tbl_count).new_revised_item_revision := l_revised_item_tbl(l_revised_item_tbl_count).new_revised_item_revision;
4563 IF (p_revised_item_type_tbl(i).component_item_tbl(j).start_effective_date < l_effectivity_date
4564 OR p_revised_item_type_tbl(i).component_item_tbl(j).start_effective_date IS NULL
4565 OR p_revised_item_type_tbl(i).component_item_tbl(j).start_effective_date = fnd_api.g_miss_date) THEN
4566 l_rev_component_tbl(l_rev_component_tbl_count).start_effective_date := l_effectivity_date + 1/86400 ; --BUG 7197943 To keep efectivity date of next rev 1 sec higher than earlier rev
4567 ELSE
4568 l_rev_component_tbl(l_rev_component_tbl_count).start_effective_date := p_revised_item_type_tbl(i).component_item_tbl(j).start_effective_date;
4569 END IF;
4570 IF (p_revised_item_type_tbl(i).component_item_tbl(j).new_effectivity_date < l_effectivity_date
4571 OR p_revised_item_type_tbl(i).component_item_tbl(j).new_effectivity_date IS NULL
4572 OR p_revised_item_type_tbl(i).component_item_tbl(j).new_effectivity_date = fnd_api.g_miss_date) THEN
4573 l_rev_component_tbl(l_rev_component_tbl_count).new_effectivity_date := l_effectivity_date + 1/86400; --BUG 7197943 To keep efectivity date of next rev 1 sec higher than earlier rev
4574 ELSE
4575 l_rev_component_tbl(l_rev_component_tbl_count).new_effectivity_date := p_revised_item_type_tbl(i).component_item_tbl(j).new_effectivity_date ;
4576 END IF;
4577 l_rev_component_tbl(l_rev_component_tbl_count).disable_date := p_revised_item_type_tbl(i).component_item_tbl(j).disable_date;
4578 l_rev_component_tbl(l_rev_component_tbl_count).operation_sequence_number := p_revised_item_type_tbl(i).component_item_tbl(j).operation_sequence_number ;
4579 l_rev_component_tbl(l_rev_component_tbl_count).component_item_name := p_revised_item_type_tbl(i).component_item_tbl(j).component_item_name ;
4580 l_rev_component_tbl(l_rev_component_tbl_count).alternate_bom_code := p_revised_item_type_tbl(i).alternate_bom_code ;
4581 l_rev_component_tbl(l_rev_component_tbl_count).acd_type := p_revised_item_type_tbl(i).component_item_tbl(j).acd_type ;
4582 l_rev_component_tbl(l_rev_component_tbl_count).old_effectivity_date := p_revised_item_type_tbl(i).component_item_tbl(j).old_effectivity_date ;
4583 l_rev_component_tbl(l_rev_component_tbl_count).old_operation_sequence_number := p_revised_item_type_tbl(i).component_item_tbl(j).old_operation_sequence_number;
4584 l_rev_component_tbl(l_rev_component_tbl_count).new_operation_sequence_number := p_revised_item_type_tbl(i).component_item_tbl(j).new_operation_sequence_number;
4585 l_rev_component_tbl(l_rev_component_tbl_count).item_sequence_number := p_revised_item_type_tbl(i).component_item_tbl(j).item_sequence_number ;
4586 l_rev_component_tbl(l_rev_component_tbl_count).basis_type := p_revised_item_type_tbl(i).component_item_tbl(j).basis_type ;
4587 l_rev_component_tbl(l_rev_component_tbl_count).quantity_per_assembly := p_revised_item_type_tbl(i).component_item_tbl(j).quantity_per_assembly ;
4588 l_rev_component_tbl(l_rev_component_tbl_count).inverse_quantity := p_revised_item_type_tbl(i).component_item_tbl(j).inverse_quantity ;
4589 l_rev_component_tbl(l_rev_component_tbl_count).planning_percent := p_revised_item_type_tbl(i).component_item_tbl(j).planning_percent ;
4590 l_rev_component_tbl(l_rev_component_tbl_count).projected_yield := p_revised_item_type_tbl(i).component_item_tbl(j).projected_yield ;
4591 l_rev_component_tbl(l_rev_component_tbl_count).include_in_cost_rollup := p_revised_item_type_tbl(i).component_item_tbl(j).include_in_cost_rollup ;
4592 l_rev_component_tbl(l_rev_component_tbl_count).wip_supply_type := p_revised_item_type_tbl(i).component_item_tbl(j).wip_supply_type ;
4593 l_rev_component_tbl(l_rev_component_tbl_count).so_basis := p_revised_item_type_tbl(i).component_item_tbl(j).so_basis ;
4594 l_rev_component_tbl(l_rev_component_tbl_count).optional := p_revised_item_type_tbl(i).component_item_tbl(j).optional ;
4595 l_rev_component_tbl(l_rev_component_tbl_count).mutually_exclusive := p_revised_item_type_tbl(i).component_item_tbl(j).mutually_exclusive ;
4596 l_rev_component_tbl(l_rev_component_tbl_count).check_atp := p_revised_item_type_tbl(i).component_item_tbl(j).check_atp ;
4597 l_rev_component_tbl(l_rev_component_tbl_count).shipping_allowed := p_revised_item_type_tbl(i).component_item_tbl(j).shipping_allowed ;
4598 l_rev_component_tbl(l_rev_component_tbl_count).required_to_ship := p_revised_item_type_tbl(i).component_item_tbl(j).required_to_ship ;
4599 l_rev_component_tbl(l_rev_component_tbl_count).required_for_revenue := p_revised_item_type_tbl(i).component_item_tbl(j).required_for_revenue;
4600 l_rev_component_tbl(l_rev_component_tbl_count).include_on_ship_docs := p_revised_item_type_tbl(i).component_item_tbl(j).include_on_ship_docs;
4601 l_rev_component_tbl(l_rev_component_tbl_count).quantity_related := p_revised_item_type_tbl(i).component_item_tbl(j).quantity_related;
4602 l_rev_component_tbl(l_rev_component_tbl_count).supply_subinventory := p_revised_item_type_tbl(i).component_item_tbl(j).supply_subinventory;
4603 l_rev_component_tbl(l_rev_component_tbl_count).location_name := p_revised_item_type_tbl(i).component_item_tbl(j).location_name ;
4604 l_rev_component_tbl(l_rev_component_tbl_count).minimum_allowed_quantity := p_revised_item_type_tbl(i).component_item_tbl(j).minimum_allowed_quantity ;
4605 l_rev_component_tbl(l_rev_component_tbl_count).maximum_allowed_quantity := p_revised_item_type_tbl(i).component_item_tbl(j).maximum_allowed_quantity;
4606 l_rev_component_tbl(l_rev_component_tbl_count).comments := p_revised_item_type_tbl(i).component_item_tbl(j).comments ;
4607 l_rev_component_tbl(l_rev_component_tbl_count).cancel_comments := p_revised_item_type_tbl(i).component_item_tbl(j).cancel_comments;
4608 l_rev_component_tbl(l_rev_component_tbl_count).attribute_category := p_revised_item_type_tbl(i).component_item_tbl(j).attribute_category;
4609 l_rev_component_tbl(l_rev_component_tbl_count).attribute1 := p_revised_item_type_tbl(i).component_item_tbl(j).attribute1 ;
4610 l_rev_component_tbl(l_rev_component_tbl_count).attribute2 := p_revised_item_type_tbl(i).component_item_tbl(j).attribute2 ;
4611 l_rev_component_tbl(l_rev_component_tbl_count).attribute3 := p_revised_item_type_tbl(i).component_item_tbl(j).attribute3 ;
4612 l_rev_component_tbl(l_rev_component_tbl_count).attribute4 := p_revised_item_type_tbl(i).component_item_tbl(j).attribute4 ;
4613 l_rev_component_tbl(l_rev_component_tbl_count).attribute5 := p_revised_item_type_tbl(i).component_item_tbl(j).attribute5 ;
4614 l_rev_component_tbl(l_rev_component_tbl_count).attribute6 := p_revised_item_type_tbl(i).component_item_tbl(j).attribute6 ;
4615 l_rev_component_tbl(l_rev_component_tbl_count).attribute7 := p_revised_item_type_tbl(i).component_item_tbl(j).attribute7 ;
4616 l_rev_component_tbl(l_rev_component_tbl_count).attribute8 := p_revised_item_type_tbl(i).component_item_tbl(j).attribute8 ;
4617 l_rev_component_tbl(l_rev_component_tbl_count).attribute9 := p_revised_item_type_tbl(i).component_item_tbl(j).attribute9 ;
4618 l_rev_component_tbl(l_rev_component_tbl_count).attribute10 := p_revised_item_type_tbl(i).component_item_tbl(j).attribute10;
4619 l_rev_component_tbl(l_rev_component_tbl_count).attribute11 := p_revised_item_type_tbl(i).component_item_tbl(j).attribute11;
4620 l_rev_component_tbl(l_rev_component_tbl_count).attribute12 := p_revised_item_type_tbl(i).component_item_tbl(j).attribute12;
4621 l_rev_component_tbl(l_rev_component_tbl_count).attribute13 := p_revised_item_type_tbl(i).component_item_tbl(j).attribute13;
4622 l_rev_component_tbl(l_rev_component_tbl_count).attribute14 := p_revised_item_type_tbl(i).component_item_tbl(j).attribute14;
4623 l_rev_component_tbl(l_rev_component_tbl_count).attribute15 := p_revised_item_type_tbl(i).component_item_tbl(j).attribute15;
4624 l_rev_component_tbl(l_rev_component_tbl_count).from_end_item_unit_number := p_revised_item_type_tbl(i).component_item_tbl(j).from_end_item_unit_number;
4625 l_rev_component_tbl(l_rev_component_tbl_count).old_from_end_item_unit_number := p_revised_item_type_tbl(i).component_item_tbl(j).old_from_end_item_unit_number ;
4626 l_rev_component_tbl(l_rev_component_tbl_count).new_from_end_item_unit_number := p_revised_item_type_tbl(i).component_item_tbl(j).new_from_end_item_unit_number;
4627 l_rev_component_tbl(l_rev_component_tbl_count).to_end_item_unit_number := p_revised_item_type_tbl(i).component_item_tbl(j).to_end_item_unit_number;
4628 l_rev_component_tbl(l_rev_component_tbl_count).new_routing_revision := p_revised_item_type_tbl(i).component_item_tbl(j).new_routing_revision ;
4629 l_rev_component_tbl(l_rev_component_tbl_count).enforce_int_requirements := p_revised_item_type_tbl(i).component_item_tbl(j).enforce_int_requirements;
4630 l_rev_component_tbl(l_rev_component_tbl_count).auto_request_material := p_revised_item_type_tbl(i).component_item_tbl(j).auto_request_material;
4631 l_rev_component_tbl(l_rev_component_tbl_count).suggested_vendor_name := p_revised_item_type_tbl(i).component_item_tbl(j).suggested_vendor_name;
4632 l_rev_component_tbl(l_rev_component_tbl_count).unit_price := p_revised_item_type_tbl(i).component_item_tbl(j).unit_price;
4633 l_rev_component_tbl(l_rev_component_tbl_count).original_system_reference := p_revised_item_type_tbl(i).component_item_tbl(j).original_system_reference;
4634 l_rev_component_tbl(l_rev_component_tbl_count).return_status := p_revised_item_type_tbl(i).component_item_tbl(j).return_status ;
4635 l_rev_component_tbl(l_rev_component_tbl_count).transaction_type := p_revised_item_type_tbl(i).component_item_tbl(j).transaction_type;
4636 l_rev_component_tbl(l_rev_component_tbl_count).row_identifier := p_revised_item_type_tbl(i).component_item_tbl(j).row_identifier ;
4637 IF l_rev_component_tbl(l_rev_component_tbl_count).acd_type IN (l_acd_update,l_acd_delete)
4638 THEN
4639 INV_EBI_UTIL.debug_line('STEP 70: BEFORE CALLING INV_EBI_CHANGE_ORDER_HELPER.get_existing_component_attr '|| ' ORG ID: '|| l_organization_id ||
4640 ' REVISED ITEM NAME: '|| l_rev_component_tbl(l_rev_component_tbl_count).revised_item_name ||
4641 ' COMPONENT ITEM NAME: '|| l_rev_component_tbl(l_rev_component_tbl_count).component_item_name);
4642
4643 get_existing_component_attr(
4644 p_organization_id => l_organization_id
4645 ,p_revised_item_name => l_rev_component_tbl(l_rev_component_tbl_count).revised_item_name
4646 ,p_component_item_name => l_rev_component_tbl(l_rev_component_tbl_count).component_item_name
4647 ,p_op_sequence_number => l_rev_component_tbl(l_rev_component_tbl_count).operation_sequence_number
4648 ,p_alternate_bom_code => l_rev_component_tbl(l_rev_component_tbl_count).alternate_bom_code
4649 ,p_bom_update_without_eco => l_bom_update_without_eco -- Bug 8340804
4650 ,p_allow_unimp_bom_updates => l_allow_unimp_bom_update -- Bug 10423301
4651 ,p_effectivity_date => l_rev_component_tbl(l_rev_component_tbl_count).start_effective_date -- Bug 8340804
4652 ,x_old_effectivity_date => l_old_effectivity_date
4653 ,x_old_op_sequence_num => l_old_op_sequence_num
4654 ,x_old_fm_end_item_unit => l_old_fm_end_item_unit
4655 );
4656 INV_EBI_UTIL.debug_line('STEP 80: AFTER CALLING INV_EBI_CHANGE_ORDER_HELPER.get_existing_component_attr');
4657 IF l_rev_component_tbl(l_rev_component_tbl_count).old_effectivity_date IS NULL
4658 THEN
4659 l_rev_component_tbl(l_rev_component_tbl_count).old_effectivity_date := l_old_effectivity_date;
4660 END IF;
4661 IF l_rev_component_tbl(l_rev_component_tbl_count).old_operation_sequence_number IS NULL
4662 THEN
4663 l_rev_component_tbl(l_rev_component_tbl_count).old_operation_sequence_number := l_old_op_sequence_num;
4664 END IF;
4665 IF l_rev_component_tbl(l_rev_component_tbl_count).old_from_end_item_unit_number IS NULL
4666 THEN
4667 l_rev_component_tbl(l_rev_component_tbl_count).old_from_end_item_unit_number := l_old_fm_end_item_unit;
4668 END IF;
4669 END IF;
4670
4671 IF(p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl IS NOT NULL AND p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl.COUNT > 0) THEN
4672 FOR k IN 1..p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl.COUNT
4673 LOOP
4674 l_ref_designator_tbl(l_ref_designator_tbl_count).eco_name := p_change_order.eco_name;
4675 l_ref_designator_tbl(l_ref_designator_tbl_count).organization_code := p_change_order.organization_code ;
4676 l_ref_designator_tbl(l_ref_designator_tbl_count).revised_item_name := p_revised_item_type_tbl(i).revised_item_name;
4677 l_ref_designator_tbl(l_ref_designator_tbl_count).new_revised_item_revision := l_revised_item_tbl(l_revised_item_tbl_count).new_revised_item_revision;
4678 l_ref_designator_tbl(l_ref_designator_tbl_count).operation_sequence_number := p_revised_item_type_tbl(i).component_item_tbl(j).operation_sequence_number;
4679 l_ref_designator_tbl(l_ref_designator_tbl_count).component_item_name := p_revised_item_type_tbl(i).component_item_tbl(j).component_item_name ;
4680 l_ref_designator_tbl(l_ref_designator_tbl_count).alternate_bom_code := p_revised_item_type_tbl(i).alternate_bom_code;
4681 IF (p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).start_effective_date < l_effectivity_date
4682 OR p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).start_effective_date IS NULL
4683 OR p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).start_effective_date =fnd_api.g_miss_date) THEN
4684 l_ref_designator_tbl(l_ref_designator_tbl_count).start_effective_date := l_effectivity_date + 1/86400; --BUG 7197943 To keep efectivity date of next rev 1 sec higher than earlier rev
4685 ELSE
4686 l_ref_designator_tbl(l_ref_designator_tbl_count).start_effective_date := p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).start_effective_date;
4687 END IF;
4688 l_ref_designator_tbl(l_ref_designator_tbl_count).reference_designator_name := p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).reference_designator_name;
4689 l_ref_designator_tbl(l_ref_designator_tbl_count).acd_type := p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).acd_type ;
4690 l_ref_designator_tbl(l_ref_designator_tbl_count).ref_designator_comment := p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).ref_designator_comment ;
4691 l_ref_designator_tbl(l_ref_designator_tbl_count).attribute_category := p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).attribute_category;
4692 l_ref_designator_tbl(l_ref_designator_tbl_count).attribute1 := p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).attribute1 ;
4693 l_ref_designator_tbl(l_ref_designator_tbl_count).attribute2 := p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).attribute2 ;
4694 l_ref_designator_tbl(l_ref_designator_tbl_count).attribute3 := p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).attribute3 ;
4695 l_ref_designator_tbl(l_ref_designator_tbl_count).attribute4 := p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).attribute4;
4696 l_ref_designator_tbl(l_ref_designator_tbl_count).attribute5 := p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).attribute5;
4697 l_ref_designator_tbl(l_ref_designator_tbl_count).attribute6 := p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).attribute6;
4698 l_ref_designator_tbl(l_ref_designator_tbl_count).attribute7 := p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).attribute7;
4699 l_ref_designator_tbl(l_ref_designator_tbl_count).attribute8 := p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).attribute8;
4700 l_ref_designator_tbl(l_ref_designator_tbl_count).attribute9 := p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).attribute9;
4701 l_ref_designator_tbl(l_ref_designator_tbl_count).attribute10 := p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).attribute10 ;
4702 l_ref_designator_tbl(l_ref_designator_tbl_count).attribute11 := p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).attribute11;
4703 l_ref_designator_tbl(l_ref_designator_tbl_count).attribute12 := p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).attribute12;
4704 l_ref_designator_tbl(l_ref_designator_tbl_count).attribute13 := p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).attribute13;
4705 l_ref_designator_tbl(l_ref_designator_tbl_count).attribute14 := p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).attribute14;
4706 l_ref_designator_tbl(l_ref_designator_tbl_count).attribute15 := p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).attribute15;
4707 l_ref_designator_tbl(l_ref_designator_tbl_count).original_system_reference := p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).original_system_reference;
4708 l_ref_designator_tbl(l_ref_designator_tbl_count).new_reference_designator := p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).new_reference_designator;
4709 l_ref_designator_tbl(l_ref_designator_tbl_count).from_end_item_unit_number := p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).from_end_item_unit_number;
4710 l_ref_designator_tbl(l_ref_designator_tbl_count).new_routing_revision := p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).new_routing_revision;
4711 l_ref_designator_tbl(l_ref_designator_tbl_count).return_status := p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).return_status;
4712 l_ref_designator_tbl(l_ref_designator_tbl_count).transaction_type := p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).transaction_type ;
4713 l_ref_designator_tbl(l_ref_designator_tbl_count).row_identifier := p_revised_item_type_tbl(i).component_item_tbl(j).reference_designator_tbl(k).row_identifier ;
4714 l_ref_designator_tbl_count := l_ref_designator_tbl_count +1;
4715 END LOOP;
4716 END IF;
4717
4718 IF(p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl IS NOT NULL AND p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl.COUNT > 0) THEN
4719 FOR k IN 1..p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl.COUNT
4720 LOOP
4721 --If context org is child org and components does not exist,item assignment should be done
4722 INV_EBI_UTIL.debug_line('STEP 90: BEFORE CALLING INV_EBI_CHANGE_ORDER_HELPER.process_assign_items FOR SUBSTITUTE COMPONENTS '||
4723 ' COMPONENT NAME : '||p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).substitute_component_name);
4724 process_assign_items(
4725 p_organization_id => l_organization_id,
4726 p_item_name => p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).substitute_component_name,
4727 x_return_status => x_out.output_status.return_status ,
4728 x_msg_data => x_out.output_status.msg_data ,
4729 x_msg_count => x_out.output_status.msg_count
4730 );
4731 INV_EBI_UTIL.debug_line('STEP 100: AFTER CALLING INV_EBI_CHANGE_ORDER_HELPER.process_assign_items STATUS: '|| x_out.output_status.return_status);
4732 IF (x_out.output_status.return_status <> FND_API.g_ret_sts_success) THEN
4733 RAISE FND_API.g_exc_unexpected_error;
4734 END IF;
4735
4736 l_sub_component_tbl(l_sub_component_tbl_count).eco_name := p_change_order.eco_name;
4737 l_sub_component_tbl(l_sub_component_tbl_count).organization_code := p_change_order.organization_code ;
4738 l_sub_component_tbl(l_sub_component_tbl_count).revised_item_name := p_revised_item_type_tbl(i).revised_item_name;
4739 l_sub_component_tbl(l_sub_component_tbl_count).new_revised_item_revision := l_revised_item_tbl(l_revised_item_tbl_count).new_revised_item_revision;
4740 l_sub_component_tbl(l_sub_component_tbl_count).operation_sequence_number := p_revised_item_type_tbl(i).component_item_tbl(j).operation_sequence_number;
4741 l_sub_component_tbl(l_sub_component_tbl_count).component_item_name := p_revised_item_type_tbl(i).component_item_tbl(j).component_item_name ;
4742 l_sub_component_tbl(l_sub_component_tbl_count).alternate_bom_code := p_revised_item_type_tbl(i).alternate_bom_code;
4743 IF (p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).start_effective_date < l_effectivity_date
4744 OR p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).start_effective_date IS NULL
4745 OR p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).start_effective_date =fnd_api.g_miss_date) THEN
4746 l_sub_component_tbl(l_sub_component_tbl_count).start_effective_date := l_effectivity_date + 1/86400;
4747 ELSE
4748 l_sub_component_tbl(l_sub_component_tbl_count).start_effective_date := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).start_effective_date;
4749 END IF;
4750 l_sub_component_tbl(l_sub_component_tbl_count).substitute_component_name := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).substitute_component_name;
4751 l_sub_component_tbl(l_sub_component_tbl_count).new_substitute_component_name := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).new_substitute_component_name ;
4752 l_sub_component_tbl(l_sub_component_tbl_count).acd_type := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).acd_type ;
4753 l_sub_component_tbl(l_sub_component_tbl_count).substitute_item_quantity := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).substitute_item_quantity ;
4754 l_sub_component_tbl(l_sub_component_tbl_count).attribute_category := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).attribute_category;
4755 l_sub_component_tbl(l_sub_component_tbl_count).attribute1 := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).attribute1;
4756 l_sub_component_tbl(l_sub_component_tbl_count).attribute2 := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).attribute2 ;
4757 l_sub_component_tbl(l_sub_component_tbl_count).attribute3 := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).attribute3;
4758 l_sub_component_tbl(l_sub_component_tbl_count).attribute4 := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).attribute4 ;
4759 l_sub_component_tbl(l_sub_component_tbl_count).attribute5 := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).attribute5 ;
4760 l_sub_component_tbl(l_sub_component_tbl_count).attribute6 := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).attribute6 ;
4761 l_sub_component_tbl(l_sub_component_tbl_count).attribute7 := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).attribute7 ;
4762 l_sub_component_tbl(l_sub_component_tbl_count).attribute8 := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).attribute8 ;
4763 l_sub_component_tbl(l_sub_component_tbl_count).attribute9 := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).attribute9 ;
4764 l_sub_component_tbl(l_sub_component_tbl_count).attribute10 := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).attribute10 ;
4765 l_sub_component_tbl(l_sub_component_tbl_count).attribute11 := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).attribute11 ;
4766 l_sub_component_tbl(l_sub_component_tbl_count).attribute12 := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).attribute12 ;
4767 l_sub_component_tbl(l_sub_component_tbl_count).attribute13 := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).attribute13 ;
4768 l_sub_component_tbl(l_sub_component_tbl_count).attribute14 := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).attribute14 ;
4769 l_sub_component_tbl(l_sub_component_tbl_count).attribute15 := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).attribute15 ;
4770 l_sub_component_tbl(l_sub_component_tbl_count).original_system_reference := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).original_system_reference ;
4771 l_sub_component_tbl(l_sub_component_tbl_count).from_end_item_unit_number := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).from_end_item_unit_number;
4772 l_sub_component_tbl(l_sub_component_tbl_count).new_routing_revision := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).new_routing_revision ;
4773 l_sub_component_tbl(l_sub_component_tbl_count).enforce_int_requirements := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).enforce_int_requirements ;
4774 l_sub_component_tbl(l_sub_component_tbl_count).return_status := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).return_status ;
4775 l_sub_component_tbl(l_sub_component_tbl_count).transaction_type := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).transaction_type ;
4776 l_sub_component_tbl(l_sub_component_tbl_count).row_identifier := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).row_identifier ;
4777 l_sub_component_tbl(l_sub_component_tbl_count).inverse_quantity := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).inverse_quantity ;
4778 l_sub_component_tbl(l_sub_component_tbl_count).program_id := p_revised_item_type_tbl(i).component_item_tbl(j).substitute_component_tbl(k).program_id ;
4779 l_sub_component_tbl_count := l_sub_component_tbl_count + 1;
4780 END LOOP;
4781 END IF;
4782 l_rev_component_tbl_count := l_rev_component_tbl_count +1;
4783 END LOOP;
4784 END IF;
4785 l_revised_item_tbl_count := l_revised_item_tbl_count + 1;
4786 END LOOP;
4787 END IF;
4788 INV_EBI_UTIL.debug_line('STEP 110: BEFORE CALLING ENG_ECO_PUB.process_eco');
4789
4790 --To create ECO
4791 ENG_ECO_PUB.process_eco (
4792 p_api_version_number => 1.0
4793 ,p_eco_rec => l_eco_rec
4794 ,p_eco_revision_tbl => l_eco_revision_tbl
4795 ,p_revised_item_tbl => l_revised_item_tbl
4796 ,p_rev_component_tbl => l_rev_component_tbl
4797 ,p_sub_component_tbl => l_sub_component_tbl
4798 ,p_ref_designator_tbl => l_ref_designator_tbl
4799 ,p_change_line_tbl => l_change_line_tbl
4800 ,p_rev_operation_tbl => l_rev_operation_tbl
4801 ,p_rev_op_resource_tbl => l_rev_op_resource_tbl
4802 ,p_rev_sub_resource_tbl => l_rev_sub_resource_tbl
4803 ,x_eco_rec => l_eco_rec
4804 ,x_eco_revision_tbl => l_eco_revision_tbl
4805 ,x_revised_item_tbl => l_revised_item_tbl
4806 ,x_rev_component_tbl => l_rev_component_tbl
4807 ,x_sub_component_tbl => l_sub_component_tbl
4808 ,x_ref_designator_tbl => l_ref_designator_tbl
4809 ,x_change_line_tbl => l_change_line_tbl
4810 ,x_rev_operation_tbl => l_rev_operation_tbl
4811 ,x_rev_op_resource_tbl => l_rev_op_resource_tbl
4812 ,x_rev_sub_resource_tbl => l_rev_sub_resource_tbl
4813 ,x_return_status => x_out.output_status.return_status
4814 ,x_msg_count => x_out.output_status.msg_count
4815 );
4816
4817
4818 INV_EBI_UTIL.debug_line('STEP 120: AFTER CALLING ENG_ECO_PUB.process_eco STATUS: '|| x_out.output_status.return_status);
4819 IF (x_out.output_status.return_status <> FND_API.g_ret_sts_success) THEN
4820 RAISE FND_API.g_exc_unexpected_error;
4821 END IF;
4822
4823 SELECT change_id ,change_notice INTO x_out.change_id,x_out.change_notice
4824 FROM eng_engineering_changes
4825 WHERE change_notice = l_eco_rec.eco_name
4826 AND organization_id = l_organization_id;
4827
4828 x_out.organization_code := p_change_order.organization_code;
4829 x_out.organization_id := l_organization_id;
4830
4831 IF FND_API.to_boolean( p_commit ) THEN
4832 COMMIT;
4833 END IF;
4834 INV_EBI_UTIL.debug_line('STEP 130: END INSIDE INV_EBI_CHANGE_ORDER_HELPER.process_eco STATUS: '|| x_out.output_status.return_status);
4835 EXCEPTION
4836 WHEN FND_API.g_exc_unexpected_error THEN
4837 ROLLBACK TO inv_ebi_proc_eco_save_pnt;
4838 x_out.output_status.return_status := FND_API.g_ret_sts_unexp_error;
4839 IF(x_out.output_status.msg_data IS NULL) THEN
4840 fnd_msg_pub.count_and_get(
4841 p_encoded => FND_API.g_false
4842 ,p_count => x_out.output_status.msg_count
4843 ,p_data => x_out.output_status.msg_data
4844 );
4845 END IF;
4846 WHEN OTHERS THEN
4847 ROLLBACK TO inv_ebi_proc_eco_save_pnt;
4848 x_out.output_status.return_status := FND_API.g_ret_sts_unexp_error;
4849 IF (x_out.output_status.msg_data IS NOT NULL) THEN
4850 x_out.output_status.msg_data := x_out.output_status.msg_data||' -> INV_EBI_CHANGE_ORDER_HELPER.process_eco ';
4851 ELSE
4852 x_out.output_status.msg_data := SQLERRM||' INV_EBI_CHANGE_ORDER_HELPER.process_eco ';
4853 END IF;
4854 END process_eco;
4855
4856 /************************************************************************************
4857 -- API name : process_structure_header
4858 -- Type : Private
4859 -- Function :
4860 -- This API is used to Process bom and common bom.
4861 --
4862 ************************************************************************************/
4863 PROCEDURE process_structure_header(
4864 p_commit IN VARCHAR2 := FND_API.G_FALSE
4865 ,p_organization_code IN VARCHAR2
4866 ,p_assembly_item_name IN VARCHAR2
4867 ,p_alternate_bom_code IN VARCHAR2
4868 ,p_structure_header IN inv_ebi_structure_header_obj
4869 ,p_component_item_tbl IN inv_ebi_rev_comp_tbl
4870 ,p_name_val_list IN inv_ebi_name_value_list
4871 ,x_out OUT NOCOPY inv_ebi_eco_output_obj
4872 )
4873 IS
4874 l_bom_header_rec bom_bo_pub.bom_head_rec_type;
4875 l_bom_revision_tbl bom_bo_pub.bom_revision_tbl_type;
4876 l_bom_component_tbl bom_bo_pub.bom_comps_tbl_type;
4877 l_bom_ref_designator_tbl bom_bo_pub.bom_ref_designator_tbl_type;
4878 l_bom_sub_component_tbl bom_bo_pub.bom_sub_component_tbl_type;
4879 l_output_status inv_ebi_output_status;
4880 l_is_bom_exists VARCHAR2(3);
4881 l_transaction_type VARCHAR2(20);
4882 l_bom_already_commoned varchar2(3) := FND_API.g_false;
4883
4884 BEGIN
4885 SAVEPOINT inv_ebi_proc_bom_save_pnt;
4886 l_output_status := inv_ebi_output_status(fnd_api.g_ret_sts_success,NULL,NULL,NULL);
4887 x_out := inv_ebi_eco_output_obj(NULL,NULL,NULL,NULL,l_output_status,NULL,NULL);
4888 INV_EBI_UTIL.debug_line('STEP 10: START INSIDE INV_EBI_CHANGE_ORDER_HELPER.process_structure_header');
4889
4890 l_is_bom_exists := is_bom_exists(
4891 p_item_number => p_assembly_item_name,
4892 p_organization_code => p_organization_code,
4893 p_alternate_bom_code => p_alternate_bom_code
4894 );
4895
4896 IF(l_is_bom_exists = fnd_api.g_false ) THEN
4897 l_transaction_type := INV_EBI_ITEM_PUB.g_otype_create ;
4898 ELSE
4899 l_transaction_type := INV_EBI_ITEM_PUB.g_otype_update;
4900
4901 --Bug 7196996
4902 /* process_common_bom_orgs(
4903 p_assembly_item_name => p_assembly_item_name,
4904 p_organization_code => p_organization_code,
4905 p_alternate_bom_code => p_alternate_bom_code,
4906 p_component_item_tbl => p_component_item_tbl,
4907 x_out => x_out
4908 );
4909 IF (x_out.output_status.return_status <> FND_API.g_ret_sts_success) THEN
4910 RAISE FND_API.g_exc_unexpected_error;
4911 END IF; */
4912 END IF;
4913
4914 IF(p_structure_header.common_assembly_item_name IS NOT NULL AND
4915 p_structure_header.common_assembly_item_name <> fnd_api.g_miss_char AND
4916 p_structure_header.common_organization_code IS NOT NULL AND
4917 p_structure_header.common_organization_code <> fnd_api.g_miss_char
4918 ) THEN
4919 --Bug 7127027
4920 INV_EBI_UTIL.debug_line('STEP 20: BEFORE CALLING INV_EBI_CHANGE_ORDER_HELPER.process_common_bom '||' ORG CODE : '|| p_organization_code ||
4921 ' ASSY ITEM NAME : '|| p_assembly_item_name ||' COMMON ASSY ITEM NAME: '|| p_structure_header.common_assembly_item_name ||
4922 ' COMMON ORG CODE : '|| p_structure_header.common_organization_code);
4923 process_common_bom(
4924 p_organization_code => p_organization_code
4925 ,p_assembly_item_name => p_assembly_item_name
4926 ,p_alternate_bom_code => p_alternate_bom_code
4927 ,p_common_assembly_item_name => p_structure_header.common_assembly_item_name
4928 ,p_common_organization_code => p_structure_header.common_organization_code
4929 ,x_return_status => x_out.output_status.return_status
4930 ,x_msg_data => x_out.output_status.msg_data
4931 ,x_msg_count => x_out.output_status.msg_count
4932 );
4933 INV_EBI_UTIL.debug_line('STEP 30: AFTER CALLING INV_EBI_CHANGE_ORDER_HELPER.process_common_bom STATUS : '|| x_out.output_status.return_status);
4934 IF (x_out.output_status.return_status <> FND_API.g_ret_sts_success) THEN
4935 RAISE FND_API.g_exc_unexpected_error;
4936 END IF;
4937 END IF;
4938
4939 l_bom_header_rec.assembly_item_name := p_assembly_item_name ;
4940 l_bom_header_rec.organization_code := p_organization_code;
4941 l_bom_header_rec.alternate_bom_code := p_alternate_bom_code ;
4942 l_bom_header_rec.common_assembly_item_name := p_structure_header.common_assembly_item_name ;
4943 l_bom_header_rec.common_organization_code := p_structure_header.common_organization_code ;
4944 l_bom_header_rec.assembly_comment := p_structure_header.assembly_comment;
4945 l_bom_header_rec.assembly_type := p_structure_header.assembly_type ;
4946 l_bom_header_rec.transaction_type := l_transaction_type ;
4947 l_bom_header_rec.return_status := p_structure_header.return_status ;
4948 l_bom_header_rec.attribute_category := p_structure_header.attribute_category ;
4949 l_bom_header_rec.attribute1 := p_structure_header.attribute1 ;
4950 l_bom_header_rec.attribute2 := p_structure_header.attribute2 ;
4951 l_bom_header_rec.attribute3 := p_structure_header.attribute3 ;
4952 l_bom_header_rec.attribute4 := p_structure_header.attribute4 ;
4953 l_bom_header_rec.attribute5 := p_structure_header.attribute5 ;
4954 l_bom_header_rec.attribute6 := p_structure_header.attribute6 ;
4955 l_bom_header_rec.attribute7 := p_structure_header.attribute7 ;
4956 l_bom_header_rec.attribute8 := p_structure_header.attribute8 ;
4957 l_bom_header_rec.attribute9 := p_structure_header.attribute9 ;
4958 l_bom_header_rec.attribute10 := p_structure_header.attribute10;
4959 l_bom_header_rec.attribute11 := p_structure_header.attribute11;
4960 l_bom_header_rec.attribute12 := p_structure_header.attribute12;
4961 l_bom_header_rec.attribute13 := p_structure_header.attribute13;
4962 l_bom_header_rec.attribute14 := p_structure_header.attribute14;
4963 l_bom_header_rec.attribute15 := p_structure_header.attribute15;
4964 l_bom_header_rec.original_system_reference := p_structure_header.original_system_reference;
4965 l_bom_header_rec.delete_group_name := p_structure_header.delete_group_name ;
4966 l_bom_header_rec.dg_description := p_structure_header.dg_description ;
4967 l_bom_header_rec.row_identifier := p_structure_header.row_identifier ;
4968 l_bom_header_rec.bom_implementation_date := p_structure_header.bom_implementation_date ;
4969 l_bom_header_rec.enable_attrs_update := p_structure_header.enable_attrs_update ;
4970 l_bom_header_rec.structure_type_name := p_structure_header.structure_type_name ;
4971
4972 IF(l_bom_header_rec.structure_type_name IS NULL OR
4973 l_bom_header_rec.structure_type_name = fnd_api.g_miss_char )
4974 AND (INV_EBI_UTIL.is_pim_installed) THEN
4975 IF p_name_val_list.name_value_table IS NOT NULL THEN
4976 FOR i in p_name_val_list.name_value_table.FIRST..p_name_val_list.name_value_table.LAST LOOP
4977 IF UPPER(p_name_val_list.name_value_table(i).param_name) = G_DEFAULT_STRUCTURE_TYPE THEN
4978 l_bom_header_rec.structure_type_name := p_name_val_list.name_value_table(i).param_value;
4979 END IF;
4980 END LOOP;
4981 END IF;
4982 END IF;
4983
4984 --Start of Bug 13340150
4985 IF(l_transaction_type = INV_EBI_ITEM_PUB.g_otype_update) THEN
4986 l_bom_already_commoned := is_bom_already_commoned(
4987 p_item_number => p_assembly_item_name,
4988 p_organization_code => p_organization_code,
4989 p_alternate_bom_code => p_alternate_bom_code
4990 );
4991
4992 END IF;
4993 IF(l_bom_already_commoned = fnd_api.g_false) THEN -- End of Bug 13340150
4994
4995 INV_EBI_UTIL.debug_line('STEP 40: BEFORE CALLING BOM_BO_PUB.process_bom');
4996
4997 BOM_BO_PUB.process_bom
4998 (
4999 p_bom_header_rec => l_bom_header_rec
5000 ,p_bom_revision_tbl => l_bom_revision_tbl
5001 ,p_bom_component_tbl => l_bom_component_tbl
5002 ,p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
5003 ,p_bom_sub_component_tbl => l_bom_sub_component_tbl
5004 ,x_bom_header_rec => l_bom_header_rec
5005 ,x_bom_revision_tbl => l_bom_revision_tbl
5006 ,x_bom_component_tbl => l_bom_component_tbl
5007 ,x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
5008 ,x_bom_sub_component_tbl => l_bom_sub_component_tbl
5009 ,x_return_status => x_out.output_status.return_status
5010 ,x_msg_count => x_out.output_status.msg_count
5011 );
5012 INV_EBI_UTIL.debug_line('STEP 50: AFTER CALLING BOM_BO_PUB.process_bom '||' RETURN STATUS: '|| x_out.output_status.return_status);
5013 IF (x_out.output_status.return_status <> FND_API.g_ret_sts_success) THEN
5014 x_out.output_status.msg_data := x_out.output_status.msg_data || ' -> Item Number: '|| p_assembly_item_name || ' ORG CODE: '|| p_organization_code;
5015 RAISE FND_API.g_exc_unexpected_error;
5016 END IF;
5017 END IF;
5018 IF FND_API.to_boolean( p_commit ) THEN
5019 COMMIT;
5020 END IF;
5021 INV_EBI_UTIL.debug_line('STEP 60: END INSIDE INV_EBI_CHANGE_ORDER_HELPER.process_structure_header STATUS: '|| x_out.output_status.return_status);
5022 EXCEPTION
5023 WHEN FND_API.g_exc_unexpected_error THEN
5024 ROLLBACK TO inv_ebi_proc_bom_save_pnt;
5025 x_out.output_status.return_status := FND_API.g_ret_sts_error;
5026 IF(x_out.output_status.msg_data IS NULL) THEN
5027 fnd_msg_pub.count_and_get(
5028 p_encoded => FND_API.g_false
5029 ,p_count => x_out.output_status.msg_count
5030 ,p_data => x_out.output_status.msg_data
5031 );
5032 END IF;
5033 WHEN OTHERS THEN
5034 ROLLBACK TO inv_ebi_proc_bom_save_pnt;
5035 x_out.output_status.return_status := FND_API.g_ret_sts_unexp_error;
5036 IF (x_out.output_status.msg_data IS NOT NULL) THEN
5037 x_out.output_status.msg_data := x_out.output_status.msg_data||' -> INV_EBI_CHANGE_ORDER_HELPER.process_structure_header ';
5038 ELSE
5039 x_out.output_status.msg_data := SQLERRM||' INV_EBI_CHANGE_ORDER_HELPER.process_structure_header ';
5040 END IF;
5041 END process_structure_header;
5042
5043 /************************************************************************************
5044 -- API name : get_eco
5045 -- Type : Public
5046 -- Function :
5047 -- This API is used to retrieve all the change order attributes
5048 ************************************************************************************/
5049 PROCEDURE get_eco (
5050 p_change_id IN NUMBER
5051 ,p_last_update_status IN VARCHAR2
5052 ,p_revised_item_sequence_id IN NUMBER
5053 ,p_name_val_list IN inv_ebi_name_value_list
5054 ,x_eco_obj OUT NOCOPY inv_ebi_eco_obj
5055 ,x_return_status OUT NOCOPY VARCHAR2
5056 ,x_msg_count OUT NOCOPY NUMBER
5057 ,x_msg_data OUT NOCOPY VARCHAR2
5058 )
5059 IS
5060 l_eco_change_order_obj inv_ebi_change_order_obj;
5061 l_eco_revision_tbl inv_ebi_eco_revision_tbl;
5062 l_eco_revision_obj inv_ebi_eco_revision_obj;
5063 l_substitute_component_tbl inv_ebi_sub_comp_tbl;
5064 l_substitute_component_obj inv_ebi_sub_comp_obj;
5065 l_reference_designator_tbl inv_ebi_ref_desg_tbl;
5066 l_reference_designator_obj inv_ebi_ref_desg_obj;
5067 l_revision_component_tbl inv_ebi_rev_comp_tbl;
5068 l_revision_component_obj inv_ebi_rev_comp_obj;
5069 l_revised_item_tbl inv_ebi_revised_item_tbl;
5070 l_revised_item_obj inv_ebi_revised_item_obj;
5071 l_structure_header_obj inv_ebi_structure_header_obj;
5072 l_current_index NUMBER;
5073 l_reviseditem_index NUMBER;
5074 l_comp_index NUMBER;
5075 l_sub_index NUMBER;
5076 l_ref_index NUMBER;
5077 l_change_id NUMBER := NULL;
5078 l_revised_item_sequence_id NUMBER := NULL;
5079 l_include_rev_items VARCHAR2(1):= fnd_api.g_true;
5080 l_include_comp_items VARCHAR2(1):= fnd_api.g_true;
5081 l_include_sub_comp VARCHAR2(1):= fnd_api.g_true;
5082 l_include_ref_designators VARCHAR2(1):= fnd_api.g_true;
5083 l_item_obj inv_ebi_item_obj;
5084
5085 CURSOR c_change_order_type(p_change_id IN VARCHAR2) IS
5086 SELECT
5087 eec.change_notice
5088 ,eec.change_order_type_id
5089 ,eec.change_notice_prefix
5090 ,eec.change_notice_number
5091 ,mp.organization_code
5092 ,mp.organization_id
5093 ,eec.change_name
5094 ,eec.description
5095 ,eec.cancellation_comments
5096 ,eec.status_code
5097 ,ecsv.status_name
5098 ,eec.priority_code
5099 ,eec.reason_code
5100 ,eec.estimated_eng_cost
5101 ,eec.estimated_mfg_cost
5102 ,eec.attribute_category
5103 ,eec.attribute1
5104 ,eec.attribute2
5105 ,eec.attribute3
5106 ,eec.attribute4
5107 ,eec.attribute5
5108 ,eec.attribute6
5109 ,eec.attribute7
5110 ,eec.attribute8
5111 ,eec.attribute9
5112 ,eec.attribute10
5113 ,eec.attribute11
5114 ,eec.attribute12
5115 ,eec.attribute13
5116 ,eec.attribute14
5117 ,eec.attribute15
5118 ,eec.ddf_context
5119 ,eeal.approval_list_name
5120 ,eec.approval_date
5121 ,eec.approval_request_date
5122 ,eec.change_mgmt_type_code
5123 ,eec.original_system_reference
5124 ,eec.organization_hierarchy
5125 ,hp.party_name assignee
5126 ,ppa.name project_name
5127 ,ppe.name task_number
5128 ,eec.source_type_code
5129 ,eec.source_name
5130 ,eec.need_by_date
5131 ,eec.effort
5132 ,haou.name eco_department_name
5133 ,eec.internal_use_only
5134 ,eec.plm_or_erp_change
5135 ,eec.status_type
5136 ,eec.implementation_date
5137 ,eec.cancellation_date
5138 ,ecot.type_name
5139 FROM
5140 eng_engineering_changes eec
5141 ,mtl_parameters mp
5142 ,eng_change_statuses_vl ecsv
5143 ,eng_ecn_approval_lists eeal
5144 ,hz_parties hp
5145 ,pa_projects_all ppa
5146 ,pa_proj_elements ppe
5147 ,hr_all_organization_units_vl haou
5148 ,eng_change_order_types_vl ecot
5149 WHERE
5150 eec.change_id = p_change_id AND
5151 eec.change_order_type_id =ecot.change_order_type_id AND
5152 mp.organization_id = eec.organization_id AND
5153 ecsv.status_code(+) = eec.status_code AND
5154 eeal.approval_list_id(+) = eec.approval_list_id AND
5155 hp.party_id(+) = eec.assignee_id AND
5156 ppa.project_id(+) = eec.project_id AND
5157 ppe.proj_element_id(+) = eec.task_id AND
5158 haou.organization_id(+) = eec.responsible_organization_id;
5159
5160 c_eco_header c_change_order_type%ROWTYPE;
5161
5162 CURSOR c_eco_revision(p_change_id IN VARCHAR2) IS
5163 SELECT
5164 ecor.revision
5165 ,ecor.comments
5166 ,ecor.attribute_category
5167 ,ecor.attribute1
5168 ,ecor.attribute2
5169 ,ecor.attribute3
5170 ,ecor.attribute4
5171 ,ecor.attribute5
5172 ,ecor.attribute6
5173 ,ecor.attribute7
5174 ,ecor.attribute8
5175 ,ecor.attribute9
5176 ,ecor.attribute10
5177 ,ecor.attribute11
5178 ,ecor.attribute12
5179 ,ecor.attribute13
5180 ,ecor.attribute14
5181 ,ecor.attribute15
5182 ,eec.change_mgmt_type_code
5183 ,ecor.original_system_reference
5184 FROM
5185 eng_change_order_revisions ecor
5186 ,eng_engineering_changes eec
5187 WHERE
5188 ecor.change_id = eec.change_id AND
5189 ecor.change_id = p_change_id;
5190
5191 CURSOR c_substitute_component(p_change_id IN VARCHAR2,p_revised_item_id IN NUMBER,p_component_id IN NUMBER) IS
5192 SELECT
5193 mif.item_number substitute_component_name
5194 ,bsc.acd_type
5195 ,bsc.substitute_item_quantity
5196 ,bsc.attribute_category
5197 ,bsc.attribute1
5198 ,bsc.attribute2
5199 ,bsc.attribute3
5200 ,bsc.attribute4
5201 ,bsc.attribute5
5202 ,bsc.attribute6
5203 ,bsc.attribute7
5204 ,bsc.attribute8
5205 ,bsc.attribute9
5206 ,bsc.attribute10
5207 ,bsc.attribute11
5208 ,bsc.attribute12
5209 ,bsc.attribute13
5210 ,bsc.attribute14
5211 ,bsc.attribute15
5212 ,bsc.original_system_reference
5213 ,bsc.enforce_int_requirements
5214 ,bsc.program_id
5215 FROM
5216 bom_inventory_components bic
5217 ,eng_revised_items eri
5218 ,mtl_item_flexfields mif
5219 ,bom_substitute_components bsc
5220 WHERE
5221 eri.change_id = p_change_id AND
5222 eri.revised_item_id = p_revised_item_id AND
5223 bic.component_item_id = p_component_id AND
5224 bic.revised_item_sequence_id(+) = eri.revised_item_sequence_id AND
5225 bsc.component_sequence_id = bic.component_sequence_id AND
5226 mif.inventory_item_id = bsc.substitute_component_id AND
5227 mif.organization_id = eri.organization_id;
5228
5229 CURSOR c_reference_designator(p_change_id IN VARCHAR2,p_revised_item_id IN NUMBER,p_component_id IN NUMBER) IS
5230 SELECT
5231 brd.component_reference_designator reference_designator_name
5232 ,brd.acd_type
5233 ,brd.ref_designator_comment
5234 ,brd.attribute_category
5235 ,brd.attribute1
5236 ,brd.attribute2
5237 ,brd.attribute3
5238 ,brd.attribute4
5239 ,brd.attribute5
5240 ,brd.attribute6
5241 ,brd.attribute7
5242 ,brd.attribute8
5243 ,brd.attribute9
5244 ,brd.attribute10
5245 ,brd.attribute11
5246 ,brd.attribute12
5247 ,brd.attribute13
5248 ,brd.attribute14
5249 ,brd.attribute15
5250 ,brd.original_system_reference
5251 FROM
5252 bom_inventory_components bic
5253 ,eng_revised_items eri
5254 ,bom_reference_designators brd
5255 WHERE
5256 eri.change_id = p_change_id AND
5257 eri.revised_item_id = p_revised_item_id AND
5258 bic.component_item_id = p_component_id AND
5259 bic.revised_item_sequence_id(+)=eri.revised_item_sequence_id AND
5260 brd.component_sequence_id(+)=bic.component_sequence_id;
5261
5262 CURSOR c_revision_component(p_change_id IN VARCHAR2,p_revised_item_id IN NUMBER) IS
5263 SELECT
5264 bic.component_item_id
5265 ,bic.disable_date
5266 ,bic.operation_seq_num
5267 ,mif.item_number component_item_name
5268 ,bic.acd_type
5269 ,bic.basis_type
5270 ,bic.component_quantity
5271 ,bic.component_quantity inverse_quantity
5272 ,bic.include_in_cost_rollup
5273 ,bic.wip_supply_type
5274 ,bic.so_basis
5275 ,bic.optional
5276 ,bic.mutually_exclusive_options
5277 ,bic.check_atp
5278 ,bic.shipping_allowed
5279 ,bic.required_to_ship
5280 ,bic.required_for_revenue
5281 ,bic.include_on_ship_docs
5282 ,bic.quantity_related
5283 ,bic.supply_subinventory
5284 ,bic.attribute_category
5285 ,bic.attribute1
5286 ,bic.attribute2
5287 ,bic.attribute3
5288 ,bic.attribute4
5289 ,bic.attribute5
5290 ,bic.attribute6
5291 ,bic.attribute7
5292 ,bic.attribute8
5293 ,bic.attribute9
5294 ,bic.attribute10
5295 ,bic.attribute11
5296 ,bic.attribute12
5297 ,bic.attribute13
5298 ,bic.attribute14
5299 ,bic.attribute15
5300 ,bic.from_end_item_unit_number
5301 ,bic.to_end_item_unit_number
5302 ,bic.enforce_int_requirements
5303 ,bic.auto_request_material
5304 ,bic.suggested_vendor_name
5305 ,bic.unit_price
5306 ,bic.original_system_reference
5307 FROM
5308 bom_inventory_components bic
5309 ,eng_revised_items eri
5310 ,mtl_item_flexfields mif
5311 WHERE
5312 eri.change_id = p_change_id AND
5313 eri.revised_item_id = p_revised_item_id AND
5314 bic.revised_item_sequence_id(+)=eri.revised_item_sequence_id AND
5315 mif.inventory_item_id=bic.component_item_id AND
5316 mif.organization_id=eri.organization_id;
5317
5318 CURSOR c_revised_item(p_change_id IN VARCHAR2) IS
5319 SELECT
5320 eri.revised_item_id
5321 ,mif.item_number revised_item_name
5322 ,eri.new_item_revision
5323 ,eri.alternate_bom_designator
5324 ,eri.status_code
5325 ,eri.status_type
5326 ,eri.mrp_active
5327 ,mif1.item_number use_up_item_name
5328 ,eri.use_up_plan_name
5329 ,eri.disposition_type
5330 ,eri.update_wip
5331 ,eri.cancel_comments
5332 ,eri.attribute_category
5333 ,eri.attribute1
5334 ,eri.attribute2
5335 ,eri.attribute3
5336 ,eri.attribute4
5337 ,eri.attribute5
5338 ,eri.attribute6
5339 ,eri.attribute7
5340 ,eri.attribute8
5341 ,eri.attribute9
5342 ,eri.attribute10
5343 ,eri.attribute11
5344 ,eri.attribute12
5345 ,eri.attribute13
5346 ,eri.attribute14
5347 ,eri.attribute15
5348 ,eri.scheduled_date
5349 ,eri.from_end_item_unit_number
5350 ,eri.original_system_reference
5351 ,eri.from_cum_qty
5352 ,eri.lot_number
5353 ,eri.completion_subinventory
5354 ,eri.priority
5355 ,eri.ctp_flag
5356 ,eri.new_routing_revision
5357 ,eri.routing_comment
5358 ,eri.eco_for_production
5359 ,eri.transfer_or_copy
5360 ,eri.transfer_or_copy_item
5361 ,eri.transfer_or_copy_bill
5362 ,eri.transfer_or_copy_routing
5363 ,eri.copy_to_item
5364 ,eri.copy_to_item_desc
5365 ,eri.selection_option
5366 ,eri.selection_date
5367 ,eri.selection_unit_number
5368 ,eri.enable_item_in_local_org
5369 ,eri.create_bom_in_local_org
5370 ,eri.new_structure_revision
5371 ,eri.plan_level
5372 ,eri.new_revision_label
5373 ,eri.new_revision_reason
5374 ,eri.revised_item_sequence_id
5375 ,eriv.revised_item_status
5376 ,eri.organization_id
5377 FROM
5378 eng_revised_items eri
5379 ,mtl_item_flexfields mif
5380 ,mtl_item_flexfields mif1
5381 ,eng_revised_items_v eriv
5382 WHERE
5383 eri.change_id = p_change_id AND
5384 mif.inventory_item_id = eri.revised_item_id AND
5385 mif.organization_id = eri.organization_id AND
5386 mif1.inventory_item_id(+) = eri.use_up_item_id AND
5387 eri.revised_item_sequence_id = eriv.revised_item_sequence_id AND
5388 mif1.organization_id(+) = eri.organization_id;
5389
5390 CURSOR c_structure_header(p_change_id IN VARCHAR2,p_revised_item_id IN NUMBER) IS
5391 SELECT
5392 msl.concatenated_segments
5393 ,bev.common_organization_name
5394 ,bev.assembly_type
5395 ,bev.attribute1
5396 ,bev.attribute2
5397 ,bev.attribute3
5398 ,bev.attribute4
5399 ,bev.attribute5
5400 ,bev.attribute6
5401 ,bev.attribute7
5402 ,bev.attribute8
5403 ,bev.attribute9
5404 ,bev.attribute10
5405 ,bev.attribute11
5406 ,bev.attribute12
5407 ,bev.attribute13
5408 ,bev.attribute14
5409 ,bev.attribute15
5410 ,bev.bom_implementation_date
5411 ,bst.structure_type_name
5412 FROM
5413 bom_explosions_v bev
5414 ,eng_revised_items eri
5415 ,bom_structure_types_vl bst
5416 ,mtl_system_items_vl msl
5417 WHERE
5418 eri.change_id = p_change_id AND
5419 bev.assembly_item_id = p_revised_item_id AND
5420 bev.access_flag = 'T' AND
5421 bev.organization_id = eri.organization_id(+) AND
5422 bst.structure_type_id = bev.structure_type_id AND
5423 msl.inventory_item_id(+) = bev.assembly_item_id AND
5424 msl.organization_id(+) = bev.organization_id;
5425
5426 c_bom_header c_structure_header%ROWTYPE;
5427
5428 CURSOR c_change_id(p_revised_item_sequence_id IN NUMBER) IS
5429 SELECT
5430 change_id
5431 FROM
5432 eng_Revised_items
5433 WHERE
5434 revised_item_sequence_id = p_revised_item_sequence_id;
5435
5436 BEGIN
5437 INV_EBI_UTIL.debug_line('STEP 10: START INSIDE INV_EBI_CHANGE_ORDER_HELPER.get_eco');
5438 x_return_status := fnd_api.g_ret_sts_success;
5439 l_change_id := p_change_id ;
5440 l_revised_item_sequence_id := p_revised_item_sequence_id;
5441
5442 FND_MSG_PUB.initialize();
5443 IF (l_change_id IS NULL AND l_revised_item_sequence_id IS NULL) THEN
5444 FND_MESSAGE.set_name('INV','INV_EBI_CHG_ID_REV_SEQ_NULL');
5445 FND_MSG_PUB.add;
5446 RAISE FND_API.g_exc_error;
5447 END IF;
5448
5449 IF (l_revised_item_sequence_id IS NOT NULL AND l_change_id IS NULL) THEN
5450 OPEN c_change_id(l_revised_item_sequence_id);
5451 FETCH c_change_id INTO l_change_id;
5452 IF c_change_id%NOTFOUND THEN
5453 FND_MESSAGE.set_name('INV','INV_EBI_REV_SEQ_ID_INVALID');
5454 FND_MESSAGE.set_token('REV_SEQ_ID',l_revised_item_sequence_id);
5455 FND_MSG_PUB.add;
5456 RAISE FND_API.g_exc_error;
5457 END IF;
5458 CLOSE c_change_id;
5459 END IF;
5460
5461 IF p_name_val_list.name_value_table IS NOT NULL THEN
5462 FOR i in p_name_val_list.name_value_table.FIRST..p_name_val_list.name_value_table.LAST LOOP
5463 IF UPPER(p_name_val_list.name_value_table(i).param_name) = G_INCLUDE_REV_ITEMS THEN
5464 l_include_rev_items := p_name_val_list.name_value_table(i).param_value;
5465 END IF;
5466 IF UPPER(p_name_val_list.name_value_table(i).param_name) = G_INCLUDE_COMP_ITEMS THEN
5467 l_include_comp_items := p_name_val_list.name_value_table(i).param_value;
5468 END IF;
5469 IF UPPER(p_name_val_list.name_value_table(i).param_name) = G_INCLUDE_SUB_COMP THEN
5470 l_include_sub_comp := p_name_val_list.name_value_table(i).param_value;
5471 END IF;
5472 IF UPPER(p_name_val_list.name_value_table(i).param_name) = G_INCLUDE_REF_DESIGNATORS THEN
5473 l_include_ref_designators := p_name_val_list.name_value_table(i).param_value;
5474 END IF;
5475 END LOOP;
5476 END IF;
5477
5478 IF NVL(p_last_update_status,'Y') = 'N' THEN
5479 l_include_rev_items := fnd_api.g_false;
5480 l_include_comp_items := fnd_api.g_false;
5481 l_include_sub_comp := fnd_api.g_false;
5482 l_include_ref_designators := fnd_api.g_false;
5483 END IF;
5484 l_eco_revision_tbl := inv_ebi_eco_revision_tbl();
5485
5486 OPEN c_change_order_type (l_change_id);
5487 FETCH c_change_order_type INTO c_eco_header;
5488 IF c_change_order_type%NOTFOUND THEN
5489 FND_MESSAGE.set_name('INV','INV_EBI_CHG_ID_INVALID');
5490 FND_MESSAGE.set_token('CHG_ID',l_change_id);
5491 FND_MSG_PUB.add;
5492 RAISE FND_API.g_exc_error;
5493 END IF;
5494 l_eco_change_order_obj := inv_ebi_change_order_obj(
5495 c_eco_header.change_notice
5496 ,l_change_id
5497 ,c_eco_header.change_notice_prefix
5498 ,c_eco_header.change_notice_number
5499 ,c_eco_header.organization_code
5500 ,c_eco_header.organization_id
5501 ,c_eco_header.change_name
5502 ,c_eco_header.description
5503 ,c_eco_header.cancellation_comments
5504 ,c_eco_header.status_code
5505 ,c_eco_header.status_name
5506 ,c_eco_header.priority_code
5507 ,c_eco_header.reason_code
5508 ,c_eco_header.estimated_eng_cost
5509 ,c_eco_header.estimated_mfg_cost
5510 ,NULL
5511 ,c_eco_header.attribute_category
5512 ,c_eco_header.attribute1
5513 ,c_eco_header.attribute2
5514 ,c_eco_header.attribute3
5515 ,c_eco_header.attribute4
5516 ,c_eco_header.attribute5
5517 ,c_eco_header.attribute6
5518 ,c_eco_header.attribute7
5519 ,c_eco_header.attribute8
5520 ,c_eco_header.attribute9
5521 ,c_eco_header.attribute10
5522 ,c_eco_header.attribute11
5523 ,c_eco_header.attribute12
5524 ,c_eco_header.attribute13
5525 ,c_eco_header.attribute14
5526 ,c_eco_header.attribute15
5527 ,c_eco_header.ddf_context
5528 ,c_eco_header.approval_list_name
5529 ,NULL
5530 ,c_eco_header.approval_date
5531 ,c_eco_header.approval_request_date
5532 ,c_eco_header.change_order_type_id
5533 ,c_eco_header.type_name
5534 ,c_eco_header.change_mgmt_type_code
5535 ,c_eco_header.original_system_reference
5536 ,c_eco_header.organization_hierarchy
5537 ,NULL --c_eco_header.party_name --assignee
5538 ,NULL --c_eco_header.name --project_name
5539 ,NULL --c_eco_header.name --task_number
5540 ,c_eco_header.source_type_code
5541 ,c_eco_header.source_name
5542 ,c_eco_header.need_by_date
5543 ,c_eco_header.effort
5544 ,NULL --c_eco_header.name --eco_department_name
5545 ,NULL --transaction_id
5546 ,NULL --transaction_type
5547 ,c_eco_header.internal_use_only
5548 ,NULL --return_status
5549 ,c_eco_header.plm_or_erp_change
5550 ,NULL
5551 ,NULL
5552 ,NULL
5553 ,NULL
5554 ,NULL
5555 ,c_eco_header.status_type
5556 ,c_eco_header.implementation_date
5557 ,c_eco_header.cancellation_date
5558 ,NULL
5559 ,NULL
5560 ,NULL
5561 ,NULL
5562 ,NULL);
5563 CLOSE c_change_order_type;
5564
5565 l_revised_item_tbl := inv_ebi_revised_item_tbl();
5566
5567 l_current_index :=1;
5568 FOR cer IN c_eco_revision(l_change_id)
5569 LOOP
5570 l_eco_revision_tbl.extend();
5571 l_eco_revision_obj := inv_ebi_eco_revision_obj(
5572 cer.revision
5573 ,NULL
5574 ,cer.comments
5575 ,cer.attribute_category
5576 ,cer.attribute1
5577 ,cer.attribute2
5578 ,cer.attribute3
5579 ,cer.attribute4
5580 ,cer.attribute5
5581 ,cer.attribute6
5582 ,cer.attribute7
5583 ,cer.attribute8
5584 ,cer.attribute9
5585 ,cer.attribute10
5586 ,cer.attribute11
5587 ,cer.attribute12
5588 ,cer.attribute13
5589 ,cer.attribute14
5590 ,cer.attribute15
5591 ,cer.change_mgmt_type_code
5592 ,cer.original_system_reference
5593 ,NULL
5594 ,NULL
5595 ,NULL
5596 );
5597 l_eco_revision_tbl(l_current_index) := l_eco_revision_obj;
5598 l_current_index := l_current_index + 1;
5599 END LOOP;
5600
5601 IF (l_include_rev_items = fnd_api.g_true) THEN
5602 l_reviseditem_index := 1;
5603 FOR ri IN c_revised_item(l_change_id)
5604 LOOP
5605 OPEN c_structure_header(l_change_id,ri.revised_item_id);
5606 FETCH c_structure_header INTO c_bom_header;
5607 l_structure_header_obj := inv_ebi_structure_header_obj(
5608 c_bom_header.concatenated_segments
5609 ,c_bom_header.common_organization_name
5610 ,NULL
5611 ,c_bom_header.assembly_type
5612 ,NULL
5613 ,NULL
5614 ,NULL
5615 ,c_bom_header.attribute1
5616 ,c_bom_header.attribute2
5617 ,c_bom_header.attribute3
5618 ,c_bom_header.attribute4
5619 ,c_bom_header.attribute5
5620 ,c_bom_header.attribute6
5621 ,c_bom_header.attribute7
5622 ,c_bom_header.attribute8
5623 ,c_bom_header.attribute9
5624 ,c_bom_header.attribute10
5625 ,c_bom_header.attribute11
5626 ,c_bom_header.attribute12
5627 ,c_bom_header.attribute13
5628 ,c_bom_header.attribute14
5629 ,c_bom_header.attribute15
5630 ,NULL
5631 ,NULL
5632 ,NULL
5633 ,NULL
5634 ,c_bom_header.bom_implementation_date
5635 ,NULL
5636 ,c_bom_header.structure_type_name
5637 ,NULL
5638 );
5639 CLOSE c_structure_header;
5640 l_comp_index := 1;
5641 l_revision_component_tbl := inv_ebi_rev_comp_tbl();
5642 IF (l_include_comp_items = fnd_api.g_true) THEN
5643 FOR rc IN c_revision_component(l_change_id,ri.revised_item_id)
5644 LOOP
5645 l_ref_index := 1;
5646 l_reference_designator_tbl := inv_ebi_ref_desg_tbl();
5647 IF (l_include_ref_designators = fnd_api.g_true) THEN
5648 FOR rd IN c_reference_designator(l_change_id,ri.revised_item_id,rc.component_item_id)
5649 LOOP
5650 l_reference_designator_tbl.extend();
5651 l_reference_designator_obj := inv_ebi_ref_desg_obj(
5652 NULL
5653 ,rd.reference_designator_name
5654 ,rd.acd_type
5655 ,rd.ref_designator_comment
5656 ,rd.attribute_category
5657 ,rd.attribute1
5658 ,rd.attribute2
5659 ,rd.attribute3
5660 ,rd.attribute4
5661 ,rd.attribute5
5662 ,rd.attribute6
5663 ,rd.attribute7
5664 ,rd.attribute8
5665 ,rd.attribute9
5666 ,rd.attribute10
5667 ,rd.attribute11
5668 ,rd.attribute12
5669 ,rd.attribute13
5670 ,rd.attribute14
5671 ,rd.attribute15
5672 ,rd.original_system_reference
5673 ,NULL
5674 ,NULL
5675 ,NULL
5676 ,NULL
5677 ,NULL
5678 ,NULL
5679 ,NULL);
5680 l_reference_designator_tbl(l_ref_index) := l_reference_designator_obj;
5681 l_ref_index := l_ref_index + 1;
5682 END LOOP;
5683 END IF; -- IF (l_include_ref_designators = fnd_api.g_true) THEN
5684
5685 l_sub_index :=1;
5686 l_substitute_component_tbl := inv_ebi_sub_comp_tbl();
5687 IF (l_include_sub_comp = fnd_api.g_true) THEN
5688 FOR sc IN c_substitute_component(l_change_id,ri.revised_item_id,rc.component_item_id)
5689 LOOP
5690 l_substitute_component_tbl.extend();
5691 l_substitute_component_obj := inv_ebi_sub_comp_obj(
5692 NULL
5693 ,sc.substitute_component_name
5694 ,NULL
5695 ,sc.acd_type
5696 ,sc.substitute_item_quantity
5697 ,sc.attribute_category
5698 ,sc.attribute1
5699 ,sc.attribute2
5700 ,sc.attribute3
5701 ,sc.attribute4
5702 ,sc.attribute5
5703 ,sc.attribute6
5704 ,sc.attribute7
5705 ,sc.attribute8
5706 ,sc.attribute9
5707 ,sc.attribute10
5708 ,sc.attribute11
5709 ,sc.attribute12
5710 ,sc.attribute13
5711 ,sc.attribute14
5712 ,sc.attribute15
5713 ,sc.original_system_reference
5714 ,NULL
5715 ,NULL
5716 ,sc.enforce_int_requirements
5717 ,NULL
5718 ,NULL
5719 ,NULL
5720 ,NULL
5721 ,sc.program_id
5722 ,NULL);
5723 l_substitute_component_tbl(l_sub_index) := l_substitute_component_obj;
5724 l_sub_index := l_sub_index + 1;
5725 END LOOP;
5726 END IF; -- IF (l_include_sub_comp = fnd_api.g_true) THEN
5727
5728 l_revision_component_tbl.extend();
5729 l_revision_component_obj := inv_ebi_rev_comp_obj(
5730 NULL
5731 ,NULL
5732 ,rc.disable_date
5733 ,rc.operation_seq_num
5734 ,rc.component_item_name
5735 ,l_substitute_component_tbl
5736 ,l_reference_designator_tbl
5737 ,rc.acd_type
5738 ,NULL
5739 ,NULL
5740 ,NULL
5741 ,NULL
5742 ,rc.basis_type
5743 ,rc.component_quantity
5744 ,rc.inverse_quantity
5745 ,NULL
5746 ,NULL
5747 ,rc.include_in_cost_rollup
5748 ,rc.wip_supply_type
5749 ,rc.so_basis
5750 ,rc.optional
5751 ,rc.mutually_exclusive_options
5752 ,rc.check_atp
5753 ,rc.shipping_allowed
5754 ,rc.required_to_ship
5755 ,rc.required_for_revenue
5756 ,rc.include_on_ship_docs
5757 ,rc.quantity_related
5758 ,rc.supply_subinventory
5759 ,NULL
5760 ,NULL
5761 ,NULL
5762 ,NULL
5763 ,NULL
5764 ,rc.attribute_category
5765 ,rc.attribute1
5766 ,rc.attribute2
5767 ,rc.attribute3
5768 ,rc.attribute4
5769 ,rc.attribute5
5770 ,rc.attribute6
5771 ,rc.attribute7
5772 ,rc.attribute8
5773 ,rc.attribute9
5774 ,rc.attribute10
5775 ,rc.attribute11
5776 ,rc.attribute12
5777 ,rc.attribute13
5778 ,rc.attribute14
5779 ,rc.attribute15
5780 ,rc.from_end_item_unit_number
5781 ,NULL
5782 ,NULL
5783 ,rc.to_end_item_unit_number
5784 ,NULL
5785 ,rc.enforce_int_requirements
5786 ,rc.auto_request_material
5787 ,rc.suggested_vendor_name
5788 ,rc.unit_price
5789 ,rc.original_system_reference
5790 ,NULL
5791 ,NULL
5792 ,NULL
5793 ,NULL
5794 ,NULL
5795 ,NULL
5796 ,NULL
5797 ,NULL);
5798 l_revision_component_tbl(l_comp_index) := l_revision_component_obj;
5799 l_comp_index := l_comp_index + 1;
5800 END LOOP;
5801 END IF; -- IF (l_include_comp_items = fnd_api.g_true) THEN
5802
5803
5804 IF (l_revised_item_sequence_id IS NULL
5805 OR ri.revised_item_sequence_id = l_revised_item_sequence_id) THEN
5806
5807 l_revised_item_tbl.extend();
5808 l_item_obj :=inv_ebi_item_obj(NULL
5809 ,NULL
5810 ,NULL
5811 ,NULL
5812 ,NULL
5813 ,NULL
5814 ,NULL
5815 ,NULL
5816 ,NULL
5817 ,NULL
5818 ,NULL
5819 ,NULL
5820 ,NULL
5821 ,NULL
5822 ,NULL
5823 ,NULL
5824 ,NULL
5825 ,NULL
5826 ,NULL
5827 ,NULL
5828 ,NULL
5829 ,NULL
5830 ,NULL
5831 ,NULL
5832 ,NULL
5833 ,NULL
5834 ,NULL
5835 ,NULL
5836 );
5837 INV_EBI_ITEM_HELPER.get_Operating_unit
5838 (p_oranization_id => ri.organization_id
5839 ,x_operating_unit => l_item_obj.operating_unit
5840 ,x_ouid => l_item_obj.operating_unit_id
5841 );
5842 l_revised_item_obj := inv_ebi_revised_item_obj(
5843 ri.revised_item_name
5844 ,ri.revised_item_id
5845 ,ri.new_item_revision
5846 ,NULL
5847 ,NULL
5848 ,NULL
5849 ,l_item_obj
5850 ,l_structure_header_obj
5851 ,l_revision_component_tbl
5852 ,NULL
5853 ,NULL
5854 ,NULL
5855 ,ri.scheduled_date
5856 ,ri.alternate_bom_designator
5857 ,ri.status_type
5858 ,ri.status_code
5859 ,ri.revised_item_status
5860 ,ri.mrp_active
5861 ,NULL
5862 ,ri.use_up_item_name
5863 ,ri.use_up_plan_name
5864 ,NULL
5865 ,ri.disposition_type
5866 ,ri.update_wip
5867 ,ri.cancel_comments
5868 ,NULL
5869 ,ri.attribute_category
5870 ,ri.attribute1
5871 ,ri.attribute2
5872 ,ri.attribute3
5873 ,ri.attribute4
5874 ,ri.attribute5
5875 ,ri.attribute6
5876 ,ri.attribute7
5877 ,ri.attribute8
5878 ,ri.attribute9
5879 ,ri.attribute10
5880 ,ri.attribute11
5881 ,ri.attribute12
5882 ,ri.attribute13
5883 ,ri.attribute14
5884 ,ri.attribute15
5885 ,ri.from_end_item_unit_number
5886 ,NULL
5887 ,ri.original_system_reference
5888 ,NULL
5889 ,NULL
5890 ,NULL
5891 ,NULL
5892 ,NULL
5893 ,ri.from_cum_qty
5894 ,ri.lot_number
5895 ,ri.completion_subinventory
5896 ,NULL
5897 ,ri.priority
5898 ,ri.ctp_flag
5899 ,ri.new_routing_revision
5900 ,NULL
5901 ,ri.routing_comment
5902 ,ri.eco_for_production
5903 ,NULL
5904 ,ri.transfer_or_copy
5905 ,ri.transfer_or_copy_item
5906 ,ri.transfer_or_copy_bill
5907 ,ri.transfer_or_copy_routing
5908 ,ri.copy_to_item
5909 ,ri.copy_to_item_desc
5910 ,NULL
5911 ,NULL
5912 ,ri.selection_option
5913 ,ri.selection_date
5914 ,ri.selection_unit_number
5915 ,NULL
5916 ,NULL
5917 ,NULL
5918 ,NULL
5919 ,ri.enable_item_in_local_org
5920 ,ri.create_bom_in_local_org
5921 ,ri.new_structure_revision
5922 ,ri.plan_level
5923 ,NULL
5924 ,NULL
5925 ,NULL
5926 ,NULL
5927 ,NULL
5928 ,ri.new_revision_label
5929 ,ri.new_revision_reason
5930 ,NULL
5931 ,NULL
5932 ,NULL
5933 ,NULL
5934 ,NULL
5935 ,NULL
5936 ,NULL);
5937
5938 l_revised_item_tbl(l_reviseditem_index) := l_revised_item_obj;
5939 l_reviseditem_index := l_reviseditem_index + 1;
5940 END IF;
5941 END LOOP;
5942 END IF; -- IF (l_include_rev_items = fnd_api.g_true) THEN
5943
5944 IF (INV_EBI_UTIL.is_pim_installed) THEN --Bug 8369900 To check is_pim_installed for reverse flow
5945 --Bug 7240247 To Retrieve Change order Header level Udas if any exists for this change_id
5946 INV_EBI_UTIL.debug_line('STEP 20: BEFORE CALLING INV_EBI_CHANGE_ORDER_HELPER.get_change_order_uda');
5947 get_change_order_uda(
5948 p_change_id => p_change_id,
5949 x_change_uda => l_eco_change_order_obj.change_order_uda,
5950 x_return_status => x_return_status,
5951 x_msg_count => x_msg_count,
5952 x_msg_data => x_msg_data
5953 );
5954 INV_EBI_UTIL.debug_line('STEP 30: AFTER CALLING INV_EBI_CHANGE_ORDER_HELPER.get_change_order_uda STATUS: '||x_return_status);
5955 IF(x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
5956 RAISE FND_API.g_exc_unexpected_error;
5957 END IF;
5958
5959 --Bug 7240247 To Retrieve Structure Header level Udas if any exists for this change_id
5960 FOR i IN 1..l_revised_item_tbl.COUNT LOOP
5961 INV_EBI_UTIL.debug_line('STEP 40: BEFORE CALLING INV_EBI_CHANGE_ORDER_HELPER.get_structure_header_uda');
5962 get_structure_header_uda(
5963 p_assembly_item_id => l_revised_item_tbl(i).revised_item_id,
5964 p_alternate_bom_code => l_revised_item_tbl(i).alternate_bom_code,
5965 p_organization_id => l_eco_change_order_obj.organization_id,
5966 x_structure_header_uda => l_revised_item_tbl(i).structure_header.structure_header_uda,
5967 x_return_status => x_return_status,
5968 x_msg_count => x_msg_count,
5969 x_msg_data => x_msg_data
5970 );
5971 INV_EBI_UTIL.debug_line('STEP 50: AFTER CALLING INV_EBI_CHANGE_ORDER_HELPER.get_structure_header_uda STATUS: '||x_return_status);
5972 IF(x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
5973 RAISE FND_API.g_exc_unexpected_error;
5974 END IF;
5975
5976 --Bug 7240247
5977 FOR j IN 1..l_revised_item_tbl(i).component_item_tbl.COUNT LOOP
5978 INV_EBI_UTIL.debug_line('STEP 60: BEFORE CALLING INV_EBI_CHANGE_ORDER_HELPER.get_component_item_uda');
5979 get_component_item_uda(
5980 p_eco_name => l_eco_change_order_obj.eco_name,
5981 p_revised_item_id => l_revised_item_tbl(i).revised_item_id,
5982 p_component_item_name => l_revised_item_tbl(i).component_item_tbl(j).component_item_name,
5983 p_alternate_bom_code => l_revised_item_tbl(i).alternate_bom_code,
5984 p_organization_id => l_eco_change_order_obj.organization_id,
5985 x_comp_item_uda => l_revised_item_tbl(i).component_item_tbl(j).component_revision_uda,
5986 x_return_status => x_return_status,
5987 x_msg_count => x_msg_count,
5988 x_msg_data => x_msg_data
5989 );
5990 INV_EBI_UTIL.debug_line('STEP 70: AFTER CALLING INV_EBI_CHANGE_ORDER_HELPER.get_component_item_uda STATUS: '||x_return_status);
5991 IF(x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
5992 RAISE FND_API.g_exc_unexpected_error;
5993 END IF;
5994 END LOOP;
5995
5996 END LOOP;
5997 END IF;-- Bug 8369900 end
5998 x_eco_obj := inv_ebi_eco_obj(l_eco_change_order_obj,l_eco_revision_tbl,l_revised_item_tbl,NULL);
5999 INV_EBI_UTIL.debug_line('STEP 80: END CALLING INV_EBI_CHANGE_ORDER_HELPER.get_eco');
6000 EXCEPTION
6001 WHEN FND_API.g_exc_error THEN
6002 x_return_status := FND_API.g_ret_sts_error;
6003 IF(x_msg_data IS NULL) THEN
6004 FND_MSG_PUB.count_and_get(
6005 p_encoded => FND_API.g_false
6006 ,p_count => x_msg_count
6007 ,p_data => x_msg_data
6008 );
6009 END IF;
6010 WHEN OTHERS THEN
6011 x_return_status := FND_API.g_ret_sts_error;
6012 IF (x_msg_data IS NOT NULL) THEN
6013 x_msg_data := x_msg_data ||' -> at INV_EBI_CHANGE_ORDER_HELPER.get_eco';
6014 ELSE
6015 x_msg_data := SQLERRM||' at INV_EBI_CHANGE_ORDER_HELPER.get_eco ';
6016 END IF;
6017 END get_eco;
6018
6019 /************************************************************************************
6020 -- API name : filter_ecos_based_on_org
6021 -- Type : Public
6022 -- Function : To filter eco's based on the given organization
6023 ************************************************************************************/
6024
6025 PROCEDURE filter_ecos_based_on_org(
6026 p_org_codes IN VARCHAR2
6027 ,p_eco_tbl IN inv_ebi_change_id_obj_tbl
6028 ,x_eco_tbl OUT NOCOPY inv_ebi_change_id_obj_tbl
6029 ,x_return_status OUT NOCOPY VARCHAR2
6030 ,x_msg_count OUT NOCOPY NUMBER
6031 ,x_msg_data OUT NOCOPY VARCHAR2)
6032 IS
6033 l_org_tbl FND_TABLE_OF_VARCHAR2_255;
6034 l_eco_output_tbl inv_ebi_change_id_obj_tbl;
6035 l_counter NUMBER:=0;
6036 l_org_code VARCHAR2(10);
6037 BEGIN
6038 x_return_status := FND_API.g_ret_sts_success;
6039 INV_EBI_UTIL.debug_line('STEP 10: START INSIDE INV_EBI_CHANGE_ORDER_HELPER.filter_ecos_based_on_org');
6040 INV_EBI_UTIL.debug_line('STEP 20: ORG CODES'||p_org_codes);
6041 l_eco_output_tbl := inv_ebi_change_id_obj_tbl();
6042
6043 IF p_org_codes IS NOT NULL THEN
6044 l_org_tbl := INV_EBI_ITEM_HELPER.parse_input_string(p_org_codes);
6045 END IF;
6046
6047 IF p_eco_tbl IS NOT NULL AND p_eco_tbl.COUNT>0 THEN
6048 FOR i in p_eco_tbl.FIRST..p_eco_tbl.LAST LOOP
6049 l_org_code := NULL;
6050 SELECT mp.organization_code INTO l_org_code
6051 FROM eng_engineering_changes ec, mtl_parameters mp
6052 WHERE ec.change_id = p_eco_tbl(i).change_id
6053 AND ec.organization_id = mp.organization_id;
6054 IF l_org_tbl IS NOT NULL AND l_org_tbl.COUNT>0 THEN
6055 FOR j in l_org_tbl.FIRST..l_org_tbl.LAST LOOP
6056 IF (l_org_code = l_org_tbl(j)) THEN
6057 l_counter := l_counter + 1;
6058 l_eco_output_tbl.EXTEND(1);
6059 l_eco_output_tbl(l_counter) := p_eco_tbl(i);
6060 EXIT;
6061 END IF;
6062 END LOOP;
6063 END IF;
6064 END LOOP;
6065 END IF;
6066
6067 x_eco_tbl := l_eco_output_tbl;
6068 IF (x_eco_tbl.count > 0 ) THEN
6069 FOR i IN 1 .. x_eco_tbl.count
6070 LOOP
6071 INV_EBI_UTIL.debug_line('STEP 30: CHANGE ID NUMBER IS '|| x_eco_tbl(i).change_id);
6072 INV_EBI_UTIL.debug_line('STEP 40: LAST UPDATE STATUS '|| x_eco_tbl(i).last_update_status);
6073 END LOOP;
6074 END IF;
6075 INV_EBI_UTIL.debug_line('STEP 50: END INSIDE INV_EBI_CHANGE_ORDER_HELPER.filter_ecos_based_on_org STATUS: '|| x_return_status);
6076 EXCEPTION
6077 WHEN OTHERS THEN
6078 x_return_status := FND_API.g_ret_sts_unexp_error;
6079 x_msg_data := SQLERRM ||' at INV_EBI_ITEM_HELPER.filter_ecos_based_on_org';
6080 END filter_ecos_based_on_org;
6081
6082 /***************************************************************************************************
6083 -- API name : parse_and_get_eco
6084 -- Type : Private For Internal Use Only
6085 -- Purpose : To parse the input string and get lis of eco
6086 *****************************************************************************************************/
6087 PROCEDURE parse_and_get_eco(
6088 p_eco_names IN VARCHAR2
6089 ,p_org_codes IN VARCHAR2
6090 ,x_eco_tbl OUT NOCOPY inv_ebi_change_id_obj_tbl
6091 ,x_return_status OUT NOCOPY VARCHAR2
6092 ,x_msg_count OUT NOCOPY NUMBER
6093 ,x_msg_data OUT NOCOPY VARCHAR2)
6094 IS
6095 l_return_status VARCHAR2(2);
6096 l_msg_data VARCHAR2(2000);
6097 l_chg_id NUMBER;
6098 l_org_id NUMBER;
6099 l_count NUMBER:=0;
6100 l_counter NUMBER := 0;
6101 l_entity_exist NUMBER :=0;
6102 l_entity_count NUMBER :=0;
6103 l_eco_obj inv_ebi_change_id_obj;
6104 l_eco_output_tbl inv_ebi_change_id_obj_tbl;
6105 l_eco_tbl FND_TABLE_OF_VARCHAR2_255;
6106 l_org_tbl FND_TABLE_OF_VARCHAR2_255;
6107 l_valid_eco_tbl FND_TABLE_OF_VARCHAR2_255;
6108 l_valid_org_tbl FND_TABLE_OF_VARCHAR2_255;
6109 l_pk_col_name_val_pairs INV_EBI_ITEM_HELPER.inv_ebi_name_value_pair_tbl ;
6110 CURSOR c_get_all_orgs( p_chg_notice VARCHAR2) IS
6111 SELECT change_id
6112 FROM eng_engineering_changes
6113 WHERE change_notice = p_chg_notice;
6114 BEGIN
6115 x_return_status := FND_API.g_ret_sts_success;
6116 INV_EBI_UTIL.debug_line('STEP 10: START INSIDE INV_EBI_CHANGE_ORDER_HELPER.parse_and_get_eco');
6117 INV_EBI_UTIL.debug_line('STEP 20: CHANGE ORDER NAMES '|| p_eco_names);
6118 INV_EBI_UTIL.debug_line('STEP 30: ORG CODE NAMES '|| p_org_codes);
6119 l_eco_output_tbl :=inv_ebi_change_id_obj_tbl();
6120
6121 IF p_eco_names IS NOT NULL THEN
6122 l_eco_tbl := INV_EBI_ITEM_HELPER.parse_input_string(p_eco_names);
6123 END IF;
6124
6125 IF p_org_codes IS NOT NULL THEN
6126 l_org_tbl := INV_EBI_ITEM_HELPER.parse_input_string(p_org_codes);
6127 END IF;
6128
6129 IF l_eco_tbl IS NOT NULL AND l_eco_tbl.COUNT > 0 THEN
6130 l_valid_eco_tbl := FND_TABLE_OF_VARCHAR2_255();
6131 l_entity_count :=0;
6132 FOR i in l_eco_tbl.FIRST..l_eco_tbl.LAST LOOP
6133 BEGIN
6134 FND_MSG_PUB.initialize();
6135 SELECT COUNT(1) into l_entity_exist
6136 FROM eng_engineering_changes
6137 WHERE change_notice = l_eco_tbl(i);
6138 IF l_entity_exist>0 THEN
6139 l_entity_count := l_entity_count +1;
6140 l_valid_eco_tbl.EXTEND();
6141 l_valid_eco_tbl(l_entity_count) := l_eco_tbl(i);
6142 ELSE
6143 FND_MESSAGE.set_name('INV','INV_EBI_ITEM_INVALID');
6144 FND_MESSAGE.set_token('COL_VALUE', l_eco_tbl(i));
6145 FND_MSG_PUB.add;
6146 RAISE FND_API.G_EXC_ERROR;
6147 END IF;
6148 EXCEPTION
6149 WHEN FND_API.G_EXC_ERROR THEN
6150 x_return_status := FND_API.g_ret_sts_error;
6151 FND_MSG_PUB.count_and_get( p_encoded => FND_API.g_false
6152 ,p_count => x_msg_count
6153 ,p_data => l_msg_data
6154 );
6155 x_msg_data := x_msg_data || l_msg_data ||' , ' ;
6156 WHEN OTHERS THEN
6157 x_return_status := FND_API.g_ret_sts_error;
6158 x_msg_data := SQLERRM ||' at INV_EBI_CHANGE_ORDER_HELPER.parse_and_get_eco';
6159 END;
6160 END LOOP;
6161 END IF;
6162
6163 IF l_org_tbl IS NOT NULL AND l_org_tbl.COUNT > 0 THEN
6164 l_valid_org_tbl := FND_TABLE_OF_VARCHAR2_255();
6165 l_entity_count :=0;
6166 FOR i in l_org_tbl.FIRST..l_org_tbl.LAST LOOP
6167 BEGIN
6168 FND_MSG_PUB.initialize();
6169 SELECT COUNT(1) into l_entity_exist
6170 FROM mtl_parameters
6171 WHERE organization_code = l_org_tbl(i);
6172 IF l_entity_exist>0 THEN
6173 l_entity_count := l_entity_count +1;
6174 l_valid_org_tbl.EXTEND();
6175 l_valid_org_tbl(l_entity_count) := l_org_tbl(i);
6176 ELSE
6177 FND_MESSAGE.set_name('INV','INV_EBI_ORG_CODE_INVALID');
6178 FND_MESSAGE.set_token('COL_VALUE', l_org_tbl(i));
6179 FND_MSG_PUB.add;
6180 RAISE FND_API.G_EXC_ERROR;
6181 END IF;
6182 EXCEPTION
6183 WHEN FND_API.G_EXC_ERROR THEN
6184 x_return_status := FND_API.g_ret_sts_error;
6185 FND_MSG_PUB.count_and_get( p_encoded => FND_API.g_false
6186 ,p_count => x_msg_count
6187 ,p_data => l_msg_data
6188 );
6189 x_msg_data := x_msg_data || l_msg_data ||' , ' ;
6190 WHEN OTHERS THEN
6191 x_return_status := FND_API.g_ret_sts_error;
6192 x_msg_data := SQLERRM ||' at INV_EBI_CHANGE_ORDER_HELPER.parse_and_get_eco';
6193 END;
6194 END LOOP;
6195 END IF;
6196
6197 IF l_valid_eco_tbl IS NOT NULL AND l_valid_eco_tbl.COUNT > 0 THEN
6198 FOR i in l_valid_eco_tbl.FIRST..l_valid_eco_tbl.LAST LOOP
6199 BEGIN
6200 FND_MSG_PUB.initialize();
6201 l_count :=0;
6202 IF l_valid_org_tbl IS NOT NULL AND l_valid_org_tbl.COUNT > 0 THEN
6203 FOR j in l_valid_org_tbl.FIRST..l_valid_org_tbl.LAST LOOP
6204 l_pk_col_name_val_pairs := INV_EBI_ITEM_HELPER.inv_ebi_name_value_pair_tbl();
6205 l_pk_col_name_val_pairs.EXTEND();
6206 l_pk_col_name_val_pairs(1).name := 'organization_code';
6207 l_pk_col_name_val_pairs(1).value := l_valid_org_tbl(j);
6208 l_org_id := INV_EBI_ITEM_HELPER.value_to_id( p_pk_col_name_val_pairs => l_pk_col_name_val_pairs
6209 ,p_entity_name => INV_EBI_ITEM_HELPER.G_ORGANIZATION
6210 );
6211 l_pk_col_name_val_pairs.TRIM(1);
6212
6213 l_chg_id := NULL;
6214 BEGIN
6215 SELECT change_id
6216 INTO l_chg_id
6217 FROM eng_engineering_changes
6218 WHERE change_notice = l_valid_eco_tbl(i)
6219 AND organization_id = l_org_id;
6220 EXCEPTION
6221 WHEN OTHERS THEN
6222 NULL;
6223 END;
6224
6225 IF l_chg_id IS NOT NULL THEN
6226 l_counter := l_counter + 1;
6227 l_eco_obj := inv_ebi_change_id_obj( l_chg_id, 'Y');
6228 l_eco_output_tbl.EXTEND(1);
6229 l_eco_output_tbl(l_counter) := l_eco_obj;
6230 l_count := 1;
6231 END IF;
6232
6233 END LOOP;
6234 ELSE
6235 FOR cur IN c_get_all_orgs(l_valid_eco_tbl(i)) LOOP
6236 l_counter := l_counter + 1;
6237 l_eco_obj := inv_ebi_change_id_obj( cur.change_id, 'Y');
6238 l_eco_output_tbl.EXTEND(1);
6239 l_eco_output_tbl(l_counter) := l_eco_obj;
6240 l_count := 1;
6241 END LOOP;
6242 END IF;
6243
6244 IF l_count = 0 THEN
6245 FND_MESSAGE.set_name('INV','INV_EBI_INVALID_USER_INPUT');
6246 FND_MESSAGE.set_token('USER_INPUT', l_valid_eco_tbl(i));
6247 FND_MSG_PUB.add;
6248 RAISE FND_API.G_EXC_ERROR;
6249 END IF;
6250 EXCEPTION
6251 WHEN FND_API.G_EXC_ERROR THEN
6252 x_return_status := FND_API.g_ret_sts_error;
6253 FND_MSG_PUB.count_and_get( p_encoded => FND_API.g_false
6254 ,p_count => x_msg_count
6255 ,p_data => l_msg_data
6256 );
6257 x_msg_data := x_msg_data || l_msg_data ;
6258 WHEN OTHERS THEN
6259 x_return_status := FND_API.g_ret_sts_unexp_error;
6260 x_msg_data := SQLERRM ||' at INV_EBI_CHANGE_ORDER_HELPER.parse_and_get_eco';
6261 END;
6262 END LOOP;
6263 END IF;
6264 x_eco_tbl := l_eco_output_tbl;
6265 IF (x_eco_tbl.count > 0) THEN
6266 FOR i IN 1 .. x_eco_tbl.count
6267 LOOP
6268 INV_EBI_UTIL.debug_line('STEP 40: CHANGE ID NUMBER '|| x_eco_tbl(i).CHANGE_ID);
6269 INV_EBI_UTIL.debug_line('STEP 50: LAST UPDATE STATUS '|| x_eco_tbl(i).LAST_UPDATE_STATUS);
6270 END LOOP;
6271 END IF;
6272 INV_EBI_UTIL.debug_line('STEP 60: END INSIDE INV_EBI_CHANGE_ORDER_HELPER.parse_and_get_eco STATUS: '|| x_return_status);
6273 EXCEPTION
6274 WHEN OTHERS THEN
6275 x_return_status := FND_API.g_ret_sts_unexp_error;
6276 x_msg_data := SQLERRM ||' at INV_EBI_CHANGE_ORDER_HELPER.parse_and_get_eco';
6277 END parse_and_get_eco;
6278
6279 /************************************************************************************
6280 -- API name : get_eco_list
6281 -- Type : Public
6282 -- Function :
6283 -- Comments : This API to return list of change ids, prepatel
6284 ************************************************************************************/
6285 PROCEDURE get_eco_list(
6286 p_name_value_list IN inv_ebi_name_value_tbl
6287 ,p_prog_id IN NUMBER
6288 ,p_appl_id IN NUMBER
6289 ,x_eco OUT NOCOPY inv_ebi_change_id_obj_tbl
6290 ,x_return_status OUT NOCOPY VARCHAR2
6291 ,x_msg_count OUT NOCOPY NUMBER
6292 ,x_msg_data OUT NOCOPY VARCHAR2
6293 )
6294 IS
6295 l_eco inv_ebi_change_id_obj_tbl;
6296 l_eco_output_tbl inv_ebi_change_id_obj_tbl;
6297 l_eco_org_output_tbl inv_ebi_change_id_obj_tbl;
6298 l_eco_tbl inv_ebi_change_id_obj_tbl;
6299 l_eco_string VARCHAR2(32000);
6300 l_org_string VARCHAR2(2000);
6301 l_from_date_str VARCHAR2(30);
6302 l_to_date_str VARCHAR2(30);
6303 l_from_date DATE := NULL;
6304 l_to_date DATE := NULL;
6305 l_last_x_hrs NUMBER;
6306 l_return_status VARCHAR2(2);
6307 l_msg_data VARCHAR2(2000);
6308 l_msg_count NUMBER;
6309
6310 CURSOR c_get_eco_chgid IS
6311 SELECT inv_ebi_change_id_obj(eci.change_id, 'Y')
6312 FROM(
6313 SELECT eec.change_id
6314 FROM eng_engineering_changes eec
6315 WHERE eec.last_update_date <> eec.creation_date
6316 AND eec.last_update_date >= l_from_date
6317 AND eec.last_update_date <= l_to_date
6318 UNION
6319 SELECT eri.change_id
6320 FROM eng_revised_items eri
6321 WHERE eri.last_update_date <> eri.creation_date
6322 AND eri.last_update_date >= l_from_date
6323 AND eri.last_update_date <= l_to_date ) eci;
6324
6325 CURSOR c_get_final_eco_list IS
6326 SELECT inv_ebi_change_id_obj(geco.change_id,geco.last_update_status)
6327 FROM (SELECT b.change_id,b.last_update_status
6328 FROM THE (SELECT CAST( l_eco as inv_ebi_change_id_obj_tbl)
6329 FROM dual ) b
6330 INTERSECT
6331 SELECT c.change_id,c.last_update_status
6332 FROM THE (SELECT CAST( l_eco_output_tbl as inv_ebi_change_id_obj_tbl)
6333 FROM dual ) c ) geco;
6334 l_ind_val NUMBER :=1;
6335 BEGIN
6336 FND_MSG_PUB.initialize();
6337 INV_EBI_UTIL.setup();
6338 INV_EBI_UTIL.debug_line('Step 10: START CALLING INV_EBI_CHANGE_ORDER_HELPER.GET_ECO_LIST');
6339 x_return_status := FND_API.G_RET_STS_SUCCESS;
6340
6341 IF (p_name_value_list IS NOT NULL AND p_name_value_list.COUNT > 0) THEN
6342 l_eco_string := INV_EBI_UTIL.get_config_param_value(p_name_value_list,'Change Order Name');
6343 l_org_string := INV_EBI_UTIL.get_config_param_value(p_name_value_list,'Organization Code');
6344 l_from_date_str := INV_EBI_UTIL.get_config_param_value(p_name_value_list,'From Date');
6345 l_to_date_str := INV_EBI_UTIL.get_config_param_value(p_name_value_list,'To Date');
6346 l_last_x_hrs := INV_EBI_UTIL.get_config_param_value(p_name_value_list,'Updated in the last X Hrs');
6347
6348 INV_EBI_UTIL.debug_line('STEP 20: INPUT PARAMETER FOR ECO IS ' || l_eco_string);
6349 INV_EBI_UTIL.debug_line('STEP 30: INPUT PARAMETER FOR ORG IS ' || l_org_string);
6350 INV_EBI_UTIL.debug_line('STEP 40: INPUT PARAMETER FOR FROM DATE IS ' || l_from_date_str);
6351 INV_EBI_UTIL.debug_line('STEP 50: INPUT PARAMETER FOR TO DATE IS ' || l_to_date_str);
6352 INV_EBI_UTIL.debug_line('STEP 60: INPUT PARAMETER FOR LAST UPDATED HRS IS '|| l_last_x_hrs);
6353
6354 IF l_from_date_str IS NOT NULL THEN
6355 l_from_date := TO_DATE(l_from_date_str,'YYYY/MM/DD HH24:MI:SS');
6356 INV_EBI_UTIL.debug_line('STEP 70: FROM DATE CONVERSION IF IT IS NOT NULL ' || l_from_date);
6357 END IF;
6358 IF l_to_date_str IS NOT NULL THEN
6359 l_to_date := TO_DATE(l_to_date_str,'YYYY/MM/DD HH24:MI:SS');
6360 INV_EBI_UTIL.debug_line('STEP 80: TO DATE CONVERSION IF IT IS NOT NULL ' || l_to_date);
6361 END IF;
6362 IF l_last_x_hrs IS NOT NULL THEN
6363 l_from_date := SYSDATE-( l_last_x_hrs/24);
6364 l_to_date := SYSDATE ;
6365 INV_EBI_UTIL.debug_line('STEP 90: FROM DATE IF THE LAST X HRS PARAMATER IS GIVEN ' || l_from_date);
6366 INV_EBI_UTIL.debug_line('STEP 100: TO DATE IF THE LAST X HRS PARAMATER IS GIVEN ' || l_to_date);
6367 END IF;
6368 END IF;
6369
6370 IF (l_eco_string IS NULL AND l_from_date IS NULL AND l_to_date IS NULL AND l_last_x_hrs IS NULL) THEN
6371 l_from_date :=INV_EBI_ITEM_HELPER.get_last_run_date( p_conc_prog_id => p_prog_id
6372 ,p_appl_id => p_appl_id
6373 );
6374 INV_EBI_UTIL.debug_line('STEP 110: FROM DATE IF ALL THE PARAMETERS ARE NULL'|| l_from_date);
6375 l_to_date := SYSDATE;
6376 INV_EBI_UTIL.debug_line('STEP 120: TO DATE IF ALL THE PARAMETERS ARE NULL '|| l_to_date);
6377 END IF;
6378
6379 IF l_from_date IS NOT NULL AND l_to_date IS NULL THEN
6380 l_to_date := SYSDATE;
6381 INV_EBI_UTIL.debug_line('STEP 130: TO DATE IF FROM DATE IS NOT NULL AND TODATE IS NULL '|| l_to_date);
6382 END IF;
6383 INV_EBI_UTIL.debug_line('STEP 140: BEFORE CALLING PARSE_AND_GET_ECO');
6384 IF ( l_eco_string IS NOT NULL ) THEN
6385 parse_and_get_eco( p_eco_names => l_eco_string
6386 ,p_org_codes => l_org_string
6387 ,x_eco_tbl => l_eco_output_tbl
6388 ,x_return_status => l_return_status
6389 ,x_msg_count => l_msg_count
6390 ,x_msg_data => l_msg_data);
6391 END IF;
6392 INV_EBI_UTIL.debug_line('STEP 150: AFTER CALLING PARSE_AND_GET_ECO STATUS: '|| x_return_status);
6393 IF (l_return_status <> FND_API.g_ret_sts_success) THEN
6394 x_return_status := l_return_status;
6395 IF l_msg_data IS NOT NULL THEN
6396 x_msg_data := l_msg_data;
6397 END IF;
6398 END IF;
6399
6400 x_eco := l_eco_output_tbl;
6401 l_eco := inv_ebi_change_id_obj_tbl();
6402
6403 IF (l_from_date IS NOT NULL AND l_to_date IS NOT NULL) THEN
6404 IF (c_get_eco_chgid%ISOPEN) THEN
6405 CLOSE c_get_eco_chgid;
6406 END IF;
6407 OPEN c_get_eco_chgid ;
6408 FETCH c_get_eco_chgid BULK COLLECT INTO l_eco ;
6409 CLOSE c_get_eco_chgid;
6410 IF (l_eco.COUNT > 0) THEN
6411 FOR i IN 1 .. l_eco.COUNT
6412 LOOP
6413 INV_EBI_UTIL.debug_line('STEP 160: CHANGE ID IF FROM DATE AND TO DATE PARAMETER IS NOT NULL '|| l_eco(i).CHANGE_ID);
6414 END LOOP;
6415 END IF;
6416 IF( l_eco_string IS NOT NULL ) THEN
6417 IF(c_get_final_eco_list%ISOPEN) THEN
6418 CLOSE c_get_final_eco_list;
6419 END IF;
6420 OPEN c_get_final_eco_list ;
6421 FETCH c_get_final_eco_list BULK COLLECT INTO l_eco_tbl ;
6422 CLOSE c_get_final_eco_list;
6423 x_eco:=l_eco_tbl;
6424 ELSIF (l_org_string IS NOT NULL) THEN
6425 INV_EBI_UTIL.debug_line('STEP 170: BEFORE CALLING FILTER ECOS BASED ON ORG');
6426 filter_ecos_based_on_org( p_org_codes => l_org_string
6427 ,p_eco_tbl => l_eco
6428 ,x_eco_tbl => l_eco_org_output_tbl
6429 ,x_return_status => l_return_status
6430 ,x_msg_count => l_msg_count
6431 ,x_msg_data => l_msg_data);
6432 INV_EBI_UTIL.debug_line('STEP 180: AFTER CALLING FILTER ECOS BASED ON ORG STATUS: '|| x_return_status);
6433 IF (l_return_status = FND_API.g_ret_sts_success) THEN
6434 x_eco := l_eco_org_output_tbl;
6435 ELSE
6436 x_return_status := l_return_status;
6437 IF x_msg_data IS NOT NULL THEN
6438 x_msg_data := x_msg_data || l_msg_data;
6439 ELSE
6440 x_msg_data := l_msg_data;
6441 END IF;
6442 END IF;
6443 ELSE
6444 x_eco:=l_eco;
6445 END IF;
6446 END IF;
6447 IF (x_eco.COUNT >0 ) THEN
6448 FOR i IN 1 .. x_eco.COUNT
6449 LOOP
6450 INV_EBI_UTIL.debug_line('STEP 190: CHANGE ID '|| x_eco(i).CHANGE_ID || ' LAST UPDATE STATUS ' ||x_eco(i).LAST_UPDATE_STATUS);
6451 END LOOP;
6452 END IF;
6453 INV_EBI_UTIL.debug_line('STEP 200: END CALLING INV_EBI_CHANGE_ORDER_HELPER.get_eco_list STATUS: '||x_return_status);
6454 INV_EBI_UTIL.wrapup;
6455 EXCEPTION
6456 WHEN OTHERS THEN
6457 x_return_status := FND_API.g_ret_sts_unexp_error;
6458 x_msg_data := SQLERRM ||' at INV_EBI_CHANGE_ORDER_HELPER.get_eco_list';
6459 IF (c_get_final_eco_list%ISOPEN) THEN
6460 CLOSE c_get_final_eco_list;
6461 END IF;
6462
6463 END get_eco_list;
6464
6465 END INV_EBI_CHANGE_ORDER_HELPER;