DBA Data[Home] [Help]

PACKAGE BODY: APPS.BOM_RTG_ERROR_HANDLER

Source


1 PACKAGE BODY Bom_Rtg_Error_Handler AS
2 /* $Header: BOMROEHB.pls 120.1 2005/12/01 03:02:50 dikrishn noship $ */
3 /*************************************************************************
4 --
5 --  Copyright (c) 2000 Oracle Corporation, Redwood Shores, CA, USA
6 --  All rights reserved.
7 --
8 --  FILENAME
9 --
10 --      BOMROEHB.pls
11 --
12 --  DESCRIPTION
13 --
14 --      Body of package Bom_Rtg_Error_Handler
15 --
16 --  NOTES   This package is created to make the RTG Business Object
17 --          independent of Bom Business Object.
18 --          Log_Error for Routing Bo procedure have been moved here from
19 --          Error_Handler package. This Log_Error procedure calls
20 --          Error Handler's functions.
21 --
22 --  HISTORY
23 --
24 --  14-DEC-00   Masanori Kimizuka      Initial Creation
25 --
26 --
27 *************************************************************************/
28 
29     /*******************************************************
30     -- Routing BO records
31     ********************************************************/
32     g_rtg_header_rec         Bom_Rtg_Pub.Rtg_Header_Rec_Type ;
33     g_rtg_revision_tbl       Bom_Rtg_Pub.Rtg_Revision_Tbl_Type ;
34     g_operation_tbl          Bom_Rtg_Pub.Operation_Tbl_Type ;
35     g_op_resource_tbl        Bom_Rtg_Pub.Op_Resource_Tbl_Type ;
36     g_sub_resource_tbl       Bom_Rtg_Pub.Sub_Resource_Tbl_Type ;
37     g_op_network_tbl         Bom_Rtg_Pub.Op_Network_Tbl_Type ;
38 
39        /* BOM BO RECORDS added for add_message procedure */
40     g_bom_header_rec         Bom_Bo_Pub.Bom_Head_Rec_Type := Bom_Bo_Pub.G_MISS_BOM_HEADER_REC;
41     g_bom_revision_tbl       Bom_Bo_Pub.Bom_Revision_Tbl_Type := Bom_Bo_Pub.G_MISS_BOM_REVISION_TBL;
42     g_bom_component_tbl      Bom_Bo_pub.Bom_Comps_Tbl_Type := Bom_Bo_Pub.G_MISS_BOM_COMPONENT_TBL;
43     g_bom_ref_designator_tbl Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type := Bom_Bo_Pub.G_MISS_BOM_REF_DESIGNATOR_TBL;
44     g_bom_sub_component_tbl  Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type := Bom_Bo_Pub.G_MISS_BOM_SUB_COMPONENT_TBL;
45     g_bom_comp_ops_tbl       Bom_Bo_Pub.Bom_Comp_Ops_Tbl_Type := Bom_Bo_Pub.G_MISS_BOM_COMP_OPS_TBL;
46         /* BOM BO RECORDS added for add_message procedure */
47 
48     G_ERROR_TABLE           Error_Handler.Error_Tbl_Type;
49     G_Msg_Index             NUMBER := 0;
50     G_Msg_Count             NUMBER := 0;
51 
52 
53     /******************************************************************
54     * Procedure     : setSubResources (Unexposed)
55     * Parameters    : Other Message
56     *                 Other Status
57     *                 Error Scope
58     *                 Entity Index
59     *                 Operation Index
60     *                 Operation Resource Index
61     * Purpose       : This procedure will set the reference designator
62     *                 record status to other status by looking at the
63     *                 revised item key or the revised component key or
64     *                 else setting all the record status to other status
65     ********************************************************************/
66     /* Fix for bug 4661753 - Added a new parameter p_other_mesg_name to the procedure below.
67        Passed this p_other_mesg_name to p_mesg_name parameter in the calls to Add_message procedure.*/
68     PROCEDURE setSubResources
69     (  p_error_scope        IN  VARCHAR2
70      , p_other_mesg_text    IN  VARCHAR2
71      , p_other_status       IN  VARCHAR2
72      , p_op_idx             IN  NUMBER
73      , p_res_idx            IN  NUMBER
74      , p_entity_index       IN  NUMBER
75      , p_other_mesg_name    IN  VARCHAR2 := NULL
76     )
77     IS
78 
79                 l_idx   NUMBER;
80     BEGIN
81          IF p_error_scope = G_SCOPE_ALL
82          THEN
83              FOR l_idx IN 1..g_sub_resource_tbl.COUNT
84              LOOP
85                  g_sub_resource_tbl(l_idx).return_status := p_other_status;
86 
87                  IF p_other_mesg_text IS NOT NULL
88                  THEN
89                        Error_Handler.Add_Message
90                        (  p_mesg_text   => p_other_mesg_text
91                         , p_entity_id   => G_SR_LEVEL
92                         , p_entity_index=> l_idx
93 			, p_row_identifier => g_sub_resource_tbl(l_idx).row_identifier
94                         , p_message_type=> 'E'
95                         , p_mesg_name   => p_other_mesg_name
96                         , p_bom_header_rec =>  g_bom_header_rec
97                         , p_bom_revision_tbl =>  g_bom_revision_tbl
98 			, p_bom_component_tbl => g_bom_component_tbl
99 			, p_bom_ref_Designator_tbl => g_bom_ref_designator_tbl
100 			, p_bom_sub_component_tbl => g_bom_sub_component_tbl
101 			, p_bom_comp_ops_tbl => g_bom_comp_ops_tbl
102 			);
103                  END IF;
104              END LOOP;
105 
106          ELSIF p_error_scope = G_SCOPE_CHILDREN AND
107                p_op_idx <> 0
108          THEN
109 
110                 FOR l_idx IN 1..g_sub_resource_tbl.COUNT
111                 LOOP
112                    IF NVL(g_sub_resource_tbl(l_idx).operation_sequence_number,
113                           FND_API.G_MISS_NUM) =
114                       NVL(g_operation_tbl(p_op_idx).operation_sequence_number,
115                           FND_API.G_MISS_NUM)
116                    AND
117                       NVL(g_sub_resource_tbl(l_idx).op_start_effective_date, SYSDATE) =
118                       NVL(g_operation_tbl(p_op_idx).start_effective_date, SYSDATE)
119                    AND
120                       NVL(g_sub_resource_tbl(l_idx).operation_type, FND_API.G_MISS_NUM) =
121                       NVL(g_operation_tbl(p_op_idx).operation_type, FND_API.G_MISS_NUM)
122                    THEN
123 
124                         g_sub_resource_tbl(l_idx).return_status := p_other_status;
125                         Error_Handler.Add_Message
126                         (  p_mesg_text          => p_other_mesg_text
127                          , p_entity_id          => G_SR_LEVEL
128                          , p_entity_index       => l_idx
129 			 , p_row_identifier	=> g_sub_resource_tbl(l_idx).row_identifier
130                          , p_message_type       => 'E'
131                          , p_mesg_name          => p_other_mesg_name
132 			, p_bom_header_rec =>  g_bom_header_rec
133 			, p_bom_revision_tbl =>  g_bom_revision_tbl
134 			, p_bom_component_tbl => g_bom_component_tbl
135 			, p_bom_ref_Designator_tbl => g_bom_ref_designator_tbl
136 			, p_bom_sub_component_tbl => g_bom_sub_component_tbl
137 			, p_bom_comp_ops_tbl => g_bom_comp_ops_tbl
138 			);
139                     END IF;
140                 END LOOP;  -- Sub Res Children of Op Seq Ends.
141 
142          ELSIF p_error_scope = G_SCOPE_SIBLINGS AND p_res_idx <> 0
143          THEN
144 
145                 FOR l_idx IN 1..g_sub_resource_tbl.COUNT
146                 LOOP
147                     IF NVL(g_sub_resource_tbl(l_idx).operation_sequence_number,
148                            FND_API.G_MISS_NUM) =
149                        NVL(g_op_resource_tbl(p_res_idx).operation_sequence_number,
150                            FND_API.G_MISS_NUM)
151                     AND
152                        NVL(g_sub_resource_tbl(l_idx).op_start_effective_date, SYSDATE) =
153                        NVL(g_op_resource_tbl(p_res_idx).op_start_effective_date,
154                             SYSDATE)
155                     AND
156                        NVL(g_sub_resource_tbl(l_idx).operation_type, FND_API.G_MISS_NUM) =
157                        NVL(g_op_resource_tbl(p_res_idx).operation_type,
158                            FND_API.G_MISS_NUM)
159                     THEN
160                         g_sub_resource_tbl(l_idx).return_status := p_other_status;
161                         Error_Handler.Add_Message
162                         (  p_mesg_text          => p_other_mesg_text
163                          , p_entity_id          => G_SR_LEVEL
164                          , p_entity_index       => l_idx
165 			 , p_row_identifier	=> g_sub_resource_tbl(l_idx).row_identifier
166                          , p_message_type       => 'E'
167                          , p_mesg_name   	=> p_other_mesg_name
168 			 , p_bom_header_rec =>  g_bom_header_rec
169 			, p_bom_revision_tbl =>  g_bom_revision_tbl
170 			, p_bom_component_tbl => g_bom_component_tbl
171 			, p_bom_ref_Designator_tbl => g_bom_ref_designator_tbl
172 			, p_bom_sub_component_tbl => g_bom_sub_component_tbl
173 			, p_bom_comp_ops_tbl => g_bom_comp_ops_tbl
174 			);
175                     END IF;
176                 END LOOP;
177 
178          ELSIF p_error_scope = G_SCOPE_SIBLINGS AND
179                p_op_idx  = 0 AND
180                p_res_idx = 0
181          THEN
182 
183 
184                 FOR l_idx IN 1..g_sub_resource_tbl.COUNT
185                 LOOP
186                     IF NVL(g_sub_resource_tbl(l_idx).operation_sequence_number,
187                            FND_API.G_MISS_NUM) =
188                        NVL(g_sub_resource_tbl(p_entity_index).operation_sequence_number,
189                            FND_API.G_MISS_NUM)
190                     AND
191                        NVL(g_sub_resource_tbl(l_idx).op_start_effective_date, SYSDATE) =
192                        NVL(g_sub_resource_tbl(p_entity_index).op_start_effective_date,
193                             SYSDATE)
194                     AND
195                        NVL(g_sub_resource_tbl(l_idx).operation_type, FND_API.G_MISS_NUM) =
196                        NVL(g_sub_resource_tbl(p_entity_index).operation_type,
197                            FND_API.G_MISS_NUM)
198                     THEN
199                         g_sub_resource_tbl(l_idx).return_status := p_other_status;
200                         Error_Handler.Add_Message
201                         (  p_mesg_text          => p_other_mesg_text
202                          , p_entity_id          => G_SR_LEVEL
203                          , p_entity_index       => l_idx
204 			 , p_row_identifier	=> g_sub_resource_tbl(l_idx).row_identifier
205                          , p_message_type       => 'E'
206                          , p_mesg_name   	=> p_other_mesg_name
207 			, p_bom_header_rec =>  g_bom_header_rec
208 			, p_bom_revision_tbl =>  g_bom_revision_tbl
209 			, p_bom_component_tbl => g_bom_component_tbl
210 			, p_bom_ref_Designator_tbl => g_bom_ref_designator_tbl
211 			, p_bom_sub_component_tbl => g_bom_sub_component_tbl
212 			, p_bom_comp_ops_tbl => g_bom_comp_ops_tbl
213 			);
214                     END IF;
215                 END LOOP;
216 
217 
218          END IF; -- If Scope = Ends.
219 
220     END setSubResources;
221 
222 
223     /******************************************************************
224     * Procedure : setOperationResources (Unexposed)
225     * Parameters    : Other Message
226     *                 Other Status
227     *                 Error Scope
228     *                 Entity Index
229     *                 Operation Index
230     * Purpose   : This procedure will set the operation resource
231     *             record status to other status by looking at the
232     *             operation sequence key or else setting all the record
233     *             status to other status
234     ********************************************************************/
235     /* Fix for bug 4661753 - Added a new parameter p_other_mesg_name to the procedure below.
236        Passed this p_other_mesg_name to Add_message, setSubResources procedures calls.*/
237     PROCEDURE setOperationResources
238     (  p_error_scope        IN  VARCHAR2
239      , p_other_mesg_text    IN  VARCHAR2
240      , p_other_status       IN  VARCHAR2
241      , p_op_idx             IN  NUMBER
242      , p_entity_index       IN  NUMBER
243      , p_other_mesg_name    IN  VARCHAR2 := NULL
244     )
245     IS
246         l_idx   NUMBER;
247     BEGIN
248 
249         IF p_error_scope = G_SCOPE_ALL
250         THEN
251            FOR l_idx IN (p_entity_index+1)..g_op_resource_tbl.COUNT
252            LOOP
253                g_op_resource_tbl(l_idx).return_status := p_other_status;
254 
255                IF p_other_mesg_text IS NOT NULL
256                THEN
257                   Error_Handler.Add_Message
258                   ( p_mesg_text     => p_other_mesg_text
259                   , p_entity_id     => G_RES_LEVEL
260                   , p_entity_index  => l_idx
261 		  , p_row_identifier => g_op_resource_tbl(l_idx).row_identifier
262                   , p_message_type  => 'E'
263                   , p_mesg_name     => p_other_mesg_name
264 		, p_bom_header_rec =>  g_bom_header_rec
265 		, p_bom_revision_tbl =>  g_bom_revision_tbl
266 		, p_bom_component_tbl => g_bom_component_tbl
267 		, p_bom_ref_Designator_tbl => g_bom_ref_designator_tbl
268 		, p_bom_sub_component_tbl => g_bom_sub_component_tbl
269 		, p_bom_comp_ops_tbl => g_bom_comp_ops_tbl
270 		);
271                END IF;
272             END LOOP;
273 
274             --
275             -- Set the Substitute Operation Resources Record Status too
276             --
277             setSubResources
278             (  p_other_status       => p_other_status
279              , p_other_mesg_text    => p_other_mesg_text
280              , p_error_scope        => p_error_scope
281              , p_op_idx             => 0
282              , p_res_idx            => 0
283              , p_entity_index       => 0
284              , p_other_mesg_name    => p_other_mesg_name
285              );
286 
287 
288         ELSIF p_error_scope = G_SCOPE_CHILDREN AND
289               p_op_idx <> 0
290         THEN
291 
292 
293             FOR l_idx IN 1..g_op_resource_tbl.COUNT
294             LOOP
295                 IF NVL(g_op_resource_tbl(l_idx).operation_sequence_number,
296                        FND_API.G_MISS_NUM) =
297                    NVL(g_operation_tbl(p_op_idx).operation_sequence_number,
298                        FND_API.G_MISS_NUM)
299                 AND
300                    NVL(g_op_resource_tbl(l_idx).op_start_effective_date, SYSDATE) =
301                    NVL(g_operation_tbl(p_op_idx).start_effective_date, SYSDATE)
302                 AND
303                    NVL(g_op_resource_tbl(l_idx).operation_type, FND_API.G_MISS_NUM) =
304                    NVL(g_operation_tbl(p_op_idx).operation_type, FND_API.G_MISS_NUM)
305                 THEN
306 
307                     g_op_resource_tbl(l_idx).return_status := p_other_status;
308                     Error_Handler.Add_Message
309                     (  p_mesg_text      => p_other_mesg_text
310                      , p_entity_id      => G_RES_LEVEL
311                      , p_entity_index   => l_idx
312 		     , p_row_identifier => g_op_resource_tbl(l_idx).row_identifier
313                      , p_message_type   => 'E'
314                      , p_mesg_name      => p_other_mesg_name
315 			, p_bom_header_rec =>  g_bom_header_rec
316 			, p_bom_revision_tbl =>  g_bom_revision_tbl
317 			, p_bom_component_tbl => g_bom_component_tbl
318 			, p_bom_ref_Designator_tbl => g_bom_ref_designator_tbl
319 			, p_bom_sub_component_tbl => g_bom_sub_component_tbl
320 			, p_bom_comp_ops_tbl => g_bom_comp_ops_tbl
321 			);
322                 END IF;
323             END LOOP;  -- Op Resource Children of Op Seq Ends.
324 
325 
326         ELSIF p_error_scope = G_SCOPE_SIBLINGS AND
327               p_op_idx = 0
328         THEN
329         --
330         -- This situation will arise when Op Seq is
331         -- not part of the business object input data.
332         -- Match the operation key information at the entity index
333         -- location with rest of the records, all those that are found
334         -- will be siblings and should get an error.
335         --
336 
337             FOR l_idx IN (p_entity_index+1)..g_op_resource_tbl.COUNT
338             LOOP
339                 IF NVL(g_op_resource_tbl(l_idx).operation_sequence_number,
340                        FND_API.G_MISS_NUM) =
341                    NVL(g_op_resource_tbl(p_entity_index).operation_sequence_number,
342                        FND_API.G_MISS_NUM)
343                 AND
344                    NVL(g_op_resource_tbl(l_idx).op_start_effective_date, SYSDATE) =
345                    NVL(g_op_resource_tbl(p_entity_index).op_start_effective_date, SYSDATE)
346                 AND
347                    NVL(g_op_resource_tbl(l_idx).operation_type,
348                        FND_API.G_MISS_NUM) =
349                    NVL(g_op_resource_tbl(p_entity_index).operation_type,
350                        FND_API.G_MISS_NUM)
351                 THEN
352 
353                     g_op_resource_tbl(l_idx).return_status := p_other_status;
354                     Error_Handler.Add_Message
355                     (  p_mesg_text      => p_other_mesg_text
356                      , p_entity_id      => G_RES_LEVEL
357                      , p_entity_index   => l_idx
358 		     , p_row_identifier => g_op_resource_tbl(l_idx).row_identifier
359                      , p_message_type   => 'E'
360                      , p_mesg_name      => p_other_mesg_name
361 		, p_bom_header_rec =>  g_bom_header_rec
362 		, p_bom_revision_tbl =>  g_bom_revision_tbl
363 		, p_bom_component_tbl => g_bom_component_tbl
364 		, p_bom_ref_Designator_tbl => g_bom_ref_designator_tbl
365 		, p_bom_sub_component_tbl => g_bom_sub_component_tbl
366 		, p_bom_comp_ops_tbl => g_bom_comp_ops_tbl
367 		);
368 
369                 END IF;
370             END LOOP;
371 
372         --
373         -- Substitute Operation Resources will also be considered as siblings
374         -- of operation resource, they should get an error when
375         -- error level is operation resource with scope of Siblings
376                 --
377             setSubResources
378             (  p_other_status       => p_other_status
379              , p_other_mesg_text    => p_other_mesg_text
380              , p_error_scope        => p_error_scope
381              , p_res_idx            => p_entity_index
382              , p_op_idx             => 0
383              , p_entity_index       => 0
384              , p_other_mesg_name    => p_other_mesg_name
385             );
386        END IF; -- If error scope Ends
387 
388     END setOperationResources ;
389 
390 
391     /*****************************************************************
392     * Procedure     : setOperationSequences (Unexposed)
393     * Parameters IN : Other Message Text
394     *                 Other status
395     *                 Entity Index
396     *                 Error Scope
397     *                 Error Status
398     *                 Revised Item Index
399     * Parameters OUT: None
400     * Purpose       : This procedure will set the revised components record
401     *                 status to other status and for each errored record
402     *                 it will log the other message indicating what caused
403     *                 the other records to fail.
404     ******************************************************************/
405     /* Fix for bug 4661753 - Added a new parameter p_other_mesg_name to the procedure below.
406        Passed this p_other_mesg_name to Add_message, setOperationResources procedure calls.*/
407     PROCEDURE setOperationSequences
408     (  p_error_scope        IN  VARCHAR2
409      , p_other_mesg_text    IN  VARCHAR2
410      , p_other_status       IN  VARCHAR2
411      , p_entity_index       IN  NUMBER
412      , p_other_mesg_name    IN  VARCHAR2 := NULL
413      )
414     IS
415         l_Idx       NUMBER;
416     BEGIN
417 
418         IF p_error_scope = G_SCOPE_ALL
419         THEN
420 
421             FOR l_idx IN 1..g_operation_tbl.COUNT
422             LOOP
423             g_operation_tbl(l_idx).return_status := p_other_status;
424 
425                IF p_other_mesg_text IS NOT NULL
426                THEN
427                   Error_Handler.Add_Message
428                   ( p_mesg_text    => p_other_mesg_text
429                   , p_entity_id    => G_OP_LEVEL
430                   , p_entity_index => l_Idx
431 		  , p_row_identifier => g_operation_tbl(l_idx).row_identifier
432                   , p_message_type => 'E'
433                   , p_mesg_name    => p_other_mesg_name
434 		, p_bom_header_rec =>  g_bom_header_rec
435 		, p_bom_revision_tbl =>  g_bom_revision_tbl
436 		, p_bom_component_tbl => g_bom_component_tbl
437 		, p_bom_ref_Designator_tbl => g_bom_ref_designator_tbl
438 		, p_bom_sub_component_tbl => g_bom_sub_component_tbl
439 		, p_bom_comp_ops_tbl => g_bom_comp_ops_tbl
440 		);
441                END IF;
442 
443             END LOOP;
444 
445             --
446             -- Set the operation resource and substitute
447             -- operation resource record status too.
448             --
449             setOperationResources
450                     (  p_other_status    => p_other_status
451                      , p_error_scope     => p_error_scope
452                      , p_other_mesg_text => p_other_mesg_text
453                      , p_op_idx          => 0
454                      , p_entity_index    => 0
455                      , p_other_mesg_name    => p_other_mesg_name
456                      );
457 
458         END IF; -- Error Scope Ends
459 
460     END setOperationSequences ;
461 
462 
463     /*****************************************************************
464     * Procedure : setOpNetworks (unexposed)
465     * Parameters IN : Other Message Text
466     *                 Other status
467     *                 Entity Index
468     * Parameters OUT: None
469     * Purpose   : This procedure will set the Operation Network record
470     *             status to other status and for each errored record
471     *             it will log the other message indicating what caused
472     *             the other records to fail.
473     ******************************************************************/
474     /* Fix for bug 4661753 - Added a new parameter p_other_mesg_name to the procedure below.
475        Passed this p_other_mesg_name to Add_message procedure call.*/
476     PROCEDURE setOpNetworks
477     (  p_other_mesg_text    IN  VARCHAR2
478      , p_other_status       IN  VARCHAR2
479      , p_other_mesg_name    IN  VARCHAR2 := NULL
480     )
481     IS
482         l_CurrentIndex  NUMBER;
483     BEGIN
484 
485         FOR l_CurrentIndex IN  1..g_op_network_tbl.COUNT
486         LOOP
487             g_op_network_tbl(l_CurrentIndex).return_status :=
488                         p_other_status;
489             IF p_other_mesg_text IS NOT NULL
490             THEN
491                 Error_Handler.Add_Message
492                 (  p_mesg_text      => p_other_mesg_text
493                  , p_entity_id      => G_NWK_LEVEL
494                  , p_entity_index   => l_CurrentIndex
495 		 , p_row_identifier => g_op_network_tbl(l_CurrentIndex).row_identifier
496                  , p_message_type   => 'E'
497                  , p_mesg_name      => p_other_mesg_name
498 		, p_bom_header_rec =>  g_bom_header_rec
499 		, p_bom_revision_tbl =>  g_bom_revision_tbl
500 		, p_bom_component_tbl => g_bom_component_tbl
501 		, p_bom_ref_Designator_tbl => g_bom_ref_designator_tbl
502 		, p_bom_sub_component_tbl => g_bom_sub_component_tbl
503 		, p_bom_comp_ops_tbl => g_bom_comp_ops_tbl
504 		);
505             END IF;
506         END LOOP;
507 
508     END setOpNetworks ;
509 
510 
511     /*****************************************************************
512     * Procedure : setRtgRevisions (unexposed)
513     * Parameters IN : Other Message Text
514     *                 Other status
515     *                 Entity Index
516     * Parameters OUT: None
517     * Purpose   : This procedure will set the Routing Revisions record
518     *             status to other status and for each errored record
519     *             it will log the other message indicating what caused
520     *             the other records to fail.
521     ******************************************************************/
522     /* Fix for bug 4661753 - Added a new parameter p_other_mesg_name to the procedure below.
523        Passed this p_other_mesg_name to Add_message procedure call.*/
524     PROCEDURE setRtgRevisions
525     (  p_other_mesg_text    IN  VARCHAR2
526      , p_other_status       IN  VARCHAR2
527      , p_other_mesg_name    IN  VARCHAR2 := NULL
528     )
529     IS
530         l_CurrentIndex  NUMBER;
531     BEGIN
532 
533         FOR l_CurrentIndex IN  1..g_rtg_revision_tbl.COUNT
534         LOOP
535             g_rtg_revision_tbl(l_CurrentIndex).return_status :=
536                         p_other_status;
537             IF p_other_mesg_text IS NOT NULL
538             THEN
539 
540                 Error_Handler.Add_Message
541                 (  p_mesg_text      => p_other_mesg_text
542                  , p_entity_id      => G_REV_LEVEL
543                  , p_entity_index   => l_CurrentIndex
544 		 , p_row_identifier => g_rtg_revision_tbl(l_CurrentIndex).row_identifier
545                  , p_message_type   => 'E'
546                  , p_mesg_name      => p_other_mesg_name
547 		, p_bom_header_rec =>  g_bom_header_rec
548 		, p_bom_revision_tbl =>  g_bom_revision_tbl
549 		, p_bom_component_tbl => g_bom_component_tbl
550 		, p_bom_ref_Designator_tbl => g_bom_ref_designator_tbl
551 		, p_bom_sub_component_tbl => g_bom_sub_component_tbl
552 		, p_bom_comp_ops_tbl => g_bom_comp_ops_tbl
553 		);
554             END IF;
555         END LOOP;
556 
557     END setRtgRevisions;
558 
559 
560 
561     /******************************************************************
562     * Procedure : Log_Error
563     * Parameters IN : Routing Header Record and Rest of the Entity Tables
564     *                 Message Token Table
565     *                 Other Message Table
566     *                 Other Status
567     *                 Entity Index
568     *                 Error Level
569     *                 Error Scope
570     *                 Error Status
571     * Parameters OUT:  Routing Header Record and Rest of the Entity Tables
572     * Purpose   : Log Error will take the Message Token Table and
573     *             seperate the message and their tokens, get the
574     *             token substitute messages from the message dictionary
575     *             and put in the error stack.
576     *             Log Error will also make sure that the error
577     *             propogates to the right level's of the business object
578     *             and that the rest of the entities get the appropriate
579     *             status and message.
580     ******************************************************************/
581      PROCEDURE Log_Error
582      ( p_rtg_header_rec          IN  Bom_Rtg_Pub.Rtg_Header_Rec_Type
583      , p_rtg_revision_tbl        IN  Bom_Rtg_Pub.Rtg_Revision_Tbl_Type
584      , p_operation_tbl           IN  Bom_Rtg_Pub.Operation_Tbl_Type
585      , p_op_resource_tbl         IN  Bom_Rtg_Pub.Op_Resource_Tbl_Type
586      , p_sub_resource_tbl        IN  Bom_Rtg_Pub.Sub_Resource_Tbl_Type
587      , p_op_network_tbl          IN  Bom_Rtg_Pub.Op_Network_Tbl_Type
588      , p_Mesg_Token_tbl          IN  Error_Handler.Mesg_Token_Tbl_Type
589      , p_error_status            IN  VARCHAR2
590      , p_error_scope             IN  VARCHAR2
591      , p_other_message           IN  VARCHAR2
592      , p_other_mesg_appid        IN  VARCHAR2
593      , p_other_status            IN  VARCHAR2
594      , p_other_token_tbl         IN  Error_Handler.Token_Tbl_Type
595      , p_error_level             IN  NUMBER
596      , p_entity_index            IN  NUMBER
597      , x_rtg_header_rec          IN OUT NOCOPY Bom_Rtg_Pub.Rtg_Header_Rec_Type
598      , x_rtg_revision_tbl        IN OUT NOCOPY Bom_Rtg_Pub.Rtg_Revision_Tbl_Type
599      , x_operation_tbl           IN OUT NOCOPY Bom_Rtg_Pub.Operation_Tbl_Type
600      , x_op_resource_tbl         IN OUT NOCOPY Bom_Rtg_Pub.Op_Resource_Tbl_Type
601      , x_sub_resource_tbl        IN OUT NOCOPY Bom_Rtg_Pub.Sub_Resource_Tbl_Type
602      , x_op_network_tbl          IN OUT NOCOPY Bom_Rtg_Pub.Op_Network_Tbl_Type
603      )
604 
605     IS
606         l_message_name      VARCHAR2(30);
607         l_other_message     VARCHAR2(2000);
608         l_message_text      VARCHAR2(2000);
609         l_LoopIndex         NUMBER;
610         l_Error_Level       NUMBER      := p_Error_Level;
611         l_error_scope       VARCHAR2(1) := p_error_scope;
612         l_error_status      VARCHAR2(1) := p_error_status;
613         l_application_id    VARCHAR2(3);
614         l_row_identifier    NUMBER;
615     BEGIN
616        g_rtg_header_rec         := p_rtg_header_rec ;
617        g_rtg_revision_tbl       := p_rtg_revision_tbl ;
618        g_operation_tbl          := p_operation_tbl ;
619        g_op_resource_tbl        := p_op_resource_tbl ;
620        g_sub_resource_tbl       := p_sub_resource_tbl ;
621        g_op_network_tbl         := p_op_network_tbl ;
622 
623        l_application_id :=  p_other_mesg_appid;
624 
625 
626         /*************************************************
627         --
628         -- Seperate message and their tokens, get the
629         -- token substituted messages and put it in the
630         -- Error Table.
631         --
632         **************************************************/
633 
634 
635 IF Bom_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Within the Rtg Log Error Procedure . . .'); END IF;
636 IF Bom_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Scope: ' || l_error_scope); END IF;
637 IF Bom_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Entity Index: ' || to_char(p_entity_index)); END IF;
638 IF Bom_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Error Level: ' || to_char(p_error_level)); END IF;
639 IF Bom_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Error Status: ' || l_error_status); END IF;
640 IF Bom_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Other Status: ' || p_other_status); END IF;
641 IF Bom_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Other Message: ' || p_other_message); END IF;
642 
643       IF p_error_level = G_BO_LEVEL OR p_error_level = G_RTG_LEVEL THEN
644          l_row_identifier := p_rtg_header_rec.row_identifier;
645       ELSIF p_error_level = G_REV_LEVEL THEN
646          l_row_identifier := p_rtg_revision_tbl(p_entity_index).row_identifier;
647       ELSIF p_error_level = G_OP_LEVEL THEN
648          l_row_identifier := p_operation_tbl(p_entity_index).row_identifier;
649       ELSIF p_error_level = G_RES_LEVEL THEN
650          l_row_identifier := p_op_resource_tbl(p_entity_index).row_identifier;
651       ELSIF p_error_level = G_SR_LEVEL THEN
652          l_row_identifier := p_sub_resource_tbl(p_entity_index).row_identifier;
653       ELSIF  p_error_level = G_NWK_LEVEL THEN
654          l_row_identifier := p_op_network_tbl(p_entity_index).row_identifier;
655       END IF;
656         Error_Handler.Translate_And_Insert_Messages
657         (  p_mesg_token_Tbl => p_mesg_token_tbl
658          , p_error_level    => p_error_level
659          , p_entity_index   => p_entity_index
660          , p_row_identifier => l_row_identifier
661         );
662 
663 IF Bom_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Finished logging messages . . . '); END IF;
664 
665         /**********************************************************
666         --
667         -- Get the other message text and token and retrieve the
668         -- token substituted message.
669         --
670         ***********************************************************/
671 
672         IF p_other_token_tbl.COUNT <> 0
673         THEN
674             FND_MESSAGE.SET_NAME
675             (  application  => l_application_id
676              , name         => p_other_message
677              );
678 
679             FOR l_LoopIndex IN 1 .. p_other_token_tbl.COUNT
680             LOOP
681                 IF p_other_token_tbl(l_LoopIndex).token_name IS
682                    NOT NULL
683                 THEN
684                    FND_MESSAGE.SET_TOKEN
685                    ( token  => p_other_token_tbl(l_LoopIndex).token_name
686                     , value => p_other_token_tbl(l_LoopIndex).token_value
687                     , translate   => p_other_token_tbl(l_LoopIndex).translate
688                    );
689                 END IF;
690             END LOOP;
691 
692             l_other_message := FND_MESSAGE.GET;
693 
694         ELSE
695             FND_MESSAGE.SET_NAME
696             (  application  => l_application_id
697              , name         => p_other_message
698              );
699 
700             l_other_message := FND_MESSAGE.GET;
701 
702         END IF; -- Other Token Tbl Count <> 0 Ends
703 
704 IF Bom_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Finished extracting other message . . . '); END IF;
705 IF Bom_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Other Message generated: ' || l_other_message); END IF;
706 
707 
708         /**********************************************************
709         --
710         -- If the Error Level is Business Object
711         -- then set the Error Level = RTG
712         --
713         ************************************************************/
714         IF l_error_level = G_BO_LEVEL
715         THEN
716             l_error_level := G_RTG_LEVEL;
717 
718 IF Bom_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Error Level is Business Object . . . '); END IF;
719 
720         END IF;
721         /**********************************************************
722         --
723         -- If the error_status is UNEXPECTED then set the error scope
724         -- to ALL, if WARNING then set the scope to RECORD.
725         --
726         ************************************************************/
727         IF l_error_status = G_STATUS_UNEXPECTED
728         THEN
729 
730 IF Bom_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Status unexpected and scope is All . . .'); END IF;
731 
732             l_error_scope := G_SCOPE_ALL;
733         ELSIF l_error_status = G_STATUS_WARNING
734         THEN
735             l_error_scope := G_SCOPE_RECORD;
736             l_error_status := FND_API.G_RET_STS_SUCCESS;
737 
738 IF Bom_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Status is warning . . .'); END IF;
739 
740         END IF;
741 
742         --
743         -- If the Error Level is Routing Header, then the scope can be
744         -- ALL/CHILDREN OR RECORD.
745         --
746         /*************************************************************
747         --
748         -- If the Error Level is Routing Header.
749         --
750         *************************************************************/
751         IF l_error_level = G_RTG_LEVEL
752         THEN
753         /* Fix for bug 4661753 - added p_other_message to the calls to Add_message, setSubResources, setOperationResources,
754 	        setOperationSequences, setOpNetworks, setRtgRevisions procedures below.
755  	        Note that p_other_message contains message_name (can be null) whereas l_other_message contains message_text.*/
756 
757 IF Bom_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Error Level is Routing Header . . .'); END IF;
758 
759             --
760             -- Set the Routing Header record status to p_error_status
761             -- This will also take care of the scope RECORD.
762             --
763             g_rtg_header_rec.return_status := l_error_status;
764 
765             IF p_other_message IS NOT NULL AND
766                p_error_level IN (G_BO_LEVEL, G_RTG_LEVEL)
767             THEN
768                 Error_Handler.Add_Message
769                 (  p_mesg_text      => l_other_message
770                  , p_entity_id      => p_error_level
771                  , p_entity_index   => p_entity_index
772 		 , p_row_identifier => g_rtg_header_rec.row_identifier
773                  , p_message_type   => 'E'
774                  , p_mesg_name      => p_other_message
775                 );
776                 l_other_message := NULL;
777             END IF;
778 
779 
780             IF l_error_scope = G_SCOPE_ALL OR
781                l_error_scope = G_SCOPE_CHILDREN
782             THEN
783                 --
784                 -- Set all the operation's
785                 -- status, this will then set the
786                 -- status of the operation resoources
787                 -- and substitute operation resoources
788 
789                 --
790                 setOperationSequences
791                 (  p_other_mesg_text => l_other_message
792                  , p_other_status    => p_other_status
793                  , p_error_scope     => G_SCOPE_ALL
794                  , p_entity_index    =>0
795                  , p_other_mesg_name => p_other_message
796                 );
797 
798             END IF; -- Routing Header Scope =  ALL or Children Ends
799 
800 
801         /********************************************
802         --
803         -- If the Error Level is Routing Revision
804         --
805         *********************************************/
806         ELSIF l_error_level = G_REV_LEVEL
807         THEN
808 
809 IF Bom_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Error Level is Routing Revision. . .'); END IF;
810             --
811             -- Set the Routing Revision record at the current entity_index
812             -- This will take care of scope = RECORD
813             --
814             g_rtg_revision_tbl(p_entity_index).return_status := l_error_status;
815 
816 
817             IF l_error_scope = G_SCOPE_ALL
818             THEN
819                IF g_rtg_revision_tbl.COUNT <> 0
820                THEN
821                   --
822                   -- Set all the revision record status
823                   --
824                   setRtgRevisions
825                   (  p_other_mesg_text => l_other_message
826                    , p_other_status    => p_other_status
827                    , p_other_mesg_name => p_other_message
828                   );
829 
830                END IF;
831 
832                --
833                -- Set all the operation's
834                -- status, this will then set the
835                -- status of the operation resources
836                -- and substitute operation resources
837                --
838                setOperationSequences
839                (  p_other_mesg_text => l_other_message
840                 , p_other_status    => p_other_status
841                 , p_error_scope     => l_error_scope
842                 , p_entity_index    => 0
843                 , p_other_mesg_name => p_other_message
844                ) ;
845 
846             END IF;
847 
848 
849         /********************************************
850         --
851         -- If the Error Level is Operation Networks
852         --
853         *********************************************/
854         ELSIF l_error_level = G_NWK_LEVEL
855         THEN
856             --
857             -- Set the Operatin Network record at the current entity_index
858             -- This will take care of scope = RECORD
859             --
860             g_op_network_tbl(p_entity_index).return_status := l_error_status;
861 
862             IF l_error_scope = G_SCOPE_ALL
863             THEN
864                IF g_op_network_tbl.COUNT <> 0
865                THEN
866                   --
867                   -- Set all the revision record status
868                   --
869 		  setOpNetworks
870                   (  p_other_mesg_text => l_other_message
871                    , p_other_status    => p_other_status
872                    , p_other_mesg_name => p_other_message
873                   );
874                END IF;
875 
876                --
877                -- Set all the operation's
878                -- status, this will then set the
879                -- status of the operation resources
880                -- and substitute operation resources
881                --
882                setOperationSequences
883                (  p_other_mesg_text => l_other_message
884                 , p_other_status    => p_other_status
885                 , p_error_scope     => l_error_scope
886                 , p_entity_index    => 0
887                 , p_other_mesg_name => p_other_message
888                ) ;
889 
890             END IF;
891 
892         /********************************************
893         --
894         -- If the Error Level is Operation Sequences
895         --
896         *********************************************/
897         ELSIF l_error_level = G_OP_LEVEL
898         THEN
899 
900             --
901             -- Set operation sequence record at the entity_index
902             -- to error_status
903             -- This will take care of Scope = RECORD.
904             --
905             g_operation_tbl(p_entity_index).return_status := l_error_status;
906 
907 IF Bom_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Error Level = Operation Sequences . . .'); END IF;
908 
909             IF l_error_scope = G_SCOPE_SIBLINGS OR
910                l_error_scope = G_SCOPE_ALL
911             THEN
912                  setOperationSequences
913                  (  p_other_mesg_text => l_other_message
914                   , p_other_status    => p_other_status
915                   , p_error_scope     => G_SCOPE_ALL
916                   , p_entity_index    => p_entity_index
917                   , p_other_mesg_name => p_other_message
918                  ) ;
919             ELSIF l_error_scope = G_SCOPE_CHILDREN
920             THEN
921                 IF g_op_resource_tbl.COUNT <> 0
922                 THEN
923                     setOperationResources
924                     (  p_error_scope     => l_error_scope
925                      , p_other_status    => p_other_status
926                      , p_other_mesg_text => l_other_message
927                      , p_op_idx          => p_entity_index
928                      , p_entity_index    => 0
929                      , p_other_mesg_name => p_other_message
930                      );
931                 END IF;
932 
933                 IF g_sub_resource_tbl.COUNT <> 0
934                 THEN
935                     setSubResources
936                     (  p_error_scope     => l_error_scope
937                      , p_other_status    => p_other_status
938                      , p_other_mesg_text => l_other_message
939                      , p_op_idx          => p_entity_index
940                      , p_res_idx            => 0
941                      , p_entity_index       => 0
942                      , p_other_mesg_name    => p_other_message
943                     );
944                 END IF;
945             END IF; -- scope = Siblings or All Ends
946 
947         /***********************************************
948         --
949         -- If the Error Level is Operation Resources
950         --
951         ************************************************/
952         ELSIF l_error_level = G_RES_LEVEL
953         THEN
954             --
955             -- Set operation resource record status at entity_idx
956             -- This will take care of Scope = RECORD.
957             --
958 IF Bom_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Error Level = Operation Resource . . .'); END IF;
959 
960             g_op_resource_tbl(p_entity_index).return_status := l_error_status;
961             IF l_error_scope <> G_SCOPE_RECORD
962             THEN
963                 setOperationResources
964                 (  p_error_scope     => l_error_scope
965                  , p_other_status    => p_other_status
966                  , p_other_mesg_text => l_other_message
967                  , p_entity_index    => p_entity_index
968                  , p_op_idx          => 0
969                  , p_other_mesg_name => p_other_message
970                 ) ;
971             END IF;
972         /***********************************************
973         --
974         -- If the Error Level is Sub Op Resources
975         --
976         ************************************************/
977         ELSIF l_error_level = G_SR_LEVEL
978         THEN
979              -- Set substitute resource record status at entity_idx
980              -- This will take care of Scope = RECORD.
981              --
982 IF Bom_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Error Level = Substitute Op Resources . . .'); END IF;
983 
984              g_sub_resource_tbl(p_entity_index).return_status := l_error_status;
985 
986              IF l_error_scope <> G_SCOPE_RECORD
987              THEN
988                 setSubResources
989                 (  p_error_scope     => l_error_scope
990                  , p_other_status    => p_other_status
991                  , p_other_mesg_text => l_other_message
992                  , p_entity_index    => p_entity_index
993                  , p_op_idx             => 0
994                  , p_res_idx            => 0
995                  , p_other_mesg_name    => p_other_message
996                 ) ;
997              END IF ;
998 
999         END IF; -- Error Level  If Ends.
1000 
1001         --
1002         -- Copy the changed record/Tables to the out parameters for
1003         -- returing to the calling program.
1004         --
1005         x_rtg_header_rec         := g_rtg_header_rec ;
1006         x_rtg_revision_tbl       := g_rtg_revision_tbl ;
1007         x_operation_tbl          := g_operation_tbl ;
1008         x_op_resource_tbl        := g_op_resource_tbl ;
1009         x_sub_resource_tbl       := g_sub_resource_tbl ;
1010         x_op_network_tbl         := g_op_network_tbl ;
1011 
1012 IF Bom_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('End of Rtg Log Error.'); END IF;
1013 
1014 
1015     END Log_Error;
1016 
1017 END Bom_Rtg_Error_Handler;