[Home] [Help]
PACKAGE BODY: APPS.ERROR_HANDLER
Source
1 PACKAGE BODY Error_Handler AS
2 /* $Header: BOMBOEHB.pls 120.5 2006/09/14 16:09:39 pdutta ship $ */
3 /*************************************************************************
4 --
5 -- Copyright (c) 1996 Oracle Corporation, Redwood Shores, CA, USA
6 -- All rights reserved.
7 --
8 -- FILENAME
9 --
10 -- BOMBOEHB.pls
11 --
12 -- DESCRIPTION
13 --
14 -- Body of package Error_Handler
15 --
16 -- NOTES
17 --
18 -- HISTORY
19 --
20 -- 21-JUL-1999 Rahul Chitko Initial Creation
21 --
22 -- 23-Aug-2000 Masanori Kimizuka Enhacement for Routing BO.
23 -- Added constant variables and Log_Error
24 -- procedure for Routing BO.
25 --
26 -- 23-AUG-01 Refai Farook One To Many operations support changes
27 --
28 -- 09-SEP-02 Refai Farook Changes to the Add_Message procedure to default
29 -- the Row_Identifier value for BOM BO
30
31 -- 24-SEP-02 Refai Farook Modified the process logic of Add_Error_Token,
32 -- Translate_Insert_Message procedures.
33 -- Implemented Add_Error_Message procedure.
34 -- Added support to write the errors into interface,
35 -- conc.log and to debug file.
36 --
37 -- 22-NOV-2002 Phani Pilli Enhancement to support BOM Open Interface
38 *************************************************************************/
39 -- g_bom_header_rec Bom_Bo_Pub.Bom_Head_Rec_Type;
40 -- g_bom_revision_tbl Bom_Bo_Pub.Bom_Revision_Tbl_Type;
41 -- g_bom_component_tbl Bom_Bo_Pub.Bom_Comps_Tbl_Type;
42 -- g_bom_ref_designator_tbl Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type;
43 -- g_bom_sub_component_tbl Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type;
44 g_bom_comp_ops_tbl Bom_Bo_Pub.Bom_Comp_Ops_Tbl_Type;
45
46 G_ERROR_TABLE Error_Handler.Error_Tbl_Type;
47 G_Msg_Index NUMBER := 0;
48 G_Msg_Count NUMBER := 0;
49
50 G_BO_IDENTIFIER VARCHAR2(30) := 'BOM';
51
52 g_debug_flag VARCHAR2(1) := 'N';
53
54 /****************************************************************
55 * Procedure : Add_Message
56 *
57 * Paramaters IN : Message Text
58 * For explanation on entity id, entity index,
59 * message type,row identifier, table name,
60 * entity code parameters please refer to
61 * Add_Error_Message API
62 *
63 * Parameters OUT: None
64 * Purpose : Add_Message will push a message on the message
65 * stack and will convert the numeric entity id to
66 * character which will be easier for the user to
67 * understand. eg. Entity Id = 1 which will be ECO
68 *****************************************************************/
69
70 PROCEDURE Add_Message
71 ( p_mesg_text IN VARCHAR2
72 , p_entity_id IN NUMBER
73 , p_entity_index IN NUMBER
74 , p_message_type IN VARCHAR2
75 , p_row_identifier IN NUMBER := NULL
76 , p_table_name IN VARCHAR2 := NULL
77 , p_entity_code IN VARCHAR2 := NULL
78 , p_mesg_name IN VARCHAR2 := NULL
79 ) IS
80 Begin
81 Add_Message
82 ( p_mesg_text
83 , p_entity_id
84 , p_entity_index
85 , p_message_type
86 , p_row_identifier
87 , p_table_name
88 , p_entity_code
89 , p_mesg_name
90 , Bom_Bo_Pub.G_MISS_BOM_HEADER_REC
91 , Bom_Bo_Pub.G_MISS_BOM_REVISION_TBL
92 , Bom_Bo_Pub.G_MISS_BOM_COMPONENT_TBL
93 , Bom_Bo_Pub.G_MISS_BOM_REF_DESIGNATOR_TBL
94 , Bom_Bo_Pub.G_MISS_BOM_SUB_COMPONENT_TBL
95 , Bom_Bo_Pub.G_MISS_BOM_COMP_OPS_TBL
96 );
97
98 END;
99
100
101
102 PROCEDURE Add_Message
103 ( p_mesg_text IN VARCHAR2
104 , p_entity_id IN NUMBER
105 , p_entity_index IN NUMBER
106 , p_message_type IN VARCHAR2
107 , p_row_identifier IN NUMBER := NULL
108 , p_table_name IN VARCHAR2 := NULL
109 , p_entity_code IN VARCHAR2 := NULL
110 , p_mesg_name IN VARCHAR2 := NULL
111 , p_bom_header_rec IN OUT NOCOPY Bom_Bo_Pub.Bom_Head_Rec_Type
112 , p_bom_revision_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Revision_Tbl_Type
113 , p_bom_component_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Comps_Tbl_Type
114 , p_bom_ref_Designator_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type
115 , p_bom_sub_component_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type
116 , p_bom_comp_ops_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Comp_Ops_Tbl_Type
117 )
118 IS
119 l_Idx BINARY_INTEGER;
120 l_entity_id_char VARCHAR2(30) := null;
121 l_row_identifier NUMBER := null;
122 l_table_name VARCHAR2(30);
123
124
125 BEGIN
126
127 l_Idx := G_ERROR_TABLE.COUNT;
128
129 IF p_entity_code IS NOT NULL
130 THEN
131
132 /* Add_Error_Message (mainly used by other applications) will always
133 pass the entity code. If entity code is passed, it takes precedence
134 over the entity id */
135 l_entity_id_char := p_entity_code;
136
137 ELSIF p_entity_id = G_BO_LEVEL
138 THEN
139 l_entity_id_char := 'BO';
140 ELSIF p_entity_id = G_ECO_LEVEL
141 THEN
142 l_entity_id_char := 'ECO';
143 ELSIF p_entity_id = G_REV_LEVEL
144 THEN
145 l_entity_id_char := 'REV';
146 ELSIF p_entity_id = G_RI_LEVEL
147 THEN
148 l_entity_id_char := 'RI';
149 ELSIF p_entity_id = G_RC_LEVEL
150 THEN
151 l_entity_id_char := 'RC';
152 ELSIF p_entity_id = G_RD_LEVEL
153 THEN
154 l_entity_id_char := 'RD';
155 ELSIF p_entity_id = G_SC_LEVEL
156 THEN
157 l_entity_id_char := 'SC';
158 ELSIF p_entity_id = G_BH_LEVEL
159 THEN
160 l_entity_id_char := 'BH';
161 /* One to many support */
162 ELSIF p_entity_id = G_COP_LEVEL
163 THEN
164 l_entity_id_char := 'COP';
165 /**********************************
166 -- Followings are for Routing BO
167 ***********************************/
168 ELSIF p_entity_id = G_RTG_LEVEL
169 THEN
170 l_entity_id_char := 'RTG';
171 ELSIF p_entity_id = G_OP_LEVEL
172 THEN
173 l_entity_id_char := 'OP';
174 ELSIF p_entity_id = G_RES_LEVEL
175 THEN
176 l_entity_id_char := 'RES';
177 ELSIF p_entity_id = G_SR_LEVEL
178 THEN
179 l_entity_id_char := 'SR';
180 ELSIF p_entity_id = G_NWK_LEVEL
181 THEN
182 l_entity_id_char := 'NWK';
183 -- Added by MK on 08/23/2000
184 ELSIF p_entity_id = G_ATCH_LEVEL
185 THEN
186 l_entity_id_char := 'ATCH';
187 END IF;
188
189 IF p_row_identifier IS NOT NULL
190 THEN
191
192 /* if row identifier is passed, use it */
193 l_row_identifier := p_row_identifier;
194
195 ELSE
196
197 /* if the row identifier is not passed, then do the defaulting (only for BOM BO)*/
198
199 IF Get_BO_Identifier = 'BOM'
200 THEN
201 IF p_entity_id IN (G_BO_LEVEL,G_BH_LEVEL)
202 THEN
203 l_row_identifier := p_bom_header_rec.row_identifier;
204 ELSIF p_entity_id = G_REV_LEVEL
205 THEN
206 l_row_identifier := p_bom_revision_tbl(p_entity_index).row_identifier;
207 ELSIF p_entity_id = G_RC_LEVEL
208 THEN
209 l_row_identifier := p_bom_component_tbl(p_entity_index).row_identifier;
210 ELSIF p_entity_id = G_RD_LEVEL
211 THEN
212 l_row_identifier := p_bom_ref_designator_tbl(p_entity_index).row_identifier;
213 ELSIF p_entity_id = G_SC_LEVEL
214 THEN
215 l_row_identifier := p_bom_sub_component_tbl(p_entity_index).row_identifier;
216 ELSIF p_entity_id = G_COP_LEVEL
217 THEN
218 l_row_identifier := p_bom_comp_ops_tbl(p_entity_index).row_identifier;
219 END IF;
220 END IF;
221 END IF;
222
223 /* Fix for bug 4652785 - If table_name is passed as a parameter then use it.
224 Otherwise populate the table_name based on the entity_id. */
225
226 l_table_name :=null;
227
228 IF p_table_name IS NOT NULL
229 THEN
230 l_table_name := p_table_name;
231 /**********************************
232 -- Followings are for Bills BO
233 ***********************************/
234 ELSIF p_entity_id =G_BH_LEVEL
235 THEN
236 l_table_name := 'BOM_BILL_OF_MTLS_INTERFACE';
237 ELSIF p_entity_id = G_RC_LEVEL
238 THEN
239 l_table_name := 'BOM_INVENTORY_COMPS_INTERFACE';
240 ELSIF p_entity_id = G_RD_LEVEL
241 THEN
242 l_table_name := 'BOM_REF_DESGS_INTERFACE';
243 ELSIF p_entity_id = G_SC_LEVEL
244 THEN
245 l_table_name := 'BOM_SUB_COMPS_INTERFACE';
246 ELSIF p_entity_id = G_COP_LEVEL
247 THEN
248 l_table_name := 'BOM_COMP_OPS_INTERFACE';
249 /**********************************
250 -- Followings are for Routing BO
251 ***********************************/
252 ELSIF p_entity_id = G_RTG_LEVEL
253 THEN
254 l_table_name := 'BOM_OP_ROUTINGS_INTERFACE';
255 ELSIF p_entity_id = G_OP_LEVEL
256 THEN
257 l_table_name := 'BOM_OP_SEQUENCES_INTERFACE';
258 ELSIF p_entity_id = G_RES_LEVEL
259 THEN
260 l_table_name := 'BOM_OP_RESOURCES_INTERFACE';
261 ELSIF p_entity_id = G_SR_LEVEL
262 THEN
263 l_table_name := 'BOM_SUB_OP_RESOURCES_INTERFACE';
264 ELSIF p_entity_id = G_NWK_LEVEL
265 THEN
266 l_table_name := 'BOM_OP_NETWORKS_INTERFACE';
267 /**************************************
268 -- Followings are for common entities
269 **************************************/
270 ELSIF p_entity_id = G_REV_LEVEL
271 THEN
272 IF Get_BO_Identifier = 'BOM' THEN
273 l_table_name := 'MTL_ITEM_REVISIONS_INTERFACE';
274 ELSIF Get_BO_Identifier = 'RTG' THEN
275 l_table_name := 'MTL_RTG_ITEM_REVS_INTERFACE';
276 ELSIF Get_BO_Identifier = 'ECO' THEN
277 l_table_name := 'ENG_ECO_REVISIONS_INTERFACE';
278 END IF;
279
280 /* bug:5260316 Default table names for ECO BO*/
281 /**********************************
282 -- Following are for ECO BO
283 ***********************************/
284 ELSIF p_entity_id = G_ECO_LEVEL
285 THEN
286 l_table_name := 'ENG_ENG_CHANGES_INTERFACE';
287 ELSIF p_entity_id = G_RI_LEVEL
288 THEN
289 l_table_name := 'ENG_REVISED_ITEMS_INTERFACE';
290 ELSIF p_entity_id = G_CL_LEVEL
291 THEN
292 l_table_name := 'ENG_CHANGE_LINES_INTERFACE';
293
294 END IF;
295 /* End of fix for bug 4652785*/
296
297
298 Error_Handler.Write_Debug('Entity Id: ' || l_entity_id_char);
299
300 G_ERROR_TABLE(l_Idx + 1).message_text := p_mesg_text;
301 G_ERROR_TABLE(l_idx + 1).entity_id := l_entity_id_char;
302 G_ERROR_TABLE(l_idx + 1).entity_index := p_entity_index;
303 G_ERROR_TABLE(l_idx + 1).message_type := p_message_type;
304 G_ERROR_TABLE(l_Idx + 1).row_identifier := l_row_identifier;
305 G_ERROR_TABLE(l_Idx + 1).table_name := l_table_name;/*Fix for bug 4652785-Replaced p_table_name with l_table_name*/
306 G_ERROR_TABLE(l_Idx + 1).bo_identifier :=
307 Error_Handler.Get_Bo_Identifier;
308 G_ERROR_TABLE(l_Idx + 1).message_name := p_mesg_name;
309 /* Fix for bug 4620997 - Populate message_name in the G_ERROR_TABLE above. */
310
311 -- Increment the message counter to keep a tally.
312
313 G_Msg_Count := G_Error_Table.Count;
314
315 Error_Handler.Write_Debug('Message Count on this point : ' || to_char(G_Msg_Count));
316
317 END Add_Message;
318
322 * Other Status
319 /******************************************************************
320 * Procedure : setCompOperations (Unexposed)
321 * Parameters : Other Message
323 * Error Scope
324 * Revised Component Index
325 * Component Operation entity Index
326 * Purpose : This procedure will set the component operation
327 * record status to other status by looking at the
328 * revised item key or the revised component key or
329 * else setting all the record status to other status
330 ********************************************************************/
331 /*Fix for bug 4661753 - Added a new parameter p_other_mesg_name to the procedure below.*/
332 PROCEDURE setCompOperations
333 ( p_error_scope IN VARCHAR2
334 , p_other_mesg_text IN VARCHAR2
335 , p_other_status IN VARCHAR2
336 , p_rc_idx IN NUMBER := 0
337 , p_entity_index IN NUMBER := 0
338 , p_other_mesg_name IN VARCHAR2 := NULL
339 , p_bom_header_rec IN OUT NOCOPY Bom_Bo_Pub.Bom_Head_Rec_Type
340 , p_bom_revision_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Revision_Tbl_Type
341 , p_bom_component_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Comps_Tbl_Type
342 , p_bom_ref_Designator_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type
343 , p_bom_sub_component_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type
344 , p_bom_comp_ops_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Comp_Ops_Tbl_Type
345 )
346 IS
347 BEGIN
348
349 Error_Handler.Write_Debug('Setting component operation records to ' || p_other_status);
350
351 IF p_error_scope = G_SCOPE_ALL
352 THEN
353 FOR l_idx IN 1..p_bom_comp_ops_tbl.COUNT
354 LOOP
355 p_bom_comp_ops_tbl(l_idx).return_status :=
356 p_other_status;
357 IF p_other_mesg_text IS NOT NULL
358 THEN
359 /* Fix for bug 4661753 - added p_mesg_name to the call to Add_message procedure below. */
360 Add_Message
361 ( p_mesg_text => p_other_mesg_text
362 , p_entity_id => G_COP_LEVEL
363 , p_entity_index=> l_idx
364 , p_message_type=> 'E'
365 , p_mesg_name => p_other_mesg_name
366 , p_bom_header_rec =>p_bom_header_rec
367 , p_bom_revision_tbl =>p_bom_revision_tbl
368 , p_bom_component_tbl =>p_bom_component_tbl
369 , p_bom_ref_Designator_tbl =>p_bom_ref_Designator_tbl
370 , p_bom_sub_component_tbl =>p_bom_sub_component_tbl
371 , p_bom_comp_ops_tbl =>p_bom_comp_ops_tbl
372 );
373 END IF;
374 END LOOP;
375 ELSIF p_error_scope = G_SCOPE_CHILDREN AND
376 p_rc_idx <> 0
377 THEN
378
379 Error_Handler.Write_Debug('Scope=Children in Component Operation');
380 Error_Handler.Write_Debug('Inventory Component index <> 0');
381
382 FOR l_idx IN 1..p_bom_comp_ops_tbl.COUNT
383 LOOP
384 IF NVL(p_bom_comp_ops_tbl(l_idx).component_item_name, ' ')=
385 NVL(p_bom_component_tbl(p_rc_idx).component_item_name,' '
386 ) AND
387 NVL(p_bom_comp_ops_tbl(l_idx).start_effective_date,
388 SYSDATE ) =
389 NVL(p_bom_component_tbl(p_rc_idx).start_effective_date,
390 SYSDATE )
391 AND
392 NVL(p_bom_comp_ops_tbl(l_idx).operation_sequence_number,
393 0) =
394 NVL(p_bom_component_tbl(p_rc_idx).operation_sequence_number, 0)
395 AND
396 NVL(p_bom_comp_ops_tbl(l_idx).organization_code, ' ') =
397 NVL(p_bom_component_tbl(p_rc_idx).organization_code, ' ')
398 THEN
399
400 p_bom_comp_ops_tbl(l_idx).return_status :=
401 p_other_status;
402 /* Fix for bug 4661753 - added p_mesg_name to the call to Add_message procedure below. */
403 Add_Message
404 ( p_mesg_text => p_other_mesg_text
405 , p_entity_id => G_COP_LEVEL
406 , p_entity_index => l_idx
407 , p_message_type => 'E'
408 , p_mesg_name => p_other_mesg_name
409 , p_bom_header_rec => p_bom_header_rec
410 , p_bom_revision_tbl =>p_bom_revision_tbl
411 , p_bom_component_tbl =>p_bom_component_tbl
412 , p_bom_ref_Designator_tbl =>p_bom_ref_Designator_tbl
413 , p_bom_sub_component_tbl =>p_bom_sub_component_tbl
417 END LOOP; -- Ref. Desg Children of Rev Comps Ends.
414 , p_bom_comp_ops_tbl =>p_bom_comp_ops_tbl
415 );
416 END IF;
418
419 ELSIF p_error_scope = G_SCOPE_SIBLINGS AND
420 p_rc_idx = 0
421 THEN
422 --
423 -- This situation will arise when inventory comp is
424 -- not part of the business object input data.
425 -- Match the component key information at the entity index
426 -- location with rest of the records, all those that are found
427 -- will be siblings and should get an error.
428 --
429 Error_Handler.Write_Debug('Scope=Siblings in Component Operation');
430 Error_Handler.Write_Debug('All entity indexes = 0');
431
432
433 FOR l_idx IN (p_entity_index+1)..p_bom_comp_ops_tbl.COUNT
434 LOOP
435 IF NVL(p_bom_comp_ops_tbl(l_idx).component_item_name, ' ') =
436 NVL(p_bom_comp_ops_tbl(p_entity_index).component_item_name, ' ')
437 AND
438 NVL(p_bom_comp_ops_tbl(l_idx).start_effective_date, SYSDATE) =
439 NVL(p_bom_comp_ops_tbl(p_entity_index).start_effective_date, SYSDATE)
440 AND
441 NVL(p_bom_comp_ops_tbl(l_idx).operation_sequence_number, 0) =
442 NVL(p_bom_comp_ops_tbl(p_entity_index).operation_sequence_number, 0)
443 AND
444 NVL(p_bom_comp_ops_tbl(l_idx).organization_code, ' ') =
445 NVL(p_bom_comp_ops_tbl(p_entity_index).organization_code, ' ')
446 THEN
447 p_bom_comp_ops_tbl(l_idx).return_status :=
448 p_other_status;
449 /* Fix for bug 4661753 - added p_mesg_name to the call to Add_message procedure below. */
450 Add_Message
451 ( p_mesg_text => p_other_mesg_text
452 , p_entity_id => G_COP_LEVEL
453 , p_entity_index => l_idx
454 , p_message_type => 'E'
455 , p_mesg_name => p_other_mesg_name
456 , p_bom_header_rec =>p_bom_header_rec
457 , p_bom_revision_tbl =>p_bom_revision_tbl
458 , p_bom_component_tbl =>p_bom_component_tbl
459 , p_bom_ref_Designator_tbl =>p_bom_ref_Designator_tbl
460 , p_bom_sub_component_tbl =>p_bom_sub_component_tbl
461 , p_bom_comp_ops_tbl =>p_bom_comp_ops_tbl
462 );
463 END IF;
464 END LOOP;
465 END IF; -- If Scope = Ends.
466
467 END setCompOperations;
468
469 /******************************************************************
470 * Procedure : setSubComponents (Unexposed)
471 * Parameters : Other Message
472 * Other Status
473 * Error Scope
474 * Revised Item Index
475 * Revised Component Index
476 * Reference Designator Index
477 * Purpose : This procedure will set the reference designator
478 * record status to other status by looking at the
479 * revised item key or the revised component key or
480 * else setting all the record status to other status
481 ********************************************************************/
482 /* Fix for bug 4661753 - Added a new parameter p_other_mesg_name to the procedure below.*/
483 PROCEDURE setSubComponents
484 ( p_error_scope IN VARCHAR2
485 , p_other_mesg_text IN VARCHAR2
486 , p_other_status IN VARCHAR2
487 , p_rc_idx IN NUMBER := 0
488 , p_rd_idx IN NUMBER := 0
492 , p_bom_revision_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Revision_Tbl_Type
489 , p_entity_index IN NUMBER := 0
490 , p_other_mesg_name IN VARCHAR2 := NULL
491 , p_bom_header_rec IN OUT NOCOPY Bom_Bo_Pub.Bom_Head_Rec_Type
493 , p_bom_component_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Comps_Tbl_Type
494 , p_bom_ref_Designator_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type
495 , p_bom_sub_component_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type
496 , p_bom_comp_ops_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Comp_Ops_Tbl_Type
497 )
498 IS
499 l_idx NUMBER;
500 BEGIN
501
502 Error_Handler.Write_Debug('Setting substitute component records to ' || p_other_status);
503
504
505 IF p_error_scope = G_SCOPE_ALL
506 THEN
507 FOR l_idx IN 1..p_bom_sub_component_tbl.COUNT
508 LOOP
509 p_bom_sub_component_tbl(l_idx).return_status :=
510 p_other_status;
511 /* Put in fix in response to bug 851387
512 -- Added IF condition
513 -- Fix made by AS on 03/17/99
514 */
515 IF p_other_mesg_text IS NOT NULL
516 THEN
517 /* Fix for bug 4661753 - added p_mesg_name to the call to Add_message procedure below. */
518 Add_Message
519 ( p_mesg_text => p_other_mesg_text
520 , p_entity_id => G_SC_LEVEL
521 , p_entity_index=> l_idx
522 , p_message_type=> 'E'
523 , p_mesg_name => p_other_mesg_name
524 , p_bom_header_rec =>p_bom_header_rec
525 , p_bom_revision_tbl =>p_bom_revision_tbl
526 , p_bom_component_tbl =>p_bom_component_tbl
527 , p_bom_ref_Designator_tbl =>p_bom_ref_Designator_tbl
528 , p_bom_sub_component_tbl =>p_bom_sub_component_tbl
529 , p_bom_comp_ops_tbl =>p_bom_comp_ops_tbl
530 );
531 END IF;
532 END LOOP;
533 ELSIF p_error_scope = G_SCOPE_CHILDREN AND
534 p_rc_idx <> 0
535 THEN
536
537 Error_Handler.Write_Debug('Scope=Children in Substitute Component');
538 Error_Handler.Write_Debug('Inventory Component index <> 0');
539
540 FOR l_idx IN 1..p_bom_sub_component_tbl.COUNT
541 LOOP
542 IF NVL(p_bom_sub_component_tbl(l_idx).component_item_name, ' ')=
543 NVL(p_bom_component_tbl(p_rc_idx).component_item_name,' '
544 ) AND
545 NVL(p_bom_sub_component_tbl(l_idx).start_effective_date,
546 SYSDATE ) =
547 NVL(p_bom_component_tbl(p_rc_idx).start_effective_date,
548 SYSDATE )
549 AND
550 NVL(p_bom_sub_component_tbl(l_idx).operation_sequence_number,
551 0) =
552 NVL(p_bom_component_tbl(p_rc_idx).operation_sequence_number, 0)
553 AND
554 NVL(p_bom_sub_component_tbl(l_idx).organization_code, ' ') =
555 NVL(p_bom_component_tbl(p_rc_idx).organization_code, ' ')
556 THEN
557
558 p_bom_sub_component_tbl(l_idx).return_status :=
559 p_other_status;
560 /* Fix for bug 4661753 - added p_mesg_name to the call to Add_message procedure below. */
561 Add_Message
562 ( p_mesg_text => p_other_mesg_text
563 , p_entity_id => G_SC_LEVEL
564 , p_entity_index => l_idx
565 , p_message_type => 'E'
566 , p_mesg_name => p_other_mesg_name
567 , p_bom_header_rec =>p_bom_header_rec
568 , p_bom_revision_tbl =>p_bom_revision_tbl
569 , p_bom_component_tbl =>p_bom_component_tbl
570 , p_bom_ref_Designator_tbl =>p_bom_ref_Designator_tbl
571 , p_bom_sub_component_tbl =>p_bom_sub_component_tbl
572 , p_bom_comp_ops_tbl =>p_bom_comp_ops_tbl
573 );
574 END IF;
575 END LOOP; -- Ref. Desg Children of Rev Comps Ends.
576
577 ELSIF p_error_scope = G_SCOPE_SIBLINGS AND
578 p_rd_idx <> 0
579 THEN
580
581 Error_Handler.Write_Debug('Scope = Siblings in Sub. Components');
582 Error_Handler.Write_Debug('Reference Desg Index <> 0');
583
584 FOR l_idx IN 1..p_bom_sub_component_tbl.COUNT
585 LOOP
586 IF NVL(p_bom_sub_component_tbl(l_idx).component_item_name,' ') =
587 NVL(p_bom_ref_designator_tbl(p_rd_idx).component_item_name, ' ') AND
588 NVL(p_bom_sub_component_tbl(l_idx).start_effective_date, SYSDATE) =
592 NVL(p_bom_ref_designator_tbl(p_rd_idx).operation_sequence_number, 0)
589 NVL(p_bom_ref_designator_tbl(p_rd_idx).start_effective_date, SYSDATE)
590 AND
591 NVL(p_bom_sub_component_tbl(l_idx).operation_sequence_number, 0) =
593 AND
594 NVL(p_bom_sub_component_tbl(l_idx).organization_code, ' ') =
595 NVL(p_bom_ref_designator_tbl(p_rd_idx).organization_code, ' ')
596 THEN
597 --
598 -- Since bill sequence id is not available
599 -- match the revised item information also.
600 --
601 p_bom_sub_component_tbl(l_idx).return_status :=
602 p_other_status;
603 /* Fix for bug 4661753 - added p_mesg_name to the call to Add_message procedure below. */
604 Add_Message
605 ( p_mesg_text => p_other_mesg_text
606 , p_entity_id => G_SC_LEVEL
607 , p_entity_index => l_idx
608 , p_message_type => 'E'
609 , p_mesg_name => p_other_mesg_name
610 , p_bom_header_rec =>p_bom_header_rec
611 , p_bom_revision_tbl =>p_bom_revision_tbl
612 , p_bom_component_tbl =>p_bom_component_tbl
613 , p_bom_ref_Designator_tbl =>p_bom_ref_Designator_tbl
614 , p_bom_sub_component_tbl =>p_bom_sub_component_tbl
615 , p_bom_comp_ops_tbl =>p_bom_comp_ops_tbl
616 );
617 END IF;
618
619 END LOOP; -- Scope = Siblings with rd_idx <> 0 Ends
620
621 ELSIF p_error_scope = G_SCOPE_SIBLINGS AND
622 p_rc_idx = 0 AND
623 p_rd_idx = 0
624 THEN
625 --
626 -- This situation will arise when inventory comp and
627 -- reference designator are not part of the business object
628 -- input data.
629 -- Match the component key information at the entity index
630 -- location with rest of the records, all those that are found
631 -- will be siblings and should get an error.
632 --
633 Error_Handler.Write_Debug('Scope=Siblings in Substitute Component');
634 Error_Handler.Write_Debug('All entity indexes = 0');
635
636
637 FOR l_idx IN (p_entity_index+1)..p_bom_sub_component_tbl.COUNT
638 LOOP
639 IF NVL(p_bom_sub_component_tbl(l_idx).component_item_name, ' ') =
640 NVL(p_bom_sub_component_tbl(p_entity_index).component_item_name, ' ')
641 AND
642 NVL(p_bom_sub_component_tbl(l_idx).start_effective_date, SYSDATE) =
643 NVL(p_bom_sub_component_tbl(p_entity_index).start_effective_date, SYSDATE)
644 AND
645 NVL(p_bom_sub_component_tbl(l_idx).operation_sequence_number, 0) =
646 NVL(p_bom_sub_component_tbl(p_entity_index).operation_sequence_number, 0)
647 AND
648 NVL(p_bom_sub_component_tbl(l_idx).organization_code, ' ') =
649 NVL(p_bom_sub_component_tbl(p_entity_index).organization_code, ' ')
650 THEN
651 p_bom_sub_component_tbl(l_idx).return_status :=
652 p_other_status;
653 /* Fix for bug 4661753 - added p_mesg_name to the call to Add_message procedure below. */
654 Add_Message
655 ( p_mesg_text => p_other_mesg_text
656 , p_entity_id => G_SC_LEVEL
657 , p_entity_index => l_idx
658 , p_message_type => 'E'
659 , p_mesg_name => p_other_mesg_name
660 , p_bom_header_rec =>p_bom_header_rec
661 , p_bom_revision_tbl =>p_bom_revision_tbl
662 , p_bom_component_tbl =>p_bom_component_tbl
663 , p_bom_ref_Designator_tbl =>p_bom_ref_Designator_tbl
664 , p_bom_sub_component_tbl =>p_bom_sub_component_tbl
665 , p_bom_comp_ops_tbl =>p_bom_comp_ops_tbl
666 );
667 END IF;
668 END LOOP;
669 END IF; -- If Scope = Ends.
670
671 END setSubComponents;
672
673 /******************************************************************
674 * Procedure : setRefDesignators (Unexposed)
675 * Parameters : Other Message
676 * Other Status
677 * Error Scope
678 * Revised Item Index
679 * Revised Component Index
680 * Purpose : This procedure will set the reference designator
681 * record status to other status by looking at the
682 * revised item key or the revised component key or
683 * else setting all the record status to other status
684 ********************************************************************/
688 , p_other_mesg_text IN VARCHAR2
685 /* Fix for bug 4661753 - Added a new parameter p_other_mesg_name to the procedure below.*/
686 PROCEDURE setRefDesignators
687 ( p_error_scope IN VARCHAR2
689 , p_other_status IN VARCHAR2
690 , p_rc_idx IN NUMBER DEFAULT 0
691 , p_entity_index IN NUMBER DEFAULT 0
692 , p_other_mesg_name IN VARCHAR2 := NULL
693 , p_bom_header_rec IN OUT NOCOPY Bom_Bo_Pub.Bom_Head_Rec_Type
694 , p_bom_revision_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Revision_Tbl_Type
695 , p_bom_component_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Comps_Tbl_Type
696 , p_bom_ref_Designator_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type
697 , p_bom_sub_component_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type
698 , p_bom_comp_ops_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Comp_Ops_Tbl_Type
699 )
700 IS
701 l_idx NUMBER;
702 BEGIN
703
704 IF p_error_scope = G_SCOPE_ALL
705 THEN
706 FOR l_idx IN (p_entity_index+1)..p_bom_ref_designator_tbl.COUNT
707 LOOP
708 p_bom_ref_designator_tbl(l_idx).return_status :=
709 p_other_status;
710 /* Put in fix in response to bug 851387
711 -- Added IF condition
712 -- Fix made by AS on 03/17/99
713 */
714 IF p_other_mesg_text IS NOT NULL
715 THEN
716 /* Fix for bug 4661753 - added p_mesg_name to the call to Add_message procedure below. */
717 Add_Message
718 ( p_mesg_text => p_other_mesg_text
719 , p_entity_id => G_RD_LEVEL
720 , p_entity_index=> l_idx
721 , p_message_type=> 'E'
722 , p_mesg_name => p_other_mesg_name
723 , p_bom_header_rec =>p_bom_header_rec
724 , p_bom_revision_tbl =>p_bom_revision_tbl
725 , p_bom_component_tbl =>p_bom_component_tbl
726 , p_bom_ref_Designator_tbl =>p_bom_ref_Designator_tbl
727 , p_bom_sub_component_tbl =>p_bom_sub_component_tbl
728 , p_bom_comp_ops_tbl =>p_bom_comp_ops_tbl
729 );
730 END IF;
731 END LOOP;
732 --
733 -- Set the Substitute Components Record Status too
734 --
735 /* Fix for bug 4661753 - added p_other_mesg_name to the call to setSubComponents procedure below. */
736 setSubComponents
737 ( p_other_status => p_other_status
738 , p_other_mesg_text => p_other_mesg_text
739 , p_error_scope => p_error_scope
740 , p_other_mesg_name => p_other_mesg_name
741 , p_bom_header_rec =>p_bom_header_rec
742 , p_bom_revision_tbl =>p_bom_revision_tbl
743 , p_bom_component_tbl =>p_bom_component_tbl
744 , p_bom_ref_Designator_tbl =>p_bom_ref_Designator_tbl
745 , p_bom_sub_component_tbl =>p_bom_sub_component_tbl
746 , p_bom_comp_ops_tbl =>p_bom_comp_ops_tbl
747 );
748 ELSIF p_error_scope = G_SCOPE_CHILDREN AND
749 p_rc_idx <> 0
750 THEN
751
752 Error_Handler.Write_Debug('Scope=Children in Reference Designator');
753 Error_Handler.Write_Debug('Inventory Component index <> 0');
754
755 FOR l_idx IN 1..p_bom_ref_designator_tbl.COUNT
756 LOOP
757 IF NVL(p_bom_ref_designator_tbl(l_idx).component_item_name,
758 ' ') =
759 NVL(p_bom_component_tbl(p_rc_idx).component_item_name,
760 ' ') AND
761 NVL(p_bom_ref_designator_tbl(l_idx).start_effective_date, SYSDATE) =
762 NVL(p_bom_component_tbl(p_rc_idx).start_effective_date, SYSDATE) AND
763 NVL(p_bom_ref_designator_tbl(l_idx).operation_sequence_number, 0) =
764 NVL(p_bom_component_tbl(p_rc_idx).operation_sequence_number, 0)
765 AND
766 NVL(p_bom_ref_designator_tbl(l_idx).organization_code, ' ')=
767 NVL(p_bom_component_tbl(p_rc_idx).organization_code, ' ')
768 THEN
769
770 p_bom_ref_designator_tbl(l_idx).return_status :=
771 p_other_status;
772 /* Fix for bug 4661753 - added p_mesg_name to the call to Add_message procedure below. */
773 Add_Message
774 ( p_mesg_text => p_other_mesg_text
775 , p_entity_id => G_RD_LEVEL
776 , p_entity_index => l_idx
777 , p_message_type => 'E'
778 , p_mesg_name => p_other_mesg_name
779 , p_bom_header_rec =>p_bom_header_rec
780 , p_bom_revision_tbl =>p_bom_revision_tbl
784 , p_bom_comp_ops_tbl =>p_bom_comp_ops_tbl
781 , p_bom_component_tbl =>p_bom_component_tbl
782 , p_bom_ref_Designator_tbl =>p_bom_ref_Designator_tbl
783 , p_bom_sub_component_tbl =>p_bom_sub_component_tbl
785 );
786 END IF;
787 END LOOP; -- Ref. Desg Children of Rev Comps Ends.
788
789 ELSIF p_error_scope = G_SCOPE_SIBLINGS AND
790 p_rc_idx = 0
791 THEN
792 --
793 -- This situation will arise when comp is
794 -- not part of the business object input data.
795 -- Match the component key information at the entity index
796 -- location with rest of the records, all those that are found
797 -- will be siblings and should get an error.
798 --
799
800 Error_Handler.Write_Debug('Scope=Siblings in Reference Designator');
801 Error_Handler.Write_Debug('All Indexes = 0');
802
803 FOR l_idx IN (p_entity_index+1)..p_bom_ref_designator_tbl.COUNT
804 LOOP
805 IF NVL(p_bom_ref_designator_tbl(l_idx).component_item_name,
806 ' ') =
807 NVL(p_bom_ref_designator_tbl(p_entity_index).component_item_name, ' ')
808 AND
809 NVL(p_bom_ref_designator_tbl(l_idx).start_effective_date, SYSDATE) =
810 NVL(p_bom_ref_designator_tbl(p_entity_index).start_effective_date, SYSDATE)
811 AND
812 NVL(p_bom_ref_designator_tbl(l_idx).operation_sequence_number, 0) =
813 NVL(p_bom_ref_designator_tbl(p_entity_index).operation_sequence_number, 0)
814 AND
815 NVL(p_bom_ref_designator_tbl(l_idx).organization_code, ' ') =
816 NVL(p_bom_ref_designator_tbl(p_entity_index).organization_code, ' ')
817 THEN
818 p_bom_ref_designator_tbl(l_idx).return_status :=
819 p_other_status;
820 /* Fix for bug 4661753 - added p_mesg_name to the call to Add_message procedure below. */
821 Add_Message
822 ( p_mesg_text => p_other_mesg_text
823 , p_entity_id => G_RD_LEVEL
824 , p_entity_index => l_idx
825 , p_message_type => 'E'
826 , p_mesg_name => p_other_mesg_name
827 , p_bom_header_rec =>p_bom_header_rec
828 , p_bom_revision_tbl =>p_bom_revision_tbl
829 , p_bom_component_tbl =>p_bom_component_tbl
830 , p_bom_ref_Designator_tbl =>p_bom_ref_Designator_tbl
831 , p_bom_sub_component_tbl =>p_bom_sub_component_tbl
832 , p_bom_comp_ops_tbl =>p_bom_comp_ops_tbl
833 );
834 END IF;
835 END LOOP;
836
837 --
838 -- Substitute Components will also be considered as siblings
839 -- of reference designators, they should get an error when
840 -- error level is reference designator with scope of Siblings
841 --
842 /* Fix for bug 4661753 - added p_other_mesg_name to the call to procedure setSubComponents below. */
843 setSubComponents
844 ( p_other_status => p_other_status
845 , p_other_mesg_text => p_other_mesg_text
846 , p_error_scope => p_error_scope
847 , p_rd_idx => p_entity_index
848 , p_other_mesg_name => p_other_mesg_name
849 , p_bom_header_rec =>p_bom_header_rec
850 , p_bom_revision_tbl =>p_bom_revision_tbl
851 , p_bom_component_tbl =>p_bom_component_tbl
852 , p_bom_ref_Designator_tbl =>p_bom_ref_Designator_tbl
853 , p_bom_sub_component_tbl =>p_bom_sub_component_tbl
854 , p_bom_comp_ops_tbl =>p_bom_comp_ops_tbl
855 );
856 END IF; -- If error scope Ends
857
858 END setRefDesignators;
859
860 /*****************************************************************
861 * Procedure : setInventory_Components(Unexposed)
862 * Parameters IN : Other Message Text
863 * Other status
864 * Entity Index
865 * Error Scope
866 * Error Status
867 * Revised Item Index
868 * Parameters OUT: None
869 * Purpose : This procedure will set the revised components record
870 * status to other status and for each errored record
871 * it will log the other message indicating what caused
872 * the other records to fail.
873 ******************************************************************/
874 /* Fix for bug 4661753 - Added a new parameter p_other_mesg_name to the procedure below.*/
875 PROCEDURE setInventory_Components
876 ( p_error_scope IN VARCHAR2
877 , p_other_mesg_text IN VARCHAR2
878 , p_other_status IN VARCHAR2
882 , p_bom_revision_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Revision_Tbl_Type
879 , p_entity_index IN NUMBER := 0
880 , p_other_mesg_name IN VARCHAR2 := NULL
881 , p_bom_header_rec IN OUT NOCOPY Bom_Bo_Pub.Bom_Head_Rec_Type
883 , p_bom_component_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Comps_Tbl_Type
884 , p_bom_ref_Designator_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type
885 , p_bom_sub_component_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type
886 , p_bom_comp_ops_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Comp_Ops_Tbl_Type
887 )
888 IS
889 l_Idx NUMBER;
890 BEGIN
891
892
893 IF p_error_scope = G_SCOPE_ALL
894 THEN
895
896 Error_Handler.Write_Debug('Scope=All in Inventory Components');
897
898 FOR l_idx IN 1..p_bom_component_tbl.COUNT
899 LOOP
900 p_bom_component_tbl(l_idx).return_status :=
901 p_other_status;
902 /* Put in fix in response to bug 851387
903 -- Added IF condition
904 -- Fix made by AS on 03/17/99
905 */
906 IF p_other_mesg_text IS NOT NULL
907 THEN
908 /* Fix for bug 4661753 - added p_mesg_name to the call to Add_message procedure below. */
909 Add_Message
910 ( p_mesg_text => p_other_mesg_text
911 , p_entity_id => G_RC_LEVEL
912 , p_entity_index=> l_Idx
913 , p_message_type=> 'E'
914 , p_mesg_name => p_other_mesg_name
915 , p_bom_header_rec =>p_bom_header_rec
916 , p_bom_revision_tbl =>p_bom_revision_tbl
917 , p_bom_component_tbl =>p_bom_component_tbl
918 , p_bom_ref_Designator_tbl =>p_bom_ref_Designator_tbl
919 , p_bom_sub_component_tbl =>p_bom_sub_component_tbl
920 , p_bom_comp_ops_tbl =>p_bom_comp_ops_tbl
921 );
922 END IF;
923
924 END LOOP;
925
926 --
927 -- Set the reference designator and substitute
928 -- component record status too.
929 --
930 /* Fix for bug 4661753 - added p_other_mesg_name to the call to setRefDesignators procedure below. */
931 setRefDesignators
932 ( p_other_status => p_other_status
933 , p_error_scope => p_error_scope
934 , p_other_mesg_text => p_other_mesg_text
935 , p_other_mesg_name => p_other_mesg_name
936 , p_bom_header_rec =>p_bom_header_rec
937 , p_bom_revision_tbl =>p_bom_revision_tbl
938 , p_bom_component_tbl =>p_bom_component_tbl
939 , p_bom_ref_Designator_tbl =>p_bom_ref_Designator_tbl
940 , p_bom_sub_component_tbl =>p_bom_sub_component_tbl
941 , p_bom_comp_ops_tbl =>p_bom_comp_ops_tbl
942 );
943
944 --
945 -- Set the component operation record status too.
946 --
947 /* Fix for bug 4661753 - added p_other_mesg_name to the call to setRefDesignators procedure below. */
948 setCompOperations
949 ( p_other_status => p_other_status
950 , p_error_scope => p_error_scope
951 , p_other_mesg_text => p_other_mesg_text
952 , p_other_mesg_name => p_other_mesg_name
953 , p_bom_header_rec =>p_bom_header_rec
954 , p_bom_revision_tbl =>p_bom_revision_tbl
955 , p_bom_component_tbl =>p_bom_component_tbl
956 , p_bom_ref_Designator_tbl =>p_bom_ref_Designator_tbl
957 , p_bom_sub_component_tbl =>p_bom_sub_component_tbl
958 , p_bom_comp_ops_tbl =>p_bom_comp_ops_tbl
959 );
960
961 END IF; -- Error Scope Ends
962
963 END setInventory_Components;
964
965
966 /*****************************************************************
967 * Procedure : setRevisions (unexposed)
968 * Parameters IN : Other Message Text
969 * Other status
970 * Entity Index
971 * Parameters OUT: None
972 * Purpose : This procedure will set the Item Revisions record
973 * status to other status and for each errored record
974 * it will log the other message indicating what caused
975 * the other records to fail.
976 ******************************************************************/
977 /* Fix for bug 4661753 - Added a new parameter p_other_mesg_name to the procedure below.*/
978 PROCEDURE setRevisions
979 ( p_other_mesg_text IN VARCHAR2
983 , p_bom_revision_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Revision_Tbl_Type
980 , p_other_status IN VARCHAR2
981 , p_other_mesg_name IN VARCHAR2 := NULL
982 , p_bom_header_rec IN OUT NOCOPY Bom_Bo_Pub.Bom_Head_Rec_Type
984 , p_bom_component_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Comps_Tbl_Type
985 , p_bom_ref_Designator_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type
986 , p_bom_sub_component_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type
987 , p_bom_comp_ops_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Comp_Ops_Tbl_Type
988 )
989 IS
990 l_CurrentIndex NUMBER;
991 BEGIN
992
993 FOR l_CurrentIndex IN 1..p_bom_revision_tbl.COUNT
994 LOOP
995 p_bom_revision_tbl(l_CurrentIndex).return_status :=
996 p_other_status;
997 IF p_other_mesg_text IS NOT NULL
998 THEN
999 /* Fix for bug 4661753 - added p_mesg_name to the call to Add_message procedure below. */
1000 Add_Message
1001 ( p_mesg_text => p_other_mesg_text
1002 , p_entity_id => G_REV_LEVEL
1003 , p_entity_index => l_CurrentIndex
1004 , p_message_type => 'E'
1005 , p_mesg_name => p_other_mesg_name
1006 , p_bom_header_rec =>p_bom_header_rec
1007 , p_bom_revision_tbl =>p_bom_revision_tbl
1008 , p_bom_component_tbl =>p_bom_component_tbl
1009 , p_bom_ref_Designator_tbl =>p_bom_ref_Designator_tbl
1010 , p_bom_sub_component_tbl =>p_bom_sub_component_tbl
1011 , p_bom_comp_ops_tbl =>p_bom_comp_ops_tbl
1012 );
1013 END IF;
1014 END LOOP;
1015
1016 END setRevisions;
1017
1018 /*********************************************************************
1019 * Function : Translate_Message
1020 * Returns : VARCHAR2 (Translated Message)
1021 * Parameters IN : Application id
1022 * Message Name
1023 * Token Table
1024 * Parameters OUT: Translated Message
1025 **********************************************************************/
1026
1027 FUNCTION Translate_Message (p_application_id IN VARCHAR2
1028 ,p_message_name IN VARCHAR2
1029 ,p_token_tbl IN Error_Handler.Token_Tbl_Type
1030 := Error_Handler.G_MISS_TOKEN_TBL)
1031 RETURN VARCHAR2 IS
1032 BEGIN
1033 IF p_token_tbl.COUNT IS NOT NULL
1034 THEN
1035
1036 Fnd_Message.Set_Name ( application => p_application_id,
1037 name => p_message_name
1038 );
1039
1040 FOR l_LoopIndex IN 1..p_token_tbl.COUNT
1041 LOOP
1042 IF p_token_tbl(l_LoopIndex).token_name IS NOT NULL
1043 THEN
1044 Fnd_Message.Set_Token ( token =>
1045 p_token_tbl(l_LoopIndex).token_name
1046 , value =>
1047 p_token_tbl(l_LoopIndex).token_value
1048 , translate =>
1049 p_token_tbl(l_LoopIndex).translate
1050 );
1051 END IF;
1052 END LOOP;
1053 Return (Fnd_Message.Get);
1054
1055 ELSE
1056
1057 Fnd_Message.Set_Name ( application => p_application_id,
1058 name => p_message_name
1059 );
1060 Return (Fnd_Message.Get);
1061
1062 END IF;
1063
1064 END;
1065
1066 /**********************************************************************
1067 * Procedure : Add_Error_Token
1068 * Parameters IN : Message Text (in case of unexpected errors)
1069 * Message Name
1070 * Mesg Token Tbl
1071 * Token Table
1072 * Parameters OUT: Mesg Token Table
1073 * Purpose : This procedure will add the message to the
1074 * message token table.
1075 **********************************************************************/
1076 PROCEDURE Add_Error_Token
1077 ( p_message_name IN VARCHAR2 := NULL
1078 , p_application_id IN VARCHAR2 := 'ENG'
1079 , p_message_text IN VARCHAR2 := NULL
1080 , x_Mesg_Token_tbl IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
1081 , p_Mesg_Token_Tbl IN Error_Handler.Mesg_Token_Tbl_Type :=
1082 Error_Handler.G_MISS_MESG_TOKEN_TBL
1083 , p_token_tbl IN Error_Handler.Token_Tbl_Type :=
1084 Error_Handler.G_MISS_TOKEN_TBL
1085 , p_message_type IN VARCHAR2 := 'E'
1086 )
1087 IS
1088 l_Index NUMBER;
1089 l_TableCount NUMBER;
1090 l_Mesg_Token_Tbl Error_Handler.Mesg_Token_Tbl_Type ;
1091 l_message_text VARCHAR2(2000);
1095 l_TableCount := l_Mesg_token_tbl.COUNT;
1092 BEGIN
1093
1094 l_Mesg_Token_Tbl := p_Mesg_Token_Tbl;
1096
1097 IF p_message_name IS NOT NULL
1098 THEN
1099 l_message_text := Translate_Message( p_application_id => substr(p_message_name,1,3),
1100 p_message_name => p_message_name,
1101 p_token_tbl => p_token_tbl);
1102 ELSE
1103 l_message_text := p_message_text;
1104 END IF;
1105
1106 l_mesg_token_tbl(l_TableCount+1).message_text :=
1107 l_message_text;
1108 l_mesg_token_tbl(l_TableCount+1).message_type :=
1109 p_message_type;
1110 l_mesg_token_tbl(l_TableCount+1).message_name := p_message_name;
1111 /*Fix for bug 4661753- Added message_name also to the l_Mesg_Token_Tbl above.*/
1112
1113 x_mesg_token_tbl := l_mesg_token_tbl;
1114
1115 END Add_Error_Token;
1116
1117 /**********************************************************************
1118 * Procedure : Add_Error_Message
1119 * Parameters IN : Message Text (in case of unexpected errors)
1120 * Free text
1121 * Message Name
1122 * FND message name
1123 * Application Id
1124 * Applicaion short name under which the
1125 * message is defined
1126 * Token Table
1127 * Token Table of type TOKEN_TBL_TYPE
1128 * Message Type
1129 * W -> Warning
1130 * E -> Error
1131 * Entity Id
1132 * Entity identifier which is defined as a
1133 * constant in the error handler
1134 * Entity Index
1135 * The order of the entity record within
1136 * the entity table
1137 * Entity Code
1138 * Replacement for entity id. This can be
1139 * used when there is no constant defined
1140 * in the error handler for the entity.
1141 * When both are passed entity code will be
1142 * used as entity identifier
1143 * Row Identifier
1144 * Any unique identifier value for the entity record.
1145 * In case of bulk load from interface table this can
1146 * be used to store the transaction_id
1147 * Table Name
1148 * Production table name where the data goes in.
1149 * This is useful when the same logical entity deals
1150 * with multiple tables.
1151 * A typical example would be extensible attributes for an
1152 * entity. Logically, the entity is same but the data is
1153 * going into two tables (ex: BOM_BILL_OF_MATERIALS and
1154 * BOM_BILL_OF_MATERIALS_EXT)
1155 *
1156 * Parameters OUT: None
1157 * Purpose : This procedure will translate and add the message directly into
1158 * the error stack with all the context information
1159 **********************************************************************/
1160
1161 PROCEDURE Add_Error_Message
1162 ( p_message_name IN VARCHAR2 := NULL
1163 , p_application_id IN VARCHAR2 := 'BOM'
1164 , p_message_text IN VARCHAR2 := NULL
1165 , p_token_tbl IN Error_Handler.Token_Tbl_Type :=
1166 Error_Handler.G_MISS_TOKEN_TBL
1167 , p_message_type IN VARCHAR2 := 'E'
1168 , p_row_identifier IN NUMBER := NULL
1169 , p_entity_id IN NUMBER := NULL
1170 , p_entity_index IN NUMBER := NULL
1171 , p_table_name IN VARCHAR2 := NULL
1172 , p_entity_code IN VARCHAR2 := NULL
1173 , p_addto_fnd_stack IN VARCHAR2 := 'N'
1174 ) IS
1175
1176 Begin
1177 Add_Error_Message
1178 ( p_message_name
1179 , p_application_id
1180 , p_message_text
1181 , p_token_tbl
1182 , p_message_type
1183 , p_row_identifier
1184 , p_entity_id
1185 , p_entity_index
1186 , p_table_name
1187 , p_entity_code
1188 , p_addto_fnd_stack
1189 , Bom_Bo_Pub.G_MISS_BOM_HEADER_REC
1190 , Bom_Bo_Pub.G_MISS_BOM_REVISION_TBL
1191 , Bom_Bo_Pub.G_MISS_BOM_COMPONENT_TBL
1192 , Bom_Bo_Pub.G_MISS_BOM_REF_DESIGNATOR_TBL
1193 , Bom_Bo_Pub.G_MISS_BOM_SUB_COMPONENT_TBL
1194 , Bom_Bo_Pub.G_MISS_BOM_COMP_OPS_TBL
1195 );
1196
1197 END;
1198
1199
1200
1201 PROCEDURE Add_Error_Message
1202 ( p_message_name IN VARCHAR2 := NULL
1203 , p_application_id IN VARCHAR2 := 'BOM'
1204 , p_message_text IN VARCHAR2 := NULL
1205 , p_token_tbl IN Error_Handler.Token_Tbl_Type :=
1206 Error_Handler.G_MISS_TOKEN_TBL
1207 , p_message_type IN VARCHAR2 := 'E'
1208 , p_row_identifier IN NUMBER := NULL
1209 , p_entity_id IN NUMBER := NULL
1210 , p_entity_index IN NUMBER := NULL
1211 , p_table_name IN VARCHAR2 := NULL
1212 , p_entity_code IN VARCHAR2 := NULL
1213 , p_addto_fnd_stack IN VARCHAR2 := 'N'
1214 , p_bom_header_rec IN OUT NOCOPY Bom_Bo_Pub.Bom_Head_Rec_Type
1215 , p_bom_revision_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Revision_Tbl_Type
1219 , p_bom_comp_ops_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Comp_Ops_Tbl_Type
1216 , p_bom_component_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Comps_Tbl_Type
1217 , p_bom_ref_Designator_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type
1218 , p_bom_sub_component_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type
1220 )
1221 IS
1222
1223 l_message_text VARCHAR2(2000);
1224
1225 BEGIN
1226
1227 IF p_message_name IS NOT NULL
1228 THEN
1229
1230 IF p_addto_fnd_stack = 'Y' THEN
1231 Fnd_Message.Set_Name(p_application_id,p_message_name);
1232 IF p_token_tbl.COUNT IS NOT NULL THEN
1233 FOR l_LoopIndex IN 1..p_token_tbl.COUNT
1234 LOOP
1235 IF p_token_tbl(l_LoopIndex).token_name IS NOT NULL THEN
1236 Fnd_Message.Set_Token ( token =>
1237 p_token_tbl(l_LoopIndex).token_name
1238 , value =>
1239 p_token_tbl(l_LoopIndex).token_value
1240 , translate =>
1241 p_token_tbl(l_LoopIndex).translate
1242 );
1243 END IF;
1244 END LOOP;
1245 END IF;
1246 Fnd_Msg_Pub.Add;
1247 END IF;
1248
1249 l_message_text := Translate_Message( p_application_id => p_application_id,
1250 p_message_name => p_message_name,
1251 p_token_tbl => p_token_tbl);
1252
1253 ELSE
1254
1255 IF p_addto_fnd_stack = 'Y' THEN
1256 Fnd_Msg_Pub.Add_Exc_Msg
1257 (p_error_text => p_message_text);
1258 END IF;
1259
1260 l_message_text := p_message_text;
1261
1262 END IF;
1263
1264 Add_Message ( p_mesg_text => l_message_text
1265 , p_entity_id => p_entity_id
1266 , p_entity_code => p_entity_code
1267 , p_entity_index => p_entity_index
1268 , p_message_type => p_message_type
1269 , p_row_identifier => p_row_identifier
1270 , p_table_name => p_table_name
1271 , p_mesg_name => p_message_name
1272 , p_bom_header_rec =>p_bom_header_rec
1273 , p_bom_revision_tbl =>p_bom_revision_tbl
1274 , p_bom_component_tbl =>p_bom_component_tbl
1275 , p_bom_ref_Designator_tbl =>p_bom_ref_Designator_tbl
1276 , p_bom_sub_component_tbl =>p_bom_sub_component_tbl
1277 , p_bom_comp_ops_tbl =>p_bom_comp_ops_tbl
1278 );
1279 END;
1280
1281
1282 /*********************************************************************
1283 * Procedure : Translate_And_Insert_Messages
1284 * Returns : None
1285 * Parameters IN : Message Token Table
1286 * Error Level
1287 * The entity level at which the error has
1288 * occured.This is same as entity id in the
1289 * other procedures (Add_Message, Add_Error_Message)
1290 * For explanation on entity id, entity index,
1291 * message type,row identifier, table name,
1292 * entity code parameters please refer to
1293 * Add_Error_Message API
1294 * Parameters OUT: Non
1295 * Purpose : This procedure will read through the message token
1296 * table and insert them into the message table with
1297 * the proper business object context.
1298 **********************************************************************/
1299
1300
1301 PROCEDURE Translate_And_Insert_Messages
1302 ( p_mesg_token_tbl IN Error_Handler.Mesg_Token_Tbl_Type
1303 , p_error_level IN NUMBER := NULL
1304 , p_entity_index IN NUMBER := NULL
1305 , p_application_id IN VARCHAR2 := 'ENG'
1306 , p_row_identifier IN NUMBER := NULL
1307 , p_table_name IN VARCHAR2 := NULL
1308 , p_entity_code IN VARCHAR2 := NULL
1309 ) IS
1310
1311 Begin
1312 Translate_And_Insert_Messages
1313 ( p_mesg_token_tbl
1314 , p_error_level
1315 , p_entity_index
1316 , p_application_id
1317 , p_row_identifier
1318 , p_table_name
1319 , p_entity_code
1320 , Bom_Bo_Pub.G_MISS_BOM_HEADER_REC
1321 , Bom_Bo_Pub.G_MISS_BOM_REVISION_TBL
1322 , Bom_Bo_Pub.G_MISS_BOM_COMPONENT_TBL
1323 , Bom_Bo_Pub.G_MISS_BOM_REF_DESIGNATOR_TBL
1324 , Bom_Bo_Pub.G_MISS_BOM_SUB_COMPONENT_TBL
1325 , Bom_Bo_Pub.G_MISS_BOM_COMP_OPS_TBL
1326 );
1327 END;
1328
1329
1330
1331 PROCEDURE Translate_And_Insert_Messages
1332 ( p_mesg_token_tbl IN Error_Handler.Mesg_Token_Tbl_Type
1333 , p_error_level IN NUMBER := NULL
1334 , p_entity_index IN NUMBER := NULL
1335 , p_application_id IN VARCHAR2 := 'ENG'
1336 , p_row_identifier IN NUMBER := NULL
1337 , p_table_name IN VARCHAR2 := NULL
1338 , p_entity_code IN VARCHAR2 := NULL
1339 , p_bom_header_rec IN OUT NOCOPY Bom_Bo_Pub.Bom_Head_Rec_Type
1343 , p_bom_sub_component_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type
1340 , p_bom_revision_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Revision_Tbl_Type
1341 , p_bom_component_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Comps_Tbl_Type
1342 , p_bom_ref_Designator_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type
1344 , p_bom_comp_ops_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Comp_Ops_Tbl_Type
1345 )
1346 IS
1347 l_message_text VARCHAR2(2000);
1348 l_message_name VARCHAR2(30);
1349 BEGIN
1350
1351 FOR l_LoopIndex IN 1..p_mesg_token_tbl.COUNT
1352 LOOP
1353 Add_Message
1354 ( p_mesg_text =>
1355 p_mesg_token_tbl(l_LoopIndex).message_text
1356 , p_entity_id => p_error_level
1357 , p_entity_index => p_entity_index
1358 , p_message_type =>
1359 p_mesg_token_tbl(l_LoopIndex).message_type
1360 , p_row_identifier => p_row_identifier
1361 , p_table_name => p_table_name
1362 , p_entity_code => p_entity_code
1363 , p_mesg_name => p_mesg_token_tbl(l_LoopIndex).message_name
1364 , p_bom_header_rec =>p_bom_header_rec
1365 , p_bom_revision_tbl =>p_bom_revision_tbl
1366 , p_bom_component_tbl =>p_bom_component_tbl
1367 , p_bom_ref_Designator_tbl =>p_bom_ref_Designator_tbl
1368 , p_bom_sub_component_tbl =>p_bom_sub_component_tbl
1369 , p_bom_comp_ops_tbl =>p_bom_comp_ops_tbl
1370 );
1371 END LOOP;
1372
1373 END Translate_And_Insert_Messages;
1374
1375
1376 /******************************************************************
1377 * Procedure : Log_Error
1378 * Parameters IN : Bill Header Record and Rest of the Entity Tables
1379 * Message Token Table
1380 * Other Message Table
1381 * Other Status
1382 * Entity Index
1383 * Error Level
1384 * Error Scope
1385 * Error Status
1386 * Parameters OUT: Bill Header Record and Rest of the Entity Tables
1387 * Purpose : Log Error will take the Message Token Table and
1388 * seperate the message and their tokens, get the
1389 * token substitute messages from the message dictionary
1390 * and put in the error stack.
1391 * Log Error will also make sure that the error
1392 * propogates to the right level's of the business object
1393 * and that the rest of the entities get the appropriate
1394 * status and message.
1395 ******************************************************************/
1396
1397 PROCEDURE Log_Error
1398 ( p_bom_header_rec IN Bom_Bo_Pub.Bom_Head_Rec_Type :=
1399 Bom_Bo_Pub.G_MISS_BOM_HEADER_REC
1400 , p_bom_revision_tbl IN Bom_Bo_Pub.Bom_Revision_Tbl_Type :=
1401 Bom_Bo_Pub.G_MISS_BOM_REVISION_TBL
1402 , p_bom_component_tbl IN Bom_Bo_Pub.Bom_Comps_Tbl_Type :=
1403 Bom_Bo_Pub.G_MISS_BOM_COMPONENT_TBL
1404 , p_bom_ref_Designator_tbl IN Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type
1405 := Bom_Bo_Pub.G_MISS_BOM_REF_DESIGNATOR_TBL
1406 , p_bom_sub_component_tbl IN Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type
1407 := Bom_Bo_Pub.G_MISS_BOM_SUB_COMPONENT_TBL
1408 , p_Mesg_Token_tbl IN Error_Handler.Mesg_Token_Tbl_Type
1409 := Error_Handler.G_MISS_MESG_TOKEN_TBL
1410 , p_error_status IN VARCHAR2
1411 , p_error_scope IN VARCHAR2 := NULL
1412 , p_other_message IN VARCHAR2 := NULL
1413 , p_other_mesg_appid IN VARCHAR2 := 'BOM'
1414 , p_other_status IN VARCHAR2 := NULL
1415 , p_other_token_tbl IN Error_Handler.Token_Tbl_Type
1416 := Error_Handler.G_MISS_TOKEN_TBL
1417 , p_error_level IN NUMBER
1418 , p_entity_index IN NUMBER := 1 -- := NULL
1419 , x_bom_header_rec IN OUT NOCOPY Bom_Bo_Pub.Bom_Head_Rec_Type
1420 , x_bom_revision_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Revision_Tbl_Type
1421 , x_bom_component_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Comps_Tbl_Type
1422 , x_bom_ref_Designator_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type
1423 , x_bom_sub_component_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type
1424 , p_row_identifier IN NUMBER := NULL
1425 )
1426 IS
1427 l_message_name VARCHAR2(30);
1428 l_other_message VARCHAR2(2000);
1429 l_message_text VARCHAR2(2000);
1430 l_LoopIndex NUMBER;
1431 l_Error_Level NUMBER := p_Error_Level;
1432 l_error_scope VARCHAR2(1) := p_error_scope;
1433 l_error_status VARCHAR2(1) := p_error_status;
1434 l_application_id VARCHAR2(3);
1435 BEGIN
1436
1437 -- g_bom_revision_tbl := p_bom_revision_tbl;
1438 -- g_bom_component_tbl := p_bom_component_tbl;
1442 l_application_id := p_other_mesg_appid;
1439 -- g_bom_ref_designator_tbl := p_bom_ref_designator_tbl;
1440 -- g_bom_sub_component_tbl := p_bom_sub_component_tbl;
1441
1443
1444
1445 /*************************************************
1446 --
1447 -- Seperate message and their tokens, get the
1448 -- token substituted messages and put it in the
1449 -- Error Table.
1450 --
1451 **************************************************/
1452
1453 Error_Handler.Write_Debug('Within the Log Error Procedure . . .');
1454 Error_Handler.Write_Debug('Scope: ' || l_error_scope);
1455 Error_Handler.Write_Debug('Entity Index: ' || to_char(p_entity_index));
1456 Error_Handler.Write_Debug('Error Level: ' || to_char(p_error_level));
1457 Error_Handler.Write_Debug('Error Status: ' || l_error_status);
1458 Error_Handler.Write_Debug('Other Status: ' || p_other_status);
1459 Error_Handler.Write_Debug('Other Message: ' || p_other_message);
1460 Error_Handler.Write_Debug('Business Object: ' || Bom_Globals.Get_Bo_Identifier);
1461
1462 Error_Handler.Translate_And_Insert_Messages
1463 ( p_mesg_token_Tbl => p_mesg_token_tbl
1464 , p_error_level => p_error_level
1465 , p_entity_index => p_entity_index
1466 , p_bom_header_rec =>x_bom_header_rec
1467 , p_bom_revision_tbl =>x_bom_revision_tbl
1468 , p_bom_component_tbl =>x_bom_component_tbl
1469 , p_bom_ref_Designator_tbl =>x_bom_ref_Designator_tbl
1470 , p_bom_sub_component_tbl =>x_bom_sub_component_tbl
1471 , p_bom_comp_ops_tbl =>g_bom_comp_ops_tbl
1472 );
1473
1474 Error_Handler.Write_Debug('Finished logging messages . . . ');
1475
1476 /**********************************************************
1477 --
1478 -- Get the other message text and token and retrieve the
1479 -- token substituted message.
1480 --
1481 ***********************************************************/
1482
1483 /* p_other_message contains the message_name (can be null).*/
1484 IF p_other_message IS NOT NULL
1485 THEN
1486 l_other_message := Translate_Message(p_application_id => p_other_mesg_appid,
1487 p_message_name => p_other_message,
1488 p_token_tbl => p_other_token_tbl);
1489 END IF;
1490
1491 Error_Handler.Write_Debug('Finished extracting other message . . . ');
1492 Error_Handler.Write_Debug('Other Message generated: ' || l_other_message);
1493
1494
1495 /**********************************************************
1496 --
1497 -- If the Error Level is Business Object
1498 -- then set the Error Level = ECO
1499 --
1500 ************************************************************/
1501 IF l_error_level = G_BO_LEVEL
1502 THEN
1503 l_error_level := G_BH_LEVEL;
1504
1505 Error_Handler.Write_Debug('Error Level is Business Object . . . ');
1506
1507 END IF;
1508 /**********************************************************
1509 --
1510 -- If the error_status is UNEXPECTED then set the error scope
1511 -- to ALL, if WARNING then set the scope to RECORD.
1512 --
1513 ************************************************************/
1514 IF l_error_status = G_STATUS_UNEXPECTED
1515 THEN
1516 Error_Handler.Write_Debug('Status unexpected and scope is All . . .');
1517 l_error_scope := G_SCOPE_ALL;
1518 ELSIF l_error_status = G_STATUS_WARNING
1519 THEN
1520 l_error_scope := G_SCOPE_RECORD;
1521 l_error_status := FND_API.G_RET_STS_SUCCESS;
1522 Error_Handler.Write_Debug('Status is warning . . .');
1523
1524 END IF;
1525
1526 --
1527 -- If the Error Level is Bill Header, then the scope can be
1528 -- ALL/CHILDREN OR RECORD.
1529 --
1530 /*************************************************************
1531 --
1532 -- If the Error Level is Bill Header.
1533 --
1534 *************************************************************/
1535 /* Fix for bug 4661753 - added p_other_message to the calls to Add_message,setInventory_Components,
1536 setRevisions, setRefDesignators, setSubComponents, setCompOperations procedures below.
1537 Note that p_other_message contains message_name (can be null) whereas l_other_message contains message_text.*/
1538 IF l_error_level = G_BH_LEVEL
1539 THEN
1540
1541 Error_Handler.Write_Debug('Error Level is Bill Header . . .');
1542 --
1543 -- Set the Bill Header record status to p_error_status
1544 -- This will also take care of the scope RECORD.
1545 --
1546 x_bom_header_rec.return_status := l_error_status;
1547
1548 IF p_other_message IS NOT NULL AND
1552 -- so that BO is the entity that the message
1549 p_error_level IN (G_BO_LEVEL, G_BH_LEVEL)
1550 THEN
1551 /* Changed l_error_level to p_error_level
1553 -- is logged for, and not ECO.
1554 -- Changed by AS on 03/17/99 for bug 851387
1555 */
1556 Add_Message
1557 ( p_mesg_text => l_other_message
1558 , p_entity_id => p_error_level
1559 , p_entity_index => p_entity_index
1560 , p_message_type => 'E'
1561 , p_mesg_name => p_other_message
1562 , p_bom_header_rec =>x_bom_header_rec
1563 , p_bom_revision_tbl =>x_bom_revision_tbl
1564 , p_bom_component_tbl =>x_bom_component_tbl
1565 , p_bom_ref_Designator_tbl =>x_bom_ref_Designator_tbl
1566 , p_bom_sub_component_tbl =>x_bom_sub_component_tbl
1567 , p_bom_comp_ops_tbl =>g_bom_comp_ops_tbl
1568 );
1569 l_other_message := NULL;
1570 END IF;
1571
1572
1573 IF l_error_scope = G_SCOPE_ALL OR
1574 l_error_scope = G_SCOPE_CHILDREN
1575 THEN
1576 IF x_bom_revision_tbl.COUNT <> 0
1577 THEN
1578 --
1579 -- Set all the revision record status
1580 --
1581 setRevisions
1582 ( p_other_mesg_text => l_other_message
1583 , p_other_status => p_other_status
1584 , p_other_mesg_name => p_other_message
1585 , p_bom_header_rec => x_bom_header_rec
1586 , p_bom_revision_tbl => x_bom_revision_tbl
1587 , p_bom_component_tbl => x_bom_component_tbl
1588 , p_bom_ref_Designator_tbl => x_bom_ref_Designator_tbl
1589 , p_bom_sub_component_tbl => x_bom_sub_component_tbl
1590 , p_bom_comp_ops_tbl => g_bom_comp_ops_tbl
1591 );
1592 END IF;
1593 --
1594 -- Set all the revised component's
1595 -- status, this will then set the
1596 -- status of the reference designators
1597 -- and substitute components
1598 --
1599 setInventory_Components
1600 ( p_other_mesg_text => l_other_message
1601 , p_other_status => p_other_status
1602 , p_error_scope => G_SCOPE_ALL
1603 , p_other_mesg_name => p_other_message
1604 , p_bom_header_rec =>x_bom_header_rec
1605 , p_bom_revision_tbl =>x_bom_revision_tbl
1606 , p_bom_component_tbl =>x_bom_component_tbl
1607 , p_bom_ref_Designator_tbl =>x_bom_ref_Designator_tbl
1608 , p_bom_sub_component_tbl =>x_bom_sub_component_tbl
1609 , p_bom_comp_ops_tbl =>g_bom_comp_ops_tbl
1610 );
1611
1612 END IF; -- Bill Header Scope = ALL or Children Ends
1613
1614 /***************************************************
1615 --
1616 -- Error Level = Item Revision
1617 --
1618 ***************************************************/
1619
1620 ELSIF l_error_level = G_REV_LEVEL
1621 THEN
1622 --
1623 -- Set the Revision record at the current entity_index
1624 -- This will take care of scope = RECORD
1625 --
1626 x_bom_revision_tbl(p_entity_index).return_status :=
1627 l_error_status;
1628
1629 IF l_error_scope = G_SCOPE_ALL
1630 THEN
1631 IF x_bom_revision_tbl.COUNT <> 0
1632 THEN
1633 --
1634 -- Set all the revision record status
1635 --
1636 setRevisions
1637 ( p_other_mesg_text => l_other_message
1638 , p_other_status => p_other_status
1639 , p_other_mesg_name => p_other_message
1640 , p_bom_header_rec =>x_bom_header_rec
1641 , p_bom_revision_tbl =>x_bom_revision_tbl
1642 , p_bom_component_tbl =>x_bom_component_tbl
1646 );
1643 , p_bom_ref_Designator_tbl =>x_bom_ref_Designator_tbl
1644 , p_bom_sub_component_tbl =>x_bom_sub_component_tbl
1645 , p_bom_comp_ops_tbl =>g_bom_comp_ops_tbl
1647 END IF;
1648
1649 --
1650 -- Set all the revised component's
1651 -- status, this will then set the
1652 -- status of the reference designators
1653 -- and substitute components
1654 --
1655 setInventory_Components
1656 ( p_other_mesg_text => l_other_message
1657 , p_other_status => p_other_status
1658 , p_error_scope => l_error_scope
1659 , p_other_mesg_name => p_other_message
1660 , p_bom_header_rec =>x_bom_header_rec
1661 , p_bom_revision_tbl =>x_bom_revision_tbl
1662 , p_bom_component_tbl =>x_bom_component_tbl
1663 , p_bom_ref_Designator_tbl =>x_bom_ref_Designator_tbl
1664 , p_bom_sub_component_tbl =>x_bom_sub_component_tbl
1665 , p_bom_comp_ops_tbl =>g_bom_comp_ops_tbl
1666 );
1667
1668 END IF;
1669 /********************************************
1670 --
1671 -- If the Error Level is Inventory COMPONENTS
1672 --
1673 *********************************************/
1674 ELSIF l_error_level = G_RC_LEVEL
1675 THEN
1676 --
1677 -- Set inventory component record at the entity_index
1678 -- to error_status
1679 -- This will take care of Scope = RECORD.
1680 --
1681 x_bom_component_tbl(p_entity_index).return_status :=
1682 l_error_status;
1683
1684 Error_Handler.Write_Debug('Error Level = Inventory components . . .');
1685
1686 IF l_error_scope = G_SCOPE_SIBLINGS OR
1687 l_error_scope = G_SCOPE_ALL
1688 THEN
1689 setInventory_Components
1690 ( p_other_mesg_text => l_other_message
1691 , p_other_status => p_other_status
1692 , p_error_scope => G_SCOPE_ALL
1693 , p_entity_index => p_entity_index
1694 , p_other_mesg_name => p_other_message
1695 , p_bom_header_rec =>x_bom_header_rec
1696 , p_bom_revision_tbl =>x_bom_revision_tbl
1697 , p_bom_component_tbl =>x_bom_component_tbl
1698 , p_bom_ref_Designator_tbl =>x_bom_ref_Designator_tbl
1699 , p_bom_sub_component_tbl =>x_bom_sub_component_tbl
1700 , p_bom_comp_ops_tbl =>g_bom_comp_ops_tbl
1701 );
1702 ELSIF l_error_scope = G_SCOPE_CHILDREN
1703 THEN
1704 IF x_bom_ref_designator_tbl.COUNT <> 0
1705 THEN
1706 setRefDesignators
1707 ( p_error_scope => l_error_scope
1708 , p_other_status => p_other_status
1709 , p_other_mesg_text => l_other_message
1710 , p_rc_idx => p_entity_index
1711 , p_other_mesg_name => p_other_message
1712 , p_bom_header_rec =>x_bom_header_rec
1713 , p_bom_revision_tbl =>x_bom_revision_tbl
1714 , p_bom_component_tbl =>x_bom_component_tbl
1715 , p_bom_ref_Designator_tbl =>x_bom_ref_Designator_tbl
1716 , p_bom_sub_component_tbl =>x_bom_sub_component_tbl
1717 , p_bom_comp_ops_tbl =>g_bom_comp_ops_tbl
1718 );
1719 END IF;
1720
1721 IF x_bom_sub_component_tbl.COUNT <> 0
1722 THEN
1723 setSubComponents
1724 ( p_error_scope => l_error_scope
1725 , p_other_status => p_other_status
1726 , p_other_mesg_text => l_other_message
1727 , p_rc_idx => p_entity_index
1728 , p_other_mesg_name => p_other_message
1729 , p_bom_header_rec =>x_bom_header_rec
1730 , p_bom_revision_tbl =>x_bom_revision_tbl
1731 , p_bom_component_tbl =>x_bom_component_tbl
1735 );
1732 , p_bom_ref_Designator_tbl =>x_bom_ref_Designator_tbl
1733 , p_bom_sub_component_tbl =>x_bom_sub_component_tbl
1734 , p_bom_comp_ops_tbl =>g_bom_comp_ops_tbl
1736 END IF;
1737 /* One to many operations suport */
1738 IF g_bom_comp_ops_tbl.COUNT <> 0
1739 THEN
1740 setCompOperations
1741 ( p_error_scope => l_error_scope
1742 , p_other_status => p_other_status
1743 , p_other_mesg_text => l_other_message
1744 , p_rc_idx => p_entity_index
1745 , p_other_mesg_name => p_other_message
1746 , p_bom_header_rec =>x_bom_header_rec
1747 , p_bom_revision_tbl =>x_bom_revision_tbl
1748 , p_bom_component_tbl =>x_bom_component_tbl
1749 , p_bom_ref_Designator_tbl =>x_bom_ref_Designator_tbl
1750 , p_bom_sub_component_tbl =>x_bom_sub_component_tbl
1751 , p_bom_comp_ops_tbl =>g_bom_comp_ops_tbl
1752 );
1753 END IF;
1754
1755 END IF; -- scope = Siblings or All Ends
1756 /***********************************************
1757 --
1758 -- If the Error Level is REFERENCE DESIGNATOR.
1759 --
1760 ************************************************/
1761 ELSIF l_error_level = G_RD_LEVEL
1762 THEN
1763 --
1764 -- Set reference designator record status at entity_idx
1765 -- This will take care of Scope = RECORD.
1766 --
1767 Error_Handler.Write_Debug('Error Level = Reference Designators . . .');
1768
1769 x_bom_ref_designator_tbl(p_entity_index).return_status
1770 := l_error_status;
1771 IF l_error_scope <> G_SCOPE_RECORD
1772 THEN
1773 setRefDesignators
1774 ( p_error_scope => l_error_scope
1775 , p_other_status => p_other_status
1776 , p_other_mesg_text => l_other_message
1777 , p_entity_index => p_entity_index
1778 , p_other_mesg_name => p_other_message
1779 , p_bom_header_rec =>x_bom_header_rec
1780 , p_bom_revision_tbl =>x_bom_revision_tbl
1781 , p_bom_component_tbl =>x_bom_component_tbl
1782 , p_bom_ref_Designator_tbl =>x_bom_ref_Designator_tbl
1783 , p_bom_sub_component_tbl =>x_bom_sub_component_tbl
1784 , p_bom_comp_ops_tbl =>g_bom_comp_ops_tbl
1785 );
1786 END IF;
1787 /***********************************************
1788 --
1789 -- If the Error Level is SUBSTITUTE COMPONENTS.
1790 --
1791 ************************************************/
1792 ELSIF l_error_level = G_SC_LEVEL
1793 THEN
1794 -- Set substitute component record status at entity_idx
1795 -- This will take care of Scope = RECORD.
1796 --
1797 Error_Handler.Write_Debug('Error Level = Substitute Components . . .');
1798
1799 x_bom_sub_component_tbl(p_entity_index).return_status :=
1800 l_error_status;
1801 IF l_error_scope <> G_SCOPE_RECORD
1802 THEN
1803 setSubComponents
1804 ( p_error_scope => l_error_scope
1805 , p_other_status => p_other_status
1806 , p_other_mesg_text => l_other_message
1807 , p_entity_index => p_entity_index
1808 , p_other_mesg_name => p_other_message
1809 , p_bom_header_rec =>x_bom_header_rec
1810 , p_bom_revision_tbl =>x_bom_revision_tbl
1811 , p_bom_component_tbl =>x_bom_component_tbl
1812 , p_bom_ref_Designator_tbl =>x_bom_ref_Designator_tbl
1813 , p_bom_sub_component_tbl =>x_bom_sub_component_tbl
1814 , p_bom_comp_ops_tbl =>g_bom_comp_ops_tbl
1815 );
1816 END IF;
1817 ELSIF l_error_level = G_COP_LEVEL
1818 THEN
1819 -- Set component operation record status at entity_idx
1820 -- This will take care of Scope = RECORD.
1821 --
1825 l_error_status;
1822 Error_Handler.Write_Debug('Error Level = Component Operations . . .');
1823
1824 g_bom_comp_ops_tbl(p_entity_index).return_status :=
1826 IF l_error_scope <> G_SCOPE_RECORD
1827 THEN
1828 setCompOperations
1829 ( p_error_scope => l_error_scope
1830 , p_other_status => p_other_status
1831 , p_other_mesg_text => l_other_message
1832 , p_entity_index => p_entity_index
1833 , p_other_mesg_name => p_other_message
1834 , p_bom_header_rec =>x_bom_header_rec
1835 , p_bom_revision_tbl =>x_bom_revision_tbl
1836 , p_bom_component_tbl =>x_bom_component_tbl
1837 , p_bom_ref_Designator_tbl =>x_bom_ref_Designator_tbl
1838 , p_bom_sub_component_tbl =>x_bom_sub_component_tbl
1839 , p_bom_comp_ops_tbl =>g_bom_comp_ops_tbl
1840 );
1841 END IF;
1842
1843 END IF; -- Error Level If Ends.
1844
1845 --
1846 -- Copy the changed record/Tables to the out parameters for
1847 -- returing to the calling program.
1848 --
1849 -- x_bom_header_rec := g_bom_header_rec;
1850 -- x_bom_revision_tbl := g_bom_revision_tbl;
1851 -- x_bom_component_tbl := g_bom_component_tbl;
1852 -- x_bom_ref_designator_tbl:= g_bom_ref_designator_tbl;
1853 -- x_bom_sub_component_tbl := g_bom_sub_component_tbl;
1854
1855 END Log_Error;
1856
1857
1858 /*********************************************************************
1859 * Procedure : Initialize
1860 * Parameters : None
1861 * Purpose : This procedure will initialize the global message
1862 * list and reset the index variables to 0.
1863 * User must initialize the message list before using
1864 * it.
1865 **********************************************************************/
1866 PROCEDURE Initialize
1867 IS
1868 BEGIN
1869
1870 G_Error_Table.DELETE;
1871 G_Msg_Count := 0;
1872 G_Msg_Index := 0;
1873
1874 END Initialize;
1875
1876 /********************************************************************
1877 * Procedure : Reset
1878 * Parameters : None
1879 * Purpose : Reset will reset the message index to the begining
1880 * of the list and the user can start reading the
1881 * messages again.
1882 *********************************************************************/
1883 PROCEDURE Reset
1884 IS
1885 BEGIN
1886
1887 g_Msg_Index := 0;
1888
1889 END Reset;
1890
1891 /********************************************************************
1892 * Procedure : Get_Message_List
1893 * Parameters : None
1894 * Purpose : This procedure will return the entire message
1895 * table out the user. The returned list will be
1896 * for a particular business object.
1897 *********************************************************************/
1898 PROCEDURE Get_Message_List
1899 ( x_Message_List IN OUT NOCOPY Error_Handler.Error_Tbl_Type)
1900 IS
1901 l_bo_identifier VARCHAR2(30) := Error_Handler.Get_Bo_Identifier;
1902 l_msg_count NUMBER := 1;
1903
1904 BEGIN
1905 FOR l_err_idx IN 1..G_ERROR_TABLE.COUNT
1906 LOOP
1907 IF G_Error_Table(l_err_idx).bo_identifier =
1908 l_bo_identifier
1909 THEN
1910 x_message_list(l_msg_count) :=
1911 G_Error_Table(l_err_idx);
1912 l_msg_Count := l_msg_count + 1;
1913 END IF;
1914 END LOOP;
1915
1916 END Get_Message_List;
1917
1918
1919 /********************************************************************
1920 * Procedure : Get_Entity_Message
1921 * Parameters IN : Entity Id
1922 * Parameters OUT: Error List
1923 * Purpose : This procedure will return all the messages for
1924 * a specific Entity.
1925 *********************************************************************/
1926 PROCEDURE Get_Entity_Message
1927 ( p_entity_id IN VARCHAR2
1928 , x_Message_List IN OUT NOCOPY Error_Handler.Error_Tbl_Type
1929 )
1930 IS
1931 l_Idx NUMBER;
1932 l_Mesg_List Error_Handler.Error_Tbl_Type;
1933 l_Count NUMBER := 1;
1934 l_bo_identifier VARCHAR2(30) := Error_Handler.Get_Bo_Identifier;
1935 BEGIN
1936 Error_Handler.Write_Debug('Get Messages for Entity : ' || p_entity_id);
1940 LOOP
1937 Error_Handler.Write_Debug('Table Size = ' || to_char(G_Msg_Count));
1938
1939 FOR l_Idx IN 1..NVL(G_Msg_Count, 0)
1941 IF G_Error_Table(l_idx).entity_id = p_entity_id AND
1942 G_Error_Table(l_Idx).bo_identifier = l_bo_identifier
1943 THEN
1944 l_mesg_list(l_count) := G_Error_Table(l_Idx);
1945 l_Count := l_Count + 1;
1946 END IF;
1947 END LOOP;
1948 x_Message_List := l_Mesg_List;
1949
1950 END Get_Entity_Message;
1951
1952 /*********************************************************************
1953 * Procedure : Get_Entity_Message
1954 * Parameters IN : Entity Id
1955 * Entity Index
1956 * Parameters OUT: Message Text
1957 * Purpose : This procedure will return all the messages for
1958 * an entity and its index
1959 *********************************************************************/
1960 PROCEDURE Get_Entity_Message
1961 ( p_entity_id IN VARCHAR2
1962 , p_entity_index IN NUMBER
1963 , x_Message_List IN OUT NOCOPY Error_Handler.Error_Tbl_Type
1964 )
1965 IS
1966 l_Mesg_List Error_Handler.Error_Tbl_Type;
1967 l_Count NUMBER := 1;
1968 l_bo_identifier VARCHAR2(30) := Error_Handler.Get_Bo_Identifier;
1969 BEGIN
1970 FOR l_Idx IN 1..NVL(G_Msg_Count, 0)
1971 LOOP
1972 IF G_Error_Table(l_idx).entity_id = p_entity_id AND
1973 G_Error_Table(l_idx).entity_index = p_entity_index
1974 AND
1975 G_Error_Table(l_idx).bo_identifier = l_bo_identifier
1976 THEN
1977 l_mesg_list(l_count) := G_Error_Table(l_Idx);
1978 l_Count := l_Count + 1;
1979 END IF;
1980 END LOOP;
1981 x_Message_List := l_Mesg_List;
1982
1983 END Get_Entity_Message;
1984
1985 /* This is a deprecated procedure */
1986
1987 PROCEDURE Get_Entity_Message
1988 ( p_entity_id IN VARCHAR2
1989 , p_entity_index IN NUMBER
1990 , x_message_text IN OUT NOCOPY /* file.sql.39 change */ VARCHAR2
1991 )
1992 IS
1993 BEGIN
1994 x_message_text := 'This method is no longer supported. Messages returned from this call could be more than one. Please use the other method which returns a list of messages';
1995
1996 return;
1997 END;
1998
1999 /*********************************************************************
2000 * Procedure : Get_Entity_Message
2001 * Parameters IN : Entity Id
2002 * Row Identifier
2003 * Parameters OUT: Message List
2004 * Purpose : This procedure will return all the messages for
2005 * an entity and its row identifier
2006 *********************************************************************/
2007 PROCEDURE Get_Entity_Message
2008 ( p_entity_id IN VARCHAR2
2009 , p_row_identifier IN NUMBER
2010 , x_Message_List IN OUT NOCOPY Error_Handler.Error_Tbl_Type
2011 )
2012 IS
2013 l_Mesg_List Error_Handler.Error_Tbl_Type;
2014 l_Count NUMBER := 1;
2015 l_bo_identifier VARCHAR2(30) := Error_Handler.Get_Bo_Identifier;
2016 BEGIN
2017 FOR l_Idx IN 1..NVL(G_Msg_Count, 0)
2018 LOOP
2019 IF G_Error_Table(l_idx).entity_id = p_entity_id AND
2020 G_Error_Table(l_idx).row_identifier = p_row_identifier
2021 AND
2022 G_Error_Table(l_idx).bo_identifier = l_bo_identifier
2023 THEN
2024 l_mesg_list(l_count) := G_Error_Table(l_Idx);
2025 l_Count := l_Count + 1;
2026 END IF;
2027 END LOOP;
2028 x_Message_List := l_Mesg_List;
2029
2030 END Get_Entity_Message;
2031
2032 /*********************************************************************
2033 * Procedure : Get_Entity_Message
2034 * Parameters IN : Entity Id
2035 * Table Name
2036 * Row Identifier
2037 * Parameters OUT: Message List
2038 * Purpose : This procedure will return all the messages for
2039 * an entity and its row identifier
2040 *********************************************************************/
2041 PROCEDURE Get_Entity_Message
2042 ( p_entity_id IN VARCHAR2
2043 , p_table_name IN VARCHAR2
2044 , p_row_identifier IN NUMBER
2045 , x_Message_List IN OUT NOCOPY Error_Handler.Error_Tbl_Type
2046 )
2047 IS
2048 l_Mesg_List Error_Handler.Error_Tbl_Type;
2049 l_Count NUMBER := 1;
2050 l_bo_identifier VARCHAR2(30) := Error_Handler.Get_Bo_Identifier;
2051 BEGIN
2052 FOR l_Idx IN 1..NVL(G_Msg_Count, 0)
2053 LOOP
2057 AND
2054 IF G_Error_Table(l_idx).entity_id = p_entity_id AND
2055 G_Error_Table(l_idx).table_name = p_table_name AND
2056 G_Error_Table(l_idx).row_identifier = p_row_identifier
2058 G_Error_Table(l_idx).bo_identifier = l_bo_identifier
2059 THEN
2060 l_mesg_list(l_count) := G_Error_Table(l_Idx);
2061 l_Count := l_Count + 1;
2062 END IF;
2063 END LOOP;
2064 x_Message_List := l_Mesg_List;
2065
2066 END Get_Entity_Message;
2067
2068
2069 /*********************************************************************
2070 * Procedure : Get_Message
2071 * Parameters : None
2072 * Purpose : This procedure will return the message at the current
2073 * message index and will advance the pointer to the
2074 * next number. If the user tries to retrieve beyond the
2075 * the size of the message list, then the message index
2076 * will be reset to the begining position.
2077 **********************************************************************/
2078 PROCEDURE Get_Message
2079 ( x_message_text IN OUT NOCOPY VARCHAR2
2080 , x_entity_index IN OUT NOCOPY NUMBER
2081 , x_entity_id IN OUT NOCOPY VARCHAR2
2082 , x_message_type IN OUT NOCOPY VARCHAR2
2083 )
2084 IS
2085 BEGIN
2086 IF G_Msg_Index = G_Msg_Count
2087 THEN
2088 G_Msg_Index := 0;
2089 ELSE
2090 G_Msg_Index := G_Msg_Index + 1;
2091 x_message_text :=
2092 G_Error_Table(g_Msg_Index).message_text;
2093 x_entity_id :=
2094 G_Error_Table(g_Msg_Index).entity_id;
2095 x_entity_index :=
2096 G_Error_Table(g_Msg_Index).entity_index;
2097 x_message_type :=
2098 G_Error_Table(g_Msg_Index).message_type;
2099 END IF;
2100
2101 END Get_Message;
2102
2103 /********************************************************************
2104 * Procedure : Delete_Message
2105 * Parameters IN : Entity Id
2106 * Entity Index
2107 * Purpose : This procedure will delete a message for an entity
2108 * record.
2109 **********************************************************************/
2110 PROCEDURE Delete_Message
2111 ( p_entity_id IN VARCHAR2
2112 , p_entity_index IN NUMBER
2113 )
2114 IS
2115 l_idx NUMBER;
2116 BEGIN
2117 FOR l_Idx IN 1..G_Msg_Count
2118 LOOP
2119 IF G_Error_Table(l_idx).entity_id = p_entity_id AND
2120 G_Error_Table(l_idx).entity_index = p_entity_index
2121 THEN
2122 G_Error_Table.Delete(l_idx);
2123 G_Msg_Count := G_Msg_Count - 1;
2124 END IF;
2125 END LOOP;
2126 END Delete_Message;
2127
2128 /********************************************************************
2129 * Procedure : Delete_Message
2130 * Parameters IN : Entity Id
2131 * Purpose : This procedure will delete all messages for an entity
2132 **********************************************************************/
2133 PROCEDURE Delete_Message
2134 ( p_entity_id IN VARCHAR2 )
2135 IS
2136 l_idx NUMBER;
2137 BEGIN
2138 FOR l_Idx IN 1..G_Msg_Count
2139 LOOP
2140 IF G_Error_Table(l_idx).entity_id = p_entity_id
2141 THEN
2142 G_Error_Table.Delete(l_idx);
2143 G_Msg_Count := G_Msg_Count - 1;
2144 END IF;
2145 END LOOP;
2146 END Delete_Message;
2147
2148
2149 /*********************************************************************
2150 * Function : Get_Message_Count
2151 * Parameters : None
2152 * Purpose : Returns the current number of records in the message
2153 * list
2154 **********************************************************************/
2155 FUNCTION Get_Message_Count
2156 RETURN NUMBER
2157 IS
2158 BEGIN
2159 RETURN G_Msg_Count;
2160 END Get_Message_Count;
2161
2162 /*********************************************************************
2163 * Function : Dump_Message_List
2164 * Parameters : None
2165 * Purpose : Will generate a dump of the message list using
2166 * dbms_output.
2167 **********************************************************************/
2168 PROCEDURE Dump_Message_List
2169 IS
2173 Error_Handler.Write_Debug('Number of Messages = '|| G_Error_Table.COUNT);
2170 l_idx NUMBER;
2171 BEGIN
2172 Error_Handler.Write_Debug('Dumping Message List :');
2174
2175 FOR l_idx IN 1..G_Error_Table.COUNT LOOP
2176 Error_Handler.Write_Debug('Row Identifier : '||G_Error_Table(l_idx).row_identifier||'. Entity : '||G_Error_Table(l_idx).entity_id||'. Entity index : '||G_Error_Table(l_idx).entity_index||'. Table Name : '||G_Error_Table(l_idx).table_name );
2177 Error_Handler.Write_Debug('Message: ' || G_Error_Table(l_idx).message_text);
2178 Error_Handler.Write_Debug(' ');
2179 END LOOP;
2180
2181 END Dump_Message_List;
2182
2183
2184 PROCEDURE Open_Debug_Session
2185 ( p_debug_filename IN VARCHAR2
2186 , p_output_dir IN VARCHAR2
2187 , x_return_status IN OUT NOCOPY VARCHAR2
2188 , x_error_mesg IN OUT NOCOPY VARCHAR2
2189 )
2190 IS
2191 l_found NUMBER := 0;
2192 l_utl_file_dir VARCHAR2(2000);
2193 BEGIN
2194
2195 x_return_status := FND_API.G_RET_STS_SUCCESS;
2196
2197 IF Error_Handler.Get_Debug <> 'Y'
2198 THEN
2199 /*
2200 x_error_mesg := 'Debug mode is not set';
2201 x_return_status := FND_API.G_RET_STS_ERROR;
2202 RETURN;
2203 */
2204 -- Issue 3323376. The Get_Debug could be used as an indicator to identify
2205 -- if the debug session is opened or not rather than using it as a prereq setup
2206 Error_Handler.Set_Debug('Y');
2207 END IF;
2208
2209 select value
2210 INTO l_utl_file_dir
2211 FROM v$parameter
2212 WHERE name = 'utl_file_dir';
2213
2214 l_found := INSTR(l_utl_file_dir, p_output_dir);
2215
2216 IF l_found = 0
2217 THEN
2218 x_error_mesg := 'Debug Session could not be started because the ' ||
2219 ' output directory name is invalid. ' ||
2220 ' Output directory must be one of the directory ' ||
2221 ' value in v$parameter for name = utl_file_dir ';
2222 x_return_status := FND_API.G_RET_STS_ERROR;
2223 Error_Handler.Set_Debug;
2224 RETURN;
2225 END IF;
2226
2227 --Changed to the *new* call of FOPEN, where we can pass
2228 --the MAXLINESIZE value. If we donot pass the default is
2229 --1023 chars. If we pass, the max value can be 32767 chars.
2230 Error_Handler.Debug_File := utl_file.fopen( p_output_dir
2231 , p_debug_filename
2232 , 'w'
2233 , 32767
2234 );
2235
2236 EXCEPTION
2237 WHEN UTL_FILE.INVALID_PATH THEN
2238 x_error_mesg := 'Error opening Debug file . . . ' || sqlerrm;
2239 x_return_status := FND_API.G_RET_STS_ERROR;
2240 Error_Handler.Set_Debug;
2241 END Open_Debug_Session;
2242
2243
2244 PROCEDURE Open_Debug_Session
2245 ( p_debug_filename IN VARCHAR2
2246 , p_output_dir IN VARCHAR2
2247 , x_return_status IN OUT NOCOPY VARCHAR2
2248 , p_mesg_token_tbl IN Error_Handler.Mesg_Token_Tbl_Type
2249 , x_mesg_Token_tbl IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
2250 )
2251 IS
2252 l_found NUMBER := 0;
2253 l_mesg_token_tbl Error_Handler.Mesg_Token_Tbl_Type :=
2254 p_mesg_token_tbl;
2255 l_utl_file_dir VARCHAR2(2000);
2256 BEGIN
2257
2258 -- Enhancement
2259 -- If BO is called by Open interface don't call this code.
2260 IF G_IS_BOM_OI then
2261 null;
2262 else
2263 select value
2264 INTO l_utl_file_dir
2265 FROM v$parameter
2266 WHERE name = 'utl_file_dir';
2267
2268 l_found := INSTR(l_utl_file_dir, p_output_dir);
2269
2270 IF l_found = 0
2271 THEN
2272 Error_Handler.Add_Error_Token
2273 ( p_Message_name => NULL
2274 , p_message_text =>
2275 ' Debug Session could not be started because the ' ||
2276 ' output directory name is invalid. ' ||
2277 ' Output directory must be one of the directory ' ||
2278 ' value in v$parameter for name = utl_file_dir ' ||
2279 ' If unsure leave out the value and the log will '||
2280 ' be written to /sqlcom/log '
2281 , x_mesg_token_tbl => l_mesg_token_tbl
2282 );
2283 x_return_status := FND_API.G_RET_STS_ERROR;
2284 x_mesg_token_tbl := l_mesg_token_tbl;
2285 RETURN;
2286 END IF;
2287 Error_Handler.Debug_File := utl_file.fopen( p_output_dir
2288 , p_debug_filename
2289 , 'w');
2290 end if;
2291 x_return_status := FND_API.G_RET_STS_SUCCESS;
2292
2293 EXCEPTION
2294 WHEN UTL_FILE.INVALID_PATH THEN
2295 Error_Handler.Add_Error_Token
2296 ( p_message_name => NULL
2297 , p_message_text => 'Error opening Debug file . . . ' || sqlerrm
2298 , x_mesg_token_tbl => l_mesg_token_tbl
2299 );
2300 x_mesg_token_tbl := l_mesg_token_tbl;
2301 END Open_Debug_Session;
2302
2303 PROCEDURE Write_Debug
2304 ( p_debug_message IN VARCHAR2 )
2305 IS
2306 BEGIN
2307 IF Error_Handler.Get_Debug = 'Y'
2308 THEN
2309
2310 IF G_IS_BOM_OI then
2311 IF FND_PROFILE.VALUE('MRP_DEBUG') = 'Y' then
2312 Fnd_File.Put_Line ( which => Fnd_File.LOG,
2316 ELSE
2313 buff => p_debug_message );
2314 Fnd_File.New_Line ( which => Fnd_File.LOG );
2315 END IF;
2317 utl_file.put_line(Error_Handler.Debug_File,p_debug_message);
2318 END IF;
2319
2320 END IF;
2321 END Write_Debug;
2322
2323 PROCEDURE Close_Debug_Session
2324 IS
2325 BEGIN
2326
2327 -- Enhancement
2328 -- If BO is called by Open interface don't call this code.
2329
2330 IF G_IS_BOM_OI THEN
2331 null;
2332 ELSE
2333 IF Error_Handler.Get_Debug = 'Y' THEN
2334 utl_file.fclose(Error_Handler.Debug_File);
2335 Error_Handler.Set_Debug;
2336 END IF;
2337 END IF;
2338
2339 END Close_Debug_Session;
2340
2341
2342 PROCEDURE Set_Bo_Identifier(p_bo_identifier IN VARCHAR2)
2343 IS
2344 BEGIN
2345 G_BO_IDENTIFIER := p_bo_identifier;
2346
2347 END Set_Bo_Identifier;
2348
2349 FUNCTION Get_Bo_Identifier RETURN VARCHAR2
2350 IS
2351 BEGIN
2352 RETURN G_BO_IDENTIFIER;
2353 END Get_Bo_Identifier;
2354
2355 /* One to many support */
2356
2357 PROCEDURE Set_Bom_Specific (p_bom_comp_ops_tbl IN Bom_Bo_Pub.Bom_Comp_Ops_Tbl_Type)
2358 IS
2359 BEGIN
2360 g_bom_comp_ops_tbl := p_bom_comp_ops_tbl;
2361 END;
2362
2363 PROCEDURE Get_Bom_Specific (x_bom_comp_ops_tbl IN OUT NOCOPY Bom_Bo_Pub.Bom_Comp_Ops_Tbl_Type)
2364 IS
2365 BEGIN
2366 x_bom_comp_ops_tbl := g_bom_comp_ops_tbl;
2367 END;
2368
2369 /*********************************************************************
2370 * Function : Write_To_InterfaceTable
2371 * Parameters : None
2372 * Purpose : To write the errors into the error interface table
2373 **********************************************************************/
2374
2375 PROCEDURE Write_To_InterfaceTable
2376 IS
2377 l_user_id NUMBER := Fnd_Global.User_Id;
2378 l_login_id NUMBER := Fnd_Global.Login_Id;
2379 l_request_id NUMBER := Fnd_Global.Conc_Request_Id;
2380 l_program_id NUMBER := Null;
2381 l_program_appl_id NUMBER := Null;
2382 l_program_upd_date DATE := Null;
2383
2384 BEGIN
2385
2386 Error_Handler.Write_Debug('Writing the messages into MTL_INTERFACE_ERRORS table : ');
2387
2388 Error_Handler.Write_Debug('Number of Messages = ' || G_Error_Table.COUNT);
2389
2390 IF l_request_id <> - 1
2391 THEN
2392 l_program_id := Fnd_Global.Conc_program_Id;
2393 l_program_appl_id := Fnd_Global.prog_appl_id;
2394 l_program_upd_date := sysdate;
2395 ELSE
2396 l_request_id := Null;
2397 END IF;
2398
2399 FOR l_idx IN 1..G_Error_Table.COUNT
2400 LOOP
2401
2402 INSERT INTO mtl_interface_errors
2403 ( organization_id
2404 , unique_id
2405 , last_update_date
2406 , last_updated_by
2407 , creation_date
2408 , created_by
2409 , last_update_login
2410 , table_name
2411 , message_name
2412 , column_name
2413 , request_id
2414 , program_application_id
2415 , program_id
2416 , program_update_date
2417 , error_message
2418 , transaction_id
2419 , entity_identifier
2420 , bo_identifier)
2421 VALUES
2422 ( G_Error_Table(l_idx).organization_id
2423 , mtl_system_items_interface_s.NEXTVAL
2424 , sysdate
2425 , l_user_id
2426 , sysdate
2427 , l_user_id
2428 , l_login_id
2429 , G_Error_Table(l_idx).table_name
2430 , G_Error_Table(l_idx).message_name
2431 , null
2432 , l_request_id
2433 , l_program_appl_id
2434 , l_program_id
2435 , l_program_upd_date
2436 , G_Error_Table(l_idx).message_text
2437 , G_Error_Table(l_idx).row_identifier
2438 , G_Error_Table(l_idx).entity_id
2439 , G_Error_Table(l_idx).bo_identifier);
2440
2441 /* Fix for bug 4661753 - Insert message_name from G_Error_Table into mtl_interface_errors above.
2442 Populate unique_id using mtl_system_items_interface_s sequence. */
2443
2444 END LOOP;
2445
2446 END;
2447
2448 /*********************************************************************
2449 * Function : Write_To_ConcurrentLog
2450 * Parameters : None
2451 * Purpose : To write the errors into the concurrent program log file
2452 **********************************************************************/
2453
2454
2455 PROCEDURE Write_To_ConcurrentLog
2456 IS
2457 l_idx NUMBER;
2458 BEGIN
2459
2460 Error_Handler.Write_Debug('Writing the messages into the log file : ');
2461
2462 Error_Handler.Write_Debug('Number of Messages = ' || G_Error_Table.COUNT);
2463
2464 FOR l_idx IN 1..G_Error_Table.COUNT
2465 LOOP
2466
2467 Fnd_File.Put( which => Fnd_File.LOG,
2468 buff => 'Entity: '||G_Error_Table(l_idx).entity_id||'. ');
2469
2470 IF G_Error_Table(l_idx).row_identifier IS NOT NULL
2471 THEN
2472 Fnd_File.Put( which => Fnd_File.LOG,
2473 buff => 'Row Identifier: '||G_Error_Table(l_idx).row_identifier||'. ');
2474 END IF;
2475
2476 IF G_Error_Table(l_idx).entity_index IS NOT NULL
2477 THEN
2478 Fnd_File.Put( which => Fnd_File.LOG,
2479 buff => 'Entity index: '||G_Error_Table(l_idx).entity_index||'. ');
2480 END IF;
2481
2482 IF G_Error_Table(l_idx).table_name IS NOT NULL
2483 THEN
2484 Fnd_File.Put( which => Fnd_File.LOG,
2485 buff => 'Table Name: '||G_Error_Table(l_idx).table_name||'.');
2486 END IF;
2487
2488 Fnd_File.New_Line ( which => Fnd_File.LOG );
2489
2490 Fnd_File.Put_Line( which => Fnd_File.LOG,
2491 buff => G_Error_Table(l_idx).message_text );
2492
2493 Fnd_File.New_Line ( which => Fnd_File.LOG );
2494
2495 END LOOP;
2496
2497 END;
2498
2499
2500 /*********************************************************************
2501 * Function : Write_To_DebugFile
2502 * Parameters : No
2503 * Purpose : To write the errors into the debug file
2504 **********************************************************************/
2505
2506 PROCEDURE Write_To_DebugFile IS
2507 BEGIN
2508 Dump_Message_List;
2509 END;
2510
2511 PROCEDURE Log_Error(p_write_err_to_inttable IN VARCHAR2 := 'N'
2512 ,p_write_err_to_conclog IN VARCHAR2 := 'N'
2513 ,p_write_err_to_debugfile IN VARCHAR2 := 'N')
2514 IS
2515 BEGIN
2516
2517 IF p_write_err_to_inttable = 'Y'
2518 THEN
2519 Write_To_InterfaceTable;
2520 END IF;
2521
2522 IF p_write_err_to_conclog = 'Y'
2523 THEN
2524 Write_To_ConcurrentLog;
2525 END IF;
2526
2527 IF p_write_err_to_debugfile = 'Y'
2528 THEN
2529 Write_To_DebugFile;
2530 END IF;
2531
2532 END;
2533
2534 PROCEDURE Set_Debug (p_debug_flag IN VARCHAR2 := 'N')
2535 IS
2536 BEGIN
2537 g_debug_flag := p_debug_flag;
2538 END;
2539
2540 FUNCTION Get_Debug RETURN VARCHAR2
2541 IS
2542 BEGIN
2543 Return g_debug_flag;
2544 END;
2545
2546 /***************************************************************************
2547 * Function : Set_BOM_OI
2548 * Returns : None
2549 * Parameters IN : None
2550 * Parameters OUT: None
2551 * Purpose : Procedure will set the value of G_IS_BOM_OI to TRUE
2552 *****************************************************************************/
2553 Procedure Set_BOM_OI
2554 IS
2555 BEGIN
2556 G_IS_BOM_OI := TRUE;
2557
2558 End Set_BOM_OI;
2559 /***************************************************************************
2560 * Function : UnSet_BOM_OI
2561 * Returns : None
2562 * Parameters IN : None
2563 * Parameters OUT: None
2564 * Purpose : Procedure will set the value of G_IS_BOM_OI to FALSE
2565 *****************************************************************************/
2566 Procedure UnSet_BOM_OI
2567 IS
2568 BEGIN
2569 G_IS_BOM_OI := FALSE;
2570 END UnSet_BOM_OI;
2571
2572
2573 END Error_Handler;