[Home] [Help]
PACKAGE BODY: APPS.ENGECOBO
Source
1 PACKAGE BODY ENGECOBO AS
2 /* $Header: ENGECOBB.pls 120.37.12020000.3 2012/09/13 10:08:51 yingyang ship $ */
3
4 ---------------------------------------------------------------
5 -- Global constant holding the package name --
6 ---------------------------------------------------------------
7 G_PKG_NAME CONSTANT VARCHAR2(30) := 'ENGECOBO';
8
9 ---------------------------------------------------------------
10 -- Global constants --
11 ---------------------------------------------------------------
12 G_VAL_NOT_EXISTS CONSTANT NUMBER := 0;
13 G_VAL_EXISTS CONSTANT NUMBER := 1;
14
15 G_VAL_FALSE CONSTANT NUMBER := 0;
16 G_VAL_TRUE CONSTANT NUMBER := 1;
17
18 ---------------------------------------------------------------
19 -- DB hardcoded values --
20 ---------------------------------------------------------------
21 G_PROPAGATED_TO CONSTANT VARCHAR2(15) := 'PROPAGATED_TO';
22 G_ENG_CHANGE CONSTANT VARCHAR2(10) := 'ENG_CHANGE';
23 G_LOG_PROC CONSTANT NUMBER := 2;
24 G_LOG_STMT CONSTANT NUMBER := 1;
25 ---------------------------------------------------------------
26 -- Global variables --
27 ---------------------------------------------------------------
28 g_global_change_id NUMBER;
29 g_global_org_id NUMBER;
30 G_STATUS_CONTROL_LEVEL NUMBER;
31 ---------------------------------------------------------------
32 -- User Defined Exception
33 ---------------------------------------------------------------
34 EXC_EXP_SKIP_OBJECT EXCEPTION;
35 EXC_ERR_PVT_API_MAIN EXCEPTION;
36 ---------------------------------------------------------------
37 -- Global Types Declaration --
38 ---------------------------------------------------------------
39 TYPE Eco_Struc_Line_rec_Type IS RECORD
40 (
41 Revised_item_sequence_id NUMBER
42 , bill_sequence_id NUMBER
43 , alternate_bom_designator VARCHAR2(10)
44 , local_bill_sequence_id NUMBER
45 , comn_bill_sequence_id NUMBER
46 , from_end_item_minor_rev_id NUMBER
47 , from_end_item_rev_id NUMBER
48 );
49
50 TYPE Eco_Struc_Line_Tbl_Type IS TABLE OF Eco_Struc_Line_rec_Type
51 INDEX BY BINARY_INTEGER;
52
53 /*TYPE Eco_Error_rec_Type IS RECORD
54 (
55 Revised_item_sequence_id NUMBER
56 , revised_line_type VARCHAR2(20)
57 , revised_line_id1 NUMBER
58 , log_text VARCHAR2(2000)
59 , log_type VARCHAR2(10)
60 );
61
62 TYPE Eco_Error_Tbl_Type IS TABLE OF Eco_Error_rec_Type
63 INDEX BY BINARY_INTEGER;
64
65 TYPE Prop_Rev_Items_Tbl_Type IS TABLE OF NUMBER
66 INDEX BY BINARY_INTEGER;*/
67
68 ---------------------------------------------------------------
69 -- Start functions and Procedures Here --
70 ---------------------------------------------------------------
71 -- Bug : 5356082
72 /*
73 The problem is that the document_id for each attachment in the
74 master org and child org for the same item is not same.
75 The previous logic for propogation was written in such a way that the item
76 attachments will be queried in the child organization with the same
77 document_id as in master organization.
78 Since because of the document_id's are different it was not able to find the
79 attachments in the child organization.
80 Now, we need to somehow match the attachments in the master organization to
81 the attachment in the child organization.
82 Steps :
83 1. Get the media_id, node_id for the master org item attachments
84 2. Get the repository type
85 3. If repository type is web services, compare master org item attachment media id with that of child org item.
86 4. If repository is webdav, compare master org item attachment file and folder path with that of child org item.
87 This function should be called for item attachment changes other than Attach to get the correct existing document_id.
88 */
89 FUNCTION Get_Child_Org_Item_AttId
90 (
91 p_item_id IN NUMBER
92 , p_item_revision_id IN NUMBER
93 , p_master_org_id IN NUMBER
94 , p_master_org_document_id IN NUMBER
95 , p_child_org_id IN NUMBER
96 )
97 RETURN NUMBER IS
98 l_master_item_media_id FND_DOCUMENTS.MEDIA_ID%TYPE;
99 l_master_item_node_id FND_DOCUMENTS.DM_NODE%TYPE;
100 l_master_item_folder_path FND_DOCUMENTS.DM_FOLDER_PATH%TYPE;
101 l_master_item_file_name FND_DOCUMENTS.FILE_NAME%TYPE;
102 l_master_item_dm_doc_id FND_DOCUMENTS.DM_DOCUMENT_ID%TYPE;
103
104 l_item_attachment_protocol DOM_REPOSITORIES.PROTOCOL%TYPE;
105 l_child_item_media_id FND_DOCUMENTS.MEDIA_ID%TYPE;
106 l_child_org_document_id FND_DOCUMENTS.DOCUMENT_ID%TYPE;
107 l_child_item_folder_path FND_DOCUMENTS.DM_FOLDER_PATH%TYPE;
108 l_child_item_file_name FND_DOCUMENTS.FILE_NAME%TYPE;
109 l_master_folder_and_file VARCHAR2(3500); -- DM_FOLDER_PATH || '/' || FILE_NAME
110 BEGIN
111 -- Get the master item attachments information
112 SELECT dm_node, media_id, dm_folder_path, file_name, dm_document_id
113 INTO l_master_item_node_id, l_master_item_media_id, l_master_item_folder_path, l_master_item_file_name, l_master_item_dm_doc_id
114 FROM fnd_documents
115 WHERE document_id = p_master_org_document_id;
116 l_master_folder_and_file := l_master_item_folder_path || '/' || l_master_item_file_name;
117
118 -- Get the Protocol
119 SELECT protocol INTO l_item_attachment_protocol FROM dom_repositories WHERE id = l_master_item_node_id;
120
121 -- If web services, then we have to compare the media and node ids of master org item attachments
122 -- with child org item attachments
123 IF l_item_attachment_protocol = 'WEBSERVICES' THEN
124 BEGIN
125 SELECT b.document_id, nvl(a.media_id , a.dm_document_id)
126 INTO l_child_org_document_id, l_child_item_media_id
127 FROM fnd_documents a, fnd_attached_documents b
128 WHERE b.document_id = a.document_id AND
129 b.pk2_value = p_item_id AND
130 b.pk1_value = p_child_org_id AND
131 b.pk3_value = p_item_revision_id AND
132 ( (l_master_item_media_id IS NOT NULL AND a.media_id = l_master_item_media_id) OR -- file
133 (l_master_item_media_id IS NULL AND a.dm_document_id = l_master_item_dm_doc_id))AND -- folder
134 a.dm_node = l_master_item_node_id;
135
136 EXCEPTION
137 WHEN OTHERS THEN
138 l_child_org_document_id := -1;
139 END;
140 END IF;
141
142 -- If web dav, then we have to compare the folder and file name of master org item attachments
143 -- with child org item attachments
144 IF l_item_attachment_protocol = 'WEBDAV' THEN
145 BEGIN
146 SELECT b.document_id, a.dm_folder_path, a.file_name
147 INTO l_child_org_document_id, l_child_item_folder_path, l_child_item_file_name
148 FROM fnd_documents a, fnd_attached_documents b
149 WHERE b.document_id = a.document_id AND
150 b.pk2_value = p_item_id AND
151 b.pk1_value = p_child_org_id AND
152 b.pk3_value = p_item_revision_id AND
153 (a.dm_folder_path || '/' || a.file_name) = l_master_folder_and_file AND
154 a.dm_node = l_master_item_node_id;
155 --FND_FILE.PUT_LINE(FND_FILE.LOG, 'MMITC : WEBDAV : ' || l_child_org_document_id );
156 -- Only one row should be found
157 l_child_org_document_id := l_child_org_document_id;
158 EXCEPTION
159 WHEN OTHERS THEN -- when no data found or if it returns more than one row
160 --FND_FILE.PUT_LINE(FND_FILE.LOG, 'MMITC : WEBDAV Exception : ' || SQLERRM );
161 l_child_org_document_id := -1;
162 END;
163 END IF;
164
165 RETURN l_child_org_document_id;
166
167 EXCEPTION
168 WHEN OTHERS THEN
169 FND_FILE.PUT_LINE(FND_FILE.LOG, 'MMITC : Main Exception : ' ||SQLERRM );
170
171 END Get_Child_Org_Item_AttId;
172
173 PROCEDURE Propagated_Local_Change (
174 p_change_id IN NUMBER
175 , p_local_organization_id IN NUMBER
176 , x_local_change_id OUT NOCOPY NUMBER
177 ) IS
178
179 CURSOR c_local_change_order IS
180 SELECT eec.change_id
181 FROM eng_engineering_changes eec
182 , eng_change_obj_relationships ecor
183 WHERE eec.change_id = ecor.object_to_id1
184 AND ecor.relationship_code IN ( 'PROPAGATED_TO', 'TRANSFERRED_TO' )
185 AND ecor.object_to_name ='ENG_CHANGE'
186 AND ecor.object_to_id3 = p_local_organization_id
187 AND ecor.change_id = p_change_id;
188
189 BEGIN
190 OPEN c_local_change_order;
191 FETCH c_local_change_order INTO x_local_change_id;
192 CLOSE c_local_change_order;
193 EXCEPTION
194 WHEN OTHERS THEN
195 IF c_local_change_order%ISOPEN
196 THEN
197 CLOSE c_local_change_order;
198 END IF;
199 x_local_change_id := NULL;
200
201 END Propagated_Local_Change;
202
203 FUNCTION Get_local_org_attachment_id (
204 p_local_entity_name IN VARCHAR2 -- MTL_ITEM_REVISIONS or MTL_SYSTEM_ITEMS
205 , p_local_pk1_value IN VARCHAR2 -- Org_id
206 , p_local_pk2_value IN VARCHAR2 -- item id
207 , p_local_pk3_value IN VARCHAR2 -- current item_revision_id
208 , p_global_document_id IN NUMBER
209 , x_att_status IN OUT NOCOPY VARCHAR2 -- Bug 3599366
210 ) RETURN NUMBER IS
211
212 l_local_attachment_id NUMBER := -1;
213
214 CURSOR c_local_attachment
215 IS
216 SELECT fad.attached_document_id, fad.status
217 FROM fnd_documents_vl fdv, fnd_attached_documents fad
218 WHERE fdv.document_id = fad.document_id
219 AND fad.entity_name = p_local_entity_name
220 AND fad.pk1_value= p_local_pk1_value
221 AND fad.pk2_value = p_local_pk2_value
222 AND fad.pk3_value = p_local_pk3_value
223 AND (fdv.document_id = p_global_document_id
224 OR
225 (fdv.document_id <> p_global_document_id
226 AND ( Nvl(fdv.dm_folder_path, '*NULL*'), fdv.dm_node, fdv.file_name)=
227 (SELECT Nvl(dm_folder_path, '*NULL*'), dm_node, file_name
228 FROM fnd_documents_vl
229 WHERE document_id = p_global_document_id)
230 )
231 OR
232 (fdv.document_id <> p_global_document_id
233 AND fdv.dm_node = 0
234 AND (fdv.file_name, fdv.datatype_id) =
235 (SELECT file_name, datatype_id
236 FROM fnd_documents_vl
237 WHERE document_id = p_global_document_id)
238 )
239 );
240
241 BEGIN
242 OPEN c_local_attachment;
243 FETCH c_local_attachment INTO l_local_attachment_id
244 , x_att_status; -- Bug 3599366
245 CLOSE c_local_attachment;
246 RETURN l_local_attachment_id;
247
248 EXCEPTION
249 WHEN OTHERS THEN
250 IF c_local_attachment%ISOPEN
251 THEN
252 CLOSE c_local_attachment;
253 END IF;
254 RETURN -1;
255 END Get_local_org_attachment_id;
256
257 PROCEDURE Propagate_Attach_Lines (
258 p_change_id IN NUMBER
259 , p_revised_item_sequence_id IN NUMBER
260 , p_revised_item_rec IN Eng_Eco_Pub.Revised_Item_Rec_Type
261 , p_revised_item_unexp_rec IN Eng_Eco_Pub.Rev_Item_Unexposed_Rec_Type
262 , p_local_organization_id IN NUMBER
263 , p_local_line_rev_id IN NUMBER
264 , x_return_status OUT NOCOPY VARCHAR2
265 , x_mesg_token_tbl IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
266 ) IS
267 l_msg_count NUMBER;
268 l_msg_data VARCHAR2(2000);
269 l_return_status VARCHAR2(3);
270
271 l_local_change_id NUMBER;
272 l_local_attachment_id NUMBER := -1;
273 l_pk3_value VARCHAR2(100);
274 l_change_document_id NUMBER;
275 l_local_att_status fnd_attached_documents.status%TYPE; -- Bug 3599366
276 l_temp_document_id NUMBER;
277
278 CURSOR c_attachment_changes (cp_revised_item_sequence_id NUMBER)
279 IS
280 SELECT eac.action_type, eac.attachment_id, eac.source_document_id, eac.SOURCE_VERSION_LABEL
281 , eac.SOURCE_PATH, eac.DEST_DOCUMENT_ID, eac.DEST_VERSION_LABEL, eac.DEST_PATH
282 , eac.CHANGE_DOCUMENT_ID, eac.entity_name, eac.pk1_value, eac.pk2_value, eac.pk3_value
283 , decode(eac.action_type, 'ATTACH', eac.source_document_id,fad.document_id) document_id
284 , eac.FAMILY_ID, eac.REPOSITORY_ID, eac.PK4_VALUE, eac.PK5_VALUE, eac.NEW_FILE_NAME
285 , eac.DESCRIPTIOn, eac.NEW_DESCRIPTIOn, eac.NEW_CATEGORY_ID
286 FROM eng_attachment_changes eac, fnd_attached_documents fad
287 WHERE eac.change_id = p_change_id -- 4517503
288 AND eac.revised_item_sequence_id = cp_revised_item_sequence_id
289 AND eac.attachment_id = fad.attached_document_id(+)
290 AND (eac.entity_name = 'MTL_ITEM_REVISIONS'
291 OR (eac.entity_name = 'MTL_SYSTEM_ITEMS'
292 AND NOT EXISTS (SELECT 1 FROM MTL_PARAMETERS MP
293 WHERE MP.organization_id = g_global_org_id
294 AND MP.master_organization_id = MP.organization_id)
295 ))
296 AND NOT EXISTS (SELECT 1 FROM eng_change_propagation_maps ecpm
297 WHERE ecpm.change_id = p_change_id
298 AND ecpm.local_organization_id = p_local_organization_id
299 AND ecpm.revised_line_type = Eng_Propagation_Log_Util.G_REV_LINE_ATCH_CHG
300 AND ecpm.revised_line_id1 = eac.change_document_id
301 AND ecpm.entity_action_status = 3);
302
303 CURSOR c_attachment_details(cp_attached_document_id IN NUMBER
304 , cp_attach_action_type IN eng_attachment_changes.action_type%TYPE
305 , cp_change_document_id IN NUMBER)
306 IS
307 SELECT fad.category_id, fad.status, fad.document_id
308 , fad.attached_document_id, fdv.file_name, fad.last_updated_by
309 , fdv.dm_type, fdv.datatype_id, fdv.document_id source_document_id
310 FROM fnd_attached_documents fad, fnd_documents_vl fdv
311 WHERE fad.attached_document_id = cp_attached_document_id
312 AND fad.document_id = fdv.document_id
313 AND cp_attach_action_type <> 'ATTACH'
314 UNION ALL
315 SELECT eac.category_id, eac.previous_status, eac.source_document_id
316 , eac.attachment_id, eac.file_name, eac.last_updated_by
317 , eac.dm_type, eac.datatype_id, eac.source_document_id
318 FROM eng_attachment_changes eac, fnd_documents_vl fdv
319 WHERE eac.change_document_id = cp_change_document_id
320 AND eac.source_document_id = fdv.document_id
321 AND cp_attach_action_type = 'ATTACH';
322
323 l_attachment_details_rec c_attachment_details%ROWTYPE;
324
325 BEGIN
326 Eng_Propagation_log_Util.Debug_Log(G_LOG_PROC, 'Propagate_Attach_Lines.BEGIN');
327 Eng_Propagation_log_Util.Debug_Log(G_LOG_STMT, 'Input Param: p_change_id '||p_change_id);
328 Eng_Propagation_log_Util.Debug_Log(G_LOG_STMT, 'Input Param: p_revised_item_sequence_id'||p_revised_item_sequence_id );
329
330 -- get the local change id
331 Propagated_Local_Change(
332 p_change_id => p_change_id
333 , p_local_organization_id => p_local_organization_id
334 , x_local_change_id => l_local_change_id);
335
336 x_return_status := FND_API.G_RET_STS_SUCCESS;
337
338 Eng_Propagation_log_Util.Debug_Log(G_LOG_STMT, 'Value: l_local_change_id'||l_local_change_id);
339 IF l_local_change_id IS null
340 THEN
341 Eng_Propagation_log_Util.Debug_Log(G_LOG_STMT, 'Value: l_local_change_id'||p_revised_item_unexp_rec.change_id);
342 l_local_change_id := p_revised_item_unexp_rec.change_id;
343 END IF;
344 Eng_Propagation_log_Util.Debug_Log(G_LOG_STMT, 'Value: p_revised_item_unexp_rec.revised_item_sequence_id'|| p_revised_item_unexp_rec.revised_item_sequence_id);
345
346 IF (l_local_change_id IS NOT NULL AND p_revised_item_unexp_rec.revised_item_sequence_id IS NOT NULL)
347 THEN
348 FOR ac in c_attachment_changes (p_revised_item_sequence_id) /* loop 2*/
349 LOOP
350 -- initialize pk value and local attachment id
351 l_pk3_value := NULL;
352 l_local_attachment_id := -1;
353 l_return_status := FND_API.G_RET_STS_SUCCESS;
354 -- set the pk3 value if the attachment belongs to item revision
355 IF (ac.entity_name = 'MTL_ITEM_REVISIONS')
356 THEN
357 Eng_Propagation_log_Util.Debug_Log(G_LOG_STMT, 'Value: p_revised_item_unexp_rec.new_item_revision_id'|| p_revised_item_unexp_rec.new_item_revision_id);
358 Eng_Propagation_log_Util.Debug_Log(G_LOG_STMT, 'Value: p_revised_item_unexp_rec.CURRENT_item_revision_id'|| p_revised_item_unexp_rec.CURRENT_item_revision_id);
359
360 -- Bug : 5355614
361 -- For item attachment changes with new revisions we need to get the correct revision id (eng_attachment_changes.pk3_value)
362 BEGIN
363 select revision_id
364 into l_pk3_value from mtl_item_revisions
365 where inventory_item_id = (select revised_item_id
366 from eng_revised_items
367 where revised_item_sequence_id = p_revised_item_unexp_rec.Revised_Item_Sequence_Id)
368 and revised_item_sequence_id = p_revised_item_unexp_rec.Revised_Item_Sequence_Id;
369 EXCEPTION
370 WHEN OTHERS THEN
371 -- this will be called for item attachment changes with default revision
372 l_pk3_value := nvl(p_revised_item_unexp_rec.new_item_revision_id,
373 p_revised_item_unexp_rec.CURRENT_item_revision_id);
374 END;
375 END IF;
376 -- Bug : 5356082
377 l_temp_document_id := ac.document_id;
378 l_temp_document_id := Get_Child_Org_Item_AttId
379 (
380 p_item_id => ac.pk2_value
381 ,p_item_revision_id => l_pk3_value
382 ,p_master_org_id => g_global_org_id
383 ,p_master_org_document_id => ac.document_id
384 ,p_child_org_id => p_revised_item_unexp_rec.organization_id
385 );
386 l_local_attachment_id := Get_local_org_attachment_id(
387 p_local_entity_name => ac.entity_name
388 , p_local_pk1_value => p_local_organization_id
389 , p_local_pk2_value => ac.pk2_value
390 , p_local_pk3_value => l_pk3_value
391 , p_global_document_id => l_temp_document_id
392 , x_att_status => l_local_att_status); -- Bug 3599366
393 Eng_Propagation_log_Util.Debug_Log(G_LOG_STMT, 'Value: ac.action_type:'||ac.action_type);
394 Eng_Propagation_log_Util.Debug_Log(G_LOG_STMT, 'Value: l_local_attachment_id:'||l_local_attachment_id);
395 Eng_Propagation_log_Util.Debug_Log(G_LOG_STMT, 'Value: ac.change_document_id:'||ac.change_document_id);
396 IF (ac.action_type = 'ATTACH' OR l_local_attachment_id <> -1)
397 THEN
398 FOR cad IN c_attachment_details(l_local_attachment_id, ac.action_type, ac.change_document_id)
399 LOOP
400 Eng_Propagation_log_Util.Debug_Log(G_LOG_STMT, 'Inserting into eng_attachment_changes..');
401 SELECT ENG_ATTACHMENT_CHANGES_S.nextval
402 INTO l_change_document_id
403 FROM dual;
404
405 INSERT INTO eng_attachment_changes (
406 CHANGE_ID
407 , REVISED_ITEM_SEQUENCE_ID
408 , ACTION_TYPE
409 , ATTACHMENT_ID
410 , SOURCE_document_ID
411 , SOURCE_VERSION_LABEL
412 , SOURCE_PATH
413 , DEST_DOCUMENT_ID
414 , DEST_VERSION_LABEL
415 , DEST_PATH
416 , CREATION_DATE
417 , CREATED_BY
418 , LAST_UPDATE_DATE
419 , LAST_UPDATED_BY
420 , LAST_UPDATE_LOGIN
421 , CHANGE_DOCUMENT_ID
422 , FILE_NAME
423 , CATEGORY_ID
424 , ATTACHED_USER_ID
425 , PREVIOUS_STATUS
426 , FAMILY_ID
427 , REPOSITORY_ID
428 , DM_TYPE
429 , ENTITY_NAME
430 , PK1_VALUE
431 , PK2_VALUE
432 , PK3_VALUE
433 , PK4_VALUE
434 , PK5_VALUE
435 , NEW_FILE_NAME
436 , DESCRIPTION
437 , NEW_DESCRIPTION
438 , NEW_CATEGORY_ID
439 , DATATYPE_ID
440 ) VALUES (
441 l_local_change_id
442 , p_revised_item_unexp_rec.revised_item_sequence_id
443 , ac.action_type
444 , decode(l_local_attachment_id, -1, ac.attachment_id, l_local_attachment_id)
445 , cad.source_document_id
446 , ac.SOURCE_VERSION_LABEL
447 , ac.SOURCE_PATH
448 , ac.DEST_DOCUMENT_ID
449 , ac.DEST_VERSION_LABEL
450 , ac.DEST_PATH
451 , sysdate
452 , FND_GLOBAL.USER_ID
453 , sysdate
454 , FND_GLOBAL.USER_ID
455 , FND_GLOBAL.USER_ID
456 , l_change_document_id
457 , cad.file_name
458 , cad.category_id
459 , cad.last_updated_by
460 , cad.status
461 , ac.FAMILY_ID
462 , ac.REPOSITORY_ID
463 , cad.DM_TYPE
464 , ac.ENTITY_NAME
465 , p_revised_item_unexp_rec.organization_id
466 , ac.PK2_VALUE
467 , l_pk3_value
468 , ac.PK4_VALUE
469 , ac.PK5_VALUE
470 , ac.NEW_FILE_NAME
471 , ac.DESCRIPTION
472 , ac.NEW_DESCRIPTION
473 , ac.NEW_CATEGORY_ID
474 , cad.DATATYPE_ID
475 );
476 END LOOP;
477 ELSE
478 Eng_Propagation_log_Util.Debug_Log(G_LOG_STMT, 'Could not process attachment_changes..Add Error');
479 Eng_Propagation_Log_Util.add_entity_map(
480 p_change_id => p_change_id
481 , p_revised_item_sequence_id => p_revised_item_sequence_id
482 , p_revised_line_type => Eng_Propagation_Log_Util.G_REV_LINE_ATCH_CHG
483 , p_revised_line_id1 => ac.CHANGE_DOCUMENT_ID
484 , p_local_organization_id => p_local_organization_id
485 , p_entity_name => Eng_Propagation_Log_Util.G_ENTITY_REVISED_LINE
486 , p_entity_action_status => Eng_Propagation_Log_Util.G_PRP_PRC_STS_ERROR
487 , p_bo_entity_identifier => 'ATCH'--Eco_Error_Handler.G_ATCH_LEVEL
488 );
489 l_return_status := FND_API.G_RET_STS_ERROR;
490 -- this case should not be reached as validation of attachments has already been done.
491 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Attachment does not exist');
492 END IF;
493 Eng_Propagation_log_Util.Debug_Log(G_LOG_STMT, 'Processed attachment change with l_return_status'|| l_return_status);
494 IF l_return_status = FND_API.G_RET_STS_SUCCESS
495 THEN
496 Eng_Propagation_Log_Util.add_entity_map(
497 p_change_id => p_change_id
498 , p_revised_item_sequence_id => p_revised_item_sequence_id
499 , p_revised_line_type => Eng_Propagation_Log_Util.G_REV_LINE_ATCH_CHG
500 , p_revised_line_id1 => ac.CHANGE_DOCUMENT_ID
501 , p_local_organization_id => p_local_organization_id
502 , p_local_revised_item_seq_id => p_revised_item_unexp_rec.revised_item_sequence_id
503 , p_local_revised_line_id1 => l_change_document_id
504 , p_entity_name => Eng_Propagation_Log_Util.G_ENTITY_REVISED_LINE
505 , p_entity_action_status => Eng_Propagation_Log_Util.G_PRP_PRC_STS_SUCCESS
506 , p_bo_entity_identifier => 'ATCH'--Eco_Error_Handler.G_ATCH_LEVEL
507 );
508 END IF;
509 IF l_return_status = FND_API.G_RET_STS_ERROR
510 THEN
511 x_return_status := l_return_status;
512 END IF;
513 END LOOP; /* end loop 2 */
514 END IF;
515 Eng_Propagation_log_Util.Debug_Log(G_LOG_STMT, 'Processed All attachment change with x_return_status'||x_return_status);
516 IF x_return_status = FND_API.G_RET_STS_ERROR
517 THEN
518 Error_Handler.Add_Error_Token(
519 p_Message_Name => 'ENG_PRP_ATT_REVITEM_ERR'
520 , p_Mesg_Token_Tbl => x_mesg_token_tbl
521 , x_Mesg_Token_Tbl => x_mesg_token_tbl
522 );
523 END IF;
524 Eng_Propagation_log_Util.Debug_Log(G_LOG_STMT, 'Propagate_Attach_Lines.END');
525
526 EXCEPTION
527 WHEN OTHERS THEN
528 x_return_status := FND_API.G_RET_STS_ERROR;
529
530 Error_Handler.Add_Error_Token(
531 p_Message_Name => NULL
532 , p_Message_Text => 'Unexpected Error Occurred when propagating attachment changes' ||SQLERRM
533 , p_Mesg_Token_Tbl => x_Mesg_Token_Tbl
534 , x_Mesg_Token_Tbl => x_Mesg_Token_Tbl
535 );
536 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Error propagating attachment changes' ||SQLERRM);
537 Eng_Propagation_log_Util.Debug_Log(G_LOG_PROC, 'Propagate_Attach_Lines.END.ERROR');
538 END Propagate_Attach_Lines;
539
540 PROCEDURE BREAK_COMMON_BOM (
541 p_to_sequence_id IN NUMBER
542 , p_from_sequence_id IN NUMBER
543 , p_from_org_id IN NUMBER
544 , p_to_org_id IN NUMBER
545 , p_to_item_id IN NUMBER
546 , p_to_alternate IN VARCHAR2
547 , p_from_item_id IN NUMBER
548 ) IS
549 l_null_val NUMBER;
550
551 BEGIN
552 /* copy bom */
553 BOM_COPY_BILL.COPY_BILL(
554 to_sequence_id => p_to_sequence_id
555 , from_sequence_id => p_from_sequence_id
556 , from_org_id => p_from_org_id
557 , to_org_id => p_to_org_id
558 , display_option => 1
559 , user_id => FND_PROFILE.value('USER_ID')
560 , to_item_id => p_to_item_id
561 , direction => 3
562 , to_alternate => p_to_alternate
563 , rev_date => sysdate
564 , e_change_notice => NULL
565 , rev_item_seq_id => NULL
566 , bill_or_eco => 1
567 , eco_eff_date => NULL
568 , eco_unit_number => NULL
569 , unit_number => NULL
570 , from_item_id => p_from_item_id
571 );
572 /* update the commoned information in bom_bill_of_materials */
573 update bom_bill_of_materials set
574 common_bill_sequence_id = p_to_sequence_id,
575 common_organization_id = NULL,
576 common_assembly_item_id = NULL
577 where bill_sequence_id = p_to_sequence_id;
578 END BREAK_COMMON_BOM;
579
580
581 FUNCTION Check_Sourcing_Rules (
582 p_local_org_id IN NUMBER
583 , p_revised_item_id IN NUMBER
584 ) RETURN NUMBER IS
585 l_item_sourced NUMBER := 2;
586 BEGIN
587 l_item_sourced := ENG_SOURCING_CHECK.IS_ITEM_SOURCED(p_revised_item_id, p_local_org_id, g_global_org_id);
588 IF(l_item_sourced = 3) /* public api not overridden */
589 THEN
590 l_item_sourced := 2;
591 -- Scoped out
592 /*BEGIN
593 select 1 into l_item_sourced from dual
594 where exists (select 1 from mrp_sources_v
595 where assignment_set_id = FND_PROFILE.VALUE( 'MRP_DEFAULT_ASSIGNMENT_SET' )
596 and organization_id = g_global_org_id
597 and inventory_item_id = p_revised_item_id
598 and source_organization_id = p_local_org_id
599 and source_type = 2);
600 EXCEPTION
601 WHEN NO_DATA_FOUND THEN
602 l_item_sourced := 2;
603 END;*/
604 END IF;
605 RETURN l_item_sourced;
606 END Check_Sourcing_Rules;
607
608 PROCEDURE Auto_Enable_Item_In_Org (
609 p_inventory_item_id IN NUMBER
610 , p_organization_id IN NUMBER
611 , x_error_table OUT NOCOPY INV_ITEM_GRP.Error_Tbl_Type
612 , x_return_status OUT NOCOPY VARCHAR2
613 ) IS
614 l_Item_rec_in INV_ITEM_GRP.Item_Rec_Type;
615 l_revision_rec INV_ITEM_GRP.Item_Revision_Rec_Type;
616 l_Item_rec_out INV_ITEM_GRP.Item_Rec_Type;
617 l_return_status VARCHAR2(1);
618 l_Error_tbl INV_ITEM_GRP.Error_Tbl_Type;
619 BEGIN
620 l_Item_rec_in.INVENTORY_ITEM_ID := p_Inventory_Item_Id;
621 l_Item_rec_in.ORGANIZATION_ID := p_Organization_Id;
622
623 INV_ITEM_GRP.Create_Item(
624 p_Item_rec => l_Item_rec_in
625 , p_Revision_rec => l_revision_rec
626 , p_Template_Id => NULL
627 , p_Template_Name => NULL
628 , x_Item_rec => l_Item_rec_out
629 , x_return_status => l_return_status
630 , x_Error_tbl => l_Error_tbl
631 );
632 x_return_status := l_return_status;
633 x_error_table := l_Error_tbl;
634
635 END Auto_Enable_Item_In_Org;
636
637 PROCEDURE Auto_Enable_Item (
638 p_api_version IN NUMBER
639 , p_init_msg_list IN VARCHAR2
640 , p_commit IN VARCHAR2
641 , x_return_status OUT NOCOPY VARCHAR2
642 , x_msg_count OUT NOCOPY NUMBER
643 , x_msg_data OUT NOCOPY VARCHAR2
644 , p_inventory_item_id IN NUMBER
645 , p_local_organization_id IN NUMBER
646 ) IS
647 l_api_name CONSTANT VARCHAR2(30) := 'Auto_Enable_Item';
648 l_api_version CONSTANT NUMBER := 1.0;
649 l_error_table INV_ITEM_GRP.Error_Tbl_Type;
650
651 BEGIN
652 x_return_status := FND_API.G_RET_STS_SUCCESS;
653 -- Standard Start of API savepoint
654 SAVEPOINT Auto_Enable_Item;
655
656 -- Standard call to check for call compatibility
657 IF NOT FND_API.Compatible_API_Call ( l_api_version
658 ,p_api_version
659 ,l_api_name
660 ,G_PKG_NAME )
661 THEN
662 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
663 END IF;
664
665 -- Initialize message list if p_init_msg_list is set to TRUE.
666 IF FND_API.to_Boolean( p_init_msg_list ) THEN
667 FND_MSG_PUB.initialize;
668 END IF ;
669
670 AUTO_ENABLE_ITEM_IN_ORG(
671 p_inventory_item_id => p_inventory_item_id
672 , p_organization_id => p_local_organization_id
673 , X_error_table => l_error_table
674 , x_return_status => x_return_status);
675
676 IF x_return_status <> FND_API.G_RET_STS_SUCCESS
677 THEN
678 FOR i IN 1..l_error_table.COUNT
679 LOOP
680 FND_MESSAGE.Set_Name('INV', l_error_table(i).message_name);
681 FND_MSG_PUB.Add;
682 END loop;
683 FND_MSG_PUB.Count_And_Get(
684 p_count => x_msg_count
685 , p_data => x_msg_data);
686 END IF;
687 -- Standard ending code ------------------------------------------------
688 IF FND_API.To_Boolean ( p_commit ) THEN
689 COMMIT WORK;
690 END IF;
691
692 EXCEPTION
693 WHEN OTHERS THEN
694 ROLLBACK TO Auto_Enable_Item;
695 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
696 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
697 THEN
698 FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME, l_api_name);
699 END IF;
700 FND_MSG_PUB.Count_And_Get(
701 p_count => x_msg_count
702 , p_data => x_msg_data);
703 END Auto_Enable_Item;
704
705 /* added this procedure to stop propogation of attachment having not allowed
706 change policy in child org.
707 added nvl condition for lifecycle & phase id because if no lifecycle defined at revision level
708 it takes item level's by default. */
709 FUNCTION Check_Attachment_Policy (
710 p_inventory_item_id IN NUMBER,
711 p_organization_id IN NUMBER,
712 p_category_id IN VARCHAR2,
713 p_revision_id IN NUMBER
714 ) RETURN NUMBER IS
715 l_strc_cp_not_allowed NUMBER := 2;
716
717 CURSOR c_check_attach_policy IS
718 SELECT 1
719 FROM (SELECT nvl(mir.lifecycle_id,msi.lifecycle_id) lifecycle_id,
720 nvl(mir.current_phase_id,msi.current_phase_id) current_phase_id, msi.item_catalog_group_id,
721 mir.inventory_item_id, mir.organization_id
722 FROM MTL_ITEM_REVISIONS mir ,MTL_SYSTEM_ITEMS msi
723 WHERE mir.INVENTORY_ITEM_ID = p_inventory_item_id
724 AND mir.ORGANIZATION_ID = p_organization_id
725 AND mir.revision_id = p_revision_id
726 AND msi.INVENTORY_ITEM_ID = mir.INVENTORY_ITEM_ID
727 AND msi.ORGANIZATION_ID = mir.ORGANIZATION_ID) ITEM_DTLS, ENG_CHANGE_POLICIES_V ECP
728 WHERE ecp.policy_object_pk1_value =
729 (SELECT TO_CHAR(ic.item_catalog_group_id)
730 FROM mtl_item_catalog_groups_b ic
731 WHERE EXISTS
732 (SELECT olc.object_classification_code CatalogId
733 FROM EGO_OBJ_TYPE_LIFECYCLES olc
734 WHERE olc.object_id = (SELECT OBJECT_ID FROM fnd_objects WHERE obj_name = 'EGO_ITEM')
735 AND olc.lifecycle_id = ITEM_DTLS.lifecycle_id
736 AND olc.object_classification_code = ic.item_catalog_group_id)
737 AND ROWNUM = 1
738 CONNECT BY PRIOR parent_catalog_group_id = item_catalog_group_id
739 START WITH item_catalog_group_id = ITEM_DTLS.item_catalog_group_id)
740 AND ecp.policy_object_pk2_value = ITEM_DTLS.lifecycle_id
741 AND ecp.policy_object_pk3_value = ITEM_DTLS.current_phase_id
742 AND ecp.policy_object_name = 'CATALOG_LIFECYCLE_PHASE'
743 AND ecp.attribute_object_name = 'EGO_CATALOG_GROUP'
744 AND ecp.attribute_code = 'ATTACHMENT'
745 AND ecp.ATTRIBUTE_NUMBER_VALUE = p_category_id
746 AND ecp.policy_char_value = 'NOT_ALLOWED';
747
748 BEGIN
749 l_strc_cp_not_allowed := 2;
750 OPEN c_check_attach_policy;
751 FETCH c_check_attach_policy INTO l_strc_cp_not_allowed;
752 CLOSE c_check_attach_policy;
753 RETURN l_strc_cp_not_allowed;
754
755 EXCEPTION
756 WHEN OTHERS THEN
757 IF c_check_attach_policy%ISOPEN THEN
758 CLOSE c_check_attach_policy;
759 END IF;
760 l_strc_cp_not_allowed := 2;
761 RETURN l_strc_cp_not_allowed;
762 END Check_Attachment_Policy;
763
764 PROCEDURE Validate_Attach_Lines (
765 p_change_id IN NUMBER
766 , p_rev_item_sequence_id IN NUMBER
767 , p_global_organization_id IN NUMBER
768 , p_global_new_item_rev IN VARCHAR2
769 , p_global_current_item_rev_id IN NUMBER
770 , p_local_organization_id IN NUMBER
771 , p_local_line_rev_id IN NUMBER
772 , p_revised_item_rec IN Eng_Eco_Pub.Revised_Item_Rec_Type
773 , p_revised_item_unexp_rec IN Eng_Eco_Pub.Rev_Item_Unexposed_Rec_Type
774 , x_return_status OUT NOCOPY VARCHAR2
775 , x_mesg_token_tbl IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
776 ) IS
777
778 CURSOR c_attachment_changes IS
779 SELECT eac.action_type, eac.entity_name, eac.pk1_value, eac.pk2_value
780 , eac.pk3_value, eac.file_name, fad.status, eac.change_document_id
781 , decode(eac.action_type, 'ATTACH', eac.source_document_id,fad.document_id) document_id,eac.category_id
782 FROM eng_attachment_changes eac, fnd_attached_documents fad
783 WHERE eac.change_id = p_change_id
784 AND eac.revised_item_sequence_id = p_rev_item_sequence_id
785 AND eac.attachment_id = fad.attached_document_id(+)
786 AND (eac.entity_name = 'MTL_ITEM_REVISIONS'
787 OR (eac.entity_name = 'MTL_SYSTEM_ITEMS'
788 AND NOT EXISTS (SELECT 1 FROM MTL_PARAMETERS MP
789 WHERE MP.organization_id = p_global_organization_id
790 AND MP.master_organization_id = MP.organization_id)
791 ))
792 AND NOT EXISTS (SELECT 1 FROM eng_change_propagation_maps ecpm
793 WHERE ecpm.change_id = p_change_id
794 AND ecpm.local_organization_id = p_local_organization_id
795 AND ecpm.revised_line_type = Eng_Propagation_Log_Util.G_REV_LINE_ATCH_CHG
796 AND ecpm.revised_line_id1 = eac.change_document_id
797 AND ecpm.entity_action_status = 3);
798
799 CURSOR c_check_item_level_changes IS
800 SELECT 1
801 FROM eng_attachment_changes eac
802 WHERE eac.change_id = p_change_id
803 AND eac.revised_item_sequence_id = p_rev_item_sequence_id
804 AND eac.entity_name = 'MTL_SYSTEM_ITEMS'
805 AND EXISTS(SELECT 1 FROM MTL_PARAMETERS MP
806 WHERE MP.organization_id = p_global_organization_id
807 AND MP.master_organization_id = MP.organization_id)
808 AND NOT EXISTS (SELECT 1 FROM eng_change_propagation_maps ecpm
809 WHERE ecpm.change_id = p_change_id
810 AND ecpm.local_organization_id = p_local_organization_id
811 AND ecpm.revised_line_type = Eng_Propagation_Log_Util.G_REV_LINE_ATCH_CHG
812 AND ecpm.revised_line_id1 = eac.change_document_id
813 AND ecpm.entity_action_status = 3);
814
815
816 l_current_revision_id NUMBER;
817 l_action_name fnd_lookups.meaning%TYPE;
818 l_local_attachment_id NUMBER;
819 l_pk3_value VARCHAR2(100);
820 l_status_name fnd_lookups.meaning%TYPE;
821 l_check_item_changes NUMBER;
822 l_local_att_status fnd_attached_documents.status%TYPE; -- Bug 3599366
823 l_Mesg_token_Tbl Error_Handler.Mesg_Token_Tbl_Type;
824 l_Token_Tbl Error_Handler.Token_Tbl_Type;
825 l_error_logged NUMBER;
826 l_cp_not_allowed NUMBER;
827 l_temp_document_id NUMBER;
828 l_local_revision VARCHAR2(30);
829 l_global_revision VARCHAR2(30);
830 l_rev_mismatch NUMBER;
831
832 BEGIN
833 Eng_Propagation_Log_Util.Debug_Log(G_LOG_PROC, 'Validate_Attach_Lines.BEGIN');
834 --
835 -- Initialize
836 l_error_logged := G_VAL_FALSE;
837 x_return_status := FND_API.G_RET_STS_SUCCESS;
838
839 -- validate attachment changes propagation
840 FOR ac IN c_attachment_changes
841 LOOP
842 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Processing attachment change record with change_document_id: '||ac.change_document_id);
843
844 Error_Handler.Delete_Message(p_entity_id => Eco_Error_Handler.G_ATCH_LEVEL);
845
846 l_mesg_token_tbl.delete;
847
848 -- initialize pk value and local attachment id
849 l_pk3_value := NULL;
850 l_local_attachment_id := -1;
851 l_rev_mismatch := G_VAL_FALSE;
852
853 -- set the pk3 value if the attachment belongs to item revision
854 IF (ac.entity_name = 'MTL_ITEM_REVISIONS')
855 THEN
856 l_pk3_value := p_local_line_rev_id;
857
858 BEGIN
859 SELECT revision
860 INTO l_local_revision
861 FROM MTL_ITEM_REVISIONS
862 WHERE revision_id = p_local_line_rev_id;
863 EXCEPTION
864 WHEN NO_DATA_FOUND THEN
865 l_local_revision := NULL;
866 END;
867
868 IF p_global_new_item_rev IS NOT NULL AND
869 p_global_new_item_rev <> FND_API.G_MISS_CHAR AND
870 p_global_new_item_rev <> l_local_revision
871 THEN
872 l_Token_Tbl.delete;
873 l_Token_Tbl(1).Token_name := 'REVISION';
874 l_Token_Tbl(1).Token_Value := p_global_new_item_rev;
875
876 Error_Handler.Add_Error_Token(
877 p_Message_Name => 'ENG_NEW_REV_PROP_ERROR'
878 , p_Mesg_Token_Tbl => l_mesg_token_tbl
879 , x_Mesg_Token_Tbl => l_mesg_token_tbl
880 , p_Token_Tbl => l_token_tbl
881 );
882
883 l_error_logged := G_VAL_TRUE;
884 l_rev_mismatch := G_VAL_TRUE;
885
886 ELSIF p_global_new_item_rev IS NULL OR
887 p_global_new_item_rev = FND_API.G_MISS_CHAR
888 THEN
889 BEGIN
890 SELECT revision
891 INTO l_global_revision
892 FROM MTL_ITEM_REVISIONS
893 WHERE revision_id = p_global_current_item_rev_id;
894 EXCEPTION
895 WHEN NO_DATA_FOUND THEN
896 l_global_revision := NULL;
897 END;
898
899 IF l_global_revision <> l_local_revision
900 THEN
901 l_Token_Tbl.delete;
902 l_Token_Tbl(1).Token_name := 'REVISION';
903 l_Token_Tbl(1).Token_Value := l_global_revision;
904
905 Error_Handler.Add_Error_Token(
906 p_Message_Name => 'ENG_CUR_REV_PROP_ERROR'
907 , p_Mesg_Token_Tbl => l_mesg_token_tbl
908 , x_Mesg_Token_Tbl => l_mesg_token_tbl
909 , p_Token_Tbl => l_token_tbl
910 );
911
912 l_error_logged := G_VAL_TRUE;
913 l_rev_mismatch := G_VAL_TRUE;
914 END IF;
915 END IF;
916
917 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Value: l_pk3_value '||l_pk3_value);
918 END IF;
919
920 IF l_rev_mismatch = G_VAL_FALSE
921 THEN
922 --added for bug 5151075
923 l_cp_not_allowed := Check_Attachment_Policy( p_inventory_item_id => ac.pk2_value
924 , p_organization_id => p_local_organization_id
925 , p_category_id => ac.category_id
926 , p_revision_id => l_pk3_value);
927 IF l_cp_not_allowed = 1
928 THEN
929 -- If revision level attachment has change allowed policy is set to 'NO'
930 l_Token_Tbl.delete;
931 Error_Handler.Add_Error_Token(p_Message_Name => 'ENG_ATT_NO_ALLOW_CHG_POLICY'
932 , p_Mesg_Token_Tbl => l_mesg_token_tbl
933 , x_Mesg_Token_Tbl => l_mesg_token_tbl
934 , p_Token_Tbl => l_token_tbl);
935 l_error_logged := G_VAL_TRUE;
936 END IF;
937
938 -- Bug : 5356082
939 l_temp_document_id := Get_Child_Org_Item_AttId(p_item_id => ac.pk2_value
940 ,p_item_revision_id => l_pk3_value
941 ,p_master_org_id => g_global_org_id
942 ,p_master_org_document_id => ac.document_id
943 ,p_child_org_id => p_revised_item_unexp_rec.organization_id);
944 l_local_attachment_id := Get_local_org_attachment_id(p_local_entity_name => ac.entity_name
945 , p_local_pk1_value => p_revised_item_unexp_rec.organization_id
946 , p_local_pk2_value => ac.pk2_value
947 , p_local_pk3_value => l_pk3_value
948 , p_global_document_id => l_temp_document_id
949 , x_att_status => l_local_att_status); -- Bug 3599366
950
951 SELECT meaning
952 INTO l_action_name
953 FROM fnd_lookups
954 WHERE lookup_type = 'DOM_CHANGE_ACTION_TYPES'
955 AND lookup_code = ac.action_type;
956
957 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Value: l_local_attachment_id'||l_local_attachment_id||' l_local_att_status'||l_local_att_status);
958 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Value: ac.action_type'||ac.action_type);
959
960 IF (ac.action_type = 'ATTACH' AND l_local_attachment_id <> -1)
961 THEN
962 -- For attach action, if Attachment already exists log error
963 l_Token_Tbl.delete;
964 l_Token_Tbl(1).Token_name := 'FILE';
965 l_Token_Tbl(1).Token_Value := ac.file_name;
966
967 Error_Handler.Add_Error_Token(
968 p_Message_Name => 'ENG_PRP_ATT_ADD_FAIL'
969 , p_Mesg_Token_Tbl => l_mesg_token_tbl
970 , x_Mesg_Token_Tbl => l_mesg_token_tbl
971 , p_Token_Tbl => l_token_tbl
972 );
973 l_error_logged := G_VAL_TRUE;
974
975 ELSIF (ac.action_type <> 'ATTACH' AND l_local_attachment_id = -1)
976 THEN
977 -- For all actions except attach, if attachment does not exist in local org, log error
978 l_Token_Tbl.delete;
979 l_Token_Tbl(1).Token_name := 'ACTION';
980 l_Token_Tbl(1).Token_Value := l_action_name;
981 l_Token_Tbl(2).Token_name := 'FILE';
982 l_Token_Tbl(2).Token_Value := ac.file_name;
983
984 Error_Handler.Add_Error_Token(
985 p_Message_Name => 'ENG_PRP_ATT_ACTION_FAIL'
986 , p_Mesg_Token_Tbl => l_mesg_token_tbl
987 , x_Mesg_Token_Tbl => l_mesg_token_tbl
988 , p_Token_Tbl => l_token_tbl
989 );
990 l_error_logged := G_VAL_TRUE;
991
992 ELSIF (ac.action_type <> 'ATTACH' AND
993 l_local_attachment_id <> -1 AND
994 l_local_att_status IN ('PENDING', 'PENDING_CHANGE', 'SUBMITTED_FOR_APPROVAL')) -- Bug 3599366
995 THEN
996 SELECT meaning
997 INTO l_status_name
998 FROM fnd_lookups
999 WHERE lookup_type = 'DOM_ATTACHED_DOC_STATUS'
1000 AND lookup_code = l_local_att_status; -- Bug 3599366
1001
1002 -- For all actions except attach, if attachment exists but it is not in a valid status for change, log error
1003 l_Token_Tbl.delete;
1004 l_Token_Tbl(1).Token_name := 'ACTION';
1005 l_Token_Tbl(1).Token_Value := l_action_name;
1006 l_Token_Tbl(2).Token_name := 'STATUS';
1007 l_Token_Tbl(2).Token_Value := l_status_name;
1008 l_Token_Tbl(3).Token_name := 'FILE';
1009 l_Token_Tbl(3).Token_Value := ac.file_name;
1010
1011 Error_Handler.Add_Error_Token(
1012 p_Message_Name => 'ENG_PRP_ATT_STATUS_FAIL'
1013 , p_Mesg_Token_Tbl => l_mesg_token_tbl
1014 , x_Mesg_Token_Tbl => l_mesg_token_tbl
1015 , p_Token_Tbl => l_token_tbl
1016 );
1017
1018 l_error_logged := G_VAL_TRUE;
1019
1020 END IF;
1021 END IF;
1022
1023 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Value: l_error_logged'||l_error_logged);
1024
1025 IF (l_error_logged = G_VAL_TRUE)
1026 THEN
1027 x_return_status := FND_API.G_RET_STS_ERROR;
1028 -- Log any messages that have been logged with the additional error
1029 -- message into error handler
1030 Eco_Error_Handler.Log_Error(
1031 p_error_status => FND_API.G_RET_STS_ERROR
1032 , p_mesg_token_tbl => l_mesg_token_tbl
1033 , p_error_scope => Error_Handler.G_SCOPE_ALL
1034 , p_error_level => Eco_Error_Handler.G_ATCH_LEVEL
1035 , x_eco_rec => ENG_Eco_PUB.G_MISS_ECO_REC
1036 , x_eco_revision_tbl => ENG_Eco_PUB.G_MISS_ECO_REVISION_TBL
1037 , x_change_line_tbl => ENG_Eco_PUB.G_MISS_CHANGE_LINE_TBL -- Eng Change
1038 , x_revised_item_tbl => ENG_Eco_PUB.G_MISS_REVISED_ITEM_TBL
1039 , x_rev_component_tbl => ENG_Eco_PUB.G_MISS_REV_COMPONENT_TBL
1040 , x_ref_designator_tbl => ENG_Eco_PUB.G_MISS_REF_DESIGNATOR_TBL
1041 , x_sub_component_tbl => ENG_Eco_PUB.G_MISS_SUB_COMPONENT_TBL
1042 , x_rev_operation_tbl => ENG_Eco_PUB.G_MISS_REV_OPERATION_TBL
1043 , x_rev_op_resource_tbl => ENG_Eco_PUB.G_MISS_REV_OP_RESOURCE_TBL
1044 , x_rev_sub_resource_tbl => ENG_Eco_PUB.G_MISS_REV_SUB_RESOURCE_TBL
1045 );
1046 -- local change id is set later
1047 -- if there are errors, based on the level they are not populated in the
1048 -- maps table.
1049 Eng_Propagation_Log_Util.add_entity_map(
1050 p_change_id => p_change_id
1051 , p_revised_item_sequence_id => p_rev_item_sequence_id
1052 , p_revised_line_type => Eng_Propagation_Log_Util.G_REV_LINE_ATCH_CHG
1053 , p_revised_line_id1 => ac.change_document_id
1054 , p_local_organization_id => p_local_organization_id
1055 , p_entity_name => Eng_Propagation_Log_Util.G_ENTITY_REVISED_LINE
1056 , p_entity_action_status => Eng_Propagation_Log_Util.G_PRP_PRC_STS_ERROR
1057 , p_bo_entity_identifier => 'ATCH'--Eco_Error_Handler.G_ATCH_LEVEL
1058 );
1059 ELSE
1060 /*Eng_Propagation_Log_Util.add_entity_map(
1061 p_change_id => p_change_id
1062 , p_revised_item_sequence_id => p_rev_item_sequence_id
1063 , p_revised_line_type => Eng_Propagation_Log_Util.G_REV_LINE_ATCH_CHG
1064 , p_revised_line_id1 => ac.change_document_id
1065 , p_local_organization_id => p_local_organization_id
1066 , p_entity_name => Eng_Propagation_Log_Util.G_ENTITY_REVISED_LINE
1067 , p_entity_action_status => Eng_Propagation_Log_Util.G_PRP_PRC_STS_SUCCESS
1068 , p_bo_entity_identifier => 'ATCH'--Eco_Error_Handler.G_ATCH_LEVEL
1069 );*/
1070 null;-- do nothing
1071 END IF;
1072
1073 END LOOP;
1074
1075 IF(l_error_logged <> G_VAL_TRUE)
1076 THEN
1077 OPEN c_check_item_level_changes;
1078 FETCH c_check_item_level_changes INTO l_check_item_changes;
1079 IF c_check_item_level_changes%FOUND
1080 THEN
1081 l_token_tbl.delete;
1082 Error_Handler.Add_Error_Token(
1083 p_Message_Name => 'ENG_PRP_ATT_ITEMCHG_INFO'
1084 , p_Mesg_Token_Tbl => x_mesg_token_tbl -- to be passed as o/p to the RI log error
1085 , x_Mesg_Token_Tbl => x_mesg_token_tbl
1086 , p_Token_Tbl => l_token_tbl
1087 , p_message_type => 'I'
1088 );
1089 END IF;
1090 ELSE
1091 l_token_tbl.delete;
1092 Error_Handler.Add_Error_Token(
1093 p_Message_Name => 'ENG_PRP_ATT_REVITEM_ERR'
1094 , p_Mesg_Token_Tbl => x_mesg_token_tbl
1095 , x_Mesg_Token_Tbl => x_mesg_token_tbl
1096 , p_Token_Tbl => l_token_tbl
1097 );
1098 END IF;
1099 Eng_Propagation_Log_Util.Debug_Log(G_LOG_PROC, 'Validate_Attach_Lines.END');
1100
1101 EXCEPTION
1102 WHEN OTHERS THEN
1103 IF (c_check_item_level_changes%ISOPEN)
1104 THEN
1105 CLOSE c_check_item_level_changes;
1106 END IF;
1107 Eng_Propagation_Log_Util.Debug_Log(G_LOG_PROC, 'Validate_Attach_Lines.ERROR');
1108 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Error in validation attachments ' || SQLERRM);
1109 l_error_logged := 1;
1110 x_return_status := FND_API.G_RET_STS_ERROR;
1111 Error_Handler.Add_Error_Token(
1112 p_Message_Name => NULL
1113 , p_Message_Text => 'Unexpected Error Occurred when validating attachment changes' ||SQLERRM
1114 , p_Mesg_Token_Tbl => x_Mesg_Token_Tbl
1115 , x_Mesg_Token_Tbl => x_Mesg_Token_Tbl
1116 );
1117
1118 END Validate_Attach_Lines;
1119
1120 PROCEDURE Check_Revised_Item_Errors (
1121 p_change_notice IN VARCHAR2
1122 , p_global_org_id IN NUMBER
1123 , p_local_org_id IN NUMBER
1124 , p_rev_item_seq_id IN NUMBER
1125 , p_revised_item_id IN NUMBER
1126 , p_use_up_item_id IN NUMBER
1127 , p_transfer_item_enable IN NUMBER
1128 , p_transfer_or_copy IN VARCHAR2
1129 , p_transfer_or_copy_item IN NUMBER
1130 , p_status_master_controlled IN NUMBER
1131 , x_error_logged OUT NOCOPY NUMBER
1132 , x_mesg_token_tbl OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
1133 , x_propagate_strc_changes OUT NOCOPY NUMBER
1134 , x_sourcing_rules_exists OUT NOCOPY NUMBER
1135 , x_revised_item_name OUT NOCOPY VARCHAR2
1136 ) IS
1137
1138 CURSOR c_rev_item_struc_lines (v_rev_item_seq_id NUMBER)
1139 IS
1140 SELECT eri.revised_item_id, eri.revised_item_sequence_id, eri.alternate_bom_designator
1141 , eri.change_notice, eri.from_end_item_rev_id, eri.from_end_item_strc_rev_id
1142 , bsb.source_bill_sequence_id, eri.bill_sequence_id
1143 FROM eng_revised_items eri, bom_structures_b bsb
1144 WHERE eri.bill_sequence_id = bsb.bill_sequence_id
1145 AND ((eri.revised_item_sequence_id = v_rev_item_seq_id
1146 AND eri.bill_sequence_id IS NOT NULL
1147 AND (eri.transfer_or_copy IS NULL
1148 OR (eri.transfer_or_copy IS NOT NULL
1149 AND eri.enable_item_in_local_org IS NOT NULL
1150 AND nvl(eri.transfer_or_copy_bill, 2) = 2
1151 AND nvl(eri.transfer_or_copy_routing, 2) = 2)
1152 )
1153 )
1154 -- Commented for bug 4946796
1155 /*OR (eri.parent_revised_item_seq_id = v_rev_item_seq_id
1156 AND eri.transfer_or_copy is null)*/);
1157
1158 -- Commented for bug 4946796
1159 /*CURSOR c_rev_items_for_enable (v_rev_item_seq_id NUMBER)
1160 IS
1161 select distinct eri.revised_item_id, msikfv.concatenated_segments item_name
1162 from eng_revised_items eri, mtl_system_items_b_kfv msikfv
1163 where eri.revised_item_id = msikfv.inventory_item_id
1164 and eri.organization_id = msikfv.organization_id
1165 and eri.parent_revised_item_seq_id = v_rev_item_seq_id
1166 and (eri.transfer_or_copy is not null and eri.transfer_or_copy = 'T')
1167 and eri.enable_item_in_local_org = 'Y'
1168 and eri.revised_item_id not in (SELECT inventory_item_id
1169 FROM mtl_system_items_b_kfv
1170 WHERE inventory_item_id = eri.revised_item_id
1171 AND organization_id = p_local_org_id);*/
1172
1173 -- Commented for bug 4946796
1174 /* Cursor for transfer, obsolete, lifecycle_phase_change , copy items */
1175
1176 /*CURSOR c_tolc_items
1177 IS
1178 select *
1179 from eng_revised_items
1180 where (parent_revised_item_seq_id = p_rev_item_seq_id
1181 or revised_item_sequence_id = p_rev_item_seq_id)
1182 and transfer_or_copy is not null
1183 AND revised_item_sequence_id NOT IN (SELECT revised_item_sequence_id
1184 FROM eng_revised_items
1185 WHERE parent_revised_item_seq_id = p_rev_item_seq_id
1186 AND (transfer_or_copy = 'L' OR transfer_or_copy = 'O')
1187 AND 1 = p_status_master_controlled);*/
1188
1189 l_item_exists_in_org_flag NUMBER;
1190 l_check_invalid_objects NUMBER;
1191 l_return_status VARCHAR2(1);
1192
1193 l_use_up_item_exists NUMBER;
1194 l_item_sourced_flag NUMBER := 2;
1195 l_structure_exists_flag NUMBER;
1196 l_revised_item_number mtl_system_items_kfv.concatenated_segments%TYPE;
1197 l_common_bom_flag NUMBER;
1198 l_local_bill_sequence_id NUMBER;
1199 l_comn_bill_sequence_id NUMBER;
1200 l_eng_bill_flag NUMBER;
1201 l_error_logged NUMBER := 0;
1202 -- l_eco_error_tbl Eco_Error_Tbl_Type;
1203 -- l_err_counter NUMBER;
1204 -- l_eco_mesg_tbl Eco_Error_Tbl_Type;
1205 -- l_mesg_counter NUMBER;
1206 l_local_revised_item_exists NUMBER := 0;
1207
1208 l_struc_line_tbl Eco_Struc_Line_Tbl_Type;
1209 l_struc_count NUMBER := 1;
1210 l_component_not_available NUMBER;
1211
1212 l_fei_strc_revision VARCHAR2(80);
1213 l_fei_bill_sequence_id NUMBER;
1214 l_fei_strc_item_rev_id NUMBER;
1215 --l_fei_alternate VARCHAR2(80);
1216 l_fei_strc_item_id NUMBER;
1217 l_dummy NUMBER;
1218 l_message_log_text VARCHAR2(2000);
1219 l_temp_mesg VARCHAR2(2000);
1220 --l_temp_item_name VARCHAR2(4000);
1221 l_transfer_item_sourced_flag NUMBER;
1222 --l_propagate_strc_changes NUMBER
1223 l_item_error_table INV_ITEM_GRP.Error_Tbl_Type;
1224 l_create_bill_for_item NUMBER;
1225 l_from_end_item_minor_rev_id NUMBER;
1226 l_from_end_item_rev_id NUMBER;
1227
1228 l_Mesg_token_Tbl Error_Handler.Mesg_Token_Tbl_Type;
1229 l_Token_Tbl Error_Handler.Token_Tbl_Type;
1230
1231 l_eco_chg_exists VARCHAR2(1); -- bug 10146196 added
1232 BEGIN
1233
1234 Eng_Propagation_Log_Util.Debug_Log(G_LOG_PROC, '-------------------------------');
1235 Eng_Propagation_Log_Util.Debug_Log(G_LOG_PROC, 'CHECK_REVISED_ITEM_ERRORS.begin');
1236 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Input Param: p_change_notice '|| p_change_notice);
1237 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Input Param: p_global_org_id '|| p_global_org_id);
1238 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Input Param: p_local_org_id '|| p_local_org_id);
1239 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Input Param: p_rev_item_seq_id '|| p_rev_item_seq_id);
1240 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Input Param: p_transfer_item_enable'|| p_transfer_item_enable);
1241 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Input Param: p_use_up_item_id '|| p_use_up_item_id);
1242 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Input Param: p_revised_item_id '|| p_revised_item_id);
1243 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Input Param: p_transfer_or_copy '|| p_transfer_or_copy);
1244 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Input Param: p_transfer_or_copy_item '|| p_transfer_or_copy_item);
1245 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Input Param: p_status_master_controlled'|| p_status_master_controlled);
1246
1247 BEGIN
1248
1249 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Validation: Checking if revised item already exists in local Change');
1250
1251 SELECT G_VAL_TRUE
1252 into l_local_revised_item_exists
1253 FROM eng_revised_items eri1
1254 WHERE eri1.change_notice = p_change_notice
1255 AND eri1.organization_id = p_local_org_id
1256 AND EXISTS
1257 (SELECT 1
1258 FROM eng_revised_items eri2
1259 WHERE revised_item_sequence_id = p_rev_item_seq_id
1260 AND eri2.organization_id = p_local_org_id -- bug 10146196 added
1261 AND eri2.revised_item_id = eri1.revised_item_id
1262 AND eri2.scheduled_date = eri1.scheduled_date
1263 AND NVL(eri2.alternate_bom_designator, 'primary') = NVL(eri1.alternate_bom_designator, 'primary'))
1264 AND eri1.parent_revised_item_seq_id IS NULL
1265 AND eri1.status_type <> 5
1266 AND ROWNUM < 2;
1267 EXCEPTION
1268 WHEN NO_DATA_FOUND THEN
1269 l_local_revised_item_exists := G_VAL_FALSE;
1270 END;
1271 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Value l_local_revised_item_exists: '||l_local_revised_item_exists);
1272
1273 IF (l_local_revised_item_exists = G_VAL_TRUE)
1274 THEN
1275 Error_Handler.Add_Error_Token(
1276 p_Message_Name => 'ENG_PRP_EXISTS_IN_CO'
1277 , p_Mesg_Token_Tbl => l_mesg_token_tbl
1278 , x_Mesg_Token_Tbl => l_mesg_token_tbl
1279 , p_Token_Tbl => l_token_tbl
1280 );
1281 l_error_logged := G_VAL_TRUE;
1282 ELSE
1283 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Validation: Checking if item exists in local Organization');
1284 BEGIN
1285 SELECT 1
1286 into l_item_exists_in_org_flag
1287 FROM mtl_system_items_b_kfv
1288 WHERE inventory_item_id = p_revised_item_id
1289 AND organization_id = p_local_org_id;
1290 EXCEPTION
1291 WHEN NO_DATA_FOUND THEN
1292 l_item_exists_in_org_flag := 0;
1293 END;
1294
1295 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Value l_item_exists_in_org_flag: '||l_item_exists_in_org_flag);
1296
1297 SELECT concatenated_segments
1298 into l_revised_item_number
1299 FROM mtl_system_items_b_kfv
1300 WHERE inventory_item_id = p_revised_item_id
1301 AND organization_id = g_global_org_id;
1302
1303 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Value l_revised_item_number: '||l_revised_item_number);
1304
1305 -- 11.5.10 Feature: Scoped Out
1306 -- If item does not exist in local organization but it is set to be enabled per organization
1307 -- at the change type level, then check if it is a transfer item and Auto Enable
1308 IF (l_item_exists_in_org_flag = 0 AND p_transfer_item_enable = 1)
1309 THEN
1310 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Item does not exist in Organization and it is supposed to be enabled for tranfer');
1311 -- Enable item in local org
1312 IF (p_transfer_or_copy = 'T' AND p_transfer_or_copy_item = 1 )
1313 THEN
1314 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Transfer Item Enabling In Progress ..');
1315 AUTO_ENABLE_ITEM_IN_ORG(
1316 p_inventory_item_id => p_revised_item_id
1317 , p_organization_id => p_local_org_id
1318 , x_error_table => l_item_error_table
1319 , x_return_status => l_return_status);
1320
1321 IF (l_return_status = 'S')
1322 THEN
1323 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Transfer Item Enabling Successful');
1324 l_item_exists_in_org_flag := 1;
1325
1326 l_token_tbl.delete;
1327 l_token_tbl(1).token_name := 'ITEM';
1328 l_token_tbl(1).token_value := l_revised_item_number;
1329 Error_Handler.Add_Error_Token(
1330 p_Message_Name => 'ENG_PRP_TRNSMFG_ENABLED'
1331 , p_Mesg_Token_Tbl => l_mesg_token_tbl
1332 , x_Mesg_Token_Tbl => l_mesg_token_tbl
1333 , p_Token_Tbl => l_token_tbl
1334 , p_message_type => 'I' );
1335 ELSE
1336 l_error_logged := G_VAL_TRUE;
1337 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Transfer Item Enabling Error');
1338 FOR i IN 1..l_item_error_table.COUNT
1339 LOOP
1340 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Transfer Item Enabling Error:'||l_item_error_table(i).message_name);
1341 Error_Handler.Add_Error_Token(
1342 p_Message_Name => NULL
1343 , p_Message_Text => l_item_error_table(i).message_text
1344 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
1345 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
1346 );
1347 END LOOP;
1348 -- Resetting the item error table
1349 l_item_error_table.delete;
1350 END IF;
1351 END IF;
1352 END IF;
1353
1354 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Value Post Auto Enable for transfer l_item_exists_in_org_flag: '||l_item_exists_in_org_flag);
1355
1356 -- If Item does not exist in local organization throw an error
1357 IF (l_item_exists_in_org_flag = 0)
1358 THEN
1359 Error_Handler.Add_Error_Token(
1360 p_Message_Name => 'ENG_PRP_DOES_NOT_EXIST'
1361 , p_Mesg_Token_Tbl => l_mesg_token_tbl
1362 , x_Mesg_Token_Tbl => l_mesg_token_tbl
1363 , p_Token_Tbl => l_token_tbl
1364 );
1365 l_error_logged := 1;
1366 ELSIF (l_item_exists_in_org_flag = 1 AND p_use_up_item_id IS NOT NULL)
1367 THEN
1368 -- If item exists check for use up item
1369 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Validation: Check if use up item Exists');
1370 BEGIN
1371 SELECT 1
1372 INTO l_use_up_item_exists
1373 FROM mtl_system_items
1374 WHERE inventory_item_id = p_use_up_item_id
1375 AND organization_id = p_local_org_id;
1376 EXCEPTION
1377 WHEN NO_DATA_FOUND THEN
1378 Error_Handler.Add_Error_Token(
1379 p_Message_Name => 'ENG_PRP_INVAL_USEUP'
1380 , p_Mesg_Token_Tbl => l_mesg_token_tbl
1381 , x_Mesg_Token_Tbl => l_mesg_token_tbl
1382 , p_Token_Tbl => l_token_tbl);
1383 l_error_logged := 1;
1384 l_item_exists_in_org_flag := 0;
1385 END;
1386 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Value l_use_up_item_exists'|| l_use_up_item_exists);
1387 END IF;
1388
1389 --
1390 -- Proceed with processing only if item and Use up exists in local Organization
1391 IF (l_item_exists_in_org_flag = 1)
1392 THEN
1393 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Proceed with processing as item and use up are valid for local Organization');
1394 x_propagate_strc_changes := G_VAL_TRUE;
1395 --
1396 -- Check if sourcing rules exist for item
1397 l_item_sourced_flag := CHECK_SOURCING_RULES(p_local_org_id , p_revised_item_id);
1398 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Fetch sourcing rules for item in local organization Value: l_item_sourced_flag'||l_item_sourced_flag);
1399
1400 --
1401 -- Check if structure line - bill exists
1402 FOR sl in c_rev_item_struc_lines(p_rev_item_seq_id)
1403 LOOP
1404 l_structure_exists_flag := 1;
1405 BEGIN
1406 select bill_sequence_id, source_bill_sequence_id
1407 into l_local_bill_sequence_id, l_comn_bill_sequence_id
1408 FROM BOM_BILL_OF_MATERIALS
1409 WHERE assembly_item_id = sl.revised_item_id
1410 AND organization_id = p_local_org_id
1411 AND nvl(alternate_bom_designator, 'PRIMARY') = nvl(sl.alternate_bom_designator, 'PRIMARY');
1412 EXCEPTION
1413 WHEN NO_DATA_FOUND THEN
1414 l_structure_exists_flag := 0;
1415 END;
1416
1417 -- Bug 3503525:
1418 -- If all the components are of type add and stryctur does not exist,
1419 -- then the ECO BO create the primary bill.
1420 -- Hence should not throw error "Structute does not exist" in such a case.
1421 IF(l_structure_exists_flag = 0)
1422 THEN
1423 l_create_bill_for_item := 0;
1424 BEGIN
1425 -- Check if all components are of type add the l_create_bill_for_item = 1
1426 -- l_create_bill_for_item = 0 otherwise
1427 SELECT 1, 1
1428 INTO l_structure_exists_flag, l_create_bill_for_item
1429 FROM dual
1430 WHERE NOT EXISTS (SELECT 1
1431 FROM bom_inventory_components
1432 WHERE change_notice = sl.change_notice
1433 AND revised_item_sequence_id = sl.revised_item_sequence_id
1434 AND acd_type IN (2,3));
1435 EXCEPTION
1436 WHEN NO_DATA_FOUND THEN
1437 null;
1438 END;
1439 END IF;
1440 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Value l_structure_exists_flag:' || l_structure_exists_flag);
1441 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Value l_create_bill_for_item:' || l_create_bill_for_item);
1442
1443 IF (l_item_sourced_flag = 1 AND l_structure_exists_flag = 1)
1444 THEN
1445 -- Log a message and do not continue
1446 Error_Handler.Add_Error_Token(
1447 p_Message_Name => 'ENG_PRP_SRC_RULES'
1448 , p_Mesg_Token_Tbl => l_mesg_token_tbl
1449 , x_Mesg_Token_Tbl => l_mesg_token_tbl
1450 , p_Token_Tbl => l_token_tbl
1451 , p_message_type => 'I');
1452
1453 EXIT; -- Exits Loop
1454 ELSIF (l_item_sourced_flag = 2)
1455 THEN
1456 -- if this is an end item effective structure change
1457 -- then it will not be propgated to the child organization
1458 IF sl.from_end_item_rev_id IS NOT NULL
1459 THEN
1460 x_propagate_strc_changes := G_VAL_FALSE;
1461 Error_Handler.Add_Error_Token(
1462 p_Message_Name => 'ENG_PRP_REVEFF_STRC_DISABLED'
1463 , p_Mesg_Token_Tbl => l_mesg_token_tbl
1464 , x_Mesg_Token_Tbl => l_mesg_token_tbl
1465 , p_Token_Tbl => l_token_tbl
1466 , p_message_type => 'I' );
1467
1468 ELSIF sl.bill_sequence_id <> nvl(sl.source_bill_sequence_id, sl.bill_sequence_id)
1469 THEN
1470 x_propagate_strc_changes := G_VAL_FALSE;
1471 Error_Handler.Add_Error_Token(
1472 p_Message_Name => 'ENG_PRP_COMN_STRC_DISABLED'
1473 , p_Mesg_Token_Tbl => l_mesg_token_tbl
1474 , x_Mesg_Token_Tbl => l_mesg_token_tbl
1475 , p_Token_Tbl => l_token_tbl
1476 , p_message_type => 'I' );
1477 ELSIF l_structure_exists_flag = 0
1478 THEN
1479 l_token_tbl.delete;
1480 l_token_tbl(1).token_name := 'STRUCTURE';
1481 l_token_tbl(1).token_value := sl.alternate_bom_designator;
1482 Error_Handler.Add_Error_Token(
1483 p_Message_Name => 'ENG_PRP_STRC_NOT_EXISTS'
1484 , p_Mesg_Token_Tbl => l_mesg_token_tbl
1485 , x_Mesg_Token_Tbl => l_mesg_token_tbl
1486 , p_Token_Tbl => l_token_tbl);
1487 l_error_logged := 1;
1488 ELSIF l_structure_exists_flag = 1
1489 THEN
1490 -- if all components are of type add,
1491 -- initialize the structure line pl/sql table with defaults, so that they are not validated
1492 IF (l_create_bill_for_item = 1)
1493 THEN
1494 l_local_bill_sequence_id := 0;
1495 l_comn_bill_sequence_id := 0;
1496 l_from_end_item_minor_rev_id := null;
1497 l_from_end_item_rev_id := null;
1498 ELSE
1499 l_from_end_item_minor_rev_id := sl.from_end_item_strc_rev_id;
1500 l_from_end_item_rev_id := sl.from_end_item_rev_id;
1501 END IF;
1502
1503 l_struc_line_tbl(l_struc_count).revised_item_sequence_id := sl.revised_item_sequence_id;
1504 l_struc_line_tbl(l_struc_count).alternate_bom_designator := sl.alternate_bom_designator;
1505 l_struc_line_tbl(l_struc_count).bill_sequence_id := sl.bill_sequence_id;
1506 l_struc_line_tbl(l_struc_count).local_bill_sequence_id := l_local_bill_sequence_id;
1507 l_struc_line_tbl(l_struc_count).comn_bill_sequence_id := l_comn_bill_sequence_id;
1508 l_struc_line_tbl(l_struc_count).from_end_item_minor_rev_id := l_from_end_item_minor_rev_id;
1509 l_struc_line_tbl(l_struc_count).from_end_item_rev_id := l_from_end_item_rev_id;
1510
1511 END IF;
1512 END IF;
1513 END LOOP;
1514
1515 --
1516 -- if all structures exist
1517 -- auto enable transfer items with enable item in local org -> 'Y'. Log Info
1518 -- auto enable comps and subs comps of acd_type add if item is not sourced. Log Info
1519 -- For all components and substitute comps not in local org, log error
1520 -- For invalid from_end_item dtls , log error
1521 /*IF (l_error_logged = 0)
1522 THEN
1523 -- get all items with enable item for transfer
1524 -- Scoped out
1525 FOR tle in c_rev_items_for_enable(p_rev_item_seq_id)
1526 LOOP
1527 AUTO_ENABLE_ITEM_IN_ORG(
1528 p_inventory_item_id => tle.revised_item_id
1529 , p_organization_id => p_local_org_id
1530 , x_error_table => l_item_error_table
1531 , x_return_status => l_return_status);
1532 IF (l_return_status = 'S')
1533 THEN
1534 l_token_tbl.delete;
1535 l_token_tbl(1).token_name := 'ITEM';
1536 l_token_tbl(1).token_value := tle.item_name;
1537 Error_Handler.Add_Error_Token(
1538 p_Message_Name => 'ENG_PRP_TRNSMFG_ENABLED'
1539 , p_Mesg_Token_Tbl => l_mesg_token_tbl
1540 , x_Mesg_Token_Tbl => l_mesg_token_tbl
1541 , p_Token_Tbl => l_token_tbl
1542 , p_message_type => 'I' );
1543 ELSE
1544 FOR i IN 1..l_item_error_table.COUNT
1545 LOOP
1546 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Transfer Item Enabling Error:'||l_item_error_table(i).message_name);
1547 l_token_tbl.delete;
1548 l_token_tbl(1).token_name := 'MESSAGE';
1549 l_token_tbl(1).token_value := l_item_error_table(i).message_name;
1550 Error_Handler.Add_Error_Token(
1551 p_Message_Name => 'ENG_ERROR_MESSAGE'
1552 , p_Mesg_Token_Tbl => l_mesg_token_tbl
1553 , x_Mesg_Token_Tbl => l_mesg_token_tbl
1554 , p_Token_Tbl => l_token_tbl
1555 );
1556
1557 l_error_logged := 1;
1558 END LOOP;
1559 l_item_error_table.delete;
1560 END IF;
1561 END LOOP;
1562 END IF;*/
1563
1564 IF (l_error_logged = 0)
1565 THEN
1566 -- If no errors logged so far then process Transfer components
1567 -- Currently scoped out , transfer/copy components are not propagated. Loop does not process
1568 /*FOR tolc IN c_tolc_items
1569 LOOP
1570
1571 BEGIN
1572 select 1
1573 into l_item_exists_in_org_flag
1574 FROM mtl_system_items_b
1575 WHERE inventory_item_id = tolc.revised_item_id
1576 AND organization_id = p_local_org_id;
1577 EXCEPTION
1578 WHEN NO_DATA_FOUND THEN
1579 l_item_exists_in_org_flag := 0;
1580 END;
1581 IF (l_item_exists_in_org_flag = 0)
1582 THEN
1583 select concatenated_segments
1584 into l_temp_item_name
1585 from mtl_system_items_b_kfv
1586 where inventory_item_id = tolc.revised_item_id
1587 and organization_id = p_global_org_id;
1588
1589 Fnd_message.set_name('ENG', 'ENG_PRP_ITM_NOT_EXISTS');
1590 fnd_message.set_token('ITEM', l_temp_item_name);
1591 l_message_log_text := fnd_message.get();
1592
1593 l_eco_error_tbl(l_err_counter).Revised_item_sequence_id := p_rev_item_seq_id;
1594 l_eco_error_tbl(l_err_counter).log_text := l_message_log_text;
1595 l_eco_error_tbl(l_err_counter).log_type := 'ERROR';
1596 l_err_counter := l_err_counter + 1;
1597 l_error_logged := 1;
1598
1599 ELSIF (l_item_exists_in_org_flag = 1 AND tolc.transfer_or_copy_bill = 1)
1600 THEN
1601 BEGIN
1602 l_structure_exists_flag := 1;
1603 select bill_sequence_id, common_bill_sequence_id, assembly_type
1604 into l_local_bill_sequence_id, l_comn_bill_sequence_id, l_eng_bill_flag
1605 FROM BOM_BILL_OF_MATERIALS
1606 WHERE assembly_item_id = tolc.revised_item_id
1607 AND organization_id = p_local_org_id
1608 AND nvl(alternate_bom_designator, 'PRIMARY') = nvl(tolc.alternate_bom_designator, 'PRIMARY');
1609 EXCEPTION
1610 WHEN NO_DATA_FOUND THEN
1611 l_structure_exists_flag := 0;
1612 END;
1613 IF (l_structure_exists_flag = 0)
1614 THEN
1615 Fnd_message.set_name('ENG', 'ENG_ITEM_LC_PHASE_CHG_LINE');
1616 l_temp_mesg := fnd_message.get();
1617 Fnd_message.set_name('ENG', 'ENG_PRP_STRC_NOT_EXISTS');
1618 fnd_message.set_token('STRUCTURE', tolc.alternate_bom_designator);
1619 fnd_message.set_token('LINE', l_temp_mesg);
1620 l_message_log_text := fnd_message.get();
1621
1622 l_error_logged := 1;
1623 l_eco_error_tbl(l_err_counter).Revised_item_sequence_id := p_rev_item_seq_id;
1624 l_eco_error_tbl(l_err_counter).log_text := l_message_log_text;
1625 l_eco_error_tbl(l_err_counter).log_type := 'ERROR';
1626 l_err_counter := l_err_counter + 1;
1627 ELSE
1628 l_transfer_item_sourced_flag := 2;
1629
1630 IF (l_comn_bill_sequence_id <> l_local_bill_sequence_id
1631 AND tolc.transfer_or_copy = 'T'
1632 AND tolc.create_bom_in_local_org = 'Y'
1633 AND l_comn_bill_sequence_id = tolc.bill_sequence_id
1634 AND l_eng_bill_flag <> 1)
1635 THEN
1636
1637 -- check if sourcing rules exist for item
1638 l_transfer_item_sourced_flag := CHECK_SOURCING_RULES(p_local_org_id, tolc.revised_item_id);
1639
1640 IF ( l_transfer_item_sourced_flag = 2)
1641 THEN
1642 BREAK_COMMON_BOM(
1643 p_to_sequence_id => l_local_bill_sequence_id
1644 , p_from_sequence_id => tolc.bill_sequence_id
1645 , p_from_org_id => p_global_org_id
1646 , p_to_org_id => p_local_org_id
1647 , p_to_item_id => tolc.revised_item_id
1648 , p_to_alternate => tolc.alternate_bom_designator
1649 , p_from_item_id => tolc.revised_item_id);
1650
1651 l_comn_bill_sequence_id := l_local_bill_sequence_id;
1652
1653 Fnd_message.set_name('ENG', 'ENG_PRP_COMN_BOM_BREAK');
1654 fnd_message.set_token('STRUCTURE', tolc.alternate_bom_designator);
1655 l_message_log_text := fnd_message.get();
1656 l_eco_mesg_tbl(l_mesg_counter).Revised_item_sequence_id := p_rev_item_seq_id;
1657 l_eco_mesg_tbl(l_mesg_counter).log_text := l_message_log_text;
1658 l_eco_mesg_tbl(l_mesg_counter).log_type := 'INFO';
1659 l_mesg_counter := l_mesg_counter + 1;
1660 END IF;
1661
1662 IF (l_comn_bill_sequence_id <> l_local_bill_sequence_id
1663 AND l_transfer_item_sourced_flag = 2
1664 AND l_eng_bill_flag <> 1)
1665 THEN
1666 Fnd_message.set_name('ENG', 'ENG_ITEM_LC_PHASE_CHG_LINE');
1667 l_temp_mesg := fnd_message.get();
1668 Fnd_message.set_name('ENG', 'ENG_PRP_COMMON_BOM');
1669 fnd_message.set_token('STRUCTURE', tolc.alternate_bom_designator);
1670 fnd_message.set_token('LINE', l_temp_mesg);
1671 l_message_log_text := fnd_message.get();
1672
1673 l_error_logged := 1;
1674 l_eco_error_tbl(l_err_counter).Revised_item_sequence_id := p_rev_item_seq_id;
1675 l_eco_error_tbl(l_err_counter).log_text := l_message_log_text;
1676 l_eco_error_tbl(l_err_counter).log_type := 'ERROR';
1677 l_err_counter := l_err_counter + 1;
1678 END IF;
1679 END IF;
1680 END IF;
1681 END IF;
1682 END LOOP;*/
1683
1684 -- Further Process structure changes
1685 -- Doing this validation after break common for tolc revised items
1686 -- Check if the structure is common an delete sturcture line from being processed.
1687 -- Only attachment changes should be processed for there revised items
1688 IF (l_item_sourced_flag = 2)
1689 THEN
1690 -- bug 10146196, check added to see if ECO has bill changes
1691 BEGIN
1692 select decode(count(*),0,'N','Y') --bug 14573265
1693 into l_eco_chg_exists
1694 from bom_inventory_components
1695 where change_notice = p_change_notice
1696 and pk2_value = p_local_org_id; --bug 14051321, add org_id to avoid error ORA-01422
1697
1698 EXCEPTION
1699 WHEN NO_DATA_FOUND THEN
1700 l_eco_chg_exists := 'N';
1701 END;
1702
1703 if (l_eco_chg_exists = 'Y' ) then -- with 'end if', end 10146196
1704 -- check all structures lines for common bom
1705 FOR i IN 1..l_struc_line_tbl.COUNT
1706 LOOP
1707 IF (l_struc_line_tbl(i).local_bill_sequence_id <> l_struc_line_tbl(i).comn_bill_sequence_id)
1708 THEN
1709 Fnd_message.set_name('ENG', 'ENG_STRUCTURE_CHG_LINE');
1710 l_temp_mesg := fnd_message.get();
1711 l_token_tbl.delete;
1712 l_token_tbl(1).token_name := 'STRUCTURE';
1713 l_token_tbl(1).token_value := l_struc_line_tbl(i).alternate_bom_designator;
1714 l_token_tbl(2).token_name := 'LINE';
1715 l_token_tbl(2).token_value := l_temp_mesg;
1716 Error_Handler.Add_Error_Token(
1717 p_Message_Name => 'ENG_PRP_COMMON_BOM'
1718 , p_Mesg_Token_Tbl => l_mesg_token_tbl
1719 , x_Mesg_Token_Tbl => l_mesg_token_tbl
1720 , p_Token_Tbl => l_token_tbl);
1721 l_error_logged := 1;
1722 --l_struc_line_tbl(i).delete;
1723 END IF;
1724 END LOOP;
1725 END IF; -- if (l_eco_chg_exists = 'Y') then
1726 END IF;
1727 END IF;
1728 END IF;
1729 END IF;
1730
1731 x_sourcing_rules_exists := l_item_sourced_flag;
1732 x_error_logged := l_error_logged;
1733 x_revised_item_name := l_revised_item_number;
1734 x_Mesg_Token_Tbl := l_mesg_token_tbl;
1735
1736 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Output Param: p_propagate_revised_item '|| l_item_exists_in_org_flag);
1737 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Output Param: p_sourcing_rules_exists '|| l_item_sourced_flag);
1738 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Output Param: p_error_logged '|| l_error_logged);
1739 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Output Param: p_revised_item_name '|| l_revised_item_number);
1740
1741 Eng_Propagation_Log_Util.Debug_Log(G_LOG_PROC, 'CHECK_REVISED_ITEM_ERRORS.end');
1742 Eng_Propagation_Log_Util.Debug_Log(G_LOG_PROC, '-------------------------------');
1743 EXCEPTION
1744 WHEN OTHERS THEN
1745 Eng_Propagation_Log_Util.Debug_Log(Eng_Propagation_Log_Util.G_LOG_ERROR, 'CHECK_REVISED_ITEM_ERRORS.Unexpected error'|| SQLERRM);
1746 END Check_Revised_Item_Errors;
1747
1748 PROCEDURE PROPAGATE_ECO_ERP
1749 (
1750 errbuf OUT NOCOPY VARCHAR2,
1751 retcode OUT NOCOPY VARCHAR2,
1752 p_change_notice IN VARCHAR2,
1753 p_org_hierarchy_name IN VARCHAR2,
1754 p_org_hierarchy_level IN VARCHAR2
1755 )
1756 IS
1757 l_eco_rec Eng_Eco_Pub.Eco_Rec_Type;
1758 l_change_lines_tbl Eng_Eco_Pub.Change_Line_Tbl_Type;
1759 l_eco_revision_tbl Eng_Eco_Pub.Eco_Revision_Tbl_Type;
1760 l_revised_item_tbl Eng_Eco_Pub.Revised_Item_Tbl_Type;
1761 l_rev_component_tbl Bom_Bo_Pub.Rev_Component_Tbl_Type;
1762 l_sub_component_tbl Bom_Bo_Pub.Sub_Component_Tbl_Type;
1763 l_ref_designator_tbl Bom_Bo_Pub.Ref_Designator_Tbl_Type;
1764 l_rev_operation_tbl Bom_Rtg_Pub.Rev_Operation_Tbl_Type;
1765 l_rev_op_resource_tbl Bom_Rtg_Pub.Rev_Op_Resource_Tbl_Type;
1766 l_rev_sub_resource_tbl Bom_Rtg_Pub.Rev_Sub_Resource_Tbl_Type;
1767
1768 l_org_code_list INV_OrgHierarchy_PVT.OrgID_tbl_type;
1769 l_org_hierarchy_level_id NUMBER;
1770 l_org_code VARCHAR2(3);
1771 l_org_id NUMBER;
1772 l_change_type_code VARCHAR2(80);
1773 l_requestor_name VARCHAR2(30);
1774 l_assignee_name VARCHAR2(30);
1775 l_Task_Number VARCHAR2(25);
1776 /* changing for UTF8 Column Expansion */
1777 l_Project_Number VARCHAR2(30);
1778 l_rev_description VARCHAR2(240);
1779 l_approval_list_name VARCHAR2(10);
1780 /* changing for UTF8 Column Expansion */
1781 l_department_name VARCHAR2(240);
1782 l_revised_item_number VARCHAR2(801);
1783 l_use_up_item_name VARCHAR2(801);
1784 l_revised_item_name VARCHAR2(801);
1785 l_new_item_revision VARCHAR2(3);
1786 l_effectivity_date DATE;
1787 l_revised_item_name1 VARCHAR2(801);
1788 l_revised_item_name2 VARCHAR2(801);
1789 l_component_item_name VARCHAR2(801);
1790 l_component_item_name1 VARCHAR2(801);
1791 l_component_item_name2 VARCHAR2(801);
1792 l_location_name VARCHAR2(81);
1793 l_substitute_component_name VARCHAR2(801);
1794 l_operation_seq_num NUMBER;
1795 l_item_exits_in_org_flag NUMBER;
1796 l_check_invalid_objects NUMBER := 1;
1797
1798 l_return_status VARCHAR2(1);
1799 l_msg_count NUMBER;
1800 l_msg_data VARCHAR2(2000);
1801 l_Error_Table Error_Handler.Error_Tbl_Type;
1802 l_Message_text VARCHAR2(2000);
1803
1804 l_org_count NUMBER;
1805 l_count NUMBER;
1806 temp_count NUMBER := 0;
1807 i NUMBER;
1808 item_id NUMBER;
1809 bill_id NUMBER;
1810 old_operation_seq_num NUMBER;
1811 old_effectivity_date DATE;
1812 l_old_effectivity_date DATE;
1813 component_seq_id NUMBER;
1814 St_Number NUMBER;
1815
1816 l_eco_status_name eng_change_statuses_vl.status_name%TYPE; -- bug 3571079
1817
1818 -- Added for Bug-5725081
1819
1820 v_component_quantity_to NUMBER ;
1821 v_component_low_quantity NUMBER ;
1822 v_component_high_quantity NUMBER ;
1823 v_substitute_item_quantity NUMBER ;
1824 l_new_change_id NUMBER; /* bug #7496156*/
1825 l_alternate_bom VARCHAR2(10) ; /* for bug 9368374 */
1826 /* Cursor to Pick all ECO header for the Top Organization for the given Change N
1827 otice */
1828
1829 CURSOR c_eco_rec IS
1830 SELECT *
1831 FROM eng_changes_v
1832 WHERE change_notice = p_change_notice
1833 AND organization_id = l_org_hierarchy_level_id;
1834
1835 /* Cursor to Pick all Revised Items for the Top Organization for the given Chan
1836 ge Notice*/
1837
1838 CURSOR c_eco_revision IS
1839 SELECT *
1840 FROM eng_change_order_revisions
1841 WHERE change_notice = p_change_notice
1842 AND organization_id = l_org_hierarchy_level_id;
1843
1844 /* Cursor to Pick all Revised Items for the Top Organization for the given Chan
1845 ge Notice.Bug no 4327321 only revised items will get propagate.No transfer and copy items.*/
1846
1847 CURSOR c_rev_items IS
1848 SELECT *
1849 FROM eng_revised_items
1850 WHERE change_notice = p_change_notice
1851 AND organization_id = l_org_hierarchy_level_id
1852 AND transfer_or_copy is NULL;
1853
1854
1855 /* cursor to pick up Revised component records for the top organization for
1856 the given change notice which have the ACD_type of Disable and have been
1857 implementedfrom eng_revised_items table. These records are not present in
1858 bom_inventory_components table hence this extra cursor. */
1859
1860 CURSOR c_rev_comps_disable IS
1861 SELECT *
1862 FROM eng_revised_components
1863 WHERE change_notice = p_change_notice
1864 AND ACD_TYPE = 3
1865 AND revised_item_sequence_id in
1866 (SELECT revised_item_sequence_id
1867 FROM eng_revised_items
1868 WHERE change_notice = p_change_notice
1869 AND organization_id = l_org_hierarchy_level_id);
1870
1871 /* Cursor to Pick all Revised Component Items for the Top Organization for the
1872 given Change Notice*/
1873
1874 CURSOR c_rev_comps IS
1875 SELECT *
1876 FROM bom_inventory_components
1877 WHERE change_notice = p_change_notice
1878 AND revised_item_sequence_id in
1879 (SELECT revised_item_sequence_id
1880 FROM eng_revised_items
1881 WHERE change_notice = p_change_notice
1882 AND organization_id = l_org_hierarchy_level_id);
1883
1884 /* Cursor to Pick all substitute Component Items for the Top Organization for t
1885 he given Change Notice*/
1886
1887 CURSOR c_sub_comps IS
1888 SELECT *
1889 FROM bom_substitute_components
1890 WHERE change_notice = p_change_notice
1891 AND component_sequence_id in
1892 (SELECT component_sequence_id
1893 FROM bom_inventory_components
1894 WHERE change_notice = p_change_notice
1895 AND revised_item_sequence_id in
1896 (SELECT revised_item_sequence_id
1897 FROM eng_revised_items
1898 WHERE change_notice = p_change_notice
1899 AND organization_id = l_org_hierarchy_level_id));
1900
1901 /* Cursor to Pick all reference designators for the Top Organization for the gi
1902 ven Change Notice*/
1903
1904 CURSOR c_ref_desgs IS
1905 SELECT *
1906 FROM bom_reference_designators
1907 WHERE change_notice = p_change_notice
1908 AND component_sequence_id in
1909 (SELECT component_sequence_id
1910 FROM bom_inventory_components
1911 WHERE change_notice = p_change_notice
1912 AND revised_item_sequence_id in
1913 (SELECT revised_item_sequence_id
1914 FROM eng_revised_items
1915 WHERE change_notice = p_change_notice
1916 AND organization_id = l_org_hierarchy_level_id));
1917
1918 -- Modified query for performance bug 4251776
1919 -- Bug No: 4327218
1920 -- Modified query to refer to 'person_party_id' instead of 'customer_id'
1921 CURSOR c_user_name(v_party_id IN NUMBER) IS
1922 SELECT us.user_name FROM fnd_user us, hz_parties pa
1923 WHERE ((us.employee_id IS NOT NULL AND us.employee_id = pa.person_identifier))
1924 AND pa.party_id = v_party_id
1925 union all
1926 SELECT us.user_name
1927 FROM fnd_user us, hz_parties pa
1928 WHERE (us.employee_id IS NULL AND (us.person_party_id= pa.party_id or (us.person_party_id is null and us.supplier_id = pa.party_id)))
1929 AND pa.party_id = v_party_id;
1930
1931 /* WHERE nvl(us.employee_id, nvl(us.customer_id, us.supplier_id)) = pa.person_identifier
1932 AND pa.party_id = v_party_id;*/
1933
1934 -- Bug 4339626
1935 l_status_type NUMBER;
1936
1937 BEGIN
1938
1939 FND_FILE.PUT_LINE(FND_FILE.LOG,'Starting PROPAGATE_ECO');
1940 FND_FILE.PUT_LINE(FND_FILE.LOG,'CHANGE_NOTICE '|| p_change_notice);
1941 FND_FILE.PUT_LINE(FND_FILE.LOG,'HIERARCHY_NAME '|| p_org_hierarchy_name);
1942 FND_FILE.PUT_LINE(FND_FILE.LOG,'HIERARCHY_LEVEL '|| p_org_hierarchy_level);
1943
1944 /* Need the Organization Id to fetch the records */
1945 SELECT MP.organization_id
1946 INTO l_org_hierarchy_level_id
1947 FROM HR_ORGANIZATION_UNITS HOU
1948 , HR_ORGANIZATION_INFORMATION HOI1
1949 , MTL_PARAMETERS MP
1950 WHERE HOU.ORGANIZATION_ID = HOI1.ORGANIZATION_ID
1951 AND HOU.ORGANIZATION_ID = MP.ORGANIZATION_ID
1952 AND HOI1.ORG_INFORMATION1 = 'INV'
1953 AND HOI1.ORG_INFORMATION2 = 'Y'
1954 AND HOU.NAME = p_org_hierarchy_level;
1955 /*SELECT organization_id
1956 INTO l_org_hierarchy_level_id
1957 FROM org_organization_definitions
1958 WHERE organization_name = p_org_hierarchy_level;*/
1959
1960 INV_ORGHIERARCHY_PVT.ORG_HIERARCHY_LIST(p_org_hierarchy_name,
1961 l_org_hierarchy_level_id,l_org_code_list);
1962
1963
1964 IF (l_org_code_list.COUNT = 0) THEN
1965
1966 FND_FILE.PUT_LINE(FND_FILE.LOG, 'No Organization exists under the Hierarchy Level '|| p_org_hierarchy_name||' and '||p_org_hierarchy_level);
1967
1968 RETURN;
1969 END IF;
1970
1971 IF (l_org_code_list.COUNT = 1) THEN
1972
1973 FND_FILE.PUT_LINE(FND_FILE.LOG,'Only Organization '|| p_org_hierarchy_level|| ' exists under the Hierarchy Level'|| p_org_hierarchy_name||' and '||p_org_hierarchy_level);
1974
1975 RETURN;
1976 END IF;
1977
1978 FND_FILE.PUT_LINE(FND_FILE.LOG,'');
1979 FND_FILE.PUT_LINE(FND_FILE.LOG,'Organizations in Hierarchy ');
1980 FND_FILE.PUT_LINE(FND_FILE.LOG,'--------------------------');
1981 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Total Orgs in Hierarchy = '||l_org_code_list.COUNT);
1982
1983 FOR l_org_count in 1..l_org_code_list.COUNT
1984 Loop
1985 FND_FILE.PUT_LINE(FND_FILE.LOG,'Org : '||l_org_code_list(l_org_count));
1986 end loop;
1987
1988 FND_FILE.PUT_LINE(FND_FILE.LOG,'');
1989
1990 FOR l_org_count in 2..l_org_code_list.LAST
1991 LOOP /* Loop 1 */
1992
1993 l_org_id := l_org_code_list(l_org_count);
1994
1995 /* Need the Organization Code for Populating PL/SQL table */
1996 -- Bug 4546616
1997 -- Check Organization is valid using exception handling
1998 BEGIN
1999
2000 SELECT organization_code
2001 INTO l_org_code
2002 FROM mtl_parameters
2003 WHERE organization_id = l_org_id;
2004 EXCEPTION
2005 WHEN NO_DATA_FOUND THEN
2006 NULL;
2007 END;
2008
2009 IF l_org_code IS NOT NULL /* Organization Check*/
2010 THEN
2011
2012 FND_FILE.PUT_LINE(FND_FILE.LOG,'Processing Organization '|| l_org_code);
2013 FND_FILE.PUT_LINE(FND_FILE.LOG,'');
2014
2015
2016 SELECT count(*)
2017 into temp_count
2018 FROM eng_engineering_changes
2019 WHERE change_notice = p_change_notice
2020 AND organization_id = l_org_id;
2021
2022 -- Fetch ECO Masters
2023
2024 IF temp_count > 0 THEN /* ECO Check */
2025
2026 FND_FILE.PUT_LINE(FND_FILE.LOG,'This ECO '||p_change_notice|| 'will not be processed as it already exists in Organization '|| l_org_code);
2027
2028 ELSE
2029
2030 FOR eco_rec IN c_eco_rec
2031 LOOP /* Loop 2 */
2032
2033 FND_FILE.PUT_LINE(FND_FILE.LOG,'Processing ECO Header ...');
2034
2035 IF (eco_rec.change_order_type_id IS NOT NULL) THEN
2036
2037 SELECT CHANGE_ORDER_TYPE
2038 INTO l_change_type_code
2039 FROM eng_change_order_types_v --11.5.10 Changes
2040 WHERE change_order_type_id = eco_rec.change_order_type_id;
2041
2042 ELSE
2043
2044 l_change_type_code := NULL;
2045
2046 END IF;
2047
2048 IF (eco_rec.responsible_organization_id IS NOT NULL) THEN
2049
2050 SELECT name
2051 INTO l_department_name
2052 FROM hr_all_organization_units
2053 WHERE organization_id = eco_rec.responsible_organization_id;
2054
2055 ELSE
2056
2057 l_department_name := NULL;
2058
2059 END IF;
2060
2061 IF (eco_rec.approval_list_id IS NOT NULL) THEN
2062
2063 SELECT approval_list_name
2064 INTO l_approval_list_name
2065 FROM eng_ecn_approval_lists
2066 WHERE approval_list_id = eco_rec.approval_list_id;
2067
2068 ELSE
2069
2070 l_approval_list_name := NULL;
2071
2072 END IF;
2073
2074 IF (eco_rec.requestor_id IS NOT NULL) THEN
2075 begin
2076 OPEN c_user_name(eco_rec.requestor_id);
2077 FETCH c_user_name INTO l_requestor_name;
2078 CLOSE c_user_name;
2079 exception
2080 When No_Data_found then
2081 FND_FILE.PUT_LINE(FND_FILE.LOG,'No_Data_found for requestor id ' || to_char( eco_rec.requestor_id) || ' in org ' || to_char(l_org_hierarchy_level_id));
2082 l_requestor_name := NULL;
2083 end;
2084
2085 /*
2086 -- Replaced the before sql for performance.
2087 Begin
2088 SELECT employee_num
2089 INTO l_requestor_name
2090 FROM mtl_employees_view
2091 WHERE organization_id = l_org_hierarchy_level_id
2092 AND employee_id = eco_rec.requestor_id;
2093 Exception
2094 When No_Data_found then
2095 FND_FILE.PUT_LINE(FND_FILE.LOG,'No_Data_found for requestor id ' || to_char( eco_rec.requestor_id) || ' in org ' || to_char(l_org_hierarchy_level_id));
2096 l_requestor_name := NULL;
2097 End;
2098 */
2099 ELSE
2100
2101 l_requestor_name := NULL;
2102
2103 END IF;
2104
2105 IF (eco_rec.assignee_id IS NOT NULL) THEN
2106 begin
2107 OPEN c_user_name(eco_rec.assignee_id);
2108 FETCH c_user_name INTO l_assignee_name;
2109 CLOSE c_user_name;
2110 exception
2111 When No_Data_found then
2112 FND_FILE.PUT_LINE(FND_FILE.LOG,'No_Data_found for assignee id ' || to_char( eco_rec.assignee_id) || ' in org ' || to_char(l_org_hierarchy_level_id));
2113 l_assignee_name := NULL;
2114 end;
2115 ELSE
2116 l_assignee_name := NULL;
2117 END IF;
2118
2119
2120 IF (eco_rec.PROJECT_ID IS NOT NULL) THEN
2121 Begin
2122 SELECT name
2123 into l_Project_Number
2124 FROM pa_projects_all
2125 WHERE project_id = eco_rec.PROJECT_ID;
2126 Exception
2127 When No_Data_found then
2128 FND_FILE.PUT_LINE(FND_FILE.LOG,'No_Data_found for project id ' || to_char( eco_rec.PROJECT_ID));
2129 l_Project_Number := NULL;
2130 End;
2131 ELSE
2132 l_Project_Number := NULL;
2133 END IF;
2134
2135 IF (eco_rec.TASK_ID IS NOT NULL) THEN
2136 Begin
2137 SELECT task_number
2138 into l_Task_Number
2139 FROM pa_tasks
2140 WHERE TASK_ID = eco_rec.TASK_ID;
2141 Exception
2142 When No_Data_found then
2143 FND_FILE.PUT_LINE(FND_FILE.LOG,'No_Data_found for task id ' || to_char( eco_rec.TASK_ID));
2144 l_Task_Number := NULL;
2145 End;
2146 ELSE
2147 l_Task_Number := NULL;
2148 END IF;
2149
2150 --
2151 -- Bug 4339626
2152 -- Use the Eng_globals to initialize the details for the process associated to the type
2153 ENG_Globals.Init_Process_Name(
2154 p_change_order_type_id => eco_rec.change_order_type_id
2155 , p_priority_code => eco_rec.priority_code
2156 , p_organization_id => l_org_id);
2157 -- Setting the destination eco status as scheduled by default
2158 l_status_type := 4;
2159 -- If there is no process associated , then schedule the detination eco
2160 -- Create the destination ECO in Open otherwise.
2161 -- The following condition is to set the detinaion eco and revised items to open
2162 IF ENG_Globals.Get_Process_Name IS NOT NULL
2163 THEN
2164 l_status_type := 1;
2165 END IF;
2166 -- End of Bug 4339626
2167
2168 -- Added for bug 3571079
2169 -- Fetch the status corresponding to status_code =4 i.e 'Scheduled'
2170 BEGIN
2171 SELECT status_name
2172 INTO l_eco_status_name
2173 FROM eng_change_statuses_vl
2174 WHERE status_code = l_status_type;
2175 EXCEPTION
2176 WHEN OTHERS THEN
2177 l_eco_status_name := eco_rec.eco_status;
2178 END;
2179 -- End changes for bug 3571079
2180
2181
2182 /* Popuating PL/SQL record for ECO Header */
2183
2184
2185 l_eco_rec.eco_name := eco_rec.change_notice;
2186 l_eco_rec.change_name := eco_rec.change_name; --Added for bug 9405365
2187 l_eco_rec.organization_code := l_org_code;
2188 l_eco_rec.change_type_code := l_change_type_code;
2189 l_eco_rec.status_name := l_eco_status_name; -- eco_rec.eco_status; -- bug 3571079
2190 l_eco_rec.eco_department_name := l_department_name;
2191 l_eco_rec.priority_code := eco_rec.priority_code;
2192 l_eco_rec.approval_list_name := l_approval_list_name;
2193 l_eco_rec.Approval_Status_Name := eco_rec.approval_status;
2194 l_eco_rec.reason_code := eco_rec.reason_code;
2195 l_eco_rec.eng_implementation_cost := eco_rec.estimated_eng_cost;
2196 l_eco_rec.mfg_implementation_cost := eco_rec.estimated_mfg_cost;
2197 l_eco_rec.cancellation_comments:=eco_rec.cancellation_comments;
2198 l_eco_rec.requestor := l_requestor_name;
2199 l_eco_rec.assignee := l_assignee_name;
2200 l_eco_rec.description := eco_rec.description;
2201 l_eco_rec.attribute_category := eco_rec.attribute_category;
2202 l_eco_rec.attribute1 := eco_rec.attribute1;
2203 l_eco_rec.attribute2 := eco_rec.attribute2;
2204 l_eco_rec.attribute3 := eco_rec.attribute3;
2205 l_eco_rec.attribute4 := eco_rec.attribute4;
2206 l_eco_rec.attribute5 := eco_rec.attribute5;
2207 l_eco_rec.attribute6 := eco_rec.attribute6;
2208 l_eco_rec.attribute7 := eco_rec.attribute7;
2209 l_eco_rec.attribute8 := eco_rec.attribute8;
2210 l_eco_rec.attribute9 := eco_rec.attribute9;
2211 l_eco_rec.attribute10 := eco_rec.attribute10;
2212 l_eco_rec.attribute11 := eco_rec.attribute11;
2213 l_eco_rec.attribute12 := eco_rec.attribute12;
2214 l_eco_rec.attribute13 := eco_rec.attribute13;
2215 l_eco_rec.attribute14 := eco_rec.attribute14;
2216 l_eco_rec.attribute15 := eco_rec.attribute15;
2217 --l_eco_rec.Original_System_Reference := eco_rec.Original_System_Reference;
2218 l_eco_rec.Project_Name := eco_rec.Project_Name;
2219 l_eco_rec.Task_Number := eco_rec.Task_Number;
2220 --l_eco_rec.hierarchy_flag := 2;
2221 l_eco_rec.organization_hierarchy := NULL;
2222 l_eco_rec.return_status := NULL;
2223 l_eco_rec.transaction_type := 'CREATE';
2224 --11.5.10
2225 l_eco_rec.plm_or_erp_change := eco_rec.plm_or_erp_change;
2226 -- Fetch ECO Revisions
2227
2228 i := 1;
2229
2230 FOR rev IN c_eco_revision
2231 LOOP /* Loop 3 */
2232
2233 FND_FILE.PUT_LINE(FND_FILE.LOG,'Processing ECO Revision ...');
2234
2235 l_eco_revision_tbl(i).eco_name := rev.change_notice;
2236 l_eco_revision_tbl(i).organization_code:= l_org_code;
2237 l_eco_revision_tbl(i).revision := rev.revision;
2238 -- l_eco_revision_tbl(i).new_revision := rev.new_revision;
2239 l_eco_revision_tbl(i).new_revision := NULL;
2240 l_eco_revision_tbl(i).Attribute_category := rev.Attribute_category;
2241 l_eco_revision_tbl(i).attribute1 := rev.attribute1;
2242 l_eco_revision_tbl(i).attribute2 := rev.attribute2;
2243 l_eco_revision_tbl(i).attribute3 := rev.attribute3;
2244 l_eco_revision_tbl(i).attribute4 := rev.attribute4;
2245 l_eco_revision_tbl(i).attribute5 := rev.attribute5;
2246 l_eco_revision_tbl(i).attribute6 := rev.attribute6;
2247 l_eco_revision_tbl(i).attribute7 := rev.attribute7;
2248 l_eco_revision_tbl(i).attribute8 := rev.attribute8;
2249 l_eco_revision_tbl(i).attribute9 := rev.attribute9;
2250 l_eco_revision_tbl(i).attribute10 :=rev.attribute10;
2251 l_eco_revision_tbl(i).attribute11 :=rev.attribute11;
2252 l_eco_revision_tbl(i).attribute12 :=rev.attribute12;
2253 l_eco_revision_tbl(i).attribute13 := rev.attribute13;
2254 l_eco_revision_tbl(i).attribute14 := rev.attribute14;
2255 l_eco_revision_tbl(i).attribute15 := rev.attribute15;
2256 l_eco_revision_tbl(i).Original_System_Reference :=
2257 rev.Original_System_Reference;
2258 l_eco_revision_tbl(i).comments := rev.comments;
2259 l_eco_revision_tbl(i).return_status := NULL;
2260 l_eco_revision_tbl(i).transaction_type := 'CREATE';
2261
2262 i := i + 1;
2263
2264 END LOOP; /* End Loop 3 */
2265
2266 FND_FILE.PUT_LINE(FND_FILE.LOG,'');
2267
2268 -- Fetch revised items
2269
2270 i := 1;
2271
2272 FOR ri IN c_rev_items
2273 LOOP /* Loop 4 */
2274
2275 FND_FILE.PUT_LINE(FND_FILE.LOG,'Processing Revised Items ...');
2276
2277 BEGIN
2278
2279 l_item_exits_in_org_flag := 1;
2280
2281 SELECT concatenated_segments
2282 INTO l_revised_item_number
2283 FROM mtl_system_items_b_kfv
2284 WHERE inventory_item_id = ri.revised_item_id
2285 AND organization_id = l_org_id;
2286 EXCEPTION
2287 WHEN NO_DATA_FOUND THEN
2288 l_item_exits_in_org_flag := 0;
2289 l_check_invalid_objects := 0;
2290 END;
2291 /* Added for bug9368374 */
2292 IF ri.alternate_bom_designator is NOT NULL then
2293 BEGIN
2294
2295 SELECT ALTERNATE_DESIGNATOR_CODE
2296 INTO l_alternate_bom
2297 FROM BOM_ALTERNATE_DESIGNATORS
2298 WHERE ORGANIZATION_ID = l_org_id
2299 AND ALTERNATE_DESIGNATOR_CODE = ri.alternate_bom_designator;
2300
2301 EXCEPTION
2302 WHEN NO_DATA_FOUND THEN
2303 FND_FILE.PUT_LINE(FND_FILE.LOG,'Alternate BOM Designator ' || ri.alternate_bom_designator||' is not defined for Org '||l_org_code);
2304 l_check_invalid_objects := 0;
2305 END;
2306
2307 BEGIN
2308
2309 select 1
2310 INTO l_alternate_bom
2311 FROM BOM_BILL_OF_MATERIALS
2312 WHERE assembly_item_id = ri.revised_item_id
2313 AND organization_id = l_org_id
2314 AND alternate_bom_designator is NULL;
2315
2316 EXCEPTION
2317 WHEN NO_DATA_FOUND THEN
2318 FND_FILE.PUT_LINE(FND_FILE.LOG,'Cannot define an Alternate BOM Designator ' ||ri.alternate_bom_designator||' without primary bill for revised item id '|| ri.revised_item_id|| ' in org '||l_org_code);
2319 l_check_invalid_objects := 0;
2320 END;
2321
2322 END IF;
2323 /* Added for bug9368374 */
2324 IF (l_item_exits_in_org_flag = 1) THEN
2325
2326 IF (ri.use_up_item_id IS NOT NULL) THEN
2327
2328 BEGIN
2329 SELECT concatenated_segments
2330 INTO l_use_up_item_name
2331 FROM mtl_system_items_b_kfv
2332 WHERE inventory_item_id = ri.use_up_item_id
2333 AND organization_id = l_org_id;
2334 EXCEPTION WHEN NO_DATA_FOUND THEN
2335 l_item_exits_in_org_flag := 0;
2336 l_check_invalid_objects := 0;
2337 END;
2338
2339 ELSE
2340
2341 l_use_up_item_name := NULL;
2342
2343 END IF;
2344
2345 FND_FILE.PUT_LINE(FND_FILE.LOG,'');
2346
2347 IF (l_item_exits_in_org_flag = 1) THEN
2348 l_revised_item_tbl(i).eco_name := ri.change_notice;
2349 l_revised_item_tbl(i).organization_code := l_org_code;
2350 l_revised_item_tbl(i).revised_item_name := l_revised_item_number;
2351 IF ((ri.new_item_revision = FND_API.G_MISS_CHAR) OR
2352 (ri.new_item_revision IS NULL)) THEN
2353 l_revised_item_tbl(i).new_revised_item_revision := NULL;
2354 ELSE
2355 l_revised_item_tbl(i).new_revised_item_revision :=
2356 ri.new_item_revision;
2357 SELECT DESCRIPTION
2358 INTO l_rev_description
2359 FROM mtl_item_revisions
2360 WHERE inventory_item_id = ri.revised_item_id
2361 AND organization_id = ri.organization_id
2362 AND revision = ri.new_item_revision ;
2363 l_revised_item_tbl(i).New_Revised_Item_Rev_Desc :=
2364 l_rev_description;
2365 l_revised_item_tbl(i).Updated_Revised_Item_Revision := NULL;
2366 END IF;
2367 l_revised_item_tbl(i).start_effective_date :=
2368 ri.scheduled_date;
2369 l_revised_item_tbl(i).New_Effective_Date := NULL;
2370 l_revised_item_tbl(i).alternate_bom_code := ri.alternate_bom_designator; /* for bug 9368374 */
2371 -- NULL;
2372
2373 /* This is always NULL as we are not creating ALternate Bills in the
2374 Hierarchy */
2375 /* Revised Item Status has to be Scheduled as the Propagated ECOs
2376 have to be scheduled automatically so that they will be picked
2377 by Auto Implement for Implementation
2378 */
2379 l_revised_item_tbl(i).status_type := l_status_type;
2380 l_revised_item_tbl(i).mrp_active := ri.mrp_active;
2381 l_revised_item_tbl(i).earliest_effective_date :=
2382 ri.early_schedule_date;
2383 l_revised_item_tbl(i).use_up_item_name := l_use_up_item_name;
2384 l_revised_item_tbl(i).use_up_plan_name := ri.use_up_plan_name;
2385 l_revised_item_tbl(i).Requestor := NULL;
2386 l_revised_item_tbl(i).disposition_type := ri.disposition_type;
2387 l_revised_item_tbl(i).update_wip := ri.update_wip;
2388 l_revised_item_tbl(i).cancel_comments := ri.cancel_comments;
2389 -- l_revised_item_tbl(i).cfm_routing_flag :=
2390 -- ri.cfm_routing_flag;
2391 l_revised_item_tbl(i).ctp_flag := ri.ctp_flag;
2392 l_revised_item_tbl(i).return_status := NULL;
2393 l_revised_item_tbl(i).change_description :=
2394 ri.descriptive_text;
2395 l_revised_item_tbl(i).Attribute_category :=
2396 ri.Attribute_category;
2397 l_revised_item_tbl(i).attribute1 := ri.attribute1;
2398 l_revised_item_tbl(i).attribute2 := ri.attribute2;
2399 l_revised_item_tbl(i).attribute3 := ri.attribute3;
2400 l_revised_item_tbl(i).attribute4 := ri.attribute4;
2401 l_revised_item_tbl(i).attribute5 := ri.attribute5;
2402 l_revised_item_tbl(i).attribute6 := ri.attribute6;
2403 l_revised_item_tbl(i).attribute7 := ri.attribute7;
2404 l_revised_item_tbl(i).attribute8 := ri.attribute8;
2405 l_revised_item_tbl(i).attribute9 := ri.attribute9;
2406 l_revised_item_tbl(i).attribute10 := ri.attribute10;
2407 l_revised_item_tbl(i).attribute11 := ri.attribute11;
2408 l_revised_item_tbl(i).attribute12 := ri.attribute12;
2409 l_revised_item_tbl(i).attribute13 := ri.attribute13;
2410 l_revised_item_tbl(i).attribute14 := ri.attribute14;
2411 l_revised_item_tbl(i).attribute15 := ri.attribute15;
2412 l_revised_item_tbl(i).From_End_Item_Unit_Number :=
2413 ri.From_End_Item_Unit_Number;
2414 l_revised_item_tbl(i).New_From_End_Item_Unit_Number := NULL;
2415 l_revised_item_tbl(i).Original_System_Reference :=
2416 ri.Original_System_Reference;
2417 l_revised_item_tbl(i).transaction_type := 'CREATE';
2418 --11.5.10 chnages
2419 l_revised_item_tbl(i).Transfer_Or_Copy := ri.Transfer_Or_Copy;
2420 l_revised_item_tbl(i).Transfer_OR_Copy_Item := ri.Transfer_OR_Copy_Item ;
2421 l_revised_item_tbl(i).Transfer_OR_Copy_Bill := ri.Transfer_OR_Copy_Bill ;
2422 l_revised_item_tbl(i).Transfer_OR_Copy_Routing := ri.Transfer_OR_Copy_Routing;
2423 l_revised_item_tbl(i).Copy_To_Item := ri.Copy_To_Item;
2424 l_revised_item_tbl(i).Copy_To_Item_Desc := ri.Copy_To_Item_Desc;
2425
2426 --11.5.10 changes
2427
2428
2429
2430
2431
2432
2433 i := i + 1;
2434
2435 ELSE
2436
2437 FND_FILE.PUT_LINE(FND_FILE.LOG,'Invalid Use_Up_Item_id = '||
2438 ri.use_up_item_id||' for Org '||l_org_code);
2439
2440 END IF;
2441
2442 ELSE
2443
2444 FND_FILE.PUT_LINE(FND_FILE.LOG,'Invalid revised_item_id = '||
2445 ri.revised_item_id||' for Org '||l_org_code);
2446
2447 END IF;
2448
2449 END LOOP; /* End Loop 4 */
2450
2451 -- Fetch revised components for disable and implemented ECO
2452 i := 1;
2453 For rcd IN c_rev_comps_disable
2454 LOOP
2455
2456 FND_FILE.PUT_LINE(FND_FILE.LOG,'Processing Revised Components For Implemented Ecos having ACD type as Disable for Components...');
2457
2458 BEGIN
2459 l_item_exits_in_org_flag := 1;
2460 SELECT msi.concatenated_segments,eri.new_item_revision
2461 INTO l_revised_item_name,l_new_item_revision
2462 FROM mtl_system_items_b_kfv msi,
2463 eng_revised_items eri
2464 WHERE eri.revised_item_sequence_id = rcd.revised_item_sequence_id
2465 AND eri.revised_item_id = msi.inventory_item_id
2466 AND msi.organization_id = l_org_id;
2467
2468 EXCEPTION WHEN NO_DATA_FOUND THEN
2469 l_item_exits_in_org_flag := 0;
2470 l_check_invalid_objects := 0;
2471 END;
2472 IF (l_item_exits_in_org_flag = 1) THEN
2473
2474 BEGIN
2475 SELECT concatenated_segments
2476 INTO l_component_item_name
2477 FROM mtl_system_items_b_kfv
2478 WHERE inventory_item_id = rcd.component_item_id
2479 AND organization_id = l_org_id;
2480 EXCEPTION WHEN NO_DATA_FOUND THEN
2481 l_item_exits_in_org_flag := 0;
2482 l_check_invalid_objects := 0;
2483 END;
2484
2485 IF (l_item_exits_in_org_flag = 1) THEN
2486
2487 IF (rcd.supply_locator_id is NOT NULL) THEN
2488
2489 SELECT CONCATENATED_SEGMENTS
2490 INTO l_location_name
2491 FROM mtl_item_locations_kfv
2492 WHERE inventory_location_id = rcd.supply_locator_id;
2493 ELSE
2494 l_location_name := NULL;
2495 END IF;
2496 BEGIN
2497 St_Number := 10;
2498 select assembly_item_id
2499 into item_id
2500 from bom_bill_of_materials
2501 where bill_sequence_id = rcd.bill_sequence_id;
2502 /* for bug 9368374 */
2503 St_Number := 15;
2504 select alternate_bom_designator
2505 into l_alternate_bom
2506 from bom_bill_of_materials
2507 where bill_sequence_id = rcd.bill_sequence_id;
2508 /* for bug 9368374 */
2509 St_Number := 20;
2510 select bill_sequence_id
2511 into bill_id
2512 from bom_bill_of_materials
2513 where assembly_item_id = item_id
2514 and organization_id = l_org_id
2515 and NVL(alternate_bom_designator,'-999')= NVL(l_alternate_bom,'-999'); /* for bug 9368374 */
2516
2517 St_Number := 30;
2518 select operation_seq_num,trunc(effectivity_date)
2519 into old_operation_seq_num,l_old_effectivity_date
2520 from bom_inventory_components
2521 where COMPONENT_SEQUENCE_ID = rcd.OLD_COMPONENT_SEQUENCE_ID;
2522
2523 St_Number := 40;
2524 select max(component_sequence_id)
2525 into component_seq_id
2526 from bom_inventory_components
2527 where ((trunc(effectivity_date) = l_old_effectivity_date) OR
2528 (rcd.effectivity_date between
2529 trunc(effectivity_date) and
2530 NVL(disable_date, rcd.effectivity_date + 1)))
2531 -- Bug 3041105 : Commenting code to pick unimplemented components
2532 -- and implementation_date IS NOT NULL
2533 and component_item_id = rcd.COMPONENT_ITEM_ID
2534 and bill_sequence_id = bill_id
2535 and operation_seq_num = old_operation_seq_num;
2536
2537 St_Number := 50;
2538 select effectivity_date
2539 into old_effectivity_date
2540 from bom_inventory_components
2541 where component_sequence_id = component_seq_id;
2542
2543 EXCEPTION
2544 WHEN NO_DATA_FOUND THEN
2545 old_operation_seq_num := NULL;
2546 old_effectivity_date := NULL;
2547 FND_FILE.PUT_LINE(FND_FILE.LOG,'No_Data_found error in Disable After implementation for sql statement Number :' || to_char(St_Number));
2548 WHEN OTHERS THEN
2549 FND_FILE.PUT_LINE(FND_FILE.LOG,'Sql error in Disable after implementation statement number: '|| to_char(St_Number) || ':' || TO_CHAR(SQLCODE) || ' ' || SUBSTR(SQLERRM, 1, 100));
2550 END;
2551 l_rev_component_tbl(i).eco_name := rcd.change_notice;
2552 l_rev_component_tbl(i).organization_code:= l_org_code;
2553 l_rev_component_tbl(i).revised_item_name :=
2554 l_revised_item_name;
2555 l_rev_component_tbl(i).new_revised_item_revision :=
2556 l_new_item_revision;
2557 l_rev_component_tbl(i).start_effective_date :=
2558 rcd.effectivity_date;
2559 l_rev_component_tbl(i).new_effectivity_date := NULL;
2560 l_rev_component_tbl(i).COMMENTS := rcd.COMPONENT_REMARKS;
2561 l_rev_component_tbl(i).disable_date := rcd.disable_date;
2562 l_rev_component_tbl(i).operation_sequence_number :=
2563 rcd.operation_sequence_num;
2564 l_rev_component_tbl(i).component_item_name :=
2565 l_component_item_name;
2566 l_rev_component_tbl(i).alternate_bom_code := l_alternate_bom; /* for bug 9368374 */
2567 -- NULL;
2568 l_rev_component_tbl(i).acd_type := rcd.acd_type;
2569 l_rev_component_tbl(i).old_effectivity_date :=
2570 old_effectivity_date;
2571 l_rev_component_tbl(i).old_operation_sequence_number :=
2572 old_operation_seq_num;
2573 l_rev_component_tbl(i).new_operation_sequence_number :=
2574 NULL;
2575 l_rev_component_tbl(i).item_sequence_number := rcd.item_num;
2576 l_rev_component_tbl(i).quantity_per_assembly :=
2577 rcd.component_quantity;
2578 l_rev_component_tbl(i).planning_percent := rcd.planning_factor;
2579 l_rev_component_tbl(i).projected_yield :=
2580 rcd.component_yield_factor;
2581 l_rev_component_tbl(i).include_in_cost_rollup :=
2582 rcd.include_in_cost_rollup;
2583 l_rev_component_tbl(i).wip_supply_type :=
2584 rcd.wip_supply_type;
2585 l_rev_component_tbl(i).so_basis := rcd.so_basis;
2586 l_rev_component_tbl(i).basis_type := rcd.basis_type;
2587 l_rev_component_tbl(i).optional := rcd.optional;
2588 l_rev_component_tbl(i).mutually_exclusive :=
2589 rcd.mutually_exclusive_options;
2590 l_rev_component_tbl(i).check_atp := rcd.check_atp;
2591 l_rev_component_tbl(i).shipping_allowed :=
2592 rcd.shipping_allowed;
2593 l_rev_component_tbl(i).required_to_ship :=
2594 rcd.required_to_ship;
2595 l_rev_component_tbl(i).required_for_revenue :=
2596 rcd.required_for_revenue;
2597 l_rev_component_tbl(i).include_on_ship_docs :=
2598 rcd.include_on_ship_docs;
2599 l_rev_component_tbl(i).quantity_related :=
2600 rcd.quantity_related;
2601 l_rev_component_tbl(i).supply_subinventory :=
2602 rcd.supply_subinventory;
2603 l_rev_component_tbl(i).location_name := l_location_name;
2604 l_rev_component_tbl(i).minimum_allowed_quantity :=
2605 rcd.low_quantity;
2606 l_rev_component_tbl(i).maximum_allowed_quantity :=
2607 rcd.high_quantity;
2608 l_rev_component_tbl(i).attribute_category :=
2609 rcd.attribute_category;
2610 l_rev_component_tbl(i).attribute1 := rcd.attribute1;
2611 l_rev_component_tbl(i).attribute2 := rcd.attribute2;
2612 l_rev_component_tbl(i).attribute3 := rcd.attribute3;
2613 l_rev_component_tbl(i).attribute4 := rcd.attribute4;
2614 l_rev_component_tbl(i).attribute5 := rcd.attribute5;
2615 l_rev_component_tbl(i).attribute6 := rcd.attribute6;
2616 l_rev_component_tbl(i).attribute7 := rcd.attribute7;
2617 l_rev_component_tbl(i).attribute8 := rcd.attribute8;
2618 l_rev_component_tbl(i).attribute9 := rcd.attribute9;
2619 l_rev_component_tbl(i).attribute10 := rcd.attribute10;
2620 l_rev_component_tbl(i).attribute11 := rcd.attribute11;
2621 l_rev_component_tbl(i).attribute12 := rcd.attribute12;
2622 l_rev_component_tbl(i).attribute13 := rcd.attribute13;
2623 l_rev_component_tbl(i).attribute14 := rcd.attribute14;
2624 l_rev_component_tbl(i).attribute15 := rcd.attribute15;
2625 l_rev_component_tbl(i).from_end_item_unit_number :=
2626 rcd.from_end_item_unit_number;
2627 l_rev_component_tbl(i).to_end_item_unit_number :=
2628 rcd.to_end_item_unit_number;
2629 l_rev_component_tbl(i).original_system_reference :=
2630 rcd.original_system_reference;
2631 l_rev_component_tbl(i).new_from_end_item_unit_number := NULL;
2632 l_rev_component_tbl(i).old_from_end_item_unit_number := NULL;
2633 l_rev_component_tbl(i).return_status := NULL;
2634 l_rev_component_tbl(i).transaction_type := 'CREATE';
2635
2636 i := i + 1;
2637
2638 ELSE
2639
2640 FND_FILE.PUT_LINE(FND_FILE.LOG,'Invalid Component_Item_id = '|| rcd.component_item_id||' for Org '||l_org_code);
2641 END IF;
2642 ELSE
2643
2644 FND_FILE.PUT_LINE(FND_FILE.LOG,'Invalid revised_item_seq_id = '||rcd.revised_item_sequence_id||' for Org '||l_org_code);
2645 END IF;
2646 END LOOP;
2647
2648 -- Fetch revised components
2649
2650 FOR rc IN c_rev_comps
2651 LOOP /* Loop 5 */
2652
2653 FND_FILE.PUT_LINE(FND_FILE.LOG,'Processing Revised Components ...');
2654
2655 BEGIN
2656
2657 l_item_exits_in_org_flag := 1;
2658
2659
2660 SELECT msi.concatenated_segments,eri.new_item_revision
2661 INTO l_revised_item_name,l_new_item_revision
2662 FROM mtl_system_items_b_kfv msi,
2663 eng_revised_items eri
2664 WHERE eri.revised_item_sequence_id = rc.revised_item_sequence_id
2665 AND eri.revised_item_id = msi.inventory_item_id
2666 AND msi.organization_id = l_org_id;
2667
2668
2669 EXCEPTION WHEN NO_DATA_FOUND THEN
2670 l_item_exits_in_org_flag := 0;
2671 l_check_invalid_objects := 0;
2672 END;
2673
2674 IF (l_item_exits_in_org_flag = 1) THEN
2675
2676 BEGIN
2677
2678 /* SELECT concatenated_segments -- Commented for bug-5725081
2679 INTO l_component_item_name
2680 FROM mtl_system_items_b_kfv
2681 WHERE inventory_item_id = rc.component_item_id
2682 AND organization_id = l_org_id;
2683 */
2684
2685 -- Code added for bug number 5725081 starts here
2686
2687 v_component_quantity_to := 0 ;
2688 v_component_low_quantity := 0 ;
2689 v_component_high_quantity := 0 ;
2690
2691 SELECT msit.concatenated_segments,
2692 DECODE(msif.primary_unit_of_measure,
2693 msit.primary_unit_of_measure,
2694 rc.component_quantity,
2695 inv_convert.INV_UM_CONVERT(rc.component_item_id,
2696 NULL,
2697 rc.component_quantity,
2698 NULL,
2699 NULL,
2700 msif.primary_unit_of_measure,
2701 msit.primary_unit_of_measure
2702 )
2703 ),
2704 DECODE(msif.primary_unit_of_measure,
2705 msit.primary_unit_of_measure,
2706 rc.low_quantity,
2707 DECODE(rc.low_quantity, NULL, NULL,
2708 inv_convert.INV_UM_CONVERT(
2709 rc.component_item_id,
2710 NULL,
2711 rc.low_quantity,
2712 NULL,
2713 NULL,
2714 msif.primary_unit_of_measure,
2715 msit.primary_unit_of_measure
2716 )
2717 )
2718 ),
2719 DECODE(msif.primary_unit_of_measure,
2720 msit.primary_unit_of_measure,
2721 rc.high_quantity,
2722 DECODE(rc.high_quantity, NULL, NULL,
2723 inv_convert.INV_UM_CONVERT(
2724 rc.component_item_id,
2725 NULL,
2726 rc.high_quantity,
2727 NULL,
2728 NULL,
2729 msif.primary_unit_of_measure,
2730 msit.primary_unit_of_measure
2731 )
2732 )
2733 )
2734 INTO l_component_item_name,
2735 v_component_quantity_to,
2736 v_component_low_quantity,
2737 v_component_high_quantity
2738 FROM mtl_system_items_b_kfv MSIF ,
2739 mtl_system_items_b_kfv MSIT
2740 WHERE msif.inventory_item_id = msit.inventory_item_id
2741 AND msif.inventory_item_id = rc.component_item_id
2742 AND msit.organization_id = l_org_id
2743 AND msif.organization_id = l_org_hierarchy_level_id ;
2744
2745 -- Code added for bug 5725081 ends here
2746 EXCEPTION WHEN NO_DATA_FOUND THEN
2747 l_item_exits_in_org_flag := 0;
2748 l_check_invalid_objects := 0;
2749 END;
2750
2751 IF (l_item_exits_in_org_flag = 1) THEN
2752
2753 IF (rc.supply_locator_id is NOT NULL) THEN
2754
2755 SELECT CONCATENATED_SEGMENTS
2756 INTO l_location_name
2757 FROM mtl_item_locations_kfv
2758 WHERE inventory_location_id = rc.supply_locator_id;
2759 ELSE
2760 l_location_name := NULL;
2761 END IF;
2762 /* for bug 9368374 */
2763 BEGIN
2764 select alternate_bom_designator
2765 into l_alternate_bom
2766 from bom_bill_of_materials
2767 where bill_sequence_id = rc.bill_sequence_id;
2768
2769 EXCEPTION WHEN NO_DATA_FOUND THEN
2770 l_check_invalid_objects := 0;
2771 END;
2772 /* for bug 9368374 */
2773 IF (rc.acd_type in (2,3)) then
2774 BEGIN
2775 St_Number := 10;
2776 select assembly_item_id
2777 into item_id
2778 from bom_bill_of_materials
2779 where bill_sequence_id = rc.bill_sequence_id;
2780
2781 St_Number := 20;
2782 select bill_sequence_id
2783 into bill_id
2784 from bom_bill_of_materials
2785 where assembly_item_id = item_id
2786 and organization_id = l_org_id
2787 and NVL(alternate_bom_designator,'-999') = NVL(l_alternate_bom,'-999'); /* for bug 9368374 */
2788
2789 St_Number := 30;
2790 select operation_seq_num,trunc(effectivity_date)
2791 into old_operation_seq_num,l_old_effectivity_date
2792 from bom_inventory_components
2793 where COMPONENT_SEQUENCE_ID = rc.OLD_COMPONENT_SEQUENCE_ID;
2794
2795 St_Number := 40;
2796 select max(component_sequence_id)
2797 into component_seq_id
2798 from bom_inventory_components
2799 where ((trunc(effectivity_date) = l_old_effectivity_date) OR
2800 (rc.effectivity_date between
2801 trunc(effectivity_date) and
2802 NVL(disable_date, rc.effectivity_date + 1))
2803 )
2804 -- Bug 3041105 : Commenting code to pick unimplemented components
2805 -- and implementation_date IS NOT NULL
2806 and component_item_id = rc.COMPONENT_ITEM_ID
2807 and bill_sequence_id = bill_id
2808 and operation_seq_num = old_operation_seq_num;
2809
2810
2811 St_Number := 50;
2812 select effectivity_date
2813 into old_effectivity_date
2814 from bom_inventory_components
2815 where component_sequence_id = component_seq_id;
2816
2817 EXCEPTION
2818 WHEN NO_DATA_FOUND THEN
2819 old_operation_seq_num := NULL;
2820 old_effectivity_date := NULL;
2821 FND_FILE.PUT_LINE(FND_FILE.LOG,'No_Data_found error for sql statement Number :' || to_char(St_Number));
2822 WHEN OTHERS THEN
2823 FND_FILE.PUT_LINE(FND_FILE.LOG,'Sql error in statement number: '|| to_char(St_Number) || ':' || TO_CHAR(SQLCODE) || ' ' || SUBSTR(SQLERRM, 1, 100));
2824 END;
2825 ELSE
2826 old_operation_seq_num := NULL;
2827 old_effectivity_date := NULL;
2828 END IF;
2829
2830 l_rev_component_tbl(i).eco_name := rc.change_notice;
2831 l_rev_component_tbl(i).organization_code:= l_org_code;
2832 l_rev_component_tbl(i).revised_item_name :=
2833 l_revised_item_name;
2834 l_rev_component_tbl(i).new_revised_item_revision :=
2835 l_new_item_revision;
2836 l_rev_component_tbl(i).start_effective_date :=
2837 rc.effectivity_date;
2838 l_rev_component_tbl(i).new_effectivity_date := NULL;
2839 l_rev_component_tbl(i).COMMENTS := rc.COMPONENT_REMARKS;
2840 l_rev_component_tbl(i).disable_date := rc.disable_date;
2841 l_rev_component_tbl(i).operation_sequence_number :=
2842 rc.operation_seq_num;
2843 l_rev_component_tbl(i).component_item_name :=
2844 l_component_item_name;
2845 l_rev_component_tbl(i).alternate_bom_code := l_alternate_bom; /* for bug 9368374 */
2846 -- NULL;
2847 l_rev_component_tbl(i).acd_type := rc.acd_type;
2848 l_rev_component_tbl(i).old_effectivity_date :=
2849 old_effectivity_date;
2850 l_rev_component_tbl(i).old_operation_sequence_number :=
2851 old_operation_seq_num;
2852 l_rev_component_tbl(i).new_operation_sequence_number :=
2853 NULL;
2854 l_rev_component_tbl(i).item_sequence_number := rc.item_num;
2855 /* l_rev_component_tbl(i).quantity_per_assembly := -- Commented for bug 5725081
2856 rc.component_quantity;*/
2857 l_rev_component_tbl(i).quantity_per_assembly := -- Added for bug 5725081
2858 v_component_quantity_to;
2859
2860 l_rev_component_tbl(i).planning_percent := rc.planning_factor;
2861 l_rev_component_tbl(i).projected_yield :=
2862 rc.component_yield_factor;
2863 l_rev_component_tbl(i).include_in_cost_rollup :=
2864 rc.include_in_cost_rollup;
2865 l_rev_component_tbl(i).wip_supply_type :=
2866 rc.wip_supply_type;
2867 l_rev_component_tbl(i).so_basis := rc.so_basis;
2868 l_rev_component_tbl(i).basis_type := rc.basis_type;
2869 l_rev_component_tbl(i).optional := rc.optional;
2870 l_rev_component_tbl(i).mutually_exclusive :=
2871 rc.mutually_exclusive_options;
2872 l_rev_component_tbl(i).check_atp := rc.check_atp;
2873 l_rev_component_tbl(i).shipping_allowed :=
2874 rc.shipping_allowed;
2875 l_rev_component_tbl(i).required_to_ship :=
2876 rc.required_to_ship;
2877 l_rev_component_tbl(i).required_for_revenue :=
2878 rc.required_for_revenue;
2879 l_rev_component_tbl(i).include_on_ship_docs :=
2880 rc.include_on_ship_docs;
2881 l_rev_component_tbl(i).quantity_related :=
2882 rc.quantity_related;
2883 l_rev_component_tbl(i).supply_subinventory :=
2884 rc.supply_subinventory;
2885 l_rev_component_tbl(i).location_name := l_location_name;
2886 /* l_rev_component_tbl(i).minimum_allowed_quantity := -- Commented for bug 5725081
2887 rc.low_quantity;
2888 l_rev_component_tbl(i).maximum_allowed_quantity :=
2889 rc.high_quantity;*/
2890 l_rev_component_tbl(i).minimum_allowed_quantity := -- Added for bug-5725081
2891 v_component_low_quantity;
2892
2893 l_rev_component_tbl(i).maximum_allowed_quantity := -- Added for bug-5725081
2894 v_component_high_quantity;
2895
2896 l_rev_component_tbl(i).attribute_category :=
2897 rc.attribute_category;
2898 l_rev_component_tbl(i).attribute1 := rc.attribute1;
2899 l_rev_component_tbl(i).attribute2 := rc.attribute2;
2900 l_rev_component_tbl(i).attribute3 := rc.attribute3;
2901 l_rev_component_tbl(i).attribute4 := rc.attribute4;
2902 l_rev_component_tbl(i).attribute5 := rc.attribute5;
2903 l_rev_component_tbl(i).attribute6 := rc.attribute6;
2904 l_rev_component_tbl(i).attribute7 := rc.attribute7;
2905 l_rev_component_tbl(i).attribute8 := rc.attribute8;
2906 l_rev_component_tbl(i).attribute9 := rc.attribute9;
2907 l_rev_component_tbl(i).attribute10 := rc.attribute10;
2908 l_rev_component_tbl(i).attribute11 := rc.attribute11;
2909 l_rev_component_tbl(i).attribute12 := rc.attribute12;
2910 l_rev_component_tbl(i).attribute13 := rc.attribute13;
2911 l_rev_component_tbl(i).attribute14 := rc.attribute14;
2912 l_rev_component_tbl(i).attribute15 := rc.attribute15;
2913 l_rev_component_tbl(i).from_end_item_unit_number :=
2914 rc.from_end_item_unit_number;
2915 l_rev_component_tbl(i).to_end_item_unit_number :=
2916 rc.to_end_item_unit_number;
2917 l_rev_component_tbl(i).original_system_reference :=
2918 rc.original_system_reference;
2919 l_rev_component_tbl(i).new_from_end_item_unit_number := NULL;
2920 l_rev_component_tbl(i).old_from_end_item_unit_number := NULL;
2921 l_rev_component_tbl(i).return_status := NULL;
2922 l_rev_component_tbl(i).transaction_type := 'CREATE';
2923
2924 i := i + 1;
2925
2926 ELSE
2927
2928 FND_FILE.PUT_LINE(FND_FILE.LOG,'Invalid Component_Item_id = '|| rc.component_item_id||' for Org '||l_org_code);
2929
2930 END IF;
2931
2932 ELSE
2933
2934 FND_FILE.PUT_LINE(FND_FILE.LOG,'Invalid revised_item_seq_id = '||
2935 rc.revised_item_sequence_id||' for Org '||l_org_code);
2936 END IF;
2937
2938 END LOOP; /* End Loop 5 */
2939
2940 -- Fetch substitute component records
2941
2942 i := 1;
2943
2944 FOR sc IN c_sub_comps
2945 LOOP /* Loop 6 */
2946
2947 FND_FILE.PUT_LINE(FND_FILE.LOG,'Processing Substitute Components ...');
2948
2949 BEGIN
2950
2951 l_item_exits_in_org_flag := 1;
2952
2953 SELECT msi.concatenated_segments,eri.new_item_revision
2954 INTO l_revised_item_name1,l_new_item_revision
2955 FROM mtl_system_items_b_kfv msi,
2956 eng_revised_items eri,
2957 bom_inventory_components bic
2958 WHERE bic.component_sequence_id = sc.component_sequence_id
2959 AND eri.revised_item_sequence_id = bic.revised_item_sequence_id
2960 AND eri.revised_item_id = msi.inventory_item_id
2961 AND msi.organization_id = l_org_id;
2962 EXCEPTION WHEN NO_DATA_FOUND THEN
2963 l_item_exits_in_org_flag := 0;
2964 l_check_invalid_objects := 0;
2965 END;
2966
2967 IF (l_item_exits_in_org_flag = 1) THEN
2968
2969 BEGIN
2970 SELECT concatenated_segments,bic.effectivity_date,
2971 bic.operation_seq_num
2972 INTO l_component_item_name1,l_effectivity_date,
2973 l_operation_seq_num
2974 FROM mtl_system_items_b_kfv msi,
2975 bom_inventory_components bic
2976 WHERE bic.component_sequence_id = sc.component_sequence_id
2977 AND msi.inventory_item_id = bic.component_item_id
2978 AND msi.organization_id = l_org_id;
2979 EXCEPTION WHEN NO_DATA_FOUND THEN
2980 l_item_exits_in_org_flag := 0;
2981 l_check_invalid_objects := 0;
2982 END;
2983
2984 IF (l_item_exits_in_org_flag = 1) THEN
2985
2986 BEGIN
2987
2988 v_substitute_item_quantity := 0; -- Added for bug-5725081
2989
2990 /* SELECT concatenated_segments -- Commented for bug-5725081
2991 INTO l_substitute_component_name
2992 FROM mtl_system_items_b_kfv
2993 WHERE inventory_item_id = sc.substitute_component_id
2994 AND organization_id = l_org_id;
2995 */
2996
2997 SELECT msit.concatenated_segments, -- Added for bug-5725081
2998 DECODE(msif.primary_unit_of_measure,
2999 msit.primary_unit_of_measure,
3000 sc.substitute_item_quantity ,
3001 inv_convert.INV_UM_CONVERT(sc.substitute_component_id,
3002 NULL,
3003 sc.substitute_item_quantity,
3004 NULL,
3005 NULL,
3006 msif.primary_unit_of_measure,
3007 msit.primary_unit_of_measure)
3008 )
3009 INTO l_substitute_component_name,
3010 v_substitute_item_quantity
3011 FROM mtl_system_items_b_kfv MSIF,
3012 mtl_system_items_b_kfv MSIT
3013 WHERE msif.inventory_item_id = msit.inventory_item_id
3014 AND msif.inventory_item_id = sc.substitute_component_id
3015 AND msit.organization_id = l_org_id
3016 AND msif.organization_id = l_org_hierarchy_level_id;
3017
3018
3019 EXCEPTION WHEN NO_DATA_FOUND THEN
3020 l_item_exits_in_org_flag := 0;
3021 l_check_invalid_objects := 0;
3022 END;
3023 /* for bug 9368374 */
3024 BEGIN
3025 SELECT bom.alternate_bom_designator
3026 INTO l_alternate_bom
3027 FROM bom_inventory_components bic,
3028 bom_structures_b bom
3029 WHERE bic.component_sequence_id = sc.component_sequence_id
3030 AND bic.bill_sequence_id = bom.bill_sequence_id;
3031
3032 EXCEPTION WHEN NO_DATA_FOUND THEN
3033 l_check_invalid_objects := 0;
3034 END;
3035 /* for bug 9368374 */
3036 IF (l_item_exits_in_org_flag = 1) THEN
3037
3038 l_sub_component_tbl(i).eco_name := sc.change_notice;
3039 l_sub_component_tbl(i).organization_code:= l_org_code;
3040 l_sub_component_tbl(i).revised_item_name :=
3041 l_revised_item_name1;
3042 l_sub_component_tbl(i).start_effective_date :=
3043 l_effectivity_date;
3044 l_sub_component_tbl(i).new_revised_item_revision :=
3045 l_new_item_revision;
3046 l_sub_component_tbl(i).component_item_name :=
3047 l_component_item_name1;
3048 l_sub_component_tbl(i).alternate_bom_code := l_alternate_bom; /* for bug 9368374 */
3049 -- NULL;
3050 l_sub_component_tbl(i).substitute_component_name :=
3051 l_substitute_component_name;
3052 l_sub_component_tbl(i).acd_type := sc.acd_type;
3053 l_sub_component_tbl(i).operation_sequence_number :=
3054 l_operation_seq_num;
3055 /* l_sub_component_tbl(i).substitute_item_quantity :=
3056 sc.substitute_item_quantity;*/
3057 l_sub_component_tbl(i).substitute_item_quantity := -- Added for bug#5725081
3058 v_substitute_item_quantity;
3059 l_sub_component_tbl(i).attribute_category :=
3060 sc.attribute_category;
3061 l_sub_component_tbl(i).attribute1 := sc.attribute1;
3062 l_sub_component_tbl(i).attribute2 := sc.attribute2;
3063 l_sub_component_tbl(i).attribute3 := sc.attribute3;
3064 l_sub_component_tbl(i).attribute4 := sc.attribute4;
3065 l_sub_component_tbl(i).attribute5 := sc.attribute5;
3066 l_sub_component_tbl(i).attribute6 := sc.attribute6;
3067 l_sub_component_tbl(i).attribute7 := sc.attribute7;
3068 l_sub_component_tbl(i).attribute8 := sc.attribute8;
3069 l_sub_component_tbl(i).attribute9 := sc.attribute9;
3070 l_sub_component_tbl(i).attribute10 := sc.attribute10;
3071 l_sub_component_tbl(i).attribute11 := sc.attribute11;
3072 l_sub_component_tbl(i).attribute12 := sc.attribute12;
3073 l_sub_component_tbl(i).attribute13 := sc.attribute13;
3074 l_sub_component_tbl(i).attribute14 := sc.attribute14;
3075 l_sub_component_tbl(i).attribute15 := sc.attribute15;
3076 l_sub_component_tbl(i).from_end_item_unit_number := NULL;
3077 l_sub_component_tbl(i).Original_System_Reference :=
3078 sc.Original_System_Reference;
3079 l_sub_component_tbl(i).return_status := NULL;
3080 l_sub_component_tbl(i).transaction_type := 'CREATE';
3081
3082 i := i + 1;
3083
3084 ELSE
3085
3086 FND_FILE.PUT_LINE(FND_FILE.LOG,'Invalid Substitute_Component_Id = '|| sc.substitute_component_id||' for Org '||l_org_code);
3087
3088 END IF;
3089
3090 ELSE
3091
3092 FND_FILE.PUT_LINE(FND_FILE.LOG,'Invalid Component_seq_id = '|| sc.component_sequence_id||' for Org '||l_org_code);
3093
3094 END IF;
3095
3096 ELSE
3097
3098 FND_FILE.PUT_LINE(FND_FILE.LOG,'Invalid revised_item_id for Component_Seq_Id = '|| sc.component_sequence_id||' for Org '||l_org_code);
3099
3100 END IF;
3101
3102 END LOOP; /* End Loop 6 */
3103
3104 -- Fetch reference designators
3105
3106 i := 1;
3107
3108 FOR rd IN c_ref_desgs
3109 LOOP /* Loop 7 */
3110
3111 FND_FILE.PUT_LINE(FND_FILE.LOG,'Processing Reference Designators ...');
3112 BEGIN
3113
3114 l_item_exits_in_org_flag := 1;
3115
3116 SELECT msi.concatenated_segments,eri.new_item_revision,
3117 bic.effectivity_date,bic.operation_seq_num
3118 INTO l_revised_item_name2,l_new_item_revision,
3119 l_effectivity_date,l_operation_seq_num
3120 FROM mtl_system_items_b_kfv msi,
3121 eng_revised_items eri,
3122 bom_inventory_components bic
3123 WHERE bic.component_sequence_id = rd.component_sequence_id
3124 AND eri.revised_item_sequence_id = bic.revised_item_sequence_id
3125 AND eri.revised_item_id = msi.inventory_item_id
3126 AND msi.organization_id = l_org_id;
3127 EXCEPTION
3128 WHEN NO_DATA_FOUND THEN
3129 l_item_exits_in_org_flag := 0;
3130 l_check_invalid_objects := 0;
3131 END;
3132
3133 IF (l_item_exits_in_org_flag = 1) THEN
3134
3135 BEGIN
3136 SELECT concatenated_segments
3137 INTO l_component_item_name2
3138 FROM mtl_system_items_b_kfv msi,
3139 bom_inventory_components bic
3140 WHERE bic.component_sequence_id = rd.component_sequence_id
3141 AND msi.inventory_item_id = bic.component_item_id
3142 AND msi.organization_id = l_org_id;
3143 EXCEPTION
3144 WHEN NO_DATA_FOUND THEN
3145 l_item_exits_in_org_flag := 0;
3146 l_check_invalid_objects := 0;
3147 END;
3148 /* for bug 9368374 */
3149 BEGIN
3150 SELECT bom.alternate_bom_designator
3151 INTO l_alternate_bom
3152 FROM bom_inventory_components bic,
3153 bom_structures_b bom
3154 WHERE bic.component_sequence_id = rd.component_sequence_id
3155 AND bic.bill_sequence_id = bom.bill_sequence_id;
3156
3157 EXCEPTION WHEN NO_DATA_FOUND THEN
3158 l_check_invalid_objects := 0;
3159 END;
3160 /* for bug 9368374 */
3161 IF (l_item_exits_in_org_flag = 1) THEN
3162
3163 l_ref_designator_tbl(i).eco_name := rd.change_notice;
3164 l_ref_designator_tbl(i).organization_code := l_org_code;
3165 l_ref_designator_tbl(i).revised_item_name :=
3166 l_revised_item_name2;
3167 l_ref_designator_tbl(i).start_effective_date :=
3168 l_effectivity_date;
3169 l_ref_designator_tbl(i).new_revised_item_revision :=
3170 l_new_item_revision;
3171 l_ref_designator_tbl(i).operation_sequence_number :=
3172 l_operation_seq_num;
3173 l_ref_designator_tbl(i).component_item_name :=
3174 l_component_item_name2;
3175 l_ref_designator_tbl(i).alternate_bom_code := l_alternate_bom; /* for bug 9368374 */
3176 -- NULL;
3177 l_ref_designator_tbl(i).reference_designator_name :=
3178 rd.component_reference_designator;
3179 l_ref_designator_tbl(i).acd_type := rd.acd_type;
3180 l_ref_designator_tbl(i).ref_designator_comment :=
3181 rd.ref_designator_comment;
3182 l_ref_designator_tbl(i).attribute_category :=
3183 rd.attribute_category;
3184 l_ref_designator_tbl(i).attribute1 := rd.attribute1;
3185 l_ref_designator_tbl(i).attribute2 := rd.attribute2;
3186 l_ref_designator_tbl(i).attribute3 := rd.attribute3;
3187 l_ref_designator_tbl(i).attribute4 := rd.attribute4;
3188 l_ref_designator_tbl(i).attribute5 := rd.attribute5;
3189 l_ref_designator_tbl(i).attribute6 := rd.attribute6;
3190 l_ref_designator_tbl(i).attribute7 := rd.attribute7;
3191 l_ref_designator_tbl(i).attribute8 := rd.attribute8;
3192 l_ref_designator_tbl(i).attribute9 := rd.attribute9;
3193 l_ref_designator_tbl(i).attribute10 := rd.attribute10;
3194 l_ref_designator_tbl(i).attribute11 := rd.attribute11;
3195 l_ref_designator_tbl(i).attribute12 := rd.attribute12;
3196 l_ref_designator_tbl(i).attribute13 := rd.attribute13;
3197 l_ref_designator_tbl(i).attribute14 := rd.attribute14;
3198 l_ref_designator_tbl(i).attribute15 := rd.attribute15;
3199 l_ref_designator_tbl(i).Original_System_Reference :=
3200 rd.Original_System_Reference;
3201 l_ref_designator_tbl(i).new_reference_designator := NULL;
3202 l_ref_designator_tbl(i).from_end_item_unit_number := NULL;
3203 l_ref_designator_tbl(i).return_status := NULL;
3204 l_ref_designator_tbl(i).transaction_type := 'CREATE';
3205
3206 i:= i + 1;
3207
3208 ELSE
3209
3210 FND_FILE.PUT_LINE(FND_FILE.LOG,'Invalid Component_seq_id = '||rd.component_sequence_id||' for Org '||l_org_code);
3211
3212 END IF;
3213
3214 ELSE
3215
3216 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Invalid revised_item_id for Component_Seq_Id = '|| rd.component_sequence_id||' for Org '||l_org_code);
3217
3218 END IF;
3219 END LOOP; /* End Loop 7 */
3220
3221 IF l_check_invalid_objects = 1 THEN
3222 FND_FILE.PUT_LINE(FND_FILE.LOG,'');
3223
3224 Eng_Globals.G_WHO_REC.org_id := l_org_id;
3225 Eng_Globals.G_WHO_REC.user_id := FND_PROFILE.value('USER_ID');
3226 Eng_Globals.G_WHO_REC.login_id := FND_PROFILE.value('LOGIN_ID');
3227 Eng_Globals.G_WHO_REC.prog_appid := FND_PROFILE.value('RESP_APPL_ID');
3228 Eng_Globals.G_WHO_REC.prog_id := NULL;
3229 Eng_Globals.G_WHO_REC.req_id := NULL;
3230
3231 fnd_global.apps_initialize
3232 (user_id => Eng_Globals.G_WHO_REC.user_id,
3233 resp_id => FND_PROFILE.value('RESP_ID'),
3234 resp_appl_id => Eng_Globals.G_WHO_REC.prog_appid
3235 );
3236
3237 /* Initializing the Error Handler */
3238
3239 Error_Handler.Initialize;
3240
3241 FND_FILE.PUT_LINE(FND_FILE.LOG,'Calling ECO Business Objects');
3242 ENG_GLOBALS.G_ENG_LAUNCH_IMPORT := 2 ;--Indicates call is from propagation
3243 Eng_Eco_Pub.Process_Eco
3244 (
3245 p_api_version_number => 1.0
3246 ,p_init_msg_list => FALSE
3247 ,x_return_status => l_return_status
3248 ,x_msg_count => l_msg_count
3249 ,p_bo_identifier => 'ECO'
3250 ,p_ECO_rec => l_eco_rec
3251 ,p_eco_revision_tbl => l_eco_revision_tbl
3252 ,p_change_line_tbl => l_change_lines_tbl
3253 ,p_revised_item_tbl => l_revised_item_tbl
3254 ,p_rev_component_tbl => l_rev_component_tbl
3255 ,p_sub_component_tbl => l_sub_component_tbl
3256 ,p_ref_designator_tbl => l_ref_designator_tbl
3257 ,p_rev_operation_tbl => l_rev_operation_tbl
3258 ,p_rev_op_resource_tbl => l_rev_op_resource_tbl
3259 ,p_rev_sub_resource_tbl => l_rev_sub_resource_tbl
3260 ,x_ECO_rec => l_eco_rec
3261 ,x_eco_revision_tbl => l_eco_revision_tbl
3262 ,x_change_line_tbl => l_change_lines_tbl
3263 ,x_revised_item_tbl => l_revised_item_tbl
3264 ,x_rev_component_tbl => l_rev_component_tbl
3265 ,x_sub_component_tbl => l_sub_component_tbl
3266 ,x_ref_designator_tbl => l_ref_designator_tbl
3267 ,x_rev_operation_tbl => l_rev_operation_tbl
3268 ,x_rev_op_resource_tbl => l_rev_op_resource_tbl
3269 ,x_rev_sub_resource_tbl => l_rev_sub_resource_tbl
3270 ,p_debug => 'N'
3271 ,p_output_dir => '/sqlcom/log/dom1151'
3272 ,p_debug_filename => 'ECO_BO_debug.log'
3273 );
3274 ENG_GLOBALS.G_ENG_LAUNCH_IMPORT :=0; --resetting values
3275 FND_FILE.PUT_LINE(FND_FILE.LOG,'ECO Business Object Processing Done');
3276 FND_FILE.PUT_LINE(FND_FILE.LOG,'');
3277 --
3278 -- On return from the PUB API
3279 -- Perform all the error handler operations to verify that the
3280 -- error or warning are displayed and all the error table interface
3281 -- function provided to the user work corrently;
3282 --
3283
3284 /*if (l_return_status = 'S') THEN
3285 propagate_eco_lines
3286 (
3287 p_ECO_rec => l_eco_rec,
3288 p_source_org_id => l_org_hierarchy_level_id,
3289 p_dest_org_id => l_org_id,
3290 x_return_status => l_return_status
3291 );
3292 end if;*/
3293
3294 if (l_return_status = 'S') THEN
3295 /*bug #7496156 to Copy attached Document*/
3296 BEGIN
3297 SELECT change_id INTO l_new_change_id
3298 FROM eng_engineering_changes
3299 WHERE change_notice = p_change_notice
3300 AND organization_id = l_org_id;
3301 FND_File.put_line(FND_FILE.log, 'Copy ECO attachment Start for Org '||l_org_id );
3302 FND_File.put_line(FND_FILE.log, 'Copy ECO attachment Start for Org Code '||l_org_Code );
3303 FND_File.put_line(FND_FILE.log, 'Copy ECO attachment Start for Change_id '||l_new_change_id );
3304 fnd_attached_documents2_pkg.copy_attachments(
3305 X_from_entity_name => 'ENG_ENGINEERING_CHANGES',
3306 X_from_pk1_value => ECO_rec.change_id,
3307 X_from_pk2_value => '',
3308 X_from_pk3_value => '',
3309 X_from_pk4_value => '',
3310 X_from_pk5_value => '',
3311 X_to_entity_name => 'ENG_ENGINEERING_CHANGES',
3312 X_to_pk1_value => l_new_change_id,
3313 X_to_pk2_value => '',
3314 X_to_pk3_value => '',
3315 X_to_pk4_value => '',
3316 X_to_pk5_value => '',
3317 X_created_by => FND_GLOBAL.USER_ID,
3318 X_last_update_login => '',
3319 X_program_application_id=> '',
3320 X_program_id => '',
3321 X_request_id => ''
3322 );
3323 FND_File.put_line(FND_FILE.log, 'Copy ECO attachment done for Org Code '|| l_org_Code||' and Change Id '||l_new_change_id );
3324 EXCEPTION WHEN OTHERS THEN
3325 FND_File.put_line(FND_FILE.log, 'Could not Copy ECO attachment for Org Code '|| l_org_Code||' and Change Id '||l_new_change_id );
3326 END;
3327 /*End bug #7496156 to Copy attached Document*/
3328 COMMIT;
3329 else
3330 ROLLBACK;
3331 Error_Handler.Get_Message_List( x_message_list => l_error_table);
3332 i:=0;
3333 FOR i IN 1..l_error_table.COUNT
3334 LOOP
3335 FND_FILE.PUT_LINE(FND_FILE.LOG,'Entity Id: '||l_error_table(i).entity_id);
3336 FND_FILE.PUT_LINE(FND_FILE.LOG,'Index: '||l_error_table(i).entity_index);
3337 FND_FILE.PUT_LINE(FND_FILE.LOG,'Mesg: '||l_error_table(i).message_text);
3338 END LOOP;
3339
3340 end if;
3341
3342 ELSE
3343
3344 FND_FILE.PUT_LINE(FND_FILE.LOG,'This ECO '||p_change_notice|| ' cannot be processed as there are invalid Items as listed above . Please correct these Items and re-run the propagate ECO');
3345
3346 l_check_invalid_objects := 1;
3347
3348 END IF;
3349
3350 END LOOP; /* End Loop 2 */
3351
3352 END IF; /* ECO Chack */
3353 END IF; /*End of IF l_org_code IS NOT NULL Organization Check */ -- Bug 4546616
3354 END LOOP; /* End Loop 1 */
3355
3356 END PROPAGATE_ECO_ERP;
3357
3358 PROCEDURE Initialize_Business_Object (
3359 p_debug IN VARCHAR2
3360 , p_debug_filename IN VARCHAR2
3361 , p_output_dir IN VARCHAR2
3362 , p_bo_identifier IN VARCHAR2
3363 , p_organization_id IN NUMBER
3364 , x_return_status IN OUT NOCOPY VARCHAR2
3365 )
3366 IS
3367 l_Mesg_Token_Tbl Error_Handler.Mesg_Token_Tbl_Type;
3368 l_other_message VARCHAR2(50);
3369 l_Token_Tbl Error_Handler.Token_Tbl_Type;
3370 l_err_text VARCHAR2(2000);
3371 l_return_status VARCHAR2(1);
3372
3373 BEGIN
3374 IF p_debug = 'Y'
3375 THEN
3376 BOM_Globals.Set_Debug(p_debug);
3377 BOM_Rtg_Globals.Set_Debug(p_debug) ; -- Added by MK on 11/08/00
3378
3379 Error_Handler.Open_Debug_Session
3380 ( p_debug_filename => p_debug_filename
3381 , p_output_dir => p_output_dir
3382 , x_return_status => l_return_status
3383 , p_mesg_token_tbl => l_mesg_token_tbl
3384 , x_mesg_token_tbl => l_mesg_token_tbl
3385 );
3386
3387 IF l_return_status <> FND_API.G_RET_STS_SUCCESS
3388 THEN
3389 BOM_Globals.Set_Debug('N');
3390 BOM_Rtg_Globals.Set_Debug('N'); -- Added by MK on 11/08/00
3391 END IF;
3392 END IF;
3393 --
3394 -- Set Business Object Idenfier in the System Information record.
3395 --
3396 Eng_Globals.Set_Bo_Identifier(p_bo_identifier => p_bo_identifier);
3397 Eng_Globals.Set_Org_Id( p_org_id => p_organization_id);
3398 -- Load environment information into the SYSTEM_INFORMATION record
3399 -- (USER_ID, LOGIN_ID, PROG_APPID, PROG_ID)
3400
3401 l_return_status := FND_API.G_RET_STS_SUCCESS;
3402 ENG_GLOBALS.Init_System_Info_Rec(
3403 x_mesg_token_tbl => l_mesg_token_tbl
3404 , x_return_status => l_return_status
3405 );
3406
3407 -- Initialize System_Information Unit_Effectivity flag
3408 IF PJM_UNIT_EFF.Enabled = 'Y'
3409 THEN
3410 BOM_Globals.Set_Unit_Effectivity (TRUE);
3411 ENG_Globals.Set_Unit_Effectivity (TRUE);
3412 ELSE
3413 BOM_Globals.Set_Unit_Effectivity (FALSE);
3414 ENG_Globals.Set_Unit_Effectivity (FALSE);
3415 END IF;
3416 x_return_status := l_return_status;
3417 IF l_return_status <> FND_API.G_RET_STS_SUCCESS
3418 THEN
3419 RAISE EXC_ERR_PVT_API_MAIN;
3420 END IF;
3421 END Initialize_Business_Object;
3422
3423 PROCEDURE Reset_Business_Object IS
3424 BEGIN
3425 -- Reset system_information business object flags
3426 ENG_GLOBALS.Set_ECO_Impl( p_eco_impl => NULL);
3427 ENG_GLOBALS.Set_ECO_Cancl( p_eco_cancl => NULL);
3428 ENG_GLOBALS.Set_Wkfl_Process( p_wkfl_process=> NULL);
3429 ENG_GLOBALS.Set_ECO_Access( p_eco_access => NULL);
3430 ENG_GLOBALS.Set_STD_Item_Access( p_std_item_access => NULL);
3431 ENG_GLOBALS.Set_MDL_Item_Access( p_mdl_item_access => NULL);
3432 ENG_GLOBALS.Set_PLN_Item_Access( p_pln_item_access => NULL);
3433 ENG_GLOBALS.Set_OC_Item_Access( p_oc_item_access => NULL);
3434 Eng_Globals.Set_Org_Id( p_org_id => NULL);
3435 Eng_Globals.Set_Eco_Name( p_eco_name => NULL);
3436 END Reset_Business_Object;
3437
3438 PROCEDURE Propagate_Revised_Component (
3439 p_component_sequence_id IN NUMBER
3440 , p_revised_item_sequence_id IN NUMBER
3441 , p_change_id IN NUMBER
3442 , p_revised_item_rec IN Eng_Eco_Pub.Revised_Item_Rec_Type
3443 , p_revised_item_unexp_rec IN Eng_Eco_Pub.Rev_Item_Unexposed_Rec_Type
3444 , p_local_organization_id IN NUMBER
3445 , x_Return_Status OUT NOCOPY VARCHAR2
3446 ) IS
3447
3448 l_rev_component_count NUMBER := 1;
3449 l_sub_component_count NUMBER := 1;
3450 l_ref_designator_count NUMBER := 1;
3451
3452 l_component_item_name mtl_system_items_vl.concatenated_segments%type;
3453 l_location_name mtl_item_locations_kfv.concatenated_segments%type;
3454 l_substitute_component_name mtl_system_items_vl.concatenated_segments%type;
3455 l_revised_item_name mtl_system_items_vl.concatenated_segments%type;
3456 l_new_item_revision VARCHAR2(3);
3457 l_effectivity_date DATE;
3458 st_number NUMBER;
3459 item_id NUMBER;
3460 bill_id NUMBER;
3461 old_operation_seq_num NUMBER;
3462 old_effectivity_date DATE;
3463 l_old_effectivity_date DATE;
3464 component_seq_id NUMBER;
3465 l_item_exits_in_org_flag NUMBER;
3466 l_has_invalid_objects NUMBER := G_VAL_FALSE;
3467 l_entity_action_status NUMBER;
3468 l_comp_exists_in_org NUMBER;
3469
3470 L_MSG_COUNT NUMBER;
3471 l_Mesg_token_Tbl Error_Handler.Mesg_Token_Tbl_Type;
3472 l_bo_Mesg_Token_Tbl Error_Handler.Mesg_Token_Tbl_Type;
3473 l_return_status VARCHAR2(1);
3474 l_Token_Tbl Error_Handler.Token_Tbl_Type;
3475 l_item_error_table INV_ITEM_GRP.Error_Tbl_Type;
3476 l_message_log_text VARCHAR2(4000);
3477 l_temp_mesg VARCHAR2(4000);
3478
3479 l_rev_component_tbl Bom_Bo_Pub.Rev_Component_Tbl_Type;
3480 l_sub_component_tbl Bom_Bo_Pub.Sub_Component_Tbl_Type;
3481 l_ref_designator_tbl Bom_Bo_Pub.Ref_Designator_Tbl_Type;
3482 l_rev_comp_unexp_rec BOM_BO_PUB.Rev_Comp_Unexposed_Rec_Type;
3483
3484 CURSOR c_component_details IS
3485 SELECT component_item_id, supply_locator_id, bill_sequence_id, old_component_sequence_id
3486 , effectivity_date , attribute_category, ACD_TYPE, change_notice, disable_date
3487 , component_remarks, operation_seq_num, attribute1, attribute2, attribute3
3488 , attribute4, attribute5, attribute6, attribute7, attribute8, attribute9, attribute10
3489 , attribute11, attribute12, attribute13, attribute14, attribute15, item_num
3490 , component_quantity, planning_factor, component_yield_factor, include_in_cost_rollup
3491 , wip_supply_type, so_basis, basis_type, optional, mutually_exclusive_options
3492 , check_atp, shipping_allowed, required_to_ship, required_for_revenue, include_on_ship_docs
3493 , quantity_related, supply_subinventory, low_quantity, high_quantity, from_end_item_unit_number
3494 , TO_END_ITEM_UNIT_NUMBER, ORIGINAL_SYSTEM_REFERENCE
3495 FROM bom_components_b
3496 WHERE component_sequence_id = p_component_sequence_id
3497 UNION ALL
3498 SELECT component_item_id, supply_locator_id, bill_sequence_id, old_component_sequence_id
3499 , effectivity_date , attribute_category, ACD_TYPE, change_notice, disable_date
3500 , component_remarks, OPERATION_SEQUENCE_NUM, attribute1, attribute2, attribute3
3501 , attribute4, attribute5, attribute6, attribute7, attribute8, attribute9, attribute10
3502 , attribute11, attribute12, attribute13, attribute14, attribute15, item_num
3503 , component_quantity, planning_factor, component_yield_factor, include_in_cost_rollup
3504 , wip_supply_type, so_basis, basis_type, optional, mutually_exclusive_options
3505 , check_atp, shipping_allowed, required_to_ship, required_for_revenue, include_on_ship_docs
3506 , quantity_related, supply_subinventory, low_quantity, high_quantity, from_end_item_unit_number
3507 , TO_END_ITEM_UNIT_NUMBER, ORIGINAL_SYSTEM_REFERENCE FROM eng_revised_components
3508 WHERE component_sequence_id = p_component_sequence_id
3509 AND acd_type = 3;
3510
3511 -- Cursor to Pick all substitute Component Items for the Top Organization for
3512 -- the given Change Notice
3513 CURSOR c_plm_sub_comps IS
3514 SELECT *
3515 FROM bom_substitute_components
3516 WHERE change_notice = p_revised_item_rec.eco_name
3517 AND component_sequence_id = p_component_sequence_id;
3518
3519 -- Cursor to Pick all reference designators for the Top Organization for the
3520 -- given Change Notice
3521
3522 CURSOR c_plm_ref_desgs IS
3523 SELECT *
3524 FROM bom_reference_designators
3525 WHERE change_notice = p_revised_item_rec.eco_name
3526 AND component_sequence_id = p_component_sequence_id;
3527
3528 CURSOR c_get_item_details(cp_inventory_item_id NUMBER, cp_organization_id NUMBER) IS
3529 SELECT concatenated_segments
3530 FROM mtl_system_items_kfv
3531 WHERE inventory_item_id = cp_inventory_item_id
3532 AND organization_id = cp_organization_id;
3533 BEGIN
3534 -- Initialize this API for error handling
3535 Eng_Propagation_Log_Util.Debug_Log(G_LOG_PROC, 'Propagate_Revised_Component.BEGIN');
3536 Error_Handler.Initialize;
3537
3538 l_entity_action_status := Eng_Propagation_Log_Util.G_PRP_PRC_STS_SUCCESS;
3539 l_return_status := FND_API.G_RET_STS_SUCCESS;
3540 -- Strat processing for each component
3541 FOR rc in c_component_details
3542 LOOP
3543
3544 l_revised_item_name := p_revised_item_rec.revised_item_name;
3545 l_new_item_revision := p_revised_item_rec.New_Revised_Item_Revision;
3546
3547 -- Check if the component exists in the local organization
3548 l_comp_exists_in_org := G_VAL_TRUE;
3549 OPEN c_get_item_details(rc.component_item_id, p_local_organization_id);
3550 FETCH c_get_item_details INTO l_component_item_name;
3551 IF c_get_item_details%NOTFOUND
3552 THEN
3553 l_comp_exists_in_org := G_VAL_FALSE;
3554 END IF;
3555 CLOSE c_get_item_details;
3556
3557
3558 -- If component ACD type is ADD
3559 -- then it has to be auto enabled in the child organization
3560 -- Proceed to auto enable component
3561 IF rc.acd_type = 1 AND l_comp_exists_in_org = G_VAL_FALSE
3562 THEN
3563 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Component Item Is being auto enabled. rc.component_item_id:'|| rc.component_item_id);
3564 Auto_enable_item_in_org(
3565 p_inventory_item_id => rc.component_item_id
3566 , p_organization_id => p_local_organization_id
3567 , x_error_table => l_item_error_table
3568 , x_return_status => l_return_status);
3569 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'After Component Item Is auto enabled. l_return_status'||l_return_status);
3570 IF (l_return_status = FND_API.G_RET_STS_SUCCESS)
3571 THEN
3572 OPEN c_get_item_details(rc.component_item_id, p_local_organization_id);
3573 FETCH c_get_item_details INTO l_component_item_name;
3574 IF c_get_item_details%NOTFOUND
3575 THEN
3576 l_comp_exists_in_org := G_VAL_FALSE;
3577 ELSE
3578 l_comp_exists_in_org := G_VAL_TRUE;
3579 Fnd_message.set_name('ENG', 'ENG_PRP_COMP_NOT_ENABLED');
3580 fnd_message.set_token('ITEM', l_component_item_name);
3581 fnd_message.set_token('STRUCTURE', p_revised_item_rec.Alternate_Bom_Code);
3582 l_message_log_text := fnd_message.get();
3583 fnd_message.set_name('ENG', 'ENG_PRP_COMP_ENABLED');
3584 l_temp_mesg := fnd_message.get();
3585 Error_Handler.Add_Error_Token(
3586 p_Message_Name => NULL
3587 , p_Message_Text => l_message_log_text || l_temp_mesg
3588 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3589 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3590 , p_message_type => 'I'
3591 );
3592 END IF;
3593 CLOSE c_get_item_details;
3594 ELSE
3595 FOR i IN 1..l_item_error_table.COUNT
3596 LOOP
3597 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Component Item Enabling Error:'||l_item_error_table(i).message_name);
3598 Error_Handler.Add_Error_Token(
3599 p_Message_Name => NULL
3600 , p_Message_Text => l_item_error_table(i).message_text
3601 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3602 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3603 );
3604 END LOOP;
3605
3606 END IF;
3607 END IF;
3608
3609 IF l_comp_exists_in_org = G_VAL_FALSE
3610 THEN
3611 OPEN c_get_item_details(rc.component_item_id, p_revised_item_unexp_rec.organization_id);
3612 FETCH c_get_item_details INTO l_component_item_name;
3613 CLOSE c_get_item_details;
3614
3615 l_token_tbl.delete;
3616 l_token_tbl(1).token_name := 'ITEM';
3617 l_token_tbl(1).token_value := l_component_item_name;
3618 l_token_tbl(1).token_name := 'STRUCTURE';
3619 l_token_tbl(1).token_value := p_revised_item_rec.Alternate_Bom_Code;
3620
3621 Error_Handler.Add_Error_Token(
3622 p_Message_Name => 'ENG_PRP_COMP_NOT_EXIST'
3623 , p_Mesg_Token_Tbl => l_mesg_token_tbl
3624 , x_Mesg_Token_Tbl => l_mesg_token_tbl
3625 , p_Token_Tbl => l_token_tbl
3626 );
3627 RAISE EXC_EXP_SKIP_OBJECT;
3628 END IF;
3629
3630 IF (rc.supply_locator_id is NOT NULL)
3631 THEN
3632 SELECT CONCATENATED_SEGMENTS
3633 INTO l_location_name
3634 FROM mtl_item_locations_kfv
3635 WHERE inventory_location_id = rc.supply_locator_id;
3636 ELSE
3637 l_location_name := NULL;
3638 END IF;
3639
3640 IF (rc.acd_type in (2,3))
3641 THEN
3642 BEGIN
3643 St_Number := 10;
3644 select assembly_item_id
3645 into item_id
3646 from bom_bill_of_materials
3647 where bill_sequence_id = rc.bill_sequence_id;
3648
3649 St_Number := 20;
3650 select bill_sequence_id
3651 into bill_id
3652 from bom_bill_of_materials
3653 where assembly_item_id = item_id
3654 and organization_id = p_local_organization_id
3655 and nvl(ALTERNATE_BOM_DESIGNATOR, 'primary') = nvl(p_revised_item_rec.alternate_bom_code,'primary');
3656
3657 St_Number := 30;
3658 select operation_seq_num,trunc(effectivity_date)
3659 into old_operation_seq_num,l_old_effectivity_date
3660 from bom_inventory_components
3661 where COMPONENT_SEQUENCE_ID = rc.OLD_COMPONENT_SEQUENCE_ID;
3662
3663 St_Number := 40;
3664 select max(component_sequence_id)
3665 into component_seq_id
3666 from bom_inventory_components
3667 where ((trunc(effectivity_date) = l_old_effectivity_date) OR
3668 (rc.effectivity_date between
3669 trunc(effectivity_date) and
3670 NVL(disable_date, rc.effectivity_date + 1))
3671 )
3672 -- Bug 3041105 : Commenting code to pick unimplemented components
3673 -- and implementation_date IS NOT NULL
3674 and component_item_id = rc.COMPONENT_ITEM_ID
3675 and bill_sequence_id = bill_id
3676 and operation_seq_num = old_operation_seq_num;
3677
3678 St_Number := 50;
3679 select effectivity_date
3680 into old_effectivity_date
3681 from bom_inventory_components
3682 where component_sequence_id = component_seq_id;
3683
3684 EXCEPTION
3685 WHEN NO_DATA_FOUND THEN
3686 old_operation_seq_num := NULL;
3687 old_effectivity_date := NULL;
3688 WHEN OTHERS THEN
3689 null;
3690 END;
3691 ELSE
3692 old_operation_seq_num := NULL;
3693 old_effectivity_date := NULL;
3694 END IF;
3695
3696 /* Populate the revised components table for this revised item */
3697
3698 l_rev_component_tbl(l_rev_component_count).eco_name := rc.change_notice;
3699 l_rev_component_tbl(l_rev_component_count).organization_code:= p_revised_item_rec.organization_code;
3700 l_rev_component_tbl(l_rev_component_count).revised_item_name := l_revised_item_name;
3701 l_rev_component_tbl(l_rev_component_count).new_revised_item_revision := l_new_item_revision;
3702 l_rev_component_tbl(l_rev_component_count).start_effective_date := rc.effectivity_date;
3703 l_rev_component_tbl(l_rev_component_count).new_effectivity_date := NULL;
3704 l_rev_component_tbl(l_rev_component_count).COMMENTS := rc.COMPONENT_REMARKS;
3705 l_rev_component_tbl(l_rev_component_count).disable_date := rc.disable_date;
3706 l_rev_component_tbl(l_rev_component_count).operation_sequence_number := rc.operation_seq_num;
3707 l_rev_component_tbl(l_rev_component_count).component_item_name := l_component_item_name;
3708 l_rev_component_tbl(l_rev_component_count).alternate_bom_code := p_revised_item_rec.alternate_bom_code;
3709 l_rev_component_tbl(l_rev_component_count).acd_type := rc.acd_type;
3710 l_rev_component_tbl(l_rev_component_count).old_effectivity_date := old_effectivity_date;
3711 l_rev_component_tbl(l_rev_component_count).old_operation_sequence_number := old_operation_seq_num;
3712 l_rev_component_tbl(l_rev_component_count).new_operation_sequence_number := NULL;
3713 l_rev_component_tbl(l_rev_component_count).item_sequence_number := rc.item_num;
3714 l_rev_component_tbl(l_rev_component_count).quantity_per_assembly := rc.component_quantity;
3715 l_rev_component_tbl(l_rev_component_count).planning_percent := rc.planning_factor;
3716 l_rev_component_tbl(l_rev_component_count).projected_yield := rc.component_yield_factor;
3717 l_rev_component_tbl(l_rev_component_count).include_in_cost_rollup := rc.include_in_cost_rollup;
3718 l_rev_component_tbl(l_rev_component_count).wip_supply_type := rc.wip_supply_type;
3719 l_rev_component_tbl(l_rev_component_count).so_basis := rc.so_basis;
3720 l_rev_component_tbl(l_rev_component_count).basis_type := rc.basis_type;
3721 l_rev_component_tbl(l_rev_component_count).optional := rc.optional;
3722 l_rev_component_tbl(l_rev_component_count).mutually_exclusive := rc.mutually_exclusive_options;
3723 l_rev_component_tbl(l_rev_component_count).check_atp := rc.check_atp;
3724 l_rev_component_tbl(l_rev_component_count).shipping_allowed := rc.shipping_allowed;
3725 l_rev_component_tbl(l_rev_component_count).required_to_ship := rc.required_to_ship;
3726 l_rev_component_tbl(l_rev_component_count).required_for_revenue := rc.required_for_revenue;
3727 l_rev_component_tbl(l_rev_component_count).include_on_ship_docs := rc.include_on_ship_docs;
3728 l_rev_component_tbl(l_rev_component_count).quantity_related := rc.quantity_related;
3729 l_rev_component_tbl(l_rev_component_count).supply_subinventory := rc.supply_subinventory;
3730 l_rev_component_tbl(l_rev_component_count).location_name := l_location_name;
3731 l_rev_component_tbl(l_rev_component_count).minimum_allowed_quantity := rc.low_quantity;
3732 l_rev_component_tbl(l_rev_component_count).maximum_allowed_quantity := rc.high_quantity;
3733 l_rev_component_tbl(l_rev_component_count).attribute_category := rc.attribute_category;
3734 l_rev_component_tbl(l_rev_component_count).attribute1 := rc.attribute1;
3735 l_rev_component_tbl(l_rev_component_count).attribute2 := rc.attribute2;
3736 l_rev_component_tbl(l_rev_component_count).attribute3 := rc.attribute3;
3737 l_rev_component_tbl(l_rev_component_count).attribute4 := rc.attribute4;
3738 l_rev_component_tbl(l_rev_component_count).attribute5 := rc.attribute5;
3739 l_rev_component_tbl(l_rev_component_count).attribute6 := rc.attribute6;
3740 l_rev_component_tbl(l_rev_component_count).attribute7 := rc.attribute7;
3741 l_rev_component_tbl(l_rev_component_count).attribute8 := rc.attribute8;
3742 l_rev_component_tbl(l_rev_component_count).attribute9 := rc.attribute9;
3743 l_rev_component_tbl(l_rev_component_count).attribute10 := rc.attribute10;
3744 l_rev_component_tbl(l_rev_component_count).attribute11 := rc.attribute11;
3745 l_rev_component_tbl(l_rev_component_count).attribute12 := rc.attribute12;
3746 l_rev_component_tbl(l_rev_component_count).attribute13 := rc.attribute13;
3747 l_rev_component_tbl(l_rev_component_count).attribute14 := rc.attribute14;
3748 l_rev_component_tbl(l_rev_component_count).attribute15 := rc.attribute15;
3749 l_rev_component_tbl(l_rev_component_count).from_end_item_unit_number := rc.from_end_item_unit_number;
3750 l_rev_component_tbl(l_rev_component_count).to_end_item_unit_number := rc.to_end_item_unit_number;
3751 l_rev_component_tbl(l_rev_component_count).original_system_reference := rc.original_system_reference;
3752 l_rev_component_tbl(l_rev_component_count).new_from_end_item_unit_number := NULL;
3753 l_rev_component_tbl(l_rev_component_count).old_from_end_item_unit_number := NULL;
3754 l_rev_component_tbl(l_rev_component_count).return_status := NULL;
3755 l_rev_component_tbl(l_rev_component_count).transaction_type := 'CREATE';
3756
3757 l_rev_component_count := l_rev_component_count + 1;
3758
3759 /* Fetch all revised substitute component items of this structure of this component */
3760
3761 FOR sc IN c_plm_sub_comps
3762 LOOP /* Loop 6 */
3763
3764 --FND_FILE.PUT_LINE(FND_FILE.LOG,'Processing Substitute Components ...');
3765 l_item_exits_in_org_flag := G_VAL_TRUE;
3766 OPEN c_get_item_details(sc.substitute_component_id, p_local_organization_id);
3767 FETCH c_get_item_details INTO l_substitute_component_name;
3768 IF c_get_item_details%NOTFOUND
3769 THEN
3770 l_item_exits_in_org_flag := G_VAL_FALSE;
3771 END IF;
3772 CLOSE c_get_item_details;
3773
3774 IF sc.acd_type = 1 AND l_item_exits_in_org_flag = G_VAL_FALSE
3775 THEN
3776 l_item_error_table.delete;
3777
3778 Auto_enable_item_in_org(
3779 p_inventory_item_id => sc.substitute_component_id
3780 , p_organization_id => p_local_organization_id
3781 , x_error_table => l_item_error_table
3782 , x_return_status => l_return_status);
3783
3784 IF (l_return_status = 'S')
3785 THEN
3786 OPEN c_get_item_details(sc.substitute_component_id, p_local_organization_id);
3787 FETCH c_get_item_details INTO l_substitute_component_name;
3788 IF c_get_item_details%NOTFOUND
3789 THEN
3790 l_item_exits_in_org_flag := G_VAL_FALSE;
3791 ELSE
3792 l_item_exits_in_org_flag := G_VAL_TRUE;
3793
3794 Fnd_message.set_name('ENG', 'ENG_PRP_SUBS_NOT_ENABLED');
3795 fnd_message.set_token('ITEM1', l_substitute_component_name);
3796 fnd_message.set_token('ITEM2', l_component_item_name);
3797 fnd_message.set_token('STRUCTURE', p_revised_item_rec.Alternate_Bom_Code);
3798 l_message_log_text := fnd_message.get();
3799 fnd_message.set_name('ENG', 'ENG_PRP_COMP_ENABLED');
3800 l_temp_mesg := fnd_message.get();
3801 Error_Handler.Add_Error_Token(
3802 p_Message_Name => NULL
3803 , p_Message_Text => l_message_log_text || l_temp_mesg
3804 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3805 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3806 );
3807 END IF;
3808 CLOSE c_get_item_details;
3809 ELSE
3810 FOR i IN 1..l_item_error_table.COUNT
3811 LOOP
3812 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Component Item Enabling Error:'||l_item_error_table(i).message_name);
3813 Error_Handler.Add_Error_Token(
3814 p_Message_Name => NULL
3815 , p_Message_Text => l_item_error_table(i).message_text
3816 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3817 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3818 );
3819 END LOOP;
3820 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Component Enabling Failed ..');
3821 l_item_error_table.delete;
3822 END IF;
3823 END IF;
3824 IF l_item_exits_in_org_flag = G_VAL_FALSE
3825 THEN
3826 l_has_invalid_objects := G_VAL_TRUE;
3827 OPEN c_get_item_details(sc.substitute_component_id, p_revised_item_unexp_rec.organization_id);
3828 FETCH c_get_item_details INTO l_substitute_component_name;
3829 CLOSE c_get_item_details;
3830
3831 l_token_tbl.delete;
3832 l_token_tbl(1).token_name := 'ITEM1';
3833 l_token_tbl(1).token_value := l_substitute_component_name;
3834 l_token_tbl(1).token_name := 'ITEM2';
3835 l_token_tbl(1).token_value := l_component_item_name;
3836 l_token_tbl(3).token_name := 'STRUCTURE';
3837 l_token_tbl(3).token_value := p_revised_item_rec.alternate_bom_code;
3838
3839 Error_Handler.Add_Error_Token(
3840 p_Message_Name => 'ENG_PRP_SUBS_NOT_EXIST'
3841 , p_Mesg_Token_Tbl => l_mesg_token_tbl
3842 , x_Mesg_Token_Tbl => l_mesg_token_tbl
3843 , p_Token_Tbl => l_token_tbl
3844 );
3845 ELSE
3846 l_sub_component_tbl(l_sub_component_count).eco_name := sc.change_notice;
3847 l_sub_component_tbl(l_sub_component_count).organization_code:= p_revised_item_rec.organization_code;
3848 l_sub_component_tbl(l_sub_component_count).revised_item_name := l_revised_item_name;
3849 l_sub_component_tbl(l_sub_component_count).start_effective_date := rc.effectivity_date;
3850 l_sub_component_tbl(l_sub_component_count).new_revised_item_revision := l_new_item_revision;
3851 l_sub_component_tbl(l_sub_component_count).component_item_name := l_component_item_name;
3852 l_sub_component_tbl(l_sub_component_count).alternate_bom_code := p_revised_item_rec.alternate_bom_code;
3853 l_sub_component_tbl(l_sub_component_count).substitute_component_name := l_substitute_component_name;
3854 l_sub_component_tbl(l_sub_component_count).acd_type := sc.acd_type;
3855 l_sub_component_tbl(l_sub_component_count).operation_sequence_number := rc.operation_seq_num;
3856 l_sub_component_tbl(l_sub_component_count).substitute_item_quantity := sc.substitute_item_quantity;
3857 l_sub_component_tbl(l_sub_component_count).attribute_category := sc.attribute_category;
3858 l_sub_component_tbl(l_sub_component_count).attribute1 := sc.attribute1;
3859 l_sub_component_tbl(l_sub_component_count).attribute2 := sc.attribute2;
3860 l_sub_component_tbl(l_sub_component_count).attribute3 := sc.attribute3;
3861 l_sub_component_tbl(l_sub_component_count).attribute4 := sc.attribute4;
3862 l_sub_component_tbl(l_sub_component_count).attribute5 := sc.attribute5;
3863 l_sub_component_tbl(l_sub_component_count).attribute6 := sc.attribute6;
3864 l_sub_component_tbl(l_sub_component_count).attribute7 := sc.attribute7;
3865 l_sub_component_tbl(l_sub_component_count).attribute8 := sc.attribute8;
3866 l_sub_component_tbl(l_sub_component_count).attribute9 := sc.attribute9;
3867 l_sub_component_tbl(l_sub_component_count).attribute10 := sc.attribute10;
3868 l_sub_component_tbl(l_sub_component_count).attribute11 := sc.attribute11;
3869 l_sub_component_tbl(l_sub_component_count).attribute12 := sc.attribute12;
3870 l_sub_component_tbl(l_sub_component_count).attribute13 := sc.attribute13;
3871 l_sub_component_tbl(l_sub_component_count).attribute14 := sc.attribute14;
3872 l_sub_component_tbl(l_sub_component_count).attribute15 := sc.attribute15;
3873 l_sub_component_tbl(l_sub_component_count).from_end_item_unit_number := rc.from_end_item_unit_number;
3874 l_sub_component_tbl(l_sub_component_count).Original_System_Reference := sc.Original_System_Reference;
3875 l_sub_component_tbl(l_sub_component_count).return_status := NULL;
3876 l_sub_component_tbl(l_sub_component_count).transaction_type := 'CREATE';
3877
3878 l_sub_component_count := l_sub_component_count + 1;
3879 END IF;
3880 END LOOP; /* End Loop 6 */
3881 IF (l_has_invalid_objects = G_VAL_TRUE)
3882 THEN
3883 RAISE EXC_EXP_SKIP_OBJECT;
3884 END IF;
3885 /* Fetch all revised reference designators on this structure of this revised item */
3886 FOR rd IN c_plm_ref_desgs
3887 LOOP /* Loop 7 */
3888
3889 --FND_FILE.PUT_LINE(FND_FILE.LOG,'Processing Reference Designators ...');
3890 l_ref_designator_tbl(l_ref_designator_count).eco_name := rd.change_notice;
3891 l_ref_designator_tbl(l_ref_designator_count).organization_code := p_revised_item_rec.organization_code;
3892 l_ref_designator_tbl(l_ref_designator_count).revised_item_name := l_revised_item_name;
3893 l_ref_designator_tbl(l_ref_designator_count).start_effective_date := rc.effectivity_date;
3894 l_ref_designator_tbl(l_ref_designator_count).new_revised_item_revision := l_new_item_revision;
3895 l_ref_designator_tbl(l_ref_designator_count).operation_sequence_number := rc.operation_seq_num;
3896 l_ref_designator_tbl(l_ref_designator_count).component_item_name := l_component_item_name;
3897 l_ref_designator_tbl(l_ref_designator_count).alternate_bom_code := p_revised_item_rec.alternate_bom_code;
3898 l_ref_designator_tbl(l_ref_designator_count).reference_designator_name := rd.component_reference_designator;
3899 l_ref_designator_tbl(l_ref_designator_count).acd_type := rd.acd_type;
3900 l_ref_designator_tbl(l_ref_designator_count).ref_designator_comment := rd.ref_designator_comment;
3901 l_ref_designator_tbl(l_ref_designator_count).attribute_category := rd.attribute_category;
3902 l_ref_designator_tbl(l_ref_designator_count).attribute1 := rd.attribute1;
3903 l_ref_designator_tbl(l_ref_designator_count).attribute2 := rd.attribute2;
3904 l_ref_designator_tbl(l_ref_designator_count).attribute3 := rd.attribute3;
3905 l_ref_designator_tbl(l_ref_designator_count).attribute4 := rd.attribute4;
3906 l_ref_designator_tbl(l_ref_designator_count).attribute5 := rd.attribute5;
3907 l_ref_designator_tbl(l_ref_designator_count).attribute6 := rd.attribute6;
3908 l_ref_designator_tbl(l_ref_designator_count).attribute7 := rd.attribute7;
3909 l_ref_designator_tbl(l_ref_designator_count).attribute8 := rd.attribute8;
3910 l_ref_designator_tbl(l_ref_designator_count).attribute9 := rd.attribute9;
3911 l_ref_designator_tbl(l_ref_designator_count).attribute10 := rd.attribute10;
3912 l_ref_designator_tbl(l_ref_designator_count).attribute11 := rd.attribute11;
3913 l_ref_designator_tbl(l_ref_designator_count).attribute12 := rd.attribute12;
3914 l_ref_designator_tbl(l_ref_designator_count).attribute13 := rd.attribute13;
3915 l_ref_designator_tbl(l_ref_designator_count).attribute14 := rd.attribute14;
3916 l_ref_designator_tbl(l_ref_designator_count).attribute15 := rd.attribute15;
3917 l_ref_designator_tbl(l_ref_designator_count).Original_System_Reference := rd.Original_System_Reference;
3918 l_ref_designator_tbl(l_ref_designator_count).new_reference_designator := NULL;
3919 l_ref_designator_tbl(l_ref_designator_count).from_end_item_unit_number := NULL;
3920 l_ref_designator_tbl(l_ref_designator_count).return_status := NULL;
3921 l_ref_designator_tbl(l_ref_designator_count).transaction_type := 'CREATE';
3922 l_ref_designator_count := l_ref_designator_count + 1;
3923 END LOOP; /* End Loop 7 */
3924
3925 END LOOP; -- End of loop of revised components Only one is selected
3926
3927 Eng_Eco_Pvt.Process_Rev_Comp(
3928 p_validation_level => FND_API.G_VALID_LEVEL_FULL
3929 , p_change_notice => p_revised_item_rec.eco_name
3930 , p_organization_id => p_local_organization_id
3931 , I => 1
3932 , p_rev_component_rec => l_rev_component_tbl(1)
3933 , p_ref_designator_tbl => l_ref_designator_tbl
3934 , p_sub_component_tbl => l_sub_component_tbl
3935 , x_rev_component_tbl => l_rev_component_tbl
3936 , x_ref_designator_tbl => l_ref_designator_tbl
3937 , x_sub_component_tbl => l_sub_component_tbl
3938 , x_rev_comp_unexp_rec => l_rev_comp_unexp_rec
3939 , x_Mesg_Token_Tbl => l_bo_Mesg_Token_Tbl
3940 , x_return_status => l_return_status
3941 , x_bill_sequence_id => p_revised_item_unexp_rec.bill_sequence_id
3942 );
3943 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS)
3944 THEN
3945 RAISE EXC_EXP_SKIP_OBJECT;
3946 END IF;
3947 --
3948 -- Add messages through propagation Maps
3949 -- Calling log_errors first as in case of successful propagation the messages are not being displayed
3950 --
3951 Eco_Error_Handler.Log_Error(
3952 p_error_status => l_return_status
3953 , p_mesg_token_tbl => l_mesg_token_tbl
3954 , p_error_scope => Error_Handler.G_SCOPE_RECORD
3955 , p_error_level => Eco_Error_Handler.G_RC_LEVEL
3956 , x_eco_rec => ENG_Eco_PUB.G_MISS_ECO_REC
3957 , x_eco_revision_tbl => ENG_Eco_PUB.G_MISS_ECO_REVISION_TBL
3958 , x_change_line_tbl => ENG_Eco_PUB.G_MISS_CHANGE_LINE_TBL -- Eng Change
3959 , x_revised_item_tbl => ENG_Eco_PUB.G_MISS_REVISED_ITEM_TBL
3960 , x_rev_component_tbl => l_rev_component_tbl
3961 , x_ref_designator_tbl => l_ref_designator_tbl
3962 , x_sub_component_tbl => l_sub_component_tbl
3963 , x_rev_operation_tbl => ENG_Eco_PUB.G_MISS_REV_OPERATION_TBL
3964 , x_rev_op_resource_tbl => ENG_Eco_PUB.G_MISS_REV_OP_RESOURCE_TBL
3965 , x_rev_sub_resource_tbl => ENG_Eco_PUB.G_MISS_REV_SUB_RESOURCE_TBL
3966 );
3967
3968 Eng_Propagation_Log_Util.Add_Entity_Map(
3969 p_change_id => p_change_id
3970 , p_revised_item_sequence_id => p_revised_item_sequence_id
3971 , p_revised_line_type => Eng_Propagation_Log_Util.G_REV_LINE_CMP_CHG
3972 , p_revised_line_id1 => p_component_sequence_id
3973 , p_local_organization_id => p_local_organization_id
3974 , p_local_revised_item_seq_id => p_revised_item_unexp_rec.revised_item_sequence_id
3975 , p_local_revised_line_id1 => l_rev_comp_unexp_rec.component_sequence_id
3976 , p_entity_name => Eng_Propagation_Log_Util.G_ENTITY_REVISED_LINE
3977 , p_entity_action_status => l_entity_action_status
3978 , p_bo_entity_identifier => 'RC'--Eco_Error_Handler.G_RC_LEVEL
3979 );
3980 -- TODO: How to handle substitue component and reference designator errors
3981 EXCEPTION
3982 WHEN EXC_EXP_SKIP_OBJECT THEN
3983 -- Set the return status
3984 l_return_status := FND_API.G_RET_STS_ERROR;
3985 -- Log any messages that have been logged with the additional error
3986 -- message into error handler
3987 Eco_Error_Handler.Log_Error(
3988 p_error_status => l_return_status
3989 , p_mesg_token_tbl => l_mesg_token_tbl
3990 , p_error_scope => Error_Handler.G_SCOPE_RECORD
3991 , p_error_level => Eco_Error_Handler.G_RC_LEVEL
3992 , x_eco_rec => ENG_Eco_PUB.G_MISS_ECO_REC
3993 , x_eco_revision_tbl => ENG_Eco_PUB.G_MISS_ECO_REVISION_TBL
3994 , x_change_line_tbl => ENG_Eco_PUB.G_MISS_CHANGE_LINE_TBL -- Eng Change
3995 , x_revised_item_tbl => ENG_Eco_PUB.G_MISS_REVISED_ITEM_TBL
3996 , x_rev_component_tbl => l_rev_component_tbl
3997 , x_ref_designator_tbl => l_ref_designator_tbl
3998 , x_sub_component_tbl => l_sub_component_tbl
3999 , x_rev_operation_tbl => ENG_Eco_PUB.G_MISS_REV_OPERATION_TBL
4000 , x_rev_op_resource_tbl => ENG_Eco_PUB.G_MISS_REV_OP_RESOURCE_TBL
4001 , x_rev_sub_resource_tbl => ENG_Eco_PUB.G_MISS_REV_SUB_RESOURCE_TBL
4002 );
4003 -- local change id is set later
4004 -- if there are errors, based on the level they are not populated in the
4005 -- maps table.
4006 Eng_Propagation_Log_Util.add_entity_map(
4007 p_change_id => p_change_id
4008 , p_revised_item_sequence_id => p_revised_item_sequence_id
4009 , p_revised_line_type => Eng_Propagation_Log_Util.G_REV_LINE_CMP_CHG
4010 , p_revised_line_id1 => p_component_sequence_id
4011 , p_local_organization_id => p_local_organization_id
4012 , p_entity_name => Eng_Propagation_Log_Util.G_ENTITY_REVISED_LINE
4013 , p_entity_action_status => Eng_Propagation_Log_Util.G_PRP_PRC_STS_ERROR
4014 , p_bo_entity_identifier => 'RC'--Eco_Error_Handler.G_RC_LEVEL
4015 );
4016 x_return_status := l_return_status;
4017 END Propagate_Revised_Component;
4018
4019 PROCEDURE Check_Change_Existance (
4020 p_change_notice IN VARCHAR2
4021 , p_organization_id IN NUMBER
4022 , x_Mesg_Token_Tbl IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
4023 , x_Return_Status OUT NOCOPY VARCHAR2
4024 ) IS
4025
4026 CURSOR c_change_notice IS
4027 SELECT G_VAL_EXISTS
4028 FROM eng_engineering_changes
4029 WHERE change_notice = p_change_notice
4030 AND organization_id = p_organization_id;
4031
4032 l_change_exists NUMBER;
4033 l_Mesg_token_Tbl Error_Handler.Mesg_Token_Tbl_Type;
4034 l_return_status VARCHAR2(1);
4035 l_err_text VARCHAR2(2000);
4036 l_Token_Tbl Error_Handler.Token_Tbl_Type;
4037
4038 BEGIN
4039 l_return_status := FND_API.G_RET_STS_SUCCESS;
4040
4041 l_change_exists := G_VAL_NOT_EXISTS;
4042
4043 OPEN c_change_notice;
4044 FETCH c_change_notice INTO l_change_exists;
4045 CLOSE c_change_notice;
4046
4047 IF l_change_exists = G_VAL_EXISTS
4048 THEN
4049 l_return_status := FND_API.G_RET_STS_ERROR;
4050 Error_Handler.Add_Error_Token(
4051 p_Message_Name => 'ENG_PRP_ECO_EXISTS'
4052 , p_Mesg_Token_Tbl => l_mesg_token_tbl
4053 , x_Mesg_Token_Tbl => l_mesg_token_tbl
4054 , p_Token_Tbl => l_token_tbl
4055 );
4056 END IF;
4057 EXCEPTION
4058 WHEN OTHERS THEN
4059 IF c_change_notice%ISOPEN
4060 THEN
4061 CLOSE c_change_notice;
4062 END IF;
4063 l_return_status := FND_API.G_RET_STS_ERROR;
4064 END Check_Change_Existance;
4065
4066 PROCEDURE Init_Local_Change_Lifecycle (
4067 p_local_change_id IN NUMBER
4068 , p_organization_id IN NUMBER
4069 , p_org_hierarchy_name IN VARCHAR2
4070 , x_return_status OUT NOCOPY VARCHAR2
4071 ) IS
4072 l_status_code NUMBER;
4073 l_msg_count NUMBER;
4074 l_mesg_data VARCHAR2(2000);
4075 l_schedule_immediately ENG_ORG_HIERARCHY_POLICIES.SCHEDULE_IMMEDIATELY_FLAG%TYPE;
4076 l_new_status_type NUMBER;
4077 CURSOR c_get_schedule_enabled IS
4078 SELECT eohp.SCHEDULE_IMMEDIATELY_FLAG
4079 FROM ENG_ORG_HIERARCHY_POLICIES eohp, ENG_TYPE_ORG_HIERARCHIES etoh, eng_engineering_changes eec
4080 WHERE eec.change_id = p_local_change_id
4081 AND eohp.organization_id = eec.organization_id
4082 AND eohp.SCHEDULE_IMMEDIATELY_FLAG = 'Y'
4083 AND eohp.change_type_org_hierarchy_id = etoh.change_type_org_hierarchy_id
4084 AND etoh.change_type_id = eec.change_order_type_id
4085 AND etoh.organization_id = p_organization_id
4086 AND EXISTS (SELECT 1
4087 FROM per_organization_structures hier
4088 WHERE hier.name = p_org_hierarchy_name
4089 AND etoh.hierarchy_id = hier.organization_structure_id);
4090
4091 -- cursor to fetch the status in which the change is to be initialized
4092 -- this cursor fetches the shduled status of the change if
4093 -- schedule immediately is set for the selected hierarchy at the change level
4094 -- for TTM case since the processing is per organization and the submit change
4095 -- would have been enabled this is not going to be called
4096 CURSOR c_get_init_status IS
4097 SELECT els.status_code
4098 FROM eng_lifecycle_statuses els
4099 WHERE els.entity_id1 = p_local_change_id
4100 AND els.entity_name = 'ENG_CHANGE'
4101 AND els.sequence_number =
4102 (SELECT min(sequence_number)
4103 FROM eng_lifecycle_statuses els1, eng_change_statuses_vl ecs1
4104 WHERE els1.entity_id1 = p_local_change_id
4105 AND els1.entity_name = 'ENG_CHANGE'
4106 AND els1.status_code = ecs1.status_code
4107 AND ((ecs1.status_type = 4 AND l_schedule_immediately = 'Y')
4108 OR nvl(l_schedule_immediately, 'N') = 'N'))
4109 AND EXISTS (SELECT 1
4110 FROM eng_engineering_changes
4111 WHERE change_id = els.entity_id1
4112 AND status_type = 0);
4113 BEGIN
4114 x_return_status := FND_API.G_RET_STS_SUCCESS;
4115 OPEN c_get_schedule_enabled;
4116 FETCH c_get_schedule_enabled INTO l_schedule_immediately;
4117 CLOSE c_get_schedule_enabled;
4118 OPEN c_get_init_status;
4119 FETCH c_get_init_status INTO l_status_code;
4120 IF c_get_init_status%FOUND
4121 THEN
4122 ENG_CHANGE_LIFECYCLE_UTIL.Init_Lifecycle(
4123 p_api_version => 1.0
4124 , p_change_id => p_local_change_id
4125 , x_return_status => x_return_status
4126 , x_msg_count => l_msg_count
4127 , x_msg_data => l_mesg_data
4128 , p_api_caller => 'CP'
4129 , p_init_status_code => l_status_code
4130 );
4131
4132 SELECT status_type
4133 INTO l_new_status_type
4134 FROM eng_change_statuses
4135 WHERE status_code = l_status_code
4136 AND rownum = 1;
4137 -- The following update should be moved to init lifecycle
4138 UPDATE eng_revised_items
4139 SET status_code = l_status_code,
4140 status_type = l_new_status_type,
4141 last_update_date = sysdate,
4142 last_updated_by = FND_PROFILE.VALUE('USER_ID'),
4143 last_update_login = FND_PROFILE.VALUE('LOGIN_ID')
4144 WHERE change_id = p_local_change_id;
4145 END IF;
4146 CLOSE c_get_init_status;
4147 EXCEPTION
4148 WHEN OTHERS THEN
4149 IF c_get_init_status%ISOPEN
4150 THEN
4151 CLOSE c_get_init_status;
4152 END IF;
4153 IF c_get_schedule_enabled%ISOPEN
4154 THEN
4155 CLOSE c_get_schedule_enabled;
4156 END IF;
4157 x_return_status := FND_API.G_RET_STS_ERROR;
4158 END Init_Local_Change_Lifecycle;
4159
4160 PROCEDURE Propagate_Change_Header (
4161 p_change_id IN NUMBER
4162 , p_change_notice IN VARCHAR2
4163 , p_organization_code IN VARCHAR2
4164 , p_organization_id IN NUMBER
4165 , p_org_hierarchy_name IN VARCHAR2
4166 , p_local_organization_code IN VARCHAR2
4167 , p_local_organization_id IN NUMBER
4168 , x_Mesg_Token_Tbl IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
4169 , x_Return_Status OUT NOCOPY VARCHAR2
4170 ) IS
4171 -- Local Identifiers
4172 l_local_change_id NUMBER;
4173 -- Exposed Column Data
4174 l_change_type_code VARCHAR2(80);
4175 l_change_mgmt_type Eng_change_order_types_tl.type_name%TYPE; --Bug 3544760
4176 l_requestor_name VARCHAR2(30);
4177 l_assignee_name VARCHAR2(360);
4178 l_Task_Number VARCHAR2(25);
4179 l_Project_Number VARCHAR2(30);
4180 -- Some internl variables
4181 l_sched_immediately NUMBER := 1;
4182 l_pk1_value VARCHAR2(100);
4183 l_pk2_value VARCHAR2(100);
4184 l_pk3_value VARCHAR2(100);
4185 l_entity_name VARCHAR2(30);
4186 l_header_subject_exists NUMBER := 1;
4187 i NUMBER;
4188 l_invalid_subject NUMBER := 0;
4189 l_pk1_name VARCHAR2(40);
4190 l_pk2_name VARCHAR2(3);
4191 l_pk3_name VARCHAR2(3);
4192 l_approval_status VARCHAR2(80);
4193 l_task_number1 VARCHAR2(100);
4194 l_party_id NUMBER;
4195 l_party_type VARCHAR2(30);
4196 l_default_assignee_type eng_change_order_types.default_assignee_type%TYPE;
4197 l_assignee_role_id NUMBER;
4198 l_status_name eng_change_statuses_tl.status_name%TYPE;
4199 l_department_name VARCHAR2(240);
4200 l_change_type_id NUMBER;
4201 -- Variables for error handling
4202 l_msg_count NUMBER;
4203 l_Mesg_token_Tbl Error_Handler.Mesg_Token_Tbl_Type;
4204 l_return_status VARCHAR2(1);
4205 l_err_text VARCHAR2(2000);
4206 l_Token_Tbl Error_Handler.Token_Tbl_Type;
4207 -- Variables for Call to Process ECO
4208 l_eco_rec Eng_Eco_Pub.Eco_Rec_Type;
4209 l_change_lines_tbl Eng_Eco_Pub.Change_Line_Tbl_Type;
4210 l_eco_revision_tbl Eng_Eco_Pub.Eco_Revision_Tbl_Type;
4211 l_revised_item_tbl Eng_Eco_Pub.Revised_Item_Tbl_Type;
4212 l_rev_component_tbl Bom_Bo_Pub.Rev_Component_Tbl_Type;
4213 l_sub_component_tbl Bom_Bo_Pub.Sub_Component_Tbl_Type;
4214 l_ref_designator_tbl Bom_Bo_Pub.Ref_Designator_Tbl_Type;
4215 l_rev_operation_tbl Bom_Rtg_Pub.Rev_Operation_Tbl_Type;
4216 l_rev_op_resource_tbl Bom_Rtg_Pub.Rev_Op_Resource_Tbl_Type;
4217 l_rev_sub_resource_tbl Bom_Rtg_Pub.Rev_Sub_Resource_Tbl_Type;
4218
4219 --
4220 -- Cursor to Pick all ECO header for the Top Organization for the given
4221 -- Change Notice
4222 CURSOR c_eco_rec IS
4223 SELECT *
4224 FROM eng_engineering_changes
4225 WHERE change_notice = p_change_notice
4226 AND organization_id = p_organization_id;
4227
4228 -- Cursor to Pick all Revised Items for the Top Organization for the given
4229 -- Change Notice
4230 CURSOR c_eco_revision IS
4231 SELECT *
4232 FROM eng_change_order_revisions
4233 WHERE change_notice = p_change_notice
4234 AND organization_id = p_organization_id
4235 AND nvl(start_date, sysdate) > sysdate; -- Added this condtion as only future revisions need to be fetched
4236 /* Cursor to fetch the group name given the party id */
4237 CURSOR c_group_name(cp_party_id NUMBER) IS
4238 SELECT party_name
4239 FROM hz_parties
4240 WHERE party_id = cp_party_id
4241 AND party_type = 'GROUP';
4242
4243 /* Cursor to fetch the assignees with direct item roles at item level */
4244 CURSOR c_item_assignee(cp_assignee_role_id NUMBER, cp_item_id NUMBER, cp_org_id NUMBER) IS
4245 SELECT party.party_id, party.party_name, party.party_type
4246 FROM HZ_PARTIES party, fnd_grants grants, fnd_objects obj
4247 WHERE obj.obj_name = 'EGO_ITEM'
4248 AND grants.object_id = obj.object_id
4249 AND grants.GRANTEE_ORIG_SYSTEM_ID = party.party_id
4250 AND (
4251 (grants.GRANTEE_ORIG_SYSTEM = 'HZ_PARTY' AND grants.grantee_type ='USER' AND party.party_type= 'PERSON')
4252 OR (grants.GRANTEE_ORIG_SYSTEM = 'HZ_GROUP' AND grants.grantee_type ='GROUP' AND party.party_type= 'GROUP')
4253 )
4254 AND grants.start_date <= SYSDATE
4255 AND NVL(grants.end_date, SYSDATE+1) >= TRUNC(SYSDATE)
4256 AND grants.instance_type = 'INSTANCE'
4257 AND grants.menu_id = cp_assignee_role_id
4258 AND grants.instance_pk1_value = cp_item_id
4259 AND grants.instance_pk2_value = cp_org_id
4260 AND ROWNUM = 1;
4261
4262 /* Cursor to fetch the assignees with item roles at catalog category level */
4263 CURSOR c_category_item_assignee(cp_assignee_role_id NUMBER, cp_item_id NUMBER, cp_org_id NUMBER) IS
4264 SELECT party.party_id, party.party_name, party.party_type
4265 FROM HZ_PARTIES party, fnd_grants grants, fnd_objects obj
4266 WHERE obj.obj_name = 'EGO_ITEM'
4267 AND grants.object_id = obj.object_id
4268 AND grants.GRANTEE_ORIG_SYSTEM_ID = party.party_id
4269 AND (
4270 (grants.GRANTEE_ORIG_SYSTEM = 'HZ_PARTY' AND grants.grantee_type ='USER' AND party.party_type= 'PERSON')
4271 OR (grants.GRANTEE_ORIG_SYSTEM = 'HZ_GROUP' AND grants.grantee_type ='GROUP' AND party.party_type= 'GROUP')
4272 )
4273 AND grants.start_date <= SYSDATE
4274 AND NVL(grants.end_date, SYSDATE+1) >= TRUNC(SYSDATE)
4275 AND grants.instance_type= 'SET'
4276 AND grants.menu_id = cp_assignee_role_id
4277 AND grants.instance_set_id IN ( SELECT instance_set.instance_set_id
4278 FROM fnd_object_instance_sets instance_set, mtl_system_items_b item1
4279 WHERE instance_set.object_id = grants.object_id
4280 AND instance_set.instance_set_name = 'EGO_ORG_CAT_ITEM_' ||
4281 to_char(item1.organization_id) || '_' || to_char(item1.ITEM_CATALOG_GROUP_ID)
4282 AND item1.INVENTORY_ITEM_ID= cp_item_id
4283 AND item1.ORGANIZATION_ID = cp_org_id )
4284 AND ROWNUM = 1;
4285
4286 /* Cursor to fetch the assignees with item roles at organization level */
4287 CURSOR c_org_assignee(cp_assignee_role_id NUMBER, cp_org_id NUMBER) IS
4288 SELECT party.party_id, party.party_name, party.party_type
4289 FROM HZ_PARTIES party, fnd_grants grants, fnd_objects obj
4290 WHERE obj.obj_name = 'EGO_ITEM'
4291 AND grants.object_id = obj.object_id
4292 AND grants.GRANTEE_ORIG_SYSTEM_ID = party.party_id
4293 AND (
4294 (grants.GRANTEE_ORIG_SYSTEM = 'HZ_PARTY' AND grants.grantee_type ='USER' AND party.party_type= 'PERSON')
4295 OR (grants.GRANTEE_ORIG_SYSTEM = 'HZ_GROUP' AND grants.grantee_type ='GROUP' AND party.party_type= 'GROUP')
4296 )
4297 AND grants.start_date <= SYSDATE
4298 AND NVL(grants.end_date, SYSDATE+1) >= TRUNC(SYSDATE)
4299 AND grants.instance_type= 'SET'
4300 AND grants.menu_id = cp_assignee_role_id
4301 AND grants.instance_set_id IN ( SELECT instance_set.instance_set_id
4302 FROM fnd_object_instance_sets instance_set
4303 WHERE instance_set.object_id = grants.object_id
4304 AND instance_set.instance_set_name = 'EGO_ORG_ITEM_' ||cp_org_id)
4305 AND ROWNUM = 1;
4306
4307 -- Bug No: 4327218
4308 -- Modified query to refer to 'person_party_id' instead of 'customer_id'
4309 CURSOR c_user_name(v_party_id IN NUMBER) IS
4310 SELECT us.user_name FROM fnd_user us, hz_parties pa
4311 WHERE ((us.employee_id IS NOT NULL AND us.employee_id = pa.person_identifier))
4312 AND pa.party_id = v_party_id
4313 union all
4314 SELECT us.user_name
4315 FROM fnd_user us, hz_parties pa
4316 WHERE (us.employee_id IS NULL AND (us.person_party_id = pa.party_id or (us.person_party_id is null and us.supplier_id = pa.party_id)))
4317 AND pa.party_id = v_party_id;
4318
4319 BEGIN
4320 l_return_status := FND_API.G_RET_STS_SUCCESS;
4321 --
4322 -- Check if the change header has already been propagated
4323 --
4324 Propagated_Local_Change(
4325 p_change_id => p_change_id
4326 , p_local_organization_id => p_local_organization_id
4327 , x_local_change_id => l_local_change_id
4328 );
4329 --
4330 -- If propagated local change exists , then the header processing will
4331 -- not continue . Return control to calling program .
4332 --
4333 IF l_local_change_id IS NOT NULL
4334 THEN
4335 Error_Handler.Add_Error_Token(
4336 p_Message_Name => 'ENG_PRP_ECO_PROPAGATED'
4337 , p_Mesg_Token_Tbl => x_Mesg_Token_Tbl
4338 , x_Mesg_Token_Tbl => x_Mesg_Token_Tbl
4339 , p_Token_Tbl => l_token_tbl
4340 , p_message_type => 'W'
4341 );
4342 RETURN;
4343 END IF;
4344
4345 --
4346 -- Check if the change order already exists in the organization
4347 -- with the same change_notice value. Then raise an error
4348 --
4349 Check_Change_Existance(
4350 p_change_notice => p_change_notice
4351 , p_organization_id => p_local_organization_id
4352 , x_Mesg_Token_Tbl => l_mesg_token_tbl
4353 , x_Return_Status => l_return_status
4354 );
4355 IF l_return_status = FND_API.G_RET_STS_ERROR
4356 THEN
4357 RAISE EXC_EXP_SKIP_OBJECT;
4358 END IF;
4359
4360 FOR eco_rec IN c_eco_rec -- Loop 1
4361 LOOP
4362 IF (eco_rec.status_type IS NOT NULL AND eco_rec.status_type = 5) /* Cancelled ECO check */
4363 THEN
4364 RAISE EXC_EXP_SKIP_OBJECT;
4365 END IF;
4366
4367 IF (eco_rec.change_order_type_id IS NOT NULL)
4368 THEN
4369 -- Changes for bug 3544760
4370 -- Fetching the change category name also
4371 SELECT ecotv.CHANGE_ORDER_TYPE
4372 , ecmtv.name
4373 , ecotv.default_assignee_type
4374 , ecotv.default_assignee_id
4375 INTO l_change_type_code
4376 , l_change_mgmt_type
4377 , l_default_assignee_type
4378 , l_assignee_role_id
4379 FROM eng_change_order_types_v ecotv
4380 , eng_change_mgmt_types_vl ecmtv
4381 WHERE ecotv.change_order_type_id = eco_rec.change_order_type_id
4382 AND ecotv.CHANGE_MGMT_TYPE_CODE = ecmtv.CHANGE_MGMT_TYPE_CODE;
4383 ELSE
4384 l_change_type_code := NULL;
4385 l_change_mgmt_type := NULL; -- bug 3544760
4386 END IF;
4387
4388 IF (eco_rec.responsible_organization_id IS NOT NULL)
4389 THEN
4390 SELECT name
4391 INTO l_department_name
4392 FROM hr_all_organization_units
4393 WHERE organization_id = eco_rec.responsible_organization_id;
4394 ELSE
4395 l_department_name := NULL;
4396 END IF;
4397
4398 IF (eco_rec.requestor_id IS NOT NULL)
4399 THEN
4400 BEGIN
4401 OPEN c_user_name(eco_rec.requestor_id);
4402 FETCH c_user_name INTO l_requestor_name;
4403 CLOSE c_user_name;
4404 EXCEPTION
4405 WHEN NO_DATA_FOUND THEN
4406 FND_FILE.PUT_LINE(FND_FILE.LOG,
4407 'No_Data_found for requestor id '
4408 || to_char( eco_rec.requestor_id)
4409 || ' in org ' || to_char(p_organization_id));
4410 l_requestor_name := NULL;
4411 END;
4412 ELSE
4413 l_requestor_name := NULL;
4414 END IF;
4415
4416 IF (eco_rec.PROJECT_ID IS NOT NULL)
4417 THEN
4418 BEGIN
4419 SELECT name
4420 into l_Project_Number
4421 FROM pa_projects_all
4422 WHERE project_id = eco_rec.PROJECT_ID;
4423 EXCEPTION
4424 WHEN NO_DATA_FOUND THEN
4425 FND_FILE.PUT_LINE(FND_FILE.LOG,'No_Data_found for project id ' || to_char( eco_rec.PROJECT_ID));
4426 l_Project_Number := NULL;
4427 END;
4428 ELSE
4429 l_Project_Number := NULL;
4430 END IF;
4431
4432 IF (eco_rec.TASK_ID IS NOT NULL)
4433 THEN
4434 BEGIN
4435 SELECT task_number
4436 INTO l_Task_Number
4437 FROM pa_tasks
4438 WHERE TASK_ID = eco_rec.TASK_ID;
4439 EXCEPTION
4440 WHEN NO_DATA_FOUND THEN
4441 FND_FILE.PUT_LINE(FND_FILE.LOG,'No_Data_found for task id ' || to_char( eco_rec.TASK_ID));
4442 l_Task_Number := NULL;
4443 END;
4444 ELSE
4445 l_Task_Number := NULL;
4446 END IF;
4447
4448 IF(eco_rec.PROJECT_ID IS NOT NULL AND eco_rec.TASK_ID IS NOT NULL)
4449 THEN
4450 BEGIN
4451 SELECT PPE.ELEMENT_NUMBER
4452 INTO l_task_number1
4453 FROM PA_PROJ_ELEMENTS PPE
4454 WHERE PPE.PROJECT_ID = Eco_rec.PROJECT_ID
4455 AND PPE.PROJ_ELEMENT_ID = Eco_rec.TASK_ID;
4456 EXCEPTION
4457 WHEN NO_DATA_FOUND THEN
4458 l_task_number1 := NULL;
4459 END;
4460 ELSE
4461 l_task_number1 := NULL;
4462 END IF;
4463
4464 /* check whether the local organization eco needs to be scheduled immediately */
4465 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Processing ECO Fetch status..' );
4466 BEGIN
4467 SELECT 1
4468 INTO l_sched_immediately
4469 FROM ENG_ORG_HIERARCHY_POLICIES
4470 WHERE organization_id = p_local_organization_id
4471 AND SCHEDULE_IMMEDIATELY_FLAG = 'Y'
4472 AND change_type_org_hierarchy_id =
4473 (SELECT change_type_org_hierarchy_id
4474 FROM ENG_TYPE_ORG_HIERARCHIES
4475 WHERE change_type_id = l_change_type_id
4476 AND organization_id = p_organization_id
4477 AND hierarchy_id = (SELECT organization_structure_id
4478 FROM per_organization_structures
4479 WHERE name = p_org_hierarchy_name));
4480 EXCEPTION
4481 WHEN NO_DATA_FOUND THEN
4482 l_sched_immediately := 0;
4483 END;
4484
4485 IF (l_sched_immediately = 1)
4486 THEN
4487 --
4488 -- To be handled differently wrt init lifecycle
4489 -- The status to the BO for processing the header should be draft in all cases
4490 --
4491 null;
4492 END IF;
4493 -- Fetch status details
4494 SELECT ecs.status_name
4495 INTO l_status_name
4496 FROM eng_change_statuses_vl ecs
4497 WHERE ecs.status_code = 0;
4498
4499 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Status = ' || l_status_name);
4500
4501 ENGECOBO.GLOBAL_CHANGE_ID := p_change_id;
4502 ENGECOBO.GLOBAL_ORG_ID := eco_rec.organization_id;
4503
4504 -- Fetch change subjects
4505 BEGIN
4506 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Processing Subject .. ');
4507
4508 l_header_subject_exists := 1;
4509
4510 select sub1.pk1_value, sub1.pk2_value, sub2.pk3_value, sub2.entity_name
4511 INTO l_pk1_value, l_pk2_value, l_pk3_value, l_entity_name
4512 from eng_change_subjects sub1,eng_change_subjects sub2
4513 where sub1.change_id = sub2.change_id
4514 and sub1.change_id = p_change_id
4515 and sub1.change_line_id is null
4516 and sub2.change_line_id is null
4517 and sub1.entity_name = 'EGO_ITEM'
4518 and ((sub2.entity_name = 'EGO_ITEM_REVISION' and sub2.subject_level =1 and sub1.subject_level=2 )
4519 or (sub2.entity_name = sub1.entity_name and sub2.subject_level = sub1.subject_level and sub1.subject_level=1 ))
4520 and rownum =1;
4521 EXCEPTION
4522 WHEN NO_DATA_FOUND THEN
4523 l_header_subject_exists := 0;
4524 END;
4525
4526 IF (l_header_subject_exists = 1)
4527 THEN
4528 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Processing Subject 2.. ');
4529 --
4530 -- Setting Pk1 Value
4531 IF (l_pk1_value IS NOT NULL)
4532 THEN
4533 BEGIN
4534 SELECT concatenated_segments
4535 INTO l_pk1_name
4536 FROM mtl_system_items_b_kfv
4537 WHERE inventory_item_id = l_pk1_value
4538 AND organization_id = p_local_organization_id;
4539 EXCEPTION
4540 WHEN NO_DATA_FOUND THEN
4541 l_return_status := FND_API.G_RET_STS_ERROR;
4542 Error_Handler.Add_Error_Token(
4543 p_Message_Name => 'ENG_PRP_SUBJECT_ITEM_INVALID'
4544 , p_Mesg_Token_Tbl => l_mesg_token_tbl
4545 , x_Mesg_Token_Tbl => l_mesg_token_tbl
4546 , p_Token_Tbl => l_token_tbl
4547 );
4548 RAISE EXC_EXP_SKIP_OBJECT;
4549 END;
4550 END IF;
4551 --
4552 -- Setting Pk2 Value
4553 l_pk2_name := p_local_organization_code;
4554 --
4555 -- Setting Pk3 Value
4556 IF (l_entity_name = 'EGO_ITEM_REVISION' AND l_invalid_subject <> 1
4557 AND l_pk1_value IS NOT NULL AND l_pk3_value IS NOT NULL)
4558 THEN
4559 BEGIN
4560 select revision
4561 into l_pk3_name
4562 from mtl_item_revisions
4563 where inventory_item_id = l_pk1_value
4564 AND organization_id = p_local_organization_id
4565 and revision = ( select revision
4566 from mtl_item_revisions
4567 where revision_id = l_pk3_value);
4568 EXCEPTION
4569 WHEN NO_DATA_FOUND THEN
4570 l_return_status := FND_API.G_RET_STS_ERROR;
4571
4572 l_token_tbl(1).token_name := 'ITEM';
4573 l_token_tbl(1).token_value := l_pk1_name;
4574
4575 Error_Handler.Add_Error_Token(
4576 p_Message_Name => 'ENG_PRP_SUBJECT_REV_INVALID'
4577 , p_Mesg_Token_Tbl => l_mesg_token_tbl
4578 , x_Mesg_Token_Tbl => l_mesg_token_tbl
4579 , p_Token_Tbl => l_token_tbl
4580 );
4581 RAISE EXC_EXP_SKIP_OBJECT;
4582 END;
4583 END IF;
4584 END IF;
4585
4586 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Processing Subject Status ' || l_invalid_subject);
4587
4588 -- Changes for bug 3547805
4589 -- Assignee Name Processing
4590 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Processing Assignee ..');
4591 l_party_id := eco_rec.assignee_id;
4592 l_assignee_name := NULL ;
4593 BEGIN
4594 -- if subject item is not null then process the role based assignee types
4595 IF (l_pk1_value IS NOT NULL AND l_assignee_role_id IS NOT NULL AND l_default_assignee_type IS NOT NULL)
4596 THEN
4597 -- Process role based types
4598 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Processing Assignee Roles..');
4599 IF (l_default_assignee_type = 'EGO_ITEM')
4600 THEN
4601 OPEN c_item_assignee(l_assignee_role_id , l_pk1_value , p_local_organization_id );
4602 FETCH c_item_assignee INTO l_party_id, l_assignee_name, l_party_type;
4603 CLOSE c_item_assignee;
4604 ELSIF (l_default_assignee_type = 'EGO_CATALOG_GROUP')
4605 THEN
4606 OPEN c_category_item_assignee(l_assignee_role_id , l_pk1_value , p_local_organization_id );
4607 FETCH c_category_item_assignee INTO l_party_id, l_assignee_name, l_party_type;
4608 CLOSE c_category_item_assignee;
4609 ELSIF (l_default_assignee_type = 'ENG_CHANGE')
4610 THEN
4611 OPEN c_org_assignee(l_assignee_role_id , p_local_organization_id );
4612 FETCH c_org_assignee INTO l_party_id, l_assignee_name, l_party_type;
4613 CLOSE c_org_assignee;
4614 END IF;
4615 END IF;
4616
4617 -- For all other cases and if role based type has person as assignee then
4618 -- Fetch the assignee name
4619 IF (l_party_id IS NOT NULL AND (l_party_type IS NULL OR l_party_type <> 'GROUP'))
4620 THEN
4621 OPEN c_user_name(l_party_id);
4622 FETCH c_user_name INTO l_assignee_name;
4623 IF c_user_name%NOTFOUND
4624 THEN
4625 OPEN c_group_name(l_party_id);
4626 FETCH c_group_name INTO l_assignee_name;
4627 CLOSE c_group_name;
4628 END IF;
4629 CLOSE c_user_name;
4630 END IF;
4631 EXCEPTION
4632 WHEN OTHERS THEN
4633 IF c_item_assignee%ISOPEN THEN
4634 CLOSE c_item_assignee;
4635 END IF;
4636 IF c_category_item_assignee%ISOPEN THEN
4637 CLOSE c_category_item_assignee;
4638 END IF;
4639 IF c_org_assignee%ISOPEN THEN
4640 CLOSE c_org_assignee;
4641 END IF;
4642 IF c_user_name%ISOPEN THEN
4643 CLOSE c_user_name;
4644 END IF;
4645 IF c_user_name%ISOPEN THEN
4646 CLOSE c_user_name;
4647 END IF;
4648 l_assignee_name := null;
4649 END;
4650 -- End changes for bug 3547805
4651
4652 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Population ECO Header Info.. ');
4653 /* Popuating PL/SQL record for ECO Header */
4654 l_eco_rec.eco_name := eco_rec.change_notice;
4655 l_eco_rec.change_name := eco_rec.change_name; --Added for bug 9405365
4656 l_eco_rec.organization_code := p_local_organization_code;
4657 l_eco_rec.change_type_code := l_change_type_code;
4658 l_eco_rec.status_name := l_status_name;
4659 l_eco_rec.eco_department_name := l_department_name;
4660 l_eco_rec.priority_code := eco_rec.priority_code;
4661 -- l_eco_rec.approval_list_name := l_approval_list_name;
4662 -- l_eco_rec.Approval_Status_Name := l_approval_status;
4663 -- Bug 3897954:For PLM records, the master org approval status will
4664 -- not be propagated as PLM ECOs are always created with an initialized
4665 -- lifecycle by ECO BO.
4666 l_eco_rec.reason_code := eco_rec.reason_code;
4667 l_eco_rec.eng_implementation_cost := eco_rec.estimated_eng_cost;
4668 l_eco_rec.mfg_implementation_cost := eco_rec.estimated_mfg_cost;
4669 l_eco_rec.cancellation_comments := eco_rec.cancellation_comments;
4670 l_eco_rec.requestor := l_requestor_name;
4671 l_eco_rec.assignee := l_assignee_name;
4672 l_eco_rec.description := eco_rec.description;
4673 l_eco_rec.attribute_category := eco_rec.attribute_category;
4674 l_eco_rec.attribute1 := eco_rec.attribute1;
4675 l_eco_rec.attribute2 := eco_rec.attribute2;
4676 l_eco_rec.attribute3 := eco_rec.attribute3;
4677 l_eco_rec.attribute4 := eco_rec.attribute4;
4678 l_eco_rec.attribute5 := eco_rec.attribute5;
4679 l_eco_rec.attribute6 := eco_rec.attribute6;
4680 l_eco_rec.attribute7 := eco_rec.attribute7;
4681 l_eco_rec.attribute8 := eco_rec.attribute8;
4682 l_eco_rec.attribute9 := eco_rec.attribute9;
4683 l_eco_rec.attribute10 := eco_rec.attribute10;
4684 l_eco_rec.attribute11 := eco_rec.attribute11;
4685 l_eco_rec.attribute12 := eco_rec.attribute12;
4686 l_eco_rec.attribute13 := eco_rec.attribute13;
4687 l_eco_rec.attribute14 := eco_rec.attribute14;
4688 l_eco_rec.attribute15 := eco_rec.attribute15;
4689 -- l_eco_rec.Original_System_Reference := eco_rec.Original_System_Reference;
4690 l_eco_rec.Project_Name := l_project_number;
4691 l_eco_rec.Task_Number := l_Task_Number1;
4692 --l_eco_rec.hierarchy_flag := 2;
4693 l_eco_rec.organization_hierarchy := NULL;
4694 l_eco_rec.return_status := NULL;
4695
4696 --lkasturi: 11.5.10 changes
4697
4698 l_eco_rec.plm_or_erp_change := 'PLM';
4699 l_eco_rec.pk1_name := l_pk1_name;
4700 l_eco_rec.pk2_name := l_pk2_name;
4701 l_eco_rec.pk3_name := l_pk3_name;
4702 l_eco_rec.change_management_type := l_change_mgmt_type; -- Bug 3544760
4703 --lkasturi: 11.5.10 end changes
4704 l_eco_rec.transaction_type := 'CREATE';
4705 -- Fetch ECO Revisions
4706 i := 1;
4707 FOR rev IN c_eco_revision
4708 LOOP
4709 FND_FILE.PUT_LINE(FND_FILE.LOG,'Processing ECO Revision ...');
4710 l_eco_revision_tbl(i).eco_name := rev.change_notice;
4711 l_eco_revision_tbl(i).organization_code:= p_local_organization_code;
4712 l_eco_revision_tbl(i).revision := rev.revision;
4713 -- l_eco_revision_tbl(i).new_revision := rev.new_revision;
4714 l_eco_revision_tbl(i).new_revision := NULL;
4715 l_eco_revision_tbl(i).Attribute_category := rev.Attribute_category;
4716 l_eco_revision_tbl(i).attribute1 := rev.attribute1;
4717 l_eco_revision_tbl(i).attribute2 := rev.attribute2;
4718 l_eco_revision_tbl(i).attribute3 := rev.attribute3;
4719 l_eco_revision_tbl(i).attribute4 := rev.attribute4;
4720 l_eco_revision_tbl(i).attribute5 := rev.attribute5;
4721 l_eco_revision_tbl(i).attribute6 := rev.attribute6;
4722 l_eco_revision_tbl(i).attribute7 := rev.attribute7;
4723 l_eco_revision_tbl(i).attribute8 := rev.attribute8;
4724 l_eco_revision_tbl(i).attribute9 := rev.attribute9;
4725 l_eco_revision_tbl(i).attribute10 :=rev.attribute10;
4726 l_eco_revision_tbl(i).attribute11 :=rev.attribute11;
4727 l_eco_revision_tbl(i).attribute12 :=rev.attribute12;
4728 l_eco_revision_tbl(i).attribute13 := rev.attribute13;
4729 l_eco_revision_tbl(i).attribute14 := rev.attribute14;
4730 l_eco_revision_tbl(i).attribute15 := rev.attribute15;
4731 l_eco_revision_tbl(i).Original_System_Reference := rev.Original_System_Reference;
4732 l_eco_revision_tbl(i).comments := rev.comments;
4733 l_eco_revision_tbl(i).return_status := NULL;
4734 l_eco_revision_tbl(i).transaction_type := 'CREATE';
4735 i := i + 1;
4736 END LOOP; -- End rev IN c_eco_revision
4737 END LOOP;
4738
4739 -- Process Header and ECO Revisions
4740 Eng_Eco_Pub.Process_Eco(
4741 p_api_version_number => 1.0
4742 , p_init_msg_list => FALSE
4743 , x_return_status => l_return_status
4744 , x_msg_count => l_msg_count
4745 , p_bo_identifier => 'ECO'
4746 , p_ECO_rec => l_eco_rec
4747 , p_eco_revision_tbl => l_eco_revision_tbl
4748 , x_ECO_rec => l_eco_rec
4749 , x_eco_revision_tbl => l_eco_revision_tbl
4750 , x_change_line_tbl => l_change_lines_tbl
4751 , x_revised_item_tbl => l_revised_item_tbl
4752 , x_rev_component_tbl => l_rev_component_tbl
4753 , x_sub_component_tbl => l_sub_component_tbl
4754 , x_ref_designator_tbl => l_ref_designator_tbl
4755 , x_rev_operation_tbl => l_rev_operation_tbl
4756 , x_rev_op_resource_tbl => l_rev_op_resource_tbl
4757 , x_rev_sub_resource_tbl => l_rev_sub_resource_tbl
4758 );
4759 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'After Propagation ECO l_return_status'|| l_return_status);
4760
4761 IF l_return_status = FND_API.G_RET_STS_SUCCESS
4762 THEN
4763
4764 Eco_Error_Handler.Log_Error(
4765 p_error_status => FND_API.G_RET_STS_SUCCESS
4766 , p_error_scope => Error_Handler.G_SCOPE_RECORD
4767 , p_error_level => Eco_Error_Handler.G_ECO_LEVEL
4768 , p_other_message => 'ENG_PRP_CHG_ORDER_SUCC'
4769 , p_other_status => l_return_status
4770 , p_other_token_tbl => l_token_tbl
4771 , x_eco_rec => l_eco_rec
4772 , x_eco_revision_tbl => l_eco_revision_tbl
4773 , x_change_line_tbl => l_change_lines_tbl -- Eng Change
4774 , x_revised_item_tbl => l_revised_item_tbl
4775 , x_rev_component_tbl => l_rev_component_tbl
4776 , x_ref_designator_tbl => l_ref_designator_tbl
4777 , x_sub_component_tbl => l_sub_component_tbl
4778 , x_rev_operation_tbl => l_rev_operation_tbl --L1
4779 , x_rev_op_resource_tbl => l_rev_op_resource_tbl --L1
4780 , x_rev_sub_resource_tbl => l_rev_sub_resource_tbl --L1
4781 );
4782 COMMIT;
4783 ELSE
4784 RAISE EXC_EXP_SKIP_OBJECT;
4785 END IF;
4786
4787 EXCEPTION
4788 WHEN EXC_EXP_SKIP_OBJECT THEN
4789 --
4790 -- Rollback any changes that may have been made to the DB
4791 --
4792 ROLLBACK;
4793 -- Set the return status
4794 l_return_status := FND_API.G_RET_STS_ERROR;
4795 -- Log any messages that have been logged with the additional error
4796 -- message into error handler
4797 Eco_Error_Handler.Log_Error(
4798 p_error_status => l_return_status
4799 , p_mesg_token_tbl => l_mesg_token_tbl
4800 , p_error_scope => Error_Handler.G_SCOPE_RECORD
4801 , p_error_level => Eco_Error_Handler.G_ECO_LEVEL
4802 , p_other_message => 'ENG_PRP_CHG_ORDER_ERR'
4803 , p_other_status => l_return_status
4804 , p_other_token_tbl => l_token_tbl
4805 , x_eco_rec => l_eco_rec
4806 , x_eco_revision_tbl => l_eco_revision_tbl
4807 , x_change_line_tbl => l_change_lines_tbl -- Eng Change
4808 , x_revised_item_tbl => l_revised_item_tbl
4809 , x_rev_component_tbl => l_rev_component_tbl
4810 , x_ref_designator_tbl => l_ref_designator_tbl
4811 , x_sub_component_tbl => l_sub_component_tbl
4812 , x_rev_operation_tbl => l_rev_operation_tbl --L1
4813 , x_rev_op_resource_tbl => l_rev_op_resource_tbl --L1
4814 , x_rev_sub_resource_tbl => l_rev_sub_resource_tbl --L1
4815 );
4816
4817 Eng_Propagation_Log_Util.add_entity_map(
4818 p_change_id => p_change_id
4819 , p_local_organization_id => p_local_organization_id
4820 , p_entity_name => Eng_Propagation_Log_Util.G_ENTITY_CHANGE
4821 , p_entity_action_status => Eng_Propagation_Log_Util.G_PRP_PRC_STS_ERROR
4822 , p_bo_entity_identifier => 'ECO'--Eco_Error_Handler.G_ECO_LEVEL
4823 );
4824
4825 -- WHEN OTHERS THEN
4826 -- LK: Do we need to handle this here ?
4827 END Propagate_Change_Header;
4828
4829 FUNCTION Inventory_Status_Control_Level
4830 RETURN NUMBER
4831 IS
4832 CURSOR c_status_control_attribute IS
4833 SELECT control_level
4834 FROM MTL_ITEM_ATTRIBUTES
4835 WHERE ATTRIBUTE_NAME = 'MTL_SYSTEM_ITEMS.INVENTORY_ITEM_STATUS_CODE';
4836 BEGIN
4837
4838 IF G_STATUS_CONTROL_LEVEL IS NULL
4839 THEN
4840 OPEN c_status_control_attribute;
4841 FETCH c_status_control_attribute INTO G_STATUS_CONTROL_LEVEL;
4842 CLOSE c_status_control_attribute;
4843 END IF;
4844 RETURN G_STATUS_CONTROL_LEVEL;
4845
4846 END Inventory_Status_Control_Level;
4847
4848
4849 PROCEDURE Propagate_Revised_Item (
4850 p_revised_item_sequence_id IN NUMBER
4851 , p_change_id IN NUMBER
4852 , p_change_notice IN VARCHAR2
4853 , p_organization_code IN VARCHAR2
4854 , p_organization_id IN NUMBER
4855 , p_local_organization_code IN VARCHAR2
4856 , p_local_organization_id IN NUMBER
4857 , p_commit IN VARCHAR2
4858 , x_Return_Status OUT NOCOPY VARCHAR2
4859 ) IS
4860
4861 l_transfer_item_enable NUMBER;
4862 l_error_logged NUMBER;
4863 --l_attach_error_logged NUMBER;
4864 l_sourcing_rules_exists NUMBER;
4865 --l_propagated_rev_items_tbl Prop_Rev_Items_Tbl_Type;
4866 --l_prop_rev_items_count NUMBER;
4867 l_propagate_revised_item NUMBER;
4868 l_parent_revised_item_name mtl_system_items_vl.concatenated_segments%TYPE;
4869 l_use_up_plan_name mrp_bom_plan_name_lov_v.plan_name%TYPE;
4870 l_revised_item_number mtl_system_items_vl.concatenated_segments%TYPE;
4871 l_use_up_item_name mtl_system_items_vl.concatenated_segments%TYPE;
4872 l_revised_item_name mtl_system_items_vl.concatenated_segments%TYPE;
4873 l_new_item_revision mtl_item_revisions.revision%TYPE;
4874 l_new_struc_revision VARCHAR2(3);
4875 l_current_struc_revision VARCHAR2(3);
4876 l_from_end_item_name mtl_system_items_vl.concatenated_segments%TYPE;
4877 l_from_end_item_alternate VARCHAR2(10);
4878 l_from_end_item_revision mtl_item_revisions.revision%TYPE;
4879 l_current_local_revision_id NUMBER;
4880 l_current_local_revision VARCHAR2(3);
4881 l_current_lifecycle_seq NUMBER;
4882 l_current_lifecycle_name VARCHAR2(150);
4883 l_new_lifecycle_seq NUMBER;
4884 l_new_lifecycle_name VARCHAR2(150);
4885 l_new_revision_exists NUMBER;
4886 l_status_master_controlled NUMBER;
4887 l_sql_stmt VARCHAR2(2000);
4888 l_revised_item_count NUMBER := 1;
4889 l_local_bill_sequence_id NUMBER;
4890 l_rev_description mtl_item_revisions.description%type;
4891 l_rev_label mtl_item_revisions.revision_label%type; -- Fixed bug10255737, can update revision label correctly
4892 l_structure_exists_flag NUMBER;
4893 l_rev_item_status_type NUMBER;
4894 l_new_item_revision_exists NUMBER;
4895 l_from_end_item_minor_rev VARCHAR2(3);
4896 l_disable_revision NUMBER;
4897 l_propagate_strc_changes NUMBER;
4898 l_structure_type_name VARCHAR2(80);
4899 l_local_line_rev_id NUMBER;
4900
4901 l_attach_return_status VARCHAR2(1);
4902 l_Mesg_token_Tbl Error_Handler.Mesg_Token_Tbl_Type;
4903 l_bo_mesg_token_tbl Error_Handler.Mesg_Token_Tbl_Type;
4904 l_return_status VARCHAR2(1);
4905 l_err_text VARCHAR2(2000);
4906 l_Token_Tbl Error_Handler.Token_Tbl_Type;
4907 l_msg_count NUMBER;
4908
4909 l_eco_rec Eng_Eco_Pub.Eco_Rec_Type;
4910 l_change_lines_tbl Eng_Eco_Pub.Change_Line_Tbl_Type;
4911 l_eco_revision_tbl Eng_Eco_Pub.Eco_Revision_Tbl_Type;
4912 l_revised_item_tbl Eng_Eco_Pub.Revised_Item_Tbl_Type;
4913 l_rev_component_tbl Bom_Bo_Pub.Rev_Component_Tbl_Type;
4914 l_sub_component_tbl Bom_Bo_Pub.Sub_Component_Tbl_Type;
4915 l_ref_designator_tbl Bom_Bo_Pub.Ref_Designator_Tbl_Type;
4916 l_rev_operation_tbl Bom_Rtg_Pub.Rev_Operation_Tbl_Type;
4917 l_rev_op_resource_tbl Bom_Rtg_Pub.Rev_Op_Resource_Tbl_Type;
4918 l_rev_sub_resource_tbl Bom_Rtg_Pub.Rev_Sub_Resource_Tbl_Type;
4919 l_revised_item_unexp_rec Eng_Eco_Pub.Rev_Item_Unexposed_Rec_Type;
4920
4921 CURSOR c_revised_items_data IS
4922 SELECT use_up_item_id
4923 , revised_item_id
4924 , enable_item_in_local_org
4925 , transfer_or_copy
4926 , transfer_or_copy_item
4927 , alternate_bom_designator
4928 , revised_item_sequence_id
4929 FROM eng_revised_items
4930 WHERE revised_item_sequence_id = p_revised_item_sequence_id;
4931
4932 l_ris c_revised_items_data%ROWTYPE;
4933
4934 -- The following cursor will return only one revised item
4935 -- Changes to design of handling component changes
4936 -- will have to be done otherwise
4937 CURSOR c_rev_items_all (cp_revised_item_sequence_id NUMBER)
4938 IS
4939 SELECT *
4940 FROM eng_revised_items
4941 WHERE (revised_item_sequence_id = cp_revised_item_sequence_id)
4942 /*OR parent_revised_item_seq_id = cp_revised_item_sequence_id)
4943 AND revised_item_sequence_id NOT IN
4944 (SELECT revised_item_sequence_id
4945 FROM eng_revised_items
4946 WHERE parent_revised_item_seq_id = cp_revised_item_sequence_id
4947 AND (transfer_or_copy = 'L' OR transfer_or_copy = 'O')
4948 AND 1 = l_status_master_controlled
4949 )
4950 ORDER BY parent_revised_item_seq_id DESC*/;
4951
4952 -- Cursor to pick up Revised component records for the top organization for
4953 -- the given change notice which have the ACD_type of Disable and have been
4954 -- implemented from eng_revised_items table. These records are not present in
4955 -- bom_inventory_components table hence this extra cursor.
4956
4957 CURSOR c_plm_rev_comps_disable (cp_revised_item_sequence_id NUMBER)
4958 IS
4959 SELECT *
4960 FROM eng_revised_components erc
4961 WHERE erc.change_notice = p_change_notice
4962 AND erc.ACD_TYPE = 3
4963 AND erc.revised_item_sequence_id = cp_revised_item_sequence_id
4964 AND NOT EXISTS (SELECT 1 FROM eng_change_propagation_maps ecpm
4965 WHERE ecpm.change_id = p_change_id
4966 AND ecpm.local_organization_id = p_local_organization_id
4967 AND ecpm.revised_line_type = Eng_Propagation_Log_Util.G_REV_LINE_CMP_CHG
4968 AND ecpm.revised_line_id1 = erc.component_sequence_id
4969 AND ecpm.entity_action_status IN (3,4))
4970 AND EXISTS (SELECT 1 FROM eng_revised_items eri
4971 WHERE eri.revised_item_sequence_id = erc.revised_item_sequence_id
4972 AND eri.bill_sequence_id = erc.bill_sequence_id);
4973
4974
4975 -- Cursor to Pick all Revised Component Items for the Top Organization for the
4976 -- given Change Notice
4977
4978 CURSOR c_plm_rev_comps (cp_revised_item_sequence_id NUMBER) IS
4979 SELECT *
4980 FROM bom_components_b bcb
4981 WHERE change_notice = p_change_notice
4982 AND revised_item_sequence_id = cp_revised_item_sequence_id
4983 AND NOT EXISTS (SELECT 1 FROM eng_change_propagation_maps ecpm
4984 WHERE ecpm.change_id = p_change_id
4985 AND ecpm.local_organization_id = p_local_organization_id
4986 AND ecpm.revised_line_type = Eng_Propagation_Log_Util.G_REV_LINE_CMP_CHG
4987 AND ecpm.revised_line_id1 = bcb.component_sequence_id
4988 AND ecpm.entity_action_status IN (3,4))
4989 AND EXISTS (SELECT 1 FROM eng_revised_items eri
4990 WHERE eri.revised_item_sequence_id = bcb.revised_item_sequence_id
4991 AND eri.bill_sequence_id = bcb.bill_sequence_id);
4992
4993 BEGIN
4994 Eng_Propagation_Log_Util.Debug_Log(G_LOG_PROC, 'Propagate_Revised_Item.BEGIN');
4995 -- Step 1:
4996 -- Initialize
4997 l_propagate_revised_item := G_VAL_TRUE;
4998 l_transfer_item_enable := G_VAL_FALSE;
4999 l_sourcing_rules_exists := 2;
5000 -- Set Savepoint
5001 SAVEPOINT BEGIN_REV_ITEM_PROCESSING;
5002 -- Error Handling
5003 l_return_status := FND_API.G_RET_STS_SUCCESS;
5004 l_error_logged := G_VAL_FALSE;
5005 l_attach_return_status := FND_API.G_RET_STS_SUCCESS;
5006
5007 Error_Handler.Initialize;
5008
5009 IF (l_ris.enable_item_in_local_org = 'Y')
5010 THEN
5011 l_transfer_item_enable := G_VAL_TRUE;
5012 FND_FILE.PUT_LINE(FND_FILE.LOG, ' Enable item in local org .. ' || l_transfer_item_enable);
5013 END IF;
5014 l_status_master_controlled := Inventory_Status_Control_Level;
5015
5016 OPEN c_revised_items_data;
5017 FETCH c_revised_items_data INTO l_ris;
5018
5019 -- Step 2:
5020 -- Preprocess Revised Item
5021 -- If Errors then RAISE EXC_EXP_SKIP_OBJECT
5022 Check_Revised_Item_Errors (
5023 p_change_notice => p_change_notice
5024 , p_global_org_id => p_organization_id
5025 , p_local_org_id => p_local_organization_id
5026 , p_rev_item_seq_id => p_revised_item_sequence_id
5027 , p_revised_item_id => l_ris.revised_item_id
5028 , p_use_up_item_id => l_ris.use_up_item_id
5029 , p_transfer_item_enable => l_transfer_item_enable
5030 , p_transfer_or_copy => l_ris.transfer_or_copy
5031 , p_transfer_or_copy_item => l_ris.transfer_or_copy_item
5032 , p_status_master_controlled => l_status_master_controlled
5033 , x_error_logged => l_error_logged
5034 , x_mesg_token_tbl => l_mesg_token_tbl
5035 , x_propagate_strc_changes => l_propagate_strc_changes
5036 , x_sourcing_rules_exists => l_sourcing_rules_exists
5037 , x_revised_item_name => l_parent_revised_item_name
5038 );
5039 IF l_error_logged = G_VAL_TRUE
5040 THEN
5041 RAISE EXC_EXP_SKIP_OBJECT;
5042 END IF;
5043
5044 -- Step 3:
5045 -- Populating the l_propagated_rev_items_tbl
5046 --l_prop_rev_items_count := l_prop_rev_items_count + 1;
5047 --l_propagated_rev_items_tbl(l_prop_rev_items_count) := p_revised_item_sequence_id;
5048 -- Step 4: Processing
5049 -- Now get all revised items for this revised item sequence id.
5050 -- This will be used only when the functionality of parent_revised_item_seq_id
5051 -- gets defined. Currently not been scoped.
5052 FOR ri in c_rev_items_all (p_revised_item_sequence_id)
5053 LOOP
5054 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Start revised item processing p_revised_item_sequence_id'|| p_revised_item_sequence_id);
5055 IF (l_sourcing_rules_exists = 2
5056 OR (l_sourcing_rules_exists = 1 AND ri.parent_revised_item_seq_id IS NULL)
5057 OR (l_sourcing_rules_exists = 1 AND ri.parent_revised_item_seq_id IS NOT NULL AND ri.transfer_or_copy IS NOT NULL))
5058 THEN
5059 -- get the item name, use up item name and plan name
5060 SELECT concatenated_segments
5061 INTO l_revised_item_number
5062 FROM mtl_system_items_b_kfv
5063 WHERE inventory_item_id = ri.revised_item_id
5064 AND organization_id = p_local_organization_id;
5065
5066 l_use_up_item_name := null;
5067 IF (ri.use_up_item_id IS NOT NULL)
5068 THEN
5069 SELECT concatenated_segments
5070 INTO l_use_up_item_name
5071 FROM mtl_system_items_b_kfv
5072 WHERE inventory_item_id = ri.use_up_item_id
5073 AND organization_id = p_local_organization_id;
5074 END IF;
5075
5076 IF (ri.use_up_plan_name IS NOT NULL)
5077 THEN
5078 BEGIN
5079 SELECT pl.plan_name
5080 INTO l_use_up_plan_name
5081 FROM mrp_bom_plan_name_lov_v pl
5082 WHERE pl.item_id = ri.use_up_item_id
5083 AND pl.organization_id = p_local_organization_id
5084 AND pl.plan_name = ri.use_up_plan_name;
5085 EXCEPTION
5086 WHEN NO_DATA_FOUND THEN
5087 l_use_up_plan_name := NULL;
5088 END;
5089 ELSE
5090 l_use_up_plan_name := NULL;
5091 END IF;
5092
5093 /* Get current and new item revisions of the item in the local org */
5094 BEGIN
5095 SELECT BOM_REVISIONS.get_item_revision_fn('ALL', 'ALL', p_local_organization_id,
5096 ri.revised_item_id, SYSDATE) revision ,
5097 BOM_REVISIONS.get_item_revision_id_fn('ALL', 'ALL', p_local_organization_id,
5098 ri.revised_item_id, SYSDATE) revision_id
5099 INTO l_current_local_revision, l_current_local_revision_id
5100 FROM dual;
5101 EXCEPTION
5102 WHEN NO_DATA_FOUND THEN
5103 l_current_local_revision := NULL;
5104 END;
5105
5106 l_new_item_revision := ri.new_item_revision;
5107
5108 IF (l_new_item_revision IS NOT NULL AND l_new_item_revision <> FND_API.G_MISS_CHAR)
5109 THEN
5110 BEGIN
5111 select 1
5112 into l_new_revision_exists
5113 from mtl_item_revisions
5114 where revision = l_new_item_revision
5115 and inventory_item_id = ri.revised_item_id
5116 and organization_id = p_local_organization_id;
5117 EXCEPTION
5118 WHEN NO_DATA_FOUND THEN
5119 l_new_revision_exists := 0;
5120 END;
5121
5122 IF ((l_new_revision_exists = 1 )
5123 OR (l_current_local_revision IS NOT NULL AND
5124 l_new_revision_exists = 0 AND
5125 l_current_local_revision > l_new_item_revision))
5126 THEN
5127 l_new_item_revision := NULL;
5128 END IF;
5129
5130 ELSE
5131 l_new_item_revision := NULL;
5132 END IF;
5133
5134 IF (FND_PROFILE.VALUE('ENG:ECO_REVISED_ITEM_REVISION') = '1') AND
5135 (l_new_item_revision IS NULL OR l_new_item_revision = FND_API.G_MISS_CHAR) AND
5136 ri.new_item_revision IS NOT NULL
5137 THEN
5138 l_token_tbl.delete;
5139
5140 l_token_tbl(1).token_name := 'REVISION';
5141 l_token_tbl(1).token_value := ri.new_item_revision;
5142 Error_Handler.Add_Error_Token
5143 ( p_Message_Name => 'ENG_NEW_REV_PROP_MISS'
5144 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5145 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5146 , p_Token_Tbl => l_Token_Tbl);
5147
5148 RAISE EXC_EXP_SKIP_OBJECT;
5149 END IF;
5150
5151 /* Get current and new item revisions of the structure in the local org */
5152
5153 l_new_struc_revision := ri.new_structure_revision;
5154 l_current_struc_revision := NULL;
5155
5156
5157 IF (ri.CURRENT_STRUCTURE_REV_ID IS NOT NULL)
5158 THEN
5159 select bill_sequence_id
5160 into l_local_bill_sequence_id
5161 FROM BOM_BILL_OF_MATERIALS
5162 WHERE assembly_item_id = ri.revised_item_id
5163 AND organization_id = p_local_organization_id
5164 AND nvl(alternate_bom_designator, 'PRIMARY') = nvl(ri.alternate_bom_designator, 'PRIMARY');
5165
5166 l_current_struc_revision := NULL;
5167 /* not supported in 11.5.10
5168 BEGIN
5169 select bsr.revision
5170 into l_current_struc_revision
5171 from should use minor revision table bsr
5172 where bsr.bill_sequence_id = l_local_bill_sequence_id
5173 and bsr.object_revision_id = l_current_local_revision_id
5174 and bsr.effective_date = (select max(effective_date)
5175 from should use minor revision table
5176 where structure_revision_id = bsr.structure_revision_id
5177 and bsr.effective_date < sysdate);
5178 EXCEPTION
5179 WHEN NO_DATA_FOUND THEN
5180 l_current_struc_revision := NULL;
5181 END;*/
5182 IF (l_new_struc_revision IS NOT NULL AND l_new_struc_revision <> FND_API.G_MISS_CHAR)
5183 THEN
5184 l_new_revision_exists := 0;
5185 /* not supported in 11.5.10
5186 BEGIN
5187 select 1
5188 into l_new_revision_exists
5189 from should use minor revision table
5190 where bill_sequence_id = l_local_bill_sequence_id
5191 and object_revision_id = l_current_local_revision_id
5192 and revision = l_new_struc_revision;
5193
5194 EXCEPTION
5195 WHEN NO_DATA_FOUND THEN
5196 l_new_revision_exists := 0;
5197 END;*/
5198
5199 IF ((l_new_revision_exists = 1 )
5200 OR (l_current_struc_revision IS NOT NULL AND l_new_revision_exists = 0
5201 AND l_current_struc_revision > l_new_struc_revision))
5202 THEN
5203 l_new_struc_revision := NULL;
5204 END IF;
5205 ELSE
5206 l_new_struc_revision := NULL;
5207 END IF;
5208 END IF;
5209
5210 /* get the from end item details */
5211 IF (ri.from_end_item_rev_id IS NOT NULL)
5212 THEN
5213 select msikfv.concatenated_segments, mir.revision
5214 into l_from_end_item_name, l_from_end_item_revision
5215 from mtl_system_items_b_kfv msikfv, mtl_item_revisions mir
5216 where mir.revision_id = ri.from_end_item_rev_id
5217 and mir.inventory_item_id = msikfv.inventory_item_id
5218 and mir.organization_id = msikfv.organization_id;
5219 END IF;
5220
5221 /* not supported in 11.5.10
5222 IF (ri.from_end_item_strc_rev_id IS NOT NULL)
5223 THEN
5224 select bsr.revision, bbm.alternate_bom_designator
5225 into l_from_end_item_minor_rev, l_from_end_item_alternate
5226 from should use minor revision table bsr, bom_bill_of_materials bbm
5227 where bsr.structure_revision_id = ri.from_end_item_strc_rev_id
5228 and bsr.bill_sequence_id = bbm.bill_sequence_id;
5229 END IF;*/
5230
5231 /* Get the current and new item lifecycle phases of the item in the local org */
5232 l_current_lifecycle_name := NULL;
5233 l_new_lifecycle_name := NULL;
5234
5235 BEGIN
5236 -- Bug 3311072: Made the query dynamic
5237 -- Modified By LKASTURI
5238 l_sql_stmt := 'SELECT LP.DISPLAY_SEQUENCE, LP.NAME '
5239 || 'FROM pa_ego_phases_v LP, MTL_System_items_vl msiv '
5240 || 'WHERE LP.PROJ_ELEMENT_ID = msiv.CURRENT_PHASE_ID '
5241 || 'AND msiv.INVENTORY_ITEM_ID = :1 '
5242 || 'AND msiv.ORGANIZATION_ID = :2 ';
5243 -- End Changes 3311072
5244 EXECUTE IMMEDIATE l_sql_stmt
5245 INTO l_current_lifecycle_seq , l_current_lifecycle_name
5246 USING ri.revised_item_id, p_local_organization_id;
5247
5248 EXCEPTION
5249 WHEN NO_DATA_FOUND THEN
5250 l_current_lifecycle_seq := NULL;
5251 l_current_lifecycle_name := NULL;
5252 END;
5253
5254 IF (ri.transfer_or_copy IS NOT NULL and ri.transfer_or_copy <> 'C' AND l_status_master_controlled = 2)
5255 THEN
5256 IF (ri.new_lifecycle_state_id IS NOT NULL)
5257 THEN
5258 -- Bug 3311072: Made the query dynamic
5259 -- Modified By LKASTURI
5260 l_sql_stmt := 'SELECT LP.DISPLAY_SEQUENCE, LP.NAME '
5261 || 'FROM pa_ego_phases_v LP '
5262 || 'WHERE LP.PROJ_ELEMENT_ID = :1 ';
5263 -- End Changes 3311072
5264
5265 EXECUTE IMMEDIATE l_sql_stmt
5266 INTO l_new_lifecycle_seq , l_new_lifecycle_name
5267 USING ri.new_lifecycle_state_id;
5268
5269 ELSE
5270 l_new_lifecycle_seq := l_current_lifecycle_seq;
5271 l_new_lifecycle_name := l_current_lifecycle_name;
5272 END IF;
5273 END IF;
5274
5275 --Defaulting the structure type name (propagation)
5276 l_structure_type_name := NULL;
5277 BEGIN
5278 SELECT BSTV.structure_type_name
5279 INTO l_structure_type_name
5280 FROM bom_structures_b BSB,
5281 bom_structure_types_vl BSTV
5282 WHERE BSB.structure_type_id = BSTV.structure_type_id
5283 AND BSB.bill_sequence_id = ri.bill_sequence_id;
5284
5285 EXCEPTION
5286 WHEN NO_DATA_FOUND THEN
5287 NULL;
5288 END;
5289
5290
5291 l_revised_item_tbl(l_revised_item_count).eco_name := ri.change_notice;
5292 l_revised_item_tbl(l_revised_item_count).organization_code := p_local_organization_code;
5293 l_revised_item_tbl(l_revised_item_count).revised_item_name := l_revised_item_number;
5294 IF (l_new_item_revision IS NULL)
5295 THEN
5296 l_revised_item_tbl(l_revised_item_count).new_revised_item_revision := NULL;
5297 ELSE
5298 l_revised_item_tbl(l_revised_item_count).new_revised_item_revision := l_new_item_revision;
5299 SELECT DESCRIPTION, revision_label
5300 INTO l_rev_description, l_rev_label
5301 FROM mtl_item_revisions
5302 WHERE inventory_item_id = ri.revised_item_id
5303 AND organization_id = ri.organization_id
5304 AND revision = l_new_item_revision ;
5305 l_revised_item_tbl(l_revised_item_count).New_Revised_Item_Rev_Desc := l_rev_description;
5306 l_revised_item_tbl(l_revised_item_count).New_Revision_Label := l_rev_label; -- Fixed bug10255737, can update revision label correctly
5307 l_revised_item_tbl(l_revised_item_count).Updated_Revised_Item_Revision := NULL;
5308 END IF;
5309 l_revised_item_tbl(l_revised_item_count).start_effective_date := ri.scheduled_date;
5310 l_revised_item_tbl(l_revised_item_count).New_Effective_Date := NULL;
5311 l_revised_item_tbl(l_revised_item_count).alternate_bom_code := ri.alternate_bom_designator;
5312 l_revised_item_tbl(l_revised_item_count).status_type := l_rev_item_status_type;
5313 l_revised_item_tbl(l_revised_item_count).mrp_active := ri.mrp_active;
5314 l_revised_item_tbl(l_revised_item_count).earliest_effective_date := ri.early_schedule_date;
5315 l_revised_item_tbl(l_revised_item_count).use_up_item_name := l_use_up_item_name;
5316 l_revised_item_tbl(l_revised_item_count).use_up_plan_name := l_use_up_plan_name;
5317 l_revised_item_tbl(l_revised_item_count).Requestor := NULL;
5318 l_revised_item_tbl(l_revised_item_count).disposition_type := ri.disposition_type;
5319 l_revised_item_tbl(l_revised_item_count).update_wip := ri.update_wip;
5320 l_revised_item_tbl(l_revised_item_count).cancel_comments := ri.cancel_comments;
5321 --l_revised_item_tbl(l_revised_item_count).cfm_routing_flag := ri.cfm_routing_flag;
5322 l_revised_item_tbl(l_revised_item_count).ctp_flag := ri.ctp_flag;
5323 l_revised_item_tbl(l_revised_item_count).return_status := NULL;
5324 l_revised_item_tbl(l_revised_item_count).change_description := ri.descriptive_text;
5325 l_revised_item_tbl(l_revised_item_count).Attribute_category := ri.Attribute_category;
5326 l_revised_item_tbl(l_revised_item_count).attribute1 := ri.attribute1;
5327 l_revised_item_tbl(l_revised_item_count).attribute2 := ri.attribute2;
5328 l_revised_item_tbl(l_revised_item_count).attribute3 := ri.attribute3;
5329 l_revised_item_tbl(l_revised_item_count).attribute4 := ri.attribute4;
5330 l_revised_item_tbl(l_revised_item_count).attribute5 := ri.attribute5;
5331 l_revised_item_tbl(l_revised_item_count).attribute6 := ri.attribute6;
5332 l_revised_item_tbl(l_revised_item_count).attribute7 := ri.attribute7;
5333 l_revised_item_tbl(l_revised_item_count).attribute8 := ri.attribute8;
5334 l_revised_item_tbl(l_revised_item_count).attribute9 := ri.attribute9;
5335 l_revised_item_tbl(l_revised_item_count).attribute10 := ri.attribute10;
5336 l_revised_item_tbl(l_revised_item_count).attribute11 := ri.attribute11;
5337 l_revised_item_tbl(l_revised_item_count).attribute12 := ri.attribute12;
5338 l_revised_item_tbl(l_revised_item_count).attribute13 := ri.attribute13;
5339 l_revised_item_tbl(l_revised_item_count).attribute14 := ri.attribute14;
5340 l_revised_item_tbl(l_revised_item_count).attribute15 := ri.attribute15;
5341 l_revised_item_tbl(l_revised_item_count).From_End_Item_Unit_Number := ri.From_End_Item_Unit_Number;
5342 l_revised_item_tbl(l_revised_item_count).New_From_End_Item_Unit_Number := NULL;
5343 l_revised_item_tbl(l_revised_item_count).Original_System_Reference := ri.Original_System_Reference;
5344 -- lkasturi: new columns in 11.5.10 changes
5345
5346 l_revised_item_tbl(l_revised_item_count).Transfer_Or_Copy := ri.transfer_or_copy;
5347 l_revised_item_tbl(l_revised_item_count).Transfer_OR_Copy_Item := ri.transfer_or_copy_item;
5348 l_revised_item_tbl(l_revised_item_count).Transfer_OR_Copy_Bill := ri.transfer_or_copy_bill;
5349 l_revised_item_tbl(l_revised_item_count).Copy_To_Item := ri.Copy_To_Item;
5350 l_revised_item_tbl(l_revised_item_count).Copy_To_Item_Desc := ri.Copy_To_Item_Desc;
5351
5352 l_revised_item_tbl(l_revised_item_count).parent_revised_item_name := l_parent_revised_item_name;
5353 l_revised_item_tbl(l_revised_item_count).parent_alternate_name := l_ris.alternate_bom_designator;
5354
5355 l_revised_item_tbl(l_revised_item_count).selection_option := ri.selection_option;
5356 l_revised_item_tbl(l_revised_item_count).selection_date := ri.selection_date;
5357 l_revised_item_tbl(l_revised_item_count).selection_unit_number := ri.selection_unit_number;
5358 l_revised_item_tbl(l_revised_item_count).current_lifecycle_phase_name := l_current_lifecycle_name;
5359 l_revised_item_tbl(l_revised_item_count).new_lifecycle_phase_name := l_new_lifecycle_name;
5360
5361 l_revised_item_tbl(l_revised_item_count).enable_item_in_local_org := ri.enable_item_in_local_org;
5362 l_revised_item_tbl(l_revised_item_count).new_structure_revision := l_new_struc_revision;
5363 l_revised_item_tbl(l_revised_item_count).current_structure_rev_name := l_current_struc_revision;
5364
5365 l_revised_item_tbl(l_revised_item_count).plan_level := ri.plan_level;
5366 l_revised_item_tbl(l_revised_item_count).from_end_item_name := l_from_end_item_name;
5367 l_revised_item_tbl(l_revised_item_count).FROM_END_ITEM_ALTERNATE := l_from_end_item_alternate;
5368 l_revised_item_tbl(l_revised_item_count).from_end_item_revision := l_from_end_item_revision;
5369 l_revised_item_tbl(l_revised_item_count).from_end_item_strc_rev := l_from_end_item_minor_rev;
5370
5371 -- lkasturi: new columns in 11.5.10 end changes
5372 l_revised_item_tbl(l_revised_item_count).transaction_type := 'CREATE';
5373 l_revised_item_tbl(l_revised_item_count).structure_type_name := l_structure_type_name;
5374
5375 Eng_Eco_Pvt.Process_Rev_Item(
5376 p_validation_level => FND_API.G_VALID_LEVEL_FULL
5377 , p_change_notice => p_change_notice
5378 , p_organization_id => p_local_organization_id
5379 , I => l_revised_item_count
5380 , p_revised_item_rec => l_revised_item_tbl(l_revised_item_count)
5381 , p_rev_component_tbl => l_rev_component_tbl
5382 , p_ref_designator_tbl => l_ref_designator_tbl
5383 , p_sub_component_tbl => l_sub_component_tbl
5384 , p_rev_operation_tbl => l_rev_operation_tbl
5385 , p_rev_op_resource_tbl => l_rev_op_resource_tbl
5386 , p_rev_sub_resource_tbl => l_rev_sub_resource_tbl
5387 , x_revised_item_tbl => l_revised_item_tbl
5388 , x_rev_component_tbl => l_rev_component_tbl
5389 , x_ref_designator_tbl => l_ref_designator_tbl
5390 , x_sub_component_tbl => l_sub_component_tbl
5391 , x_rev_operation_tbl => l_rev_operation_tbl
5392 , x_rev_op_resource_tbl => l_rev_op_resource_tbl
5393 , x_rev_sub_resource_tbl => l_rev_sub_resource_tbl
5394 , x_revised_item_unexp_rec => l_revised_item_unexp_rec
5395 , x_Mesg_Token_Tbl => l_bo_mesg_token_tbl -- Using another message token table as these are logged by BO itself
5396 , x_return_status => l_return_status
5397 , x_disable_revision => l_disable_revision
5398 );
5399
5400 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'After processing revised item through BO return status is '||l_return_status);
5401 IF l_return_status <> FND_API.G_RET_STS_SUCCESS
5402 THEN
5403 RAISE EXC_EXP_SKIP_OBJECT;
5404 END IF;
5405
5406 IF (l_sourcing_rules_exists = 2 AND l_propagate_strc_changes = G_VAL_TRUE)
5407 THEN
5408 FOR rcd in c_plm_rev_comps_disable(p_revised_item_sequence_id)
5409 LOOP
5410 Propagate_Revised_Component (
5411 p_component_sequence_id => rcd.component_sequence_id
5412 , p_revised_item_sequence_id => rcd.revised_item_sequence_id
5413 , p_change_id => p_change_id
5414 , p_revised_item_rec => l_revised_item_tbl(l_revised_item_count)
5415 , p_revised_item_unexp_rec => l_revised_item_unexp_rec
5416 , p_local_organization_id => p_local_organization_id
5417 , x_Return_Status => l_return_status
5418 );
5419 IF l_return_status <> FND_API.G_RET_STS_SUCCESS
5420 THEN
5421 l_propagate_revised_item := G_VAL_FALSE;
5422 END IF;
5423 END LOOP;
5424
5425 FOR rc in c_plm_rev_comps(p_revised_item_sequence_id)
5426 LOOP
5427 Propagate_Revised_Component (
5428 p_component_sequence_id => rc.component_sequence_id
5429 , p_revised_item_sequence_id => rc.revised_item_sequence_id
5430 , p_change_id => p_change_id
5431 , p_revised_item_rec => l_revised_item_tbl(l_revised_item_count)
5432 , p_revised_item_unexp_rec => l_revised_item_unexp_rec
5433 , p_local_organization_id => p_local_organization_id
5434 , x_Return_Status => l_return_status
5435 );
5436 IF l_return_status <> FND_API.G_RET_STS_SUCCESS
5437 THEN
5438 l_propagate_revised_item := G_VAL_FALSE;
5439 END IF;
5440 END LOOP;
5441 END IF;
5442
5443 -- Getting the revision id for the items attachment lines context.
5444 -- This is the revision id to which the revision specific lines would be added
5445 BEGIN
5446 select revision_id
5447 into l_local_line_rev_id
5448 from mtl_item_revisions
5449 where inventory_item_id = (select revised_item_id
5450 from eng_revised_items
5451 where revised_item_sequence_id = l_revised_item_unexp_rec.revised_item_sequence_id)
5452 and revised_item_sequence_id = l_revised_item_unexp_rec.revised_item_sequence_id;
5453 EXCEPTION
5454 WHEN OTHERS THEN
5455 --this will be called for item attachment changes with default revision
5456 l_local_line_rev_id := nvl(l_revised_item_unexp_rec.new_item_revision_id,
5457 l_revised_item_unexp_rec.current_item_revision_id);
5458 END;
5459
5460
5461 Validate_Attach_Lines(
5462 p_change_id => p_change_id
5463 , p_rev_item_sequence_id => p_revised_item_sequence_id
5464 , p_global_organization_id => p_organization_id
5465 , p_global_new_item_rev => ri.new_item_revision
5466 , p_global_current_item_rev_id => ri.current_item_revision_id
5467 , p_local_organization_id => p_local_organization_id
5468 , p_local_line_rev_id => l_local_line_rev_id
5469 , p_revised_item_rec => l_revised_item_tbl(l_revised_item_count)
5470 , p_revised_item_unexp_rec => l_revised_item_unexp_rec
5471 , x_return_status => l_attach_return_status
5472 , x_mesg_token_tbl => l_mesg_token_tbl
5473 );
5474
5475 IF l_attach_return_status <> FND_API.G_RET_STS_SUCCESS
5476 THEN
5477 l_propagate_revised_item := G_VAL_FALSE;
5478 END IF;
5479 IF l_propagate_revised_item = G_VAL_TRUE
5480 THEN
5481 Propagate_Attach_Lines(
5482 p_change_id => p_change_id
5483 , p_revised_item_sequence_id => p_revised_item_sequence_id
5484 , p_revised_item_rec => l_revised_item_tbl(l_revised_item_count)
5485 , p_revised_item_unexp_rec => l_revised_item_unexp_rec
5486 , p_local_organization_id => p_local_organization_id
5487 , p_local_line_rev_id => l_local_line_rev_id
5488 , x_Return_Status => l_attach_return_status
5489 , x_mesg_token_tbl => l_mesg_token_tbl
5490 );
5491 IF l_attach_return_status <> FND_API.G_RET_STS_SUCCESS
5492 THEN
5493 l_propagate_revised_item := G_VAL_FALSE;
5494 END IF;
5495 END IF;
5496 IF l_propagate_revised_item = G_VAL_FALSE
5497 THEN
5498 RAISE EXC_EXP_SKIP_OBJECT;
5499 END IF;
5500
5501 l_revised_item_count := l_revised_item_count + 1;
5502 END IF;
5503
5504 END LOOP;
5505
5506 -- Commit the changes if the api hasnt exit so far
5507 IF (p_commit = FND_API.G_TRUE)
5508 THEN
5509 COMMIT;
5510 END IF;
5511 Eco_Error_Handler.Log_Error(
5512 p_error_status => l_return_status
5513 , p_mesg_token_tbl => l_mesg_token_tbl
5514 , p_error_scope => Error_Handler.G_SCOPE_RECORD
5515 , p_error_level => Eco_Error_Handler.G_RI_LEVEL
5516 , x_eco_rec => l_eco_rec
5517 , x_eco_revision_tbl => l_eco_revision_tbl
5518 , x_change_line_tbl => l_change_lines_tbl -- Eng Change
5519 , x_revised_item_tbl => l_revised_item_tbl
5520 , x_rev_component_tbl => l_rev_component_tbl
5521 , x_ref_designator_tbl => l_ref_designator_tbl
5522 , x_sub_component_tbl => l_sub_component_tbl
5523 , x_rev_operation_tbl => l_rev_operation_tbl --L1
5524 , x_rev_op_resource_tbl => l_rev_op_resource_tbl --L1
5525 , x_rev_sub_resource_tbl => l_rev_sub_resource_tbl --L1
5526 );
5527 Eng_Propagation_Log_Util.add_entity_map(
5528 p_change_id => p_change_id
5529 , p_revised_item_sequence_id => p_revised_item_sequence_id
5530 , p_local_organization_id => p_local_organization_id
5531 , p_local_revised_item_seq_id => l_revised_item_unexp_rec.revised_item_sequence_id
5532 , p_entity_name => Eng_Propagation_Log_Util.G_ENTITY_REVISED_ITEM
5533 , p_entity_action_status => Eng_Propagation_Log_Util.G_PRP_PRC_STS_SUCCESS
5534 , p_bo_entity_identifier => 'RI'--Eco_Error_Handler.G_RI_LEVEL
5535 );
5536 CLOSE c_revised_items_data;
5537
5538 x_return_status := l_return_status;
5539
5540 Eng_Propagation_Log_Util.Debug_Log(G_LOG_PROC, 'Propagate_Revised_Item.END');
5541 EXCEPTION
5542 WHEN EXC_EXP_SKIP_OBJECT THEN
5543 IF c_revised_items_data%ISOPEN
5544 THEN
5545 CLOSE c_revised_items_data;
5546 End IF;
5547
5548 -- Set the return status
5549 l_return_status := FND_API.G_RET_STS_ERROR;
5550 -- Log any messages that have been logged with the additional error
5551 -- message into error handler
5552 Eco_Error_Handler.Log_Error(
5553 p_error_status => l_return_status
5554 , p_mesg_token_tbl => l_mesg_token_tbl
5555 , p_error_scope => Error_Handler.G_SCOPE_RECORD
5556 , p_error_level => Eco_Error_Handler.G_RI_LEVEL
5557 , p_other_message => 'ENG_PRP_REV_ITEM_ERR'
5558 , p_other_status => l_return_status
5559 , p_other_token_tbl => l_token_tbl
5560 , x_eco_rec => l_eco_rec
5561 , x_eco_revision_tbl => l_eco_revision_tbl
5562 , x_change_line_tbl => l_change_lines_tbl -- Eng Change
5563 , x_revised_item_tbl => l_revised_item_tbl
5564 , x_rev_component_tbl => l_rev_component_tbl
5565 , x_ref_designator_tbl => l_ref_designator_tbl
5566 , x_sub_component_tbl => l_sub_component_tbl
5567 , x_rev_operation_tbl => l_rev_operation_tbl --L1
5568 , x_rev_op_resource_tbl => l_rev_op_resource_tbl --L1
5569 , x_rev_sub_resource_tbl => l_rev_sub_resource_tbl --L1
5570 );
5571 Eng_Propagation_Log_Util.add_entity_map(
5572 p_change_id => p_change_id
5573 , p_revised_item_sequence_id => p_revised_item_sequence_id
5574 , p_local_organization_id => p_local_organization_id
5575 , p_entity_name => Eng_Propagation_Log_Util.G_ENTITY_REVISED_ITEM
5576 , p_entity_action_status => Eng_Propagation_Log_Util.G_PRP_PRC_STS_ERROR
5577 , p_bo_entity_identifier => 'RI'--Eco_Error_Handler.G_RI_LEVEL
5578 );
5579 x_return_status := l_return_status;
5580 --
5581 -- Rollback any changes that may have been made to the DB
5582 --
5583 ROLLBACK TO BEGIN_REV_ITEM_PROCESSING;
5584 Eng_Propagation_Log_Util.Debug_Log(G_LOG_PROC, 'Propagate_Revised_Item.END');
5585 WHEN OTHERS THEN
5586 IF c_revised_items_data%ISOPEN
5587 THEN
5588 CLOSE c_revised_items_data;
5589 End IF;
5590 -- Set the return status
5591 l_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5592 l_err_text := G_PKG_NAME || ' : (Revised Item Propagation) ' || substrb(SQLERRM,1,200);
5593
5594 Error_Handler.Add_Error_Token(
5595 p_Message_Name => NULL
5596 , p_Message_Text => l_Err_Text
5597 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5598 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5599 );
5600 -- Log any messages that have been logged with the additional error
5601 -- message into error handler
5602 Eco_Error_Handler.Log_Error(
5603 p_error_status => l_return_status
5604 , p_mesg_token_tbl => l_mesg_token_tbl
5605 , p_error_scope => Error_Handler.G_SCOPE_RECORD
5606 , p_error_level => Eco_Error_Handler.G_RI_LEVEL
5607 , p_other_message => 'ENG_PRP_REV_ITEM_ERR'
5608 , p_other_status => l_return_status
5609 , p_other_token_tbl => l_token_tbl
5610 , x_eco_rec => l_eco_rec
5611 , x_eco_revision_tbl => l_eco_revision_tbl
5612 , x_change_line_tbl => l_change_lines_tbl -- Eng Change
5613 , x_revised_item_tbl => l_revised_item_tbl
5614 , x_rev_component_tbl => l_rev_component_tbl
5615 , x_ref_designator_tbl => l_ref_designator_tbl
5616 , x_sub_component_tbl => l_sub_component_tbl
5617 , x_rev_operation_tbl => l_rev_operation_tbl --L1
5618 , x_rev_op_resource_tbl => l_rev_op_resource_tbl --L1
5619 , x_rev_sub_resource_tbl => l_rev_sub_resource_tbl --L1
5620 );
5621
5622 Eng_Propagation_Log_Util.add_entity_map(
5623 p_change_id => p_change_id
5624 , p_revised_item_sequence_id => p_revised_item_sequence_id
5625 , p_local_organization_id => p_local_organization_id
5626 , p_entity_name => Eng_Propagation_Log_Util.G_ENTITY_REVISED_ITEM
5627 , p_entity_action_status => Eng_Propagation_Log_Util.G_PRP_PRC_STS_ERROR
5628 , p_bo_entity_identifier => 'RI'--Eco_Error_Handler.G_RI_LEVEL
5629 );
5630 x_return_status := l_return_status;
5631 --
5632 -- Rollback any changes that may have been made to the DB
5633 --
5634 ROLLBACK TO BEGIN_REV_ITEM_PROCESSING;
5635 END Propagate_Revised_Item;
5636
5637 -- ****************************************************************** --
5638 -- API name : Propagate_ECO_PLM --
5639 -- Type : Private --
5640 -- Pre-reqs : None. --
5641 -- Procedure : Propagates the specified ECO --
5642 -- Parameters : --
5643 -- IN : p_api_version NUMBER Required --
5644 -- p_change_id VARCHAR2 Required --
5645 -- p_organization_id NUMBER Required --
5646 -- p_org_hierarchy_id VARCHAR2 --
5647 -- p_local_organization_id NUMBER := NULL --
5648 -- p_calling_api NUMBER := NULL --
5649 -- OUT : x_return_status VARCHAR2(1) --
5650 -- x_error_buf VARCHAR2(30) --
5651 -- Version : --
5652 -- Current version 1.0 --
5653 -- Initial version 1.0 --
5654 -- --
5655 -- Notes : --
5656 -- if org hierarchy id is -1 then the list of orgs --
5657 -- associated to the change are picked for propagation --
5658 -- if p_org_hierarchy_id is null, check that the value --
5659 -- local_organization_id has been specified --
5660 -- Validate that the local organization id either --
5661 -- belongs to the hierarchy or to the list of local --
5662 -- orgs of thesource change order --
5663 -- p_calling API is TTM then the change header --
5664 -- relation is checked first 'TRANSFERRED_TO' --
5665 -- ****************************************************************** --
5666
5667 PROCEDURE Propagate_ECO_PLM (
5668 p_api_version IN NUMBER := 1.0
5669 , x_error_buf OUT NOCOPY VARCHAR2
5670 , x_return_status OUT NOCOPY VARCHAR2
5671 , p_change_notice IN VARCHAR2
5672 , p_organization_id IN NUMBER
5673 , p_org_hierarchy_name IN VARCHAR2
5674 , p_local_organization_id IN NUMBER := NULL
5675 , p_calling_api IN VARCHAR2 := NULL
5676 ) IS
5677
5678 l_api_name CONSTANT VARCHAR2(30) := 'PROPAGATE_ECO_PLM';
5679 l_api_version CONSTANT NUMBER := 1.0;
5680
5681 l_org_code mtl_parameters.organization_code%TYPE;
5682 l_global_org_code mtl_parameters.organization_code%TYPE;
5683 l_global_change_id NUMBER;
5684 l_local_change_id NUMBER;
5685 -- this corresponds to the processing status that will have to be updated to the change
5686 l_top_entity_process_status NUMBER;
5687
5688 l_Mesg_Token_Tbl Error_Handler.Mesg_Token_Tbl_Type;
5689 l_return_status VARCHAR2(1);
5690
5691 -- Bug# 9498305
5692 l_propagated_to_chg_id NUMBER;
5693 l_ext_id_nextval NUMBER;
5694 -- Bug# 9498305 End
5695
5696 -- Bug# 9498305
5697 CURSOR c_extention_id_all (v_change_id NUMBER)
5698 IS
5699 SELECT EXTENSION_ID
5700 FROM ENG_CHANGES_EXT_B
5701 WHERE CHANGE_ID = v_change_id;
5702 -- Bug# 9498305 End
5703
5704 CURSOR c_fetch_org_code(cp_organization_id NUMBER) IS
5705 SELECT organization_code
5706 FROM mtl_parameters
5707 WHERE organization_id = cp_organization_id;
5708
5709 CURSOR c_change_header IS
5710 SELECT change_id
5711 FROM eng_engineering_changes
5712 WHERE change_notice = p_change_notice
5713 AND organization_id = p_organization_id;
5714 ---added Bug no 4327321 only revised items will get propagate.No transfer and copy items
5715 CURSOR c_prp_revised_item IS
5716 SELECT eri.revised_item_sequence_id
5717 FROM eng_revised_items eri
5718 WHERE eri.change_id = l_global_change_id
5719 AND transfer_or_copy is NULL
5720 AND NOT EXISTS
5721 (SELECT 1
5722 FROM eng_change_propagation_maps ecpm
5723 WHERE ecpm.change_id = eri.change_id
5724 AND ecpm.local_organization_id = p_local_organization_id
5725 AND ecpm.revised_item_sequence_id = eri.revised_item_sequence_id
5726 AND ecpm.entity_name = Eng_Propagation_Log_Util.G_ENTITY_REVISED_ITEM
5727 AND ecpm.entity_action_status IN (Eng_Propagation_Log_Util.G_PRP_PRC_STS_SUCCESS, Eng_Propagation_Log_Util.G_PRP_PRC_STS_EXCL_TTM));
5728
5729 BEGIN
5730 Eng_Propagation_Log_Util.Debug_Log(G_LOG_PROC, 'PROPAGATE_ECO_PLM.Begin For Organization: '|| l_org_code);
5731 -- Standard call to check for call compatibility
5732 IF NOT FND_API.Compatible_API_Call ( l_api_version
5733 , p_api_version
5734 , l_api_name
5735 , G_PKG_NAME )
5736 THEN
5737 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5738 END IF;
5739
5740 --
5741 -- Initialize return status
5742 l_return_status := FND_API.G_RET_STS_SUCCESS;
5743 Error_Handler.Initialize;
5744 ENG_GLOBALS.G_ENG_LAUNCH_IMPORT := 2 ;--Indicates call is from propagation
5745 -- Removed check for local orgs same master org when propagating change orders
5746 -- as if required this can be added to the Business Object ---- 6/15/2005
5747
5748 --
5749 -- Fetch Organization Code for further processing
5750 OPEN c_fetch_org_code(p_organization_id);
5751 FETCH c_fetch_org_code INTO l_global_org_code;
5752 CLOSE c_fetch_org_code;
5753
5754 OPEN c_fetch_org_code(p_local_organization_id);
5755 FETCH c_fetch_org_code INTO l_org_code;
5756 CLOSE c_fetch_org_code;
5757 --
5758 -- Fetch change_id for further processing
5759 OPEN c_change_header;
5760 FETCH c_change_header INTO l_global_change_id;
5761 CLOSE c_change_header;
5762
5763 IF p_calling_API IS NULL
5764 THEN
5765 -- Progress with call to propagate the change header when
5766 -- calling api is not TTM
5767 -- Currently this is the only case possible
5768
5769 Propagate_Change_Header(
5770 p_change_id => l_global_change_id
5771 , p_change_notice => p_change_notice
5772 , p_organization_code => l_global_org_code
5773 , p_organization_id => p_organization_id
5774 , p_org_hierarchy_name => p_org_hierarchy_name
5775 , p_local_organization_code => l_org_code
5776 , p_local_organization_id => p_local_organization_id
5777 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5778 , x_Return_Status => l_return_status
5779 );
5780 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS)
5781 THEN
5782 l_top_entity_process_status := Eng_Propagation_Log_Util.G_PRP_PRC_STS_ERROR;
5783 RAISE EXC_EXP_SKIP_OBJECT;
5784 END IF;
5785 END IF; -- **** END of p_calling_API <> 'TTM' **** --
5786
5787 -- p_calling_API = 'TTM' and even after normal processing check if the ecdo already exists
5788 -- if the calling api is TTM then check if the change has already
5789 -- been propagated , only then continue processing
5790 -- if local change does not already exist , then the organization
5791 -- need not be propagated.
5792 -- calling api will be TTM only when the automatic change prpagation
5793 -- request has been triggered off by the BOM COPY process from
5794 -- Product Workbench
5795 Propagated_Local_Change(
5796 p_change_id => l_global_change_id
5797 , p_local_organization_id => p_local_organization_id
5798 , x_local_change_id => l_local_change_id
5799 );
5800 IF (l_local_change_id IS NULL)
5801 THEN
5802 Eng_Propagation_Log_Util.Debug_Log(G_LOG_PROC, 'PROPAGATE_ECO_PLM.End For Organization: '|| l_org_code);
5803 RETURN;
5804 END IF;
5805 Eng_Propagation_Log_Util.Debug_Log(G_LOG_STMT, 'Value x_local_change_id: '|| l_local_change_id);
5806 Initialize_Business_object(
5807 p_debug => 'N'
5808 , p_debug_filename => ''
5809 , p_output_dir => ''
5810 , p_bo_identifier => 'ECO'
5811 , p_organization_id => p_local_organization_id
5812 , x_return_status => l_return_status
5813 );
5814 FOR eri IN c_prp_revised_item
5815 LOOP
5816 Propagate_Revised_Item(
5817 p_revised_item_sequence_id => eri.revised_item_sequence_id
5818 , p_change_id => l_global_change_id
5819 , p_change_notice => p_change_notice
5820 , p_organization_code => l_global_org_code
5821 , p_organization_id => p_organization_id
5822 , p_local_organization_code => l_org_code
5823 , p_local_organization_id => p_local_organization_id
5824 , p_commit => FND_API.G_TRUE
5825 , x_Return_Status => l_return_status
5826 );
5827 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS)
5828 THEN
5829 l_top_entity_process_status := Eng_Propagation_Log_Util.G_PRP_PRC_STS_ERROR;
5830 END IF;
5831 END LOOP;
5832 Reset_Business_Object;
5833 IF l_top_entity_process_status = Eng_Propagation_Log_Util.G_PRP_PRC_STS_ERROR
5834 THEN
5835 RAISE EXC_EXP_SKIP_OBJECT;
5836 END IF;
5837
5838 -- Bug# 9498305
5839 SELECT object_to_id1
5840 INTO l_propagated_to_chg_id
5841 FROM eng_change_obj_relationships
5842 WHERE relationship_code = 'PROPAGATED_TO'
5843 AND object_to_name ='ENG_CHANGE'
5844 AND change_id = l_global_change_id
5845 AND object_to_id2 = p_organization_id
5846 AND object_to_id3 = p_local_organization_id;
5847
5848 FOR ri in c_extention_id_all (l_global_change_id)
5849 LOOP
5850
5851 SELECT EGO_EXTFWK_S.NEXTVAL
5852 INTO l_ext_id_nextval
5853 FROM DUAL;
5854
5855 INSERT INTO ENG_CHANGES_EXT_B (
5856 EXTENSION_ID ,
5857 CHANGE_ID ,
5858 CHANGE_TYPE_ID ,
5859 ATTR_GROUP_ID ,
5860 CREATED_BY ,
5861 CREATION_DATE ,
5862 LAST_UPDATED_BY ,
5863 LAST_UPDATE_DATE ,
5864 LAST_UPDATE_LOGIN ,
5865 C_EXT_ATTR1 ,
5866 C_EXT_ATTR2 ,
5867 C_EXT_ATTR3 ,
5868 C_EXT_ATTR4 ,
5869 C_EXT_ATTR5 ,
5870 C_EXT_ATTR6 ,
5871 C_EXT_ATTR7 ,
5872 C_EXT_ATTR8 ,
5873 C_EXT_ATTR9 ,
5874 C_EXT_ATTR10 ,
5875 C_EXT_ATTR11 ,
5876 C_EXT_ATTR12 ,
5877 C_EXT_ATTR13 ,
5878 C_EXT_ATTR14 ,
5879 C_EXT_ATTR15 ,
5880 C_EXT_ATTR16 ,
5881 C_EXT_ATTR17 ,
5882 C_EXT_ATTR18 ,
5883 C_EXT_ATTR19 ,
5884 C_EXT_ATTR20 ,
5885 N_EXT_ATTR1 ,
5886 N_EXT_ATTR2 ,
5887 N_EXT_ATTR3 ,
5888 N_EXT_ATTR4 ,
5889 N_EXT_ATTR5 ,
5890 N_EXT_ATTR6 ,
5891 N_EXT_ATTR7 ,
5892 N_EXT_ATTR8 ,
5893 N_EXT_ATTR9 ,
5894 N_EXT_ATTR10 ,
5895 D_EXT_ATTR1 ,
5896 D_EXT_ATTR2 ,
5897 D_EXT_ATTR3 ,
5898 D_EXT_ATTR4 ,
5899 D_EXT_ATTR5 ,
5900 C_EXT_ATTR21 ,
5901 C_EXT_ATTR22 ,
5902 C_EXT_ATTR23 ,
5903 C_EXT_ATTR24 ,
5904 C_EXT_ATTR25 ,
5905 C_EXT_ATTR26 ,
5906 C_EXT_ATTR27 ,
5907 C_EXT_ATTR28 ,
5908 C_EXT_ATTR29 ,
5909 C_EXT_ATTR30 ,
5910 C_EXT_ATTR31 ,
5911 C_EXT_ATTR32 ,
5912 C_EXT_ATTR33 ,
5913 C_EXT_ATTR34 ,
5914 C_EXT_ATTR35 ,
5915 C_EXT_ATTR36 ,
5916 C_EXT_ATTR37 ,
5917 C_EXT_ATTR38 ,
5918 C_EXT_ATTR39 ,
5919 C_EXT_ATTR40 ,
5920 N_EXT_ATTR11 ,
5921 N_EXT_ATTR12 ,
5922 N_EXT_ATTR13 ,
5923 N_EXT_ATTR14 ,
5924 N_EXT_ATTR15 ,
5925 N_EXT_ATTR16 ,
5926 N_EXT_ATTR17 ,
5927 N_EXT_ATTR18 ,
5928 N_EXT_ATTR19 ,
5929 N_EXT_ATTR20 ,
5930 UOM_EXT_ATTR1 ,
5931 UOM_EXT_ATTR2 ,
5932 UOM_EXT_ATTR3 ,
5933 UOM_EXT_ATTR4 ,
5934 UOM_EXT_ATTR5 ,
5935 UOM_EXT_ATTR6 ,
5936 UOM_EXT_ATTR7 ,
5937 UOM_EXT_ATTR8 ,
5938 UOM_EXT_ATTR9 ,
5939 UOM_EXT_ATTR10 ,
5940 UOM_EXT_ATTR11 ,
5941 UOM_EXT_ATTR12 ,
5942 UOM_EXT_ATTR13 ,
5943 UOM_EXT_ATTR14 ,
5944 UOM_EXT_ATTR15 ,
5945 UOM_EXT_ATTR16 ,
5946 UOM_EXT_ATTR17 ,
5947 UOM_EXT_ATTR18 ,
5948 UOM_EXT_ATTR19 ,
5949 UOM_EXT_ATTR20 ,
5950 D_EXT_ATTR6 ,
5951 D_EXT_ATTR7 ,
5952 D_EXT_ATTR8 ,
5953 D_EXT_ATTR9 ,
5954 D_EXT_ATTR10
5955 ) SELECT
5956 l_ext_id_nextval ,
5957 l_propagated_to_chg_id ,
5958 CHANGE_TYPE_ID ,
5959 ATTR_GROUP_ID ,
5960 Eng_Globals.Get_User_Id ,
5961 sysdate ,
5962 Eng_Globals.Get_User_Id ,
5963 sysdate ,
5964 Eng_Globals.Get_Login_id ,
5965 C_EXT_ATTR1 ,
5966 C_EXT_ATTR2 ,
5967 C_EXT_ATTR3 ,
5968 C_EXT_ATTR4 ,
5969 C_EXT_ATTR5 ,
5970 C_EXT_ATTR6 ,
5971 C_EXT_ATTR7 ,
5972 C_EXT_ATTR8 ,
5973 C_EXT_ATTR9 ,
5974 C_EXT_ATTR10 ,
5975 C_EXT_ATTR11 ,
5976 C_EXT_ATTR12 ,
5977 C_EXT_ATTR13 ,
5978 C_EXT_ATTR14 ,
5979 C_EXT_ATTR15 ,
5980 C_EXT_ATTR16 ,
5981 C_EXT_ATTR17 ,
5982 C_EXT_ATTR18 ,
5983 C_EXT_ATTR19 ,
5984 C_EXT_ATTR20 ,
5985 N_EXT_ATTR1 ,
5986 N_EXT_ATTR2 ,
5987 N_EXT_ATTR3 ,
5988 N_EXT_ATTR4 ,
5989 N_EXT_ATTR5 ,
5990 N_EXT_ATTR6 ,
5991 N_EXT_ATTR7 ,
5992 N_EXT_ATTR8 ,
5993 N_EXT_ATTR9 ,
5994 N_EXT_ATTR10 ,
5995 D_EXT_ATTR1 ,
5996 D_EXT_ATTR2 ,
5997 D_EXT_ATTR3 ,
5998 D_EXT_ATTR4 ,
5999 D_EXT_ATTR5 ,
6000 C_EXT_ATTR21 ,
6001 C_EXT_ATTR22 ,
6002 C_EXT_ATTR23 ,
6003 C_EXT_ATTR24 ,
6004 C_EXT_ATTR25 ,
6005 C_EXT_ATTR26 ,
6006 C_EXT_ATTR27 ,
6007 C_EXT_ATTR28 ,
6008 C_EXT_ATTR29 ,
6009 C_EXT_ATTR30 ,
6010 C_EXT_ATTR31 ,
6011 C_EXT_ATTR32 ,
6012 C_EXT_ATTR33 ,
6013 C_EXT_ATTR34 ,
6014 C_EXT_ATTR35 ,
6015 C_EXT_ATTR36 ,
6016 C_EXT_ATTR37 ,
6017 C_EXT_ATTR38 ,
6018 C_EXT_ATTR39 ,
6019 C_EXT_ATTR40 ,
6020 N_EXT_ATTR11 ,
6021 N_EXT_ATTR12 ,
6022 N_EXT_ATTR13 ,
6023 N_EXT_ATTR14 ,
6024 N_EXT_ATTR15 ,
6025 N_EXT_ATTR16 ,
6026 N_EXT_ATTR17 ,
6027 N_EXT_ATTR18 ,
6028 N_EXT_ATTR19 ,
6029 N_EXT_ATTR20 ,
6030 UOM_EXT_ATTR1 ,
6031 UOM_EXT_ATTR2 ,
6032 UOM_EXT_ATTR3 ,
6033 UOM_EXT_ATTR4 ,
6034 UOM_EXT_ATTR5 ,
6035 UOM_EXT_ATTR6 ,
6036 UOM_EXT_ATTR7 ,
6037 UOM_EXT_ATTR8 ,
6038 UOM_EXT_ATTR9 ,
6039 UOM_EXT_ATTR10 ,
6040 UOM_EXT_ATTR11 ,
6041 UOM_EXT_ATTR12 ,
6042 UOM_EXT_ATTR13 ,
6043 UOM_EXT_ATTR14 ,
6044 UOM_EXT_ATTR15 ,
6045 UOM_EXT_ATTR16 ,
6046 UOM_EXT_ATTR17 ,
6047 UOM_EXT_ATTR18 ,
6048 UOM_EXT_ATTR19 ,
6049 UOM_EXT_ATTR20 ,
6050 D_EXT_ATTR6 ,
6051 D_EXT_ATTR7 ,
6052 D_EXT_ATTR8 ,
6053 D_EXT_ATTR9 ,
6054 D_EXT_ATTR10
6055 FROM ENG_CHANGES_EXT_B
6056 WHERE CHANGE_ID = l_global_change_id
6057 AND EXTENSION_ID = ri.EXTENSION_ID;
6058
6059 INSERT INTO ENG_CHANGES_EXT_TL (
6060 EXTENSION_ID ,
6061 CHANGE_ID ,
6062 CHANGE_TYPE_ID ,
6063 ATTR_GROUP_ID ,
6064 SOURCE_LANG ,
6065 LANGUAGE ,
6066 LAST_UPDATE_DATE ,
6067 LAST_UPDATED_BY ,
6068 LAST_UPDATE_LOGIN ,
6069 CREATED_BY ,
6070 CREATION_DATE ,
6071 TL_EXT_ATTR1 ,
6072 TL_EXT_ATTR2 ,
6073 TL_EXT_ATTR3 ,
6074 TL_EXT_ATTR4 ,
6075 TL_EXT_ATTR5 ,
6076 TL_EXT_ATTR6 ,
6077 TL_EXT_ATTR7 ,
6078 TL_EXT_ATTR8 ,
6079 TL_EXT_ATTR9 ,
6080 TL_EXT_ATTR10 ,
6081 TL_EXT_ATTR11 ,
6082 TL_EXT_ATTR12 ,
6083 TL_EXT_ATTR13 ,
6084 TL_EXT_ATTR14 ,
6085 TL_EXT_ATTR15 ,
6086 TL_EXT_ATTR16 ,
6087 TL_EXT_ATTR17 ,
6088 TL_EXT_ATTR18 ,
6089 TL_EXT_ATTR19 ,
6090 TL_EXT_ATTR20 ,
6091 TL_EXT_ATTR21 ,
6092 TL_EXT_ATTR22 ,
6093 TL_EXT_ATTR23 ,
6094 TL_EXT_ATTR24 ,
6095 TL_EXT_ATTR25 ,
6096 TL_EXT_ATTR26 ,
6097 TL_EXT_ATTR27 ,
6098 TL_EXT_ATTR28 ,
6099 TL_EXT_ATTR29 ,
6100 TL_EXT_ATTR30 ,
6101 TL_EXT_ATTR31 ,
6102 TL_EXT_ATTR32 ,
6103 TL_EXT_ATTR33 ,
6104 TL_EXT_ATTR34 ,
6105 TL_EXT_ATTR35 ,
6106 TL_EXT_ATTR36 ,
6107 TL_EXT_ATTR37 ,
6108 TL_EXT_ATTR38 ,
6109 TL_EXT_ATTR39 ,
6110 TL_EXT_ATTR40
6111 ) SELECT
6112 l_ext_id_nextval ,
6113 l_propagated_to_chg_id ,
6114 CHANGE_TYPE_ID ,
6115 ATTR_GROUP_ID ,
6116 SOURCE_LANG ,
6117 LANGUAGE ,
6118 sysdate ,
6119 Eng_Globals.Get_User_Id ,
6120 Eng_Globals.Get_Login_id ,
6121 Eng_Globals.Get_User_Id ,
6122 sysdate ,
6123 TL_EXT_ATTR1 ,
6124 TL_EXT_ATTR2 ,
6125 TL_EXT_ATTR3 ,
6126 TL_EXT_ATTR4 ,
6127 TL_EXT_ATTR5 ,
6128 TL_EXT_ATTR6 ,
6129 TL_EXT_ATTR7 ,
6130 TL_EXT_ATTR8 ,
6131 TL_EXT_ATTR9 ,
6132 TL_EXT_ATTR10 ,
6133 TL_EXT_ATTR11 ,
6134 TL_EXT_ATTR12 ,
6135 TL_EXT_ATTR13 ,
6136 TL_EXT_ATTR14 ,
6137 TL_EXT_ATTR15 ,
6138 TL_EXT_ATTR16 ,
6139 TL_EXT_ATTR17 ,
6140 TL_EXT_ATTR18 ,
6141 TL_EXT_ATTR19 ,
6142 TL_EXT_ATTR20 ,
6143 TL_EXT_ATTR21 ,
6144 TL_EXT_ATTR22 ,
6145 TL_EXT_ATTR23 ,
6146 TL_EXT_ATTR24 ,
6147 TL_EXT_ATTR25 ,
6148 TL_EXT_ATTR26 ,
6149 TL_EXT_ATTR27 ,
6150 TL_EXT_ATTR28 ,
6151 TL_EXT_ATTR29 ,
6152 TL_EXT_ATTR30 ,
6153 TL_EXT_ATTR31 ,
6154 TL_EXT_ATTR32 ,
6155 TL_EXT_ATTR33 ,
6156 TL_EXT_ATTR34 ,
6157 TL_EXT_ATTR35 ,
6158 TL_EXT_ATTR36 ,
6159 TL_EXT_ATTR37 ,
6160 TL_EXT_ATTR38 ,
6161 TL_EXT_ATTR39 ,
6162 TL_EXT_ATTR40
6163 FROM ENG_CHANGES_EXT_TL
6164 WHERE CHANGE_ID = l_global_change_id
6165 AND EXTENSION_ID = ri.EXTENSION_ID;
6166 END LOOP;
6167 -- Bug# 9498305 End
6168
6169
6170 Init_Local_Change_Lifecycle (
6171 p_local_change_id => l_local_change_id
6172 , p_organization_id => p_organization_id
6173 , p_org_hierarchy_name => p_org_hierarchy_name
6174 , x_return_status => l_return_status
6175 );
6176 -- Not doing anythig for processing the Init_Local_Change_Lifecycle return status as
6177 -- the changes to the change order in local org can go through .user can then
6178 -- manually init the lifecycle if required
6179 Eng_Propagation_Log_Util.add_entity_map(
6180 p_change_id => l_global_change_id
6181 , p_local_organization_id => p_local_organization_id
6182 , p_entity_name => Eng_Propagation_Log_Util.G_ENTITY_CHANGE
6183 , p_entity_action_status => Eng_Propagation_Log_Util.G_PRP_PRC_STS_SUCCESS
6184 , p_bo_entity_identifier => 'ECO'--Eco_Error_Handler.G_ECO_LEVEL
6185 );
6186 EXCEPTION
6187 WHEN EXC_EXP_SKIP_OBJECT THEN
6188 Eng_Propagation_Log_Util.add_entity_map(
6189 p_change_id => l_global_change_id
6190 , p_local_organization_id => p_local_organization_id
6191 , p_entity_name => Eng_Propagation_Log_Util.G_ENTITY_CHANGE
6192 , p_entity_action_status => Eng_Propagation_Log_Util.G_PRP_PRC_STS_ERROR
6193 , p_bo_entity_identifier => 'ECO'--Eco_Error_Handler.G_ECO_LEVEL
6194 );
6195 ROLLBACK;
6196 WHEN OTHERS THEN
6197 ROLLBACK;
6198 END Propagate_ECO_PLM;
6199
6200 PROCEDURE Get_Local_Orgs_List (
6201 p_change_notice IN VARCHAR2
6202 , p_organization_id IN NUMBER
6203 , p_hierarchy_name IN VARCHAR2
6204 , p_local_organization_id IN NUMBER
6205 , x_organizations_list OUT NOCOPY INV_OrgHierarchy_PVT.OrgID_tbl_type
6206 , x_return_status OUT NOCOPY VARCHAR2
6207 ) IS
6208
6209 CURSOR c_local_orgs IS
6210 SELECT eclo.local_organization_id
6211 FROM eng_engineering_changes eec
6212 , eng_change_local_orgs eclo
6213 , hr_all_organization_units org
6214 , hr_organization_information hoi
6215 , mtl_parameters mp
6216 WHERE eec.change_notice = p_change_notice
6217 AND eec.organization_id = p_organization_id
6218 AND eclo.change_id = eec.change_id
6219 AND org.organization_id = hoi.organization_id
6220 AND org.organization_id = mp.organization_id
6221 AND hoi.org_information1 = 'INV'
6222 AND hoi.org_information2 = 'Y' -- inventory enabled flag
6223 AND hoi.org_information_context = 'CLASS'
6224 -- expiration check
6225 AND org.organization_id = eclo.local_organization_id
6226 AND (org.date_to >= SYSDATE OR org.date_to IS NULL)
6227 -- inv security access check
6228 AND (NOT EXISTS(SELECT 1 FROM ORG_ACCESS acc
6229 WHERE acc.organization_id = eclo.local_organization_id )
6230 OR EXISTS(SELECT 1 FROM ORG_ACCESS acc
6231 WHERE acc.organization_id = eclo.local_organization_id
6232 AND acc.responsibility_id = TO_NUMBER(fnd_profile.value('RESP_ID'))));
6233 l_org_Idx NUMBER;
6234 l_orgs_Cnt NUMBER;
6235
6236 BEGIN
6237 x_return_status := FND_API.G_RET_STS_SUCCESS;
6238 IF p_local_organization_id IS NOT NULL
6239 THEN
6240 x_organizations_list(1) := p_organization_id;
6241 x_organizations_list(2) := p_local_organization_id;
6242 ELSIF p_hierarchy_name IS NOT NULL
6243 THEN
6244 -- Fetch the list of organizations from hierarchy if specified
6245 Inv_OrgHierarchy_Pvt.Org_Hierarchy_List(p_hierarchy_name, p_organization_id, x_organizations_list);
6246 ELSE
6247 -- from eng_change_local_organizations for TTM
6248 -- The following APIs fetch the list of all organizations for which the user has access
6249 -- by responsibility and by business group.
6250 l_org_Idx := 1;
6251 x_organizations_list(l_org_Idx) := p_organization_id;
6252 x_organizations_list(l_org_Idx+1) := 209;
6253 FOR c_org IN c_local_orgs
6254 LOOP
6255 l_org_Idx := l_org_Idx+1;
6256 x_organizations_list(l_org_Idx) := c_org.local_organization_id;
6257 END LOOP;
6258 END IF;
6259
6260 l_orgs_Cnt := x_organizations_list.COUNT;
6261 IF (l_orgs_Cnt IN (0, 1))
6262 THEN
6263 FND_FILE.PUT_LINE(FND_FILE.LOG, 'No Organization exists for propagating changes');
6264 x_return_status := FND_API.G_RET_STS_ERROR;
6265 END IF;
6266 END Get_Local_Orgs_List;
6267
6268 -- ****************************************************************** --
6269 -- API name : Propagate_ECO --
6270 -- Type : Public --
6271 -- Pre-reqs : None. --
6272 -- Procedure : Propagates the specified ECO --
6273 -- Parameters : --
6274 -- IN : --
6275 -- p_change_notice VARCHAR2 Required --
6276 -- p_org_hierarchy_name varchar2 --
6277 -- p_org_hierarchy_level VARCHAR2 --
6278 -- p_local_organization_id NUMBER := NULL --
6279 -- p_calling_api NUMBER := NULL --
6280 -- OUT : retcode VARCHAR2(1) --
6281 -- error_buf VARCHAR2(30) --
6282 -- Version : --
6283 -- Current version 1.0 --
6284 -- Initial version 1.0 --
6285 -- --
6286 -- Notes : --
6287 -- if org hierarchy id is -1 then the list of orgs --
6288 -- associated to the change are picked for propagation --
6289 -- if p_org_hierarchy_id is null, check that the value --
6290 -- local_organization_id has been specified --
6291 -- Validate that the local organization id either --
6292 -- belongs to the hierarchy or to the list of local --
6293 -- orgs of thesource change order --
6294 -- p_calling API is TTM then the change header --
6295 -- relation is checked first 'TRANSFERRED_TO' --
6296 -- ****************************************************************** --
6297 PROCEDURE PROPAGATE_ECO (
6298 errbuf OUT NOCOPY VARCHAR2
6299 , retcode OUT NOCOPY VARCHAR2
6300 , p_change_notice IN VARCHAR2
6301 , p_org_hierarchy_name IN VARCHAR2
6302 , p_org_hierarchy_level IN VARCHAR2
6303 , p_local_organization_id IN NUMBER := NULL
6304 , p_calling_API IN VARCHAR2 := NULL
6305 ) IS
6306
6307 l_plm_or_erp_flag VARCHAR2(3);
6308 l_org_hierarchy_level_id NUMBER;
6309 l_org_code_list INV_OrgHierarchy_PVT.OrgID_tbl_type;
6310
6311 CURSOR c_organization_details IS
6312 SELECT MP.organization_id
6313 FROM HR_ORGANIZATION_UNITS HOU
6314 , HR_ORGANIZATION_INFORMATION HOI1
6315 , MTL_PARAMETERS MP
6316 WHERE HOU.ORGANIZATION_ID = HOI1.ORGANIZATION_ID
6317 AND HOU.ORGANIZATION_ID = MP.ORGANIZATION_ID
6318 AND HOI1.ORG_INFORMATION1 = 'INV'
6319 AND HOI1.ORG_INFORMATION2 = 'Y'
6320 AND HOU.NAME = p_org_hierarchy_level;
6321 /*FROM org_organization_definitions
6322 WHERE organization_name = p_org_hierarchy_level;*/
6323
6324 l_return_status VARCHAR2(1);
6325 BEGIN
6326 -- Fetch the global organization id
6327 OPEN c_organization_details;
6328 FETCH c_organization_details INTO l_org_hierarchy_level_id;
6329 CLOSE c_organization_details;
6330 -- Fetch the value of plm_or_erp_change
6331 -- The processing will be routed differently for PLM ECOs and ERP ECOs
6332 l_plm_or_erp_flag := Eng_Globals.Get_PLM_Or_ERP_Change(
6333 p_change_notice => p_change_notice
6334 , p_organization_id => l_org_hierarchy_level_id);
6335 -- Begin Processing for PLM
6336 IF (l_plm_or_erp_flag = 'PLM')
6337 THEN
6338 -- Bug : 5326333 ECO Propagation was failing because validations not required from PLM flow are happening from BOM API.
6339 -- If we set the following flag, then bom validations will be skipped for PLM flow.
6340 Bom_Globals.Set_Validate_For_Plm('Y');
6341 -- Set OrganizationId as global variable
6342 g_global_org_id := l_org_hierarchy_level_id;
6343 -- This following validation needs to be done for all orgs in the list
6344 -- Eng_Validate.Organization_Id(p_organization_id => l_org_id);
6345 Get_Local_Orgs_List(
6346 p_change_notice => p_change_notice
6347 , p_organization_id => l_org_hierarchy_level_id
6348 , p_hierarchy_name => p_org_hierarchy_name
6349 , p_local_organization_id => p_local_organization_id
6350 , x_organizations_list => l_org_code_list
6351 , x_return_status => l_return_status);
6352
6353 IF l_return_status = FND_API.G_RET_STS_ERROR
6354 THEN
6355 RETURN;
6356 END IF;
6357
6358 FOR l_org_count IN 2..l_org_code_list.LAST
6359 LOOP
6360 Eng_Propagation_Log_Util.Initialize;
6361 Propagate_ECO_PLM(
6362 x_error_buf => errbuf
6363 , x_return_status => retcode
6364 , p_change_notice => p_change_notice
6365 , p_organization_id => l_org_hierarchy_level_id
6366 , p_org_hierarchy_name => p_org_hierarchy_name
6367 , p_local_organization_id => l_org_code_list(l_org_count)
6368 , p_calling_API => p_calling_API
6369 );
6370 Eng_Propagation_Log_Util.Write_Propagation_Log;
6371 commit;
6372
6373 END LOOP; -- end FOR l_org_count IN 2..l_org_code_list.LAST
6374 ELSE
6375 PROPAGATE_ECO_ERP(
6376 errbuf => errbuf ,
6377 retcode => retcode,
6378 p_change_notice => p_change_notice,
6379 p_org_hierarchy_name => p_org_hierarchy_name,
6380 p_org_hierarchy_level => p_org_hierarchy_level
6381 );
6382
6383 END IF; -- end l_plm_or_erp_flag = 'PLM'
6384
6385 END PROPAGATE_ECO;
6386
6387 -- ****************************************************************** --
6388 -- API name : PreProcess_Propagate_Request --
6389 -- Type : Public --
6390 -- Pre-reqs : None. --
6391 -- Procedure : Adds a row into the Propagation maps table --
6392 -- Parameters : --
6393 -- IN : p_api_version IN NUMBER --
6394 -- p_init_msg_list IN VARCHAR2 --
6395 -- p_commit IN VARCHAR2 --
6396 -- p_request_id IN NUMBER --
6397 -- p_change_id IN VARCHAR2 --
6398 -- p_org_hierarchy_name IN VARCHAR2 --
6399 -- p_local_organization_id IN NUMBER --
6400 -- p_calling_API IN VARCHAR2 --
6401 -- --
6402 -- OUT : x_msg_count OUT NOCOPY NUMBER --
6403 -- x_msg_data OUT NOCOPY VARCHAR2 --
6404 -- x_return_status VARCHAR2(1) --
6405 -- --
6406 -- Version : --
6407 -- Current version 1.0 --
6408 -- Initial version 1.0 --
6409 -- --
6410 -- Notes : --
6411 -- ****************************************************************** --
6412 PROCEDURE PreProcess_Propagate_Request (
6413 p_api_version IN NUMBER --
6414 , p_init_msg_list IN VARCHAR2 --
6415 , p_commit IN VARCHAR2 --
6416 , p_request_id IN NUMBER
6417 , p_change_id IN VARCHAR2
6418 , p_org_hierarchy_name IN VARCHAR2
6419 , p_local_organization_id IN NUMBER
6420 , p_calling_API IN VARCHAR2
6421 , x_return_status OUT NOCOPY VARCHAR2 --
6422 , x_msg_count OUT NOCOPY NUMBER --
6423 , x_msg_data OUT NOCOPY VARCHAR2 --
6424 ) IS
6425
6426 l_org_hierarchy_level_id NUMBER;
6427 l_change_notice eng_engineering_changes.change_notice%TYPE;
6428 l_org_code_list INV_OrgHierarchy_PVT.OrgID_tbl_type;
6429
6430 CURSOR c_change_details IS
6431 SELECT change_notice, organization_id
6432 FROM eng_engineering_changes
6433 WHERE change_id = p_change_id;
6434
6435 l_api_name CONSTANT VARCHAR2(30) := 'PreProcess_Propagate_Request';
6436 l_api_version CONSTANT NUMBER := 1.0;
6437 l_return_status VARCHAR2(1);
6438 l_change_map_id NUMBER;
6439 BEGIN
6440 --
6441 -- Standard Start of API savepoint
6442 SAVEPOINT PreProcess_Propagate_Request;
6443 --
6444 -- Standard call to check for call compatibility
6445 IF NOT FND_API.Compatible_API_Call ( l_api_version
6446 ,p_api_version
6447 ,l_api_name
6448 ,G_PKG_NAME )
6449 THEN
6450 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6451 END IF;
6452 --
6453 -- Initialize message list if p_init_msg_list is set to TRUE.
6454 IF FND_API.to_Boolean( p_init_msg_list ) THEN
6455 FND_MSG_PUB.initialize;
6456 END IF ;
6457 --
6458 -- Fetch the change details
6459 OPEN c_change_details;
6460 FETCH c_change_details INTO l_change_notice, l_org_hierarchy_level_id;
6461 CLOSE c_change_details;
6462 --
6463 -- Fetch the list of organizations that are going to be processed
6464 -- by the request submitted
6465 Get_Local_Orgs_List(p_change_notice => l_change_notice
6466 , p_organization_id => l_org_hierarchy_level_id
6467 , p_hierarchy_name => p_org_hierarchy_name
6468 , p_local_organization_id => p_local_organization_id
6469 , x_organizations_list => l_org_code_list
6470 , x_return_status => l_return_status);
6471 --
6472 -- If successful , then proceed
6473 IF l_return_status = FND_API.G_RET_STS_SUCCESS
6474 THEN
6475 --
6476 -- For each organization, check if propagation process had already been
6477 -- initiated for the change in that organization
6478 -- If the map does not exist then create a new map entry with entity action status
6479 -- as G_PRP_PRC_STS_NOACTION CONSTANT NUMBER := 0 => Meaning: No action yet
6480 -- if the map already exists , then update just the value of request id on the
6481 -- change map, so that the UI can reference to the latest reqeust as soon as
6482 -- it is submitted.
6483 FOR l_org_count IN 2..l_org_code_list.LAST
6484 LOOP
6485 --
6486 -- Check for header map existance for the change and specific local org
6487 Eng_Propagation_Log_Util.Check_Entity_Map_Existance (
6488 p_change_id => p_change_id
6489 , p_entity_name => Eng_Propagation_Log_Util.G_ENTITY_CHANGE--'ENG_CHANGE'
6490 , p_local_organization_id => l_org_code_list(l_org_count)
6491 , x_change_map_id => l_change_map_id
6492 );
6493 --
6494 -- If it deoes not exist, INSERT
6495 IF l_change_map_id IS NULL
6496 THEN
6497 SELECT eng_change_propagation_maps_s.nextval
6498 INTO l_change_map_id
6499 FROM DUAL;
6500
6501 INSERT INTO eng_change_propagation_maps(
6502 change_propagation_map_id
6503 , change_id
6504 , request_id
6505 , local_organization_id
6506 , entity_name
6507 , creation_date
6508 , created_by
6509 , last_update_date
6510 , last_updated_by
6511 , last_update_login
6512 , entity_action_status
6513 )
6514 VALUES(
6515 l_CHANGE_MAP_ID
6516 , p_CHANGE_ID
6517 , p_request_id
6518 , l_org_code_list(l_org_count)
6519 , Eng_Propagation_Log_Util.G_ENTITY_CHANGE--'ENG_CHANGE'
6520 , SYSDATE
6521 , FND_GLOBAL.USER_ID
6522 , SYSDATE
6523 , FND_GLOBAL.USER_ID
6524 , FND_GLOBAL.LOGIN_ID
6525 , Eng_Propagation_Log_Util.G_PRP_PRC_STS_NOACTION
6526 );
6527 --
6528 -- Else UPDATE
6529 ELSE
6530 UPDATE eng_change_propagation_maps
6531 SET request_id = p_request_id
6532 , creation_date = SYSDATE
6533 , created_by = FND_GLOBAL.USER_ID
6534 , last_update_date = SYSDATE
6535 , last_updated_by = FND_GLOBAL.USER_ID
6536 , last_update_login = FND_GLOBAL.LOGIN_ID
6537 WHERE change_propagation_map_id = l_change_map_id;
6538 END IF; -- IF l_change_map_id IS NULL
6539 END LOOP; -- FOR l_org_count IN 2..l_org_code_list.LAST
6540 END IF; -- IF l_return_status = FND_API.G_RET_STS_SUCCESS
6541
6542 -- Standard ending code ------------------------------------------------
6543 IF FND_API.To_Boolean ( p_commit ) THEN
6544 COMMIT WORK;
6545 END IF;
6546
6547 EXCEPTION
6548 WHEN OTHERS THEN
6549 IF c_change_details%ISOPEN THEN
6550 CLOSE c_change_details;
6551 END IF;
6552 -- Begin Exception handling
6553 ROLLBACK TO PreProcess_Propagate_Request;
6554
6555 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6556 IF FND_MSG_PUB.Check_Msg_Level( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
6557 THEN
6558 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME, l_api_name );
6559 END IF;
6560 FND_MSG_PUB.Count_And_Get(
6561 p_count => x_msg_count
6562 , p_data => x_msg_data );
6563 -- End Exception handling
6564 END PreProcess_Propagate_Request;
6565
6566 END ENGECOBO;
6567