DBA Data[Home] [Help]

PACKAGE BODY: APPS.EAM_ERROR_MESSAGE_PVT

Source


1 PACKAGE BODY EAM_ERROR_MESSAGE_PVT AS
2 /* $Header: EAMVWOEB.pls 120.3 2006/08/10 05:43:10 amourya noship $ */
3 /***************************************************************************
4 --
5 --  Copyright (c) 2002 Oracle Corporation, Redwood Shores, CA, USA
6 --  All rights reserved.
7 --
8 --  FILENAME
9 --
10 --      EAMVWOEB.pls
11 --
12 --  DESCRIPTION
13 --
14 --      Body of package EAM_ERROR_MESSAGE_PVT
15 --
16 --  NOTES
17 --
18 --  HISTORY
19 --
20 --  30-JUN-2002    Kenichi Nagumo     Initial Creation
21 ***************************************************************************/
22 
23 G_PKG_NAME              CONSTANT VARCHAR2(30) := 'EAM_PROCESS_WO_PVT';
24 
25         g_eam_wo_rec            EAM_PROCESS_WO_PUB.eam_wo_rec_type;
26         g_eam_op_tbl            EAM_PROCESS_WO_PUB.eam_op_tbl_type;
27         g_eam_op_network_tbl    EAM_PROCESS_WO_PUB.eam_op_network_tbl_type;
28         g_eam_res_tbl           EAM_PROCESS_WO_PUB.eam_res_tbl_type;
29         g_eam_res_inst_tbl      EAM_PROCESS_WO_PUB.eam_res_inst_tbl_type;
30         g_eam_sub_res_tbl       EAM_PROCESS_WO_PUB.eam_sub_res_tbl_type;
31         g_eam_res_usage_tbl     EAM_PROCESS_WO_PUB.eam_res_usage_tbl_type;
32         g_eam_mat_req_tbl       EAM_PROCESS_WO_PUB.eam_mat_req_tbl_type;
33         g_eam_direct_items_tbl  EAM_PROCESS_WO_PUB.eam_direct_items_tbl_type;
34 
35 	g_eam_wo_comp_rec            EAM_PROCESS_WO_PUB.eam_wo_comp_rec_type;
36 	g_eam_wo_quality_tbl         EAM_PROCESS_WO_PUB.eam_wo_quality_tbl_type;
37 	g_eam_meter_reading_tbl      EAM_PROCESS_WO_PUB.eam_meter_reading_tbl_type;
38         g_eam_counter_prop_tbl       EAM_PROCESS_WO_PUB.eam_counter_prop_tbl_type;
39 
40 	g_eam_wo_comp_rebuild_tbl    EAM_PROCESS_WO_PUB.eam_wo_comp_rebuild_tbl_type;
41 	g_eam_wo_comp_mr_read_tbl    EAM_PROCESS_WO_PUB.eam_wo_comp_mr_read_tbl_type;
42 	g_eam_op_comp_tbl            EAM_PROCESS_WO_PUB.eam_op_comp_tbl_type;
43 	g_eam_request_tbl            EAM_PROCESS_WO_PUB.eam_request_tbl_type;
44 
45 
46         G_ERROR_TABLE           EAM_ERROR_MESSAGE_PVT.Error_Tbl_Type;
47         G_Msg_Index             NUMBER := 0;
48         G_Msg_Count             NUMBER := 0;
49 
50         G_BO_IDENTIFIER         VARCHAR2(3) := 'EAM';
51 
52 
53 
54     /******************************************************************
55     * Procedure : setMaterialRequirements
56     * Parameters    : Other Message
57     *                 Other Status
58     *                 Error Scope
59     *                 Entity Index
60     *                 Operation Index
61     * Purpose   : This procedure will set the operation resource
62     *             record status to other status by looking at the
63     *             operation sequence key or else setting all the record
64     *             status to other status
65     ********************************************************************/
66     PROCEDURE setMaterialRequirements
67     (  p_error_scope        IN  VARCHAR2
68      , p_other_mesg_text    IN  VARCHAR2
69      , p_other_status       IN  VARCHAR2
70      , p_op_idx             IN  NUMBER := 0
71      , p_entity_index       IN  NUMBER := 0
72     )
73     IS
74         l_idx   NUMBER;
75     BEGIN
76 
77         IF p_error_scope = G_SCOPE_ALL
78         THEN
79            FOR l_idx IN (p_entity_index+1)..g_eam_mat_req_tbl.COUNT
80            LOOP
81                g_eam_mat_req_tbl(l_idx).return_status := p_other_status;
82 
83                IF p_other_mesg_text IS NOT NULL
84                THEN
85                   EAM_ERROR_MESSAGE_PVT.Add_Message
86                   ( p_mesg_text     => p_other_mesg_text
87                   , p_entity_id     => G_MAT_REQ_LEVEL
88                   , p_entity_index  => l_idx
89                   , p_message_type  => 'E');
90                END IF;
91             END LOOP;
92 
93 
94         ELSIF p_error_scope = G_SCOPE_CHILDREN AND
95               p_op_idx <> 0
96         THEN
97 
98             FOR l_idx IN 1..g_eam_mat_req_tbl.COUNT
99             LOOP
100                 IF NVL(g_eam_mat_req_tbl(l_idx).OPERATION_SEQ_NUM,
101                        FND_API.G_MISS_NUM) =
102                    NVL(g_eam_op_tbl(p_op_idx).OPERATION_SEQ_NUM,
103                        FND_API.G_MISS_NUM)
104                 THEN
105 
106                     g_eam_mat_req_tbl(l_idx).return_status := p_other_status;
107                     EAM_ERROR_MESSAGE_PVT.Add_Message
108                     (  p_mesg_text      => p_other_mesg_text
109                      , p_entity_id      => G_MAT_REQ_LEVEL
110                      , p_entity_index   => l_idx
111                      , p_message_type   => 'E');
112                 END IF;
113             END LOOP;  -- MR Children of Op Seq Ends.
114 
115 
116         ELSIF p_error_scope = G_SCOPE_SIBLINGS AND
117               p_op_idx = 0
118         THEN
119 
120         --
121         -- This situation will arise when Op Seq is
122         -- not part of the business object input data.
123         -- Match the operation key information at the entity index
124         -- location with rest of the records, all those that are found
125         -- will be siblings and should get an error.
126         --
127 
128             FOR l_idx IN (p_entity_index+1)..g_eam_mat_req_tbl.COUNT
129             LOOP
130                 IF NVL(g_eam_mat_req_tbl(l_idx).OPERATION_SEQ_NUM, FND_API.G_MISS_NUM) =
131                    NVL(g_eam_mat_req_tbl(p_entity_index).OPERATION_SEQ_NUM, FND_API.G_MISS_NUM)
132                 THEN
133 
134                     g_eam_mat_req_tbl(l_idx).return_status := p_other_status;
135                     EAM_ERROR_MESSAGE_PVT.Add_Message
136                     (  p_mesg_text      => p_other_mesg_text
137                      , p_entity_id      => G_MAT_REQ_LEVEL
138                      , p_entity_index   => l_idx
139                      , p_message_type   => 'E');
140 
141                 END IF;
142             END LOOP;
143 
144        END IF; -- If error scope Ends
145 
146     END setMaterialRequirements ;
147 
148 
149     /******************************************************************
150     * Procedure : setDirectItems
151     * Parameters    : Other Message
152     *                 Other Status
153     *                 Error Scope
154     *                 Entity Index
155     *                 Operation Index
156     * Purpose   : This procedure will set the operation resource
157     *             record status to other status by looking at the
158     *             operation sequence key or else setting all the record
159     *             status to other status
160     ********************************************************************/
161 
162     PROCEDURE setDirectItems
163     (  p_error_scope        IN  VARCHAR2
164      , p_other_mesg_text    IN  VARCHAR2
165      , p_other_status       IN  VARCHAR2
166      , p_op_idx             IN  NUMBER := 0
167      , p_entity_index       IN  NUMBER := 0
168     )
169     IS
170         l_idx   NUMBER;
171     BEGIN
172 
173         IF p_error_scope = G_SCOPE_ALL
174         THEN
175            FOR l_idx IN (p_entity_index+1)..g_eam_direct_items_tbl.COUNT
176            LOOP
177                g_eam_direct_items_tbl(l_idx).return_status := p_other_status;
178 
179                IF p_other_mesg_text IS NOT NULL
180                THEN
181                   EAM_ERROR_MESSAGE_PVT.Add_Message
182                   ( p_mesg_text     => p_other_mesg_text
183                   , p_entity_id     => G_DIRECT_ITEMS_LEVEL
184                   , p_entity_index  => l_idx
185                   , p_message_type  => 'E');
186                END IF;
187             END LOOP;
188 
189 
190         ELSIF p_error_scope = G_SCOPE_CHILDREN AND
191               p_op_idx <> 0
192         THEN
193 
194             FOR l_idx IN 1..g_eam_direct_items_tbl.COUNT
195             LOOP
196                 IF NVL(g_eam_direct_items_tbl(l_idx).OPERATION_SEQ_NUM,
197                        FND_API.G_MISS_NUM) =
198                    NVL(g_eam_op_tbl(p_op_idx).OPERATION_SEQ_NUM,
199                        FND_API.G_MISS_NUM)
200                 THEN
201 
202                     g_eam_direct_items_tbl(l_idx).return_status := p_other_status;
203                     EAM_ERROR_MESSAGE_PVT.Add_Message
204                     (  p_mesg_text      => p_other_mesg_text
205                      , p_entity_id      => G_DIRECT_ITEMS_LEVEL
206                      , p_entity_index   => l_idx
207                      , p_message_type   => 'E');
208                 END IF;
209             END LOOP;  -- DI Children of Op Seq Ends.
210 
211 
212         ELSIF p_error_scope = G_SCOPE_SIBLINGS AND
213               p_op_idx = 0
214         THEN
215 
216         --
217         -- This situation will arise when Op Seq is
218         -- not part of the business object input data.
219         -- Match the operation key information at the entity index
220         -- location with rest of the records, all those that are found
221         -- will be siblings and should get an error.
222         --
223 
224             FOR l_idx IN (p_entity_index+1)..g_eam_direct_items_tbl.COUNT
225             LOOP
226                 IF NVL(g_eam_direct_items_tbl(l_idx).OPERATION_SEQ_NUM, FND_API.G_MISS_NUM) =
227                    NVL(g_eam_direct_items_tbl(p_entity_index).OPERATION_SEQ_NUM, FND_API.G_MISS_NUM)
228                 THEN
229 
230                     g_eam_direct_items_tbl(l_idx).return_status := p_other_status;
231                     EAM_ERROR_MESSAGE_PVT.Add_Message
232                     (  p_mesg_text      => p_other_mesg_text
233                      , p_entity_id      => G_DIRECT_ITEMS_LEVEL
234                      , p_entity_index   => l_idx
235                      , p_message_type   => 'E');
236 
237                 END IF;
238             END LOOP;
239 
240        END IF; -- If error scope Ends
241 
242     END setDirectItems;
243 
244 
245 
246     /******************************************************************
247     * Procedure     : setSubResources
248     * Parameters    : Other Message
249     *                 Other Status
250     *                 Error Scope
251     *                 Entity Index
252     *                 Operation Index
253     *                 Operation Resource Index
254     * Purpose       : This procedure will set the reference designator
255     *                 record status to other status by looking at the
256     *                 revised item key or the revised component key or
257     *                 else setting all the record status to other status
258     ********************************************************************/
259     PROCEDURE setSubResources
260     (  p_error_scope        IN  VARCHAR2
261      , p_other_mesg_text    IN  VARCHAR2
262      , p_other_status       IN  VARCHAR2
263      , p_op_idx             IN  NUMBER := 0
264      , p_res_idx            IN  NUMBER := 0
265      , p_entity_index       IN  NUMBER := 0
266     )
267     IS
268                 l_idx   NUMBER;
269     BEGIN
270 
271          IF p_error_scope = G_SCOPE_ALL
272          THEN
273              FOR l_idx IN 1..g_eam_sub_res_tbl.COUNT
274              LOOP
275                  g_eam_sub_res_tbl(l_idx).return_status := p_other_status;
276 
277                  IF p_other_mesg_text IS NOT NULL
278                  THEN
279                        EAM_ERROR_MESSAGE_PVT.Add_Message
280                        (  p_mesg_text   => p_other_mesg_text
281                         , p_entity_id   => G_SUB_RES_LEVEL
282                         , p_entity_index=> l_idx
283                         , p_message_type=> 'E');
284                  END IF;
285              END LOOP;
286 
287          ELSIF p_error_scope = G_SCOPE_CHILDREN AND
288                p_op_idx <> 0
289          THEN
290 
291                 FOR l_idx IN 1..g_eam_sub_res_tbl.COUNT
292                 LOOP
293                    IF NVL(g_eam_sub_res_tbl(l_idx).OPERATION_SEQ_NUM, FND_API.G_MISS_NUM) =
294                       NVL(g_eam_op_tbl(p_op_idx).OPERATION_SEQ_NUM, FND_API.G_MISS_NUM)
295 
296                    THEN
297                         g_eam_sub_res_tbl(l_idx).return_status := p_other_status;
298                         EAM_ERROR_MESSAGE_PVT.Add_Message
299                         (  p_mesg_text          => p_other_mesg_text
300                          , p_entity_id          => G_SUB_RES_LEVEL
301                          , p_entity_index       => l_idx
302                          , p_message_type       => 'E');
303                     END IF;
304 
305                 END LOOP;  -- Sub Res Children of Op Seq Ends.
306 
307          ELSIF p_error_scope = G_SCOPE_SIBLINGS AND p_res_idx <> 0
308          THEN
309 
310                 FOR l_idx IN 1..g_eam_sub_res_tbl.COUNT
311                 LOOP
312                     IF NVL(g_eam_sub_res_tbl(l_idx).OPERATION_SEQ_NUM,
313                            FND_API.G_MISS_NUM) =
314                        NVL(g_eam_res_tbl(p_res_idx).OPERATION_SEQ_NUM,
315                            FND_API.G_MISS_NUM)
316 
317                     THEN
318                         g_eam_sub_res_tbl(l_idx).return_status := p_other_status;
319                         EAM_ERROR_MESSAGE_PVT.Add_Message
320                         (  p_mesg_text          => p_other_mesg_text
321                          , p_entity_id          => G_SUB_RES_LEVEL
322                          , p_entity_index       => l_idx
323                          , p_message_type       => 'E');
324                     END IF;
325                 END LOOP;
326 
327          ELSIF p_error_scope = G_SCOPE_SIBLINGS AND
328                p_op_idx  = 0 AND
329                p_res_idx = 0
330          THEN
331 
332                 FOR l_idx IN 1..g_eam_sub_res_tbl.COUNT
333                 LOOP
334                     IF NVL(g_eam_sub_res_tbl(l_idx).OPERATION_SEQ_NUM,
335                            FND_API.G_MISS_NUM) =
336                        NVL(g_eam_sub_res_tbl(p_entity_index).OPERATION_SEQ_NUM,
337                            FND_API.G_MISS_NUM)
338 
339                     THEN
340                         g_eam_sub_res_tbl(l_idx).return_status := p_other_status;
341                         EAM_ERROR_MESSAGE_PVT.Add_Message
342                         (  p_mesg_text          => p_other_mesg_text
343                          , p_entity_id          => G_SUB_RES_LEVEL
344                          , p_entity_index       => l_idx
345                          , p_message_type       => 'E');
346                     END IF;
347                 END LOOP;
348 
349 
350          END IF; -- If Scope = Ends.
351 
352     END setSubResources;
353 
357 
354 
355 
356 
358 
359 
360 
361 
362 
363     /******************************************************************
364     * Procedure     : setResInstances
365     * Parameters    : Other Message
366     *                 Other Status
367     *                 Error Scope
368     *                 Entity Index
369     *                 Operation Index
370     *                 Operation Resource Index
371     * Purpose       : This procedure will set the reference designator
372     *                 record status to other status by looking at the
373     *                 revised item key or the revised component key or
374     *                 else setting all the record status to other status
375     ********************************************************************/
376     PROCEDURE setResInstances
377     (  p_error_scope        IN  VARCHAR2
378      , p_other_mesg_text    IN  VARCHAR2
379      , p_other_status       IN  VARCHAR2
380      , p_op_idx             IN  NUMBER := 0
381      , p_res_idx            IN  NUMBER := 0
382      , p_entity_index       IN  NUMBER := 0
383     )
384     IS
385                 l_idx   NUMBER;
386     BEGIN
387 
388          IF p_error_scope = G_SCOPE_ALL
389          THEN
390              FOR l_idx IN 1..g_eam_res_inst_tbl.COUNT
391              LOOP
392                  g_eam_res_inst_tbl(l_idx).return_status := p_other_status;
393 
394                  IF p_other_mesg_text IS NOT NULL
395                  THEN
396                        EAM_ERROR_MESSAGE_PVT.Add_Message
397                        (  p_mesg_text   => p_other_mesg_text
398                         , p_entity_id   => G_RES_INST_LEVEL
399                         , p_entity_index=> l_idx
400                         , p_message_type=> 'E');
401                  END IF;
402              END LOOP;
403 
404          ELSIF p_error_scope = G_SCOPE_CHILDREN AND
405                p_op_idx <> 0
406          THEN
407 
408                 FOR l_idx IN 1..g_eam_res_inst_tbl.COUNT
409                 LOOP
410                    IF NVL(g_eam_res_inst_tbl(l_idx).OPERATION_SEQ_NUM, FND_API.G_MISS_NUM) =
411                       NVL(g_eam_op_tbl(p_op_idx).OPERATION_SEQ_NUM, FND_API.G_MISS_NUM)
412 
413                    THEN
414                         g_eam_res_inst_tbl(l_idx).return_status := p_other_status;
415                         EAM_ERROR_MESSAGE_PVT.Add_Message
416                         (  p_mesg_text          => p_other_mesg_text
417                          , p_entity_id          => G_RES_INST_LEVEL
418                          , p_entity_index       => l_idx
419                          , p_message_type       => 'E');
420                     END IF;
421 
422                 END LOOP;  -- Sub Res Children of Op Seq Ends.
423 
424          ELSIF p_error_scope = G_SCOPE_SIBLINGS AND p_res_idx <> 0
425          THEN
426 
427                 FOR l_idx IN 1..g_eam_res_inst_tbl.COUNT
428                 LOOP
429                     IF NVL(g_eam_res_inst_tbl(l_idx).OPERATION_SEQ_NUM,
430                            FND_API.G_MISS_NUM) =
431                        NVL(g_eam_res_tbl(p_res_idx).OPERATION_SEQ_NUM,
432                            FND_API.G_MISS_NUM)
433 
434                     THEN
435                         g_eam_res_inst_tbl(l_idx).return_status := p_other_status;
436                         EAM_ERROR_MESSAGE_PVT.Add_Message
437                         (  p_mesg_text          => p_other_mesg_text
438                          , p_entity_id          => G_RES_INST_LEVEL
439                          , p_entity_index       => l_idx
440                          , p_message_type       => 'E');
441                     END IF;
442                 END LOOP;
443 
444          ELSIF p_error_scope = G_SCOPE_SIBLINGS AND
445                p_op_idx  = 0 AND
446                p_res_idx = 0
447          THEN
448 
449                 FOR l_idx IN 1..g_eam_res_inst_tbl.COUNT
450                 LOOP
451                     IF NVL(g_eam_res_inst_tbl(l_idx).OPERATION_SEQ_NUM,
452                            FND_API.G_MISS_NUM) =
453                        NVL(g_eam_res_inst_tbl(p_entity_index).OPERATION_SEQ_NUM,
454                            FND_API.G_MISS_NUM)
455 
456                     THEN
457                         g_eam_res_inst_tbl(l_idx).return_status := p_other_status;
458                         EAM_ERROR_MESSAGE_PVT.Add_Message
459                         (  p_mesg_text          => p_other_mesg_text
460                          , p_entity_id          => G_RES_INST_LEVEL
461                          , p_entity_index       => l_idx
462                          , p_message_type       => 'E');
463                     END IF;
464                 END LOOP;
465 
466 
467          END IF; -- If Scope = Ends.
468 
469     END setResInstances;
470 
471 
472 
473 
474 
475 
476 
477 
478 
479 
480     /******************************************************************
481     * Procedure     : setResUsages
482     * Parameters    : Other Message
483     *                 Other Status
484     *                 Error Scope
485     *                 Entity Index
486     *                 Resource Usage Index
487     * Purpose       : This procedure will set the reference designator
488     *                 record status to other status by looking at the
489     *                 revised item key or the revised component key or
490     *                 else setting all the record status to other status
491     ********************************************************************/
492     PROCEDURE setResUsages
493     (  p_error_scope        IN  VARCHAR2
494      , p_other_mesg_text    IN  VARCHAR2
498      , p_res_usage_idx      IN  NUMBER := 0
495      , p_other_status       IN  VARCHAR2
496      , p_op_idx             IN  NUMBER := 0
497      , p_res_idx            IN  NUMBER := 0
499      , p_entity_index       IN  NUMBER := 0
500     )
501     IS
502                 l_idx   NUMBER;
503     BEGIN
504 
505          IF p_error_scope = G_SCOPE_ALL
506          THEN
507              FOR l_idx IN 1..g_eam_res_usage_tbl.COUNT
508              LOOP
509                  g_eam_res_usage_tbl(l_idx).return_status := p_other_status;
510 
511                  IF p_other_mesg_text IS NOT NULL
512                  THEN
513                        EAM_ERROR_MESSAGE_PVT.Add_Message
514                        (  p_mesg_text   => p_other_mesg_text
515                         , p_entity_id   => G_RES_USAGE_LEVEL
516                         , p_entity_index=> l_idx
517                         , p_message_type=> 'E');
518                  END IF;
519              END LOOP;
520 
521          ELSIF p_error_scope = G_SCOPE_CHILDREN AND
522                p_op_idx <> 0
523          THEN
524 
525                 FOR l_idx IN 1..g_eam_res_usage_tbl.COUNT
526                 LOOP
527                    IF NVL(g_eam_res_usage_tbl(l_idx).OPERATION_SEQ_NUM, FND_API.G_MISS_NUM) =
528                       NVL(g_eam_op_tbl(p_op_idx).OPERATION_SEQ_NUM, FND_API.G_MISS_NUM)
529 
530                    THEN
531                         g_eam_res_usage_tbl(l_idx).return_status := p_other_status;
532                         EAM_ERROR_MESSAGE_PVT.Add_Message
533                         (  p_mesg_text          => p_other_mesg_text
534                          , p_entity_id          => G_RES_USAGE_LEVEL
535                          , p_entity_index       => l_idx
536                          , p_message_type       => 'E');
537                     END IF;
538 
539                 END LOOP;  -- Res usage Children of Op Seq Ends.
540 
541          ELSIF p_error_scope = G_SCOPE_SIBLINGS AND p_res_idx <> 0
542          THEN
543 
544                 FOR l_idx IN 1..g_eam_res_usage_tbl.COUNT
545                 LOOP
546                     IF NVL(g_eam_res_usage_tbl(l_idx).OPERATION_SEQ_NUM,
547                            FND_API.G_MISS_NUM) =
548                        NVL(g_eam_res_tbl(p_res_idx).OPERATION_SEQ_NUM,
549                            FND_API.G_MISS_NUM)
550 
551                     THEN
552                         g_eam_res_usage_tbl(l_idx).return_status := p_other_status;
553                         EAM_ERROR_MESSAGE_PVT.Add_Message
554                         (  p_mesg_text          => p_other_mesg_text
555                          , p_entity_id          => G_RES_USAGE_LEVEL
556                          , p_entity_index       => l_idx
557                          , p_message_type       => 'E');
558                     END IF;
559                 END LOOP;
560 
561          ELSIF p_error_scope = G_SCOPE_SIBLINGS AND
562                p_op_idx  = 0 AND
563                p_res_idx = 0
564          THEN
565 
566                 FOR l_idx IN 1..g_eam_res_usage_tbl.COUNT
567                 LOOP
568                     IF NVL(g_eam_res_usage_tbl(l_idx).OPERATION_SEQ_NUM,
569                            FND_API.G_MISS_NUM) =
570                        NVL(g_eam_res_usage_tbl(p_entity_index).OPERATION_SEQ_NUM,
571                            FND_API.G_MISS_NUM)
572 
573                     THEN
574                         g_eam_res_usage_tbl(l_idx).return_status := p_other_status;
575                         EAM_ERROR_MESSAGE_PVT.Add_Message
576                         (  p_mesg_text          => p_other_mesg_text
577                          , p_entity_id          => G_RES_USAGE_LEVEL
578                          , p_entity_index       => l_idx
579                          , p_message_type       => 'E');
580                     END IF;
581                 END LOOP;
582 
583 
584          END IF; -- If Scope = Ends.
585 
586     END setResUsages;
587 
588 
589 
590 
591 
592 
593     /******************************************************************
594     * Procedure : setOperationResources
595     * Parameters    : Other Message
596     *                 Other Status
597     *                 Error Scope
598     *                 Entity Index
599     *                 Operation Index
600     * Purpose   : This procedure will set the operation resource
601     *             record status to other status by looking at the
602     *             operation sequence key or else setting all the record
603     *             status to other status
604     ********************************************************************/
605 
606     PROCEDURE setOperationResources
607     (  p_error_scope        IN  VARCHAR2
608      , p_other_mesg_text    IN  VARCHAR2
609      , p_other_status       IN  VARCHAR2
610      , p_op_idx             IN  NUMBER := 0
611      , p_entity_index       IN  NUMBER := 0
612     )
613     IS
614         l_idx   NUMBER;
615     BEGIN
616 
617         IF p_error_scope = G_SCOPE_ALL
618         THEN
619            FOR l_idx IN (p_entity_index+1)..g_eam_res_tbl.COUNT
620            LOOP
621                g_eam_res_tbl(l_idx).return_status := p_other_status;
622 
623                IF p_other_mesg_text IS NOT NULL
624                THEN
625                   EAM_ERROR_MESSAGE_PVT.Add_Message
626                   ( p_mesg_text     => p_other_mesg_text
627                   , p_entity_id     => G_RES_LEVEL
628                   , p_entity_index  => l_idx
629                   , p_message_type  => 'E');
630                END IF;
631             END LOOP;
632 
633             --
634             -- Set the Substitute Operation Resources Record Status too
638              , p_other_mesg_text    => p_other_mesg_text
635             --
636             setSubResources
637             (  p_other_status       => p_other_status
639              , p_error_scope        => p_error_scope
640              );
641 
642 
643         ELSIF p_error_scope = G_SCOPE_CHILDREN AND
644               p_op_idx <> 0
645         THEN
646 
647 
648             FOR l_idx IN 1..g_eam_res_tbl.COUNT
649             LOOP
650 
651                 IF NVL(g_eam_res_tbl(l_idx).OPERATION_SEQ_NUM,
652                        FND_API.G_MISS_NUM) =
653                    NVL(g_eam_op_tbl(p_op_idx).OPERATION_SEQ_NUM,
654                        FND_API.G_MISS_NUM)
655                 THEN
656 
657                     g_eam_res_tbl(l_idx).return_status := p_other_status;
658                     EAM_ERROR_MESSAGE_PVT.Add_Message
659                     (  p_mesg_text      => p_other_mesg_text
660                      , p_entity_id      => G_RES_LEVEL
661                      , p_entity_index   => l_idx
662                      , p_message_type   => 'E');
663                 END IF;
664             END LOOP;  -- Op Resource Children of Op Seq Ends.
665 
666         ELSIF p_error_scope = G_SCOPE_SIBLINGS AND
667               p_op_idx = 0
668         THEN
669 
670         -- This situation will arise when Op Seq is
671         -- not part of the business object input data.
672         -- Match the operation key information at the entity index
673         -- location with rest of the records, all those that are found
674         -- will be siblings and should get an error.
675 
676             FOR l_idx IN (p_entity_index+1)..g_eam_res_tbl.COUNT
677             LOOP
678                 IF NVL(g_eam_res_tbl(l_idx).OPERATION_SEQ_NUM,
679                        FND_API.G_MISS_NUM) =
680                    NVL(g_eam_res_tbl(p_entity_index).OPERATION_SEQ_NUM,
681                        FND_API.G_MISS_NUM)
682                 THEN
683 
684                     g_eam_res_tbl(l_idx).return_status := p_other_status;
685                     EAM_ERROR_MESSAGE_PVT.Add_Message
686                     (  p_mesg_text      => p_other_mesg_text
687                      , p_entity_id      => G_RES_LEVEL
688                      , p_entity_index   => l_idx
689                      , p_message_type   => 'E');
690 
691                 END IF;
692             END LOOP;
693 
694         --
695         -- Substitute Operation Resources will also be considered as siblings
696         -- of operation resource, they should get an error when
697         -- error level is operation resource with scope of Siblings
698 
699             setSubResources
700             (  p_other_status       => p_other_status
701              , p_other_mesg_text    => p_other_mesg_text
702              , p_error_scope        => p_error_scope
703              , p_res_idx            => p_entity_index
704             );
705 
706        END IF; -- If error scope Ends
707 
708     END setOperationResources ;
709 
710 
711     /*****************************************************************
712     * Procedure     : setOperationSequences
713     * Parameters IN : Other Message Text
714     *                 Other status
715     *                 Entity Index
716     *                 Error Scope
717     *                 Error Status
718     *                 Revised Item Index
719     * Parameters OUT NOCOPY: None
720     * Purpose       : This procedure will set the revised components record
721     *                 status to other status and for each errored record
722     *                 it will log the other message indicating what caused
723     *                 the other records to fail.
724     ******************************************************************/
725     PROCEDURE setOperationSequences
726     (  p_error_scope        IN  VARCHAR2
727      , p_other_mesg_text    IN  VARCHAR2
728      , p_other_status       IN  VARCHAR2
729      , p_entity_index       IN  NUMBER := 0
730      )
731     IS
732         l_Idx       NUMBER;
733     BEGIN
734 
735 
736         IF p_error_scope = G_SCOPE_ALL
737         THEN
738 
739             FOR l_idx IN 1..g_eam_op_tbl.COUNT
740             LOOP
741             g_eam_op_tbl(l_idx).return_status := p_other_status;
742 
743                IF p_other_mesg_text IS NOT NULL
744                THEN
745                   EAM_ERROR_MESSAGE_PVT.Add_Message
746                   ( p_mesg_text    => p_other_mesg_text
747                   , p_entity_id    => G_OP_LEVEL
748                   , p_entity_index => l_Idx
749                   , p_message_type => 'E');
750                END IF;
751 
752             END LOOP;
753 
754             --
755             -- Set the operation resource and substitute
756             -- operation resource record status too.
757             --
758             setOperationResources
759                     (  p_other_status    => p_other_status
760                      , p_error_scope     => p_error_scope
761                      , p_other_mesg_text => p_other_mesg_text
762                      );
763 
764         END IF; -- Error Scope Ends
765 
766     END setOperationSequences ;
767 
768 
769     /*****************************************************************
770     * Procedure : setOpNetworks
771     * Parameters IN : Other Message Text
772     *                 Other status
773     *                 Entity Index
774     * Parameters OUT NOCOPY: None
775     * Purpose   : This procedure will set the Operation Network record
776     *             status to other status and for each errored record
777     *             it will log the other message indicating what caused
781     (  p_other_mesg_text    IN  VARCHAR2
778     *             the other records to fail.
779     ******************************************************************/
780     PROCEDURE setOpNetworks
782      , p_other_status       IN  VARCHAR2
783     )
784     IS
785         l_CurrentIndex  NUMBER;
786     BEGIN
787 
788         FOR l_CurrentIndex IN  1..g_eam_op_network_tbl.COUNT
789         LOOP
790             g_eam_op_network_tbl(l_CurrentIndex).return_status :=
791                         p_other_status;
792             IF p_other_mesg_text IS NOT NULL
793             THEN
794                 EAM_ERROR_MESSAGE_PVT.Add_Message
795                 (  p_mesg_text      => p_other_mesg_text
796                  , p_entity_id      => G_OP_NETWORK_LEVEL
797                  , p_entity_index   => l_CurrentIndex
798                  , p_message_type   => 'E');
799             END IF;
800         END LOOP;
801 
802     END setOpNetworks ;
803 
804 
805 
806 
807         /****************************************************************
808         * Procedure     : Add_Message
809         * Paramaters IN : Message Text
810         *                 Entity ID
811         *                 Entity Index
812         * Parameters OUT NOCOPY: None
813         * Purpose       : Add_Message will push a message on the message
814         *                 stack and will convert the numeric entity id to
815         *                 character which will be easier for the user to
816         *                 understand. eg. Entity Id = 1 which will be ECO
817         *****************************************************************/
818         PROCEDURE Add_Message
819         (  p_mesg_text          IN  VARCHAR2
820          , p_entity_id          IN  NUMBER
821          , p_entity_index       IN  NUMBER
822          , p_message_type       IN  VARCHAR2)
823         IS
824                 l_Idx                   BINARY_INTEGER;
825                 l_entity_id_char        VARCHAR2(3);
826 
827         BEGIN
828 
829                 l_Idx := G_ERROR_TABLE.COUNT;
830 
831                 IF p_entity_id = G_WO_LEVEL
832                 THEN
833                         l_entity_id_char := 'WO';
834                 ELSIF p_entity_id = G_OP_LEVEL
835                 THEN
836                         l_entity_id_char := 'OP';
837                 ELSIF p_entity_id = G_OP_NETWORK_LEVEL
838                 THEN
839                         l_entity_id_char := 'ON';
840                 ELSIF p_entity_id = G_RES_LEVEL
841                 THEN
842                         l_entity_id_char := 'RS';
843                 ELSIF p_entity_id = G_RES_INST_LEVEL
844                 THEN
845                         l_entity_id_char := 'RI';
846                 ELSIF p_entity_id = G_SUB_RES_LEVEL
847                 THEN
848                         l_entity_id_char := 'SR';
849                 ELSIF p_entity_id = G_RES_USAGE_LEVEL
850                 THEN
851                         l_entity_id_char := 'RU';
852                 ELSIF p_entity_id = G_MAT_REQ_LEVEL
853                 THEN
854                         l_entity_id_char := 'MR';
855                 END IF;
856 
857 
858 
859                 G_ERROR_TABLE(l_Idx + 1).message_text := p_mesg_text;
860                 G_ERROR_TABLE(l_idx + 1).entity_id    := l_entity_id_char;
861                 G_ERROR_TABLE(l_idx + 1).entity_index := p_entity_index;
862                 G_ERROR_TABLE(l_idx + 1).message_type := p_message_type;
863                 G_ERROR_TABLE(l_Idx + 1).bo_identifier:= EAM_ERROR_MESSAGE_PVT.Get_BO_Identifier;
864 
865                 -- Increment the message counter to keep a tally.
866 
867                 G_Msg_Count := G_Error_Table.Count;
868 
869 
870         END Add_Message;
871 
872 
873 
874         /**********************************************************************
875         * Procedure     : Add_Error_Token
876         * Parameters IN : Message Text (in case of unexpected errors)
877         *                 Message Name
878         *                 Mesg Token Tbl
879         *                 Token Table
880         * Parameters OUT: Mesg Token Table
881         * Purpose       : This procedure will create a list messages and their
882         *                 tokens. When the user passes in a message wtih a
883         *                 bunch of token, this procedure will do ahead and
884         *                 that message in to the mesg_token_tbl with all those
885         *                 token, so that that the log error procedure can
886         *                 then seperate the message and its token for generating
887         *                 a token substituted and translated message.
888         **********************************************************************/
889 
890         PROCEDURE Add_Error_Token
891         (  p_message_name      IN  VARCHAR2 := NULL
892          , p_application_id    IN  VARCHAR2 := 'EAM'
893          , p_message_text      IN  VARCHAR2 := NULL
894          , x_Mesg_Token_tbl    OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
895          , p_Mesg_Token_Tbl    IN  EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type :=
896                                    EAM_ERROR_MESSAGE_PVT.G_MISS_MESG_TOKEN_TBL
897          , p_token_tbl         IN  EAM_ERROR_MESSAGE_PVT.Token_Tbl_Type :=
898                                    EAM_ERROR_MESSAGE_PVT.G_MISS_TOKEN_TBL
899          , p_message_type      IN  VARCHAR2 := 'E'
900          )
901         IS
902                 l_Index         NUMBER;
903                 l_TableCount    NUMBER;
904                 l_Mesg_Token_Tbl EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type ;
905         BEGIN
906                 ----------------------------------------------------------------
910                 -- Log_Error procedure to create a token substituted and
907                 -- This procedure can be called from the individual entity
908                 -- validation  procedures to fill up the err_token_tbl that will
909                 -- be passed to the
911                 -- translated list of messages.
912                 ----------------------------------------------------------------
913 
914                 l_Mesg_Token_Tbl := p_Mesg_Token_Tbl;
915                 l_Index := 0;
916                 l_TableCount := l_Mesg_token_tbl.COUNT;
917 
918               IF p_message_name IS NOT NULL THEN
919 
920                 IF p_token_tbl.COUNT = 0 AND
921                         p_message_name IS NOT NULL
922                 THEN
923                         l_Mesg_token_tbl(l_TableCount + 1).message_name :=
924                                         p_message_name;
925                         l_Mesg_token_Tbl(l_TableCount + 1).message_type
926                                 := p_message_type;
927                         l_Mesg_token_tbl(l_TableCount + 1).Application_id
928                                 := SUBSTR(p_message_name, 1, 3);
929 
930 
931                 ELSIF p_token_tbl.COUNT <> 0 AND
932                         p_message_name IS NOT NULL
933                 THEN
934                         FOR l_Index IN 1..p_token_tbl.COUNT LOOP
935                                 l_TableCount := l_TableCount + 1;
936                                 l_Mesg_token_tbl(l_TableCount).message_name :=
937                                         p_message_name;
938                                 l_Mesg_token_tbl(l_TableCount).token_name :=
939                                         p_token_tbl(l_Index).token_name;
940                                 l_Mesg_token_tbl(l_TableCount).token_value
941                                         := p_token_tbl(l_Index).token_value;
942                                 l_Mesg_token_tbl(l_TableCount).translate
943                                         := p_token_tbl(l_Index).translate;
944                                 l_Mesg_token_Tbl(l_TableCount).message_type
945                                         := p_message_type;
946                                l_Mesg_token_tbl(l_TableCount).Application_id
947                                 := SUBSTR(p_message_name, 1, 3);
948 
949 
950                         END LOOP;
951 		END IF;
952                 ELSIF p_message_name IS NULL AND
953                       p_message_text IS NOT NULL THEN
954                         l_Mesg_token_tbl(l_TableCount + 1).message_text :=
955                                 p_message_text;
956                         l_Mesg_token_Tbl(l_TableCount + 1).message_type
957                                 := p_message_type;
958                 END IF;
959 
960 
961 
962                 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
963 
964         END Add_Error_Token;
965 
966 
967         /*********************************************************************
968         * Procedure     : Translate_And_Insert_Messages
969         * Returns       : None
970         * Parameters IN : Message Token Table
971         * Parameters OUT NOCOPY: None
972         * Purpose       : This procedure will parse through the message token
973         *                 table and seperate tokens for a message, get the
974         *                 translated message, substitute the tokens and insert
975         *                 the message in the message table.
976         **********************************************************************/
977         PROCEDURE Translate_And_Insert_Messages
978         (  p_mesg_token_tbl     IN  EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
979          , p_error_level        IN  NUMBER
980          , p_entity_index       IN  NUMBER
981          , p_application_id     IN  VARCHAR2 := 'EAM'
982          )
983         IS
984                 l_message_text  VARCHAR2(2000);
985                 l_message_name  VARCHAR2(30);
986         BEGIN
987                 l_message_name := NULL;
988                 FOR l_LoopIndex IN 1..p_mesg_token_tbl.COUNT
989                 LOOP
990                       IF NVL(l_message_name, ' ') <> p_mesg_token_tbl(l_LoopIndex).message_name
991                         THEN
992 
993 			       fnd_message.set_name
994                                 (  application  => p_mesg_token_tbl(l_LoopIndex).application_id
995                                  , name         => p_mesg_token_tbl(l_LoopIndex).message_name
996                                  );
997 
998 				-- add token/tokens to message
999                                 IF p_mesg_token_tbl(l_LoopIndex).token_name IS NOT NULL
1000                                 THEN
1001                                    fnd_message.set_token
1002                                    (  token     => p_mesg_token_tbl(l_LoopIndex).token_name
1003                                     , value     => p_mesg_token_tbl(l_LoopIndex).token_value
1004                                     );
1005                                 END IF; -- Check on token
1006 
1007 				l_message_name := p_mesg_token_tbl(l_LoopIndex).message_name;
1008 
1009 				-- insert a message when last message or message changes in p_mesg_token_tbl
1010                                 IF l_loopIndex=p_mesg_token_tbl.COUNT OR (l_loopIndex<>p_mesg_token_tbl.COUNT AND l_message_name<>p_mesg_token_tbl(l_loopIndex+1).message_name)
1011 				THEN
1012 					fnd_msg_pub.add;
1013 				END IF; -- Check for last message/ new message
1014 
1015 			-- Check for first message/ new message ends
1016 
1017 			-- add multiple tokens in a message
1018                         ELSIF l_message_name = p_mesg_token_tbl(l_LoopIndex).message_name
1019                         THEN
1020 			       -- add a token to message
1021                                IF p_mesg_token_tbl(l_LoopIndex).token_name IS NOT NULL
1022                                 THEN
1026                                    );
1023                                    fnd_message.set_token
1024                                    (  token     => p_mesg_token_tbl(l_LoopIndex).token_name
1025                                     , value     => p_mesg_token_tbl(l_LoopIndex).token_value
1027                                 END IF ; -- Check on token
1028 
1029 				--insert a message when last message or message changes in p_mesg_token_tbl
1030 				IF l_loopIndex=p_mesg_token_tbl.COUNT OR (l_loopIndex<>p_mesg_token_tbl.COUNT AND l_message_name<>p_mesg_token_tbl(l_loopIndex+1).message_name)
1031 				THEN
1032 					fnd_msg_pub.add;
1033 				END IF;	-- Check for last message/ new message
1034 
1035                                 l_message_name := p_mesg_token_tbl(l_LoopIndex).message_name;
1036 
1037                         END IF;
1038 
1039                 END LOOP;
1040                 -- Mesg Token Tbl Loop Ends.
1041 		-- loop inserts message/messages with a single or multiple token for display on UI
1042 
1043 		l_message_name := NULL;
1044 
1045 		FOR l_LoopIndex IN 1..p_mesg_token_tbl.COUNT
1046                 LOOP
1047                        IF NVL(l_message_name, ' ') <> p_mesg_token_tbl(l_LoopIndex).message_name
1048                         THEN
1049                                fnd_message.set_name
1050                                 (  application  => p_mesg_token_tbl(l_LoopIndex).application_id
1051                                  , name         => p_mesg_token_tbl(l_LoopIndex).message_name
1052                                  );
1053 
1054 				-- add token/tokens to message
1055                                 IF p_mesg_token_tbl(l_LoopIndex).token_name IS NOT NULL
1056                                 THEN
1057                                    fnd_message.set_token
1058                                    (  token     => p_mesg_token_tbl(l_LoopIndex).token_name
1059                                     , value     => p_mesg_token_tbl(l_LoopIndex).token_value
1060                                     , translate => p_mesg_token_tbl(l_LoopIndex).translate
1061                                     );
1062                                 END IF; -- Check on token
1063 
1064 				l_message_name := p_mesg_token_tbl(l_LoopIndex).message_name;
1065 
1066 				-- add a message when last message or message changes in p_mesg_token_tbl
1067                                 IF l_loopIndex=p_mesg_token_tbl.COUNT OR (l_loopIndex<>p_mesg_token_tbl.COUNT AND l_message_name<>p_mesg_token_tbl(l_loopIndex+1).message_name)
1068 				THEN
1069 					l_message_text := fnd_message.get;
1070 					IF (l_message_text IS NOT NULL OR l_message_text <> ' ' OR l_message_text <> '' )
1071 					THEN
1072 					Add_Message
1073 					   (  p_mesg_text          => l_message_text
1074 					    , p_entity_id          => p_error_level
1075 					    , p_entity_index       => p_entity_index
1076 					    , p_message_type       => p_mesg_token_tbl(l_LoopIndex).message_type);
1077 					END IF; -- check for Message Text
1078 				END IF; -- check for last message/ new message
1079 
1080                        ELSIF l_message_name = p_mesg_token_tbl(l_LoopIndex).message_name
1081                         THEN
1082 			       -- add token/tokens to message
1083                                IF p_mesg_token_tbl(l_LoopIndex).token_name IS NOT NULL
1084                                 THEN
1085                                    fnd_message.set_token
1086                                    (  token     => p_mesg_token_tbl(l_LoopIndex).token_name
1087                                     , value     => p_mesg_token_tbl(l_LoopIndex).token_value
1088                                     , translate => p_mesg_token_tbl(l_LoopIndex).translate
1089                                    );
1090                                 END IF ; -- Check on token
1091 
1092 				-- add a message when last message or message changes in p_mesg_token_tbl
1093                                 IF l_loopIndex=p_mesg_token_tbl.COUNT OR (l_loopIndex<>p_mesg_token_tbl.COUNT AND l_message_name<>p_mesg_token_tbl(l_loopIndex+1).message_name)
1094 				THEN
1095 					l_message_text := fnd_message.get;
1096 					IF (l_message_text IS NOT NULL OR l_message_text <> ' ' OR l_message_text <> '' )
1097 					THEN
1098 					Add_Message
1099 					   (  p_mesg_text          => l_message_text
1100 					    , p_entity_id          => p_error_level
1101 					    , p_entity_index       => p_entity_index
1102 					    , p_message_type       => p_mesg_token_tbl(l_LoopIndex).message_type);
1103 					END IF; -- check for Message Text ends
1104 				END IF;  -- check for last message/ new message
1105 
1106                                 l_message_name := p_mesg_token_tbl(l_LoopIndex).message_name;
1107 
1108                         END IF;
1109 
1110 			-- Add the unexpected error message which may not have a message name
1111                         IF p_mesg_token_tbl(l_LoopIndex).message_name IS NULL AND p_mesg_token_tbl(l_LoopIndex).message_text IS NOT NULL
1112                         THEN
1113                                 Add_Message
1114                                 (  p_mesg_text    => p_mesg_token_tbl(l_LoopIndex).message_text
1115                                  , p_entity_id    => p_error_level
1116                                  , p_entity_index => p_entity_index
1117                                  , p_message_type => p_mesg_token_tbl(l_LoopIndex).message_type
1118                                  );
1119                         END IF;
1120 
1121                 END LOOP;
1122 		-- Mesg Token Tbl Loop for log ends
1123 		-- This adds message/messages with a single or multiple tokenc to log
1124         END Translate_And_Insert_Messages;
1125 
1126 
1127         /******************************************************************
1128         * Procedure     : Log_Error
1129         * Parameters IN : Work Order Record and Rest of the Entity Tables
1130         *                 Message Token Table
1131         *                 Other Message Table
1132         *                 Other Status
1136         *                 Error Status
1133         *                 Entity Index
1134         *                 Error Level
1135         *                 Error Scope
1137         * Parameters OUT NOCOPY:  Work Order Record and Rest of the Entity Tables
1138         * Purpose       : Log Error will take the Message Token Table and
1139         *                 seperate the message and their tokens, get the
1140         *                 token substitute messages from the message dictionary
1141         *                 and put in the error stack.
1142         *                 Log Error will also make sure that the error
1143         *                 propogates to the right level's of the business object
1144         *                 and that the rest of the entities get the appropriate
1145         *                 status and message.
1146         ******************************************************************/
1147 
1148         PROCEDURE Log_Error
1149         (  p_eam_wo_rec         IN  EAM_PROCESS_WO_PUB.eam_wo_rec_type
1150                                     :=EAM_PROCESS_WO_PUB.G_MISS_EAM_WO_REC
1151          , p_eam_op_tbl         IN  EAM_PROCESS_WO_PUB.eam_op_tbl_type
1152                                     :=EAM_PROCESS_WO_PUB.G_MISS_EAM_OP_TBL
1153          , p_eam_op_network_tbl IN  EAM_PROCESS_WO_PUB.eam_op_network_tbl_type
1154                                     :=EAM_PROCESS_WO_PUB.G_MISS_EAM_OP_NETWORK_TBL
1155          , p_eam_res_tbl        IN  EAM_PROCESS_WO_PUB.eam_res_tbl_type
1156                                     :=EAM_PROCESS_WO_PUB.G_MISS_EAM_RES_TBL
1157          , p_eam_res_inst_tbl   IN  EAM_PROCESS_WO_PUB.eam_res_inst_tbl_type
1158                                     :=EAM_PROCESS_WO_PUB.G_MISS_EAM_RES_INST_TBL
1159          , p_eam_sub_res_tbl    IN  EAM_PROCESS_WO_PUB.eam_sub_res_tbl_type
1160                                     :=EAM_PROCESS_WO_PUB.G_MISS_EAM_SUB_RES_TBL
1161          , p_eam_res_usage_tbl  IN  EAM_PROCESS_WO_PUB.eam_res_usage_tbl_type
1162                                     :=EAM_PROCESS_WO_PUB.G_MISS_EAM_RES_USAGE_TBL
1163          , p_eam_mat_req_tbl    IN  EAM_PROCESS_WO_PUB.eam_mat_req_tbl_type
1164                                     :=EAM_PROCESS_WO_PUB.G_MISS_EAM_MAT_REQ_TBL
1165          , p_eam_direct_items_tbl    IN  EAM_PROCESS_WO_PUB.eam_direct_items_tbl_type
1166                                 :=EAM_PROCESS_WO_PUB.G_MISS_EAM_DIRECT_ITEMS_TBL
1167          , x_eam_wo_rec         OUT NOCOPY EAM_PROCESS_WO_PUB.eam_wo_rec_type
1168          , x_eam_op_tbl         OUT NOCOPY EAM_PROCESS_WO_PUB.eam_op_tbl_type
1169          , x_eam_op_network_tbl OUT NOCOPY EAM_PROCESS_WO_PUB.eam_op_network_tbl_type
1170          , x_eam_res_tbl        OUT NOCOPY EAM_PROCESS_WO_PUB.eam_res_tbl_type
1171          , x_eam_res_inst_tbl   OUT NOCOPY EAM_PROCESS_WO_PUB.eam_res_inst_tbl_type
1172          , x_eam_sub_res_tbl    OUT NOCOPY EAM_PROCESS_WO_PUB.eam_sub_res_tbl_type
1173          , x_eam_res_usage_tbl  OUT NOCOPY EAM_PROCESS_WO_PUB.eam_res_usage_tbl_type
1174          , x_eam_mat_req_tbl    OUT NOCOPY EAM_PROCESS_WO_PUB.eam_mat_req_tbl_type
1175          , x_eam_direct_items_tbl    OUT NOCOPY EAM_PROCESS_WO_PUB.eam_direct_items_tbl_type
1176          , p_mesg_token_tbl     IN  EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
1177          , p_error_status       IN  VARCHAR2
1178          , p_error_scope        IN  VARCHAR2 := NULL
1179          , p_other_message      IN  VARCHAR2 := NULL
1180          , p_other_mesg_appid   IN  VARCHAR2 := 'EAM'
1181          , p_other_status       IN  VARCHAR2 := NULL
1182          , p_other_token_tbl    IN  EAM_ERROR_MESSAGE_PVT.Token_Tbl_Type
1183                                     := EAM_ERROR_MESSAGE_PVT.G_MISS_TOKEN_TBL
1184          , p_error_level        IN   NUMBER
1185          , p_entity_index       IN   NUMBER := 1  -- := NULL
1186          )
1187         IS
1188                 l_message_name          VARCHAR2(30);
1189                 l_other_message         VARCHAR2(2000);
1190                 l_message_text          VARCHAR2(2000);
1191                 l_LoopIndex             NUMBER;
1192                 l_Error_Level           NUMBER      := p_Error_Level;
1193                 l_error_scope           VARCHAR2(1) := p_error_scope;
1194                 l_error_status          VARCHAR2(1) := p_error_status;
1195                 l_application_id        VARCHAR2(3);
1196 
1197         BEGIN
1198 
1199                 g_eam_wo_rec            := p_eam_wo_rec;
1200                 g_eam_op_tbl            := p_eam_op_tbl;
1201                 g_eam_op_network_tbl    := p_eam_op_network_tbl;
1202                 g_eam_res_tbl           := p_eam_res_tbl;
1203                 g_eam_res_inst_tbl      := p_eam_res_inst_tbl;
1204                 g_eam_sub_res_tbl       := p_eam_sub_res_tbl;
1205                 g_eam_res_usage_tbl     := p_eam_res_usage_tbl;
1206                 g_eam_mat_req_tbl       := p_eam_mat_req_tbl;
1207                 g_eam_direct_items_tbl  := p_eam_direct_items_tbl;
1208 
1209                 l_application_id :=  p_other_mesg_appid;
1210 
1211                 --
1212                 -- Seperate message and their tokens, get the
1213                 -- token substituted messages and put it in the
1214                 -- Error Table.
1215           --
1216 
1217 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Within the Log Error Procedure . . .'); END IF;
1218 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Scope: ' || l_error_scope); END IF;
1219 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Entity Index: ' || to_char(p_entity_index)); END IF;
1220 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Error Level: ' || to_char(p_error_level)); END IF;
1221 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Error Status: ' || l_error_status); END IF;
1222 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Other Status: ' || p_other_status); END IF;
1223 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Other Message: ' || p_other_message); END IF;
1227                 (  p_mesg_token_Tbl     => p_mesg_token_tbl
1224 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Business Object: ' || Get_BO_Identifier); END IF;
1225 
1226                 EAM_ERROR_MESSAGE_PVT.Translate_And_Insert_Messages
1228                  , p_error_level        => p_error_level
1229                  , p_entity_index       => p_entity_index
1230                 );
1231 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Finished logging messages . . . '); END IF;
1232 
1233                 --
1234                 -- Get the other message text and token and retrieve the
1235                 -- token substituted message.
1236               IF p_other_message is not null THEN
1237 
1238                 IF p_other_token_tbl.COUNT <> 0
1239                 THEN
1240                         fnd_message.set_name
1241                         (  application  => l_application_id
1242                          , name         => p_other_message
1243                          );
1244 
1245                         FOR l_LoopIndex IN 1 .. p_other_token_tbl.COUNT
1246                         LOOP
1247                                 IF p_other_token_tbl(l_LoopIndex).token_name IS NOT NULL
1248                                 THEN
1249                                    fnd_message.set_token
1250                                    ( token      => p_other_token_tbl(l_LoopIndex).token_name
1251                                     , value     => p_other_token_tbl(l_LoopIndex).token_value
1252                                     );
1253                                 END IF;
1254                         END LOOP;
1255 
1256                         fnd_msg_pub.add;
1257 
1258                         fnd_message.set_name
1259                         (  application  => l_application_id
1260                          , name         => p_other_message
1261                          );
1262 
1263                         FOR l_LoopIndex IN 1 .. p_other_token_tbl.COUNT
1264                         LOOP
1265                                 IF p_other_token_tbl(l_LoopIndex).token_name IS NOT NULL
1266                                 THEN
1267                                    fnd_message.set_token
1268                                    ( token      => p_other_token_tbl(l_LoopIndex).token_name
1269                                     , value     => p_other_token_tbl(l_LoopIndex).token_value
1270                                     , translate => p_other_token_tbl(l_LoopIndex).translate
1271                                     );
1272                                 END IF;
1273                         END LOOP;
1274 
1275                         l_other_message := fnd_message.get;
1276 
1277                 ELSE
1278                         fnd_message.set_name
1279                         (  application  => l_application_id
1280                          , name         => p_other_message
1281                          );
1282 
1283                         fnd_msg_pub.add;
1284 
1285                         fnd_message.set_name
1286                         (  application  => l_application_id
1287                          , name         => p_other_message
1288                          );
1289 
1290                         l_other_message := fnd_message.get;
1291 
1292                 END IF;
1293                 -- Other Token Tbl Count <> 0 Ends
1294                                 Add_Message
1295                                 (  p_mesg_text          => l_other_message
1296                                  , p_entity_id          => p_error_level
1297                                  , p_entity_index       => p_entity_index
1298                                  , p_message_type       => 'E'
1299                                  );
1300                                 l_other_message := NULL;
1301               END IF;
1302 
1303 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Finished extracting other message . . . '); END IF;
1304 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Other Message generated: ' || l_other_message); END IF;
1305 
1306         /*
1307                 --
1308                 -- If the Error Level is Business Object
1309                 -- then set the Error Level = WO
1310                 --
1311 
1312                 IF l_error_level = G_BO_LEVEL
1313                 THEN
1314                         l_error_level := G_WO_LEVEL;
1315 
1316 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Error Level is Business Object . . . '); END IF;
1317 
1318                 END IF;
1319 
1320 
1321                 --
1322                 -- If the error_status is UNEXPECTED then set the error scope
1323                 -- to ALL, if WARNING then set the scope to RECORD.
1324                 --
1325 
1326                 IF l_error_status = G_STATUS_UNEXPECTED
1327                 THEN
1328 
1329 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Status unexpected and scope is All . . .'); END IF;
1330 
1331                         l_error_scope := G_SCOPE_ALL;
1332 
1333                 ELSIF l_error_status = G_STATUS_WARNING
1334 
1335                 THEN
1336                         l_error_scope := G_SCOPE_RECORD;
1337                         l_error_status := FND_API.G_RET_STS_SUCCESS;
1338 
1339 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Status is warning . . .'); END IF;
1340 
1341                 END IF;
1342 
1343                 --
1344                 -- If the Error Level is WO Header, then the scope can be
1345                 -- ALL/CHILDREN OR RECORD.
1346                 --
1347 
1348                 --
1349                 -- If the Error Level is WO Header.
1350 
1351 
1352              IF l_error_level = G_WO_LEVEL
1353                 THEN
1357                         -- Set the WO Header record status to p_error_status
1354 
1355 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Error Level is WO Header . . .'); END IF;
1356                         --
1358                         -- This will also take care of the scope RECORD.
1359                         --
1360                         g_eam_wo_rec.return_status := l_error_status;
1361 
1362 
1363                         IF l_error_scope = G_SCOPE_ALL OR
1364                            l_error_scope = G_SCOPE_CHILDREN
1365                         THEN
1366                         --
1367                         -- Set all the operation's
1368                         -- status, this will then set the
1369                         -- status of the operation resoources
1370                         -- and substitute operation resoources
1371 
1372                        setOperationSequences
1373                         (  p_other_mesg_text => l_other_message
1374                          , p_other_status    => p_other_status
1375                          , p_error_scope     => G_SCOPE_ALL
1376                         );
1377 
1378                         END IF;
1379                         -- Work Order Header Scope =  ALL or Children Ends
1380 
1381 
1382         --
1383         -- If the Error Level is Operation Networks
1384         --
1385 
1386         ELSIF l_error_level = G_OP_NETWORK_LEVEL
1387         THEN
1388             --
1389             -- Set the Operatin Network record at the current entity_index
1390             -- This will take care of scope = RECORD
1391             --
1392             g_eam_op_network_tbl(p_entity_index).return_status := l_error_status;
1393 
1394             IF l_error_scope = G_SCOPE_ALL
1395             THEN
1396                IF g_eam_op_network_tbl.COUNT <> 0
1397                THEN
1398                   --
1399                   -- Set all the revision record status
1400                   --
1401                   setOpNetworks
1402                   (  p_other_mesg_text => l_other_message
1403                    , p_other_status    => p_other_status
1404                   );
1405                END IF;
1406 
1407                --
1408                -- Set all the operation's
1409                -- status, this will then set the
1410                -- status of the operation resources
1411                -- and substitute operation resources
1412                --
1413                setOperationSequences
1414                (  p_other_mesg_text => l_other_message
1415                 , p_other_status    => p_other_status
1416                 , p_error_scope     => l_error_scope
1417                ) ;
1418 
1419             END IF;
1420 
1421         --
1422         -- If the Error Level is Operation Sequences
1423         --
1424         ELSIF l_error_level = G_OP_LEVEL
1425         THEN
1426 
1427             --
1428             -- Set operation sequence record at the entity_index
1429             -- to error_status
1430             -- This will take care of Scope = RECORD.
1431             --
1432             g_eam_op_tbl(p_entity_index).return_status := l_error_status;
1433 
1434 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Error Level = Operation Sequences . . .'); END IF;
1435 
1436             IF l_error_scope = G_SCOPE_SIBLINGS OR
1437                l_error_scope = G_SCOPE_ALL
1438             THEN
1439                  setOperationSequences
1440                  (  p_other_mesg_text => l_other_message
1441                   , p_other_status    => p_other_status
1442                   , p_error_scope     => G_SCOPE_ALL
1443                   , p_entity_index    => p_entity_index
1444                  ) ;
1445             ELSIF l_error_scope = G_SCOPE_CHILDREN
1446             THEN
1447                 IF g_eam_res_tbl.COUNT <> 0
1448                 THEN
1449                     setOperationResources
1450                     (  p_error_scope     => l_error_scope
1451                      , p_other_status    => p_other_status
1452                      , p_other_mesg_text => l_other_message
1453                      , p_op_idx          => p_entity_index
1454                      );
1455                 END IF;
1456 
1457                 IF g_eam_sub_res_tbl.COUNT <> 0
1458                 THEN
1459                     setSubResources
1460                     (  p_error_scope     => l_error_scope
1461                      , p_other_status    => p_other_status
1462                      , p_other_mesg_text => l_other_message
1463                      , p_op_idx          => p_entity_index
1464                     );
1465                 END IF;
1466 
1467                 IF g_eam_mat_req_tbl.COUNT <> 0
1468                 THEN
1469                    setMaterialRequirements
1470                    (  p_error_scope     => l_error_scope
1471                     , p_other_status    => p_other_status
1472                     , p_other_mesg_text => l_other_message
1473                     , p_op_idx          => p_entity_index
1474                    ) ;
1475                 END IF ;
1476 
1477                 IF g_eam_direct_items_tbl.COUNT <> 0
1478                 THEN
1479                    setDirectItems
1480                    (  p_error_scope     => l_error_scope
1481                     , p_other_status    => p_other_status
1482                     , p_other_mesg_text => l_other_message
1483                     , p_op_idx          => p_entity_index
1484                    ) ;
1485                 END IF ;
1486 
1487             END IF; -- scope = Siblings or All Ends
1488 
1489         --
1490         -- If the Error Level is Operation Resources
1491         --
1492 
1493         ELSIF l_error_level = G_RES_LEVEL
1494         THEN
1498             --
1495             --
1496             -- Set operation resource record status at entity_idx
1497             -- This will take care of Scope = RECORD.
1499 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Error Level = Operation Resource . . .'); END IF;
1500 
1501             g_eam_res_tbl(p_entity_index).return_status := l_error_status;
1502 --            IF l_error_scope <> G_SCOPE_RECORD
1503             IF l_error_scope = G_SCOPE_SIBLINGS OR
1504                l_error_scope = G_SCOPE_ALL
1505             THEN
1506                 setOperationResources
1507                 (  p_error_scope     => l_error_scope
1508                  , p_other_status    => p_other_status
1509                  , p_other_mesg_text => l_other_message
1510                  , p_entity_index    => p_entity_index
1511                 ) ;
1512 
1513 
1514             END IF;
1515 
1516 
1517 
1518         --
1519         -- If the Error Level is Resource Instances
1520         --
1521 
1522         ELSIF l_error_level = G_RES_INST_LEVEL
1523         THEN
1524              -- Set resource instance record status at entity_idx
1525              -- This will take care of Scope = RECORD.
1526              --
1527 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Error Level = Resource Instances . . .'); END IF;
1528 
1529              g_eam_res_inst_tbl(p_entity_index).return_status := l_error_status;
1530 
1531              IF l_error_scope <> G_SCOPE_RECORD
1532              THEN
1533                 setResInstances
1534                 (  p_error_scope     => l_error_scope
1535                  , p_other_status    => p_other_status
1536                  , p_other_mesg_text => l_other_message
1537                  , p_entity_index    => p_entity_index
1538                 ) ;
1539              END IF ;
1540 
1541 
1542         --
1543         -- If the Error Level is Sub Op Resources
1544         --
1545 
1546         ELSIF l_error_level = G_SUB_RES_LEVEL
1547         THEN
1548              -- Set substitute resource record status at entity_idx
1549              -- This will take care of Scope = RECORD.
1550              --
1551 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Error Level = Substitute Op Resources . . .'); END IF;
1552 
1553              g_eam_sub_res_tbl(p_entity_index).return_status := l_error_status;
1554 
1555              IF l_error_scope <> G_SCOPE_RECORD
1556              THEN
1557                 setSubResources
1558                 (  p_error_scope     => l_error_scope
1559                  , p_other_status    => p_other_status
1560                  , p_other_mesg_text => l_other_message
1561                  , p_entity_index    => p_entity_index
1562                 ) ;
1563              END IF ;
1564 
1565 
1566 
1567 
1568         ELSIF l_error_level = G_RES_USAGE_LEVEL
1569         THEN
1570             --
1571             -- Set resource usage record status at entity_idx
1572             -- This will take care of Scope = RECORD.
1573             --
1574 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Error Level = Resource Usage. . .'); END IF;
1575 
1576             g_eam_res_usage_tbl(p_entity_index).return_status := l_error_status;
1577 --            IF l_error_scope <> G_SCOPE_RECORD
1578             IF l_error_scope = G_SCOPE_SIBLINGS OR
1579                l_error_scope = G_SCOPE_ALL
1580             THEN
1581                 setResUsages
1582                 (  p_error_scope     => l_error_scope
1583                  , p_other_status    => p_other_status
1584                  , p_other_mesg_text => l_other_message
1585                  , p_entity_index    => p_entity_index
1586                 ) ;
1587              END IF ;
1588 
1589         --
1590         -- If the Error Level is Material Requirements
1591         --
1592 
1593 
1594 
1595         ELSIF l_error_level = G_MAT_REQ_LEVEL
1596         THEN
1597 
1598 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Error Level = Material Requirements . . .'); END IF;
1599 
1600              g_eam_mat_req_tbl(p_entity_index).return_status := l_error_status;
1601 
1602              IF l_error_scope <> G_SCOPE_RECORD
1603              THEN
1604                 setMaterialRequirements
1605                 (  p_error_scope     => l_error_scope
1606                  , p_other_status    => p_other_status
1607                  , p_other_mesg_text => l_other_message
1608                  , p_entity_index    => p_entity_index
1609                 ) ;
1610              END IF ;
1611 
1612 
1613         --
1614         -- If the Error Level is Direct Items
1615         --
1616 
1617         ELSIF l_error_level = G_DIRECT_ITEMS_LEVEL
1618         THEN
1619 
1620 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Error Level = DIRECT ITEMS . . .'); END IF;
1621 
1622              g_eam_direct_items_tbl(p_entity_index).return_status := l_error_status;
1623 
1624              IF l_error_scope <> G_SCOPE_RECORD
1625              THEN
1626                 setDirectItems
1627                 (  p_error_scope     => l_error_scope
1628                  , p_other_status    => p_other_status
1629                  , p_other_mesg_text => l_other_message
1630                  , p_entity_index    => p_entity_index
1631                 ) ;
1632              END IF ;
1633 
1634         END IF;	*/
1635 
1636         -- Error Level  If Ends.
1637 
1638 
1639 
1640 
1641         --
1642         -- Copy the changed record/Tables to the out parameters for
1643         -- returing to the calling program.
1644         --
1645         x_eam_wo_rec                   := g_eam_wo_rec;
1649         x_eam_res_inst_tbl             := g_eam_res_inst_tbl;
1646         x_eam_op_tbl                   := g_eam_op_tbl;
1647         x_eam_op_network_tbl           := g_eam_op_network_tbl;
1648         x_eam_res_tbl                  := g_eam_res_tbl;
1650         x_eam_sub_res_tbl              := g_eam_sub_res_tbl;
1651         x_eam_res_usage_tbl            := g_eam_res_usage_tbl;
1652         x_eam_mat_req_tbl              := g_eam_mat_req_tbl;
1653         x_eam_direct_items_tbl         := g_eam_direct_items_tbl;
1654 
1655 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('End of Rtg Log Error.'); END IF;
1656 
1657         END Log_Error;
1658 
1659 
1660         /*********************************************************************
1661         * Procedure     : Initialize
1662         * Parameters    : None
1663         * Purpose       : This procedure will initialize the global message
1664         *                 list and reset the index variables to 0.
1665         *                 User must initialize the message list before using
1666         *                 it.
1667         **********************************************************************/
1668         PROCEDURE Initialize
1669         IS
1670         BEGIN
1671 
1672                 G_Error_Table.DELETE;
1673                 G_Msg_Count := 0;
1674                 G_Msg_Index := 0;
1675 
1676                 FND_MSG_PUB.Initialize;
1677 
1678         END Initialize;
1679 
1680         /********************************************************************
1681         * Procedure     : Reset
1682         * Parameters    : None
1683         * Purpose       : Reset will reset the message index to the begining
1684         *                 of the list and the user can start reading the
1685         *                 messages again.
1686         *********************************************************************/
1687         PROCEDURE Reset
1688         IS
1689         BEGIN
1690 
1691                 g_Msg_Index := 0;
1692 
1693         END Reset;
1694 
1695         /********************************************************************
1696         * Procedure     : Get_Message_List
1697         * Parameters    : None
1698         * Purpose       : This procedure will return the entire message
1699         *                 table out NOCOPY the user. The returned list will be
1700         *                 for a particular business object.
1701         *********************************************************************/
1702         PROCEDURE Get_Message_List
1703         ( x_Message_List OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Error_Tbl_Type)
1704         IS
1705                 l_bo_identifier VARCHAR2(3) := EAM_ERROR_MESSAGE_PVT.Get_BO_Identifier;
1706                 l_msg_count     NUMBER := 1;
1707 
1708         BEGIN
1709                 FOR l_err_idx IN 1..G_ERROR_TABLE.COUNT
1710                 LOOP
1711                         IF G_Error_Table(l_err_idx).bo_identifier =
1712                            l_bo_identifier
1713                         THEN
1714                                 x_message_list(l_msg_count) :=
1715                                         G_Error_Table(l_err_idx);
1716                                 l_msg_Count := l_msg_count + 1;
1717                         END IF;
1718                 END LOOP;
1719 
1720         END Get_Message_List;
1721 
1722 
1723         /********************************************************************
1724         * Procedure     : Get_Entity_Message
1725         * Parameters IN : Entity Id
1726         * Parameters OUT NOCOPY: Error List
1727         * Purpose       : This procedure will return all the messages for
1728         *                 a specific Entity.
1729         *********************************************************************/
1730         PROCEDURE Get_Entity_Message
1731         (  p_entity_id  IN  VARCHAR2
1732          , x_Message_List OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Error_Tbl_Type
1733         )
1734         IS
1735                 l_Idx           NUMBER;
1736                 l_Mesg_List     EAM_ERROR_MESSAGE_PVT.Error_Tbl_Type;
1737                 l_Count         NUMBER := 1;
1738                 l_bo_identifier VARCHAR2(3) := EAM_ERROR_MESSAGE_PVT.Get_BO_Identifier;
1739         BEGIN
1740 
1741 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Get Messages for Entity : ' || p_entity_id); END IF;
1742 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Table Size = ' || to_char(G_Msg_Count)); END IF;
1743 
1744                 FOR l_Idx IN 1..NVL(G_Msg_Count, 0)
1745                 LOOP
1746                         IF G_Error_Table(l_idx).entity_id = p_entity_id AND
1747                            G_Error_Table(l_Idx).bo_identifier = l_bo_identifier
1748                         THEN
1749                                 l_mesg_list(l_count) := G_Error_Table(l_Idx);
1750                                 l_Count := l_Count + 1;
1751                         END IF;
1752                 END LOOP;
1753                 x_Message_List := l_Mesg_List;
1754 
1755         END Get_Entity_Message;
1756 
1757         /*********************************************************************
1758         * Procedure     : Get_Entity_Message
1759         * Parameters IN : Entity Id
1760         *                 Entity Index
1761         * Parameters OUT NOCOPY: Message Text
1762         * Purpose       : This procedure will a specific messages for
1763         *                 an entity and its index
1764         *********************************************************************/
1765         PROCEDURE Get_Entity_Message
1766         (  p_entity_id          IN  VARCHAR2
1767          , p_entity_index       IN  NUMBER
1768          , x_message_text       OUT NOCOPY VARCHAR2
1769          )
1770         IS
1771                 l_Idx           NUMBER;
1775         BEGIN
1772                 l_Mesg_List     EAM_ERROR_MESSAGE_PVT.Error_Tbl_Type;
1773                 l_Count         NUMBER;
1774                 l_bo_identifier VARCHAR2(3) := EAM_ERROR_MESSAGE_PVT.Get_BO_Identifier;
1776                 FOR l_Idx IN 1..NVL(G_Msg_Count, 0)
1777                 LOOP
1778                         IF G_Error_Table(l_idx).entity_id = p_entity_id AND
1779                            G_Error_Table(l_idx).entity_index = p_entity_index
1780                            AND
1781                            G_Error_Table(l_idx).bo_identifier = l_bo_identifier
1782                         THEN
1783                                 x_message_text :=
1784                                         G_Error_Table(l_idx).message_text;
1785                         END IF;
1786                 END LOOP;
1787         END Get_Entity_Message;
1788 
1789         /*********************************************************************
1790         * Procedure     : Get_Message
1791         * Parameters    : None
1792         * Purpose       : This procedure will return the message at the current
1793         *                 message index and will advance the pointer to the
1794         *                 next number. If the user tries to retrieve beyond the
1795         *                 the size of the message list, then the message index
1796         *                 will be reset to the begining position.
1797         **********************************************************************/
1798         PROCEDURE Get_Message
1799         (  x_message_text        OUT NOCOPY VARCHAR2
1800          , x_entity_index        OUT NOCOPY NUMBER
1801          , x_entity_id           OUT NOCOPY VARCHAR2
1802          , x_message_type        OUT NOCOPY VARCHAR2
1803          )
1804         IS
1805         BEGIN
1806                 IF G_Msg_Index = G_Msg_Count
1807                 THEN
1808                         G_Msg_Index := 0;
1809                 ELSE
1810                         G_Msg_Index := G_Msg_Index + 1;
1811                         x_message_text :=
1812                                 G_Error_Table(g_Msg_Index).message_text;
1813                         x_entity_id :=
1814                                 G_Error_Table(g_Msg_Index).entity_id;
1815                         x_entity_index :=
1816                                 G_Error_Table(g_Msg_Index).entity_index;
1817                         x_message_type :=
1818                                 G_Error_Table(g_Msg_Index).message_type;
1819                 END IF;
1820 
1821         END Get_Message;
1822 
1823         /********************************************************************
1824         * Procedure     : Delete_Message
1825         * Parameters IN : Entity Id
1826         *                 Entity Index
1827         * Purpose       : This procedure will delete a message for an entity
1828         *                 record.
1829         **********************************************************************/
1830         PROCEDURE Delete_Message
1831         (  p_entity_id          IN  VARCHAR2
1832          , p_entity_index       IN  NUMBER
1833         )
1834         IS
1835                 l_idx   NUMBER;
1836         BEGIN
1837                 FOR l_Idx IN 1..G_Msg_Count
1838                 LOOP
1839                         IF G_Error_Table(l_idx).entity_id = p_entity_id AND
1840                            G_Error_Table(l_idx).entity_index = p_entity_index
1841                         THEN
1842                                G_Error_Table.Delete(l_idx);
1843                                G_Msg_Count := G_Msg_Count - 1;
1844                         END IF;
1845                 END LOOP;
1846         END Delete_Message;
1847 
1848         /********************************************************************
1849         * Procedure     : Delete_Message
1850         * Parameters IN : Entity Id
1851         * Purpose       : This procedure will delete all messages for an entity
1852         **********************************************************************/
1853         PROCEDURE Delete_Message
1854         (  p_entity_id          IN  VARCHAR2 )
1855         IS
1856                 l_idx   NUMBER;
1857         BEGIN
1858                 FOR l_Idx IN 1..G_Msg_Count
1859                 LOOP
1860                         IF G_Error_Table(l_idx).entity_id = p_entity_id
1861                         THEN
1862                                G_Error_Table.Delete(l_idx);
1863                                G_Msg_Count := G_Msg_Count - 1;
1864                         END IF;
1865                 END LOOP;
1866         END Delete_Message;
1867 
1868 
1869 
1870         /* This procedure deletes the last message in the message stack
1871         */
1872         PROCEDURE Delete_Message
1873         IS
1874           l_count NUMBER;
1875         BEGIN
1876                 G_Msg_Count := G_Error_Table.Count;
1877                 G_Error_Table.delete(G_Msg_Count,G_Msg_Count);
1878                 G_Msg_Count := G_Error_Table.Count;
1879         END Delete_Message;
1880 
1881 
1882         /*********************************************************************
1883         * Function      : Get_Message_Count
1884         * Parameters    : None
1885         * Purpose       : Returns the current number of records in the message
1886         *                 list
1887         **********************************************************************/
1888         FUNCTION Get_Message_Count
1889         RETURN NUMBER
1890         IS
1891         BEGIN
1892                 RETURN G_Msg_Count;
1893         END Get_Message_Count;
1894 
1895         /*********************************************************************
1896         * Function      : Dump_Message_List
1897         * Parameters    : None
1898         * Purpose       : Will generate a dump of the message list using
1899         *                 utl_file.
1903                 l_idx   NUMBER;
1900         **********************************************************************/
1901         PROCEDURE Dump_Message_List
1902         IS
1904         BEGIN
1905                 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Dumping Message List :'); END IF;
1906                 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Number of Messages = '|| G_Error_Table.COUNT); END IF;
1907 
1908                 FOR l_idx IN 1..G_Error_Table.COUNT LOOP
1909                         IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Entity Id: ' || G_Error_Table(l_idx).entity_id ); END IF;
1910                         IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Entity Index: ' || to_char(G_Error_Table(l_idx).entity_index)); END IF;
1911                         IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Message: ' || G_Error_Table(l_idx).message_text); END IF;
1912                 END LOOP;
1913 
1914         END Dump_Message_List;
1915 
1916 
1917 /*This procedure is used to open the debug session.But if the file could not be opened or input directory is null
1918   then an error will be returned and the calling procedure will set the debug flag to 'N' and continue.Hence no
1919   error messages will be shown to user but the log messages will not be written in case of an error*/
1920         PROCEDURE Open_Debug_Session
1921         (  p_debug_filename     IN  VARCHAR2
1922          , p_output_dir         IN  VARCHAR2
1923          , p_debug_file_mode    IN  VARCHAR2
1924          , x_return_status      OUT NOCOPY VARCHAR2
1925          , p_mesg_token_tbl     IN  EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
1926          , x_mesg_Token_tbl     OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
1927          )
1928         IS
1929                 l_found NUMBER := 0;
1930                 l_mesg_token_tbl EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type :=
1931                                 p_mesg_token_tbl;
1932                 l_utl_file_dir VARCHAR2(2000);
1933                 l_debug_file_mode VARCHAR2(1) := p_debug_file_mode;
1934         BEGIN
1935                IF(p_output_dir IS NULL) THEN
1936 	              EAM_ERROR_MESSAGE_PVT.Add_Error_Token
1937                         (  p_Message_name       => NULL
1938                          , p_message_text       =>
1939                            ' Debug Session could not be started because the ' ||
1940                            ' output directory name is invalid. '             ||
1941                            ' Output directory must be one of the directory ' ||
1942                            ' value in v$parameter for name = utl_file_dir '  ||
1943                            ' If unsure leave out the value and the log will '||
1944                            ' be written to /sqlcom/log '
1945                          , x_mesg_token_tbl     => l_mesg_token_tbl
1946                          );
1947                         x_return_status := FND_API.G_RET_STS_ERROR;
1948                         x_mesg_token_tbl := l_mesg_token_tbl;
1949                         RETURN;
1950 	       END IF;
1951 
1952 		select  value
1953                   INTO l_utl_file_dir
1954                   FROM v$parameter
1955                  WHERE name = 'utl_file_dir';
1956 
1957                  l_found := INSTR(l_utl_file_dir, p_output_dir);
1958 
1959                 IF l_found = 0
1960                 THEN
1961                         EAM_ERROR_MESSAGE_PVT.Add_Error_Token
1962                         (  p_Message_name       => NULL
1963                          , p_message_text       =>
1964                            ' Debug Session could not be started because the ' ||
1965                            ' output directory name is invalid. '             ||
1966                            ' Output directory must be one of the directory ' ||
1967                            ' value in v$parameter for name = utl_file_dir '  ||
1968                            ' If unsure leave out the value and the log will '||
1969                            ' be written to /sqlcom/log '
1970                          , x_mesg_token_tbl     => l_mesg_token_tbl
1971                          );
1972                         x_return_status := FND_API.G_RET_STS_ERROR;
1973                         x_mesg_token_tbl := l_mesg_token_tbl;
1974                         RETURN;
1975                 END IF;
1976 
1977                 if l_debug_file_mode <> 'w' and
1978                    l_debug_file_mode <> 'W' and
1979                    l_debug_file_mode <> 'a' and
1980                    l_debug_file_mode <> 'A' then
1981                   l_debug_file_mode := 'w';
1982                 end if;
1983 
1984                 EAM_ERROR_MESSAGE_PVT.Debug_File := utl_file.fopen(  p_output_dir
1985                                                            , p_debug_filename
1986                                                            , p_debug_file_mode);
1987 
1988                 x_return_status := FND_API.G_RET_STS_SUCCESS;
1989 
1990                 EXCEPTION
1991                         WHEN UTL_FILE.INVALID_PATH THEN
1992                                 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
1993                                 (  p_message_name       => NULL
1994                                  , p_message_text       => 'Error opening Debug file . . . ' || sqlerrm
1995                                  , x_mesg_token_tbl     => l_mesg_token_tbl
1996                                  );
1997                         x_mesg_token_tbl := l_mesg_token_tbl;
1998 			x_return_status := FND_API.G_RET_STS_ERROR;
1999         END Open_Debug_Session;
2000 
2001         PROCEDURE Write_Debug
2002         (  p_debug_message      IN  VARCHAR2 )
2003         IS
2004         BEGIN
2005                 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y'
2006                 THEN
2007                     utl_file.put_line(EAM_ERROR_MESSAGE_PVT.Debug_File, p_debug_message);
2008 
2009                 END IF;
2013         IS
2010         END Write_Debug;
2011 
2012         PROCEDURE Close_Debug_Session
2014         BEGIN
2015                 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y'
2016                 THEN
2017                   utl_file.fclose(EAM_ERROR_MESSAGE_PVT.Debug_File);
2018                   -- set debug to NO once debug session is closed
2019                   EAM_PROCESS_WO_PVT.Set_Debug('N');
2020                 END IF;
2021         END Close_Debug_Session;
2022 
2023 
2024 	PROCEDURE Set_BO_Identifier(p_bo_identifier        IN VARCHAR)
2025 	IS
2026 	BEGIN
2027 		G_BO_IDENTIFIER := p_bo_identifier;
2028 
2029 	END Set_BO_Identifier;
2030 
2031 	FUNCTION  Get_BO_Identifier RETURN VARCHAR2
2032 	IS
2033 	BEGIN
2034 		RETURN G_BO_IDENTIFIER;
2035 	END Get_BO_Identifier;
2036 
2037 
2038 PROCEDURE Log_Error
2039         (   p_eam_wo_comp_rec         IN  EAM_PROCESS_WO_PUB.eam_wo_comp_rec_type
2040                                      :=EAM_PROCESS_WO_PUB.G_MISS_EAM_COMP_WO_REC
2041      , p_eam_wo_quality_tbl      IN  EAM_PROCESS_WO_PUB.eam_wo_quality_tbl_type
2042                                      :=EAM_PROCESS_WO_PUB.G_MISS_EAM_WO_QUALITY_TBL
2043      , p_eam_meter_reading_tbl   IN  EAM_PROCESS_WO_PUB.eam_meter_reading_tbl_type
2044                                      :=EAM_PROCESS_WO_PUB.G_MISS_EAM_METER_READING_TBL
2045      , p_eam_counter_prop_tbl    IN  EAM_PROCESS_WO_PUB.eam_counter_prop_tbl_type
2046 				     :=EAM_PROCESS_WO_PUB.G_MISS_EAM_COUNTER_PROP_TBL
2047      , p_eam_wo_comp_rebuild_tbl IN  EAM_PROCESS_WO_PUB.eam_wo_comp_rebuild_tbl_type
2048                                      :=EAM_PROCESS_WO_PUB.G_MISS_EAM_WO_COMP_REBUILD_TBL
2049      , p_eam_wo_comp_mr_read_tbl IN  EAM_PROCESS_WO_PUB.eam_wo_comp_mr_read_tbl_type
2050                                      :=EAM_PROCESS_WO_PUB.G_MISS_EAM_WO_COMP_MR_READ_TBL
2051      , p_eam_op_comp_tbl         IN  EAM_PROCESS_WO_PUB.eam_op_comp_tbl_type
2052                                      :=EAM_PROCESS_WO_PUB.G_MISS_EAM_OP_COMP_TBL
2053      , p_eam_request_tbl         IN  EAM_PROCESS_WO_PUB.eam_request_tbl_type
2054                                     :=EAM_PROCESS_WO_PUB.G_MISS_EAM_REQUEST_TBL
2055 
2056      , x_eam_wo_comp_rec            OUT NOCOPY EAM_PROCESS_WO_PUB.eam_wo_comp_rec_type
2057      , x_eam_wo_quality_tbl         OUT NOCOPY EAM_PROCESS_WO_PUB.eam_wo_quality_tbl_type
2058      , x_eam_meter_reading_tbl      OUT NOCOPY EAM_PROCESS_WO_PUB.eam_meter_reading_tbl_type
2059      , x_eam_counter_prop_tbl       OUT NOCOPY EAM_PROCESS_WO_PUB.eam_counter_prop_tbl_type
2060      , x_eam_wo_comp_rebuild_tbl    OUT NOCOPY EAM_PROCESS_WO_PUB.eam_wo_comp_rebuild_tbl_type
2061      , x_eam_wo_comp_mr_read_tbl    OUT NOCOPY EAM_PROCESS_WO_PUB.eam_wo_comp_mr_read_tbl_type
2062      , x_eam_op_comp_tbl            OUT NOCOPY EAM_PROCESS_WO_PUB.eam_op_comp_tbl_type
2063      , x_eam_request_tbl            OUT NOCOPY EAM_PROCESS_WO_PUB.eam_request_tbl_type
2064 
2065      , p_mesg_token_tbl     IN  EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
2066      , p_error_status       IN  VARCHAR2
2067      , p_error_scope        IN  VARCHAR2 := NULL
2068      , p_other_message      IN  VARCHAR2 := NULL
2069      , p_other_mesg_appid   IN  VARCHAR2 := 'EAM'
2070      , p_other_status       IN  VARCHAR2 := NULL
2071      , p_other_token_tbl    IN  EAM_ERROR_MESSAGE_PVT.Token_Tbl_Type
2072                                 := EAM_ERROR_MESSAGE_PVT.G_MISS_TOKEN_TBL
2073      , p_error_level        IN   NUMBER
2074      , p_entity_index       IN   NUMBER := 1  -- := NULL
2075          )
2076         IS
2077                 l_message_name          VARCHAR2(30);
2078                 l_other_message         VARCHAR2(2000);
2079                 l_message_text          VARCHAR2(2000);
2080                 l_LoopIndex             NUMBER;
2081                 l_Error_Level           NUMBER      := p_Error_Level;
2082                 l_error_scope           VARCHAR2(1) := p_error_scope;
2083                 l_error_status          VARCHAR2(1) := p_error_status;
2084                 l_application_id        VARCHAR2(3);
2085 
2086         BEGIN
2087 
2088 	g_eam_wo_comp_rec		:= p_eam_wo_comp_rec;
2089 	g_eam_wo_quality_tbl		:= p_eam_wo_quality_tbl;
2090 	g_eam_meter_reading_tbl		:= p_eam_meter_reading_tbl;
2091 	g_eam_counter_prop_tbl		:= p_eam_counter_prop_tbl;
2092 	g_eam_wo_comp_rebuild_tbl	:= p_eam_wo_comp_rebuild_tbl;
2093 	g_eam_wo_comp_mr_read_tbl	:= p_eam_wo_comp_mr_read_tbl;
2094 	g_eam_op_comp_tbl		:= p_eam_op_comp_tbl;
2095 	g_eam_request_tbl		:= p_eam_request_tbl;
2096 
2097         l_application_id :=  p_other_mesg_appid;
2098 
2099          --
2100          -- Seperate message and their tokens, get the
2101          -- token substituted messages and put it in the
2102          -- Error Table.
2103          --
2104 
2105 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Within the Log Error Procedure . . .'); END IF;
2106 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Scope: ' || l_error_scope); END IF;
2107 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Entity Index: ' || to_char(p_entity_index)); END IF;
2108 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Error Level: ' || to_char(p_error_level)); END IF;
2109 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Error Status: ' || l_error_status); END IF;
2110 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Other Status: ' || p_other_status); END IF;
2111 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Other Message: ' || p_other_message); END IF;
2112 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Business Object: ' || Get_BO_Identifier); END IF;
2113 
2114     EAM_ERROR_MESSAGE_PVT.Translate_And_Insert_Messages
2115                 (  p_mesg_token_Tbl     => p_mesg_token_tbl
2116                  , p_error_level        => p_error_level
2117                  , p_entity_index       => p_entity_index
2118                 );
2122                 -- Get the other message text and token and retrieve the
2119 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Finished logging messages . . . '); END IF;
2120 
2121                 --
2123                 -- token substituted message.
2124 
2125               IF p_other_message is not null THEN
2126                 IF p_other_token_tbl.COUNT <> 0
2127                 THEN
2128                         fnd_message.set_name
2129                         (  application  => l_application_id
2130                          , name         => p_other_message
2131                          );
2132 
2133                         FOR l_LoopIndex IN 1 .. p_other_token_tbl.COUNT
2134                         LOOP
2135                                 IF p_other_token_tbl(l_LoopIndex).token_name IS NOT NULL
2136                                 THEN
2137                                    fnd_message.set_token
2138                                    ( token      => p_other_token_tbl(l_LoopIndex).token_name
2139                                     , value     => p_other_token_tbl(l_LoopIndex).token_value
2140                                     );
2141                                 END IF;
2142                         END LOOP;
2143 
2144                         fnd_msg_pub.add;
2145 
2146                         fnd_message.set_name
2147                         (  application  => l_application_id
2148                          , name         => p_other_message
2149                          );
2150                         FOR l_LoopIndex IN 1 .. p_other_token_tbl.COUNT
2151                         LOOP
2152                                 IF p_other_token_tbl(l_LoopIndex).token_name IS NOT NULL
2153                                 THEN
2154                                    fnd_message.set_token
2155                                    ( token      => p_other_token_tbl(l_LoopIndex).token_name
2156                                     , value     => p_other_token_tbl(l_LoopIndex).token_value
2157                                     , translate => p_other_token_tbl(l_LoopIndex).translate
2158                                     );
2159                                 END IF;
2160                         END LOOP;
2161 
2162                         l_other_message := fnd_message.get;
2163 
2164                 ELSE
2165                         fnd_message.set_name
2166                         (  application  => l_application_id
2167                          , name         => p_other_message
2168                          );
2169 
2170                         fnd_msg_pub.add;
2171 
2172                         fnd_message.set_name
2173                         (  application  => l_application_id
2174                          , name         => p_other_message
2175                          );
2176 
2177                         l_other_message := fnd_message.get;
2178 
2179                 END IF;
2180                 -- Other Token Tbl Count <> 0 Ends
2181                                 Add_Message
2182                                 (  p_mesg_text          => l_other_message
2183                                  , p_entity_id          => p_error_level
2184                                  , p_entity_index       => p_entity_index
2185                                  , p_message_type       => 'E'
2186                                  );
2187                                 l_other_message := NULL;
2188               END IF;
2189 
2190 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Finished extracting other message . . . '); END IF;
2191 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Other Message generated: ' || l_other_message); END IF;
2192 
2193   --
2194                 -- If the Error Level is Business Object
2195                 -- then set the Error Level = WO
2196                 --
2197 
2198                 IF l_error_level = G_BO_LEVEL
2199                 THEN
2200                         l_error_level := G_WO_LEVEL;
2201 
2202 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Error Level is Business Object . . . '); END IF;
2203 
2204                 END IF;
2205 
2206 
2207                 --
2208                 -- If the error_status is UNEXPECTED then set the error scope
2209                 -- to ALL, if WARNING then set the scope to RECORD.
2210                 --
2211 
2212                 IF l_error_status = G_STATUS_UNEXPECTED
2213                 THEN
2214 
2215 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Status unexpected and scope is All . . .'); END IF;
2216 
2217                         l_error_scope := G_SCOPE_ALL;
2218 
2219                 ELSIF l_error_status = G_STATUS_WARNING
2220 
2221                 THEN
2222                         l_error_scope := G_SCOPE_RECORD;
2223                         l_error_status := FND_API.G_RET_STS_SUCCESS;
2224 
2225 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Status is warning . . .'); END IF;
2226 
2227                 END IF;
2228 
2229 	x_eam_wo_comp_rec          := g_eam_wo_comp_rec       ;
2230 	x_eam_wo_quality_tbl       := g_eam_wo_quality_tbl     ;
2231 	x_eam_meter_reading_tbl    := g_eam_meter_reading_tbl   ;
2232 	x_eam_counter_prop_tbl     := g_eam_counter_prop_tbl    ;
2233 	x_eam_wo_comp_rebuild_tbl  := g_eam_wo_comp_rebuild_tbl ;
2234 	x_eam_wo_comp_mr_read_tbl  := g_eam_wo_comp_mr_read_tbl ;
2235 	x_eam_op_comp_tbl          := g_eam_op_comp_tbl         ;
2236 	x_eam_request_tbl          := g_eam_request_tbl         ;
2237 
2238         END Log_Error;
2239 
2240 END EAM_ERROR_MESSAGE_PVT;