DBA Data[Home] [Help]

PACKAGE BODY: APPS.BOM_BO_PVT

Source


1 PACKAGE BODY Bom_Bo_PVT AS
2 /* $Header: BOMVBOMB.pls 120.9 2006/07/03 12:11:01 abbhardw noship $ */
3 --
4 --  Copyright (c) 1996 Oracle Corporation, Redwood Shores, CA, USA
5 --  All rights reserved.
6 --
7 --  FILENAME
8 --
9 --      BOMVBOMB.pls
10 --
11 --  DESCRIPTION
12 --
13 --      Body of package Bom_Bo_Pvt
14 --
15 --  NOTES
16 --
17 --  HISTORY
18 --
19 --  02-AUG-1999 Rahul Chitko  Initial Creation
20 --
21 --  08-MAY-2001 Refai Farook  EAM related changes
22 --
23 --  28-AUG-01   Refai Farook    One To Many support changes
24 --
25 --  05-May-05   Abhishek Rudresh       Common BOM attr updates
26 --
27 --  Global constant holding the package name
28 
29 G_PKG_NAME              CONSTANT VARCHAR2(30) := 'Bom_Bo_PVT';
30 G_EXC_QUIT_IMPORT       EXCEPTION;
31 
32 /* --4306013  */
33 G_SUB_COMP_FLAG   NUMBER :=0;         --4306013
34 G_Comp_Op_Flag    NUMBER :=0;         --4306013
35 G_Ref_Desig_Flag  NUMBER :=0;         --4306013
36 G_Comp_Flag   NUMBER :=0;         --4306013
37 Entity_Name   VARCHAR2(100) := '';      --4306013
38 
39 G_Bill_Seq_Id NUMBER := 0;
40 --Global constant holding the bill_seq_id value for the entity
41 
42 EXC_SEV_QUIT_RECORD     EXCEPTION;
43 EXC_SEV_QUIT_BRANCH     EXCEPTION;
44 EXC_SEV_SKIP_BRANCH     EXCEPTION;
45 EXC_FAT_QUIT_OBJECT     EXCEPTION;
46 EXC_SEV_QUIT_OBJECT EXCEPTION;
47 EXC_UNEXP_SKIP_OBJECT   EXCEPTION;
48 EXC_SEV_QUIT_SIBLINGS   EXCEPTION;
49 EXC_FAT_QUIT_SIBLINGS   EXCEPTION;
50 EXC_FAT_QUIT_BRANCH     EXCEPTION;
51 
52 PROCEDURE Component_Operations
53 (   p_validation_level              IN  NUMBER
54 ,   p_organization_id       IN  NUMBER := NULL
55 ,   p_assembly_item_name      IN  VARCHAR2 := NULL
56 ,   p_alternate_bom_code      IN  VARCHAR2 := NULL
57 ,   p_effectivity_date            IN  DATE := NULL
58 ,   p_component_item_name     IN  VARCHAR2 := NULL
59 ,   p_operation_seq_num       IN  NUMBER := NULL
60 ,   p_bom_comp_ops_tbl              IN  Bom_Bo_Pub.Bom_Comp_Ops_Tbl_Type
61 ,   x_bom_comp_ops_tbl              IN OUT NOCOPY Bom_Bo_Pub.Bom_Comp_Ops_Tbl_Type
62 ,   x_Mesg_Token_Tbl        IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
63 ,   x_return_status       IN OUT NOCOPY VARCHAR2
64 )
65 IS
66 l_Mesg_Token_Tbl        Error_Handler.Mesg_Token_Tbl_Type;
67 l_other_token_tbl       Error_Handler.Token_Tbl_Type;
68 l_other_message         VARCHAR2(2000);
69 l_err_text              VARCHAR2(2000);
70 l_valid     BOOLEAN := TRUE;
71 l_item_parent_exists  BOOLEAN := FALSE;
72 l_comp_parent_exists  BOOLEAN := FALSE;
73 l_Return_Status         VARCHAR2(1);
74 l_bo_return_status      VARCHAR2(1);
75 
76 l_bom_header_rec      Bom_Bo_Pub.Bom_Head_Rec_Type;
77 l_bom_revision_tbl      Bom_Bo_Pub.Bom_Revision_Tbl_Type;
78 l_bom_component_tbl         Bom_Bo_Pub.Bom_Comps_Tbl_Type;
79 l_bom_ref_designator_tbl    Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type;
80 l_bom_sub_component_tbl     Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type;
81 l_bom_comp_ops_tbl          Bom_Bo_Pub.Bom_Comp_Ops_Tbl_Type :=
82           p_bom_comp_ops_tbl;
83 l_bom_comp_ops_rec          Bom_Bo_Pub.Bom_Comp_Ops_Rec_Type;
84 l_bom_comp_ops_unexp_rec    Bom_Bo_Pub.Bom_Comp_Ops_Unexp_Rec_Type;
85 
86 l_old_bom_comp_ops_rec       Bom_Bo_Pub.Bom_Comp_Ops_Rec_Type;
87 l_old_bom_comp_ops_unexp_rec Bom_Bo_Pub.Bom_Comp_Ops_Unexp_Rec_Type;
88 
89 l_return_value          NUMBER;
90 l_Token_Tbl             Error_Handler.Token_Tbl_Type;
91 l_comp_ops_processed    BOOLEAN := FALSE;
92 BEGIN
93 
94     --  Init local table variables.
95 
96     l_return_status := 'S';
97     l_bo_return_status := 'S';
98 
99     l_bom_comp_ops_tbl           := p_bom_comp_ops_tbl;
100 
101     l_bom_comp_ops_unexp_rec.organization_id := Bom_Globals.Get_org_id;
102 
103 
104     FOR I IN 1..l_bom_comp_ops_tbl.COUNT LOOP
105     BEGIN
106 
107         --  Load local records.
108 
109         l_bom_comp_ops_rec := l_bom_comp_ops_tbl(I);
110 
111         l_bom_comp_ops_rec.transaction_type :=
112           UPPER(l_bom_comp_ops_rec.transaction_type);
113 
114         IF p_component_item_name IS NOT NULL AND
115            p_operation_seq_num IS NOT NULL AND
116            p_assembly_item_name IS NOT NULL AND
117            p_effectivity_date IS NOT NULL AND
118            p_organization_id IS NOT NULL
119         THEN
120           -- Inventory Component parent exists
121 
122           l_comp_parent_exists := TRUE;
123 
124         ELSIF p_assembly_item_name IS NOT NULL AND
125            p_organization_id IS NOT NULL
126         THEN
127           -- Assembly item parent exists
128 
129           l_item_parent_exists := TRUE;
130         END IF;
131 
132       -- Process Flow Step 2: Check if record has not yet been processed and
133       -- that it is the child of the parent that called this procedure
134       --
135 
136       IF (l_bom_comp_ops_rec.return_status IS NULL OR
137           l_bom_comp_ops_rec.return_status = FND_API.G_MISS_CHAR)
138          AND
139 
140          -- Did Revised_Components call this procedure, that is,
141          -- if revised comp exists, then is this record a child ?
142 
143      ((l_comp_parent_exists AND
144          (l_bom_comp_ops_rec.assembly_item_name =
145           p_assembly_item_name AND
146           l_bom_comp_ops_unexp_rec.organization_id = p_organization_id
147     AND
148           l_bom_comp_ops_rec.component_item_name =
149     p_component_item_name AND
150           l_bom_comp_ops_rec.operation_sequence_number =
151     p_operation_seq_num
152          )
153        )
154            OR
155            -- Did Bom_Header call this procedure, that is,
156            -- if revised item exists, then is this record a child ?
157 
158        (l_item_parent_exists AND
159          (l_bom_comp_ops_rec.assembly_item_name =
160       p_assembly_item_name AND
161           l_bom_comp_ops_unexp_rec.organization_id =
162       p_organization_id AND
163     l_bom_comp_ops_rec.alternate_bom_code =
164       p_alternate_bom_code
165     )
166         )
167        OR
168            (NOT l_item_parent_exists AND
169         NOT l_comp_parent_exists))
170       THEN
171          l_comp_ops_processed := TRUE;
172          l_return_status := FND_API.G_RET_STS_SUCCESS;
173          l_bom_comp_ops_rec.return_status := FND_API.G_RET_STS_SUCCESS;
174 
175      --
176      -- Check if transaction_type is valid
177      --
178 
179      Bom_Globals.Transaction_Type_Validity
180      (   p_transaction_type => l_bom_comp_ops_rec.transaction_type
181      ,   p_entity   => 'Bom_Comp_Ops'
182      ,   p_entity_id  => l_bom_comp_ops_rec.assembly_item_name
183      ,   x_valid    => l_valid
184      ,   x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
185      );
186 
187      IF NOT l_valid
188      THEN
189                 l_return_status := Error_Handler.G_STATUS_ERROR;
190         RAISE EXC_SEV_QUIT_RECORD;
191      END IF;
192 
193      --
194      -- Process Flow step 4(a): Convert user unique index to unique
195      -- index I
196      --
197      Bom_Val_To_Id.Bom_Comp_Operation_UUI_To_UI
198     ( p_bom_comp_ops_rec => l_bom_comp_ops_rec
199     , p_bom_comp_ops_unexp_rec => l_bom_comp_ops_unexp_rec
200     , x_bom_comp_ops_unexp_rec => l_bom_comp_ops_unexp_rec
201     , x_Mesg_Token_Tbl     => l_Mesg_Token_Tbl
202     , x_Return_Status      => l_return_status
203     );
204 
205      IF l_return_status = Error_Handler.G_STATUS_ERROR
206      THEN
207         RAISE EXC_SEV_QUIT_RECORD;
208      ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
209      THEN
210     l_other_message := 'BOM_COPS_UUI_UNEXP_SKIP';
211     l_other_token_tbl(1).token_name := 'COMPONENT_ITEM_NAME';
212     l_other_token_tbl(1).token_value :=
213       l_bom_comp_ops_rec.component_item_name;
214     l_other_token_tbl(2).token_name := 'OPERATION_SEQUENCE_NUM';
215     l_other_token_tbl(2).token_value :=
216       l_bom_comp_ops_rec.operation_sequence_number;
217     RAISE EXC_UNEXP_SKIP_OBJECT;
218          END IF;
219 
220      --
221      -- Process Flow step 4(b): Convert user unique index to unique
222      -- index II
223      --
224 
225      Bom_Val_To_Id.Bom_Comp_Operation_UUI_To_UI2
226     ( p_bom_comp_ops_rec => l_bom_comp_ops_rec
227     , p_bom_comp_ops_unexp_rec => l_bom_comp_ops_unexp_rec
228     , x_bom_comp_ops_unexp_rec => l_bom_comp_ops_unexp_rec
229     , x_Mesg_Token_Tbl     => l_Mesg_Token_Tbl
230                 , x_other_message      => l_other_message
231                 , x_other_token_tbl    => l_other_token_tbl
232     , x_Return_Status      => l_return_status
233     );
234 
235      IF l_return_status = Error_Handler.G_STATUS_ERROR
236      THEN
237         RAISE EXC_SEV_QUIT_SIBLINGS;
238      ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
239      THEN
240     l_other_message := 'BOM_COPS_UUI_UNEXP_SKIP';
241     l_other_token_tbl(1).token_name := 'COMPONENT_ITEM_NAME';
242     l_other_token_tbl(1).token_value :=
243       l_bom_comp_ops_rec.component_item_name;
244     l_other_token_tbl(2).token_name := 'OPERATION_SEQUENCE_NUM';
245     l_other_token_tbl(2).token_value :=
246       l_bom_comp_ops_rec.operation_sequence_number;
247     RAISE EXC_UNEXP_SKIP_OBJECT;
248          END IF;
249 
250      --
251      -- Process Flow step 5: Verify Component Operation's existence
252      --
253 
254      Bom_Validate_Comp_Operation.Check_Existence
255       (  p_bom_comp_ops_rec   => l_bom_comp_ops_rec
256       ,  p_bom_comp_ops_unexp_rec   => l_bom_comp_ops_unexp_rec
257     ,  x_old_bom_comp_ops_rec => l_old_bom_comp_ops_rec
258                 ,  x_old_bom_comp_ops_unexp_rec => l_old_bom_comp_ops_unexp_rec
259           ,  x_Mesg_Token_Tbl       => l_Mesg_Token_Tbl
260           ,  x_return_status        => l_Return_Status
261       );
262 
263      IF l_return_status = Error_Handler.G_STATUS_ERROR
264      THEN
265         RAISE EXC_SEV_QUIT_RECORD;
266      ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
267      THEN
268     l_other_message := 'BOM_COPS_EXS_UNEXP_SKIP';
269     l_other_token_tbl(1).token_name := 'COMPONENT_ITEM_NAME';
270     l_other_token_tbl(1).token_value :=
271       l_bom_comp_ops_rec.component_item_name;
272     l_other_token_tbl(2).token_name := 'OPERATION_SEQUENCE_NUM';
273     l_other_token_tbl(2).token_value :=
274       l_bom_comp_ops_rec.operation_sequence_number;
275     RAISE EXC_UNEXP_SKIP_OBJECT;
276          END IF;
277 
278            /* Assign the correct transaction type for SYNC operations */
279 
280            IF l_bom_comp_ops_rec.transaction_type = 'SYNC' THEN
281              l_bom_comp_ops_rec.transaction_type :=
282                  l_old_bom_comp_ops_rec.transaction_type;
283            END IF;
284 
285      --
286      -- Process Flow step 6: Is Revised Component record an orphan ?
287      --
288 
289      IF NOT l_comp_parent_exists
290      THEN
291 
292       -- Process Flow step 7: Check lineage
293       --
294            /* Check lineage is not necessary for a component operation */
295 
296          /*   IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Check lineage');     END IF;
297       Bom_Validate_Comp_Operation.Check_Lineage
298       (  p_bom_comp_ops_rec   => l_bom_comp_ops_rec
299       ,  p_bom_comp_ops_unexp_rec   => l_bom_comp_ops_unexp_rec
300           ,  x_Mesg_Token_Tbl       => l_Mesg_Token_Tbl
301           ,  x_return_status        => l_Return_Status
302       );
303 
304       IF l_return_status = Error_Handler.G_STATUS_ERROR
305       THEN
306           RAISE EXC_SEV_QUIT_BRANCH;
307       ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
308       THEN
309       l_other_message := 'BOM_COPS_LIN_UNEXP_SKIP';
310       l_other_token_tbl(1).token_name := 'COMPONENT_ITEM_NAME';
311       l_other_token_tbl(1).token_value :=
312         l_bom_comp_ops_rec.component_item_name;
313       l_other_token_tbl(2).token_name := 'OPERATION_SEQUENCE_NUM';
314       l_other_token_tbl(2).token_value :=
315         l_bom_comp_ops_rec.operation_sequence_number;
316       RAISE EXC_UNEXP_SKIP_OBJECT;
317           END IF;
318                */
319 
320     --
321       -- Process Flow step 8(a and b): check that user has access to
322           -- Assembly item
323       --
324       Bom_Validate_Bom_Header.Check_Access
325     (  p_organization_id=>l_bom_comp_ops_unexp_rec.organization_id
326           ,  p_assembly_item_id=>l_bom_comp_ops_unexp_rec.assembly_item_id
327     ,  p_alternate_bom_code=>
328         l_bom_comp_ops_rec.alternate_bom_code
329     ,  p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
330     ,  x_Mesg_Token_Tbl     => l_Mesg_Token_Tbl
331           ,  x_return_status      => l_Return_Status
332     );
333 
334       IF l_return_status = Error_Handler.G_STATUS_ERROR
335       THEN
336       l_other_message := 'BOM_COPS_RITACC_FAT_FATAL';
337       l_other_token_tbl(1).token_name := 'REVISED_ITEM_NAME';
338       l_other_token_tbl(1).token_value :=
339         l_bom_comp_ops_rec.assembly_item_name;
340       l_other_token_tbl(2).token_name := 'OPERATION_SEQUENCE_NUM';
341       l_other_token_tbl(2).token_value :=
342         l_bom_comp_ops_rec.operation_sequence_number;
343                         l_return_status := 'F';
344       RAISE EXC_FAT_QUIT_SIBLINGS;
345       ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
346       THEN
347       l_other_message := 'BOM_COPS_RITACC_UNEXP_SKIP';
348       l_other_token_tbl(1).token_name := 'REVISED_ITEM_NAME';
349       l_other_token_tbl(1).token_value :=
350         l_bom_comp_ops_rec.assembly_item_name;
351       l_other_token_tbl(2).token_name := 'OPERATION_SEQUENCE_NUM';
352       l_other_token_tbl(2).token_value :=
353         l_bom_comp_ops_rec.operation_sequence_number;
354       RAISE EXC_UNEXP_SKIP_OBJECT;
355           END IF;
356 
357        END IF;  -- Check if Not Compononent Parents Exist Ends
358 
359     --
360     -- Process Flow step:Check that user has access to Bom component
361     --
362 
363     Bom_Validate_Bom_Component.Check_Access
364     (  p_organization_id  =>
365           l_bom_comp_ops_unexp_rec.organization_id
366     ,  p_component_item_id =>
367         l_bom_comp_ops_unexp_rec.component_item_id
368     ,  p_component_name     =>
369         l_bom_comp_ops_rec.component_item_name
370     ,  x_Mesg_Token_Tbl     => l_Mesg_Token_Tbl
371           ,  x_return_status      => l_Return_Status
372     );
373 
374       IF l_return_status = Error_Handler.G_STATUS_ERROR
375       THEN
376       l_other_message := 'BOM_COPS_CMPACC_FAT_FATAL';
377       l_other_token_tbl(1).token_name := 'COMPONENT_ITEM_NAME';
378       l_other_token_tbl(1).token_value :=
379         l_bom_comp_ops_rec.component_item_name;
380       l_other_token_tbl(2).token_name := 'OPERATION_SEQUENCE_NUM';
381       l_other_token_tbl(2).token_value :=
382         l_bom_comp_ops_rec.operation_sequence_number;
383                         l_return_status := 'F';
384           RAISE EXC_FAT_QUIT_SIBLINGS;
385       ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
386       THEN
387       l_other_message := 'BOM_COPS_CMPACC_UNEXP_SKIP';
388       l_other_token_tbl(1).token_name := 'COMPONENT_ITEM_NAME';
389       l_other_token_tbl(1).token_value :=
390         l_bom_comp_ops_rec.component_item_name;
391       l_other_token_tbl(2).token_name := 'OPERATION_SEQUENCE_NUM';
392       l_other_token_tbl(2).token_value :=
393         l_bom_comp_ops_rec.operation_sequence_number;
394       RAISE EXC_UNEXP_SKIP_OBJECT;
395           END IF;
396 
397   --
398       -- Process Flow step 9: Attribute Validation for Create and Update
399       --
400 
401       IF l_bom_comp_ops_rec.transaction_type IN
402         (Bom_Globals.G_OPR_UPDATE, Bom_Globals.G_OPR_CREATE)
403       THEN
404 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Bom Component Operation: Check Attributes . . .'); END IF;
405 
406           Bom_Validate_Comp_Operation.Check_Attributes
407                 (   x_return_status            => l_return_status
408                 ,   x_Mesg_Token_Tbl           => l_Mesg_Token_Tbl
409                 ,   p_bom_comp_ops_rec           => l_bom_comp_ops_rec
410                 ,   p_bom_comp_ops_unexp_rec     => l_bom_comp_ops_unexp_rec
411                 );
412 
413     IF l_return_status = Error_Handler.G_STATUS_ERROR
414     THEN
415             RAISE EXC_SEV_QUIT_RECORD;
416     ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
417     THEN
418       RAISE EXC_UNEXP_SKIP_OBJECT;
419     END IF;
420       END IF;
421 
422             -- Process flow step 10 - Populate NULL columns for Update and
423             -- Delete
424 
425       IF l_bom_comp_ops_rec.transaction_type IN
426     (Bom_Globals.G_OPR_UPDATE, Bom_Globals.G_OPR_DELETE)
427             THEN
428         IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Populate NULL columns'); END IF;
429         Bom_Default_Comp_Operation.Populate_Null_Columns
430                     (   p_bom_comp_ops_rec     => l_bom_Comp_ops_Rec
431                     ,   p_old_bom_Comp_ops_Rec => l_old_bom_Comp_ops_Rec
432                     ,   p_bom_comp_ops_unexp_rec    => l_bom_comp_ops_unexp_rec
433                     ,   p_old_bom_comp_ops_unexp_rec=> l_old_bom_comp_ops_unexp_rec
434                     ,   x_bom_comp_ops_Rec     => l_bom_Comp_ops_Rec
435                     ,   x_bom_comp_ops_unexp_rec    => l_bom_comp_ops_unexp_rec
436                     );
437 
438          ELSIF l_bom_comp_ops_rec.Transaction_Type = Bom_Globals.G_OPR_CREATE
439      THEN
440 
441     --
442           -- Process Flow step 11 : Default missing values for Operation
443     -- CREATE
444     --
445 
446           IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Attribute Defaulting'); END IF;
447           Bom_Default_Comp_Operation.Attribute_Defaulting
448                 (   p_bom_comp_ops_rec    => l_bom_comp_ops_rec
449                 ,   p_bom_comp_ops_unexp_rec  => l_bom_comp_ops_unexp_rec
450                 ,   x_bom_comp_ops_rec    => l_bom_comp_ops_rec
451                 ,   x_bom_comp_ops_unexp_rec  => l_bom_comp_ops_unexp_rec
452                 ,   x_Mesg_Token_Tbl      => l_Mesg_Token_Tbl
453                 ,   x_return_status   => l_return_status
454                 );
455 
456           IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('return_status: ' || l_return_status); END IF;
457 
458     IF l_return_status = Error_Handler.G_STATUS_ERROR
459     THEN
460       l_other_message := 'BOM_COPS_ATTDEF_CSEV_SKIP';
461       l_other_token_tbl(1).token_name := 'COMPONENT_ITEM_NAME';
462       l_other_token_tbl(1).token_value :=
463         l_bom_comp_ops_rec.component_item_name;
464       l_other_token_tbl(2).token_name := 'OPERATION_SEQUENCE_NUM';
465       l_other_token_tbl(2).token_value :=
466         l_bom_comp_ops_rec.operation_sequence_number;
467           RAISE EXC_SEV_SKIP_BRANCH;
468     ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
469     THEN
470       l_other_message := 'BOM_COPS_ATTDEF_UNEXP_SKIP';
471       l_other_token_tbl(1).token_name := 'COMPONENT_ITEM_NAME';
472       l_other_token_tbl(1).token_value :=
473         l_bom_comp_ops_rec.component_item_name;
474       l_other_token_tbl(2).token_name := 'OPERATION_SEQUENCE_NUM';
475       l_other_token_tbl(2).token_value :=
476         l_bom_comp_ops_rec.operation_sequence_number;
477       RAISE EXC_UNEXP_SKIP_OBJECT;
478     END IF;
479      END IF;
480 
481 
482          -- Process Flow step 12- Entity Level Validation
483      --
484 
485          IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Entity validation'); END IF;
486 
487            IF l_bom_comp_ops_rec.transaction_type <> 'DELETE'
488            THEN
489 
490               Bom_Validate_Comp_Operation.Check_Entity
491           (  p_bom_comp_ops_rec     => l_bom_comp_ops_rec
492           ,  p_bom_comp_ops_unexp_rec     => l_bom_comp_ops_unexp_rec
493           ,  x_Mesg_Token_Tbl         => l_Mesg_Token_Tbl
494       ,  x_return_status          => l_Return_Status
495           );
496            END IF ;
497 
498          IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('return_status: ' || l_return_status); END IF;
499 
500      IF l_return_status = Error_Handler.G_STATUS_ERROR
501      THEN
502         RAISE EXC_SEV_QUIT_RECORD;
503      ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
504      THEN
505     l_other_message := 'BOM_COPS_ENTVAL_UNEXP_SKIP';
506     l_other_token_tbl(1).token_name := 'COMPONENT_ITEM_NAME';
507     l_other_token_tbl(1).token_value :=
508       l_bom_comp_ops_rec.component_item_name;
509     l_other_token_tbl(2).token_name := 'OPERATION_SEQUENCE_NUM';
510     l_other_token_tbl(2).token_value :=
511       l_bom_comp_ops_rec.operation_sequence_number;
512     RAISE EXC_UNEXP_SKIP_OBJECT;
513          END IF;
514 
515      --
516          -- Process Flow step 13 : Database Writes
517      --
518 
519          IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Writing to the database'); END IF;
520          Bom_Comp_Operation_Util.Perform_Writes
521           (   p_bom_comp_ops_rec => l_bom_comp_ops_rec
522           ,   p_bom_comp_ops_unexp_rec => l_bom_comp_ops_unexp_rec
523           ,   x_Mesg_Token_Tbl    => l_Mesg_Token_Tbl
524           ,   x_return_status     => l_return_status
525           );
526 
527      IF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
528      THEN
529     l_other_message := 'BOM_COPS_WRITES_UNEXP_SKIP';
530     l_other_token_tbl(1).token_name := 'COMPONENT_ITEM_NAME';
531     l_other_token_tbl(1).token_value :=
532       l_bom_comp_ops_rec.component_item_name;
533     l_other_token_tbl(2).token_name := 'OPERATION_SEQUENCE_NUM';
534     l_other_token_tbl(2).token_value :=
535       l_bom_comp_ops_rec.operation_sequence_number;
536     RAISE EXC_UNEXP_SKIP_OBJECT;
537          END IF;
538 
539         END IF; -- END IF statement that checks RETURN STATUS
540 
541         --  Load tables.
542 
543         l_bom_comp_ops_tbl(I)          := l_bom_comp_ops_rec;
544 
545     --  For loop exception handler.
546 
547     EXCEPTION
548 
549        WHEN EXC_SEV_QUIT_RECORD THEN
550 
551         Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
552 
553   Error_Handler.Log_Error
554     (
555        p_mesg_token_tbl => l_mesg_token_tbl
556     ,  p_error_status => Error_Handler.G_STATUS_ERROR
557     ,  p_error_scope  => Error_Handler.G_SCOPE_RECORD
558     ,  p_error_level  => Error_Handler.G_COP_LEVEL
559     ,  p_entity_index => I
560     ,  x_bom_header_rec => l_bom_header_rec
561     ,  x_bom_revision_tbl => l_bom_revision_tbl
562     ,  x_bom_component_tbl  => l_bom_component_tbl
563     ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
564     ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
565     );
566 
567         Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
568 
569         IF l_bo_return_status = 'S'
570         THEN
571                 l_bo_return_status     := l_return_status;
572         END IF;
573         x_return_status                := l_bo_return_status;
574   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
575       x_bom_comp_ops_tbl            := l_bom_comp_ops_tbl;
576 
577        WHEN EXC_SEV_QUIT_BRANCH THEN
578 
579         Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
580         Error_Handler.Log_Error
581                 (  p_mesg_token_tbl     => l_mesg_token_tbl
582                 ,  p_error_status       => Error_Handler.G_STATUS_ERROR
583                 ,  p_error_scope        => Error_Handler.G_SCOPE_CHILDREN
584                 ,  p_other_status       => Error_Handler.G_STATUS_ERROR
585                 ,  p_other_message      => l_other_message
586                 ,  p_other_token_tbl    => l_other_token_tbl
587                 ,  p_error_level        => Error_Handler.G_COP_LEVEL
588                 ,  p_entity_index       => I
589                 ,  x_bom_header_rec     => l_bom_header_rec
590                 ,  x_bom_revision_tbl   => l_bom_revision_tbl
591                 ,  x_bom_component_tbl  => l_bom_component_tbl
592                 ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
593                 ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
594                 );
595         Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
596 
597         IF l_bo_return_status = 'S'
598         THEN
599                 l_bo_return_status     := l_return_status;
600         END IF;
601         x_return_status                := l_bo_return_status;
602         x_Mesg_Token_Tbl               := l_Mesg_Token_Tbl;
603         x_bom_comp_ops_tbl            := l_bom_comp_ops_tbl;
604 
605        WHEN EXC_SEV_QUIT_SIBLINGS THEN
606         Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
607 
608   Error_Handler.Log_Error
609     (  p_mesg_token_tbl => l_mesg_token_tbl
610     ,  p_error_status => Error_Handler.G_STATUS_ERROR
611     ,  p_error_scope  => Error_Handler.G_SCOPE_SIBLINGS
612     ,  p_other_status => Error_Handler.G_STATUS_ERROR
613     ,  p_other_message  => l_other_message
614     ,  p_other_token_tbl  => l_other_token_tbl
615     ,  p_error_level  => Error_Handler.G_COP_LEVEL
616     ,  p_entity_index => I
617     ,  x_bom_header_rec     => l_bom_header_rec
618     ,  x_bom_revision_tbl => l_bom_revision_tbl
619     ,  x_bom_component_tbl  => l_bom_component_tbl
620     ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
621     ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
622     );
623         Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
624 
625         IF l_bo_return_status = 'S'
626         THEN
627                 l_bo_return_status     := l_return_status;
628         END IF;
629         x_return_status                := l_bo_return_status;
630   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
631       x_bom_comp_ops_tbl            := l_bom_comp_ops_tbl;
632 
633       RETURN;
634 
635        WHEN EXC_FAT_QUIT_SIBLINGS THEN
636         Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
637   Error_Handler.Log_Error
638     (  p_mesg_token_tbl => l_mesg_token_tbl
639     ,  p_error_status => Error_Handler.G_STATUS_FATAL
640     ,  p_error_scope  => Error_Handler.G_SCOPE_SIBLINGS
641     ,  p_other_status       => Error_Handler.G_STATUS_FATAL
642                 ,  p_other_message  => l_other_message
643     ,  p_other_token_tbl  => l_other_token_tbl
644     ,  p_error_level  => Error_Handler.G_COP_LEVEL
645     ,  p_entity_index => I
646     ,  x_bom_header_rec     => l_bom_header_rec
647     ,  x_bom_revision_tbl => l_bom_revision_tbl
648     ,  x_bom_component_tbl  => l_bom_component_tbl
649     ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
650     ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
651     );
652         Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
653 
654         x_return_status                := Error_Handler.G_STATUS_FATAL;
655   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
656       x_bom_comp_ops_tbl            := l_bom_comp_ops_tbl;
657 
658       RETURN;
659 
660        WHEN EXC_FAT_QUIT_OBJECT THEN
661 
662         Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
663   Error_Handler.Log_Error
664     (  p_mesg_token_tbl => l_mesg_token_tbl
665     ,  p_error_status => Error_Handler.G_STATUS_FATAL
666     ,  p_error_scope  => Error_Handler.G_SCOPE_ALL
667     ,  p_other_status       => Error_Handler.G_STATUS_FATAL
668     ,  p_other_message  => l_other_message
669     ,  p_other_token_tbl  => l_other_token_tbl
670     ,  p_error_level  => Error_Handler.G_COP_LEVEL
671     ,  p_entity_index => I
672     ,  x_bom_header_rec     => l_bom_header_rec
673     ,  x_bom_revision_tbl => l_bom_revision_tbl
674     ,  x_bom_component_tbl  => l_bom_component_tbl
675     ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
676     ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
677     );
678         Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
679 
680   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
681       x_bom_comp_ops_tbl            := l_bom_comp_ops_tbl;
682 
683   l_return_status := 'Q';
684 
685        WHEN EXC_UNEXP_SKIP_OBJECT THEN
686         Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
687 
688   Error_Handler.Log_Error
689     (  p_mesg_token_tbl => l_mesg_token_tbl
690     ,  p_error_status => Error_Handler.G_STATUS_UNEXPECTED
691     ,  p_other_status       => Error_Handler.G_STATUS_NOT_PICKED
692                 ,  p_other_message  => l_other_message
693     ,  p_other_token_tbl  => l_other_token_tbl
694     ,  p_error_level  => Error_Handler.G_RD_LEVEL
695     ,  x_bom_header_rec     => l_bom_header_rec
696     ,  x_bom_revision_tbl => l_bom_revision_tbl
697     ,  x_bom_component_tbl  => l_bom_component_tbl
698     ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
699     ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
700     );
701         Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
702 
703       x_bom_comp_ops_tbl            := l_bom_comp_ops_tbl;
704   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
705 
706   l_return_status := 'U';
707 
708      END; -- END block
709 
710       IF l_return_status in ('Q', 'U')
711       THEN
712           x_return_status := l_return_status;
713     RETURN;
714       END IF;
715 
716   --4306013
717   IF( l_bom_comp_ops_tbl(I).transaction_type in ( Bom_Globals.G_OPR_UPDATE, Bom_Globals.G_OPR_CREATE )
718       AND l_return_status = 'S' )
719   THEN
720     G_Comp_Op_Flag := 1;
721   END IF;
722 
723    END LOOP; -- END Component Operations processing loop
724    IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('after end loop');     END IF;
725 
726      /*********Business Event************/
727       IF ( G_Comp_Op_Flag = 1 AND l_comp_ops_processed) THEN
728            Bom_Business_Event_PKG.Raise_Component_Event(
729            p_event_load_type          => 'Bulk'
730            , p_request_identifier      => FND_GLOBAL.CONC_REQUEST_ID
731            , p_batch_identifier        => BOM_GLOBALS.G_BATCH_ID
732            , p_event_entity_name       => 'Component Operation'
733            , p_event_name              => Bom_Business_Event_PKG.G_COMPONENT_MODIFIED_EVENT
734            , p_last_update_date        => sysdate
735            , p_last_updated_by         => fnd_global.user_id
736         );
737        END IF;
738        G_Comp_Op_Flag := 0;
739    /*********Business Event************/
740 
741 
742     --  Load out parameters
743 
744      x_return_status          := l_bo_return_status;
745      x_bom_comp_ops_tbl       := l_bom_comp_ops_tbl;
746      x_Mesg_Token_Tbl     := l_Mesg_Token_Tbl;
747 
748 
749 END Component_Operations;
750 
751 PROCEDURE Substitute_Components
752 (   p_validation_level              IN  NUMBER
753 ,   p_assembly_item_name      IN  VARCHAR2 := NULL
754 ,   p_organization_id       IN  NUMBER := NULL
755 ,   p_alternate_bom_code      IN  VARCHAR2 := NULL
756 ,   p_effectivity_date            IN  DATE := NULL
757 ,   p_component_item_name     IN  VARCHAR2 := NULL
758 ,   p_operation_seq_num       IN  NUMBER := NULL
759 ,   p_bom_sub_component_tbl         IN  Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type
760 ,   x_bom_sub_component_tbl         IN OUT NOCOPY Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type
761 ,   x_Mesg_Token_Tbl        IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
762 ,   x_return_status       IN OUT NOCOPY VARCHAR2
763 )
764 IS
765 l_Mesg_Token_Tbl            Error_Handler.Mesg_Token_Tbl_Type;
766 l_other_token_tbl           Error_Handler.Token_Tbl_Type;
767 l_other_message             VARCHAR2(2000);
768 l_err_text                  VARCHAR2(2000);
769 l_valid         BOOLEAN := TRUE;
770 l_item_parent_exists      BOOLEAN := FALSE;
771 l_comp_parent_exists      BOOLEAN := FALSE;
772 l_Return_Status             VARCHAR2(1);
773 l_bo_return_status      VARCHAR2(1);
774 l_bom_header_rec      Bom_Bo_Pub.Bom_Head_Rec_Type;
775 l_bom_revision_tbl      Bom_Bo_Pub.Bom_Revision_Tbl_Type;
776 l_bom_component_tbl         Bom_Bo_Pub.Bom_Comps_Tbl_Type;
777 l_bom_ref_designator_tbl    Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type;
778 l_bom_sub_component_rec     Bom_Bo_Pub.Bom_Sub_Component_Rec_Type;
779 l_bom_sub_component_tbl     Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type
780         := p_bom_sub_component_tbl;
781 l_old_bom_sub_component_rec Bom_Bo_Pub.Bom_Sub_Component_Rec_Type;
782 l_bom_sub_comp_unexp_rec    Bom_Bo_Pub.Bom_Sub_Comp_Unexp_Rec_Type;
783 l_old_bom_sub_comp_unexp_rec Bom_Bo_Pub.Bom_Sub_Comp_Unexp_Rec_Type;
784 l_return_value              NUMBER;
785 l_Token_Tbl                 Error_Handler.Token_Tbl_Type;
786 l_sub_comp_processed        BOOLEAN := FALSE;
787 BEGIN
788 
789     l_return_status := 'S';
790     l_bo_return_status := 'S';
791 
792     l_comp_parent_exists := FALSE;
793     l_item_parent_exists := FALSE;
794 
795     --  Init local table variables.
796 
797     l_bom_sub_component_tbl            := p_bom_sub_component_tbl;
798 
799     l_bom_sub_comp_unexp_rec.organization_id := Bom_Globals.Get_org_id;
800 
801 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Within Substitute Components . . . will process records: ' || l_bom_sub_component_tbl.COUNT); END IF;
802 
803 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Input parameters '); END IF;
804 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Assembly : ' || p_assembly_item_name);
805 END IF;
806 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Organization: ' || p_organization_id);END IF;
807 
808 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Alternate: ' || p_alternate_bom_code);END IF;
809 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Component: ' || p_component_item_name);END IF;
810 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Op Seq: ' || p_operation_seq_num); END IF;
811 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Eff Dt: ' || to_char(p_effectivity_date)); END IF;
812 
813     FOR I IN 1..l_bom_sub_component_tbl.COUNT LOOP
814     BEGIN
815 
816   --  Load local records.
817 
818         l_bom_sub_component_rec := l_bom_sub_component_tbl(I);
819   l_bom_sub_comp_unexp_rec := Bom_Bo_Pub.G_MISS_BOM_SUB_COMP_UNEXP_REC;
820   l_bom_sub_comp_unexp_rec.organization_id := Bom_Globals.Get_org_id;
821 
822 
823 IF Bom_Globals.Get_Debug = 'Y' THEN
824   Error_Handler.Write_Debug('Substitute Component Record values:');
825   Error_Handler.Write_Debug('Component Item Name: ' || l_bom_sub_component_rec.component_item_name);
826   Error_Handler.Write_Debug('Op Seq Num: ' || l_bom_sub_component_rec.operation_sequence_number);
827   Error_Handler.Write_Debug('Effectivity Date: ' || l_bom_sub_component_rec.start_effective_date);
828   Error_Handler.Write_Debug('Organization Id: ' || l_bom_sub_comp_unexp_rec.organization_id);
829 END IF;
830 
831         l_bom_sub_component_rec.transaction_type :=
832           UPPER(l_bom_sub_component_rec.transaction_type);
833 
834   IF p_component_item_name IS NOT NULL AND
835            p_operation_seq_num IS NOT NULL AND
836            p_effectivity_date IS NOT NULL AND
837            p_organization_id IS NOT NULL
838         THEN
839           -- revised comp parent exists
840 
841     l_comp_parent_exists := TRUE;
842 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Sub Comps called by Component . . .'); END IF;
843 
844   ELSIF p_assembly_item_name IS NOT NULL AND
845               p_organization_id IS NOT NULL
846         THEN
847           -- revised item parent exists
848 
849     l_item_parent_exists := TRUE;
850 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Sub Comps called by Header. . .'); END IF;
851 
852         END IF;
853 
854   -- Process Flow Step 2: Check if record has not yet been processed and
855       -- that it is the child of the parent that called this procedure
856       --
857 
858 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Sub Comp Status prior to start of processing: ' || l_bom_sub_component_rec.return_status);
859 END IF;
860 
861       IF ( l_bom_sub_component_rec.return_status IS NULL OR
862            l_bom_sub_component_rec.return_status = FND_API.G_MISS_CHAR
863       )
864            AND
865           -- Did Bom_Components call this procedure ?
866           -- i.e. if Bom comp exists, then is this record a child ?
867      ((l_comp_parent_exists AND
868          (l_bom_sub_component_rec.component_item_name =
869         p_component_item_name AND
870           l_bom_sub_comp_unexp_rec.organization_id =
871         p_organization_id AND
872           l_bom_sub_component_rec.start_effective_date =
873         p_effectivity_date AND
874           l_bom_sub_component_rec.operation_sequence_number =
875         p_operation_seq_num
876     )
877         )
878             OR
879             -- Did Bom Header call this procedure, that is,
880             -- is this record an indirect child ?
881         (l_item_parent_exists AND
882            (  l_bom_sub_component_rec.assembly_item_name =
883             p_assembly_item_name AND
884               l_bom_sub_comp_unexp_rec.organization_id =
885             p_organization_id AND
886               NVL(l_bom_sub_component_rec.alternate_bom_code, 'NONE') =
887             NVL(p_alternate_bom_code, 'NONE')
888             )
889          )
890          OR
891          (  NOT l_comp_parent_exists AND
892             NOT l_item_parent_exists
893           )
894        )
895       THEN
896          l_sub_comp_processed   := TRUE;
897          l_return_status := FND_API.G_RET_STS_SUCCESS;
898 
899            l_bom_sub_component_rec.return_status := FND_API.G_RET_STS_SUCCESS;
900 
901      --
902      -- Check if transaction_type is valid
903      --
904 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Sub Comps: Transaction Type Validity . . .'); END IF;
905      Bom_Globals.Transaction_Type_Validity
906      (   p_transaction_type => l_bom_sub_component_rec.transaction_type
907      ,   p_entity   => 'Sub_Comps'
908      ,   p_entity_id  => l_bom_sub_component_rec.assembly_item_name
909      ,   x_valid    => l_valid
910      ,   x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
911      );
912 
913      IF NOT l_valid
914      THEN
915                 l_return_status := Error_Handler.G_STATUS_ERROR;
916         RAISE EXC_SEV_QUIT_RECORD;
917      END IF;
918 
919      --
920      -- Process Flow step 4(a): Convert user unique index to unique
921      -- index I
922      --
923      --
924 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Sub Comps: UUI-UI Conversion . . .'); END IF;
925 
926      Bom_Val_To_Id.Sub_Component_UUI_To_UI
927     ( p_bom_sub_component_rec  => l_bom_sub_component_rec
928     , p_bom_sub_comp_unexp_rec => l_bom_sub_comp_unexp_rec
929     , x_bom_sub_comp_unexp_rec => l_bom_sub_comp_unexp_rec
930     , x_Mesg_Token_Tbl     => l_Mesg_Token_Tbl
931     , x_Return_Status      => l_return_status
932     );
933 
934          IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('return_status: ' || l_return_status); END IF;
935 
936      IF l_return_status = Error_Handler.G_STATUS_ERROR
937      THEN
938         RAISE EXC_SEV_QUIT_RECORD;
939      ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
940      THEN
941     l_other_message := 'BOM_SBC_UUI_UNEXP_SKIP';
942     l_other_token_tbl(1).token_name := 'SUBSTITUTE_ITEM_NAME';
943     l_other_token_tbl(1).token_value :=
944       l_bom_sub_component_rec.substitute_component_name;
945     RAISE EXC_UNEXP_SKIP_OBJECT;
946          END IF;
947 
948      --
949      -- Process Flow step 4(b): Convert user unique index to unique
950      -- index II
951      --
952 
953      Bom_Val_To_Id.Sub_Component_UUI_To_UI2
954     ( p_bom_sub_component_rec  => l_bom_sub_component_rec
955     , p_bom_sub_comp_unexp_rec => l_bom_sub_comp_unexp_rec
956     , x_bom_sub_comp_unexp_rec => l_bom_sub_comp_unexp_rec
957     , x_Mesg_Token_Tbl     => l_Mesg_Token_Tbl
958     , x_other_message      => l_other_message
959     , x_other_token_tbl    => l_other_token_tbl
960     , x_Return_Status      => l_return_status
961     );
962 
963      IF l_return_status = Error_Handler.G_STATUS_ERROR
964      THEN
965         RAISE EXC_SEV_QUIT_SIBLINGS;
966      ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
967      THEN
968     l_other_message := 'BOM_SBC_UUI_UNEXP_SKIP';
969     l_other_token_tbl(1).token_name := 'SUBSTITUTE_ITEM_NAME';
970     l_other_token_tbl(1).token_value :=
971       l_bom_sub_component_rec.substitute_component_name;
972     RAISE EXC_UNEXP_SKIP_OBJECT;
973          END IF;
974 
975      Error_Handler.Write_Debug ('SCOMP: Transaction type before SYNC is '||l_bom_sub_component_rec.transaction_type);
976 
977      --
978      -- Process Flow step 5: Verify Substitute Component's existence
979      --
980 
981      Bom_Validate_Sub_Component.Check_Existence
982       (  p_bom_sub_component_rec    => l_bom_sub_component_rec
983       ,  p_bom_sub_comp_unexp_rec   => l_bom_sub_comp_unexp_rec
984     ,  x_old_bom_sub_component_rec  => l_old_bom_sub_component_rec
985                 ,  x_old_bom_sub_comp_unexp_rec => l_old_bom_sub_comp_unexp_rec
986           ,  x_Mesg_Token_Tbl       => l_Mesg_Token_Tbl
987           ,  x_return_status        => l_Return_Status
988       );
989 
990      IF l_return_status = Error_Handler.G_STATUS_ERROR
991      THEN
992         RAISE EXC_SEV_QUIT_RECORD;
993      ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
994      THEN
995     l_other_message := 'BOM_SBC_EXS_UNEXP_SKIP';
996     l_other_token_tbl(1).token_name := 'SUBSTITUTE_ITEM_NAME';
997     l_other_token_tbl(1).token_value :=
998       l_bom_sub_component_rec.substitute_component_name;
999     l_other_token_tbl(2).token_name := 'REVISED_COMPONENT_NAME';
1000     l_other_token_tbl(2).token_value :=
1001         l_bom_sub_component_rec.component_item_name;
1002     RAISE EXC_UNEXP_SKIP_OBJECT;
1003          END IF;
1004 
1005      Error_Handler.Write_Debug ('SCOMP: Transaction type After check exist '||l_bom_sub_component_rec.transaction_type);
1006            /* Assign the correct transaction type for SYNC operations */
1007 
1008            IF l_bom_sub_component_rec.transaction_type = 'SYNC' THEN
1009              l_bom_sub_component_rec.transaction_type :=
1010                  l_old_bom_sub_component_rec.transaction_type;
1011            END IF;
1012      Error_Handler.Write_Debug ('SCOMP: Transaction type after SYNC is '||l_bom_sub_component_rec.transaction_type);
1013      -- Process Flow step 7: Is Subsitute Component record an orphan ?
1014 
1015      IF NOT l_comp_parent_exists
1016      THEN
1017 
1018     --
1019       -- Process Flow step 6: Check lineage
1020       --
1021 
1022       Bom_Validate_Sub_Component.Check_Lineage
1023       (  p_bom_sub_component_rec    => l_bom_sub_component_rec
1024       ,  p_bom_sub_comp_unexp_rec   => l_bom_sub_comp_unexp_rec
1025           ,  x_Mesg_Token_Tbl       => l_Mesg_Token_Tbl
1026           ,  x_return_status        => l_Return_Status
1027       );
1028 
1029       IF l_return_status = Error_Handler.G_STATUS_ERROR
1030       THEN
1031           RAISE EXC_SEV_QUIT_BRANCH;
1032       ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
1033       THEN
1034       l_other_message := 'BOM_SBC_LIN_UNEXP_SKIP';
1035       l_other_token_tbl(1).token_name :=
1036         'SUBSTITUTE_ITEM_NAME';
1037       l_other_token_tbl(1).token_value :=
1038       l_bom_sub_component_rec.substitute_component_name;
1039       RAISE EXC_UNEXP_SKIP_OBJECT;
1040           END IF;
1041 
1042     --
1043     -- Process Flow Step: 6a - Check Assembly Item Accessibility
1044     --
1045       Bom_Validate_Bom_Header.Check_Access
1046     (  p_organization_id =>l_bom_sub_comp_unexp_rec.organization_id
1047           ,  p_assembly_item_id=>l_bom_sub_comp_unexp_rec.assembly_item_id
1048     ,  p_alternate_bom_code=>
1049         l_bom_sub_component_rec.alternate_bom_code
1050     ,  x_Mesg_Token_Tbl     => l_Mesg_Token_Tbl
1051           ,  x_return_status      => l_Return_Status
1052     );
1053 
1054       IF l_return_status = Error_Handler.G_STATUS_ERROR
1055       THEN
1056       l_other_message := 'BOM_SBC_RITACC_FAT_FATAL';
1057       l_other_token_tbl(1).token_name :=
1058           'SUBSTITUTE_ITEM_NAME';
1059       l_other_token_tbl(1).token_value :=
1060           l_bom_sub_component_rec.substitute_component_name;
1061                         l_return_status := 'F';
1062       RAISE EXC_FAT_QUIT_SIBLINGS;
1063       ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
1064       THEN
1065       l_other_message := 'BOM_SBC_RITACC_UNEXP_SKIP';
1066       l_other_token_tbl(1).token_name :=
1067           'SUBSTITUTE_ITEM_NAME';
1068       l_other_token_tbl(1).token_value :=
1069       l_bom_sub_component_rec.substitute_component_name;
1070       RAISE EXC_UNEXP_SKIP_OBJECT;
1071           END IF;
1072 
1073     --
1074     -- Process Flow step 6b: Check that user has access to revised
1075     -- component
1076     --
1077 
1078     Bom_Validate_Bom_Component.Check_Access
1079     (  p_organization_id  =>
1080         l_bom_sub_comp_unexp_rec.organization_id
1081     ,  p_component_item_id  =>
1082         l_bom_sub_comp_unexp_rec.component_item_id
1083     ,  p_component_name     =>
1084         l_bom_sub_component_rec.component_item_name
1085     ,  x_Mesg_Token_Tbl     => l_Mesg_Token_Tbl
1086           ,  x_return_status      => l_Return_Status
1087     );
1088 
1089       IF l_return_status = Error_Handler.G_STATUS_ERROR
1090       THEN
1091       l_other_message := 'BOM_SBC_CMPACC_FAT_FATAL';
1092       l_other_token_tbl(1).token_name :=
1093             'SUBSTITUTE_ITEM_NAME';
1094       l_other_token_tbl(1).token_value :=
1095       l_bom_sub_component_rec.substitute_component_name;
1096       l_other_token_tbl(2).token_name :=
1097             'REVISED_COMPONENT_NAME';
1098       l_other_token_tbl(2).token_value :=
1099       l_bom_sub_component_rec.component_item_name;
1100                         l_return_status := 'F';
1101           RAISE EXC_FAT_QUIT_SIBLINGS;
1102       ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
1103       THEN
1104       l_other_message := 'BOM_SBC_CMPACC_UNEXP_SKIP';
1105       l_other_token_tbl(1).token_name :=
1106             'SUBSTITUTE_ITEM_NAME';
1107       l_other_token_tbl(1).token_value :=
1108       l_bom_sub_component_rec.substitute_component_name;
1109       l_other_token_tbl(2).token_name :=
1110             'REVISED_COMPONENT_NAME';
1111                         l_other_token_tbl(2).token_value :=
1112         l_bom_sub_component_rec.component_item_name;
1113       RAISE EXC_UNEXP_SKIP_OBJECT;
1114           END IF;
1115 
1116     --
1117     -- Process Flow step 7: Does user have access to substitute
1118     -- component ?
1119     --
1120 
1121     Bom_Validate_Sub_Component.Check_Access
1122     (  p_bom_sub_component_rec => l_bom_sub_component_rec
1123     ,  p_bom_sub_comp_unexp_rec => l_bom_sub_comp_unexp_rec
1124     ,  x_Mesg_Token_Tbl     => l_Mesg_Token_Tbl
1125           ,  x_return_status      => l_Return_Status
1126     );
1127 
1128       IF l_return_status = Error_Handler.G_STATUS_ERROR
1129       THEN
1130       l_other_message := 'BOM_SBC_ACCESS_FAT_FATAL';
1131       l_other_token_tbl(1).token_name :=
1132             'SUBSTITUTE_ITEM_NAME';
1133       l_other_token_tbl(1).token_value :=
1134       l_bom_sub_component_rec.substitute_component_name;
1135                         l_return_status := 'F';
1136           RAISE EXC_FAT_QUIT_BRANCH;
1137       ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
1138       THEN
1139       l_other_message := 'BOM_SBC_ACCESS_UNEXP_SKIP';
1140       l_other_token_tbl(1).token_name :=
1141           'SUBSTITUTE_ITEM_NAME';
1142       l_other_token_tbl(1).token_value :=
1143       l_bom_sub_component_rec.substitute_component_name;
1144       RAISE EXC_UNEXP_SKIP_OBJECT;
1145           END IF;
1146 
1147      END IF;
1148 
1149   --
1150       -- Process Flow step 8: Attribute Validation for Create and Update
1151       --
1152 
1153       IF l_bom_sub_component_rec.transaction_type IN
1154         (Bom_Globals.G_OPR_UPDATE, Bom_Globals.G_OPR_CREATE)
1155       THEN
1156     IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Bom Substitute Component: Check Attributes . . .'); END IF;
1157 
1158           Bom_Validate_Sub_Component.Check_Attributes
1159           (  p_bom_sub_component_rec      => l_bom_sub_component_rec
1160           ,  p_bom_sub_comp_unexp_rec     => l_bom_sub_comp_unexp_rec
1161           ,  x_Mesg_Token_Tbl         => l_Mesg_Token_Tbl
1162       ,  x_return_status          => l_Return_Status
1163           );
1164 
1165     IF l_return_status = Error_Handler.G_STATUS_ERROR
1166     THEN
1167             RAISE EXC_SEV_QUIT_RECORD;
1168     ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
1169     THEN
1170       RAISE EXC_UNEXP_SKIP_OBJECT;
1171     END IF;
1172       END IF;
1173 
1174      -- peform Populate_null_columns if the Transaction Type is
1175      -- not INSERT.
1176 
1177      IF l_bom_sub_component_rec.Transaction_Type IN
1178             (Bom_Globals.G_OPR_UPDATE, Bom_Globals.G_OPR_DELETE)
1179          THEN
1180 
1181           -- Process flow step 8  - Populate NULL columns for Update and
1182           -- Delete.
1183 
1184           IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Populating NULL Columns'); END IF;
1185 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Comp Seq: ' || l_bom_sub_comp_unexp_rec.component_sequence_id); END IF;
1186 
1187     Bom_Default_Sub_Component.Populate_NULL_Columns
1188                 (   p_bom_sub_component_rec   => l_bom_sub_component_rec
1189                 ,   p_old_bom_sub_component_rec => l_old_bom_sub_component_rec
1190                 ,   p_bom_sub_comp_unexp_rec  => l_bom_sub_comp_unexp_rec
1191                 ,   p_old_bom_sub_comp_unexp_rec=> l_old_bom_sub_comp_unexp_rec
1192                 ,   x_bom_sub_component_rec   => l_bom_sub_component_rec
1193                 ,   x_bom_sub_comp_unexp_rec  => l_bom_sub_comp_unexp_rec
1194                 );
1195 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Comp Seq after populate: ' || l_bom_sub_comp_unexp_rec.component_sequence_id); END IF;
1196 
1197 
1198          ELSIF l_bom_sub_component_rec.Transaction_Type =
1199           Bom_Globals.G_OPR_CREATE
1200      THEN
1201 
1202     --
1203           -- Process Flow step 9: Default missing values for Operation
1204     -- CREATE
1205     --
1206 
1207           IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Sub Comps: Attribute Defaulting, comp seq: '|| l_bom_sub_comp_unexp_rec.component_sequence_id); END IF;
1208           Bom_Default_Sub_Component.Attribute_Defaulting
1209                 (   p_bom_sub_component_rec   => l_bom_sub_component_rec
1210                 ,   p_bom_sub_comp_unexp_rec  => l_bom_sub_comp_unexp_rec
1211                 ,   x_bom_sub_component_rec   => l_bom_sub_component_rec
1212                 ,   x_bom_sub_comp_unexp_rec  => l_bom_sub_comp_unexp_rec
1213                 ,   x_Mesg_Token_Tbl      => l_Mesg_Token_Tbl
1214                 ,   x_return_status   => l_return_status
1215                 );
1216 
1217 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Sub Comps: Comp Seq after defaulting ' || l_bom_sub_comp_unexp_rec.component_sequence_id); END IF;
1218 
1219     IF l_return_status = Error_Handler.G_STATUS_ERROR
1220     THEN
1221           RAISE EXC_SEV_QUIT_RECORD;
1222     ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
1223     THEN
1224       l_other_message := 'BOM_SBC_ATTDEF_UNEXP_SKIP';
1225       l_other_token_tbl(1).token_name :=
1226           'SUBSTITUTE_ITEM_NAME';
1227       l_other_token_tbl(1).token_value :=
1228       l_bom_sub_component_rec.substitute_component_name;
1229       RAISE EXC_UNEXP_SKIP_OBJECT;
1230     END IF;
1231 
1232      END IF; -- Process flow step 8 Ends
1233 
1234      --
1235          -- Process Flow step 9 - Entity Level Validation
1236      --
1237          Bom_Validate_Sub_Component.Check_Entity
1238           (  p_bom_sub_component_rec      => l_bom_sub_component_rec
1239           ,  p_bom_sub_comp_unexp_rec     => l_bom_sub_comp_unexp_rec
1240           ,  x_Mesg_Token_Tbl         => l_Mesg_Token_Tbl
1241       ,  x_return_status          => l_Return_Status
1242           );
1243 
1244          IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('return_status: ' || l_return_status); END IF;
1245 
1246      IF l_return_status = Error_Handler.G_STATUS_ERROR
1247      THEN
1248         RAISE EXC_SEV_QUIT_RECORD;
1249      ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
1250      THEN
1251     l_other_message := 'BOM_SBC_ENTVAL_UNEXP_SKIP';
1252     l_other_token_tbl(1).token_name := 'SUBSTITUTE_ITEM_NAME';
1253     l_other_token_tbl(1).token_value :=
1254       l_bom_sub_component_rec.substitute_component_name;
1255     RAISE EXC_UNEXP_SKIP_OBJECT;
1256          END IF;
1257 
1258            --
1259          -- Process Flow step 10 : Database Writes
1260      --
1261 
1262 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Sub Comps: Performing Database write...'); END IF;
1263 
1264          Bom_Sub_Component_Util.Perform_Writes
1265           (   p_bom_sub_component_rec   => l_bom_sub_component_rec
1266           ,   p_bom_sub_comp_unexp_rec  => l_bom_sub_comp_unexp_rec
1267           ,   x_Mesg_Token_Tbl          => l_Mesg_Token_Tbl
1268           ,   x_return_status           => l_return_status
1269           );
1270 
1271      IF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
1272      THEN
1273     l_other_message := 'BOM_SBC_WRITES_UNEXP_SKIP';
1274     l_other_token_tbl(1).token_name := 'SUBSTITUTE_ITEM_NAME';
1275     l_other_token_tbl(1).token_value :=
1276       l_bom_sub_component_rec.substitute_component_name;
1277     RAISE EXC_UNEXP_SKIP_OBJECT;
1278          END IF;
1279 
1280         END IF; -- END IF statement that checks RETURN STATUS
1281 
1282         --  Load tables.
1283 
1284   --l_bom_sub_component_rec.return_status := l_return_status;
1285 
1286         l_bom_sub_component_tbl(I)          := l_bom_sub_component_rec;
1287 
1288         IF( l_bom_sub_component_tbl(I).transaction_type in ( Bom_Globals.G_OPR_UPDATE, Bom_Globals.G_OPR_CREATE )
1289         AND l_return_status = 'S')
1290         THEN
1291           G_SUB_COMP_FLAG := 1;
1292         END IF;
1293 
1294         x_return_status := l_return_status;
1295 
1296     --  For loop exception handler.
1297 
1298 
1299     EXCEPTION
1300 
1301        WHEN EXC_SEV_QUIT_RECORD THEN
1302 
1303     Error_Handler.Log_Error
1304     (  p_bom_sub_component_tbl => l_bom_sub_component_tbl
1305            , p_Mesg_Token_tbl => l_mesg_token_tbl
1306            , p_error_status => Error_Handler.G_STATUS_ERROR
1307            , p_error_scope  => Error_Handler.G_SCOPE_RECORD
1308            , p_error_level  => Error_Handler.G_SC_LEVEL
1309            , p_entity_index => I
1310            , x_bom_header_rec => l_bom_header_rec
1311            , x_bom_revision_tbl => l_bom_revision_tbl
1312            , x_bom_component_tbl  => l_bom_component_tbl
1313            , x_bom_ref_Designator_tbl => l_bom_ref_designator_tbl
1314            , x_bom_sub_component_tbl  => l_bom_sub_component_tbl
1315            );
1316         IF l_bo_return_status = 'S'
1317         THEN
1318                 l_bo_return_status     := l_return_status;
1319         END IF;
1320         x_return_status                := l_bo_return_status;
1321   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
1322       x_bom_sub_component_tbl            := l_bom_sub_component_tbl;
1323 
1324        WHEN EXC_SEV_QUIT_BRANCH THEN
1325 
1326           Error_Handler.Log_Error
1327                 (  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
1328                 ,  p_mesg_token_tbl     => l_mesg_token_tbl
1329                 ,  p_error_status       => Error_Handler.G_STATUS_ERROR
1330                 ,  p_error_scope        => Error_Handler.G_SCOPE_CHILDREN
1331                 ,  p_other_status       => Error_Handler.G_STATUS_ERROR
1332                 ,  p_other_message      => l_other_message
1333                 ,  p_other_token_tbl    => l_other_token_tbl
1334                 ,  p_error_level        => Error_Handler.G_SC_LEVEL
1335                 ,  p_entity_index       => I
1336                 ,  x_bom_header_rec     => l_bom_header_rec
1337                 ,  x_bom_revision_tbl   => l_bom_revision_tbl
1338                 ,  x_bom_component_tbl  => l_bom_component_tbl
1339                 ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
1340                 ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
1341                 );
1342 
1343         IF l_bo_return_status = 'S'
1344         THEN
1345                 l_bo_return_status     := l_return_status;
1346         END IF;
1347         x_return_status                := l_bo_return_status;
1348         x_Mesg_Token_Tbl               := l_Mesg_Token_Tbl;
1349         x_bom_sub_component_tbl            := l_bom_sub_component_tbl;
1350 
1351        WHEN EXC_SEV_QUIT_SIBLINGS THEN
1352 
1353     Error_Handler.Log_Error
1354     (  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
1355     ,  p_mesg_token_tbl => l_mesg_token_tbl
1356     ,  p_error_status => Error_Handler.G_STATUS_ERROR
1357     ,  p_error_scope  => Error_Handler.G_SCOPE_SIBLINGS
1358     ,  p_other_status => Error_Handler.G_STATUS_ERROR
1359     ,  p_other_message  => l_other_message
1360     ,  p_other_token_tbl  => l_other_token_tbl
1361     ,  p_error_level  => Error_Handler.G_SC_LEVEL
1362     ,  p_entity_index => I
1363     ,  x_bom_header_rec     => l_bom_header_rec
1364     ,  x_bom_revision_tbl => l_bom_revision_tbl
1365     ,  x_bom_component_tbl  => l_bom_component_tbl
1366     ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
1367     ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
1368     );
1369 
1370         IF l_bo_return_status = 'S'
1371         THEN
1372                 l_bo_return_status     := l_return_status;
1373         END IF;
1374         x_return_status                := l_bo_return_status;
1375   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
1376       x_bom_sub_component_tbl            := l_bom_sub_component_tbl;
1377 
1378       RETURN;
1379 
1380        WHEN EXC_FAT_QUIT_SIBLINGS THEN
1381 
1382     Error_Handler.Log_Error
1383     (  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
1384     ,  p_mesg_token_tbl => l_mesg_token_tbl
1385     ,  p_error_status => Error_Handler.G_STATUS_FATAL
1386     ,  p_error_scope  => Error_Handler.G_SCOPE_SIBLINGS
1387     ,  p_other_status       => Error_Handler.G_STATUS_FATAL
1388                 ,  p_other_message  => l_other_message
1389     ,  p_other_token_tbl  => l_other_token_tbl
1390     ,  p_error_level  => Error_Handler.G_SC_LEVEL
1391     ,  p_entity_index => I
1392     ,  x_bom_header_rec     => l_bom_header_rec
1393     ,  x_bom_component_tbl  => l_bom_component_tbl
1394     ,  x_bom_revision_tbl => l_bom_revision_tbl
1395     ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
1396     ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
1397     );
1398 
1399         x_return_status                := Error_Handler.G_STATUS_FATAL;
1400   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
1401       x_bom_sub_component_tbl            := l_bom_sub_component_tbl;
1402 
1403       RETURN;
1404 
1405        WHEN EXC_FAT_QUIT_BRANCH THEN
1406 
1407   Error_Handler.Log_Error
1408     (  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
1409     ,  p_mesg_token_tbl => l_mesg_token_tbl
1410     ,  p_error_status => Error_Handler.G_STATUS_FATAL
1411     ,  p_error_scope  => Error_Handler.G_SCOPE_CHILDREN
1412     ,  p_other_status       => Error_Handler.G_STATUS_FATAL
1413                 ,  p_other_message  => l_other_message
1414     ,  p_other_token_tbl  => l_other_token_tbl
1415     ,  p_error_level  => Error_Handler.G_SC_LEVEL
1416     ,  p_entity_index => I
1417     ,  x_bom_header_rec => l_bom_header_rec
1418     ,  x_bom_revision_tbl => l_bom_revision_tbl
1419     ,  x_bom_component_tbl  => l_bom_component_tbl
1420     ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
1421     ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
1422     );
1423 
1424         x_return_status                := Error_Handler.G_STATUS_FATAL;
1425   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
1426       x_bom_sub_component_tbl            := l_bom_sub_component_tbl;
1427 
1428        WHEN EXC_FAT_QUIT_OBJECT THEN
1429 
1430   Error_Handler.Log_Error
1431     (  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
1432     ,  p_mesg_token_tbl => l_mesg_token_tbl
1433     ,  p_error_status => Error_Handler.G_STATUS_FATAL
1434     ,  p_error_scope  => Error_Handler.G_SCOPE_ALL
1435     ,  p_other_status       => Error_Handler.G_STATUS_FATAL
1436     ,  p_other_message  => l_other_message
1437     ,  p_other_token_tbl  => l_other_token_tbl
1438     ,  p_error_level  => Error_Handler.G_SC_LEVEL
1439     ,  p_entity_index => I
1440     ,  x_bom_header_rec     => l_bom_header_rec
1441     ,  x_bom_revision_tbl => l_bom_revision_tbl
1442     ,  x_bom_component_tbl  => l_bom_component_tbl
1443     ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
1444     ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
1445     );
1446 
1447         x_return_status                := Error_Handler.G_STATUS_FATAL;
1448   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
1449       x_bom_sub_component_tbl            := l_bom_sub_component_tbl;
1450 
1451   l_return_status := 'Q';
1452 
1453        WHEN EXC_UNEXP_SKIP_OBJECT THEN
1454 
1455   Error_Handler.Log_Error
1456     (  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
1457     ,  p_mesg_token_tbl => l_mesg_token_tbl
1458     ,  p_error_status => Error_Handler.G_STATUS_UNEXPECTED
1459     ,  p_other_status       => Error_Handler.G_STATUS_NOT_PICKED
1460                 ,  p_other_message  => l_other_message
1461     ,  p_other_token_tbl  => l_other_token_tbl
1462     ,  p_error_level  => Error_Handler.G_SC_LEVEL
1463     ,  x_bom_header_rec     => l_bom_header_rec
1464     ,  x_bom_revision_tbl => l_bom_revision_tbl
1465     ,  x_bom_component_tbl  => l_bom_component_tbl
1466     ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
1467     ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
1468     );
1469 
1470         x_return_status                := l_bo_return_status;
1471       x_bom_sub_component_tbl            := l_bom_sub_component_tbl;
1472   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
1473 
1474   l_return_status := 'U';
1475 
1476         END; -- END block
1477 
1478      END LOOP; -- END Substitute Components processing loop
1479 
1480     IF l_return_status in ('Q', 'U')
1481     THEN
1482         x_return_status := l_return_status;
1483   RETURN;
1484     END IF;
1485 
1486     --  Load out parameters
1487 
1488  /*********Business Event************/
1489    IF ( G_SUB_COMP_FLAG = 1 AND l_sub_comp_processed) THEN
1490         Bom_Business_Event_PKG.Raise_Component_Event(
1491           p_event_load_type          => 'Bulk'
1492         , p_request_identifier      => FND_GLOBAL.CONC_REQUEST_ID
1493         , p_batch_identifier        => BOM_GLOBALS.G_BATCH_ID
1494         , p_event_entity_name       => 'Substitute Component'
1495         , p_event_name              => Bom_Business_Event_PKG.G_COMPONENT_MODIFIED_EVENT
1496         , p_last_update_date        => sysdate
1497         , p_last_updated_by         => fnd_global.user_id
1498     );
1499    END IF;
1500    G_SUB_COMP_FLAG := 0;
1501    /*********Business Event************/
1502 
1503      x_return_status          := l_bo_return_status;
1504      x_bom_sub_component_tbl    := l_bom_sub_component_tbl;
1505      x_Mesg_Token_Tbl     := l_Mesg_Token_Tbl;
1506 
1507 END Substitute_Components;
1508 
1509 
1510 --  Ref_Desgs
1511 
1512 PROCEDURE Reference_Designators
1513 (   p_validation_level              IN  NUMBER
1514 ,   p_organization_id       IN  NUMBER := NULL
1515 ,   p_assembly_item_name      IN  VARCHAR2 := NULL
1516 ,   p_alternate_bom_code      IN  VARCHAR2 := NULL
1517 ,   p_effectivity_date            IN  DATE := NULL
1518 ,   p_component_item_name     IN  VARCHAR2 := NULL
1519 ,   p_operation_seq_num       IN  NUMBER := NULL
1520 ,   p_bom_ref_designator_tbl        IN  Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type
1521 ,   p_bom_sub_component_tbl     IN  Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type
1522 ,   x_bom_ref_designator_tbl        IN OUT NOCOPY Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type
1523 ,   x_bom_sub_component_tbl     IN OUT NOCOPY Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type
1524 ,   x_Mesg_Token_Tbl        IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
1525 ,   x_return_status       IN OUT NOCOPY VARCHAR2
1526 )
1527 IS
1528 TYPE Bom_Comp_Details_Rec_Type IS RECORD
1529 (  Component_Item_Name       VARCHAR2(240)
1530  , Component_Sequence_Id     NUMBER
1531  , Entity_Index              NUMBER
1532 );
1533 TYPE Bom_Comp_Details_Tbl_Type IS TABLE OF Bom_Comp_Details_Rec_Type
1534     INDEX BY BINARY_INTEGER;
1535 l_Comp_Seq_Id           NUMBER;
1536 l_Comp_Item_Name        VARCHAR2(240);
1537 l_Bom_Comp_Details_Tbl  Bom_Comp_Details_Tbl_Type;
1538 l_Rec_Index             NUMBER;
1539 
1540 l_Mesg_Token_Tbl        Error_Handler.Mesg_Token_Tbl_Type;
1541 l_other_token_tbl       Error_Handler.Token_Tbl_Type;
1542 l_other_message         VARCHAR2(2000);
1543 l_err_text              VARCHAR2(2000);
1544 l_valid     BOOLEAN := TRUE;
1545 l_item_parent_exists  BOOLEAN := FALSE;
1546 l_comp_parent_exists  BOOLEAN := FALSE;
1547 l_Return_Status         VARCHAR2(1);
1548 l_bo_return_status      VARCHAR2(1);
1549 l_bom_header_rec  Bom_Bo_Pub.Bom_Head_Rec_Type;
1550 l_bom_revision_tbl  Bom_Bo_Pub.Bom_Revision_Tbl_Type;
1551 l_bom_component_tbl     Bom_Bo_Pub.Bom_Comps_Tbl_Type;
1552 l_bom_ref_designator_rec    Bom_Bo_Pub.Bom_Ref_Designator_Rec_Type;
1553 l_bom_ref_designator_tbl    Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type :=
1554           p_bom_ref_designator_tbl;
1555 l_old_bom_ref_designator_rec Bom_Bo_Pub.Bom_Ref_Designator_Rec_Type;
1556 l_bom_ref_desg_unexp_rec    Bom_Bo_Pub.Bom_Ref_Desg_Unexp_Rec_Type;
1557 l_old_bom_ref_desg_unexp_rec Bom_Bo_Pub.Bom_Ref_Desg_Unexp_Rec_Type;
1558 l_bom_sub_component_tbl     Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type :=
1559           p_bom_sub_component_tbl;
1560 l_return_value          NUMBER;
1561 l_Token_Tbl             Error_Handler.Token_Tbl_Type;
1562 l_ref_desig_processed   BOOLEAN := FALSE;
1563 BEGIN
1564 
1565     --  Init local table variables.
1566 
1567     l_return_status := 'S';
1568     l_bo_return_status := 'S';
1569 
1570     l_bom_ref_designator_tbl           := p_bom_ref_designator_tbl;
1571 
1572     l_bom_ref_desg_unexp_rec.organization_id := Bom_Globals.Get_org_id;
1573 
1574 
1575     FOR I IN 1..l_bom_ref_designator_tbl.COUNT LOOP
1576     BEGIN
1577 
1578         --  Load local records.
1579 
1580         l_bom_ref_designator_rec := l_bom_ref_designator_tbl(I);
1581 
1582         l_bom_ref_designator_rec.transaction_type :=
1583           UPPER(l_bom_ref_designator_rec.transaction_type);
1584 
1585         IF p_component_item_name IS NOT NULL AND
1586            p_operation_seq_num IS NOT NULL AND
1587            p_assembly_item_name IS NOT NULL AND
1588            p_effectivity_date IS NOT NULL AND
1589            p_organization_id IS NOT NULL
1590         THEN
1591           -- Inventory Component parent exists
1592 
1593           l_comp_parent_exists := TRUE;
1594 
1595         ELSIF p_assembly_item_name IS NOT NULL AND
1596            p_effectivity_date IS NOT NULL AND
1597            p_organization_id IS NOT NULL
1598         THEN
1599           -- Assembly item parent exists
1600 
1601           l_item_parent_exists := TRUE;
1602         END IF;
1603 
1604       -- Process Flow Step 2: Check if record has not yet been processed and
1605       -- that it is the child of the parent that called this procedure
1606       --
1607 
1608       IF (l_bom_ref_designator_rec.return_status IS NULL OR
1609           l_bom_ref_designator_rec.return_status = FND_API.G_MISS_CHAR)
1610          AND
1611 
1612          -- Did Revised_Components call this procedure, that is,
1613          -- if revised comp exists, then is this record a child ?
1614 
1615      ((l_comp_parent_exists AND
1616          (l_bom_ref_designator_rec.assembly_item_name =
1617           p_assembly_item_name AND
1618           l_bom_ref_desg_unexp_rec.organization_id = p_organization_id
1619     AND
1620           l_bom_ref_designator_rec.component_item_name =
1621     p_component_item_name AND
1622           l_bom_ref_designator_rec.operation_sequence_number =
1623     p_operation_seq_num
1624     AND l_bom_ref_designator_rec.start_effective_date =
1625           p_effectivity_date   -- Bug 4519366. Effectivity date needed to identify parent
1626          )
1627        )
1628            OR
1629            -- Did Bom_Header call this procedure, that is,
1630            -- if revised item exists, then is this record a child ?
1631 
1632        (l_item_parent_exists AND
1633          (l_bom_ref_designator_rec.assembly_item_name =
1634       p_assembly_item_name AND
1635           l_bom_ref_desg_unexp_rec.organization_id =
1636       p_organization_id AND
1637     l_bom_ref_designator_rec.alternate_bom_code =
1638       p_alternate_bom_code
1639     )
1640         )
1641        OR
1642            (NOT l_item_parent_exists AND
1643         NOT l_comp_parent_exists))
1644       THEN
1645          l_ref_desig_processed := TRUE;
1646          l_return_status := FND_API.G_RET_STS_SUCCESS;
1647 
1648            l_bom_ref_designator_rec.return_status := FND_API.G_RET_STS_SUCCESS;
1649 
1650      --
1651      -- Check if transaction_type is valid
1652      --
1653 
1654      Bom_Globals.Transaction_Type_Validity
1655      (   p_transaction_type => l_bom_ref_designator_rec.transaction_type
1656      ,   p_entity   => 'Ref_Desgs'
1657      ,   p_entity_id  => l_bom_ref_designator_rec.assembly_item_name
1658      ,   x_valid    => l_valid
1659      ,   x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
1660      );
1661 
1662      IF NOT l_valid
1663      THEN
1664                 l_return_status := Error_Handler.G_STATUS_ERROR;
1665         RAISE EXC_SEV_QUIT_RECORD;
1666      END IF;
1667 
1668      --
1669      -- Process Flow step 4(a): Convert user unique index to unique
1670      -- index I
1671      --
1672      Bom_Val_To_Id.Ref_Designator_UUI_To_UI
1673     ( p_bom_ref_designator_rec => l_bom_ref_designator_rec
1674     , p_bom_ref_desg_unexp_rec => l_bom_ref_desg_unexp_rec
1675     , x_bom_ref_desg_unexp_rec => l_bom_ref_desg_unexp_rec
1676     , x_Mesg_Token_Tbl     => l_Mesg_Token_Tbl
1677     , x_Return_Status      => l_return_status
1678     );
1679 
1680      IF l_return_status = Error_Handler.G_STATUS_ERROR
1681      THEN
1682         RAISE EXC_SEV_QUIT_RECORD;
1683      ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
1684      THEN
1685     l_other_message := 'BOM_RFD_UUI_UNEXP_SKIP';
1686     l_other_token_tbl(1).token_name := 'REFERENCE_DESIGNATOR_NAME';
1687     l_other_token_tbl(1).token_value :=
1688       l_bom_ref_designator_rec.reference_designator_name;
1689     RAISE EXC_UNEXP_SKIP_OBJECT;
1690          END IF;
1691 
1692      --
1693      -- Process Flow step 4(b): Convert user unique index to unique
1694      -- index II
1695      --
1696 
1697      Bom_Val_To_Id.Ref_Designator_UUI_To_UI2
1698     ( p_bom_ref_designator_rec => l_bom_ref_designator_rec
1699     , p_bom_ref_desg_unexp_rec => l_bom_ref_desg_unexp_rec
1700     , x_bom_ref_desg_unexp_rec => l_bom_ref_desg_unexp_rec
1701     , x_Mesg_Token_Tbl     => l_Mesg_Token_Tbl
1702                 , x_other_message      => l_other_message
1703                 , x_other_token_tbl    => l_other_token_tbl
1704     , x_Return_Status      => l_return_status
1705     );
1706 
1707      IF l_return_status = Error_Handler.G_STATUS_ERROR
1708      THEN
1709         RAISE EXC_SEV_QUIT_SIBLINGS;
1710      ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
1711      THEN
1712     l_other_message := 'BOM_RFD_UUI_UNEXP_SKIP';
1713     l_other_token_tbl(1).token_name := 'REFERENCE_DESIGNATOR_NAME';
1714     l_other_token_tbl(1).token_value :=
1715       l_bom_ref_designator_rec.reference_designator_name;
1716     RAISE EXC_UNEXP_SKIP_OBJECT;
1717          END IF;
1718 
1719      --
1720      -- Process Flow step 5: Verify Reference Designator's existence
1721      --
1722 
1723      Bom_Validate_Ref_Designator.Check_Existence
1724       (  p_bom_ref_designator_rec   => l_bom_ref_designator_rec
1725       ,  p_bom_ref_desg_unexp_rec   => l_bom_ref_desg_unexp_rec
1726     ,  x_old_bom_ref_designator_rec => l_old_bom_ref_designator_rec
1727                 ,  x_old_bom_ref_desg_unexp_rec => l_old_bom_ref_desg_unexp_rec
1728           ,  x_Mesg_Token_Tbl       => l_Mesg_Token_Tbl
1729           ,  x_return_status        => l_Return_Status
1730       );
1731 
1732      IF l_return_status = Error_Handler.G_STATUS_ERROR
1733      THEN
1734         RAISE EXC_SEV_QUIT_RECORD;
1735      ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
1736      THEN
1737     l_other_message := 'BOM_RFD_EXS_UNEXP_SKIP';
1738     l_other_token_tbl(1).token_name := 'REFERENCE_DESIGNATOR_NAME';
1739     l_other_token_tbl(1).token_value :=
1740       l_bom_ref_designator_rec.reference_designator_name;
1741                 l_other_token_tbl(2).token_name := 'REVISED_COMPONENT_NAME';
1742                 l_other_token_tbl(2).token_value :=
1743       l_bom_ref_designator_rec.component_item_name;
1744     RAISE EXC_UNEXP_SKIP_OBJECT;
1745          END IF;
1746 
1747            /* Assign the correct transaction type for SYNC operations */
1748 
1749            IF l_bom_ref_designator_rec.transaction_type = 'SYNC' THEN
1750              l_bom_ref_designator_rec.transaction_type :=
1751                  l_old_bom_ref_designator_rec.transaction_type;
1752            END IF;
1753 
1754      --
1755      -- Process Flow step 6: Is Revised Component record an orphan ?
1756      --
1757 
1758      IF NOT l_comp_parent_exists
1759      THEN
1760 
1761       -- Process Flow step 7: Check lineage
1762       --
1763 
1764           IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Check lineage');     END IF;
1765       Bom_Validate_Ref_Designator.Check_Lineage
1766       (  p_bom_ref_designator_rec   => l_bom_ref_designator_rec
1767       ,  p_bom_ref_desg_unexp_rec   => l_bom_ref_desg_unexp_rec
1768           ,  x_Mesg_Token_Tbl       => l_Mesg_Token_Tbl
1769           ,  x_return_status        => l_Return_Status
1770       );
1771 
1772       IF l_return_status = Error_Handler.G_STATUS_ERROR
1773       THEN
1774           RAISE EXC_SEV_QUIT_BRANCH;
1775       ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
1776       THEN
1777       l_other_message := 'BOM_RFD_LIN_UNEXP_SKIP';
1778       l_other_token_tbl(1).token_name :=
1779           'REFERENCE_DESIGNATOR_NAME';
1780       l_other_token_tbl(1).token_value :=
1781       l_bom_ref_designator_rec.reference_designator_name;
1782       RAISE EXC_UNEXP_SKIP_OBJECT;
1783           END IF;
1784 
1785     --
1786       -- Process Flow step 9(a and b): check that user has access to
1787           -- Assembly item
1788       --
1789       Bom_Validate_Bom_Header.Check_Access
1790     (  p_organization_id=>l_bom_ref_desg_unexp_rec.organization_id
1791           ,  p_assembly_item_id=>l_bom_ref_desg_unexp_rec.assembly_item_id
1792     ,  p_alternate_bom_code=>
1793         l_bom_ref_designator_rec.alternate_bom_code
1794     ,  p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
1795     ,  x_Mesg_Token_Tbl     => l_Mesg_Token_Tbl
1796           ,  x_return_status      => l_Return_Status
1797     );
1798 
1799       IF l_return_status = Error_Handler.G_STATUS_ERROR
1800       THEN
1801       l_other_message := 'BOM_RFD_RITACC_FAT_FATAL';
1802       l_other_token_tbl(1).token_name :=
1803           'REFERENCE_DESIGNATOR_NAME';
1804       l_other_token_tbl(1).token_value :=
1805       l_bom_ref_designator_rec.reference_designator_name;
1806                         l_return_status := 'F';
1807       RAISE EXC_FAT_QUIT_SIBLINGS;
1808       ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
1809       THEN
1810       l_other_message := 'BOM_RFD_RITACC_UNEXP_SKIP';
1811       l_other_token_tbl(1).token_name :=
1812           'REFERENCE_DESIGNATOR_NAME';
1813       l_other_token_tbl(1).token_value :=
1814       l_bom_ref_designator_rec.reference_designator_name;
1815       RAISE EXC_UNEXP_SKIP_OBJECT;
1816           END IF;
1817 
1818        END IF;  -- Check if Not Compononent Parents Exist Ends
1819 
1820     --
1821     -- Process Flow step:Check that user has access to Bom component
1822     --
1823 
1824     Bom_Validate_Bom_Component.Check_Access
1825     (  p_organization_id  =>
1826           l_bom_ref_desg_unexp_rec.organization_id
1827     ,  p_component_item_id =>
1828         l_bom_ref_desg_unexp_rec.component_item_id
1829     ,  p_component_name     =>
1830         l_bom_ref_designator_rec.component_item_name
1831     ,  x_Mesg_Token_Tbl     => l_Mesg_Token_Tbl
1832           ,  x_return_status      => l_Return_Status
1833     );
1834 
1835       IF l_return_status = Error_Handler.G_STATUS_ERROR
1836       THEN
1837       l_other_message := 'BOM_RFD_CMPACC_FAT_FATAL';
1838       l_other_token_tbl(1).token_name :=
1839         'REFERENCE_DESIGNATOR_NAME';
1840       l_other_token_tbl(1).token_value :=
1841       l_bom_ref_designator_rec.reference_designator_name;
1842                         l_return_status := 'F';
1843           RAISE EXC_FAT_QUIT_SIBLINGS;
1844       ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
1845       THEN
1846       l_other_message := 'BOM_RFD_CMPACC_UNEXP_SKIP';
1847       l_other_token_tbl(1).token_name :=
1848         'REFERENCE_DESIGNATOR_NAME';
1849       l_other_token_tbl(1).token_value :=
1850       l_bom_ref_designator_rec.reference_designator_name;
1851       RAISE EXC_UNEXP_SKIP_OBJECT;
1852           END IF;
1853 
1854      IF l_bom_ref_designator_rec.transaction_type IN
1855             (Bom_Globals.G_OPR_UPDATE, Bom_Globals.G_OPR_DELETE)
1856          THEN
1857 
1858           -- Process flow step 11 - Populate NULL columns for Update and
1859           -- Delete.
1860 
1861           IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Populating NULL Columns'); END IF;
1862     Bom_Default_Ref_Designator.Populate_NULL_Columns
1863                 (   p_bom_ref_designator_rec    => l_bom_ref_designator_rec
1864                 ,   p_old_bom_ref_designator_rec=> l_old_bom_ref_designator_rec
1865                 ,   p_bom_ref_desg_unexp_rec  => l_bom_ref_desg_unexp_rec
1866                 ,   p_old_bom_ref_desg_unexp_rec=> l_old_bom_ref_desg_unexp_rec
1867                 ,   x_bom_ref_designator_rec    => l_bom_ref_designator_rec
1868                 ,   x_bom_ref_desg_unexp_rec  => l_bom_ref_desg_unexp_rec
1869                 );
1870 
1871      END IF;
1872 
1873          -- Process Flow step 12 - Entity Level Validation
1874      --
1875 
1876          IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Entity validation'); END IF;
1877 
1878            IF l_bom_ref_designator_rec.transaction_type = 'DELETE'
1879            THEN
1880 
1881            IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Calling Entity Delete validation'); END IF;
1882 
1883                 Bom_Validate_Ref_Designator.Check_Entity_Delete
1884           (  p_bom_ref_designator_rec     => l_bom_ref_designator_rec
1885           ,  p_bom_ref_desg_unexp_rec     => l_bom_ref_desg_unexp_rec
1886                 ,  x_Mesg_Token_Tbl             => l_Mesg_Token_Tbl
1887                 ,  x_return_status              => l_Return_Status
1888                 );
1889            ELSE
1890               Bom_Validate_Ref_Designator.Check_Entity
1891           (  p_bom_ref_designator_rec     => l_bom_ref_designator_rec
1892           ,  p_bom_ref_desg_unexp_rec     => l_bom_ref_desg_unexp_rec
1893           ,  x_Mesg_Token_Tbl         => l_Mesg_Token_Tbl
1894       ,  x_return_status          => l_Return_Status
1895           );
1896            END IF ;
1897 
1898          IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('return_status: ' || l_return_status); END IF;
1899 
1900      IF l_return_status = Error_Handler.G_STATUS_ERROR
1901      THEN
1902         RAISE EXC_SEV_QUIT_RECORD;
1903      ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
1904      THEN
1905     l_other_message := 'BOM_RFD_ENTVAL_UNEXP_SKIP';
1906     l_other_token_tbl(1).token_name := 'REFERENCE_DESIGNATOR_NAME';
1907     l_other_token_tbl(1).token_value :=
1908       l_bom_ref_designator_rec.reference_designator_name;
1909     RAISE EXC_UNEXP_SKIP_OBJECT;
1910             ELSIF l_return_status ='S' AND
1911                     l_Mesg_Token_Tbl.COUNT <>0
1912             THEN
1913               Error_Handler.Log_Error
1914                 (  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
1915                 ,  p_bom_sub_component_tbl => l_bom_sub_component_tbl
1916                 ,  p_mesg_token_tbl => l_mesg_token_tbl
1917                 ,  p_error_status => 'W'
1918                 ,  p_error_level  => Error_Handler.G_RD_LEVEL
1919                 ,  p_entity_index => I
1920                 ,  x_bom_header_rec     => l_bom_header_rec
1921                 ,  x_bom_revision_tbl => l_bom_revision_tbl
1922                 ,  x_bom_component_tbl  => l_bom_component_tbl
1923                 ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
1924                 ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
1925                 );
1926             END IF;
1927 
1928      --
1929          -- Process Flow step 14 : Database Writes
1930      --
1931 
1932          IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Writing to the database'); END IF;
1933          Bom_Ref_Designator_Util.Perform_Writes
1934           (   p_bom_ref_designator_rec => l_bom_ref_designator_rec
1935           ,   p_bom_ref_desg_unexp_rec => l_bom_ref_desg_unexp_rec
1936           ,   x_Mesg_Token_Tbl    => l_Mesg_Token_Tbl
1937           ,   x_return_status     => l_return_status
1938           );
1939 
1940      IF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
1941      THEN
1942     l_other_message := 'BOM_RFD_WRITES_UNEXP_SKIP';
1943     l_other_token_tbl(1).token_name := 'REFERENCE_DESIGNATOR_NAME';
1944     l_other_token_tbl(1).token_value :=
1945       l_bom_ref_designator_rec.reference_designator_name;
1946     RAISE EXC_UNEXP_SKIP_OBJECT;
1947          END IF;
1948 
1949         l_Comp_Seq_Id    := l_bom_ref_desg_unexp_rec.Component_Sequence_Id;
1950         l_Comp_Item_Name := l_bom_ref_designator_rec.Component_Item_Name;
1951         IF NOT l_comp_parent_exists THEN
1952           l_Bom_Comp_Details_Tbl(l_Comp_Seq_Id).Component_Sequence_Id := l_Comp_Seq_Id;
1953           l_Bom_Comp_Details_Tbl(l_Comp_Seq_Id).Component_Item_Name := l_Comp_Item_Name;
1954           l_Bom_Comp_Details_Tbl(l_Comp_Seq_Id).Entity_Index := I;
1955         END IF;
1956 
1957         END IF; -- END IF statement that checks RETURN STATUS
1958 
1959         --  Load tables.
1960 
1961         l_bom_ref_designator_tbl(I)          := l_bom_ref_designator_rec;
1962         --4306013
1963         IF( l_bom_ref_designator_tbl(I).transaction_type in ( Bom_Globals.G_OPR_UPDATE, Bom_Globals.G_OPR_CREATE )
1964         AND l_return_status = 'S')
1965         THEN
1966           G_Ref_Desig_Flag := 1;
1967        END IF;
1968 
1969     --  For loop exception handler.
1970 
1971 
1972     EXCEPTION
1973 
1974        WHEN EXC_SEV_QUIT_RECORD THEN
1975 
1976     Error_Handler.Log_Error
1977     (  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
1978     ,  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
1979     ,  p_mesg_token_tbl => l_mesg_token_tbl
1980     ,  p_error_status => Error_Handler.G_STATUS_ERROR
1981     ,  p_error_scope  => Error_Handler.G_SCOPE_RECORD
1982     ,  p_error_level  => Error_Handler.G_RD_LEVEL
1983     ,  p_entity_index => I
1984     ,  x_bom_header_rec => l_bom_header_rec
1985     ,  x_bom_revision_tbl => l_bom_revision_tbl
1986     ,  x_bom_component_tbl  => l_bom_component_tbl
1987     ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
1988     ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
1989     );
1990 
1991         IF l_bo_return_status = 'S'
1992         THEN
1993                 l_bo_return_status     := l_return_status;
1994         END IF;
1995         x_return_status                := l_bo_return_status;
1996   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
1997       x_bom_ref_designator_tbl           := l_bom_ref_designator_tbl;
1998       x_bom_sub_component_tbl            := l_bom_sub_component_tbl;
1999 
2000        WHEN EXC_SEV_QUIT_BRANCH THEN
2001 
2002         Error_Handler.Log_Error
2003                 (  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
2004                 ,  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
2005                 ,  p_mesg_token_tbl     => l_mesg_token_tbl
2006                 ,  p_error_status       => Error_Handler.G_STATUS_ERROR
2007                 ,  p_error_scope        => Error_Handler.G_SCOPE_CHILDREN
2008                 ,  p_other_status       => Error_Handler.G_STATUS_ERROR
2009                 ,  p_other_message      => l_other_message
2010                 ,  p_other_token_tbl    => l_other_token_tbl
2011                 ,  p_error_level        => Error_Handler.G_RD_LEVEL
2012                 ,  p_entity_index       => I
2013                 ,  x_bom_header_rec     => l_bom_header_rec
2014                 ,  x_bom_revision_tbl   => l_bom_revision_tbl
2015                 ,  x_bom_component_tbl  => l_bom_component_tbl
2016                 ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
2017                 ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
2018                 );
2019 
2020         IF l_bo_return_status = 'S'
2021         THEN
2022                 l_bo_return_status     := l_return_status;
2023         END IF;
2024         x_return_status                := l_bo_return_status;
2025         x_Mesg_Token_Tbl               := l_Mesg_Token_Tbl;
2026         x_bom_ref_designator_tbl           := l_bom_ref_designator_tbl;
2027         x_bom_sub_component_tbl            := l_bom_sub_component_tbl;
2028 
2029        WHEN EXC_SEV_QUIT_SIBLINGS THEN
2030 
2031   Error_Handler.Log_Error
2032     (  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
2033     ,  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
2034     ,  p_mesg_token_tbl => l_mesg_token_tbl
2035     ,  p_error_status => Error_Handler.G_STATUS_ERROR
2036     ,  p_error_scope  => Error_Handler.G_SCOPE_SIBLINGS
2037     ,  p_other_status => Error_Handler.G_STATUS_ERROR
2038     ,  p_other_message  => l_other_message
2039     ,  p_other_token_tbl  => l_other_token_tbl
2040     ,  p_error_level  => Error_Handler.G_RD_LEVEL
2041     ,  p_entity_index => I
2042     ,  x_bom_header_rec     => l_bom_header_rec
2043     ,  x_bom_revision_tbl => l_bom_revision_tbl
2044     ,  x_bom_component_tbl  => l_bom_component_tbl
2045     ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
2046     ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
2047     );
2048 
2049         IF l_bo_return_status = 'S'
2050         THEN
2051                 l_bo_return_status     := l_return_status;
2052         END IF;
2053         x_return_status                := l_bo_return_status;
2054   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
2055       x_bom_ref_designator_tbl           := l_bom_ref_designator_tbl;
2056       x_bom_sub_component_tbl            := l_bom_sub_component_tbl;
2057 
2058       RETURN;
2059 
2060        WHEN EXC_FAT_QUIT_SIBLINGS THEN
2061 
2062   Error_Handler.Log_Error
2063     (  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
2064     ,  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
2065     ,  p_mesg_token_tbl => l_mesg_token_tbl
2066     ,  p_error_status => Error_Handler.G_STATUS_FATAL
2067     ,  p_error_scope  => Error_Handler.G_SCOPE_SIBLINGS
2068     ,  p_other_status       => Error_Handler.G_STATUS_FATAL
2069                 ,  p_other_message  => l_other_message
2070     ,  p_other_token_tbl  => l_other_token_tbl
2071     ,  p_error_level  => Error_Handler.G_RD_LEVEL
2072     ,  p_entity_index => I
2073     ,  x_bom_header_rec     => l_bom_header_rec
2074     ,  x_bom_revision_tbl => l_bom_revision_tbl
2075     ,  x_bom_component_tbl  => l_bom_component_tbl
2076     ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
2077     ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
2078     );
2079 
2080         x_return_status                := Error_Handler.G_STATUS_FATAL;
2081   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
2082       x_bom_ref_designator_tbl           := l_bom_ref_designator_tbl;
2083       x_bom_sub_component_tbl            := l_bom_sub_component_tbl;
2084 
2085       RETURN;
2086 
2087        WHEN EXC_FAT_QUIT_OBJECT THEN
2088 
2089   Error_Handler.Log_Error
2090     (  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
2091     ,  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
2092     ,  p_mesg_token_tbl => l_mesg_token_tbl
2093     ,  p_error_status => Error_Handler.G_STATUS_FATAL
2094     ,  p_error_scope  => Error_Handler.G_SCOPE_ALL
2095     ,  p_other_status       => Error_Handler.G_STATUS_FATAL
2096     ,  p_other_message  => l_other_message
2097     ,  p_other_token_tbl  => l_other_token_tbl
2098     ,  p_error_level  => Error_Handler.G_RD_LEVEL
2099     ,  p_entity_index => I
2100     ,  x_bom_header_rec     => l_bom_header_rec
2101     ,  x_bom_revision_tbl => l_bom_revision_tbl
2102     ,  x_bom_component_tbl  => l_bom_component_tbl
2103     ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
2104     ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
2105     );
2106 
2107   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
2108       x_bom_ref_designator_tbl           := l_bom_ref_designator_tbl;
2109       x_bom_sub_component_tbl            := l_bom_sub_component_tbl;
2110 
2111   l_return_status := 'Q';
2112 
2113        WHEN EXC_UNEXP_SKIP_OBJECT THEN
2114 
2115   Error_Handler.Log_Error
2116     (  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
2117     ,  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
2118     ,  p_mesg_token_tbl => l_mesg_token_tbl
2119     ,  p_error_status => Error_Handler.G_STATUS_UNEXPECTED
2120     ,  p_other_status       => Error_Handler.G_STATUS_NOT_PICKED
2121                 ,  p_other_message  => l_other_message
2122     ,  p_other_token_tbl  => l_other_token_tbl
2123     ,  p_error_level  => Error_Handler.G_RD_LEVEL
2124     ,  x_bom_header_rec     => l_bom_header_rec
2125     ,  x_bom_revision_tbl => l_bom_revision_tbl
2126     ,  x_bom_component_tbl  => l_bom_component_tbl
2127     ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
2128     ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
2129     );
2130 
2131       x_bom_ref_designator_tbl           := l_bom_ref_designator_tbl;
2132       x_bom_sub_component_tbl            := l_bom_sub_component_tbl;
2133   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
2134 
2135   l_return_status := 'U';
2136 
2137      END; -- END block
2138 
2139       IF l_return_status in ('Q', 'U')
2140       THEN
2141           x_return_status := l_return_status;
2142     RETURN;
2143       END IF;
2144 
2145   END LOOP; -- END Reference Designator processing loop
2146 
2147     l_Rec_Index := l_Bom_Comp_Details_Tbl.FIRST;
2148     WHILE l_Rec_Index IS NOT NULL LOOP
2149       Bom_Validate_Ref_Designator.check_quantity
2150         ( x_return_status         => l_return_status
2151         , x_mesg_token_tbl        => l_Mesg_Token_Tbl
2152         , p_component_sequence_id => l_Bom_Comp_Details_Tbl(l_Rec_Index).component_sequence_id
2153         , p_component_item_name   => l_Bom_Comp_Details_Tbl(l_Rec_Index).component_item_name
2154         );
2155       IF l_return_status = Error_Handler.G_STATUS_ERROR
2156       THEN
2157         Error_Handler.Log_Error
2158         (  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
2159         ,  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
2160         ,  p_mesg_token_tbl => l_mesg_token_tbl
2161         ,  p_error_status => Error_Handler.G_STATUS_WARNING
2162         ,  p_error_scope  => Error_Handler.G_SCOPE_RECORD
2163         ,  p_error_level  => Error_Handler.G_RD_LEVEL
2164         ,  p_entity_index => l_Bom_Comp_Details_Tbl(l_Rec_Index).Entity_Index
2165         ,  x_bom_header_rec => l_bom_header_rec
2166         ,  x_bom_revision_tbl => l_bom_revision_tbl
2167         ,  x_bom_component_tbl  => l_bom_component_tbl
2168         ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
2169         ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
2170         );
2171       END IF;
2172         l_Rec_Index := l_Bom_Comp_Details_Tbl.NEXT(l_Rec_Index);
2173       END LOOP; -- END proceesing components for orphan ref desigs
2174 
2175    /*********Business Event************/
2176    IF ( G_Ref_Desig_Flag = 1 AND l_ref_desig_processed) THEN
2177         Bom_Business_Event_PKG.Raise_Component_Event(
2178         p_event_load_type          => 'Bulk'
2179         , p_request_identifier      => FND_GLOBAL.CONC_REQUEST_ID
2180         , p_batch_identifier        => BOM_GLOBALS.G_BATCH_ID
2181         , p_event_entity_name       => 'Reference Designator'
2182         , p_event_name              => Bom_Business_Event_PKG.G_COMPONENT_MODIFIED_EVENT
2183         , p_last_update_date        => sysdate
2184         , p_last_updated_by         => fnd_global.user_id
2185     );
2186    END IF;
2187    G_Ref_Desig_Flag := 0;
2188    /*********Business Event************/
2189 
2190     --  Load out parameters
2191 
2192      x_return_status          := l_bo_return_status;
2193      x_bom_ref_designator_tbl       := l_bom_ref_designator_tbl;
2194      x_bom_sub_component_tbl        := l_bom_sub_component_tbl;
2195      x_Mesg_Token_Tbl     := l_Mesg_Token_Tbl;
2196 
2197 
2198 END Reference_Designators;
2199 
2200 --  Bom _Components
2201 
2202 PROCEDURE Bom_Components
2203 (   p_validation_level              IN  NUMBER
2204 ,   p_organization_id       IN  NUMBER := NULL
2205 ,   p_assembly_item_name      IN  VARCHAR2 := NULL
2206 ,   p_alternate_bom_code      IN  VARCHAR2 := NULL
2207 ,   p_effectivity_date            IN  DATE := NULL
2208 ,   p_bom_component_tbl             IN  Bom_Bo_Pub.Bom_Comps_Tbl_Type
2209 ,   p_bom_ref_designator_tbl      IN  Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type
2210 ,   p_bom_sub_component_tbl     IN  Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type
2211 ,   p_bom_comp_ops_tbl            IN  Bom_Bo_Pub.Bom_Comp_Ops_Tbl_Type
2212 ,   x_bom_component_tbl             IN OUT NOCOPY Bom_Bo_Pub.Bom_Comps_Tbl_Type
2213 ,   x_bom_ref_designator_tbl      IN OUT NOCOPY Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type
2214 ,   x_bom_sub_component_tbl     IN OUT NOCOPY Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type
2215 ,   x_bom_comp_ops_tbl            IN OUT NOCOPY  Bom_Bo_Pub.Bom_Comp_Ops_Tbl_Type
2216 ,   x_Mesg_Token_Tbl        IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
2217 ,   x_return_status       IN OUT NOCOPY VARCHAR2
2218 )
2219 IS
2220 l_Mesg_Token_Tbl        Error_Handler.Mesg_Token_Tbl_Type;
2221 l_other_token_tbl       Error_Handler.Token_Tbl_Type;
2222 l_other_message         VARCHAR2(2000);
2223 l_err_text              VARCHAR2(2000);
2224 l_valid     BOOLEAN := TRUE;
2225 l_item_parent_exists  BOOLEAN := FALSE;
2226 l_Return_Status         VARCHAR2(1);
2227 l_bo_return_status      VARCHAR2(1);
2228 
2229 l_bom_header_rec  Bom_Bo_Pub.Bom_Head_Rec_Type;
2230 l_bom_revision_tbl  Bom_Bo_Pub.Bom_Revision_Tbl_Type;
2231 l_bom_component_rec     Bom_Bo_Pub.Bom_Comps_Rec_Type;
2232 l_bom_component_tbl     Bom_Bo_Pub.Bom_Comps_Tbl_Type := p_bom_component_tbl;
2233 l_bom_comp_unexp_rec    Bom_Bo_Pub.Bom_Comps_Unexposed_Rec_Type;
2234 l_old_bom_component_rec Bom_Bo_Pub.Bom_Comps_Rec_Type;
2235 l_old_bom_comp_unexp_rec Bom_Bo_Pub.Bom_Comps_Unexposed_Rec_Type;
2236 l_bom_ref_designator_tbl    Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type :=
2237           p_bom_ref_designator_tbl;
2238 l_bom_sub_component_tbl     Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type :=
2239           p_bom_sub_component_tbl;
2240 l_bom_comp_ops_tbl      Bom_Bo_Pub.Bom_Comp_Ops_Tbl_Type :=
2241           p_bom_comp_ops_tbl;
2242 l_return_value          NUMBER;
2243 l_process_children  BOOLEAN := TRUE;
2244 l_Token_Tbl             Error_Handler.Token_Tbl_Type;
2245 create_rec_flag    VARCHAR2(1) :='N';
2246 l_comps_processed BOOLEAN := FALSE;
2247 BEGIN
2248 
2249     --  Init local table variables.
2250 
2251     l_return_status := 'S';
2252     l_bo_return_status := 'S';
2253 
2254     l_bom_component_tbl            := p_bom_component_tbl;
2255 
2256     l_bom_comp_unexp_rec.organization_id := Bom_Globals.Get_org_id;
2257 
2258     FOR I IN 1..l_bom_component_tbl.COUNT LOOP
2259     BEGIN
2260 
2261         --  Load local records.
2262 
2263         l_bom_component_rec := l_bom_component_tbl(I);
2264 
2265   l_process_children := false;
2266 
2267   -- Initialize the unexposed record;
2268   l_bom_comp_unexp_rec := Bom_Bo_Pub.G_MISS_BOM_COMP_UNEXP_REC;
2269   l_bom_comp_unexp_rec.organization_id := Bom_Globals.Get_org_id;
2270 
2271 
2272         l_bom_component_rec.transaction_type :=
2273           UPPER(l_bom_component_rec.transaction_type);
2274 
2275         IF p_assembly_item_name IS NOT NULL AND
2276            p_organization_id IS NOT NULL
2277         THEN
2278           -- revised item parent exists
2279 
2280           l_item_parent_exists := TRUE;
2281         END IF;
2282 
2283       -- Process Flow Step 2: Check if record has not yet been processed and
2284       -- that it is the child of the parent that called this procedure
2285       --
2286 
2287       IF (l_bom_component_rec.return_status IS NULL OR
2288           l_bom_component_rec.return_status = FND_API.G_MISS_CHAR)
2289          AND
2290 
2291           -- Did Rev_Items call this procedure, that is,
2292           -- if revised item exists, then is this record a child ?
2293 
2294       (NOT l_item_parent_exists
2295        OR
2296        (l_item_parent_exists AND
2297         (l_bom_component_rec.assembly_item_name = p_assembly_item_name AND
2298          l_bom_comp_unexp_rec.organization_id = p_organization_id
2299          )
2300         )
2301        )
2302       THEN
2303          l_comps_processed := TRUE;
2304          l_return_status := FND_API.G_RET_STS_SUCCESS;
2305 
2306            l_bom_component_rec.return_status := FND_API.G_RET_STS_SUCCESS;
2307 
2308      --
2309      -- Check if transaction_type is valid
2310      --
2311 
2312      Bom_Globals.Transaction_Type_Validity
2313      (   p_transaction_type => l_bom_component_rec.transaction_type
2314      ,   p_entity   => 'Rev_Comps'
2315      ,   p_entity_id  => l_bom_component_rec.assembly_item_name
2316      ,   x_valid    => l_valid
2317      ,   x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
2318      );
2319 
2320      IF NOT l_valid
2321      THEN
2322         RAISE EXC_SEV_QUIT_RECORD;
2323      END IF;
2324 
2325      --
2326      -- Process Flow step 4(a): Convert user unique index to unique
2327      -- index I
2328      --
2329 
2330      Bom_Val_To_Id.Bom_Component_UUI_To_UI
2331     ( p_bom_component_rec  => l_bom_component_rec
2332     , p_bom_comp_unexp_rec => l_bom_comp_unexp_rec
2333     , x_bom_comp_unexp_rec => l_bom_comp_unexp_rec
2334     , x_Mesg_Token_Tbl     => l_Mesg_Token_Tbl
2335     , x_Return_Status      => l_return_status
2336     );
2337 
2338          IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('return_status: ' || l_return_status); END IF;
2339 
2340      IF l_return_status = Error_Handler.G_STATUS_ERROR
2341      THEN
2342     l_other_message := 'BOM_CMP_UUI_SEV_ERROR';
2343     l_other_token_tbl(1).token_name := 'REVISED_COMPONENT_NAME';
2344     l_other_token_tbl(1).token_value :=
2345         l_bom_component_rec.component_item_name;
2346         RAISE EXC_SEV_QUIT_BRANCH;
2347      ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
2348      THEN
2349     l_other_message := 'BOM_CMP_UUI_UNEXP_SKIP';
2350     l_other_token_tbl(1).token_name := 'REVISED_COMPONENT_NAME';
2351     l_other_token_tbl(1).token_value :=
2352       l_bom_component_rec.component_item_name;
2353     RAISE EXC_UNEXP_SKIP_OBJECT;
2354          END IF;
2355 
2356      --
2357      -- Process Flow step 4(b): Convert user unique index to unique
2358      -- index II
2359      --
2360 
2361      Bom_Val_To_Id.Bom_Component_UUI_To_UI2
2362     ( p_bom_component_rec  => l_bom_component_rec
2363     , p_bom_comp_unexp_rec => l_bom_comp_unexp_rec
2364     , x_bom_comp_unexp_rec => l_bom_comp_unexp_rec
2365     , x_Mesg_Token_Tbl     => l_Mesg_Token_Tbl
2366     , x_other_message      => l_other_message
2367     , x_other_token_tbl    => l_other_token_tbl
2368     , x_Return_Status      => l_return_status
2369     );
2370 
2371      IF l_return_status = Error_Handler.G_STATUS_ERROR
2372      THEN
2373         RAISE EXC_SEV_QUIT_SIBLINGS;
2374      ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
2375      THEN
2376     l_other_message := 'BOM_CMP_UUI_UNEXP_SKIP';
2377     l_other_token_tbl(1).token_name := 'REVISED_COMPONENT_NAME';
2378     l_other_token_tbl(1).token_value :=
2379           l_bom_component_rec.component_item_name;
2380     RAISE EXC_UNEXP_SKIP_OBJECT;
2381          END IF;
2382            Bom_Globals.Set_Unit_Controlled_Item (
2383                p_inventory_item_id => l_bom_comp_unexp_rec.assembly_item_id,
2384                p_organization_id   => l_bom_comp_unexp_rec.organization_id);
2385 
2386      --
2387      -- Process Flow step 5: Verify Revised Component's existence
2388      --
2389      Bom_Validate_Bom_Component.Check_Existence
2390       (  p_bom_component_rec    => l_bom_component_rec
2391       ,  p_bom_comp_unexp_rec   => l_bom_comp_unexp_rec
2392     ,  x_old_bom_component_rec    => l_old_bom_component_rec
2393                 ,  x_old_bom_comp_unexp_rec   => l_old_bom_comp_unexp_rec
2394           ,  x_Mesg_Token_Tbl       => l_Mesg_Token_Tbl
2395           ,  x_return_status        => l_Return_Status
2396       );
2397 
2398          IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('return_status: ' || l_return_status); END IF;
2399 
2400      IF l_return_status = Error_Handler.G_STATUS_ERROR
2401      THEN
2402     l_other_message := 'BOM_CMP_EXS_SEV_ERROR';
2403     l_other_token_tbl(1).token_name := 'REVISED_COMPONENT_NAME';
2404     l_other_token_tbl(1).token_value :=
2405         l_bom_component_rec.component_item_name;
2406         l_other_token_tbl(2).token_name := 'REVISED_ITEM_NAME';
2407     l_other_token_tbl(2).token_value :=
2408       l_bom_component_rec.assembly_item_name;
2409     RAISE EXC_SEV_QUIT_BRANCH;
2410      ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
2411      THEN
2412     l_other_message := 'BOM_CMP_EXS_UNEXP_SKIP';
2413     l_other_token_tbl(1).token_name := 'REVISED_COMPONENT_NAME';
2414     l_other_token_tbl(1).token_value :=
2415         l_bom_component_rec.component_item_name;
2416                 l_other_token_tbl(2).token_name := 'REVISED_ITEM_NAME';
2417                 l_other_token_tbl(2).token_value :=
2418       l_bom_component_rec.assembly_item_name;
2419 
2420     RAISE EXC_UNEXP_SKIP_OBJECT;
2421          END IF;
2422 
2423            /* Assign the correct transaction type for SYNC operations */
2424 
2425            IF l_bom_component_rec.transaction_type = 'SYNC' THEN
2426              l_bom_component_rec.transaction_type :=
2427                  l_old_bom_component_rec.transaction_type;
2428            END IF;
2429 
2430      -- 5a.Check for the count of components if the current transaction is CREATE
2431 
2432      IF l_bom_component_rec.transaction_type = Bom_Globals.G_OPR_CREATE
2433      THEN
2434            create_rec_flag := 'Y';
2435        END IF;
2436 
2437        IF (I = l_bom_component_tbl.COUNT AND create_rec_flag='Y')
2438        THEN
2439        -- We will check for the component count only once per bill
2440 
2441        Bom_Validate_Bom_Component.Check_ComponentCount
2442       (  p_bom_component_rec          => l_bom_component_rec
2443        , p_bom_comp_unexp_rec   => l_bom_comp_unexp_rec
2444            , x_Mesg_Token_Tbl       => l_Mesg_Token_Tbl
2445            , x_return_status        => l_Return_Status);
2446 
2447        IF l_return_status = Error_Handler.G_STATUS_ERROR
2448        THEN
2449        l_other_message := 'BOM_CMP_LIN_SEV_SKIP';
2450        l_other_token_tbl(1).token_name := 'REVISED_COMPONENT_NAME';
2451        l_other_token_tbl(1).token_value :=
2452       l_bom_component_rec.component_item_name;
2453            RAISE EXC_SEV_QUIT_BRANCH;
2454        ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
2455        THEN
2456        l_other_message := 'BOM_CMP_LIN_UNEXP_SKIP';
2457        l_other_token_tbl(1).token_name := 'REVISED_COMPONENT_NAME';
2458        l_other_token_tbl(1).token_value :=
2459       l_bom_component_rec.component_item_name;
2460        RAISE EXC_UNEXP_SKIP_OBJECT;
2461        ELSIF l_return_status ='S' AND
2462              l_Mesg_Token_Tbl.COUNT <>0
2463        THEN
2464        Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
2465        Error_Handler.Log_Error
2466       (  p_bom_component_tbl  => l_bom_component_tbl
2467       ,  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
2468       ,  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
2469       ,  p_mesg_token_tbl => l_mesg_token_tbl
2470       ,  p_error_status => 'W'
2471       ,  p_error_level  => Error_Handler.G_RC_LEVEL
2472       ,  p_entity_index => I
2473       ,  x_bom_header_rec => l_bom_header_rec
2474       ,  x_bom_revision_tbl => l_bom_revision_tbl
2475       ,  x_bom_component_tbl  => l_bom_component_tbl
2476       ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
2477       ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
2478       );
2479              Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
2480            END IF;
2481 
2482      END IF;
2483 
2484      -- Process Flow step 6: Check lineage
2485      --
2486 
2487          IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Check lineage');      END IF;
2488      Bom_Validate_Bom_Component.Check_Lineage
2489       (  p_bom_component_rec    => l_bom_component_rec
2490       ,  p_bom_comp_unexp_rec   => l_bom_comp_unexp_rec
2491           ,  x_Mesg_Token_Tbl       => l_Mesg_Token_Tbl
2492           ,  x_return_status        => l_Return_Status
2493       );
2494 
2495      IF l_return_status = Error_Handler.G_STATUS_ERROR
2496      THEN
2497        l_other_message := 'BOM_CMP_LIN_SEV_SKIP';
2498        l_other_token_tbl(1).token_name := 'REVISED_COMPONENT_NAME';
2499        l_other_token_tbl(1).token_value :=
2500       l_bom_component_rec.component_item_name;
2501            RAISE EXC_SEV_QUIT_BRANCH;
2502      ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
2503      THEN
2504        l_other_message := 'BOM_CMP_LIN_UNEXP_SKIP';
2505        l_other_token_tbl(1).token_name := 'REVISED_COMPONENT_NAME';
2506        l_other_token_tbl(1).token_value :=
2507       l_bom_component_rec.component_item_name;
2508        RAISE EXC_UNEXP_SKIP_OBJECT;
2509          END IF;
2510 
2511      -- Process Flow step 7: Is Revised Component record an orphan ?
2512 
2513      IF NOT l_item_parent_exists
2514      THEN
2515       Bom_Validate_Bom_Header.Check_Access
2516                 ( p_assembly_item_id   => l_bom_comp_unexp_rec.assembly_item_id
2517                 , p_organization_id    => l_bom_comp_unexp_rec.organization_id
2518                 , p_alternate_bom_code => l_bom_component_rec.alternate_bom_code
2519                 , x_Mesg_Token_Tbl     => l_Mesg_Token_Tbl
2520                 , x_Return_Status      => l_return_status
2521                 );
2522       IF l_return_status = Error_Handler.G_STATUS_ERROR
2523       THEN
2524       l_other_message := 'BOM_CMP_RITACC_FAT_FATAL';
2525         l_other_token_tbl(1).token_name :=
2526         'REVISED_COMPONENT_NAME';
2527         l_other_token_tbl(1).token_value :=
2528         l_bom_component_rec.component_item_name;
2529                         l_return_status := 'F';
2530       RAISE EXC_FAT_QUIT_SIBLINGS;
2531       ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
2532       THEN
2533       l_other_message := 'BOM_CMP_RITACC_UNEXP_SKIP';
2534         l_other_token_tbl(1).token_name :=
2535         'REVISED_COMPONENT_NAME';
2536         l_other_token_tbl(1).token_value :=
2537         l_bom_component_rec.component_item_name;
2538       RAISE EXC_UNEXP_SKIP_OBJECT;
2539           END IF;
2540 
2541     --
2542     -- Process Flow step: Check that user has access to Bom
2543     -- component
2544     --
2545 
2546     Bom_Validate_Bom_Component.Check_Access
2547     (  p_organization_id    =>
2548                                 l_bom_comp_unexp_rec.organization_id
2549                 ,  p_component_item_id  =>
2550                                 l_bom_comp_unexp_rec.component_item_id
2551                 ,  p_component_name     =>
2552                                 l_bom_component_rec.component_item_name
2553                 ,  x_Mesg_Token_Tbl     => l_Mesg_Token_Tbl
2554                 ,  x_return_status      => l_Return_Status
2555                 );
2556 
2557       IF l_return_status = Error_Handler.G_STATUS_ERROR
2558       THEN
2559       l_other_message := 'BOM_CMP_ACCESS_FAT_FATAL';
2560       l_other_token_tbl(1).token_name :=
2561           'REVISED_COMPONENT_NAME';
2562       l_other_token_tbl(1).token_value :=
2563         l_bom_component_rec.component_item_name;
2564                         l_return_status := 'F';
2565           RAISE EXC_FAT_QUIT_BRANCH;
2566       ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
2567       THEN
2568       l_other_message := 'BOM_CMP_ACCESS_UNEXP_SKIP';
2569       l_other_token_tbl(1).token_name :=
2570           'REVISED_COMPONENT_NAME';
2571       l_other_token_tbl(1).token_value :=
2572         l_bom_component_rec.component_item_name;
2573       RAISE EXC_UNEXP_SKIP_OBJECT;
2574           END IF;
2575 
2576      END IF;
2577 
2578      -- Process Flow step 9: Check and validate the direct items specific attributes
2579      --
2580      IF BOM_EAMUTIL.Enabled = 'Y' THEN --- checking if EAM is installed
2581      --- Check if org is eAM enabled?
2582     Bom_Validate_Bom_Component.Check_Direct_item_comps
2583     ( p_bom_component_rec       => l_bom_component_rec
2584     , p_bom_comp_unexp_rec      => l_bom_comp_unexp_rec
2585     , x_bom_component_rec       => l_bom_component_rec
2586     , x_Mesg_Token_Tbl          => l_Mesg_Token_Tbl
2587     , x_Return_Status           => l_Return_Status
2588     );
2589 
2590                 /* Commented as part of bug fix 3741040
2591     IF l_return_status = Error_Handler.G_STATUS_ERROR --- the direct item component is being
2592     THEN                                              --- tried to be added to a non-EAM BOM
2593       Error_Handler.Add_Error_Token
2594                         (  p_Message_Name       => 'BOM_DIRECT_FOR_MAINT_ONLY'
2595                          , p_Mesg_Token_Tbl     => l_Mesg_Token_Tbl
2596                          , x_Mesg_Token_Tbl     => l_Mesg_Token_Tbl
2597                          , p_Token_Tbl          => l_token_tbl
2598                         );
2599       RAISE EXC_SEV_QUIT_BRANCH;
2600     ELS
2601     */
2602     IF l_return_status ='S' AND
2603             l_Mesg_Token_Tbl.COUNT <>0
2604     THEN
2605       Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
2606       Error_Handler.Log_Error
2607       (  p_bom_component_tbl  => l_bom_component_tbl
2608       ,  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
2609       ,  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
2610       ,  p_mesg_token_tbl => l_mesg_token_tbl
2611       ,  p_error_status => 'W'
2612       ,  p_error_level  => Error_Handler.G_RC_LEVEL
2613       ,  p_entity_index => I
2614       ,  x_bom_header_rec => l_bom_header_rec
2615       ,  x_bom_revision_tbl => l_bom_revision_tbl
2616       ,  x_bom_component_tbl  => l_bom_component_tbl
2617       ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
2618       ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
2619       );
2620       Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
2621     END IF;
2622      END IF;
2623 
2624      -- Process Flow step 11: Value to Id conversions
2625      --
2626 
2627          IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Value-id conversions'); END IF;
2628      Bom_Val_To_Id.Bom_Component_VID
2629     ( x_Return_Status       => l_return_status
2630     , x_Mesg_Token_Tbl      => l_Mesg_Token_Tbl
2631     , p_bom_comp_unexp_Rec  => l_bom_comp_unexp_rec
2632     , x_bom_comp_unexp_Rec  => l_bom_comp_unexp_rec
2633     , p_bom_component_Rec   => l_bom_component_rec
2634     );
2635 
2636          IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('return_status: ' || l_return_status); END IF;
2637 
2638      IF l_return_status = Error_Handler.G_STATUS_ERROR
2639      THEN
2640         IF l_bom_component_rec.transaction_type = 'CREATE'
2641         THEN
2642       l_other_message := 'BOM_CMP_VID_CSEV_SKIP';
2643       l_other_token_tbl(1).token_name :=
2644         'REVISED_COMPONENT_NAME';
2645       l_other_token_tbl(1).token_value :=
2646         l_bom_component_rec.component_item_name;
2647       RAISE EXC_SEV_SKIP_BRANCH;
2648           ELSE
2649           RAISE EXC_SEV_QUIT_RECORD;
2650         END IF;
2651      ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
2652      THEN
2653     l_other_message := 'BOM_CMP_VID_UNEXP_SKIP';
2654     l_other_token_tbl(1).token_name :=
2655         'REVISED_COMPONENT_NAME';
2656     l_other_token_tbl(1).token_value :=
2657         l_bom_component_rec.component_item_name;
2658     RAISE EXC_UNEXP_SKIP_OBJECT;
2659      ELSIF l_return_status ='S' AND
2660           l_Mesg_Token_Tbl.COUNT <>0
2661      THEN
2662           Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
2663     Error_Handler.Log_Error
2664     (  p_bom_component_tbl  => l_bom_component_tbl
2665     ,  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
2666     ,  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
2667     ,  p_mesg_token_tbl => l_mesg_token_tbl
2668     ,  p_error_status => 'W'
2669     ,  p_error_level  => Error_Handler.G_RC_LEVEL
2670     ,  p_entity_index => I
2671     ,  x_bom_header_rec => l_bom_header_rec
2672     ,  x_bom_revision_tbl => l_bom_revision_tbl
2673     ,  x_bom_component_tbl  => l_bom_component_tbl
2674     ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
2675     ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
2676     );
2677           Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
2678          END IF;
2679 
2680      -- Process Flow step 12: Check required fields exist
2681      -- (also includes conditionally required fields)
2682      --
2683 
2684      Bom_Validate_Bom_Component.Check_Required
2685     ( x_return_status              => l_return_status
2686     , x_Mesg_Token_Tbl             => l_Mesg_Token_Tbl
2687     , p_bom_component_rec          => l_bom_component_rec
2688       );
2689 
2690      IF l_return_status = Error_Handler.G_STATUS_ERROR
2691      THEN
2692         IF l_bom_component_rec.transaction_type = 'CREATE'
2693         THEN
2694       l_other_message := 'BOM_CMP_REQ_CSEV_SKIP';
2695       l_other_token_tbl(1).token_name :=
2696           'REVISED_COMPONENT_NAME';
2697       l_other_token_tbl(1).token_value :=
2698           l_bom_component_rec.component_item_name;
2699       RAISE EXC_SEV_SKIP_BRANCH;
2700           ELSE
2701           RAISE EXC_SEV_QUIT_RECORD;
2702         END IF;
2703      ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
2704      THEN
2705     l_other_message := 'BOM_CMP_REQ_UNEXP_SKIP';
2706     l_other_token_tbl(1).token_name := 'REVISED_COMPONENT_NAME';
2707     l_other_token_tbl(1).token_value :=
2708         l_bom_component_rec.component_item_name;
2709     RAISE EXC_UNEXP_SKIP_OBJECT;
2710          END IF;
2711 
2712      --
2713      -- Process Flow step : Attribute Validation for CREATE and UPDATE
2714      --
2715 
2716      IF l_bom_component_rec.Transaction_Type IN
2717             (Bom_Globals.G_OPR_CREATE, Bom_Globals.G_OPR_UPDATE)
2718          THEN
2719     Bom_Validate_Bom_Component.Check_Attributes
2720     ( x_return_status              => l_return_status
2721     , x_Mesg_Token_Tbl             => l_Mesg_Token_Tbl
2722     , p_bom_component_rec          => l_bom_component_rec
2723     , p_bom_comp_unexp_rec         => l_bom_comp_unexp_rec
2724     );
2725 
2726       IF l_return_status = Error_Handler.G_STATUS_ERROR
2727       THEN
2728            IF l_bom_component_rec.transaction_type = 'CREATE'
2729            THEN
2730       l_other_message := 'BOM_CMP_ATTVAL_CSEV_SKIP';
2731       l_other_token_tbl(1).token_name :=
2732           'REVISED_COMPONENT_NAME';
2733       l_other_token_tbl(1).token_value :=
2734         l_bom_component_rec.component_item_name;
2735       RAISE EXC_SEV_SKIP_BRANCH;
2736              ELSE
2737           RAISE EXC_SEV_QUIT_RECORD;
2738            END IF;
2739       ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
2740       THEN
2741        l_other_message := 'BOM_CMP_ATTVAL_UNEXP_SKIP';
2742        l_other_token_tbl(1).token_name :=
2743         'REVISED_COMPONENT_NAME';
2744        l_other_token_tbl(1).token_value :=
2745         l_bom_component_rec.component_item_name;
2746        RAISE EXC_UNEXP_SKIP_OBJECT;
2747       ELSIF l_return_status ='S' AND
2748                 l_Mesg_Token_Tbl.COUNT <>0
2749       THEN
2750              Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
2751        Error_Handler.Log_Error
2752         (  p_bom_component_tbl  => l_bom_component_tbl
2753         ,  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
2754         ,  p_bom_sub_component_tbl=> l_bom_sub_component_tbl
2755         ,  p_mesg_token_tbl => l_mesg_token_tbl
2756         ,  p_error_status => 'W'
2757         ,  p_error_level  => Error_Handler.G_RC_LEVEL
2758       ,  p_entity_index => I
2759       ,  x_bom_header_rec => l_bom_header_rec
2760       ,  x_bom_revision_tbl => l_bom_revision_tbl
2761       ,  x_bom_component_tbl  => l_bom_component_tbl
2762       ,  x_bom_ref_designator_tbl=> l_bom_ref_designator_tbl
2763       ,  x_bom_sub_component_tbl=> l_bom_sub_component_tbl
2764       );
2765             Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
2766     END IF;
2767          END IF;
2768 
2769             -- Process flow step - Populate NULL columns for Update and
2770             -- Delete, and Creates with ACD_Type 'Add'.
2771 
2772       IF l_bom_component_rec.transaction_type IN
2773     (Bom_Globals.G_OPR_UPDATE, Bom_Globals.G_OPR_DELETE)
2774             THEN
2775         IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Populate NULL columns'); END IF;
2776         Bom_Default_Bom_Component.Populate_Null_Columns
2777                     (   p_bom_component_rec     => l_bom_Component_Rec
2778                     ,   p_old_bom_Component_Rec => l_old_bom_Component_Rec
2779                     ,   p_bom_comp_unexp_rec    => l_bom_comp_unexp_rec
2780                     ,   p_old_bom_comp_unexp_rec=> l_old_bom_comp_unexp_rec
2781                     ,   x_bom_Component_Rec     => l_bom_Component_Rec
2782                     ,   x_bom_comp_unexp_rec    => l_bom_comp_unexp_rec
2783                     );
2784 
2785          ELSIF l_bom_component_rec.Transaction_Type = Bom_Globals.G_OPR_CREATE
2786      THEN
2787 
2788     --
2789           -- Process Flow step : Default missing values for Operation
2790     -- CREATE
2791     --
2792 
2793           IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Attribute Defaulting'); END IF;
2794           Bom_Default_Bom_Component.Attribute_Defaulting
2795                 (   p_bom_component_rec   => l_bom_component_rec
2796                 ,   p_bom_comp_unexp_rec  => l_bom_comp_unexp_rec
2797                 ,   x_bom_component_rec   => l_bom_component_rec
2798                 ,   x_bom_comp_unexp_rec  => l_bom_comp_unexp_rec
2799                 ,   x_Mesg_Token_Tbl      => l_Mesg_Token_Tbl
2800                 ,   x_return_status   => l_return_status
2801                 );
2802 
2803           IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('return_status: ' || l_return_status); END IF;
2804 
2805     IF l_return_status = Error_Handler.G_STATUS_ERROR
2806     THEN
2807       l_other_message := 'BOM_CMP_ATTDEF_CSEV_SKIP';
2808       l_other_token_tbl(1).token_name :=
2809           'REVISED_COMPONENT_NAME';
2810       l_other_token_tbl(1).token_value :=
2811         l_bom_component_rec.component_item_name;
2812           RAISE EXC_SEV_SKIP_BRANCH;
2813     ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
2814     THEN
2815       l_other_message := 'BOM_CMP_ATTDEF_UNEXP_SKIP';
2816       l_other_token_tbl(1).token_name :=
2817           'REVISED_COMPONENT_NAME';
2818       l_other_token_tbl(1).token_value :=
2819           l_bom_component_rec.component_item_name;
2820       RAISE EXC_UNEXP_SKIP_OBJECT;
2821     ELSIF l_return_status ='S' AND
2822             l_Mesg_Token_Tbl.COUNT <>0
2823     THEN
2824             Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
2825       Error_Handler.Log_Error
2826       (  p_bom_component_tbl  => l_bom_component_tbl
2827       ,  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
2828       ,  p_bom_sub_component_tbl=> l_bom_sub_component_tbl
2829       ,  p_mesg_token_tbl => l_mesg_token_tbl
2830       ,  p_error_status => 'W'
2831       ,  p_error_level  => Error_Handler.G_RC_LEVEL
2832       ,  p_entity_index => I
2833       ,  x_bom_header_rec => l_bom_header_rec
2834       ,  x_bom_revision_tbl => l_bom_revision_tbl
2835       ,  x_bom_component_tbl  => l_bom_component_tbl
2836       ,  x_bom_ref_designator_tbl=> l_bom_ref_designator_tbl
2837       ,  x_bom_sub_component_tbl=> l_bom_sub_component_tbl
2838       );
2839             Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
2840     END IF;
2841      END IF;
2842 
2843      --
2844          -- Process Flow step 17: Entity defaulting for CREATE and UPDATE
2845          --
2846 
2847          IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Entity defaulting'); END IF;
2848      IF l_bom_component_rec.Transaction_Type IN
2849             (Bom_Globals.G_OPR_CREATE, Bom_Globals.G_OPR_UPDATE)
2850          THEN
2851     Bom_Default_Bom_Component.Entity_Defaulting
2852     (   p_bom_component_rec         => l_bom_component_rec
2853     ,   p_old_bom_component_rec     => l_old_bom_component_rec
2854     ,   x_bom_component_rec         => l_bom_component_rec
2855     );
2856 
2857     IF l_return_status = Error_Handler.G_STATUS_ERROR
2858     THEN
2859            IF l_bom_component_rec.transaction_type = 'CREATE'
2860            THEN
2861       l_other_message := 'BOM_CMP_ENTDEF_CSEV_SKIP';
2862       l_other_token_tbl(1).token_name :=
2863           'REVISED_COMPONENT_NAME';
2864       l_other_token_tbl(1).token_value :=
2865         l_bom_component_rec.component_item_name;
2866       RAISE EXC_SEV_SKIP_BRANCH;
2867              ELSE
2868           RAISE EXC_SEV_QUIT_RECORD;
2869            END IF;
2870     ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
2871     THEN
2872       l_other_message := 'BOM_CMP_ENTDEF_UNEXP_SKIP';
2873       l_other_token_tbl(1).token_name :=
2874           'REVISED_COMPONENT_NAME';
2875       l_other_token_tbl(1).token_value :=
2876         l_bom_component_rec.component_item_name;
2877       RAISE EXC_UNEXP_SKIP_OBJECT;
2878     ELSIF l_return_status ='S' AND
2879             l_Mesg_Token_Tbl.COUNT <>0
2880     THEN
2881             Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
2882       Error_Handler.Log_Error
2883       (  p_bom_component_tbl  => l_bom_component_tbl
2884       ,  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
2885       ,  p_bom_sub_component_tbl => l_bom_sub_component_tbl
2886       ,  p_mesg_token_tbl => l_mesg_token_tbl
2887       ,  p_error_status => 'W'
2888       ,  p_error_level  => Error_Handler.G_RC_LEVEL
2889       ,  p_entity_index => I
2890       ,  x_bom_header_rec => l_bom_header_rec
2891       ,  x_bom_revision_tbl => l_bom_revision_tbl
2892       ,  x_bom_component_tbl  => l_bom_component_tbl
2893       ,  x_bom_ref_designator_tbl=> l_bom_ref_designator_tbl
2894       ,  x_bom_sub_component_tbl=> l_bom_sub_component_tbl
2895       );
2896             Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
2897     END IF;
2898      END IF;
2899 
2900      --
2901          -- Process Flow step 18 - Entity Level Validation
2902      --
2903      IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Entity Defaulting completed with ' || l_return_Status || ' starting with Components entity validation . . . '); END IF;
2904 
2905          Bom_Validate_Bom_Component.Check_Entity
2906           (  p_bom_component_rec      => l_bom_component_rec
2907           ,  p_bom_comp_unexp_rec     => l_bom_comp_unexp_rec
2908           ,  p_old_bom_component_rec  => l_old_bom_component_rec
2909           ,  p_old_bom_comp_unexp_rec   => l_old_bom_comp_unexp_rec
2910           ,  x_Mesg_Token_Tbl         => l_Mesg_Token_Tbl
2911       ,  x_return_status          => l_Return_Status
2912           );
2913 
2914      IF l_return_status = Error_Handler.G_STATUS_ERROR
2915      THEN
2916         IF l_bom_component_rec.transaction_type = 'CREATE'
2917         THEN
2918       l_other_message := 'BOM_CMP_ENTVAL_CSEV_SKIP';
2919       l_other_token_tbl(1).token_name :=
2920           'REVISED_COMPONENT_NAME';
2921       l_other_token_tbl(1).token_value :=
2922           l_bom_component_rec.component_item_name;
2923       RAISE EXC_SEV_SKIP_BRANCH;
2924           ELSE
2925           RAISE EXC_SEV_QUIT_RECORD;
2926         END IF;
2927      ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
2928      THEN
2929     l_other_message := 'BOM_CMP_ENTVAL_UNEXP_SKIP';
2930     l_other_token_tbl(1).token_name := 'REVISED_COMPONENT_NAME';
2931     l_other_token_tbl(1).token_value :=
2932           l_bom_component_rec.component_item_name;
2933     RAISE EXC_UNEXP_SKIP_OBJECT;
2934      ELSIF l_return_status ='S' AND
2935           l_Mesg_Token_Tbl.COUNT <>0
2936      THEN
2937           Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
2938     Error_Handler.Log_Error
2939     (  p_bom_component_tbl  => l_bom_component_tbl
2940     ,  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
2941     ,  p_bom_sub_component_tbl => l_bom_sub_component_tbl
2942     ,  p_mesg_token_tbl => l_mesg_token_tbl
2943     ,  p_error_status => 'W'
2944     ,  p_error_level  => Error_Handler.G_RC_LEVEL
2945     ,  p_entity_index => I
2946     ,  x_bom_header_rec => l_bom_header_rec
2947     ,  x_bom_revision_tbl => l_bom_revision_tbl
2948     ,  x_bom_component_tbl  => l_bom_component_tbl
2949     ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
2950     ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
2951     );
2952           Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
2953          END IF;
2954      IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Entity validation completed with ' || l_return_Status || ' proceeding for database writes . . . '); END IF;
2955 
2956      --
2957          -- Process Flow step 16 : Database Writes
2958      --
2959          Bom_Bom_Component_Util.Perform_Writes
2960           (   p_bom_component_rec         => l_bom_component_rec
2961           ,   p_bom_comp_unexp_rec      => l_bom_comp_unexp_rec
2962           ,   x_Mesg_Token_Tbl      => l_Mesg_Token_Tbl
2963           ,   x_return_status       => l_return_status
2964           );
2965 
2966      IF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
2967      THEN
2968     l_other_message := 'BOM_CMP_WRITES_UNEXP_SKIP';
2969     l_other_token_tbl(1).token_name := 'REVISED_COMPONENT_NAME';
2970     l_other_token_tbl(1).token_value :=
2971         l_bom_component_rec.component_item_name;
2972     RAISE EXC_UNEXP_SKIP_OBJECT;
2973      ELSIF l_return_status ='S' AND
2974         l_Mesg_Token_Tbl.COUNT <>0
2975      THEN
2976           Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
2977     Error_Handler.Log_Error
2978     (  p_bom_component_tbl  => l_bom_component_tbl
2979     ,  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
2980     ,  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
2981     ,  p_mesg_token_tbl => l_mesg_token_tbl
2982     ,  p_error_status => 'W'
2983     ,  p_error_level  => Error_Handler.G_RC_LEVEL
2984     ,  p_entity_index => I
2985     ,  x_bom_header_rec     => l_bom_header_rec
2986     ,  x_bom_revision_tbl => l_bom_revision_tbl
2987     ,  x_bom_component_tbl  => l_bom_component_tbl
2988     ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
2989     ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
2990     );
2991           Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
2992          END IF;
2993 
2994     IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Database writes completed with status. . . ' || l_return_status); END IF;
2995 
2996         END IF; -- END IF statement that checks RETURN STATUS
2997 
2998         --  Load tables.
2999 
3000         l_bom_component_tbl(I)          := l_bom_component_rec;
3001 
3002   -- Indicate that children need to be processed
3003 
3004   l_process_children := TRUE;
3005 
3006     --  For loop exception handler.
3007 
3008 
3009     EXCEPTION
3010 
3011        WHEN EXC_SEV_QUIT_RECORD THEN
3012 
3013           Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
3014     Error_Handler.Log_Error
3015     (  p_bom_component_tbl  => l_bom_component_tbl
3016     ,  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
3017     ,  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
3018     ,  p_mesg_token_tbl => l_mesg_token_tbl
3019     ,  p_error_status => FND_API.G_RET_STS_ERROR
3020     ,  p_error_scope  => Error_Handler.G_SCOPE_RECORD
3021     ,  p_error_level  => Error_Handler.G_RC_LEVEL
3022     ,  p_entity_index => I
3023     ,  x_bom_header_rec     => l_bom_header_rec
3024     ,  x_bom_revision_tbl => l_bom_revision_tbl
3025     ,  x_bom_component_tbl  => l_bom_component_tbl
3026     ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
3027     ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
3028     );
3029           Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
3030 
3031   l_process_children := TRUE;
3032 
3033         IF l_bo_return_status = 'S'
3034         THEN
3035                 l_bo_return_status     := l_return_status;
3036         END IF;
3037         x_return_status                := l_bo_return_status;
3038   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
3039       x_bom_component_tbl            := l_bom_component_tbl;
3040       x_bom_ref_designator_tbl           := l_bom_ref_designator_tbl;
3041       x_bom_sub_component_tbl            := l_bom_sub_component_tbl;
3042       x_bom_comp_ops_tbl             := l_bom_comp_ops_tbl;
3043 
3044        WHEN EXC_SEV_QUIT_BRANCH THEN
3045 
3046           Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
3047     Error_Handler.Log_Error
3048     (  p_bom_component_tbl  => l_bom_component_tbl
3049     ,  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
3050     ,  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
3051     ,  p_mesg_token_tbl => l_mesg_token_tbl
3052     ,  p_error_status => Error_Handler.G_STATUS_ERROR
3053     ,  p_error_scope  => Error_Handler.G_SCOPE_CHILDREN
3054     ,  p_other_status => Error_Handler.G_STATUS_ERROR
3055     ,  p_other_message  => l_other_message
3056     ,  p_other_token_tbl  => l_other_token_tbl
3057     ,  p_error_level  => Error_Handler.G_RC_LEVEL
3058     ,  p_entity_index => I
3059     ,  x_bom_header_rec     => l_bom_header_rec
3060     ,  x_bom_revision_tbl => l_bom_revision_tbl
3061     ,  x_bom_component_tbl  => l_bom_component_tbl
3062     ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
3063     ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
3064     );
3065           Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
3066 
3067         l_process_children := FALSE;
3068 
3069         IF l_bo_return_status = 'S'
3070         THEN
3071                 l_bo_return_status     := l_return_status;
3072         END IF;
3073         x_return_status                := l_bo_return_status;
3074   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
3075       x_bom_component_tbl            := l_bom_component_tbl;
3076       x_bom_ref_designator_tbl           := l_bom_ref_designator_tbl;
3077       x_bom_sub_component_tbl            := l_bom_sub_component_tbl;
3078       x_bom_comp_ops_tbl             := l_bom_comp_ops_tbl;
3079 
3080        WHEN EXC_SEV_SKIP_BRANCH THEN
3081 
3082           Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
3083     Error_Handler.Log_Error
3084     (  p_bom_component_tbl  => l_bom_component_tbl
3085     ,  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
3086     ,  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
3087     ,  p_mesg_token_tbl => l_mesg_token_tbl
3088     ,  p_error_status => Error_Handler.G_STATUS_ERROR
3089     ,  p_error_scope  => Error_Handler.G_SCOPE_CHILDREN
3090     ,  p_other_status       => Error_Handler.G_STATUS_NOT_PICKED
3091     ,  p_other_message  => l_other_message
3092     ,  p_other_token_tbl  => l_other_token_tbl
3093     ,  p_error_level  => Error_Handler.G_RC_LEVEL
3094     ,  p_entity_index => I
3095     ,  x_bom_header_rec     => l_bom_header_rec
3096     ,  x_bom_revision_tbl => l_bom_revision_tbl
3097     ,  x_bom_component_tbl  => l_bom_component_tbl
3098     ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
3099     ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
3100     );
3101           Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
3102 
3103         l_process_children := FALSE;
3104 
3105         IF l_bo_return_status = 'S'
3106         THEN
3107                 l_bo_return_status     := l_return_status;
3108         END IF;
3109         x_return_status                := l_bo_return_status;
3110   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
3111       x_bom_component_tbl            := l_bom_component_tbl;
3112       x_bom_ref_designator_tbl           := l_bom_ref_designator_tbl;
3113       x_bom_sub_component_tbl            := l_bom_sub_component_tbl;
3114       x_bom_comp_ops_tbl             := l_bom_comp_ops_tbl;
3115 
3116        WHEN EXC_SEV_QUIT_SIBLINGS THEN
3117 
3118           Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
3119     Error_Handler.Log_Error
3120     (  p_bom_component_tbl  => l_bom_component_tbl
3121     ,  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
3122     ,  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
3123     ,  p_mesg_token_tbl => l_mesg_token_tbl
3124     ,  p_error_status => Error_Handler.G_STATUS_ERROR
3125     ,  p_error_scope  => Error_Handler.G_SCOPE_SIBLINGS
3126     ,  p_other_status => Error_Handler.G_STATUS_ERROR
3127     ,  p_other_message  => l_other_message
3128     ,  p_other_token_tbl  => l_other_token_tbl
3129     ,  p_error_level  => Error_Handler.G_RC_LEVEL
3130     ,  p_entity_index => I
3131     ,  x_bom_header_rec     => l_bom_header_rec
3132     ,  x_bom_revision_tbl => l_bom_revision_tbl
3133     ,  x_bom_component_tbl  => l_bom_component_tbl
3134     ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
3135     ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
3136     );
3137           Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
3138 
3139         l_process_children := FALSE;
3140 
3141         IF l_bo_return_status = 'S'
3142         THEN
3143                 l_bo_return_status     := l_return_status;
3144         END IF;
3145         x_return_status                := l_bo_return_status;
3146   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
3147       x_bom_component_tbl            := l_bom_component_tbl;
3148       x_bom_ref_designator_tbl           := l_bom_ref_designator_tbl;
3149       x_bom_sub_component_tbl            := l_bom_sub_component_tbl;
3150       x_bom_comp_ops_tbl             := l_bom_comp_ops_tbl;
3151 
3152        WHEN EXC_FAT_QUIT_BRANCH THEN
3153 
3154           Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
3155     Error_Handler.Log_Error
3156     (  p_bom_component_tbl  => l_bom_component_tbl
3157     ,  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
3158     ,  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
3159     ,  p_mesg_token_tbl => l_mesg_token_tbl
3160     ,  p_error_status => Error_Handler.G_STATUS_FATAL
3161     ,  p_error_scope  => Error_Handler.G_SCOPE_CHILDREN
3162     ,  p_other_status       => Error_Handler.G_STATUS_FATAL
3163                 ,  p_other_message  => l_other_message
3164     ,  p_other_token_tbl  => l_other_token_tbl
3165     ,  p_error_level  => Error_Handler.G_RC_LEVEL
3166     ,  p_entity_index => I
3167     ,  x_bom_header_rec     => l_bom_header_rec
3168     ,  x_bom_revision_tbl => l_bom_revision_tbl
3169     ,  x_bom_component_tbl  => l_bom_component_tbl
3170     ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
3171     ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
3172     );
3173           Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
3174 
3175         l_process_children := FALSE;
3176 
3177         x_return_status                := Error_Handler.G_STATUS_FATAL;
3178   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
3179       x_bom_component_tbl            := l_bom_component_tbl;
3180       x_bom_ref_designator_tbl           := l_bom_ref_designator_tbl;
3181       x_bom_sub_component_tbl            := l_bom_sub_component_tbl;
3182       x_bom_comp_ops_tbl             := l_bom_comp_ops_tbl;
3183 
3184        WHEN EXC_FAT_QUIT_SIBLINGS THEN
3185 
3186           Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
3187     Error_Handler.Log_Error
3188     (  p_bom_component_tbl  => l_bom_component_tbl
3189     ,  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
3190     ,  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
3191     ,  p_mesg_token_tbl => l_mesg_token_tbl
3192     ,  p_error_status => Error_Handler.G_STATUS_FATAL
3193     ,  p_error_scope  => Error_Handler.G_SCOPE_SIBLINGS
3194     ,  p_other_status       => Error_Handler.G_STATUS_FATAL
3195                 ,  p_other_message  => l_other_message
3196     ,  p_other_token_tbl  => l_other_token_tbl
3197     ,  p_error_level  => Error_Handler.G_RC_LEVEL
3198     ,  p_entity_index => I
3199     ,  x_bom_header_rec     => l_bom_header_rec
3200     ,  x_bom_revision_tbl => l_bom_revision_tbl
3201     ,  x_bom_component_tbl  => l_bom_component_tbl
3202     ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
3203     ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
3204     );
3205           Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
3206 
3207         l_process_children := FALSE;
3208 
3209         x_return_status                := Error_Handler.G_STATUS_FATAL;
3210   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
3211       x_bom_component_tbl            := l_bom_component_tbl;
3212       x_bom_ref_designator_tbl           := l_bom_ref_designator_tbl;
3213       x_bom_sub_component_tbl            := l_bom_sub_component_tbl;
3214       x_bom_comp_ops_tbl             := l_bom_comp_ops_tbl;
3215 
3216        WHEN EXC_FAT_QUIT_OBJECT THEN
3217 
3218           Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
3219     Error_Handler.Log_Error
3220     (  p_bom_component_tbl  => l_bom_component_tbl
3221     ,  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
3222     ,  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
3223     ,  p_mesg_token_tbl => l_mesg_token_tbl
3224     ,  p_error_status => Error_Handler.G_STATUS_FATAL
3225     ,  p_error_scope  => Error_Handler.G_SCOPE_ALL
3226     ,  p_other_status       => Error_Handler.G_STATUS_FATAL
3227                 ,  p_other_message  => l_other_message
3228     ,  p_other_token_tbl  => l_other_token_tbl
3229     ,  p_error_level  => Error_Handler.G_RC_LEVEL
3230     ,  p_entity_index => I
3231     ,  x_bom_header_rec     => l_bom_header_rec
3232     ,  x_bom_revision_tbl => l_bom_revision_tbl
3233     ,  x_bom_component_tbl  => l_bom_component_tbl
3234     ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
3235     ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
3236     );
3237           Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
3238 
3239   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
3240       x_bom_component_tbl            := l_bom_component_tbl;
3241       x_bom_ref_designator_tbl           := l_bom_ref_designator_tbl;
3242       x_bom_sub_component_tbl            := l_bom_sub_component_tbl;
3243       x_bom_comp_ops_tbl             := l_bom_comp_ops_tbl;
3244 
3245   l_return_status := 'Q';
3246 
3247        WHEN EXC_UNEXP_SKIP_OBJECT THEN
3248 
3249           Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
3250     Error_Handler.Log_Error
3251     (  p_bom_component_tbl  => l_bom_component_tbl
3252     ,  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
3253     ,  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
3254     ,  p_mesg_token_tbl => l_mesg_token_tbl
3255     ,  p_error_status => Error_Handler.G_STATUS_UNEXPECTED
3256     ,  p_other_status       => Error_Handler.G_STATUS_NOT_PICKED
3257                 ,  p_other_message  => l_other_message
3258     ,  p_other_token_tbl  => l_other_token_tbl
3259     ,  p_error_level  => Error_Handler.G_RC_LEVEL
3260     ,  x_bom_header_rec     => l_bom_header_rec
3261     ,  x_bom_revision_tbl => l_bom_revision_tbl
3262     ,  x_bom_component_tbl  => l_bom_component_tbl
3263     ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
3264     ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
3265     );
3266           Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
3267 
3268       x_bom_component_tbl            := l_bom_component_tbl;
3269       x_bom_ref_designator_tbl           := l_bom_ref_designator_tbl;
3270       x_bom_sub_component_tbl            := l_bom_sub_component_tbl;
3271       x_bom_comp_ops_tbl             := l_bom_comp_ops_tbl;
3272   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
3273 
3274   l_return_status := 'U';
3275 
3276         END; -- END block
3277 
3278   IF l_return_status in ('Q', 'U')
3279       THEN
3280           x_return_status := l_return_status;
3281           RETURN;
3282       END IF;
3283 
3284   --4306013
3285   IF( l_bom_component_tbl(I).transaction_type in ( Bom_Globals.G_OPR_UPDATE, Bom_Globals.G_OPR_CREATE )
3286       AND l_return_status = 'S')
3287   THEN
3288     G_Comp_Flag := 1;
3289   END IF;
3290 
3291    IF l_process_children
3292    THEN
3293 IF Bom_Globals.Get_Debug = 'Y' THEN
3294   Error_Handler.Write_Debug('Component processing completed, process_child true so proceeding with ref desg and then sub comps. . . ' || l_return_status); END IF;
3295 
3296   -- Process Reference Designators that are direct children of this
3297       -- component
3298 
3299       Reference_Designators
3300   (   p_validation_level      => p_validation_level
3301   ,   p_organization_id => l_bom_comp_unexp_rec.organization_id
3302   ,   p_assembly_item_name=> l_bom_component_rec.assembly_item_name
3303   ,   p_effectivity_date  => l_bom_component_rec.start_effective_date
3304   ,   p_component_item_name=> l_bom_component_rec.component_item_name
3305   ,   p_operation_seq_num => l_bom_component_rec.operation_sequence_number
3306   ,   p_bom_ref_designator_tbl=> l_bom_ref_designator_tbl
3307   ,   p_bom_sub_component_tbl=> l_bom_sub_component_tbl
3308   ,   x_bom_ref_designator_tbl=> l_bom_ref_designator_tbl
3309   ,   x_bom_sub_component_tbl=> l_bom_sub_component_tbl
3310   ,   x_Mesg_Token_Tbl  => l_Mesg_Token_Tbl
3311   ,   x_return_status => l_return_status
3312   );
3313 
3314       -- Check the quantity related validations.
3315       Bom_Validate_Ref_Designator.check_quantity
3316         ( x_return_status         => l_return_status
3317         , x_mesg_token_tbl        => l_Mesg_Token_Tbl
3318         , p_component_sequence_id => l_bom_comp_unexp_rec.component_sequence_id
3319         , p_component_item_name   => l_bom_component_rec.component_item_name
3320         );
3321       IF l_return_status = Error_Handler.G_STATUS_ERROR
3322       THEN
3323         Error_Handler.Log_Error
3324         (  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
3325         ,  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
3326         ,  p_mesg_token_tbl => l_mesg_token_tbl
3327         ,  p_error_status => Error_Handler.G_STATUS_WARNING
3328         ,  p_error_scope  => Error_Handler.G_SCOPE_RECORD
3329         ,  p_error_level  => Error_Handler.G_RC_LEVEL
3330         ,  p_entity_index => I
3331         ,  x_bom_header_rec => l_bom_header_rec
3332         ,  x_bom_revision_tbl => l_bom_revision_tbl
3333         ,  x_bom_component_tbl  => l_bom_component_tbl
3334         ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
3335         ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
3336         );
3337       END IF;
3338 
3339     -- Process Substitute Components that are direct children of this
3340       -- component
3341 
3342   Substitute_Components
3343       (   p_validation_level  => p_validation_level
3344   ,   p_organization_id => l_bom_comp_unexp_rec.organization_id
3345   ,   p_assembly_item_name=> l_bom_component_rec.assembly_item_name
3346   ,   p_effectivity_date  => l_bom_component_rec.start_effective_date
3347   ,   p_component_item_name=> l_bom_component_rec.component_item_name
3348   ,   p_operation_seq_num => l_bom_component_rec.operation_sequence_number
3349   ,   p_bom_sub_component_tbl=> l_bom_sub_component_tbl
3350   ,   x_bom_sub_component_tbl=> l_bom_sub_component_tbl
3351   ,   x_Mesg_Token_Tbl  => l_Mesg_Token_Tbl
3352   ,   x_return_status => l_return_status
3353   );
3354 
3355     -- Process Component Operations that are direct children of this
3356       -- component
3357 
3358   Component_Operations
3359       (   p_validation_level  => p_validation_level
3360   ,   p_organization_id => l_bom_comp_unexp_rec.organization_id
3361   ,   p_assembly_item_name=> l_bom_component_rec.assembly_item_name
3362   ,   p_effectivity_date  => l_bom_component_rec.start_effective_date
3363   ,   p_component_item_name=> l_bom_component_rec.component_item_name
3364   ,   p_operation_seq_num => l_bom_component_rec.operation_sequence_number
3365   ,   p_bom_comp_ops_tbl=> l_bom_comp_ops_tbl
3366   ,   x_bom_comp_ops_tbl=> l_bom_comp_ops_tbl
3367   ,   x_Mesg_Token_Tbl  => l_Mesg_Token_Tbl
3368   ,   x_return_status => l_return_status
3369   );
3370 
3371     END IF;  -- Process children
3372 
3373     END LOOP; -- END Revised Components processing loop
3374 
3375     --  Load out parameters
3376 
3377      IF NVL(l_return_status, 'S') <> 'S'
3378      THEN
3379       x_return_status     := l_return_status;
3380      END IF;
3381 
3382     /*********Business Event************/
3383      IF ( G_Comp_Flag = 1 and (Bom_Globals.Get_Bo_Identifier = Bom_Globals.G_BOM_BO)
3384          AND  l_comps_processed
3385      ) THEN
3386        Bom_Business_Event_PKG.Raise_Bill_Event(
3387         p_event_load_type          => 'Bulk'
3388       , p_request_identifier      => FND_GLOBAL.CONC_REQUEST_ID
3389       , p_batch_identifier        => BOM_GLOBALS.G_BATCH_ID
3390       , p_event_entity_name       => 'Component'
3391       , p_event_name              => Bom_Business_Event_PKG.G_STRUCTURE_MODIFIED_EVENT
3392       , p_last_update_date        => sysdate
3393       , p_last_updated_by         => fnd_global.user_id
3394       );
3395       END IF;
3396       G_Comp_Flag := 0;
3397      /*********Business Event************/
3398 
3399      x_bom_component_tbl        := l_bom_component_tbl;
3400      x_bom_ref_designator_tbl       := l_bom_ref_designator_tbl;
3401      x_bom_sub_component_tbl        := l_bom_sub_component_tbl;
3402      x_bom_comp_ops_tbl         := l_bom_comp_ops_tbl;
3403      x_Mesg_Token_Tbl     := l_Mesg_Token_Tbl;
3404 END Bom_Components;
3405 
3406 
3407 /****************************************************************************
3408 * Procedure : Bom_Revisions
3409 * Parameters IN : BOM Revision Table and all the other entities
3410 * Parameters OUT: BOM Revision Table and all the other entities
3411 * Purpose : This procedure will process all the BOM revision records.
3412 *     Although the other entities are not children of this entity
3413 *     the are taken as parameters so that the error handler could
3414 *     set the records to appropriate status if a fatal or severity
3415 *     1 error occurs.
3416 *****************************************************************************/
3417 PROCEDURE Bom_Revisions
3418 (   p_validation_level     IN  NUMBER
3419  ,  p_assembly_item_name   IN  VARCHAR2   := NULL
3420  ,  p_assembly_item_id     IN  NUMBER := NULL
3421  ,  p_organization_id      IN  NUMBER := NULL
3422  ,  p_alternate_bom_code   IN  VARCHAR2 := NULL
3423  ,  p_bom_revision_tbl     IN  Bom_Bo_Pub.Bom_Revision_Tbl_Type
3424  ,  p_bom_component_tbl    IN  Bom_Bo_Pub.Bom_Comps_Tbl_Type
3425  ,  p_bom_ref_designator_tbl   IN  Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type
3426  ,  p_bom_sub_component_tbl  IN  Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type
3427  ,  p_bom_comp_ops_tbl           IN  Bom_Bo_Pub.Bom_Comp_Ops_Tbl_Type
3428  ,  x_bom_revision_tbl       IN OUT NOCOPY Bom_Bo_Pub.Bom_Revision_Tbl_Type
3429  ,  x_bom_component_tbl    IN OUT NOCOPY Bom_Bo_Pub.Bom_Comps_Tbl_Type
3430  ,  x_bom_ref_designator_tbl   IN OUT NOCOPY Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type
3431  ,  x_bom_sub_component_tbl  IN OUT NOCOPY Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type
3432  ,  x_bom_comp_ops_tbl           IN OUT NOCOPY  Bom_Bo_Pub.Bom_Comp_Ops_Tbl_Type
3433  ,  x_Mesg_Token_Tbl     IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
3434  ,  x_return_status    IN OUT NOCOPY VARCHAR2
3435  )
3436 IS
3437 l_Mesg_Token_Tbl        Error_Handler.Mesg_Token_Tbl_Type;
3438 l_other_token_tbl       Error_Handler.Token_Tbl_Type;
3439 l_other_message         VARCHAR2(2000);
3440 l_err_text              VARCHAR2(2000);
3441 l_valid     BOOLEAN := TRUE;
3442 l_Return_Status         VARCHAR2(1);
3443 l_bo_return_status  VARCHAR2(1);
3444 l_bom_parent_exists BOOLEAN := FALSE;
3445 
3446 l_bom_header_rec  Bom_Bo_Pub.Bom_Head_Rec_Type;
3447 l_bom_header_unexp_rec  Bom_Bo_Pub.Bom_Head_Unexposed_Rec_Type;
3448 l_old_bom_header_rec  Bom_Bo_Pub.Bom_Head_Rec_Type;
3449 l_old_bom_header_unexp_rec Bom_Bo_Pub.Bom_Head_Unexposed_Rec_Type;
3450 
3451 l_bom_revision_rec      Bom_Bo_Pub.Bom_Revision_Rec_Type;
3452 l_bom_revision_tbl      Bom_Bo_Pub.Bom_Revision_Tbl_Type := p_bom_revision_tbl;
3453 l_bom_rev_unexp_rec   Bom_Bo_Pub.Bom_Rev_Unexposed_Rec_Type;
3454 l_old_bom_revision_rec  Bom_Bo_Pub.Bom_Revision_Rec_Type := NULL;
3455 l_old_bom_rev_unexp_rec Bom_Bo_Pub.Bom_Rev_Unexposed_Rec_Type := NULL;
3456 
3457 l_bom_component_tbl     Bom_Bo_Pub.Bom_Comps_Tbl_Type := p_bom_component_tbl;
3458 l_bom_ref_designator_tbl Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type
3459           := p_bom_ref_designator_tbl;
3460 l_bom_sub_component_tbl     Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type
3461           := p_bom_sub_component_tbl;
3462 l_bom_comp_ops_tbl      Bom_Bo_Pub.Bom_Comp_Ops_Tbl_Type
3463           := p_bom_comp_ops_tbl;
3464 l_return_value          NUMBER;
3465 l_Token_Tbl             Error_Handler.Token_Tbl_Type;
3466 
3467 BEGIN
3468 
3469 
3470     l_return_status := 'S';
3471     l_bo_return_status := 'S';
3472 
3473     --  Init local table variables.
3474 
3475     l_bom_revision_tbl             := p_bom_revision_tbl;
3476 
3477     l_bom_rev_unexp_rec.organization_id := Bom_Globals.Get_org_id;
3478 
3479     FOR I IN 1..l_bom_revision_tbl.COUNT LOOP
3480     BEGIN
3481 
3482         --  Load local records.
3483 
3484         l_bom_revision_rec := l_bom_revision_tbl(I);
3485 
3486         l_bom_revision_rec.transaction_type :=
3487           UPPER(l_bom_revision_rec.transaction_type);
3488 
3489         IF p_assembly_item_name IS NOT NULL AND
3490            p_organization_id IS NOT NULL
3491         THEN
3492           l_bom_parent_exists := TRUE;
3493         END IF;
3494 
3495   --
3496       -- Process Flow Step 2: Check if record has not yet been processed and
3497       -- that it is the child of the parent that called this procedure
3498       --
3499 
3500       IF (l_bom_revision_rec.return_status IS NULL OR
3501           l_bom_revision_rec.return_status = FND_API.G_MISS_CHAR)
3502          AND
3503          (NOT l_bom_parent_exists
3504           OR
3505           (l_bom_parent_exists AND
3506         ( l_bom_revision_rec.assembly_item_name = p_assembly_item_name AND
3507           l_bom_rev_unexp_rec.organization_id = p_organization_id AND
3508     NVL(l_bom_revision_rec.alternate_bom_code, 'NONE') =
3509     NVL(p_alternate_bom_code, 'NONE')
3510          )
3511        )
3512       )
3513       THEN
3514 
3515          l_return_status := FND_API.G_RET_STS_SUCCESS;
3516 
3517            l_bom_revision_rec.return_status := FND_API.G_RET_STS_SUCCESS;
3518 
3519      --
3520      -- Check if transaction_type is valid
3521      --
3522 
3523      Bom_Globals.Transaction_Type_Validity
3524      (   p_transaction_type   => l_bom_revision_rec.transaction_type
3525      ,   p_entity     => 'Bom_Rev'
3526      ,   p_entity_id    => l_bom_revision_rec.revision
3527      ,   x_valid      => l_valid
3528      ,   x_Mesg_Token_Tbl     => l_Mesg_Token_Tbl
3529      );
3530 
3531      IF NOT l_valid
3532      THEN
3533                 l_return_status := Error_Handler.G_STATUS_ERROR;
3534         RAISE EXC_SEV_QUIT_RECORD;
3535      END IF;
3536 
3537      --
3538      -- Process Flow step 4: Verify that Revision is not NULL or MISSING
3539      --
3540      Bom_Validate_Bom_Revision.Check_Required
3541     (  x_return_status    => l_return_status
3542     ,  p_bom_revision_rec   => l_bom_revision_rec
3543     ,  x_mesg_token_tbl   => l_Mesg_Token_Tbl
3544     );
3545 
3546            IF l_return_status = Error_Handler.G_STATUS_ERROR
3547            THEN
3548                 RAISE EXC_SEV_QUIT_RECORD;
3549            ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
3550            THEN
3551     l_other_message := 'BOM_REV_KEYCOL_UNEXP_SKIP';
3552                 l_other_token_tbl(1).token_name := 'REVISION';
3553                 l_other_token_tbl(1).token_value := l_bom_revision_rec.revision;
3554                 RAISE EXC_UNEXP_SKIP_OBJECT;
3555      END IF;
3556 
3557 
3558      --
3559      -- Process Flow Step: 5 Convert User Unique Index
3560      --
3561      Bom_Val_To_Id.Bom_Revision_UUI_To_UI2
3562      (  p_bom_revision_rec  => l_bom_revision_rec
3563       , p_bom_rev_unexp_rec => l_bom_rev_unexp_rec
3564       , x_bom_rev_unexp_rec => l_bom_rev_unexp_rec
3565       , x_mesg_token_tbl    => l_mesg_token_tbl
3566       , x_return_status   => l_return_status
3567       );
3568       IF l_return_status = FND_API.G_RET_STS_ERROR
3569       THEN
3570     l_other_message := 'BOM_REV_UUI_SEV_ERROR';
3571     l_other_token_tbl(1).token_name := 'REVISION';
3572     l_other_token_tbl(1).token_value := l_bom_revision_rec.revision;
3573     l_other_token_tbl(2).token_name := 'ASSEMBLY_ITEM_NAME';
3574     l_other_token_tbl(2).token_value := l_bom_revision_rec.assembly_item_name;
3575     RAISE EXC_SEV_QUIT_OBJECT;
3576             ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
3577             THEN
3578                  l_other_message := 'BOM_REV_UUI_UNEXP_SKIP';
3579                  l_other_token_tbl(1).token_name := 'REVISION';
3580                  l_other_token_tbl(1).token_value :=
3581                       l_bom_revision_rec.revision;
3582                  RAISE EXC_UNEXP_SKIP_OBJECT;
3583       END IF;
3584 
3585            -- Verify Bom Header's existence in database.
3586      -- If revision is being created and the business object does not
3587      -- carry the BOM header, then it is imperative to check for the
3588      -- BOM Header's existence
3589 
3590            IF l_bom_revision_rec.transaction_type = Bom_Globals.G_OPR_CREATE
3591               AND
3592               NOT l_bom_parent_exists
3593            THEN
3594     l_bom_header_rec.alternate_bom_code := p_alternate_bom_code;
3595     l_bom_header_unexp_rec.organization_id := p_organization_id;
3596     l_bom_header_unexp_rec.assembly_item_id := p_assembly_item_id;
3597     l_bom_header_rec.transaction_type := 'XXX';
3598 
3599                 Bom_Validate_Bom_Header.Check_Existence
3600     ( p_bom_header_rec  => l_bom_header_rec
3601     , p_bom_head_unexp_rec  => l_bom_header_unexp_rec
3602                 , x_old_bom_header_rec  => l_old_bom_header_rec
3603                 , x_old_bom_head_unexp_rec=> l_old_bom_header_unexp_rec
3604                 , x_Mesg_Token_Tbl      => l_Mesg_Token_Tbl
3605                 , x_return_status       => l_Return_Status
3606                 );
3607                 IF l_return_status = Error_Handler.G_STATUS_ERROR
3608                 THEN
3609                    l_other_message := 'BOM_BOM_HEADER_NOT_EXIST';
3610                    l_other_token_tbl(1).token_name := 'ASSEMBLY_ITEM_NAME';
3611                    l_other_token_tbl(1).token_value :=
3612           l_bom_revision_rec.assembly_item_name;
3613                    l_other_token_tbl(2).token_name := 'ORGANIZATION_CODE';
3614                    l_other_token_tbl(2).token_value :=
3615           l_bom_revision_rec.organization_code;
3616                    RAISE EXC_SEV_QUIT_OBJECT;
3617                 ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
3618                 THEN
3619                    l_other_message := 'BOM_REV_LIN_UNEXP_SKIP';
3620                    l_other_token_tbl(1).token_name := 'REVISION';
3621                    l_other_token_tbl(1).token_value :=
3622             l_bom_revision_rec.revision;
3623                    RAISE EXC_UNEXP_SKIP_OBJECT;
3624                 END IF;
3625            END IF;
3626 
3627            /* Assign the correct transaction type for SYNC operations */
3628 
3629            IF l_bom_header_rec.transaction_type = 'SYNC' THEN
3630              l_bom_header_rec.transaction_type :=
3631                  l_old_bom_header_rec.transaction_type;
3632            END IF;
3633 
3634      --
3635      -- Process Flow step 5: Verify Revision's existence
3636      --
3637      Bom_Validate_Bom_Revision.Check_Existence
3638       (  p_bom_revision_rec     => l_bom_revision_rec
3639       ,  p_bom_rev_unexp_rec    => l_bom_rev_unexp_rec
3640     ,  x_old_bom_revision_rec     => l_old_bom_revision_rec
3641                 ,  x_old_bom_rev_unexp_rec  => l_old_bom_rev_unexp_rec
3642           ,  x_Mesg_Token_Tbl       => l_Mesg_Token_Tbl
3643           ,  x_return_status        => l_Return_Status
3644       );
3645 
3646      IF l_return_status = Error_Handler.G_STATUS_ERROR
3647      THEN
3648         RAISE EXC_SEV_QUIT_RECORD;
3649      ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
3650      THEN
3651                 l_other_message := 'BOM_REV_EXS_UNEXP_SKIP';
3652                 l_other_token_tbl(1).token_name := 'REVISION';
3653                 l_other_token_tbl(1).token_value := l_bom_revision_rec.revision;
3654     RAISE EXC_UNEXP_SKIP_OBJECT;
3655          END IF;
3656 
3657            /* Assign the correct transaction type for SYNC operations */
3658 
3659            IF l_bom_revision_rec.transaction_type = 'SYNC' THEN
3660              l_bom_revision_rec.transaction_type :=
3661                  l_old_bom_revision_rec.transaction_type;
3662            END IF;
3663 
3664 
3665      -- Process Flow step 5: Is Revision record an orphan ?
3666 
3667      IF NOT l_bom_parent_exists
3668      THEN
3669 
3670     Bom_Validate_Bom_Header.Check_Access
3671     ( p_assembly_item_id  => l_bom_rev_unexp_rec.assembly_item_id
3672     , p_organization_id => l_bom_rev_unexp_rec.organization_id
3673     , p_alternate_bom_code  => l_bom_revision_rec.alternate_bom_code
3674     , x_Mesg_Token_Tbl      => l_Mesg_Token_Tbl
3675     , x_Return_Status       => l_return_status
3676     );
3677 
3678       IF l_return_status = Error_Handler.G_STATUS_ERROR
3679       THEN
3680       l_other_message := 'BOM_REV_BOMACC_FAT_FATAL';
3681       l_other_token_tbl(1).token_name := 'REVISION';
3682       l_other_token_tbl(1).token_value :=
3683             l_bom_revision_rec.revision;
3684                         l_return_status := 'F';
3685           RAISE EXC_FAT_QUIT_OBJECT;
3686       ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
3687       THEN
3688       l_other_message := 'BOM_REV_ACCESS_UNEXP_ERROR';
3689       l_other_token_tbl(1).token_name := 'REVISION';
3690       l_other_token_tbl(1).token_value :=
3691             l_bom_revision_rec.revision;
3692       RAISE EXC_UNEXP_SKIP_OBJECT;
3693           END IF;
3694 
3695      END IF;
3696 
3697      IF l_bom_revision_rec.Transaction_Type IN
3698             (Bom_Globals.G_OPR_UPDATE, Bom_Globals.G_OPR_DELETE)
3699          THEN
3700 
3701           -- Process flow step 7 - Populate NULL columns for Update and
3702           -- Delete.
3703 
3704     Bom_Default_Bom_Revision.Populate_NULL_Columns
3705                 (   p_bom_revision_rec    => l_bom_revision_rec
3706                 ,   p_bom_rev_unexp_rec   => l_bom_rev_unexp_rec
3707                 ,   p_old_bom_revision_rec    => l_old_bom_revision_rec
3708                 ,   p_old_bom_rev_unexp_rec   => l_old_bom_rev_unexp_rec
3709                 ,   x_bom_revision_rec    => l_bom_revision_rec
3710                 ,   x_bom_rev_unexp_rec   => l_bom_rev_unexp_rec
3711                 );
3712 
3713          ELSIF l_bom_revision_rec.Transaction_Type = Bom_Globals.G_OPR_CREATE
3714      THEN
3715 
3716     --
3717           -- Process Flow step 8: Default missing values for Operation
3718     -- CREATE
3719     --
3720       NULL;
3721     /*
3722     ** There is not attribute defualting for BOM Revisions
3723     */
3724 
3725      END IF;
3726 
3727      --
3728          -- Process Flow step 10 - Entity Level Validation
3729      --
3730 
3731          Bom_Validate_Bom_Revision.Check_Entity
3732           (  x_return_status        => l_Return_Status
3733           ,  x_Mesg_Token_Tbl       => l_Mesg_Token_Tbl
3734           ,  p_bom_revision_rec     => l_bom_revision_rec
3735           ,  p_bom_rev_unexp_rec    => l_bom_rev_unexp_rec
3736     ,  p_old_bom_revision_rec => l_old_bom_revision_rec
3737     ,  p_old_bom_rev_unexp_rec=> l_old_bom_rev_unexp_rec
3738           );
3739 
3740      IF l_return_status = Error_Handler.G_STATUS_ERROR
3741      THEN
3742         RAISE EXC_SEV_QUIT_RECORD;
3743      ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
3744      THEN
3745     l_other_message := 'BOM_REV_ENTVAL_UNEXP_ERROR';
3746     l_other_token_tbl(1).token_name := 'REVISION';
3747     l_other_token_tbl(1).token_value := l_bom_revision_rec.revision;
3748     RAISE EXC_UNEXP_SKIP_OBJECT;
3749          END IF;
3750 
3751      --
3752          -- Process Flow step 11 : Database Writes
3753      --
3754          Bom_Bom_Revision_Util.Perform_Writes
3755           (   p_bom_revision_rec          => l_bom_revision_rec
3756           ,   p_bom_rev_unexp_rec     => l_bom_rev_unexp_rec
3757           ,   x_Mesg_Token_Tbl      => l_Mesg_Token_Tbl
3758           ,   x_return_status       => l_return_status
3759           );
3760 
3761      IF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
3762      THEN
3763     l_other_message := 'BOM_REV_WRITES_UNEXP_ERROR';
3764     l_other_token_tbl(1).token_name := 'REVISION';
3765     l_other_token_tbl(1).token_value := l_bom_revision_rec.revision;
3766     RAISE EXC_UNEXP_SKIP_OBJECT;
3767          END IF;
3768 
3769         END IF;
3770   -- End IF that checks RETURN STATUS AND PARENT-CHILD RELATIONSHIP
3771 
3772         --  Load tables.
3773 
3774         l_bom_revision_tbl(I)          := l_bom_revision_rec;
3775 
3776         --  For loop exception handler.
3777      EXCEPTION
3778 
3779        WHEN EXC_SEV_QUIT_RECORD THEN
3780           Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
3781     Error_Handler.Log_Error
3782     (  p_bom_revision_tbl => l_bom_revision_tbl
3783     ,  p_bom_component_tbl  => l_bom_component_tbl
3784     ,  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
3785     ,  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
3786     ,  p_mesg_token_tbl => l_mesg_token_tbl
3787     ,  p_error_status => FND_API.G_RET_STS_ERROR
3788     ,  p_error_scope  => Error_Handler.G_SCOPE_RECORD
3789     ,  p_error_level  => Error_Handler.G_REV_LEVEL
3790     ,  p_entity_index => I
3791     ,  x_bom_header_rec => l_bom_header_rec
3792     ,  x_bom_revision_tbl => l_bom_revision_tbl
3793     ,  x_bom_component_tbl  => l_bom_component_tbl
3794     ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
3795     ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
3796     );
3797           Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
3798 
3799 
3800         IF l_bo_return_status = 'S'
3801   THEN
3802     l_bo_return_status     := l_return_status;
3803   END IF;
3804   x_return_status          := l_bo_return_status;
3805   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
3806       x_bom_revision_tbl             := l_bom_revision_tbl;
3807       x_bom_component_tbl            := l_bom_component_tbl;
3808       x_bom_ref_designator_tbl       := l_bom_ref_designator_tbl;
3809       x_bom_sub_component_tbl        := l_bom_sub_component_tbl;
3810       x_bom_comp_ops_tbl             := l_bom_comp_ops_tbl;
3811 
3812         WHEN EXC_SEV_QUIT_OBJECT THEN
3813 
3814             Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
3815             Error_Handler.Log_Error
3816             (  p_bom_revision_tbl     => l_bom_revision_tbl
3817              , p_bom_component_tbl      => l_bom_component_tbl
3818              , p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
3819              , p_bom_sub_component_tbl  => l_bom_sub_component_tbl
3820              , p_mesg_token_tbl       => l_mesg_token_tbl
3821              , p_error_status           => Error_Handler.G_STATUS_ERROR
3822              , p_error_scope            => Error_Handler.G_SCOPE_ALL
3823              --, p_error_level            => Error_Handler.G_BO_LEVEL
3824              , p_error_level            => Error_Handler.G_REV_LEVEL	-- BUG 5368107
3825              , p_other_message          => l_other_message
3826              , p_other_status           => Error_Handler.G_STATUS_ERROR
3827              , p_other_token_tbl        => l_other_token_tbl
3828              , x_bom_header_rec         => l_bom_header_rec
3829              , x_bom_revision_tbl       => l_bom_revision_tbl
3830              , x_bom_component_tbl      => l_bom_component_tbl
3831              , x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
3832              , x_bom_sub_component_tbl  => l_bom_sub_component_tbl
3833              );
3834             Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
3835 
3836         IF l_bo_return_status = 'S'
3837         THEN
3838                 l_bo_return_status     := l_return_status;
3839         END IF;
3840         x_return_status                := l_bo_return_status;
3841         x_Mesg_Token_Tbl               := l_Mesg_Token_Tbl;
3842         x_bom_revision_tbl             := l_bom_revision_tbl;
3843         x_bom_component_tbl            := l_bom_component_tbl;
3844         x_bom_ref_designator_tbl       := l_bom_ref_designator_tbl;
3845         x_bom_sub_component_tbl        := l_bom_sub_component_tbl;
3846       x_bom_comp_ops_tbl             := l_bom_comp_ops_tbl;
3847 
3848        WHEN EXC_FAT_QUIT_OBJECT THEN
3849 
3850           Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
3851     Error_Handler.Log_Error
3852             (  p_bom_revision_tbl       => l_bom_revision_tbl
3853              , p_bom_component_tbl      => l_bom_component_tbl
3854              , p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
3855              , p_bom_sub_component_tbl  => l_bom_sub_component_tbl
3856        , p_mesg_token_tbl         => l_mesg_token_tbl
3857              , p_error_status           => Error_Handler.G_STATUS_FATAL
3858              , p_error_scope            => Error_Handler.G_SCOPE_ALL
3859              , p_error_level            => Error_Handler.G_REV_LEVEL
3860              , p_other_message          => l_other_message
3861              , p_other_status           => Error_Handler.G_STATUS_FATAL
3862              , p_other_token_tbl        => l_other_token_tbl
3863              , x_bom_header_rec         => l_bom_header_rec
3864              , x_bom_revision_tbl       => l_bom_revision_tbl
3865              , x_bom_component_tbl      => l_bom_component_tbl
3866              , x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
3867              , x_bom_sub_component_tbl  => l_bom_sub_component_tbl
3868              );
3869             Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
3870 
3871   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
3872       x_bom_revision_tbl             := l_bom_revision_tbl;
3873       x_bom_component_tbl            := l_bom_component_tbl;
3874       x_bom_ref_designator_tbl       := l_bom_ref_designator_tbl;
3875       x_bom_sub_component_tbl        := l_bom_sub_component_tbl;
3876       x_bom_comp_ops_tbl             := l_bom_comp_ops_tbl;
3877 
3878   l_return_status := 'Q';
3879 
3880        WHEN EXC_UNEXP_SKIP_OBJECT THEN
3881 
3882             Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
3883             Error_Handler.Log_Error
3884             (  p_bom_revision_tbl       => l_bom_revision_tbl
3885              , p_bom_component_tbl      => l_bom_component_tbl
3886              , p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
3887              , p_bom_sub_component_tbl  => l_bom_sub_component_tbl
3888              , p_mesg_token_tbl         => l_mesg_token_tbl
3889        , p_error_status           => Error_Handler.G_STATUS_UNEXPECTED
3890              , p_error_scope            => Error_Handler.G_SCOPE_ALL
3891              , p_error_level            => Error_Handler.G_REV_LEVEL
3892              , p_other_message          => l_other_message
3893              , p_other_status           => Error_Handler.G_STATUS_NOT_PICKED
3894              , p_other_token_tbl        => l_other_token_tbl
3895              , x_bom_header_rec         => l_bom_header_rec
3896              , x_bom_revision_tbl       => l_bom_revision_tbl
3897              , x_bom_component_tbl      => l_bom_component_tbl
3898              , x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
3899              , x_bom_sub_component_tbl  => l_bom_sub_component_tbl
3900              );
3901              Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
3902         IF l_bo_return_status = 'S'
3903         THEN
3904                 l_bo_return_status     := l_return_status;
3905         END IF;
3906         x_return_status                := l_bo_return_status;
3907   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
3908       x_bom_revision_tbl             := l_bom_revision_tbl;
3909       x_bom_component_tbl            := l_bom_component_tbl;
3910       x_bom_ref_designator_tbl       := l_bom_ref_designator_tbl;
3911       x_bom_sub_component_tbl        := l_bom_sub_component_tbl;
3912       x_bom_comp_ops_tbl             := l_bom_comp_ops_tbl;
3913 
3914   l_return_status := 'U';
3915 
3916         END; -- END block
3917 
3918      END LOOP; -- END Revisions processing loop
3919 
3920     IF l_return_status in ('Q', 'U')
3921     THEN
3922         x_return_status := l_return_status;
3923         RETURN;
3924     END IF;
3925 
3926      --  Load out parameters
3927 
3928      x_return_status          := l_bo_return_status;
3929      x_bom_revision_tbl         := l_bom_revision_tbl;
3930      x_bom_component_tbl        := l_bom_component_tbl;
3931      x_bom_ref_designator_tbl   := l_bom_ref_designator_tbl;
3932      x_bom_sub_component_tbl    := l_bom_sub_component_tbl;
3933      x_bom_comp_ops_tbl         := l_bom_comp_ops_tbl;
3934      x_Mesg_Token_Tbl     := l_Mesg_Token_Tbl;
3935 
3936 END Bom_Revisions;
3937 
3938 /***************************************************************************
3939 * Procedure : Bom_Header (Unexposed)
3940 * Parameters IN : Bom Header Record and all the child entities
3941 * Parameters OUT: Bom Header Record and all the child entities
3942 * Purpose : This procedure will validate and perform the appropriate
3943 *     action on the BOM Header record.
3944 *     It will process the entities that are children of this header.
3945 ***************************************************************************/
3946 
3947 PROCEDURE Bom_Header
3948 (   p_validation_level              IN  NUMBER
3949 ,   p_bom_header_rec                IN  Bom_Bo_Pub.Bom_Head_Rec_Type
3950 ,   p_bom_revision_tbl        IN  Bom_Bo_Pub.Bom_Revision_Tbl_Type
3951 ,   p_bom_component_tbl       IN  Bom_Bo_Pub.Bom_Comps_Tbl_Type
3952 ,   p_bom_ref_designator_tbl      IN  Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type
3953 ,   p_bom_sub_component_tbl     IN  Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type
3954 ,   p_bom_comp_ops_tbl              IN  Bom_Bo_Pub.Bom_Comp_Ops_Tbl_Type
3955 ,   x_bom_header_rec                IN OUT NOCOPY Bom_Bo_Pub.Bom_Head_Rec_Type
3956 ,   x_bom_revision_tbl              IN OUT NOCOPY Bom_Bo_Pub.Bom_Revision_Tbl_Type
3957 ,   x_bom_component_tbl             IN OUT NOCOPY Bom_Bo_Pub.Bom_Comps_Tbl_Type
3958 ,   x_bom_ref_designator_tbl        IN OUT NOCOPY Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type
3959 ,   x_bom_sub_component_tbl         IN OUT NOCOPY Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type
3960 ,   x_bom_comp_ops_tbl              IN OUT NOCOPY  Bom_Bo_Pub.Bom_Comp_Ops_Tbl_Type
3961 ,   x_Mesg_Token_Tbl        IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
3962 ,   x_return_status       IN OUT NOCOPY VARCHAR2
3963 )
3964 IS
3965 
3966 l_Mesg_Token_Tbl        Error_Handler.Mesg_Token_Tbl_Type;
3967 l_other_token_tbl       Error_Handler.Token_Tbl_Type;
3968 l_other_message         VARCHAR2(50);
3969 l_err_text              VARCHAR2(2000);
3970 l_valid     BOOLEAN := TRUE;
3971 l_Return_Status         VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
3972 l_bo_return_status  VARCHAR2(1) := 'S';
3973 
3974 l_bom_header_rec        Bom_Bo_Pub.Bom_Head_Rec_Type;
3975 l_old_bom_header_rec  Bom_Bo_Pub.Bom_Head_Rec_Type;
3976 l_old_bom_header_unexp_rec Bom_Bo_Pub.Bom_Head_Unexposed_Rec_Type;
3977 l_bom_header_Unexp_Rec  Bom_Bo_Pub.Bom_Head_Unexposed_Rec_Type;
3978 
3979 l_bom_revision_tbl      Bom_Bo_Pub.Bom_Revision_Tbl_Type := p_bom_revision_tbl;
3980 l_bom_component_tbl     Bom_Bo_Pub.Bom_Comps_Tbl_Type := p_bom_component_tbl;
3981 l_bom_ref_designator_tbl    Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type :=
3982         p_bom_ref_designator_tbl;
3983 l_bom_sub_component_tbl     Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type :=
3984         p_bom_sub_component_tbl;
3985 l_bom_comp_ops_tbl      Bom_Bo_Pub.Bom_Comp_Ops_Tbl_Type :=
3986         p_bom_comp_ops_tbl;
3987 l_return_value          NUMBER;
3988 l_Token_Tbl             Error_Handler.Token_Tbl_Type;
3989 
3990 BEGIN
3991 
3992   -- Begin block that processes header.
3993   -- This block holds the exception handlers for header errors.
3994 
3995     BEGIN
3996 
3997       --  Load entity and record-specific details into system_information
3998   -- record
3999 
4000       l_bom_header_Unexp_rec.organization_id := Bom_Globals.Get_Org_Id;
4001 
4002 
4003       l_bom_header_rec := p_bom_header_rec;
4004         l_bom_header_rec.transaction_type :=
4005         UPPER(l_bom_header_rec.transaction_type);
4006 
4007         -- Process Flow Step 2: Check if record has not yet been processed
4008         --
4009 
4010         IF l_bom_header_rec.return_status IS NOT NULL AND
4011            l_bom_header_rec.return_status <> FND_API.G_MISS_CHAR
4012         THEN
4013                 x_return_status                := l_return_status;
4014                 x_bom_header_rec               := l_bom_header_rec;
4015                 x_bom_revision_tbl             := l_bom_revision_tbl;
4016                 x_bom_component_tbl            := l_bom_component_tbl;
4017                 x_bom_ref_designator_tbl       := l_bom_ref_designator_tbl;
4018                 x_bom_sub_component_tbl        := l_bom_sub_component_tbl;
4019                 RETURN;
4020         END IF;
4021 
4022         l_return_status := FND_API.G_RET_STS_SUCCESS;
4023   l_bom_header_rec.return_status := FND_API.G_RET_STS_SUCCESS;
4024 
4025   --
4026   -- Process Flow Step 3: Check if transaction_type is valid
4027   --
4028 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Bom Header: Transaction Type Validity . . . '); END IF;
4029 
4030   Bom_Globals.Transaction_Type_Validity
4031   (   p_transaction_type  => l_bom_header_rec.transaction_type
4032   ,   p_entity    => 'Bom_Header'
4033   ,   p_entity_id   => l_bom_header_rec.assembly_item_name
4034   ,   x_valid   => l_valid
4035   ,   x_Mesg_Token_Tbl    => l_Mesg_Token_Tbl
4036   );
4037 
4038   IF NOT l_valid
4039   THEN
4040         l_return_status := Error_Handler.G_STATUS_ERROR;
4041     RAISE EXC_SEV_QUIT_RECORD;
4042   END IF;
4043 
4044 
4045   --
4046   -- Process Flow Step 4: Convert User Unique Index to Unique Index
4047   --
4048 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Bom Header: UUI-"UI Conversion . . .'); END IF;
4049 
4050   Bom_Val_To_Id.BOM_Header_UUI_To_UI
4051   (  p_bom_header_rec   => l_bom_header_rec
4052    , p_bom_header_unexp_rec => l_bom_header_unexp_rec
4053    , x_bom_header_unexp_rec => l_bom_header_unexp_rec
4054    , x_return_status    => l_return_status
4055    , x_mesg_token_tbl   => l_mesg_token_tbl
4056   );
4057         IF l_return_status = Error_Handler.G_STATUS_ERROR
4058         THEN
4059                 l_other_message := 'BOM_BOM_UUI_SEV_ERROR';
4060                 l_other_token_tbl(1).token_name := 'ASSEMBLY_ITEM_NAME';
4061                 l_other_token_tbl(1).token_value :=
4062                                         l_bom_header_rec.assembly_item_name;
4063                 RAISE EXC_SEV_QUIT_BRANCH;
4064         ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
4065         THEN
4066                 l_other_message := 'BOM_BOM_UUI_UNEXP_SKIP';
4067                 l_other_token_tbl(1).token_name := 'ASSEMBLY_ITEM_NAME';
4068                 l_other_token_tbl(1).token_value :=
4069                                         l_bom_header_rec.assembly_item_name;
4070                 RAISE EXC_UNEXP_SKIP_OBJECT;
4071         END IF;
4072 
4073   --
4074       -- Process Flow step 5: Verify Bom Header's existence
4075       --
4076 
4077 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Bom Header: Check Existence . . .'); END IF;
4078 
4079       Bom_Validate_Bom_Header.Check_Existence
4080         (   p_bom_header_rec  => l_bom_header_rec
4081     , p_bom_head_unexp_rec=> l_bom_header_unexp_rec
4082     , x_old_bom_header_rec  => l_old_bom_header_rec
4083     , x_old_bom_head_unexp_rec=> l_old_bom_header_unexp_rec
4084                 , x_Mesg_Token_Tbl  => l_Mesg_Token_Tbl
4085                 , x_return_status => l_Return_Status
4086                 );
4087 
4088   IF l_return_status = Error_Handler.G_STATUS_ERROR
4089   THEN
4090     l_other_message := 'BOM_BOM_EXS_SEV_ERROR';
4091     l_other_token_tbl(1).token_name := 'ASSEMBLY_ITEM_NAME';
4092     l_other_token_tbl(1).token_value :=
4093           l_bom_header_rec.assembly_item_name;
4094     RAISE EXC_SEV_QUIT_BRANCH;
4095   ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
4096   THEN
4097     l_other_message := 'BOM_BOM_EXS_UNEXP_SKIP';
4098     l_other_token_tbl(1).token_name := 'ASSEMBLY_ITEM_NAME';
4099     l_other_token_tbl(1).token_value :=
4100           l_bom_header_rec.assembly_item_name;
4101     RAISE EXC_UNEXP_SKIP_OBJECT;
4102   END IF;
4103 
4104         /* Assign the correct transaction type for SYNC operations */
4105 
4106         IF l_bom_header_rec.transaction_type = 'SYNC' THEN
4107           l_bom_header_rec.transaction_type :=
4108                  l_old_bom_header_rec.transaction_type;
4109         END IF;
4110 
4111 
4112   --
4113   -- Process Flow Step:6 Check Access to the Bill Item's Bom Item Type
4114   --
4115 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Bom Header: Check Access . . .'); END IF;
4116 
4117   Bom_Validate_Bom_Header.Check_Access
4118   (  p_assembly_item_id => l_bom_header_unexp_rec.assembly_item_id
4119    , p_alternate_bom_code => l_bom_header_rec.alternate_bom_code
4120    , p_organization_id  => l_bom_header_unexp_rec.organization_id
4121    , p_mesg_token_tbl => l_mesg_token_tbl
4122    , x_mesg_token_tbl => l_mesg_token_tbl
4123    , x_return_status  => l_return_status
4124    );
4125         IF l_return_status = Error_Handler.G_STATUS_ERROR
4126         THEN
4127                 l_other_message := 'BOM_BOM_ACC_SEV_ERROR';
4128                 l_other_token_tbl(1).token_name := 'ASSEMBLY_ITEM_NAME';
4129                 l_other_token_tbl(1).token_value :=
4130                                         l_bom_header_rec.assembly_item_name;
4131                 RAISE EXC_SEV_QUIT_BRANCH;
4132         ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
4133         THEN
4134                 l_other_message := 'BOM_BOM_ACC_UNEXP_SKIP';
4135                 l_other_token_tbl(1).token_name := 'ASSEMBLY_ITEM_NAME';
4136                 l_other_token_tbl(1).token_value :=
4137                                         l_bom_header_rec.assembly_item_name;
4138                 RAISE EXC_UNEXP_SKIP_OBJECT;
4139         END IF;
4140 
4141   --
4142   -- Process Flow Step: 7 Value to ID Conversion
4143   --
4144 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Bom Header: Value-Id Conversion . . .'); END IF;
4145       Bom_Val_To_Id.Bom_Header_VID
4146         (  x_Return_Status    => l_return_status
4147         ,  x_Mesg_Token_Tbl   => l_Mesg_Token_Tbl
4148         ,  p_bom_header_rec   => l_bom_header_rec
4149         ,  p_bom_head_unexp_rec  => l_bom_header_unexp_rec
4150         ,  x_bom_head_unexp_rec  => l_bom_header_unexp_rec
4151         );
4152   IF l_return_status = Error_Handler.G_STATUS_ERROR
4153   THEN
4154       IF l_bom_header_rec.transaction_type = 'CREATE'
4155       THEN
4156     l_other_message := 'BOM_BOM_VID_CSEV_SKIP';
4157     l_other_token_tbl(1).token_name := 'ASSEMBLY_ITEM_NAME';
4158     l_other_token_tbl(1).token_value :=
4159           l_bom_header_rec.assembly_item_name;
4160     RAISE EXC_SEV_SKIP_BRANCH;
4161       ELSE
4162         RAISE EXC_SEV_QUIT_RECORD;
4163       END IF;
4164   ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
4165   THEN
4166     l_other_message := 'BOM_BOM_VID_UNEXP_SKIP';
4167     l_other_token_tbl(1).token_name := 'ASSEMBLY_ITEM_NAME';
4168     l_other_token_tbl(1).token_value :=
4169           l_bom_header_rec.assembly_item_name;
4170     RAISE EXC_UNEXP_SKIP_OBJECT;
4171   ELSIF l_return_status ='S' AND
4172         l_Mesg_Token_Tbl.COUNT <>0
4173   THEN
4174           Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
4175     Error_Handler.Log_Error
4176     (  p_bom_header_rec   => l_bom_header_rec
4177     ,  p_bom_revision_tbl   => l_bom_revision_tbl
4178     ,  p_bom_component_tbl    => l_bom_component_tbl
4179     ,  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
4180     ,  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
4181     ,  p_mesg_token_tbl   => l_mesg_token_tbl
4182     ,  p_error_status   => 'W'
4183     ,  p_error_level    => Error_Handler.G_BH_LEVEL
4184     ,  x_bom_header_rec   => l_bom_header_rec
4185     ,  x_bom_revision_tbl   => l_bom_revision_tbl
4186     ,  x_bom_component_tbl    => l_bom_component_tbl
4187     ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
4188     ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
4189     );
4190           Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
4191   END IF;
4192 
4193   --
4194       -- Process Flow step 8: Attribute Validation for Create and Update
4195       --
4196 
4197       IF l_bom_header_rec.transaction_type IN
4198         (Bom_Globals.G_OPR_UPDATE, Bom_Globals.G_OPR_CREATE)
4199       THEN
4200 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Bom Header: Check Attributes . . .'); END IF;
4201 
4202           Bom_Validate_Bom_Header.Check_Attributes
4203                 (   x_return_status            => l_return_status
4204                 ,   x_Mesg_Token_Tbl           => l_Mesg_Token_Tbl
4205                 ,   p_bom_header_rec           => l_bom_header_rec
4206                 ,   p_bom_head_unexp_rec     => l_bom_header_unexp_rec
4207                 ,   p_old_bom_header_rec       => l_Old_bom_header_rec
4208                 ,   p_old_bom_head_unexp_rec => l_Old_bom_header_unexp_rec
4209                 );
4210 
4211     IF l_return_status = Error_Handler.G_STATUS_ERROR
4212     THEN
4213           IF l_bom_header_rec.transaction_type = 'CREATE'
4214           THEN
4215         l_other_message := 'BOM_BOM_ATTVAL_CSEV_SKIP';
4216         l_other_token_tbl(1).token_name
4217             := 'ASSEMBLY_ITEM_NAME';
4218         l_other_token_tbl(1).token_value :=
4219           l_bom_header_rec.assembly_item_name;
4220         RAISE EXC_SEV_SKIP_BRANCH;
4221           ELSE
4222             RAISE EXC_SEV_QUIT_RECORD;
4223           END IF;
4224     ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
4225     THEN
4226       l_other_message := 'BOM_BOM_ATTVAL_UNEXP_SKIP';
4227       l_other_token_tbl(1).token_name
4228         := 'ASSEMBLY_ITEM_NAME';
4229       l_other_token_tbl(1).token_value
4230         := l_bom_header_rec.assembly_item_name;
4231 
4232       RAISE EXC_UNEXP_SKIP_OBJECT;
4233     ELSIF l_return_status ='S' AND
4234             l_Mesg_Token_Tbl.COUNT <>0
4235     THEN
4236             Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
4237       Error_Handler.Log_Error
4238                    (  p_bom_header_rec        => l_bom_header_rec
4239                    ,  p_bom_revision_tbl      => l_bom_revision_tbl
4240                    ,  p_bom_component_tbl     => l_bom_component_tbl
4241                    ,  p_bom_ref_designator_tbl=> l_bom_ref_designator_tbl
4242                    ,  p_bom_sub_component_tbl => l_bom_sub_component_tbl
4243                    ,  p_mesg_token_tbl        => l_mesg_token_tbl
4244                    ,  p_error_status          => 'W'
4245                    ,  p_error_level           => Error_Handler.G_BH_LEVEL
4246                    ,  x_bom_header_rec        => l_bom_header_rec
4247                    ,  x_bom_revision_tbl      => l_bom_revision_tbl
4248                    ,  x_bom_component_tbl     => l_bom_component_tbl
4249                    ,  x_bom_ref_designator_tbl=> l_bom_ref_designator_tbl
4250                    ,  x_bom_sub_component_tbl => l_bom_sub_component_tbl
4251                    );
4252             Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
4253     END IF;
4254       END IF;
4255 
4256   --
4257   -- Process Flow Step:9
4258   -- If the Transaction Type is Update/Delete, then Populate_Null_Columns
4259   -- Else Attribute_Defaulting
4260   --
4261       IF l_bom_header_rec.Transaction_Type IN
4262            (Bom_Globals.G_OPR_UPDATE, Bom_Globals.G_OPR_DELETE)
4263       THEN
4264 
4265    --
4266          -- Process flow step 9 - Populate NULL columns for Update and
4267          -- Delete.
4268    --
4269 
4270 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Bom Header:  Populate Null Columns . . .'); END IF;
4271 
4272           Bom_Default_Bom_Header.Populate_NULL_Columns
4273                 (   p_bom_header_rec      => l_bom_header_rec
4274                 ,   p_bom_head_unexp_rec  => l_bom_header_unexp_rec
4275                 ,   p_Old_bom_header_rec  => l_Old_bom_header_rec
4276                 ,   p_Old_bom_head_unexp_rec  => l_Old_bom_header_unexp_rec
4277                 ,   x_bom_header_rec    => l_bom_header_rec
4278                 ,   x_bom_head_unexp_rec  => l_bom_header_unexp_rec
4279                 );
4280 
4281      ELSIF l_bom_header_rec.Transaction_Type = Bom_Globals.G_OPR_CREATE THEN
4282 
4283    --
4284          -- Process Flow step 9: Default missing values for Operation CREATE
4285    --
4286 
4287 IF Bom_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Bom Header: Attribute Defaulting . . .'); END IF;
4288 
4289           Bom_Default_Bom_Header.Attribute_Defaulting
4290                 (   p_bom_header_rec      => l_bom_header_rec
4291                 ,   p_bom_head_unexp_rec  => l_bom_header_unexp_rec
4292                 ,   x_bom_header_rec      => l_bom_header_rec
4293                 ,   x_bom_head_unexp_rec  => l_bom_header_unexp_rec
4294                 ,   x_Mesg_Token_Tbl      => l_Mesg_Token_Tbl
4295                 ,   x_return_status       => l_Return_Status
4296                 );
4297 
4298   IF l_return_status = Error_Handler.G_STATUS_ERROR
4299   THEN
4300       IF l_bom_header_rec.transaction_type = 'CREATE'
4301       THEN
4302     l_other_message := 'BOM_BOM_ATTDEF_CSEV_SKIP';
4303     l_other_token_tbl(1).token_name := 'ASSEMBLY_ITEM_NAME';
4304     l_other_token_tbl(1).token_value :=
4305           l_bom_header_rec.assembly_item_name;
4306     RAISE EXC_SEV_SKIP_BRANCH;
4307       ELSE
4308         RAISE EXC_SEV_QUIT_RECORD;
4309       END IF;
4310   ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
4311   THEN
4312     l_other_message := 'BOM_BOM_ATTDEF_UNEXP_SKIP';
4313     l_other_token_tbl(1).token_name := 'ASSEMBLY_ITEM_NAME';
4314     l_other_token_tbl(1).token_value :=
4315           l_bom_header_rec.assembly_item_name;
4316     RAISE EXC_UNEXP_SKIP_OBJECT;
4317   ELSIF l_return_status ='S' AND
4318         l_Mesg_Token_Tbl.COUNT <>0
4319   THEN
4320           Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
4321     Error_Handler.Log_Error
4322                 (  p_bom_header_rec        => l_bom_header_rec
4323                 ,  p_bom_revision_tbl      => l_bom_revision_tbl
4324                 ,  p_bom_component_tbl     => l_bom_component_tbl
4325                 ,  p_bom_ref_designator_tbl=> l_bom_ref_designator_tbl
4326                 ,  p_bom_sub_component_tbl => l_bom_sub_component_tbl
4327                 ,  p_mesg_token_tbl        => l_mesg_token_tbl
4328                 ,  p_error_status          => 'W'
4329                 ,  p_error_level           => Error_Handler.G_BH_LEVEL
4330                 ,  x_bom_header_rec        => l_bom_header_rec
4331                 ,  x_bom_revision_tbl      => l_bom_revision_tbl
4332                 ,  x_bom_component_tbl     => l_bom_component_tbl
4333                 ,  x_bom_ref_designator_tbl=> l_bom_ref_designator_tbl
4334                 ,  x_bom_sub_component_tbl => l_bom_sub_component_tbl
4335                 );
4336           Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
4337   END IF;
4338      END IF;
4339 
4340   --
4341   -- Process Flow step 10 - Check Conditionally Required Fields
4342   --
4343 
4344       Bom_Validate_Bom_Header.Check_Required
4345         (   x_return_status       => l_return_status
4346         ,   x_Mesg_Token_Tbl      => l_Mesg_Token_Tbl
4347         ,   p_bom_header_rec      => l_bom_header_rec
4348   );
4349 
4350      IF l_return_status = Error_Handler.G_STATUS_ERROR
4351      THEN
4352   IF l_bom_header_rec.transaction_type = Bom_Globals.G_OPR_CREATE
4353   THEN
4354     l_other_message := 'BOM_BOM_CONREQ_CSEV_SKIP';
4355     l_other_token_tbl(1).token_name := 'ASSEMBLY_ITEM_NAME';
4356     l_other_token_tbl(1).token_value :=
4357           l_bom_header_rec.assembly_item_name;
4358     RAISE EXC_SEV_SKIP_BRANCH;
4359         ELSE
4360         RAISE EXC_SEV_QUIT_RECORD;
4361   END IF;
4362      ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
4363      THEN
4364   l_other_message := 'BOM_BOM_CONREQ_UNEXP_SKIP';
4365   l_other_token_tbl(1).token_name := 'ASSEMBLY_ITEM_NAME';
4366   l_other_token_tbl(1).token_value := l_bom_header_rec.assembly_item_name;
4367   RAISE EXC_UNEXP_SKIP_OBJECT;
4368      ELSIF l_return_status ='S' AND
4369      l_Mesg_Token_Tbl.COUNT <>0
4370      THEN
4371           Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
4372     Error_Handler.Log_Error
4373     (  p_bom_header_rec        => l_bom_header_rec
4374                 ,  p_bom_revision_tbl      => l_bom_revision_tbl
4375                 ,  p_bom_component_tbl     => l_bom_component_tbl
4376                 ,  p_bom_ref_designator_tbl=> l_bom_ref_designator_tbl
4377                 ,  p_bom_sub_component_tbl => l_bom_sub_component_tbl
4378                 ,  p_mesg_token_tbl        => l_mesg_token_tbl
4379                 ,  p_error_status          => 'W'
4380                 ,  p_error_level           => Error_Handler.G_BH_LEVEL
4381                 ,  x_bom_header_rec        => l_bom_header_rec
4382                 ,  x_bom_revision_tbl      => l_bom_revision_tbl
4383                 ,  x_bom_component_tbl     => l_bom_component_tbl
4384                 ,  x_bom_ref_designator_tbl=> l_bom_ref_designator_tbl
4385                 ,  x_bom_sub_component_tbl => l_bom_sub_component_tbl
4386                 );
4387           Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
4388      END IF;
4389 
4390   --
4391   -- Process Flow step 11 - Entity Level Defaulting
4392   --
4393   -- BOM Header does not have any entity level defaulting.
4394 
4395   --
4396   -- Process Flow step 12 - Entity Level Validation
4397   --
4398 
4399 --  IF l_bom_header_rec.transaction_type <> ENG_Globals.G_OPR_DELETE
4400   IF l_bom_header_rec.transaction_type <> 'DELETE'
4401   THEN
4402         Bom_Validate_Bom_Header.Check_Entity
4403           (  x_return_status        => l_Return_Status
4404           ,  x_Mesg_Token_Tbl       => l_Mesg_Token_Tbl
4405           ,  p_bom_header_rec       => l_bom_header_rec
4406           ,  p_bom_head_unexp_rec => l_bom_header_unexp_rec
4407           ,  p_old_bom_head_rec   => l_bom_header_rec
4408           ,  p_old_bom_head_unexp_rec => l_old_bom_header_unexp_rec
4409           );
4410   ELSE
4411                 Bom_Validate_Bom_Header.Check_Entity_Delete
4412                 ( x_return_status       => l_return_status
4413                 , x_Mesg_Token_Tbl      => l_mesg_token_tbl
4414                 , p_bom_header_rec    => l_bom_header_rec
4415                 , p_bom_head_Unexp_Rec  => l_bom_header_unexp_rec
4416     , x_bom_head_unexp_rec  => l_bom_header_unexp_rec
4417                 );
4418   END IF;
4419         IF l_return_status = Error_Handler.G_STATUS_ERROR
4420         THEN
4421                 IF l_bom_header_rec.transaction_type = Bom_Globals.G_OPR_CREATE
4422                 THEN
4423                 l_other_message := 'BOM_BOM_CHECKENT_CSEV_SKIP';
4424                 l_other_token_tbl(1).token_name := 'ASSEMBLY_ITEM_NAME';
4425                 l_other_token_tbl(1).token_value :=
4426                                         l_bom_header_rec.assembly_item_name;
4427                         RAISE EXC_SEV_SKIP_BRANCH;
4428                 ELSE
4429                         RAISE EXC_SEV_QUIT_RECORD;
4430                 END IF;
4431      ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
4432      THEN
4433         l_other_message := 'BOM_BOM_CHKENT_UNEXP_SKIP';
4434         l_other_token_tbl(1).token_name := 'ASSEMBLY_ITEM_NAME';
4435         l_other_token_tbl(1).token_value := l_bom_header_rec.assembly_item_name;
4436         RAISE EXC_UNEXP_SKIP_OBJECT;
4437      ELSIF l_return_status ='S' AND
4438            l_Mesg_Token_Tbl.COUNT <>0
4439      THEN
4440           Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
4441                 Error_Handler.Log_Error
4442                 (  p_bom_header_rec        => l_bom_header_rec
4443                 ,  p_bom_revision_tbl      => l_bom_revision_tbl
4444                 ,  p_bom_component_tbl     => l_bom_component_tbl
4445                 ,  p_bom_ref_designator_tbl=> l_bom_REF_DEsignator_tbl
4446                 ,  p_bom_sub_component_tbl => l_bom_sub_component_tbl
4447                 ,  p_mesg_token_tbl        => l_mesg_token_tbl
4448                 ,  p_error_status          => 'W'
4449                 ,  p_error_level           => Error_Handler.G_BH_LEVEL
4450                 ,  x_bom_header_rec        => l_bom_header_rec
4451                 ,  x_bom_revision_tbl      => l_bom_revision_tbl
4452                 ,  x_bom_component_tbl     => l_bom_component_tbl
4453                 ,  x_bom_ref_designator_tbl=> l_bom_ref_designator_tbl
4454                 ,  x_bom_sub_component_tbl => l_bom_sub_component_tbl
4455                 );
4456           Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
4457      END IF;
4458 
4459   --
4460   -- Process Flow step 13 : Database Writes
4461   --
4462       G_Bill_Seq_Id := l_bom_header_unexp_rec.bill_sequence_id;
4463 
4464       Bom_Bom_Header_Util.Perform_Writes
4465         (   p_bom_header_rec    => l_bom_header_rec
4466         ,   p_bom_head_unexp_rec  => l_bom_header_unexp_rec
4467         ,   x_Mesg_Token_Tbl    => l_Mesg_Token_Tbl
4468         ,   x_return_status   => l_return_status
4469         );
4470 
4471      IF l_bom_header_unexp_rec.source_bill_sequence_id <>
4472                                 nvl(l_bom_header_unexp_rec.common_bill_sequence_id, l_bom_header_unexp_rec.bill_sequence_id)
4473      THEN
4474      --Replicate component.
4475       BOMPCMBM.Replicate_Components(
4476                           p_src_bill_sequence_id   => l_bom_header_unexp_rec.source_bill_sequence_id,
4477                           p_dest_bill_sequence_id  => l_bom_header_unexp_rec.bill_sequence_id,
4478                           x_Mesg_Token_Tbl => l_Mesg_Token_Tbl,
4479                           x_Return_Status => l_return_status);
4480       IF l_return_status = Error_Handler.G_STATUS_ERROR
4481       THEN
4482       --arudresh_debug('error -> BOM_UNIT_COMM_NO_EDIT');
4483         /*l_other_message := 'BOM_UNIT_COMM_NO_EDIT';
4484         l_other_token_tbl(1).token_name := null;
4485         l_other_token_tbl(1).token_value := null;*/
4486         RAISE EXC_SEV_SKIP_BRANCH;
4487       END IF;
4488 
4489      END iF;
4490 
4491 
4492      IF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
4493      THEN
4494   l_other_message := 'BOM_BOM_WRITES_UNEXP_SKIP';
4495   l_other_token_tbl(1).token_name := 'ASSEMBLY_ITEM_NAME';
4496   l_other_token_tbl(1).token_value :=
4497         l_bom_header_rec.assembly_item_name;
4498   RAISE EXC_UNEXP_SKIP_OBJECT;
4499      ELSIF l_return_status ='S' AND
4500      l_Mesg_Token_Tbl.COUNT <>0
4501      THEN
4502           Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
4503     Error_Handler.Log_Error
4504                 (  p_bom_header_rec        => l_bom_header_rec
4505                 ,  p_bom_revision_tbl      => l_bom_revision_tbl
4506                 ,  p_bom_component_tbl     => l_bom_component_tbl
4507                 ,  p_bom_ref_designator_tbl=> l_bom_ref_designator_tbl
4508                 ,  p_bom_sub_component_tbl => l_bom_sub_component_tbl
4509                 ,  p_mesg_token_tbl        => l_mesg_token_tbl
4510                 ,  p_error_status          => 'W'
4511                 ,  p_error_level           => Error_Handler.G_BH_LEVEL
4512                 ,  x_bom_header_rec        => l_bom_header_rec
4513                 ,  x_bom_revision_tbl      => l_bom_revision_tbl
4514                 ,  x_bom_component_tbl     => l_bom_component_tbl
4515                 ,  x_bom_ref_designator_tbl=> l_bom_ref_designator_tbl
4516                 ,  x_bom_sub_component_tbl => l_bom_sub_component_tbl
4517                 );
4518           Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
4519      END IF;
4520 
4521   EXCEPTION
4522 
4523     WHEN EXC_SEV_QUIT_RECORD THEN
4524 
4525           Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
4526     Error_Handler.Log_Error
4527                 (  p_bom_header_rec        => l_bom_header_rec
4528                 ,  p_bom_revision_tbl      => l_bom_revision_tbl
4529                 ,  p_bom_component_tbl     => l_bom_component_tbl
4530                 ,  p_bom_ref_designator_tbl=> l_bom_ref_designator_tbl
4531                 ,  p_bom_sub_component_tbl => l_bom_sub_component_tbl
4532     ,  p_mesg_token_tbl    => l_mesg_token_tbl
4533     ,  p_error_status    => FND_API.G_RET_STS_ERROR
4534     ,  p_error_scope     => Error_Handler.G_SCOPE_RECORD
4535     ,  p_error_level     => Error_Handler.G_BH_LEVEL
4536                 ,  x_bom_header_rec        => l_bom_header_rec
4537                 ,  x_bom_revision_tbl      => l_bom_revision_tbl
4538                 ,  x_bom_component_tbl     => l_bom_component_tbl
4539                 ,  x_bom_ref_designator_tbl=> l_bom_ref_designator_tbl
4540                 ,  x_bom_sub_component_tbl => l_bom_sub_component_tbl
4541 
4542     );
4543           Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
4544 
4545         x_return_status          := l_return_status;
4546   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
4547       x_bom_header_rec               := l_bom_header_rec;
4548       x_bom_revision_tbl             := l_bom_revision_tbl;
4549       x_bom_component_tbl            := l_bom_component_tbl;
4550       x_bom_ref_designator_tbl       := l_bom_ref_designator_tbl;
4551       x_bom_sub_component_tbl        := l_bom_sub_component_tbl;
4552       x_bom_comp_ops_tbl             := l_bom_comp_ops_tbl;
4553 
4554        WHEN EXC_SEV_QUIT_BRANCH THEN
4555 
4556           Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
4557           Error_Handler.Log_Error
4558                 (  p_bom_header_rec         => l_bom_header_rec
4559                 ,  p_bom_revision_tbl       => l_bom_revision_tbl
4560                 ,  p_bom_component_tbl      => l_bom_component_tbl
4561                 ,  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
4562                 ,  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
4563                 ,  p_mesg_token_tbl         => l_mesg_token_tbl
4564                 ,  p_error_status           => Error_Handler.G_STATUS_ERROR
4565                 ,  p_error_scope            => Error_Handler.G_SCOPE_CHILDREN
4566                 ,  p_other_status           => Error_Handler.G_STATUS_ERROR
4567                 ,  p_other_message          => l_other_message
4568                 ,  p_other_token_tbl        => l_other_token_tbl
4569                 ,  p_error_level            => Error_Handler.G_BH_LEVEL
4570                 ,  x_bom_header_rec         => l_bom_header_rec
4571                 ,  x_bom_revision_tbl       => l_bom_revision_tbl
4572                 ,  x_bom_component_tbl      => l_bom_component_tbl
4573                 ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
4574                 ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
4575                 );
4576           Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
4577 
4578         x_return_status                := l_return_status;
4579         x_Mesg_Token_Tbl               := l_Mesg_Token_Tbl;
4580         x_bom_header_rec               := l_bom_header_rec;
4581         x_bom_revision_tbl             := l_bom_revision_tbl;
4582         x_bom_component_tbl            := l_bom_component_tbl;
4583         x_bom_ref_designator_tbl       := l_bom_ref_designator_tbl;
4584         x_bom_sub_component_tbl        := l_bom_sub_component_tbl;
4585       x_bom_comp_ops_tbl             := l_bom_comp_ops_tbl;
4586 
4587   RETURN;
4588 
4589     WHEN EXC_SEV_SKIP_BRANCH THEN
4590 
4591           Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
4592     Error_Handler.Log_Error
4593     (  p_bom_header_rec         => l_bom_header_rec
4594                 ,  p_bom_revision_tbl       => l_bom_revision_tbl
4595                 ,  p_bom_component_tbl      => l_bom_component_tbl
4596                 ,  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
4597                 ,  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
4598     ,  p_mesg_token_tbl => l_mesg_token_tbl
4599     ,  p_error_status => Error_Handler.G_STATUS_ERROR
4600     ,  p_error_scope  => Error_Handler.G_SCOPE_CHILDREN
4601     ,  p_other_message  => l_other_message
4602     ,  p_other_token_tbl  => l_other_token_tbl
4603     ,  p_other_status       => Error_Handler.G_STATUS_NOT_PICKED
4604     ,  p_error_level  => Error_Handler.G_BH_LEVEL
4605                 ,  x_bom_header_rec         => l_bom_header_rec
4606                 ,  x_bom_revision_tbl       => l_bom_revision_tbl
4607                 ,  x_bom_component_tbl      => l_bom_component_tbl
4608                 ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
4609                 ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
4610     );
4611           Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
4612 
4613         x_return_status          := l_return_status;
4614   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
4615         x_bom_header_rec               := l_bom_header_rec;
4616         x_bom_revision_tbl             := l_bom_revision_tbl;
4617         x_bom_component_tbl            := l_bom_component_tbl;
4618         x_bom_ref_designator_tbl       := l_bom_ref_designator_tbl;
4619         x_bom_sub_component_tbl        := l_bom_sub_component_tbl;
4620       x_bom_comp_ops_tbl             := l_bom_comp_ops_tbl;
4621 
4622   RETURN;
4623 
4624     WHEN EXC_FAT_QUIT_OBJECT THEN
4625 
4626           Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
4627     Error_Handler.Log_Error
4628                 (  p_bom_header_rec         => l_bom_header_rec
4629                 ,  p_bom_revision_tbl       => l_bom_revision_tbl
4630                 ,  p_bom_component_tbl      => l_bom_component_tbl
4631                 ,  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
4632                 ,  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
4633     ,  p_mesg_token_tbl => l_mesg_token_tbl
4634     ,  p_error_status => Error_Handler.G_STATUS_FATAL
4635     ,  p_error_scope  => Error_Handler.G_SCOPE_ALL
4636     ,  p_other_message  => l_other_message
4637                 ,  p_other_status       => Error_Handler.G_STATUS_FATAL
4638     ,  p_other_token_tbl  => l_other_token_tbl
4639     ,  p_error_level  => Error_Handler.G_BH_LEVEL
4640                 ,  x_bom_header_rec         => l_bom_header_rec
4641                 ,  x_bom_revision_tbl       => l_bom_revision_tbl
4642                 ,  x_bom_component_tbl      => l_bom_component_tbl
4643                 ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
4644                 ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
4645 
4646     );
4647           Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
4648 
4649   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
4650         x_bom_header_rec               := l_bom_header_rec;
4651         x_bom_revision_tbl             := l_bom_revision_tbl;
4652         x_bom_component_tbl            := l_bom_component_tbl;
4653         x_bom_ref_designator_tbl       := l_bom_ref_designator_tbl;
4654         x_bom_sub_component_tbl        := l_bom_sub_component_tbl;
4655       x_bom_comp_ops_tbl             := l_bom_comp_ops_tbl;
4656 
4657   l_return_status := 'Q';
4658 
4659     WHEN EXC_UNEXP_SKIP_OBJECT THEN
4660 
4661           Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
4662     Error_Handler.Log_Error
4663                 (  p_bom_header_rec         => l_bom_header_rec
4664                 ,  p_bom_revision_tbl       => l_bom_revision_tbl
4665                 ,  p_bom_component_tbl      => l_bom_component_tbl
4666                 ,  p_bom_ref_designator_tbl => l_bom_ref_designator_tbl
4667                 ,  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
4668     ,  p_mesg_token_tbl => l_mesg_token_tbl
4669     ,  p_error_status => Error_Handler.G_STATUS_UNEXPECTED
4670     ,  p_other_status       => Error_Handler.G_STATUS_NOT_PICKED
4671                 ,  p_other_message  => l_other_message
4672     ,  p_other_token_tbl  => l_other_token_tbl
4673     ,  p_error_level  => Error_Handler.G_BH_LEVEL
4674                 ,  x_bom_header_rec         => l_bom_header_rec
4675                 ,  x_bom_revision_tbl       => l_bom_revision_tbl
4676                 ,  x_bom_component_tbl      => l_bom_component_tbl
4677                 ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
4678                 ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
4679     );
4680           Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
4681 
4682         x_return_status          := l_return_status;
4683   x_Mesg_Token_Tbl         := l_Mesg_Token_Tbl;
4684         x_bom_header_rec               := l_bom_header_rec;
4685         x_bom_revision_tbl             := l_bom_revision_tbl;
4686         x_bom_component_tbl            := l_bom_component_tbl;
4687         x_bom_ref_designator_tbl       := l_bom_ref_designator_tbl;
4688         x_bom_sub_component_tbl        := l_bom_sub_component_tbl;
4689       x_bom_comp_ops_tbl             := l_bom_comp_ops_tbl;
4690 
4691   l_return_status := 'U';
4692 
4693   END; -- END Header processing block
4694 
4695     IF l_return_status in ('Q', 'U')
4696     THEN
4697     x_return_status := l_return_status;
4698   RETURN;
4699     END IF;
4700 
4701     l_bo_return_status := l_return_status;
4702 
4703   --
4704   -- Process BOM Revisions that are chilren of this header
4705   --
4706 
4707   Bom_Revisions
4708       (   p_validation_level      => p_validation_level
4709       ,   p_assembly_item_name    => l_bom_header_rec.assembly_item_name
4710       ,   p_organization_id     => l_bom_header_unexp_rec.organization_id
4711   ,   p_alternate_bom_code    => l_bom_header_rec.alternate_bom_code
4712       ,   p_bom_revision_tbl      => l_bom_revision_tbl
4713         ,   p_bom_component_tbl     => l_bom_component_tbl
4714         ,   p_bom_ref_designator_tbl=> l_bom_ref_designator_tbl
4715         ,   p_bom_sub_component_tbl => l_bom_sub_component_tbl
4716         ,   p_bom_comp_ops_tbl      => l_bom_comp_ops_tbl
4717       ,   x_bom_revision_tbl      => l_bom_revision_tbl
4718       ,   x_bom_component_tbl     => l_bom_component_tbl
4719       ,   x_bom_ref_designator_tbl=> l_bom_ref_designator_tbl
4720       ,   x_bom_sub_component_tbl => l_bom_sub_component_tbl
4721         ,   x_bom_comp_ops_tbl      => l_bom_comp_ops_tbl
4722       ,   x_Mesg_Token_Tbl      => l_Mesg_Token_Tbl
4723       ,   x_return_status       => l_return_status
4724       );
4725     IF l_return_status <> 'S'
4726     THEN
4727   l_bo_return_status := l_return_status;
4728     END IF;
4729 
4730     -- Process Components that are orphans (without immediate revised
4731     -- item parents) but are indirect children of this header
4732 
4733       Bom_Components
4734   (   p_validation_level      => p_validation_level
4735         ,   p_assembly_item_name    => l_bom_header_rec.assembly_item_name
4736         ,   p_organization_id       => l_bom_header_unexp_rec.organization_id
4737         ,   p_alternate_bom_code    => l_bom_header_rec.alternate_bom_code
4738         ,   p_bom_component_tbl     => l_bom_component_tbl
4739         ,   p_bom_ref_designator_tbl=> l_bom_ref_designator_tbl
4740         ,   p_bom_sub_component_tbl => l_bom_sub_component_tbl
4741         ,   p_bom_comp_ops_tbl      => l_bom_comp_ops_tbl
4742         ,   x_bom_component_tbl     => l_bom_component_tbl
4743         ,   x_bom_ref_designator_tbl=> l_bom_ref_designator_tbl
4744         ,   x_bom_sub_component_tbl => l_bom_sub_component_tbl
4745         ,   x_bom_comp_ops_tbl      => l_bom_comp_ops_tbl
4746   ,   x_Mesg_Token_Tbl    => l_Mesg_Token_Tbl
4747   ,   x_return_status   => l_return_status
4748   );
4749 
4750     IF l_return_status <> 'S'
4751     THEN
4752         l_bo_return_status := l_return_status;
4753     END IF;
4754 
4755     -- Process Reference Designators that are orphans (without immediate revised
4756     -- component parents) but are indirect children of this header
4757 
4758       Reference_Designators
4759   (   p_validation_level          => p_validation_level
4760         ,   p_assembly_item_name    => l_bom_header_rec.assembly_item_name
4761         ,   p_organization_id       => l_bom_header_unexp_rec.organization_id
4762         ,   p_alternate_bom_code    => l_bom_header_rec.alternate_bom_code
4763         ,   p_bom_ref_designator_tbl=> l_bom_ref_designator_tbl
4764         ,   p_bom_sub_component_tbl => l_bom_sub_component_tbl
4765         ,   x_bom_ref_designator_tbl=> l_bom_ref_designator_tbl
4766         ,   x_bom_sub_component_tbl => l_bom_sub_component_tbl
4767   ,   x_Mesg_Token_Tbl    => l_Mesg_Token_Tbl
4768   ,   x_return_status   => l_return_status
4769   );
4770 
4771     IF l_return_status <> 'S'
4772     THEN
4773         l_bo_return_status := l_return_status;
4774     END IF;
4775 
4776     -- Process Substitute Components that are orphans (without immediate revised
4777     -- component parents) but are indirect children of this header
4778 
4779       Substitute_Components
4780   (   p_validation_level          => p_validation_level
4781         ,   p_assembly_item_name    => l_bom_header_rec.assembly_item_name
4782         ,   p_organization_id       => l_bom_header_unexp_rec.organization_id
4783         ,   p_alternate_bom_code    => l_bom_header_rec.alternate_bom_code
4784         ,   p_bom_sub_component_tbl => l_bom_sub_component_tbl
4785         ,   x_bom_sub_component_tbl => l_bom_sub_component_tbl
4786   ,   x_Mesg_Token_Tbl    => l_Mesg_Token_Tbl
4787   ,   x_return_status   => l_return_status
4788   );
4789 
4790     IF l_return_status <> 'S'
4791     THEN
4792         l_bo_return_status := l_return_status;
4793     END IF;
4794 
4795     -- Process Component Operations that are orphans (without immediate revised
4796     -- component parents) but are indirect children of this header
4797 
4798       Component_Operations
4799   (   p_validation_level          => p_validation_level
4800         ,   p_assembly_item_name    => l_bom_header_rec.assembly_item_name
4801         ,   p_organization_id       => l_bom_header_unexp_rec.organization_id
4802         ,   p_alternate_bom_code    => l_bom_header_rec.alternate_bom_code
4803         ,   p_bom_comp_ops_tbl      => l_bom_comp_ops_tbl
4804         ,   x_bom_comp_ops_tbl      => l_bom_comp_ops_tbl
4805   ,   x_Mesg_Token_Tbl    => l_Mesg_Token_Tbl
4806   ,   x_return_status   => l_return_status
4807   );
4808 
4809     IF l_return_status <> 'S'
4810     THEN
4811         l_bo_return_status := l_return_status;
4812     END IF;
4813 
4814  /*****************Business Event*********/
4815     IF ( l_return_status = 'S') THEN
4816       if (Bom_Globals.Get_Bo_Identifier = Bom_Globals.G_BOM_BO) then
4817        IF l_bom_header_rec.transaction_type in ( Bom_Globals.G_OPR_CREATE) THEN
4818         Bom_Business_Event_PKG.Raise_Bill_Event
4819        (p_Event_Load_Type => 'Bulk'
4820         ,p_Request_Identifier => FND_GLOBAL.CONC_REQUEST_ID
4821         ,p_batch_identifier        => BOM_GLOBALS.G_BATCH_ID
4822         ,p_Event_Entity_Name => 'Structure'
4823         ,p_Event_Entity_Parent_Id  => G_Bill_Seq_Id
4824         ,p_Event_Name => Bom_Business_Event_PKG.G_STRUCTURE_CREATION_EVENT
4825         ,p_last_update_date => sysdate
4826         ,p_last_updated_by => FND_GLOBAL.user_id
4827         );
4828       ELSIF l_bom_header_rec.transaction_type in ( Bom_Globals.G_OPR_UPDATE) THEN
4829         Bom_Business_Event_PKG.Raise_Bill_Event
4830          (p_Event_Load_Type => 'Bulk'
4831         ,p_Request_Identifier => FND_GLOBAL.CONC_REQUEST_ID
4832         ,p_batch_identifier        => BOM_GLOBALS.G_BATCH_ID
4833         ,p_Event_Entity_Name => 'Structure'
4834         ,p_Event_Entity_Parent_Id  => G_Bill_Seq_Id
4835         ,p_Event_Name => Bom_Business_Event_PKG.G_STRUCTURE_MODIFIED_EVENT
4836         ,p_last_update_date => sysdate
4837         ,p_last_updated_by => FND_GLOBAL.user_id
4838         );
4839       END IF;
4840     end if;
4841    END IF;
4842   /****************Business Event*********/
4843 
4844 
4845      --  Load out parameters
4846 
4847      x_return_status          := l_bo_return_status;
4848      x_bom_header_rec   := l_bom_header_rec;
4849      x_bom_revision_tbl         := l_bom_revision_tbl;
4850      x_bom_component_tbl        := l_bom_component_tbl;
4851      x_bom_ref_designator_tbl   := l_bom_ref_designator_tbl;
4852      x_bom_sub_component_tbl    := l_bom_sub_component_tbl;
4853      x_bom_comp_ops_tbl         := l_bom_comp_ops_tbl;
4854      x_Mesg_Token_Tbl     := l_Mesg_Token_Tbl;
4855 
4856 END Bom_Header;
4857 
4858 
4859 /***************************************************************************
4860 * Procedure : Process_Bom
4861 * Parameters IN : BOM Business Object Entities, Record for Header and tables
4862 *     for the remaining entities
4863 * Parameters OUT: BOM Business Object Entities, Record for Header and tables
4864 *     for the remaining entities
4865 * Returns : None
4866 * Purpose : This is the only exposed procedure in the PVT API.
4867 *     Process_BOM will drive the business object processing. It
4868 *     will take each entity and call individual procedure that will
4869 *     handle the processing of that entity and its children.
4870 ****************************************************************************/
4871 PROCEDURE Process_Bom
4872 (   p_api_version_number       IN  NUMBER
4873 ,   p_validation_level         IN  NUMBER := FND_API.G_VALID_LEVEL_FULL
4874 ,   x_return_status            IN OUT NOCOPY VARCHAR2
4875 ,   x_msg_count                IN OUT NOCOPY NUMBER
4876 ,   p_bom_header_rec           IN  Bom_Bo_Pub.Bom_Head_Rec_Type :=
4877                                         Bom_Bo_Pub.G_MISS_BOM_HEADER_REC
4878 ,   p_bom_revision_tbl         IN  Bom_Bo_PUB.Bom_Revision_Tbl_Type :=
4879                                         Bom_Bo_PUB.G_MISS_BOM_REVISION_TBL
4880 ,   p_bom_component_tbl        IN  Bom_Bo_Pub.Bom_Comps_Tbl_Type :=
4881                                         Bom_Bo_Pub.G_MISS_BOM_COMPONENT_TBL
4882 ,   p_bom_ref_designator_tbl    IN  Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type
4883                                     :=  Bom_Bo_Pub.G_MISS_BOM_REF_DESIGNATOR_TBL
4884 ,   p_bom_sub_component_tbl     IN  Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type
4885                                     :=  Bom_Bo_Pub.G_MISS_BOM_SUB_COMPONENT_TBL
4886 ,   p_bom_comp_ops_tbl          IN  Bom_Bo_Pub.Bom_Comp_Ops_Tbl_Type
4887                                     :=  Bom_Bo_Pub.G_MISS_BOM_COMP_OPS_TBL
4888 ,   x_bom_header_rec            IN OUT NOCOPY Bom_Bo_Pub.Bom_Head_Rec_Type
4889 ,   x_bom_revision_tbl          IN OUT NOCOPY Bom_Bo_PUB.Bom_Revision_Tbl_Type
4890 ,   x_bom_component_tbl         IN OUT NOCOPY Bom_Bo_Pub.Bom_Comps_Tbl_Type
4891 ,   x_bom_ref_designator_tbl    IN OUT NOCOPY Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type
4892 ,   x_bom_sub_component_tbl     IN OUT NOCOPY Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type
4893 ,   x_bom_comp_ops_tbl          IN OUT NOCOPY Bom_Bo_Pub.Bom_Comp_Ops_Tbl_Type
4894 )
4895 IS
4896 l_api_version_number          CONSTANT NUMBER := 1.0;
4897 l_api_name                    CONSTANT VARCHAR2(30):= 'Process_Bom';
4898 l_err_text          VARCHAR2(240);
4899 l_return_status               VARCHAR2(1);
4900 
4901 l_bo_return_status        VARCHAR2(1);
4902 
4903 l_bom_header_rec    Bom_Bo_Pub.Bom_Head_Rec_Type;
4904 l_bom_component_rec   Bom_Bo_Pub.Bom_Comps_Rec_Type;
4905 l_bom_revision_tbl    Bom_Bo_Pub.Bom_Revision_Tbl_Type;
4906 l_bom_ref_designator_rec  Bom_Bo_Pub.Bom_Ref_Designator_Rec_Type;
4907 l_bom_sub_component_rec         Bom_Bo_Pub.Bom_Sub_Component_Rec_Type;
4908 l_bom_comp_ops_rec          Bom_Bo_Pub.Bom_Comp_Ops_Rec_Type;
4909 l_bom_component_tbl   Bom_Bo_Pub.Bom_Comps_Tbl_Type;
4910 l_bom_ref_designator_tbl  Bom_Bo_Pub.Bom_Ref_Designator_Tbl_Type;
4911 l_bom_sub_component_tbl         Bom_Bo_Pub.Bom_Sub_Component_Tbl_Type;
4912 l_bom_comp_ops_tbl          Bom_Bo_Pub.Bom_Comp_Ops_Tbl_Type;
4913 
4914 l_mesg_token_tbl        Error_Handler.Mesg_Token_Tbl_Type;
4915 l_other_message         VARCHAR2(2000);
4916 l_other_token_tbl       Error_Handler.Token_Tbl_Type;
4917 bill_seq_id number;    -- 4306013
4918 
4919 EXC_ERR_PVT_API_MAIN        EXCEPTION;
4920 
4921 BEGIN
4922 
4923   --  Init local variables.
4924   l_bom_header_rec  := p_bom_header_rec;
4925   l_bom_revision_tbl  := p_bom_revision_tbl;
4926   l_bom_component_tbl := p_bom_component_tbl;
4927   l_bom_ref_designator_tbl:= p_bom_ref_designator_tbl;
4928   l_bom_sub_component_tbl := p_bom_sub_component_tbl;
4929   l_bom_comp_ops_tbl  := p_bom_comp_ops_tbl;
4930 
4931   -- Business Object starts with a status of Success
4932   l_bo_return_status := 'S';
4933 
4934   --Load environment information into the SYSTEM_INFORMATION record
4935   -- (USER_ID, LOGIN_ID, PROG_APPID, PROG_ID)
4936 
4937   Bom_Globals.Init_System_Info_Rec
4938           (  x_mesg_token_tbl => l_mesg_token_tbl
4939           ,  x_return_status  => l_return_status
4940           );
4941 
4942   -- Initialize System_Information Unit_Effectivity flag
4943 
4944   IF (FND_PROFILE.DEFINED('PJM:PJM_UNITEFF_NO_EFFECT') AND
4945                FND_PROFILE.VALUE('PJM:PJM_UNITEFF_NO_EFFECT') = 'Y')
4946            OR (BOM_EAMUTIL.Enabled = 'Y')
4947   THEN
4948     Bom_Globals.Set_Unit_Effectivity (TRUE);
4949       ELSE
4950     Bom_Globals.Set_Unit_Effectivity (FALSE);
4951       END IF;
4952 
4953   IF l_return_status <> FND_API.G_RET_STS_SUCCESS
4954       THEN
4955         RAISE EXC_ERR_PVT_API_MAIN;
4956       END IF;
4957 
4958   --
4959   -- Start with processing of the Bill Header.
4960   --
4961       IF  (l_bom_header_rec.assembly_item_name <> FND_API.G_MISS_CHAR
4962         AND l_bom_header_rec.assembly_item_name IS NOT NULL)
4963       THEN
4964         Bom_Header
4965         (   p_validation_level          => p_validation_level
4966     ,   p_bom_header_rec    => l_bom_header_rec
4967     ,   p_bom_revision_tbl    => l_bom_revision_tbl
4968     ,   p_bom_component_tbl   => l_bom_component_tbl
4969     ,   p_bom_ref_designator_tbl    => l_bom_ref_designator_tbl
4970     ,   p_bom_sub_component_tbl => l_bom_sub_component_tbl
4971     ,   p_bom_comp_ops_tbl    => l_bom_comp_ops_tbl
4972     ,   x_bom_header_rec    => l_bom_header_rec
4973     ,   x_bom_revision_tbl    => l_bom_revision_tbl
4974     ,   x_bom_component_tbl   => l_bom_component_tbl
4975     ,   x_bom_ref_designator_tbl    => l_bom_ref_designator_tbl
4976     ,   x_bom_sub_component_tbl => l_bom_sub_component_tbl
4977     ,   x_bom_comp_ops_tbl    => l_bom_comp_ops_tbl
4978         ,   x_Mesg_Token_Tbl    => l_Mesg_Token_Tbl
4979         ,   x_return_status     => l_return_status
4980         );
4981           IF NVL(l_return_status, 'S') = 'Q'
4982           THEN
4983       l_return_status := 'F';
4984       RAISE G_EXC_QUIT_IMPORT;
4985           ELSIF NVL(l_return_status, 'S') = 'U'
4986     THEN
4987       RAISE G_EXC_QUIT_IMPORT;
4988 
4989     ELSIF NVL(l_return_status, 'S') <> 'S'
4990           THEN
4991       l_bo_return_status := l_return_status;
4992     END IF;
4993 
4994     END IF;  -- Processing Bom Header Ends
4995 
4996   --
4997   -- Process BOM Revisions
4998   --
4999     IF l_bom_revision_tbl.Count <> 0
5000   THEN
5001     Bom_Revisions
5002         (   p_validation_level          => p_validation_level
5003     ,   p_bom_revision_tbl    => l_bom_revision_tbl
5004     ,   p_bom_component_tbl   => l_bom_component_tbl
5005     ,   p_bom_ref_designator_tbl=> l_bom_ref_designator_tbl
5006     ,   p_bom_sub_component_tbl => l_bom_sub_component_tbl
5007     ,   p_bom_comp_ops_tbl    => l_bom_comp_ops_tbl
5008     ,   x_bom_revision_tbl    => l_bom_revision_tbl
5009     ,   x_bom_component_tbl   => l_bom_component_tbl
5010     ,   x_bom_ref_designator_tbl=> l_bom_ref_designator_tbl
5011     ,   x_bom_sub_component_tbl => l_bom_sub_component_tbl
5012     ,   x_bom_comp_ops_tbl    => l_bom_comp_ops_tbl
5013         ,   x_Mesg_Token_Tbl    => l_Mesg_Token_Tbl
5014         ,   x_return_status     => l_return_status
5015         );
5016 
5017           IF NVL(l_return_status, 'S') = 'Q'
5018           THEN
5019                   l_return_status := 'F';
5020                   RAISE G_EXC_QUIT_IMPORT;
5021           ELSIF NVL(l_return_status, 'S') = 'U'
5022           THEN
5023                   RAISE G_EXC_QUIT_IMPORT;
5024           ELSIF NVL(l_return_status, 'S') <> 'S'
5025           THEN
5026                   l_bo_return_status := l_return_status;
5027           END IF;
5028 
5029   END IF;  -- Processing of BOM revisions Ends
5030 
5031   --
5032   --  Process Inventory Components
5033   --
5034 
5035   IF l_bom_component_tbl.Count <> 0
5036   THEN
5037         Bom_Components
5038         (   p_validation_level          => p_validation_level
5039         ,   p_bom_component_tbl         => l_bom_component_tbl
5040           ,   p_bom_ref_designator_tbl=> l_bom_ref_designator_tbl
5041           ,   p_bom_sub_component_tbl => l_bom_sub_component_tbl
5042     ,   p_bom_comp_ops_tbl    => l_bom_comp_ops_tbl
5043         ,   x_bom_component_tbl         => l_bom_component_tbl
5044         ,   x_bom_ref_designator_tbl=> l_bom_ref_designator_tbl
5045         ,   x_bom_sub_component_tbl => l_bom_sub_component_tbl
5046     ,   x_bom_comp_ops_tbl    => l_bom_comp_ops_tbl
5047         ,   x_Mesg_Token_Tbl    => l_Mesg_Token_Tbl
5048     ,   x_return_status   => l_return_status
5049         );
5050 
5051     IF NVL(l_return_status, 'S') = 'Q'
5052           THEN
5053                   l_return_status := 'F';
5054                   RAISE G_EXC_QUIT_IMPORT;
5055           ELSIF NVL(l_return_status, 'S') = 'U'
5056           THEN
5057                   RAISE G_EXC_QUIT_IMPORT;
5058           ELSIF NVL(l_return_status, 'S') <> 'S'
5059           THEN
5060                   l_bo_return_status := l_return_status;
5061           END IF;
5062       END IF; -- Processing of Inventory Components Ends
5063 
5064   -- Process Reference Designators
5065   --
5066   IF l_bom_ref_designator_tbl.Count <> 0
5067       THEN
5068         Reference_Designators
5069         (   p_validation_level          => p_validation_level
5070         ,   p_bom_ref_designator_tbl=> l_bom_ref_designator_tbl
5071           ,   p_bom_sub_component_tbl => l_bom_sub_component_tbl
5072         ,   x_bom_ref_designator_tbl=> l_bom_ref_designator_tbl
5073         ,   x_bom_sub_component_tbl => l_bom_sub_component_tbl
5074         ,   x_Mesg_Token_Tbl    => l_Mesg_Token_Tbl
5075     ,   x_return_status   => l_return_status
5076         );
5077 
5078           IF NVL(l_return_status, 'S') = 'Q'
5079           THEN
5080                   l_return_status := 'F';
5081                   RAISE G_EXC_QUIT_IMPORT;
5082           ELSIF NVL(l_return_status, 'S') = 'U'
5083           THEN
5084                   RAISE G_EXC_QUIT_IMPORT;
5085 
5086           ELSIF NVL(l_return_status, 'S') <> 'S'
5087           THEN
5088                   l_bo_return_status := l_return_status;
5089           END IF;
5090   END IF; -- Processing of Reference Designator Ends
5091 
5092   IF l_bom_Sub_Component_Tbl.Count <> 0
5093   THEN
5094         Substitute_Components
5095         (   p_validation_level          => p_validation_level
5096         ,   p_bom_sub_component_tbl     => l_bom_sub_component_tbl
5097         ,   x_bom_sub_component_tbl     => l_bom_sub_component_tbl
5098         ,   x_Mesg_Token_Tbl    => l_Mesg_Token_Tbl
5099     ,   x_return_status   => l_return_status
5100         );
5101           IF NVL(l_return_status, 'S') = 'Q'
5102           THEN
5103                   l_return_status := 'F';
5104                   RAISE G_EXC_QUIT_IMPORT;
5105           ELSIF NVL(l_return_status, 'S') = 'U'
5106           THEN
5107                   RAISE G_EXC_QUIT_IMPORT;
5108 
5109           ELSIF NVL(l_return_status, 'S') <> 'S'
5110           THEN
5111                   l_bo_return_status := l_return_status;
5112           END IF;
5113 
5114   END IF;  -- Processing of Substitute Components Ends
5115 
5116   IF l_Bom_Comp_Ops_Tbl.Count <> 0
5117   THEN
5118         Component_Operations
5119         (   p_validation_level          => p_validation_level
5120         ,   x_bom_comp_ops_tbl          => l_bom_comp_ops_tbl
5121         ,   p_bom_comp_ops_tbl          => l_bom_comp_ops_tbl
5122         ,   x_Mesg_Token_Tbl    => l_Mesg_Token_Tbl
5123     ,   x_return_status   => l_return_status
5124         );
5125 
5126           IF NVL(l_return_status, 'S') = 'Q'
5127           THEN
5128                   l_return_status := 'F';
5129                   RAISE G_EXC_QUIT_IMPORT;
5130           ELSIF NVL(l_return_status, 'S') = 'U'
5131           THEN
5132                   RAISE G_EXC_QUIT_IMPORT;
5133                 ELSIF NVL(l_return_status, 'S') <> 'S'
5134           THEN
5135                   l_bo_return_status := l_return_status;
5136           END IF;
5137 
5138 
5139   END IF;  -- Processing of Component Operations Ends
5140 
5141     x_return_status   := l_bo_return_status;
5142 
5143     x_bom_header_rec    := l_bom_header_rec;
5144     x_bom_revision_tbl    := l_bom_revision_tbl;
5145     x_bom_component_tbl   := l_bom_component_tbl;
5146     x_bom_ref_designator_tbl  := l_bom_ref_designator_tbl;
5147     x_bom_sub_component_tbl := l_bom_sub_component_tbl;
5148     x_bom_comp_ops_tbl    := l_bom_comp_ops_tbl;
5149 
5150     -- Reset system_information business object flags
5151 
5152     Bom_GLOBALS.Set_STD_Item_Access( p_std_item_access => NULL);
5153     Bom_GLOBALS.Set_MDL_Item_Access( p_mdl_item_access => NULL);
5154     Bom_GLOBALS.Set_PLN_Item_Access( p_pln_item_access => NULL);
5155     Bom_GLOBALS.Set_OC_Item_Access( p_oc_item_access   => NULL);
5156 
5157 EXCEPTION
5158 
5159     WHEN EXC_ERR_PVT_API_MAIN THEN
5160 
5161         Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
5162   Error_Handler.Log_Error
5163   (  p_bom_header_rec   => l_bom_header_rec
5164   ,  p_bom_revision_tbl   => l_bom_revision_tbl
5165   ,  p_bom_component_tbl    => l_bom_component_tbl
5166   ,  p_bom_ref_designator_tbl   => l_bom_ref_designator_tbl
5167   ,  p_bom_sub_component_tbl  => l_bom_sub_component_tbl
5168   ,  p_mesg_token_tbl   => l_mesg_token_tbl
5169   ,  p_error_status   => FND_API.G_RET_STS_UNEXP_ERROR
5170   ,  p_other_status         => Error_Handler.G_STATUS_NOT_PICKED
5171         ,  p_other_message    => l_other_message
5172   ,  p_other_token_tbl    => l_other_token_tbl
5173   ,  p_error_level    => 0
5174   ,  x_bom_header_rec   => l_bom_header_rec
5175   ,  x_bom_revision_tbl   => l_bom_revision_tbl
5176   ,  x_bom_component_tbl    => l_bom_component_tbl
5177   ,  x_bom_ref_designator_tbl => l_bom_ref_designator_tbl
5178   ,  x_bom_sub_component_tbl  => l_bom_sub_component_tbl
5179   );
5180         Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
5181 
5182         x_return_status          := l_return_status;
5183       x_bom_header_rec         := l_bom_header_rec;
5184       x_bom_revision_tbl             := l_bom_revision_tbl;
5185       x_bom_component_tbl            := l_bom_component_tbl;
5186       x_bom_ref_designator_tbl       := l_bom_ref_designator_tbl;
5187       x_bom_sub_component_tbl        := l_bom_sub_component_tbl;
5188         x_bom_comp_ops_tbl         := l_bom_comp_ops_tbl;
5189 
5190       -- Reset system_information business object flags
5191 
5192     Bom_GLOBALS.Set_STD_Item_Access( p_std_item_access => NULL);
5193     Bom_GLOBALS.Set_MDL_Item_Access( p_mdl_item_access => NULL);
5194     Bom_GLOBALS.Set_PLN_Item_Access( p_pln_item_access => NULL);
5195     Bom_GLOBALS.Set_OC_Item_Access( p_oc_item_access   => NULL);
5196 
5197     WHEN G_EXC_QUIT_IMPORT THEN
5198 
5199         x_return_status          := l_return_status;
5200         x_bom_header_rec               := l_bom_header_rec;
5201         x_bom_revision_tbl             := l_bom_revision_tbl;
5202         x_bom_component_tbl            := l_bom_component_tbl;
5203         x_bom_ref_designator_tbl       := l_bom_ref_designator_tbl;
5204         x_bom_sub_component_tbl        := l_bom_sub_component_tbl;
5205         x_bom_comp_ops_tbl         := l_bom_comp_ops_tbl;
5206 
5207       -- Reset system_information business object flags
5208 
5209     Bom_GLOBALS.Set_STD_Item_Access( p_std_item_access => NULL);
5210     Bom_GLOBALS.Set_MDL_Item_Access( p_mdl_item_access => NULL);
5211     Bom_GLOBALS.Set_PLN_Item_Access( p_pln_item_access => NULL);
5212     Bom_GLOBALS.Set_OC_Item_Access( p_oc_item_access   => NULL);
5213 
5214     WHEN OTHERS THEN
5215 
5216   IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5217         THEN
5218                 l_err_text := G_PKG_NAME || ' : Process BOM '
5219                   || substrb(SQLERRM,1,200);
5220     Error_Handler.Add_Error_Token
5221                   ( p_Message_Text => l_err_text
5222                         , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5223                         , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
5224                         );
5225   END IF;
5226 
5227         Error_Handler.Set_Bom_Specific(p_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
5228   Error_Handler.Log_Error
5229         (  p_bom_header_rec             => l_bom_header_rec
5230         ,  p_bom_revision_tbl           => l_bom_revision_tbl
5231         ,  p_bom_component_tbl          => l_bom_component_tbl
5232         ,  p_bom_ref_designator_tbl     => l_bom_ref_designator_tbl
5233         ,  p_bom_sub_component_tbl      => l_bom_sub_component_tbl
5234         ,  p_mesg_token_tbl             => l_mesg_token_tbl
5235         ,  p_error_status               => FND_API.G_RET_STS_UNEXP_ERROR
5236         ,  p_other_status               => Error_Handler.G_STATUS_NOT_PICKED
5237         ,  p_other_message              => l_other_message
5238         ,  p_other_token_tbl            => l_other_token_tbl
5239         ,  p_error_level                => 0
5240         ,  x_bom_header_rec             => l_bom_header_rec
5241         ,  x_bom_revision_tbl           => l_bom_revision_tbl
5242         ,  x_bom_component_tbl          => l_bom_component_tbl
5243         ,  x_bom_ref_designator_tbl     => l_bom_ref_designator_tbl
5244         ,  x_bom_sub_component_tbl      => l_bom_sub_component_tbl
5245         );
5246         Error_Handler.Get_Bom_Specific(x_bom_comp_ops_tbl => l_bom_comp_ops_tbl);
5247 
5248         x_return_status          := l_return_status;
5249         x_bom_header_rec               := l_bom_header_rec;
5250         x_bom_revision_tbl             := l_bom_revision_tbl;
5251         x_bom_component_tbl            := l_bom_component_tbl;
5252         x_bom_ref_designator_tbl       := l_bom_ref_designator_tbl;
5253         x_bom_sub_component_tbl        := l_bom_sub_component_tbl;
5254         x_bom_comp_ops_tbl         := l_bom_comp_ops_tbl;
5255 
5256       -- Reset system_information business object flags
5257 
5258     Bom_GLOBALS.Set_STD_Item_Access( p_std_item_access => NULL);
5259     Bom_GLOBALS.Set_MDL_Item_Access( p_mdl_item_access => NULL);
5260     Bom_GLOBALS.Set_PLN_Item_Access( p_pln_item_access => NULL);
5261     Bom_GLOBALS.Set_OC_Item_Access( p_oc_item_access   => NULL);
5262 
5263  END Process_BOM;
5264 END Bom_Bo_Pvt;