DBA Data[Home] [Help]

PACKAGE BODY: APPS.ENG_FORM_ECO_PVT

Source


1 PACKAGE BODY ENG_FORM_ECO_PVT AS
2 /* $Header: ENGFPVTB.pls 120.1 2006/03/27 06:58:44 sdarbha noship $ */
3 
4 --  Global constant holding the package name
5 
6 G_PKG_NAME              CONSTANT VARCHAR2(30) := 'ENG_Eco_PVT';
7 G_EXC_QUIT_IMPORT       EXCEPTION;
8 
9 G_MISS_ECO_REC          ENG_Eco_PUB.ECO_Rec_Type;
10 G_MISS_ECO_REV_REC      ENG_Eco_PUB.ECO_Revision_Rec_Type;
11 G_MISS_REV_ITEM_REC     ENG_Eco_PUB.Revised_Item_Rec_Type;
12 G_MISS_REV_COMP_REC     BOM_BO_PUB.Rev_Component_Rec_Type;
13 G_MISS_REF_DESG_REC     BOM_BO_PUB.Ref_Designator_Rec_Type;
14 G_MISS_SUB_COMP_REC     BOM_BO_PUB.Sub_Component_Rec_Type;
15 G_MISS_REV_OP_REC       BOM_RTG_PUB.Rev_Operation_Rec_Type;        --add
16 G_MISS_REV_OP_RES_REC   BOM_RTG_PUB.Rev_Op_Resource_Rec_Type;      --add
17 G_MISS_REV_SUB_RES_REC  BOM_RTG_PUB.Rev_Sub_Resource_Rec_Type;     --add
18 
19 G_CONTROL_REC           BOM_BO_PUB.Control_Rec_Type;
20 
21 
22 -- Added for Bug#1587263
23 -- Set Revised Item's attributes to Global_System_Information
24 -- records, which are used from rev item chidlren entities.
25 -- This modification caused BOs modification for dependency issue.
26 -- In feature, following source I added will be eliminated
27 -- as well as BO's modification for dependency issue.
28 -- This procedure is called from each child entity of Rev Item.
29 -- p_bo_processed is 'RTG' or 'BOM'
30 --
31 --
32 PROCEDURE Set_RevItem_Attributes
33 (  p_revised_item_sequence_id    IN  NUMBER
34  , p_bo_processed                IN  VARCHAR2 := 'RTG'
35 )
36 
37 IS
38         l_lot_number            VARCHAR2(30) ;
39         l_routing_sequence_id   NUMBER ;
40         l_from_wip_entity_id    NUMBER ;
41         l_to_wip_entity_id      NUMBER ;
42         l_from_cum_qty          NUMBER ;
43         l_eco_for_production    NUMBER ;
44         l_cfm_routing_flag      NUMBER ;
45 
46         l_err_text              VARCHAR2(2000);
47         l_Mesg_Token_Tbl        Error_Handler.Mesg_Token_Tbl_Type;
48         l_return_status         VARCHAR2(1);
49 BEGIN
50 
51     l_return_status := FND_API.G_RET_STS_SUCCESS;
52 
53     BEGIN
54         SELECT routing_sequence_id
55              , lot_number
56              , from_wip_entity_id
57              , to_wip_entity_id
58              , from_cum_qty
59              , NVL(eco_for_production,2)
60              , NVL(cfm_routing_flag,2)
61          INTO  l_routing_sequence_id
62              , l_lot_number
63              , l_from_wip_entity_id
64              , l_to_wip_entity_id
65              , l_from_cum_qty
66              , l_eco_for_production
67              , l_cfm_routing_flag
68          FROM eng_revised_items
69          WHERE revised_item_sequence_id = p_revised_item_sequence_id ;
70 
71     EXCEPTION
72         -- Added for Bug1606881
73         WHEN NO_DATA_FOUND THEN
74            NULL ;
75 
76     END  ;
77 
78     IF  p_bo_processed = 'RTG' THEN
79 
80          -- Set Revised Item Attributes to Global System Information.
81          Bom_Rtg_Globals.Set_Lot_Number(l_lot_number) ;
82          Bom_Rtg_Globals.Set_From_Wip_Entity_Id(l_from_wip_entity_id) ;
83          Bom_Rtg_Globals.Set_To_Wip_Entity_Id(l_to_wip_entity_id) ;
84          Bom_Rtg_Globals.Set_From_Cum_Qty(l_from_cum_qty) ;
85          Bom_Rtg_Globals.Set_Eco_For_Production(l_eco_for_production) ;
86          Bom_Rtg_Globals.Set_Routing_Sequence_Id(l_routing_sequence_id) ;
87 
88     ELSIF p_bo_processed = 'BOM' THEN
89 
90          -- Set Revised Item Attributes to Global System Information.
91          Bom_Globals.Set_Lot_Number(l_lot_number) ;
92          Bom_Globals.Set_From_Wip_Entity_Id(l_from_wip_entity_id) ;
93          Bom_Globals.Set_To_Wip_Entity_Id(l_to_wip_entity_id) ;
94          Bom_Globals.Set_From_Cum_Qty(l_from_cum_qty) ;
95          Bom_Globals.Set_Eco_For_Production(l_eco_for_production) ;
96 
97     END IF ;
98 
99 END Set_RevItem_Attributes ;
100 
101 
102 -- Added by Masahiko Mochizuki on 09/13/00
103 -- Rev_Sub_Res
104 
105 PROCEDURE Rev_Sub_Res
106 (   p_unexp_rev_sub_res_rec         IN  BOM_RTG_PUB.Rev_Sub_Res_Unexposed_Rec_Type
107 ,   p_rev_op_resource_tbl           IN  BOM_RTG_PUB.Rev_Op_Resource_Tbl_Type
108 ,   p_rev_sub_resource_tbl          IN  BOM_RTG_PUB.Rev_Sub_Resource_Tbl_Type
109 ,   x_ECO_rec                       IN OUT NOCOPY ENG_Eco_PUB.Eco_Rec_Type
110 ,   x_unexp_rev_sub_res_rec         IN OUT NOCOPY BOM_RTG_PUB.Rev_Sub_Res_Unexposed_Rec_Type
111 ,   x_eco_revision_tbl              IN OUT NOCOPY ENG_Eco_PUB.Eco_Revision_Tbl_Type
112 ,   x_revised_item_tbl              IN OUT NOCOPY ENG_Eco_PUB.Revised_Item_Tbl_Type
113 ,   x_rev_component_tbl             IN OUT NOCOPY BOM_BO_PUB.Rev_Component_Tbl_Type
114 ,   x_ref_designator_tbl            IN OUT NOCOPY BOM_BO_PUB.Ref_Designator_Tbl_Type
115 ,   x_sub_component_tbl             IN OUT NOCOPY BOM_BO_PUB.Sub_Component_Tbl_Type
116 ,   x_rev_operation_tbl             IN OUT NOCOPY BOM_RTG_PUB.Rev_operation_Tbl_Type
117 ,   x_rev_op_resource_tbl           IN OUT NOCOPY BOM_RTG_PUB.Rev_op_resource_Tbl_Type
118 ,   x_rev_sub_resource_tbl          IN OUT NOCOPY BOM_RTG_PUB.Rev_sub_resource_Tbl_Type
119 ,   x_Mesg_Token_Tbl                IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
120 ,   x_return_status                 IN OUT NOCOPY VARCHAR2
121 )
122 IS
123 
124 l_Mesg_Token_Tbl        Error_Handler.Mesg_Token_Tbl_Type;
125 l_other_token_tbl       Error_Handler.Token_Tbl_Type;
126 l_other_message         VARCHAR2(50);
127 l_err_text              VARCHAR2(2000);
128 l_valid                 BOOLEAN := TRUE;
129 l_Return_Status         VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
130 l_bo_return_status      VARCHAR2(1) := 'S';
131 l_rev_sub_resource_Rec    BOM_RTG_PUB.Rev_Sub_Resource_Rec_Type;
132 l_rev_sub_res_unexp_Rec   BOM_RTG_PUB.Rev_Sub_Res_Unexposed_Rec_Type := p_unexp_Rev_Sub_Res_rec;
133 l_old_rev_sub_resource_Rec   BOM_RTG_PUB.Rev_Sub_Resource_Rec_Type := NULL;
134 l_old_rev_sub_res_unexp_Rec  BOM_RTG_PUB.Rev_Sub_Res_Unexposed_Rec_Type := NULL;
135 l_eco_rec               ENG_ECO_PUB.ECO_Rec_Type := NULL;
136 l_eco_revision_tbl      ENG_Eco_PUB.Eco_Revision_Tbl_Type;
137 l_revised_item_tbl      ENG_Eco_PUB.Revised_Item_Tbl_Type;
138 l_rev_component_tbl     BOM_BO_PUB.Rev_Component_Tbl_Type;
139 l_ref_designator_tbl    BOM_BO_PUB.Ref_Designator_Tbl_Type;
140 l_sub_component_tbl     BOM_BO_PUB.Sub_Component_Tbl_Type;
141 l_rev_operation_tbl     BOM_RTG_PUB.Rev_Operation_Tbl_Type;
142 l_rev_op_resource_tbl   BOM_RTG_PUB.Rev_Op_Resource_Tbl_Type := p_rev_op_resource_tbl;
143 l_rev_sub_resource_tbl  BOM_RTG_PUB.Rev_Sub_Resource_Tbl_Type := p_rev_sub_resource_tbl;
144 l_return_value          NUMBER;
145 l_Token_Tbl             Error_Handler.Token_Tbl_Type;
146 
147 EXC_SEV_QUIT_RECORD     EXCEPTION;
148 EXC_UNEXP_SKIP_OBJECT   EXCEPTION;
149 
150 BEGIN
151 
152     -- Begin block that processes revised items. This block holds the exception handlers
153     -- for header errors.
154 
155     FOR I IN 1..l_rev_sub_resource_tbl.COUNT LOOP
156     BEGIN
157         --  Load local records.
158 
159         l_rev_sub_resource_rec := l_rev_sub_resource_tbl(I);
160 
161         l_rev_sub_resource_rec.transaction_type :=
162                 UPPER(l_rev_sub_resource_rec.transaction_type);
163 
164         l_return_status := FND_API.G_RET_STS_SUCCESS;
165         l_rev_sub_resource_rec.return_status := FND_API.G_RET_STS_SUCCESS;
166 
167         -- Process Flow step 3: Verify Sub Operation Resource's existence
168         --
169 
170         IF g_control_rec.check_existence
171         THEN
172                 --dbms_output.put_line('Checking Existence');
173                 Bom_Validate_Sub_Op_Res.Check_Existence
174                 (  p_rev_sub_resource_rec          => l_rev_sub_resource_rec
175                 ,  p_rev_sub_res_unexp_rec         => l_rev_sub_res_unexp_rec
176                 ,  x_old_rev_sub_resource_rec      => l_old_rev_sub_resource_rec
177                 ,  x_old_rev_sub_res_unexp_rec     => l_old_rev_sub_res_unexp_rec
178                 ,  x_Mesg_Token_Tbl                => x_Mesg_Token_Tbl
179                 ,  x_return_status                 => x_Return_Status
180                 );
181 
182                 --dbms_output.put_line('return_status: ' || l_return_status);
183 
184                 IF l_return_status = Error_Handler.G_STATUS_ERROR
185                 THEN
186                         RAISE EXC_SEV_QUIT_RECORD;
187                 ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
188                 THEN
189                         RAISE EXC_UNEXP_SKIP_OBJECT;
190                 END IF;
191         END IF;
192 
193         -- Set parent revised item attributes
194         Set_RevItem_Attributes
195         (  p_revised_item_sequence_id    => l_rev_sub_res_unexp_rec.revised_item_sequence_id
196          , p_bo_processed                => 'RTG'
197         ) ;
198 
199 
200 
201      -- Process Flow step 12 - Entity Level Validation
202 
203         IF g_control_rec.entity_validation
204         THEN
205                 --dbms_output.put_line('Entity validation');
206                 IF l_rev_sub_resource_rec.transaction_type = 'DELETE'
207                 THEN
208                         NULL;
209                         /*Eng_Validate_Revised_Item.Check_Entity_Delete
210                         (  p_rev_sub_resource_rec    => l_rev_sub_resource_rec
211                         ,  p_rev_operation_unexp_rec => l_rev_operation_unexp_rec
212                         ,  x_Mesg_Token_Tbl          => l_Mesg_Token_Tbl
213                         ,  x_return_status           => l_Return_Status
214                         );*/
215                 ELSE
216                         Bom_Validate_Sub_Op_Res.Check_Entity
217                         (  p_rev_sub_resource_rec      => l_rev_sub_resource_rec
218                         ,  p_rev_sub_res_unexp_rec     => l_rev_sub_res_unexp_rec
219                         ,  p_old_rev_sub_resource_rec  => l_old_rev_sub_resource_rec
220                         ,  p_old_rev_sub_res_unexp_rec => l_old_rev_sub_res_unexp_rec
221                         ,  p_control_rec               => Bom_Rtg_Pub.G_Default_Control_Rec
222                         ,  x_rev_sub_resource_rec      => l_rev_sub_resource_rec
223                         ,  x_rev_sub_res_unexp_rec     => l_rev_sub_res_unexp_rec
224                         ,  x_return_status             => l_return_status
225                         ,  x_mesg_token_tbl            => l_mesg_token_tbl
226                         );
227 
228                 END IF;
229 
230                 --dbms_output.put_line('return_status: ' || l_return_status);
231 
232                 IF l_return_status = Error_Handler.G_STATUS_ERROR
233                 THEN
234                         RAISE EXC_SEV_QUIT_RECORD;
235                 ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
236                 THEN
237                         RAISE EXC_UNEXP_SKIP_OBJECT;
238                 ELSIF l_return_status ='S' AND
239                       l_Mesg_Token_Tbl.COUNT <>0
240                 THEN
241                         Eco_Error_Handler.Log_Error
242                         (  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl
243                         ,  p_rev_op_resource_tbl  => l_rev_op_resource_tbl
244                         ,  p_mesg_token_tbl       => l_mesg_token_tbl
245                         ,  p_error_status         => 'W'
246                         ,  p_error_level          => Error_Handler.G_SR_LEVEL
247                         ,  p_entity_index         => I
248                         ,  x_eco_rec              => l_eco_rec
249                         ,  x_eco_revision_tbl     => l_eco_revision_tbl
250                         ,  x_revised_item_tbl     => l_revised_item_tbl
251                         ,  x_rev_component_tbl    => l_rev_component_tbl
252                         ,  x_ref_designator_tbl   => l_ref_designator_tbl
253                         ,  x_sub_component_tbl    => l_sub_component_tbl
254                         ,  x_rev_operation_tbl    => l_rev_operation_tbl
255                         ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl
256                         ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl
257                         );
258                 END IF;
259         END IF;
260 
261         -- Process Flow step 13 : Database Writes
262 --dbms_output.put_line('checking if to write to db');
263         IF g_control_rec.write_to_db
264         THEN
265                 bom_globals.set_user_id(p_user_id => g_control_rec.last_updated_by);
266                 bom_rtg_globals.set_user_id(p_user_id => g_control_rec.last_updated_by);
267                 bom_globals.set_login_id(p_login_id => g_control_rec.last_update_login);
268                 bom_rtg_globals.set_login_id(p_login_id => g_control_rec.last_update_login);
269 
270                 --dbms_output.put_line('Writing to the database');
271                 Bom_Sub_Op_Res_Util.Perform_Writes
272                 (   p_rev_sub_resource_rec   => l_rev_sub_resource_rec
273                 ,   p_rev_sub_res_unexp_rec  => l_rev_sub_res_unexp_rec
274                 ,   p_control_rec            => Bom_Rtg_Pub.G_Default_Control_Rec
275                 ,   x_mesg_token_tbl         => x_mesg_token_tbl
276                 ,   x_return_status          => x_return_status
277                 );
278 
279                 --dbms_output.put_line('return_status: ' || l_return_status);
280 
281                 IF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
282                 THEN
283                         RAISE EXC_UNEXP_SKIP_OBJECT;
284                 ELSIF l_return_status ='S' AND
285                       l_Mesg_Token_Tbl.COUNT <>0
286                 THEN
287                         Eco_Error_Handler.Log_Error
288                         (  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl
289                         ,  p_rev_op_resource_tbl  => l_rev_op_resource_tbl
290                         ,  p_mesg_token_tbl       => l_mesg_token_tbl
291                         ,  p_error_status         => 'W'
292                         ,  p_error_level          => Error_Handler.G_SR_LEVEL
293                         ,  p_entity_index         => I
294                         ,  x_eco_rec              => l_eco_rec
295                         ,  x_eco_revision_tbl     => l_eco_revision_tbl
296                         ,  x_revised_item_tbl     => l_revised_item_tbl
297                         ,  x_rev_component_tbl    => l_rev_component_tbl
298                         ,  x_ref_designator_tbl   => l_ref_designator_tbl
299                         ,  x_sub_component_tbl    => l_sub_component_tbl
300                         ,  x_rev_operation_tbl    => l_rev_operation_tbl
301                         ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl
302                         ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl
303                         );
304                 END IF;
305         END IF;
306 
307         l_rev_sub_resource_tbl(I) := l_rev_sub_resource_rec;
308 
309   EXCEPTION
310 
311     WHEN EXC_SEV_QUIT_RECORD THEN
312 
313         --dbms_output.put_line('Expected error generated');
314         l_rev_sub_resource_tbl(I) := l_rev_sub_resource_rec;
315         Eco_Error_Handler.Log_Error
316                 (  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl
317                 ,  p_rev_op_resource_tbl  => l_rev_op_resource_tbl
318                 ,  p_mesg_token_tbl       => l_mesg_token_tbl
319                 ,  p_error_status         => FND_API.G_RET_STS_ERROR
320                 ,  p_error_scope          => Error_Handler.G_SCOPE_RECORD
321                 ,  p_error_level          => Error_Handler.G_SR_LEVEL
322                 ,  p_entity_index         => I
323                 ,  x_eco_rec              => l_eco_rec
324                 ,  x_eco_revision_tbl     => l_eco_revision_tbl
325                 ,  x_revised_item_tbl     => l_revised_item_tbl
326                 ,  x_rev_component_tbl    => l_rev_component_tbl
327                 ,  x_ref_designator_tbl   => l_ref_designator_tbl
328                 ,  x_sub_component_tbl    => l_sub_component_tbl
329                 ,  x_rev_operation_tbl    => l_rev_operation_tbl
330                 ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl
331                 ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl
332                 );
333 
334         x_return_status                := l_return_status;
335         x_Mesg_Token_Tbl               := l_Mesg_Token_Tbl;
336         x_ECO_rec                      := l_ECO_rec;
337         x_rev_sub_resource_tbl         := l_rev_sub_resource_tbl;
338         x_unexp_rev_sub_res_rec        := l_rev_sub_res_unexp_rec;
339         x_eco_revision_tbl             := l_eco_revision_tbl;
340         x_revised_item_tbl             := l_revised_item_tbl;
341         x_sub_component_tbl            := l_sub_component_tbl;
342         x_ref_designator_tbl           := l_ref_designator_tbl;
343         x_rev_component_tbl            := l_rev_component_tbl;
344         x_rev_operation_tbl            := l_rev_operation_tbl;
345         x_rev_op_resource_tbl         := l_rev_op_resource_tbl;
346 
347         RETURN;
348 
349     WHEN EXC_UNEXP_SKIP_OBJECT THEN
350 
351         --dbms_output.put_line('Unexpected error generated');
352         Eco_Error_Handler.Log_Error
353                 (  p_rev_sub_resource_tbl  => l_rev_sub_resource_tbl
354                 ,  p_mesg_token_tbl        => l_mesg_token_tbl
355                 ,  p_error_status          => Error_Handler.G_STATUS_UNEXPECTED
356                 ,  p_other_status          => Error_Handler.G_STATUS_NOT_PICKED
357                 ,  p_other_message         => l_other_message
358                 ,  p_other_token_tbl       => l_other_token_tbl
359                 ,  p_error_level           => Error_Handler.G_SR_LEVEL
360                 ,  p_entity_index          => I
361                 ,  x_ECO_rec               => l_ECO_rec
362                 ,  x_eco_revision_tbl      => l_eco_revision_tbl
363                 ,  x_revised_item_tbl      => l_revised_item_tbl
364                 ,  x_rev_component_tbl     => l_rev_component_tbl
365                 ,  x_ref_designator_tbl    => l_ref_designator_tbl
366                 ,  x_sub_component_tbl     => l_sub_component_tbl
367                 ,  x_rev_operation_tbl     => l_rev_operation_tbl
368                 ,  x_rev_op_resource_tbl   => l_rev_op_resource_tbl
369                 ,  x_rev_sub_resource_tbl  => l_rev_sub_resource_tbl
370                 );
371 
372         x_Mesg_Token_Tbl               := l_Mesg_Token_Tbl;
373         x_ECO_rec                      := l_ECO_rec;
374         x_rev_sub_resource_tbl         := l_rev_sub_resource_tbl;
375         x_unexp_rev_sub_res_rec        := l_rev_sub_res_unexp_rec;
376         x_eco_revision_tbl             := l_eco_revision_tbl;
377         x_revised_item_tbl             := l_revised_item_tbl;
378         x_ref_designator_tbl           := l_ref_designator_tbl;
379         x_rev_component_tbl            := l_rev_component_tbl;
380         x_sub_component_tbl            := l_sub_component_tbl;
381         x_rev_operation_tbl            := l_rev_operation_tbl;
382         x_rev_op_resource_tbl          := l_rev_op_resource_tbl;
383 
384         l_return_status := 'U';
385 
386   END;
387   END LOOP; -- END revised items processing block
388 
389     IF l_return_status in ('Q', 'U')
390     THEN
391         x_return_status := l_return_status;
392         RETURN;
393     END IF;
394 
395     l_bo_return_status := l_return_status;
396 
397      x_return_status            := l_bo_return_status;
398      x_ECO_rec                  := l_ECO_rec;
399      x_unexp_rev_sub_res_rec    := l_rev_sub_res_unexp_Rec;
400      x_eco_revision_tbl         := l_eco_revision_tbl;
401      x_revised_item_tbl         := l_revised_item_tbl;
402      x_rev_component_tbl        := l_rev_component_tbl;
403      x_ref_designator_tbl       := l_ref_designator_tbl;
404      x_sub_component_tbl        := l_sub_component_tbl;
405      x_rev_operation_tbl        := l_rev_operation_tbl;
406      x_rev_op_resource_tbl      := l_rev_op_resource_tbl;
407      x_rev_sub_resource_tbl     := l_rev_sub_resource_tbl;
408      x_Mesg_Token_Tbl           := l_Mesg_Token_Tbl;
409 
410 END Rev_Sub_Res;
411 
412 -- Added by Masahiko Mochizuki on 09/12/00
413 --  Rev_Op_Res
414 
415 PROCEDURE Rev_Op_Res
416 (   p_unexp_rev_op_res_rec          IN  BOM_RTG_PUB.Rev_Op_Res_Unexposed_Rec_Type
417 ,   p_rev_op_resource_tbl           IN  BOM_RTG_PUB.Rev_Op_Resource_Tbl_Type
418 ,   p_rev_sub_resource_tbl          IN  BOM_RTG_PUB.Rev_Sub_Resource_Tbl_Type
419 ,   x_ECO_rec                       IN OUT NOCOPY ENG_Eco_PUB.Eco_Rec_Type
420 ,   x_unexp_rev_op_res_rec          IN OUT NOCOPY BOM_RTG_PUB.Rev_Op_Res_Unexposed_Rec_Type
421 ,   x_eco_revision_tbl              IN OUT NOCOPY ENG_Eco_PUB.Eco_Revision_Tbl_Type
422 ,   x_revised_item_tbl              IN OUT NOCOPY ENG_Eco_PUB.Revised_Item_Tbl_Type
423 ,   x_rev_component_tbl             IN OUT NOCOPY BOM_BO_PUB.Rev_Component_Tbl_Type
424 ,   x_ref_designator_tbl            IN OUT NOCOPY BOM_BO_PUB.Ref_Designator_Tbl_Type
425 ,   x_sub_component_tbl             IN OUT NOCOPY BOM_BO_PUB.Sub_Component_Tbl_Type
426 ,   x_rev_operation_tbl             IN OUT NOCOPY BOM_RTG_PUB.Rev_operation_Tbl_Type
427 ,   x_rev_op_resource_tbl           IN OUT NOCOPY BOM_RTG_PUB.Rev_op_resource_Tbl_Type
428 ,   x_rev_sub_resource_tbl          IN OUT NOCOPY BOM_RTG_PUB.Rev_sub_resource_Tbl_Type
429 ,   x_Mesg_Token_Tbl                IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
430 ,   x_return_status                 IN OUT NOCOPY VARCHAR2
431 )
432 IS
433 
434 l_Mesg_Token_Tbl        Error_Handler.Mesg_Token_Tbl_Type;
435 l_other_token_tbl       Error_Handler.Token_Tbl_Type;
436 l_other_message         VARCHAR2(50);
437 l_err_text              VARCHAR2(2000);
438 l_valid                 BOOLEAN := TRUE;
439 l_Return_Status         VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
440 l_bo_return_status      VARCHAR2(1) := 'S';
441 l_rev_op_resource_Rec       BOM_RTG_PUB.Rev_Op_Resource_Rec_Type;
442 l_rev_op_res_unexp_Rec      BOM_RTG_PUB.Rev_Op_Res_Unexposed_Rec_Type := p_unexp_rev_op_res_rec;
443 l_old_rev_op_resource_Rec   BOM_RTG_PUB.Rev_Op_Resource_Rec_Type := NULL;
444 l_old_rev_op_res_unexp_Rec  BOM_RTG_PUB.Rev_Op_Res_Unexposed_Rec_Type := NULL;
445 l_eco_rec               ENG_ECO_PUB.ECO_Rec_Type := NULL;
446 l_eco_revision_tbl      ENG_Eco_PUB.Eco_Revision_Tbl_Type;
447 l_revised_item_tbl      ENG_Eco_PUB.Revised_Item_Tbl_Type;
448 l_rev_component_tbl     BOM_BO_PUB.Rev_Component_Tbl_Type;
449 l_ref_designator_tbl    BOM_BO_PUB.Ref_Designator_Tbl_Type;
450 l_sub_component_tbl     BOM_BO_PUB.Sub_Component_Tbl_Type;
451 l_rev_operation_tbl     BOM_RTG_PUB.Rev_Operation_Tbl_Type;
452 l_rev_op_resource_tbl   BOM_RTG_PUB.Rev_Op_Resource_Tbl_Type := p_rev_op_resource_tbl;
453 l_rev_sub_resource_tbl  BOM_RTG_PUB.Rev_Sub_Resource_Tbl_Type := p_rev_sub_resource_tbl;
454 l_return_value          NUMBER;
455 l_Token_Tbl             Error_Handler.Token_Tbl_Type;
456 
457 EXC_SEV_QUIT_RECORD     EXCEPTION;
458 EXC_UNEXP_SKIP_OBJECT   EXCEPTION;
459 
460 BEGIN
461 
462     -- Begin block that processes revised items. This block holds the exception handlers
463     -- for header errors.
464 
465     FOR I IN 1..l_rev_op_resource_tbl.COUNT LOOP
466     BEGIN
467         --  Load local records.
468 
469         l_rev_op_resource_rec := l_rev_op_resource_tbl(I);
470 
471         l_rev_op_resource_rec.transaction_type :=
472                 UPPER(l_rev_op_resource_rec.transaction_type);
473 
474         l_return_status := FND_API.G_RET_STS_SUCCESS;
475         l_rev_op_resource_rec.return_status := FND_API.G_RET_STS_SUCCESS;
476 
477         -- Process Flow step 3: Verify Operation Resource's existence
478         --
479 
480         IF g_control_rec.check_existence
481         THEN
482                 --dbms_output.put_line('Checking Existence');
483                 Bom_Validate_Op_Res.Check_Existence
484                 (  p_rev_op_resource_rec        => l_rev_op_resource_rec
485                 ,  p_rev_op_res_unexp_rec       => l_rev_op_res_unexp_rec
486                 ,  x_old_rev_op_resource_rec    => l_old_rev_op_resource_rec
487                 ,  x_old_rev_op_res_unexp_rec   => l_old_rev_op_res_unexp_rec
488                 ,  x_Mesg_Token_Tbl             => x_Mesg_Token_Tbl
489                 ,  x_return_status              => x_Return_Status
490                 );
491 
492                 --dbms_output.put_line('return_status: ' || l_return_status);
493 
494                 IF l_return_status = Error_Handler.G_STATUS_ERROR
495                 THEN
496                         RAISE EXC_SEV_QUIT_RECORD;
497                 ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
498                 THEN
499                         RAISE EXC_UNEXP_SKIP_OBJECT;
500                 END IF;
501         END IF;
502 
503         -- Set parent revised item attributes
504         Set_RevItem_Attributes
505         (  p_revised_item_sequence_id    => l_rev_op_res_unexp_rec.revised_item_sequence_id
506          , p_bo_processed                => 'RTG'
507         ) ;
508 
509 
510      -- Process Flow step 12 - Entity Level Validation
511 
512         IF g_control_rec.entity_validation
513         THEN
514                 --dbms_output.put_line('Entity validation');
515                 IF l_rev_op_resource_rec.transaction_type = 'DELETE'
516                 THEN
517                         NULL;
518                         /*Eng_Validate_Revised_Item.Check_Entity_Delete
519                         (  p_rev_op_resource_rec     => l_rev_op_resource_rec
520                         ,  p_rev_operation_unexp_rec => l_rev_operation_unexp_rec
521                         ,  x_Mesg_Token_Tbl          => l_Mesg_Token_Tbl
522                         ,  x_return_status           => l_Return_Status
523                         );*/
524                 ELSE
525                         Bom_Validate_Op_Res.Check_Entity
526                         (  p_rev_op_resource_rec      => l_rev_op_resource_rec
527                         ,  p_rev_op_res_unexp_rec     => l_rev_op_res_unexp_rec
528                         ,  p_old_rev_op_resource_rec  => l_old_rev_op_resource_rec
529                         ,  p_old_rev_op_res_unexp_rec => l_old_rev_op_res_unexp_rec
530                         ,  p_control_rec              => Bom_Rtg_Pub.G_Default_Control_Rec
531                         ,  x_rev_op_resource_rec      => l_rev_op_resource_rec
532                         ,  x_rev_op_res_unexp_rec     => l_rev_op_res_unexp_rec
533                         ,  x_return_status            => l_return_status
534                         ,  x_mesg_token_tbl           => l_mesg_token_tbl
535                         );
536                 END IF;
537 
538                 --dbms_output.put_line('return_status: ' || l_return_status);
539 
540                 IF l_return_status = Error_Handler.G_STATUS_ERROR
541                 THEN
542                         RAISE EXC_SEV_QUIT_RECORD;
543                 ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
544                 THEN
545                         RAISE EXC_UNEXP_SKIP_OBJECT;
546                 ELSIF l_return_status ='S' AND
547                       l_Mesg_Token_Tbl.COUNT <>0
548                 THEN
549                         Eco_Error_Handler.Log_Error
550                         (  p_rev_op_resource_tbl  => l_rev_op_resource_tbl
551                         ,  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl
552                         ,  p_mesg_token_tbl       => l_mesg_token_tbl
553                         ,  p_error_status         => 'W'
554                         ,  p_error_level          => Error_Handler.G_RES_LEVEL
555                         ,  p_entity_index         => I
556                         ,  x_eco_rec              => l_eco_rec
557                         ,  x_eco_revision_tbl     => l_eco_revision_tbl
558                         ,  x_revised_item_tbl     => l_revised_item_tbl
559                         ,  x_rev_component_tbl    => l_rev_component_tbl
560                         ,  x_ref_designator_tbl   => l_ref_designator_tbl
561                         ,  x_sub_component_tbl    => l_sub_component_tbl
562                         ,  x_rev_operation_tbl    => l_rev_operation_tbl
563                         ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl
564                         ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl
565                         );
566                 END IF;
567         END IF;
568 
569         -- Process Flow step 13 : Database Writes
570 --dbms_output.put_line('checking if to write to db');
571         IF g_control_rec.write_to_db
572         THEN
573                 bom_globals.set_user_id(p_user_id => g_control_rec.last_updated_by);
574                 bom_rtg_globals.set_user_id(p_user_id => g_control_rec.last_updated_by);
575                 bom_globals.set_login_id(p_login_id => g_control_rec.last_update_login);
576                 bom_rtg_globals.set_login_id(p_login_id => g_control_rec.last_update_login);
577 
578                 --dbms_output.put_line('Writing to the database');
579                 Bom_Op_Res_Util.Perform_Writes
580                 (   p_rev_op_resource_rec       => l_rev_op_resource_rec
581                 ,   p_rev_op_res_unexp_rec      => l_rev_op_res_unexp_rec
582                 ,   p_control_rec               => Bom_Rtg_Pub.G_Default_Control_Rec
583                 ,   x_Mesg_Token_Tbl            => l_Mesg_Token_Tbl
584                 ,   x_return_status             => l_return_status
585                 );
586 
587                 --dbms_output.put_line('return_status: ' || l_return_status);
588 
589                 IF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
590                 THEN
591                         RAISE EXC_UNEXP_SKIP_OBJECT;
592                 ELSIF l_return_status ='S' AND
593                       l_Mesg_Token_Tbl.COUNT <>0
594                 THEN
595                         Eco_Error_Handler.Log_Error
596                         (  p_rev_op_resource_tbl  => l_rev_op_resource_tbl
597                         ,  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl
598                         ,  p_mesg_token_tbl       => l_mesg_token_tbl
599                         ,  p_error_status         => 'W'
600                         ,  p_error_level          => Error_Handler.G_RES_LEVEL
601                         ,  p_entity_index         => I
602                         ,  x_eco_rec              => l_eco_rec
603                         ,  x_eco_revision_tbl     => l_eco_revision_tbl
604                         ,  x_revised_item_tbl     => l_revised_item_tbl
605                         ,  x_rev_component_tbl    => l_rev_component_tbl
606                         ,  x_ref_designator_tbl   => l_ref_designator_tbl
607                         ,  x_sub_component_tbl    => l_sub_component_tbl
608                         ,  x_rev_operation_tbl    => l_rev_operation_tbl
609                         ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl
610                         ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl
611                         );
612                 END IF;
613         END IF;
614 
615         l_rev_op_resource_tbl(I) := l_rev_op_resource_rec;
616 
617   EXCEPTION
618 
619     WHEN EXC_SEV_QUIT_RECORD THEN
620 
621         --dbms_output.put_line('Expected error generated');
622         l_rev_op_resource_tbl(I) := l_rev_op_resource_rec;
623         Eco_Error_Handler.Log_Error
624                 (  p_rev_op_resource_tbl  => l_rev_op_resource_tbl
625                 ,  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl
626                 ,  p_mesg_token_tbl       => l_mesg_token_tbl
627                 ,  p_error_status         => FND_API.G_RET_STS_ERROR
628                 ,  p_error_scope          => Error_Handler.G_SCOPE_RECORD
629                 ,  p_error_level          => Error_Handler.G_RES_LEVEL
630                 ,  p_entity_index         => I
631                 ,  x_eco_rec              => l_eco_rec
632                 ,  x_eco_revision_tbl     => l_eco_revision_tbl
633                 ,  x_revised_item_tbl     => l_revised_item_tbl
634                 ,  x_rev_component_tbl    => l_rev_component_tbl
635                 ,  x_ref_designator_tbl   => l_ref_designator_tbl
636                 ,  x_sub_component_tbl    => l_sub_component_tbl
637                 ,  x_rev_operation_tbl    => l_rev_operation_tbl
638                 ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl
639                 ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl
640                 );
641 
642         x_return_status                := l_return_status;
643         x_Mesg_Token_Tbl               := l_Mesg_Token_Tbl;
644         x_ECO_rec                      := l_ECO_rec;
645         x_rev_op_resource_tbl          := l_rev_op_resource_tbl;
646         x_unexp_rev_op_res_rec         := l_rev_op_res_unexp_rec;
647         x_eco_revision_tbl             := l_eco_revision_tbl;
648         x_revised_item_tbl             := l_revised_item_tbl;
649         x_ref_designator_tbl           := l_ref_designator_tbl;
650         x_sub_component_tbl            := l_sub_component_tbl;
651         x_rev_component_tbl            := l_rev_component_tbl;
652         x_rev_operation_tbl            := l_rev_operation_tbl;
653         x_rev_sub_resource_tbl        := l_rev_sub_resource_tbl;
654 
655         RETURN;
656 
657     WHEN EXC_UNEXP_SKIP_OBJECT THEN
658 
659         --dbms_output.put_line('Unexpected error generated');
660         Eco_Error_Handler.Log_Error
661                 (  p_rev_op_resource_tbl  => l_rev_op_resource_tbl
662                 ,  p_mesg_token_tbl       => l_mesg_token_tbl
663                 ,  p_error_status         => Error_Handler.G_STATUS_UNEXPECTED
664                 ,  p_other_status         => Error_Handler.G_STATUS_NOT_PICKED
665                 ,  p_other_message        => l_other_message
666                 ,  p_other_token_tbl      => l_other_token_tbl
667                 ,  p_error_level          => Error_Handler.G_RES_LEVEL
668                 ,  p_entity_index         => I
669                 ,  x_ECO_rec              => l_ECO_rec
670                 ,  x_eco_revision_tbl     => l_eco_revision_tbl
671                 ,  x_revised_item_tbl     => l_revised_item_tbl
672                 ,  x_rev_component_tbl    => l_rev_component_tbl
673                 ,  x_ref_designator_tbl   => l_ref_designator_tbl
674                 ,  x_sub_component_tbl    => l_sub_component_tbl
675                 ,  x_rev_operation_tbl    => l_rev_operation_tbl
676                 ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl
677                 ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl
678                 );
679 
680         x_Mesg_Token_Tbl               := l_Mesg_Token_Tbl;
681         x_ECO_rec                      := l_ECO_rec;
682         x_rev_op_resource_tbl          := l_rev_op_resource_tbl;
683         x_unexp_rev_op_res_rec         := l_rev_op_res_unexp_rec;
684         x_eco_revision_tbl             := l_eco_revision_tbl;
685         x_revised_item_tbl             := l_revised_item_tbl;
686         x_ref_designator_tbl           := l_ref_designator_tbl;
687         x_rev_component_tbl            := l_rev_component_tbl;
688         x_sub_component_tbl            := l_sub_component_tbl;
689         x_rev_operation_tbl            := l_rev_operation_tbl;
690         x_rev_sub_resource_tbl         := l_rev_sub_resource_tbl;
691 
692         l_return_status := 'U';
693 
694   END;
695   END LOOP; -- END revised items processing block
696 
697     IF l_return_status in ('Q', 'U')
698     THEN
699         x_return_status := l_return_status;
700         RETURN;
701     END IF;
702 
703     l_bo_return_status := l_return_status;
704 
705      x_return_status            := l_bo_return_status;
706      x_ECO_rec                  := l_ECO_rec;
707      x_unexp_rev_op_res_rec     := l_rev_op_res_unexp_Rec;
708      x_eco_revision_tbl         := l_eco_revision_tbl;
709      x_revised_item_tbl         := l_revised_item_tbl;
710      x_rev_component_tbl        := l_rev_component_tbl;
711      x_ref_designator_tbl       := l_ref_designator_tbl;
712      x_sub_component_tbl        := l_sub_component_tbl;
713      x_rev_operation_tbl        := l_rev_operation_tbl;
714      x_rev_op_resource_tbl      := l_rev_op_resource_tbl;
715      x_rev_sub_resource_tbl     := l_rev_sub_resource_tbl;
716      x_Mesg_Token_Tbl           := l_Mesg_Token_Tbl;
717 
718 END Rev_Op_Res;
719 
720 -- Added by Masahiko Mochizuki on 09/12/00
721 --  Rev_Ops
722 
723 PROCEDURE Rev_Ops
724 (   p_rev_operation_tbl             IN  BOM_RTG_PUB.Rev_operation_Tbl_Type
725 ,   p_unexp_rev_op_rec              IN  BOM_RTG_PUB.Rev_Op_Unexposed_Rec_Type
726 ,   p_rev_op_resource_tbl           IN  BOM_RTG_PUB.Rev_op_resource_Tbl_Type
727 ,   p_rev_sub_resource_tbl          IN  BOM_RTG_PUB.Rev_sub_resource_Tbl_Type
728 ,   x_ECO_rec                       IN OUT NOCOPY ENG_Eco_PUB.Eco_Rec_Type
729 ,   x_unexp_rev_op_rec              IN OUT NOCOPY BOM_RTG_PUB.Rev_Op_Unexposed_Rec_Type
730 ,   x_eco_revision_tbl              IN OUT NOCOPY ENG_Eco_PUB.Eco_Revision_Tbl_Type
731 ,   x_revised_item_tbl              IN OUT NOCOPY ENG_Eco_PUB.Revised_Item_Tbl_Type
732 ,   x_rev_component_tbl             IN OUT NOCOPY BOM_BO_PUB.Rev_Component_Tbl_Type
733 ,   x_ref_designator_tbl            IN OUT NOCOPY BOM_BO_PUB.Ref_Designator_Tbl_Type
734 ,   x_sub_component_tbl             IN OUT NOCOPY BOM_BO_PUB.Sub_Component_Tbl_Type
735 ,   x_rev_operation_tbl             IN OUT NOCOPY BOM_RTG_PUB.Rev_operation_Tbl_Type
736 ,   x_rev_op_resource_tbl           IN OUT NOCOPY BOM_RTG_PUB.Rev_op_resource_Tbl_Type
737 ,   x_rev_sub_resource_tbl          IN OUT NOCOPY BOM_RTG_PUB.Rev_sub_resource_Tbl_Type
738 ,   x_Mesg_Token_Tbl                IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
739 ,   x_return_status                 IN OUT NOCOPY VARCHAR2
740 )
741 IS
742 
743 l_Mesg_Token_Tbl        Error_Handler.Mesg_Token_Tbl_Type;
744 l_other_token_tbl       Error_Handler.Token_Tbl_Type;
745 l_other_message         VARCHAR2(50);
746 l_err_text              VARCHAR2(2000);
747 l_valid                 BOOLEAN := TRUE;
748 l_Return_Status         VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
749 l_bo_return_status      VARCHAR2(1) := 'S';
750 l_rev_operation_Rec     BOM_RTG_PUB.Rev_Operation_Rec_Type;
751 l_rev_op_unexp_Rec      BOM_RTG_PUB.Rev_Op_Unexposed_Rec_Type := p_unexp_rev_op_rec;
752 l_old_rev_operation_Rec BOM_RTG_PUB.Rev_Operation_Rec_Type := NULL;
753 l_old_rev_op_unexp_Rec  BOM_RTG_PUB.Rev_Op_Unexposed_Rec_Type := NULL;
754 l_eco_rec               ENG_ECO_PUB.ECO_Rec_Type := NULL;
755 l_eco_revision_tbl      ENG_Eco_PUB.Eco_Revision_Tbl_Type;
756 l_revised_item_tbl      ENG_Eco_PUB.Revised_Item_Tbl_Type;
757 l_rev_component_tbl     BOM_BO_PUB.Rev_Component_Tbl_Type;
758 l_ref_designator_tbl    BOM_BO_PUB.Ref_Designator_Tbl_Type;
759 l_sub_component_tbl     BOM_BO_PUB.Sub_Component_Tbl_Type;
760 l_rev_operation_tbl     BOM_RTG_PUB.Rev_Operation_Tbl_Type := p_rev_operation_tbl;
761 l_rev_op_resource_tbl   BOM_RTG_PUB.Rev_Op_Resource_Tbl_Type := p_rev_op_resource_tbl;
762 l_rev_sub_resource_tbl  BOM_RTG_PUB.Rev_Sub_Resource_Tbl_Type := p_rev_sub_resource_tbl;
763 l_return_value          NUMBER;
764 l_Token_Tbl             Error_Handler.Token_Tbl_Type;
765 l_query_op_seq_num      NUMBER := NULL;
766 -- Bug no:2770096
767 l_routing_sequence_id   NUMBER := NULL;
768 l_query_effective_date  DATE := NULL;
769 
770 EXC_SEV_QUIT_RECORD     EXCEPTION;
771 EXC_UNEXP_SKIP_OBJECT   EXCEPTION;
772 
773 BEGIN
774 
775     -- Begin block that processes revised items. This block holds the exception handlers
776     -- for header errors.
777 
778 IF BOM_Globals.get_debug = 'Y'
779 THEN
780      error_handler.write_debug('At the beginning of Rev_Op, the rec count is');
781      error_handler.write_debug( l_rev_operation_tbl.COUNT);
782 END IF;
783  FOR I IN 1..l_rev_operation_tbl.COUNT LOOP
784     BEGIN
785         --  Load local records.
786 
787         l_rev_operation_rec := l_rev_operation_tbl(I);
788 
789         l_rev_operation_rec.transaction_type :=
790                 UPPER(l_rev_operation_rec.transaction_type);
791 
792         l_return_status := FND_API.G_RET_STS_SUCCESS;
793         l_rev_operation_rec.return_status := FND_API.G_RET_STS_SUCCESS;
794 
795         -- Process Flow step 3: Verify Revised Operation's existence
796         --
797 IF BOM_Globals.get_debug = 'Y'
798 THEN
799      error_handler.write_debug('At the beginning of check existence');
800 END IF;
801         IF g_control_rec.check_existence
802         THEN
803                 --dbms_output.put_line('Checking Existence');
804                 Bom_Validate_Op_Seq.Check_Existence
805                 (  p_rev_operation_rec     => l_rev_operation_rec
806                 ,  p_rev_op_unexp_rec      => l_rev_op_unexp_rec
807                 ,  x_old_rev_operation_rec => l_old_rev_operation_rec
808                 ,  x_old_rev_op_unexp_rec  => l_old_rev_op_unexp_rec
809                 ,  x_return_status         => l_return_status
810                 ,  x_mesg_token_tbl        => l_mesg_token_tbl
811                 );
812 
813 IF BOM_Globals.get_debug = 'Y'
814 THEN
815      error_handler.write_debug('After check existence, the return status is');
816      error_handler.write_debug( l_Return_Status);
817 END IF;
818 
819 
820                 IF l_return_status = Error_Handler.G_STATUS_ERROR
821                 THEN
822                         RAISE EXC_SEV_QUIT_RECORD;
823                 ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
824                 THEN
825                         RAISE EXC_UNEXP_SKIP_OBJECT;
826                 END IF;
827         END IF;
828 
829         -- Set parent revised item attributes
830         Set_RevItem_Attributes
831         (  p_revised_item_sequence_id    => l_rev_op_unexp_rec.revised_item_sequence_id
832          , p_bo_processed                => 'RTG'
833         ) ;
834 
835 
836         IF g_control_rec.attribute_defaulting AND
837            l_rev_operation_rec.Transaction_Type = ENG_GLOBALS.G_OPR_CREATE
838         THEN
839 
840                 -- Process Flow step 9: Default missing values for Operation CREATE
841 IF BOM_Globals.get_debug = 'Y'
842 THEN
843      error_handler.write_debug('before op_seq attribute , the return status is');
844      error_handler.write_debug( l_Return_Status);
845 END IF;
846                 Bom_Default_Op_Seq.Attribute_Defaulting
847                 (  p_rev_operation_rec     => l_rev_operation_rec
848                 ,  p_rev_op_unexp_rec      => l_rev_op_unexp_rec
849                 ,  p_control_rec           => Bom_Rtg_Pub.G_Default_Control_Rec
850                 ,  x_rev_operation_rec     => l_rev_operation_rec
851                 ,  x_rev_op_unexp_rec      => l_rev_op_unexp_rec
852                 ,  x_return_status         => l_return_status
853                 ,  x_mesg_token_tbl        => l_mesg_token_tbl
854                 );
855 
856                 --dbms_output.put_line('pvt item num: ' || to_char(l_rev_operation_rec.item_sequence_number));
857 
858                 --dbms_output.put_line('return_status: ' || l_return_status);
859 
860                 IF l_return_status = Error_Handler.G_STATUS_ERROR
861                 THEN
862                         RAISE EXC_SEV_QUIT_RECORD;
863                 ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
864                 THEN
865                         RAISE EXC_UNEXP_SKIP_OBJECT;
866                 ELSIF l_return_status ='S' AND                     l_Mesg_Token_Tbl.COUNT <>0
867                 THEN
868                         Eco_Error_Handler.Log_Error
869                         (  p_rev_operation_tbl    => l_rev_operation_tbl
870                         ,  p_rev_op_resource_tbl  => l_rev_op_resource_tbl
871                         ,  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl
872                         ,  p_mesg_token_tbl       => l_mesg_token_tbl
873                         ,  p_error_status         => 'W'
874                         ,  p_error_level          => Error_Handler.G_OP_LEVEL
875                         ,  p_entity_index         => I
876                         ,  x_eco_rec              => l_eco_rec
877                         ,  x_eco_revision_tbl     => l_eco_revision_tbl
878                         ,  x_revised_item_tbl     => l_revised_item_tbl
879                         ,  x_rev_component_tbl    => l_rev_component_tbl
880                         ,  x_ref_designator_tbl   => l_ref_designator_tbl
881                         ,  x_sub_component_tbl    => l_sub_component_tbl
882                         ,  x_rev_operation_tbl    => l_rev_operation_tbl
883                         ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl
884                         ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl
885                         );
886                 END IF;
887         END IF;
888 
889 
890         IF ((g_control_rec.entity_defaulting AND
891              NOT g_control_rec.attribute_defaulting)
892             OR
893             g_control_rec.entity_validation)
894            AND
895            (l_rev_operation_rec.transaction_type='UPDATE'
896             OR
897            (l_rev_operation_rec.transaction_type = 'CREATE'
898             AND l_rev_operation_rec.acd_type = 2)
899             )
900         THEN
901                 IF l_rev_operation_rec.transaction_type='UPDATE'
902                 THEN
903 
904                      -- Bug #1614911
905                      -- Form does not have new operatin seq num.
906                      -- and Form always passes the new operation seq num value
907                      -- to operation_sequence_number and new_operation_sequence_number
908                      -- in l_rev_operation_rec.
909                      --
910                      -- Hence theis logic get the original op seq num and
911                      -- effective date using operation_sequence_id
912                      -- Bug no:2770096 ,selecting routing_sequence_id also
913                      BEGIN
914 
915                          SELECT operation_seq_num ,
916                                 effectivity_date ,
917 				routing_sequence_id
918                          INTO   l_query_op_seq_num ,
919                                 l_query_effective_date,
920 				l_routing_sequence_id
921                          FROM   BOM_OPERATION_SEQUENCES
922                          WHERE  operation_sequence_id
923                                   =  l_rev_op_unexp_rec.operation_sequence_id  ;
924                      EXCEPTION
925                          WHEN OTHERS THEN
926                               NULL ;
927                      END  ;
928 
929                      /* Comment Out
930                         l_query_op_seq_num := l_rev_operation_rec.new_operation_sequence_number;
931                         l_query_effective_date := l_rev_operation_rec.start_effective_date;
932                      */
933                 ELSE
934                         l_query_op_seq_num := l_rev_operation_rec.old_operation_sequence_number;
935                         l_query_effective_date := l_rev_operation_rec.old_start_effective_date;
936                 END IF;
937 
938                 --dbms_output.put_line('querying row');
939 
940 IF BOM_Globals.get_debug = 'Y'
941 THEN
942      error_handler.write_debug('before query_row, the return status is');
943      error_handler.write_debug( l_Return_Status);
944 END IF;
945 
946 --Bug 2827097
947 
948 if(l_rev_operation_rec.acd_type = 2 )then
949    l_routing_sequence_id :=l_rev_op_unexp_rec.routing_sequence_id;
950 end if;
951 
952 --end of Bug 2827097
953                 Bom_Op_Seq_Util.Query_Row
954                    -- Modified conditions for Bug1609574
955                    ( p_operation_sequence_number => l_query_op_seq_num
956                                                     --  l_rev_operation_rec.old_operation_sequence_number
957                    , p_effectivity_date          => l_query_effective_date
958                                                     --  l_rev_operation_rec.old_start_effective_date
959                    , p_routing_sequence_id       => l_routing_sequence_id --Bug no:2770096
960 		                                   --l_rev_op_unexp_rec.routing_sequence_id
961                    , p_operation_type            => l_rev_operation_rec.operation_type
962                    , p_mesg_token_tbl            => l_mesg_token_tbl
963                    , x_rev_operation_rec         => l_old_rev_operation_rec
964                    , x_rev_op_unexp_rec          => l_old_rev_op_unexp_rec
965                    , x_mesg_token_tbl            => l_mesg_token_tbl
966                    , x_return_status             => l_return_status
967                    );
968 
969                 --dbms_output.put_line('query return_status: ' || l_return_status);
970 
971                 IF l_return_status = 'N'
972                 THEN
973                         -- Added for Bug1609574
974                         l_return_status := Error_Handler.G_STATUS_ERROR ;
975                         l_Token_Tbl(1).token_name := 'OP_SEQ_NUMBER';
976                         l_Token_Tbl(1).token_value :=
977                                  l_rev_operation_rec.operation_sequence_number ;
978 
979                         Error_Handler.Add_Error_Token
980                         ( p_message_name       => 'BOM_OP_CREATE_REC_NOT_FOUND'
981                         , p_mesg_token_tbl     => l_Mesg_Token_Tbl
982                         , p_token_tbl          => l_Token_Tbl
983                         , x_Mesg_Token_Tbl     => l_Mesg_Token_Tbl
984                         );
985 
986                         RAISE EXC_SEV_QUIT_RECORD;
987                 ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
988                 THEN
989                         RAISE EXC_UNEXP_SKIP_OBJECT;
990                 ELSIF l_return_status ='S' AND
991                       l_Mesg_Token_Tbl.COUNT <>0
992                 THEN
993                         Eco_Error_Handler.Log_Error
994                         (  p_rev_operation_tbl    => l_rev_operation_tbl
995                         ,  p_rev_op_resource_tbl  => l_rev_op_resource_tbl
996                         ,  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl
997                         ,  p_mesg_token_tbl       => l_mesg_token_tbl
998                         ,  p_error_status         => 'W'
999                         ,  p_error_level          => Error_Handler.G_OP_LEVEL
1000                         ,  p_entity_index         => I
1001                         ,  x_eco_rec              => l_eco_rec
1002                         ,  x_eco_revision_tbl     => l_eco_revision_tbl
1003                         ,  x_revised_item_tbl     => l_revised_item_tbl
1004                         ,  x_rev_component_tbl    => l_rev_component_tbl
1005                         ,  x_ref_designator_tbl   => l_ref_designator_tbl
1006                         ,  x_sub_component_tbl    => l_sub_component_tbl
1007                         ,  x_rev_operation_tbl    => l_rev_operation_tbl
1008                         ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl
1009                         ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl
1010                         );
1011 
1012                 END IF;
1013 
1014 /*              IF l_return_status = 'F'
1015                 THEN
1016                         dbms_output.put_line('queried old record');
1017                 ELSIF l_return_status = 'N'
1018                 THEN
1019                         dbms_output.put_line('old record not found');
1020                 END IF;*/
1021         END IF;
1022 
1023      -- Process Flow step 11 - Entity Level Defaulting
1024 
1025         IF g_control_rec.entity_defaulting
1026         THEN
1027                 --dbms_output.put_line('Entity Defaulting');
1028 IF BOM_Globals.get_debug = 'Y'
1029 THEN
1030      error_handler.write_debug('before entity_defaulting , the return status is');
1031      error_handler.write_debug( l_Return_Status);
1032 END IF;
1033 
1034                 Bom_Default_Op_Seq.Entity_Defaulting
1035                 (   p_rev_operation_rec     => l_rev_operation_rec
1036                 ,   p_rev_op_unexp_rec      => l_rev_op_unexp_rec
1037                 ,   p_control_rec           => Bom_Rtg_Pub.G_Default_Control_Rec
1038                 ,   x_rev_operation_rec     => l_rev_operation_rec
1039                 ,   x_rev_op_unexp_rec      => l_rev_op_unexp_rec
1040                 ,   x_return_status         => l_return_status
1041                 ,   x_mesg_token_tbl        => l_mesg_token_tbl
1042                 );
1043 
1044                 --dbms_output.put_line('pvt item num: ' || to_char(l_rev_operation_rec.item_sequence_number));
1045 
1046                 --dbms_output.put_line('return_status: ' || l_return_status);
1047 
1048                 IF l_return_status = Error_Handler.G_STATUS_ERROR
1049                 THEN
1050                         RAISE EXC_SEV_QUIT_RECORD;
1051                 ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
1052                 THEN
1053                         RAISE EXC_UNEXP_SKIP_OBJECT;
1054                 ELSIF l_return_status ='S' AND
1055                       l_Mesg_Token_Tbl.COUNT <>0
1056                 THEN
1057                         Eco_Error_Handler.Log_Error
1058                         (  p_rev_operation_tbl    => l_rev_operation_tbl
1059                         ,  p_rev_op_resource_tbl  => l_rev_op_resource_tbl
1060                         ,  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl
1061                         ,  p_mesg_token_tbl       => l_mesg_token_tbl
1062                         ,  p_error_status         => 'W'
1063                         ,  p_error_level          => Error_Handler.G_OP_LEVEL
1064                         ,  p_entity_index         => I
1065                         ,  x_eco_rec              => l_eco_rec
1066                         ,  x_eco_revision_tbl     => l_eco_revision_tbl
1067                         ,  x_revised_item_tbl     => l_revised_item_tbl
1068                         ,  x_rev_component_tbl    => l_rev_component_tbl
1069                         ,  x_ref_designator_tbl   => l_ref_designator_tbl
1070                         ,  x_sub_component_tbl    => l_sub_component_tbl
1071                         ,  x_rev_operation_tbl    => l_rev_operation_tbl
1072                         ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl
1073                         ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl
1074                         );
1075                 END IF;
1076         END IF;
1077 
1078      -- Process Flow step 12 - Entity Level Validation
1079         IF g_control_rec.entity_validation
1080         THEN
1081 
1082 IF BOM_Globals.get_debug = 'Y'
1083 THEN
1084      error_handler.write_debug('before entity validation , the return status is');
1085      error_handler.write_debug( l_Return_Status);
1086 END IF;
1087 
1088                 --dbms_output.put_line('Entity validation');
1089                 IF l_rev_operation_rec.transaction_type = 'DELETE'
1090                 THEN
1091                         NULL;
1092                         /*Eng_Validate_Revised_Item.Check_Entity_Delete
1093                         (  p_rev_operation_rec    => l_rev_operation_rec
1094                         ,  p_rev_item_unexp_rec   => l_rev_item_unexp_rec
1095                         ,  x_Mesg_Token_Tbl       => l_Mesg_Token_Tbl
1096                         ,  x_return_status        => l_Return_Status
1097                         );*/
1098                 ELSE
1099 IF BOM_Globals.get_debug = 'Y'
1100 THEN
1101      error_handler.write_debug('before calling Bom_Validate_Op_Seq.Check_Entity,the return status is');
1102      error_handler.write_debug( l_Return_Status);
1103      error_handler.write_debug( l_rev_operation_rec.operation_sequence_number);
1104       error_handler.write_debug( l_rev_operation_rec.count_point_type);
1105       error_handler.write_debug( l_rev_operation_rec.backflush_flag);
1106 
1107      error_handler.write_debug(  'then all others:'           );
1108       error_handler.write_debug(  l_rev_operation_rec.eco_name           );
1109       error_handler.write_debug(  l_rev_operation_rec.organization_code  );
1110       error_handler.write_debug(  l_rev_operation_rec.revised_item_name );
1111       error_handler.write_debug(  l_rev_operation_rec.new_revised_item_revision  );
1112       error_handler.write_debug(  l_rev_operation_rec.ACD_Type                );
1113       error_handler.write_debug(  l_rev_operation_rec.Alternate_Routing_Code   );
1114       error_handler.write_debug(  l_rev_operation_rec.Operation_Type        );
1115       error_handler.write_debug(  l_rev_operation_rec.Start_Effective_Date  );
1116       error_handler.write_debug(  l_rev_operation_rec.new_operation_sequence_number);
1117       error_handler.write_debug(  l_rev_operation_rec.Old_Operation_Sequence_Number );
1118       error_handler.write_debug(  l_rev_operation_rec.Old_Start_Effective_Date    );
1119       error_handler.write_debug(  l_rev_operation_rec.Standard_Operation_Code   );
1120       error_handler.write_debug(  l_rev_operation_rec.Department_Code           );
1121       error_handler.write_debug(  l_rev_operation_rec.Op_Lead_Time_Percent     );
1122       error_handler.write_debug(  l_rev_operation_rec.Minimum_Transfer_Quantity);
1123       error_handler.write_debug(  l_rev_operation_rec.Operation_Description    );
1124       error_handler.write_debug(  l_rev_operation_rec.Disable_Date            );
1125       error_handler.write_debug(  l_rev_operation_rec.Option_Dependent_Flag   );
1126       error_handler.write_debug(  l_rev_operation_rec.Reference_Flag         );
1127       error_handler.write_debug(  l_rev_operation_rec.Yield                  );
1128       error_handler.write_debug(  l_rev_operation_rec.Cumulative_Yield       );
1129       error_handler.write_debug(  l_rev_operation_rec.Cancel_Comments       );
1130       error_handler.write_debug(  l_rev_operation_rec.Attribute_category);
1131     error_handler.write_debug( 'After attribute_category');
1132       error_handler.write_debug(  l_rev_operation_rec.Original_System_Reference   );
1133       error_handler.write_debug(  l_rev_operation_rec.Transaction_Type        );
1134       error_handler.write_debug(  l_rev_operation_rec.Return_Status          );
1135 END IF;
1136 
1137 
1138 
1139 
1140                         Bom_Validate_Op_Seq.Check_Entity
1141                         (  p_rev_operation_rec     => l_rev_operation_rec
1142                         ,  p_rev_op_unexp_rec      => l_rev_op_unexp_rec
1143                         ,  p_old_rev_operation_rec => l_old_rev_operation_rec
1144                         ,  p_old_rev_op_unexp_rec  => l_old_rev_op_unexp_rec
1145                         ,  p_control_rec           => Bom_Rtg_Pub.G_Default_Control_Rec
1146                         ,  x_rev_operation_rec     => l_rev_operation_rec
1147                         ,  x_rev_op_unexp_rec      => l_rev_op_unexp_rec
1148                         ,  x_return_status         => l_return_status
1149                         ,  x_mesg_token_tbl        => l_mesg_token_tbl
1150                         );
1151 
1152                 END IF;
1153 
1154                 --dbms_output.put_line('return_status: ' || l_return_status);
1155 
1156                 IF l_return_status = Error_Handler.G_STATUS_ERROR
1157                 THEN
1158                         RAISE EXC_SEV_QUIT_RECORD;
1159                 ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
1160                 THEN
1161                         RAISE EXC_UNEXP_SKIP_OBJECT;
1162                 ELSIF l_return_status ='S' AND
1163                       l_Mesg_Token_Tbl.COUNT <>0
1164                 THEN
1165                         --dbms_output.put_line('logging warnings');
1166                         Eco_Error_Handler.Log_Error
1167                         (  p_rev_operation_tbl    => l_rev_operation_tbl
1168                         ,  p_rev_op_resource_tbl  => l_rev_op_resource_tbl
1169                         ,  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl
1170                         ,  p_mesg_token_tbl       => l_mesg_token_tbl
1171                         ,  p_error_status         => 'W'
1172                         ,  p_error_level          => Error_Handler.G_OP_LEVEL
1173                         ,  p_entity_index         => I
1174                         ,  x_eco_rec              => l_eco_rec
1175                         ,  x_eco_revision_tbl     => l_eco_revision_tbl
1176                         ,  x_revised_item_tbl     => l_revised_item_tbl
1177                         ,  x_rev_component_tbl    => l_rev_component_tbl
1178                         ,  x_ref_designator_tbl   => l_ref_designator_tbl
1179                         ,  x_sub_component_tbl    => l_sub_component_tbl
1180                         ,  x_rev_operation_tbl    => l_rev_operation_tbl
1181                         ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl
1182                         ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl
1183                         );
1184                 END IF;
1185         END IF;
1186 
1187         -- Process Flow step 13 : Database Writes
1188 
1189 
1190         IF g_control_rec.write_to_db
1191         THEN
1192 
1193 IF BOM_Globals.get_debug = 'Y'
1194 THEN
1195      error_handler.write_debug('Before write_to_db, the return status is');
1196      error_handler.write_debug( l_Return_Status);
1197      error_handler.write_debug( l_rev_op_unexp_rec.operation_sequence_id);
1198 END IF;
1199                 bom_globals.set_user_id(p_user_id => g_control_rec.last_updated_by);
1200                 bom_rtg_globals.set_user_id(p_user_id => g_control_rec.last_updated_by);
1201                 bom_globals.set_login_id(p_login_id => g_control_rec.last_update_login);
1202                 bom_rtg_globals.set_login_id(p_login_id => g_control_rec.last_update_login);
1203 
1204 
1205            ENG_Globals.Perform_Writes_For_Primary_Rtg
1206               (   p_rev_operation_rec       => l_rev_operation_rec
1207               ,   p_rev_op_unexp_rec        => l_rev_op_unexp_rec
1208               ,   x_mesg_token_tbl          => l_mesg_token_tbl
1209               ,   x_return_status           => l_return_status
1210               ) ;
1211 
1212            IF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
1213            THEN
1214                l_other_message := 'BOM_OP_WRITES_UNEXP_SKIP';
1215                l_other_token_tbl(1).token_name := 'OP_SEQ_NUMBER';
1216                l_other_token_tbl(1).token_value :=
1217                           l_rev_operation_rec.operation_sequence_number ;
1218                RAISE EXC_UNEXP_SKIP_OBJECT ;
1219            ELSIF l_return_status ='S' AND
1220                l_mesg_token_tbl .COUNT <>0
1221            THEN
1222                ECO_Error_Handler.Log_Error
1223                (  p_rev_operation_tbl   => l_rev_operation_tbl
1224                ,  p_rev_op_resource_tbl => l_rev_op_resource_tbl
1225                ,  p_rev_sub_resource_tbl=> l_rev_sub_resource_tbl
1226                ,  p_mesg_token_tbl      => l_mesg_token_tbl
1227                ,  p_error_status        => 'W'
1228                ,  p_error_level         => Error_Handler.G_OP_LEVEL
1229                ,  p_entity_index        => I
1230                ,  x_ECO_rec             => l_ECO_rec
1231                ,  x_eco_revision_tbl    => l_eco_revision_tbl
1232                ,  x_revised_item_tbl    => l_revised_item_tbl
1233                ,  x_rev_component_tbl   => l_rev_component_tbl
1234                ,  x_ref_designator_tbl  => l_ref_designator_tbl
1235                ,  x_sub_component_tbl   => l_sub_component_tbl
1236                ,  x_rev_operation_tbl   => l_rev_operation_tbl
1237                ,  x_rev_op_resource_tbl => l_rev_op_resource_tbl
1238                ,  x_rev_sub_resource_tbl=> l_rev_sub_resource_tbl
1239                ) ;
1240            END IF;
1241 
1242                 --dbms_output.put_line('Writing to the database');
1243                 BOM_Op_Seq_Util.Perform_Writes
1244                 (   p_rev_operation_rec     => l_rev_operation_rec
1245                 ,   p_rev_op_unexp_rec      => l_rev_op_unexp_rec
1246                 ,   p_control_rec           => Bom_Rtg_Pub.G_Default_Control_Rec
1247                 ,   x_return_status         => l_return_status
1248                 ,   x_mesg_token_tbl        => l_mesg_token_tbl
1249                 );
1250 
1251                 --dbms_output.put_line('return_status: ' || l_return_status);
1252 
1253                 IF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
1254                 THEN
1255                         RAISE EXC_UNEXP_SKIP_OBJECT;
1256                 ELSIF l_return_status ='S' AND
1257                       l_Mesg_Token_Tbl.COUNT <>0
1258                 THEN
1259                         Eco_Error_Handler.Log_Error
1260                         (  p_rev_operation_tbl    => l_rev_operation_tbl
1261                         ,  p_rev_op_resource_tbl  => l_rev_op_resource_tbl
1262                         ,  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl
1263                         ,  p_mesg_token_tbl       => l_mesg_token_tbl
1264                         ,  p_error_status         => 'W'
1265                         ,  p_error_level          => Error_Handler.G_OP_LEVEL
1266                         ,  p_entity_index         => I
1267                         ,  x_eco_rec              => l_eco_rec
1268                         ,  x_eco_revision_tbl     => l_eco_revision_tbl
1269                         ,  x_revised_item_tbl     => l_revised_item_tbl
1270                         ,  x_rev_component_tbl    => l_rev_component_tbl
1271                         ,  x_ref_designator_tbl   => l_ref_designator_tbl
1272                         ,  x_sub_component_tbl    => l_sub_component_tbl
1273                         ,  x_rev_operation_tbl    => l_rev_operation_tbl
1274                         ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl
1275                         ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl
1276                         );
1277                 END IF;
1278         END IF;
1279 
1280         l_rev_operation_tbl(I) := l_rev_operation_rec;
1281 
1282 
1283 IF BOM_Globals.get_debug = 'Y'
1284 THEN
1285     error_handler.write_debug( 'after checck entity ');
1286    error_handler.write_debug( l_rev_operation_tbl(1).operation_sequence_number);
1287       error_handler.write_debug( l_rev_operation_tbl(1).count_point_type);
1288       error_handler.write_debug( l_rev_operation_tbl(1).backflush_flag);
1289 
1290      error_handler.write_debug(  'then all others:'           );
1291       error_handler.write_debug(  l_rev_operation_tbl(1).eco_name           );
1292       error_handler.write_debug(  l_rev_operation_tbl(1).organization_code  );
1293       error_handler.write_debug(  l_rev_operation_tbl(1).revised_item_name );
1294       error_handler.write_debug(  l_rev_operation_tbl(1).new_revised_item_revision  );
1295       error_handler.write_debug(  l_rev_operation_tbl(1).ACD_Type                );
1296       error_handler.write_debug(  l_rev_operation_tbl(1).Alternate_Routing_Code   );
1297       error_handler.write_debug(  l_rev_operation_tbl(1).Operation_Type        );
1298       error_handler.write_debug(  l_rev_operation_tbl(1).Start_Effective_Date  );
1299       error_handler.write_debug(  l_rev_operation_tbl(1).new_operation_sequence_number);
1300       error_handler.write_debug(  l_rev_operation_tbl(1).Old_Operation_Sequence_Number );
1301       error_handler.write_debug(  l_rev_operation_tbl(1).Old_Start_Effective_Date    );
1302       error_handler.write_debug(  l_rev_operation_tbl(1).Standard_Operation_Code   );
1303       error_handler.write_debug(  l_rev_operation_tbl(1).Department_Code           );
1304       error_handler.write_debug(  l_rev_operation_tbl(1).Op_Lead_Time_Percent     );
1305       error_handler.write_debug(  l_rev_operation_tbl(1).Minimum_Transfer_Quantity);
1306       error_handler.write_debug(  l_rev_operation_tbl(1).Operation_Description    );
1307       error_handler.write_debug(  l_rev_operation_tbl(1).Disable_Date            );
1308       error_handler.write_debug(  l_rev_operation_tbl(1).Option_Dependent_Flag   );
1309       error_handler.write_debug(  l_rev_operation_tbl(1).Reference_Flag         );
1310       error_handler.write_debug(  l_rev_operation_tbl(1).Yield                  );
1311       error_handler.write_debug(  l_rev_operation_tbl(1).Cumulative_Yield       );
1312       error_handler.write_debug(  l_rev_operation_tbl(1).Cancel_Comments       );
1313       error_handler.write_debug(  l_rev_operation_tbl(1).Attribute_category);
1314     error_handler.write_debug( 'After attribute_category');
1315       error_handler.write_debug(  l_rev_operation_tbl(1).Original_System_Reference   );
1316       error_handler.write_debug(  l_rev_operation_tbl(1).Transaction_Type        );
1317       error_handler.write_debug(  l_rev_operation_tbl(1).Return_Status          );
1318   --    error_handler.write_debug(     l_rev_operation_tbl(1).Revised_Item_Sequence_Id    );
1319    --   error_handler.write_debug(     l_rev_operation_tbl(1).Operation_Sequence_Id      );
1320    --   error_handler.write_debug(     l_rev_operation_tbl(1).Old_Operation_Sequence_Id  );
1321    --   error_handler.write_debug(     l_rev_operation_tbl(1).Routing_Sequence_Id      );
1322    --   error_handler.write_debug(     l_rev_operation_tbl(1).Revised_Item_Id          );
1323    --   error_handler.write_debug(     l_rev_operation_tbl(1).Organization_Id          );
1324    --   error_handler.write_debug(     l_rev_operation_tbl(1).Standard_Operation_Id    );
1325     --  error_handler.write_debug(     l_rev_operation_tbl(1).Department_Id            );
1326 
1327      error_handler.write_debug('End of Rev_Op, the return status is');
1328      error_handler.write_debug( l_Return_Status);
1329 END IF;
1330 
1331   EXCEPTION
1332 
1333     WHEN EXC_SEV_QUIT_RECORD THEN
1334 
1335         --dbms_output.put_line('Expected error generated');
1336         l_rev_operation_tbl(I) := l_rev_operation_rec;
1337         Eco_Error_Handler.Log_Error
1338                         (  p_rev_operation_tbl    => l_rev_operation_tbl
1339                         ,  p_rev_op_resource_tbl  => l_rev_op_resource_tbl
1340                         ,  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl
1341                         ,  p_mesg_token_tbl       => l_mesg_token_tbl
1342                         ,  p_error_status         => FND_API.G_RET_STS_ERROR
1343                         ,  p_error_scope          => Error_Handler.G_SCOPE_RECORD
1344                         ,  p_error_level          => Error_Handler.G_OP_LEVEL
1345                         ,  p_entity_index         => I
1346                         ,  x_eco_rec              => l_eco_rec
1347                         ,  x_eco_revision_tbl     => l_eco_revision_tbl
1348                         ,  x_revised_item_tbl     => l_revised_item_tbl
1349                         ,  x_rev_component_tbl    => l_rev_component_tbl
1350                         ,  x_ref_designator_tbl   => l_ref_designator_tbl
1351                         ,  x_sub_component_tbl    => l_sub_component_tbl
1352                         ,  x_rev_operation_tbl    => l_rev_operation_tbl
1353                         ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl
1354                         ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl
1355                         );
1356 
1357         x_return_status                := l_return_status;
1358         x_Mesg_Token_Tbl               := l_Mesg_Token_Tbl;
1359         x_ECO_rec                      := l_ECO_rec;
1360         x_rev_operation_tbl            := l_rev_operation_tbl;
1361         x_unexp_rev_op_rec             := l_rev_op_unexp_rec;
1362         x_eco_revision_tbl             := l_eco_revision_tbl;
1363         x_revised_item_tbl             := l_revised_item_tbl;
1364         x_ref_designator_tbl           := l_ref_designator_tbl;
1365         x_sub_component_tbl            := l_sub_component_tbl;
1366         x_rev_op_resource_tbl          := l_rev_op_resource_tbl;
1367         x_rev_sub_resource_tbl         := l_rev_sub_resource_tbl;
1368                 --dbms_output.put_line('err pvt item num: ' || to_char(l_rev_operation_rec.item_sequence_number));
1369 
1370         RETURN;
1371 
1372     WHEN EXC_UNEXP_SKIP_OBJECT THEN
1373 
1374         --dbms_output.put_line('Unexpected error generated');
1375         Eco_Error_Handler.Log_Error
1376                 (  p_rev_operation_tbl    => l_rev_operation_tbl
1377                 ,  p_rev_op_resource_tbl  => l_rev_op_resource_tbl
1378                 ,  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl
1379                 ,  p_mesg_token_tbl       => l_mesg_token_tbl
1380                 ,  p_error_status         => Error_Handler.G_STATUS_UNEXPECTED
1381                 ,  p_other_status         => Error_Handler.G_STATUS_NOT_PICKED
1382                 ,  p_other_message        => l_other_message
1383                 ,  p_other_token_tbl      => l_other_token_tbl
1384                 ,  p_error_level          => Error_Handler.G_OP_LEVEL
1385                 ,  p_entity_index         => I
1386                 ,  x_ECO_rec              => l_ECO_rec
1387                 ,  x_eco_revision_tbl     => l_eco_revision_tbl
1388                 ,  x_revised_item_tbl     => l_revised_item_tbl
1389                 ,  x_rev_component_tbl    => l_rev_component_tbl
1390                 ,  x_ref_designator_tbl   => l_ref_designator_tbl
1391                 ,  x_sub_component_tbl    => l_sub_component_tbl
1392                 ,  x_rev_operation_tbl    => l_rev_operation_tbl
1393                 ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl
1394                 ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl
1395                 );
1396 
1397         l_return_status := 'U';
1398 --dbms_output.put_line('unexp message' || l_mesg_token_tbl(1).message_text);
1399         x_return_status                := l_return_status;
1400         x_Mesg_Token_Tbl               := l_Mesg_Token_Tbl;
1401         x_ECO_rec                      := l_ECO_rec;
1402         x_eco_revision_tbl             := l_eco_revision_tbl;
1403         x_revised_item_tbl             := l_revised_item_tbl;
1404         x_rev_component_tbl            := l_rev_component_tbl;
1405         x_ref_designator_tbl           := l_ref_designator_tbl;
1406         x_sub_component_tbl            := l_sub_component_tbl;
1407         x_rev_operation_tbl            := l_rev_operation_tbl;
1408         x_unexp_rev_op_rec             := l_rev_op_unexp_rec;
1409         x_rev_op_resource_tbl          := l_rev_op_resource_tbl;
1410         x_rev_sub_resource_tbl         := l_rev_sub_resource_tbl;
1411 
1412   END;
1413   END LOOP; -- END revised items processing block
1414 
1415     IF l_return_status in ('Q', 'U')
1416     THEN
1417         x_return_status := l_return_status;
1418         RETURN;
1419     END IF;
1420 
1421     l_bo_return_status := l_return_status;
1422 
1423      x_return_status            := l_bo_return_status;
1424      x_ECO_rec                  := l_ECO_rec;
1425      x_unexp_rev_op_rec         := l_rev_op_unexp_Rec;
1426      x_eco_revision_tbl         := l_eco_revision_tbl;
1427      x_revised_item_tbl         := l_revised_item_tbl;
1428      x_rev_component_tbl        := l_rev_component_tbl;
1429      x_ref_designator_tbl       := l_ref_designator_tbl;
1430      x_sub_component_tbl        := l_sub_component_tbl;
1431      x_rev_operation_tbl        := l_rev_operation_tbl;
1432      x_rev_op_resource_tbl      := l_rev_op_resource_tbl;
1433      x_rev_sub_resource_tbl     := l_rev_sub_resource_tbl;
1434      x_Mesg_Token_Tbl           := l_Mesg_Token_Tbl;
1435                 --dbms_output.put_line('end pvt item num: ' || to_char(l_rev_operation_rec.item_sequence_number));
1436 
1437 END Rev_Ops;
1438 
1439 --  Sub_Comps
1440 
1441 PROCEDURE Sub_Comps
1442 (   p_unexp_sub_comp_rec            IN  BOM_BO_PUB.Sub_Comp_Unexposed_Rec_Type
1443 ,   p_ref_designator_tbl            IN  BOM_BO_PUB.Ref_Designator_Tbl_Type
1444 ,   p_sub_component_tbl             IN  BOM_BO_PUB.Sub_Component_Tbl_Type
1445 ,   x_ECO_rec                       IN OUT NOCOPY ENG_Eco_PUB.Eco_Rec_Type
1446 ,   x_unexp_sub_comp_rec            IN OUT NOCOPY BOM_BO_PUB.Sub_Comp_Unexposed_Rec_Type
1447 ,   x_eco_revision_tbl              IN OUT NOCOPY ENG_Eco_PUB.Eco_Revision_Tbl_Type
1448 ,   x_revised_item_tbl              IN OUT NOCOPY ENG_Eco_PUB.Revised_Item_Tbl_Type
1449 ,   x_rev_component_tbl             IN OUT NOCOPY BOM_BO_PUB.Rev_Component_Tbl_Type
1450 ,   x_ref_designator_tbl            IN OUT NOCOPY BOM_BO_PUB.Ref_Designator_Tbl_Type
1451 ,   x_sub_component_tbl             IN OUT NOCOPY BOM_BO_PUB.Sub_Component_Tbl_Type
1452 ,   x_rev_operation_tbl             IN OUT NOCOPY BOM_RTG_PUB.Rev_operation_Tbl_Type    --add
1453 ,   x_rev_op_resource_tbl           IN OUT NOCOPY BOM_RTG_PUB.Rev_op_resource_Tbl_Type  --add
1454 ,   x_rev_sub_resource_tbl          IN OUT NOCOPY BOM_RTG_PUB.Rev_sub_resource_Tbl_Type --add
1455 ,   x_Mesg_Token_Tbl                IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
1456 ,   x_return_status                 IN OUT NOCOPY VARCHAR2
1457 )
1458 IS
1459 
1460 l_Mesg_Token_Tbl        Error_Handler.Mesg_Token_Tbl_Type;
1461 l_other_token_tbl       Error_Handler.Token_Tbl_Type;
1462 l_other_message         VARCHAR2(50);
1463 l_err_text              VARCHAR2(2000);
1464 l_valid                 BOOLEAN := TRUE;
1465 l_Return_Status         VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
1466 l_bo_return_status      VARCHAR2(1) := 'S';
1467 l_sub_component_Rec      BOM_BO_PUB.Sub_Component_Rec_Type;
1468 l_sub_comp_unexp_Rec     BOM_BO_PUB.Sub_Comp_Unexposed_Rec_Type := p_unexp_sub_comp_rec;
1469 l_old_sub_component_Rec  BOM_BO_PUB.Sub_Component_Rec_Type := NULL;
1470 l_old_sub_comp_unexp_Rec BOM_BO_PUB.Sub_Comp_Unexposed_Rec_Type := NULL;
1471 l_eco_rec               ENG_ECO_PUB.ECO_Rec_Type := NULL;
1472 l_eco_revision_tbl      ENG_Eco_PUB.Eco_Revision_Tbl_Type;
1473 l_revised_item_tbl      ENG_Eco_PUB.Revised_Item_Tbl_Type;
1474 l_rev_component_tbl     BOM_BO_PUB.Rev_Component_Tbl_Type;
1475 l_ref_designator_tbl    BOM_BO_PUB.Ref_Designator_Tbl_Type := p_ref_designator_tbl;
1476 l_sub_component_tbl     BOM_BO_PUB.Sub_Component_Tbl_Type := p_sub_component_tbl;
1477 l_rev_operation_tbl     BOM_RTG_PUB.Rev_Operation_Tbl_Type;     --add
1478 l_rev_op_resource_tbl   BOM_RTG_PUB.Rev_Op_Resource_Tbl_Type;   --add
1479 l_rev_sub_resource_tbl  BOM_RTG_PUB.Rev_Sub_Resource_Tbl_Type;  --add
1480 l_return_value          NUMBER;
1481 l_Token_Tbl             Error_Handler.Token_Tbl_Type;
1482 
1483 EXC_SEV_QUIT_RECORD     EXCEPTION;
1484 EXC_UNEXP_SKIP_OBJECT   EXCEPTION;
1485 
1486 BEGIN
1487 
1488     -- Begin block that processes revised items. This block holds the exception handlers
1489     -- for header errors.
1490 
1491     FOR I IN 1..l_sub_component_tbl.COUNT LOOP
1492     BEGIN
1493         --  Load local records.
1494 
1495         l_sub_component_rec := l_sub_component_tbl(I);
1496 
1497         l_sub_component_rec.transaction_type :=
1498                 UPPER(l_sub_component_rec.transaction_type);
1499 
1500         l_return_status := FND_API.G_RET_STS_SUCCESS;
1501         l_sub_component_rec.return_status := FND_API.G_RET_STS_SUCCESS;
1502 
1503         -- Process Flow step 3: Verify Substitute Component's existence
1504         --
1505 
1506         IF g_control_rec.check_existence
1507         THEN
1508                 --dbms_output.put_line('Checking Existence');
1509                 Bom_Validate_Sub_Component.Check_Existence
1510                 (  p_sub_component_rec          => l_sub_component_rec
1511                 ,  p_sub_comp_unexp_rec         => l_sub_comp_unexp_rec
1512                 ,  x_old_sub_component_rec      => l_old_sub_component_rec
1513                 ,  x_old_sub_comp_unexp_rec     => l_old_sub_comp_unexp_rec
1514                 ,  x_Mesg_Token_Tbl             => l_Mesg_Token_Tbl
1515                 ,  x_return_status              => l_Return_Status
1516                 );
1517 
1518                 --dbms_output.put_line('return_status: ' || l_return_status);
1519 
1520                 IF l_return_status = Error_Handler.G_STATUS_ERROR
1521                 THEN
1522                         RAISE EXC_SEV_QUIT_RECORD;
1523                 ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
1524                 THEN
1525                         RAISE EXC_UNEXP_SKIP_OBJECT;
1526                 END IF;
1527         END IF;
1528 
1529         -- Set parent revised item attributes
1530         Set_RevItem_Attributes
1531         (  p_revised_item_sequence_id    => l_sub_comp_unexp_rec.revised_item_sequence_id
1532          , p_bo_processed                => 'BOM'
1533         ) ;
1534 
1535 
1536      -- Process Flow step 12 - Entity Level Validation
1537 
1538         IF g_control_rec.entity_validation
1539         THEN
1540                 --dbms_output.put_line('Entity validation');
1541                 IF l_sub_component_rec.transaction_type = 'DELETE'
1542                 THEN
1543                         NULL;
1544                         /*Eng_Validate_Revised_Item.Check_Entity_Delete
1545                         (  p_rev_component_rec     => l_rev_component_rec
1546                         ,  p_rev_item_unexp_rec   => l_rev_item_unexp_rec
1547                         ,  x_Mesg_Token_Tbl       => l_Mesg_Token_Tbl
1548                         ,  x_return_status        => l_Return_Status
1549                         );*/
1550                 ELSE
1551                         Bom_Validate_Sub_Component.Check_Entity
1552                         (  p_sub_component_rec          => l_sub_component_rec
1553                         ,  p_sub_comp_unexp_rec         => l_sub_comp_unexp_rec
1554                         ,  p_control_rec                => g_control_rec
1555                         ,  x_Mesg_Token_Tbl             => l_Mesg_Token_Tbl
1556                         ,  x_return_status              => l_Return_Status
1557                         );
1558                 END IF;
1559 
1560                 --dbms_output.put_line('return_status: ' || l_return_status);
1561 
1562                 IF l_return_status = Error_Handler.G_STATUS_ERROR
1563                 THEN
1564                         RAISE EXC_SEV_QUIT_RECORD;
1565                 ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
1566                 THEN
1567                         RAISE EXC_UNEXP_SKIP_OBJECT;
1568                 ELSIF l_return_status ='S' AND
1569                       l_Mesg_Token_Tbl.COUNT <>0
1570                 THEN
1571                         Eco_Error_Handler.Log_Error
1572                         (  p_ref_designator_tbl => l_ref_designator_tbl
1573                         ,  p_sub_component_tbl  => l_sub_component_tbl
1574                         ,  p_mesg_token_tbl     => l_mesg_token_tbl
1575                         ,  p_error_status       => 'W'
1576                         ,  p_error_level        => 6
1577                         ,  p_entity_index       => I
1578                         ,  x_eco_rec            => l_eco_rec
1579                         ,  x_eco_revision_tbl   => l_eco_revision_tbl
1580                         ,  x_revised_item_tbl   => l_revised_item_tbl
1581                         ,  x_rev_component_tbl  => l_rev_component_tbl
1582                         ,  x_ref_designator_tbl => l_ref_designator_tbl
1583                         ,  x_sub_component_tbl  => l_sub_component_tbl
1584                         ,  x_rev_operation_tbl    => l_rev_operation_tbl     --add
1585                         ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl   --add
1586                         ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl  --add
1587                         );
1588                 END IF;
1589         END IF;
1590 
1591         -- Process Flow step 13 : Database Writes
1592 --dbms_output.put_line('checking if to write to db');
1593         IF g_control_rec.write_to_db
1594         THEN
1595                 bom_globals.set_user_id(p_user_id => g_control_rec.last_updated_by);
1596                 bom_globals.set_login_id(p_login_id => g_control_rec.last_update_login);
1597 
1598                 --dbms_output.put_line('Writing to the database');
1599                 Bom_Sub_Component_Util.Perform_Writes
1600                 (   p_sub_component_rec         => l_sub_component_rec
1601                 ,   p_sub_comp_unexp_rec        => l_sub_comp_unexp_rec
1602                 ,   x_Mesg_Token_Tbl            => l_Mesg_Token_Tbl
1603                 ,   x_return_status             => l_return_status
1604                 );
1605 
1606                 --dbms_output.put_line('return_status: ' || l_return_status);
1607 
1608                 IF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
1609                 THEN
1610                         RAISE EXC_UNEXP_SKIP_OBJECT;
1611                 ELSIF l_return_status ='S' AND
1612                       l_Mesg_Token_Tbl.COUNT <>0
1613                 THEN
1614                         Eco_Error_Handler.Log_Error
1615                         (  p_ref_designator_tbl => l_ref_designator_tbl
1616                         ,  p_sub_component_tbl  => l_sub_component_tbl
1617                         ,  p_mesg_token_tbl     => l_mesg_token_tbl
1618                         ,  p_error_status       => 'W'
1619                         ,  p_error_level        => 6
1620                         ,  p_entity_index       => I
1621                         ,  x_eco_rec            => l_eco_rec
1622                         ,  x_eco_revision_tbl   => l_eco_revision_tbl
1623                         ,  x_revised_item_tbl   => l_revised_item_tbl
1624                         ,  x_rev_component_tbl  => l_rev_component_tbl
1625                         ,  x_ref_designator_tbl => l_ref_designator_tbl
1626                         ,  x_sub_component_tbl  => l_sub_component_tbl
1627                         ,  x_rev_operation_tbl    => l_rev_operation_tbl     --add
1628                         ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl   --add
1629                         ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl  --add
1630                         );
1631                 END IF;
1632         END IF;
1633 
1634         l_sub_component_tbl(I) := l_sub_component_rec;
1635 
1636   EXCEPTION
1637 
1638     WHEN EXC_SEV_QUIT_RECORD THEN
1639 
1640         --dbms_output.put_line('Expected error generated');
1641         l_sub_component_tbl(I) := l_sub_component_rec;
1642         Eco_Error_Handler.Log_Error
1643                 (  p_ref_designator_tbl => l_ref_designator_tbl
1644                 ,  p_sub_component_tbl  => l_sub_component_tbl
1645                 ,  p_mesg_token_tbl     => l_mesg_token_tbl
1646                 ,  p_error_status       => FND_API.G_RET_STS_ERROR
1647                 ,  p_error_scope        => Error_Handler.G_SCOPE_RECORD
1648                 ,  p_error_level        => 6
1649                 ,  p_entity_index       => I
1650                 ,  x_eco_rec            => l_eco_rec
1651                 ,  x_eco_revision_tbl   => l_eco_revision_tbl
1652                 ,  x_revised_item_tbl   => l_revised_item_tbl
1653                 ,  x_rev_component_tbl  => l_rev_component_tbl
1654                 ,  x_ref_designator_tbl => l_ref_designator_tbl
1655                 ,  x_sub_component_tbl  => l_sub_component_tbl
1656                 ,  x_rev_operation_tbl    => l_rev_operation_tbl     --add
1657                 ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl   --add
1658                 ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl  --add
1659                 );
1660 
1661         x_return_status                := l_return_status;
1662         x_Mesg_Token_Tbl               := l_Mesg_Token_Tbl;
1663         x_ECO_rec                      := l_ECO_rec;
1664         x_sub_component_tbl            := l_sub_component_tbl;
1665         x_unexp_sub_comp_rec           := l_sub_comp_unexp_rec;
1666         x_eco_revision_tbl             := l_eco_revision_tbl;
1667         x_revised_item_tbl             := l_revised_item_tbl;
1668         x_ref_designator_tbl           := l_ref_designator_tbl;
1669         x_rev_component_tbl            := l_rev_component_tbl;
1670         x_rev_operation_tbl            := l_rev_operation_tbl;     --add
1671         x_rev_op_resource_tbl          := l_rev_op_resource_tbl;   --add
1672         x_rev_sub_resource_tbl         := l_rev_sub_resource_tbl;  --add
1673 
1674         RETURN;
1675 
1676     WHEN EXC_UNEXP_SKIP_OBJECT THEN
1677 
1678         --dbms_output.put_line('Unexpected error generated');
1679         Eco_Error_Handler.Log_Error
1680                 (  p_sub_component_tbl  => l_sub_component_tbl
1681                 ,  p_mesg_token_tbl     => l_mesg_token_tbl
1682                 ,  p_error_status       => Error_Handler.G_STATUS_UNEXPECTED
1683                 ,  p_other_status       => Error_Handler.G_STATUS_NOT_PICKED
1684                 ,  p_other_message      => l_other_message
1685                 ,  p_other_token_tbl    => l_other_token_tbl
1686                 ,  p_error_level        => 6
1687                 ,  p_entity_index       => I
1688                 ,  x_ECO_rec            => l_ECO_rec
1689                 ,  x_eco_revision_tbl   => l_eco_revision_tbl
1690                 ,  x_revised_item_tbl   => l_revised_item_tbl
1691                 ,  x_rev_component_tbl  => l_rev_component_tbl
1692                 ,  x_ref_designator_tbl => l_ref_designator_tbl
1693                 ,  x_sub_component_tbl  => l_sub_component_tbl
1694                 ,  x_rev_operation_tbl     => l_rev_operation_tbl     --add
1695                 ,  x_rev_op_resource_tbl   => l_rev_op_resource_tbl   --add
1696                 ,  x_rev_sub_resource_tbl  => l_rev_sub_resource_tbl  --add
1697                 );
1698 
1699         x_Mesg_Token_Tbl               := l_Mesg_Token_Tbl;
1700         x_ECO_rec                      := l_ECO_rec;
1701         x_sub_component_tbl            := l_sub_component_tbl;
1702         x_unexp_sub_comp_rec           := l_sub_comp_unexp_rec;
1703         x_eco_revision_tbl             := l_eco_revision_tbl;
1704         x_revised_item_tbl             := l_revised_item_tbl;
1705         x_ref_designator_tbl           := l_ref_designator_tbl;
1706         x_rev_component_tbl            := l_rev_component_tbl;
1707         x_rev_operation_tbl            := l_rev_operation_tbl;     --add
1708         x_rev_op_resource_tbl          := l_rev_op_resource_tbl;   --add
1709         x_rev_sub_resource_tbl         := l_rev_sub_resource_tbl;  --add
1710 
1711         l_return_status := 'U';
1712 
1713   END;
1714   END LOOP; -- END revised items processing block
1715 
1716     IF l_return_status in ('Q', 'U')
1717     THEN
1718         x_return_status := l_return_status;
1719         RETURN;
1720     END IF;
1721 
1722     l_bo_return_status := l_return_status;
1723 
1724      x_return_status            := l_bo_return_status;
1725      x_ECO_rec                  := l_ECO_rec;
1726      x_unexp_sub_comp_rec       := l_sub_comp_unexp_Rec;
1727      x_eco_revision_tbl         := l_eco_revision_tbl;
1728      x_revised_item_tbl         := l_revised_item_tbl;
1729      x_rev_component_tbl        := l_rev_component_tbl;
1730      x_ref_designator_tbl       := l_ref_designator_tbl;
1731      x_sub_component_tbl        := l_sub_component_tbl;
1732      x_rev_operation_tbl        := l_rev_operation_tbl;     --add
1733      x_rev_op_resource_tbl      := l_rev_op_resource_tbl;   --add
1734      x_rev_sub_resource_tbl     := l_rev_sub_resource_tbl;  --add
1735      x_Mesg_Token_Tbl           := l_Mesg_Token_Tbl;
1736 
1737 END Sub_Comps;
1738 
1739 --  Ref_Desgs
1740 
1741 PROCEDURE Ref_Desgs
1742 (   p_unexp_ref_desg_rec            IN  BOM_BO_PUB.Ref_Desg_Unexposed_Rec_Type
1743 ,   p_ref_designator_tbl            IN  BOM_BO_PUB.Ref_Designator_Tbl_Type
1744 ,   p_sub_component_tbl             IN  BOM_BO_PUB.Sub_Component_Tbl_Type
1745 ,   x_ECO_rec                       IN OUT NOCOPY ENG_Eco_PUB.Eco_Rec_Type
1746 ,   x_unexp_ref_desg_rec            IN OUT NOCOPY BOM_BO_PUB.Ref_Desg_Unexposed_Rec_Type
1747 ,   x_eco_revision_tbl              IN OUT NOCOPY ENG_Eco_PUB.Eco_Revision_Tbl_Type
1748 ,   x_revised_item_tbl              IN OUT NOCOPY ENG_Eco_PUB.Revised_Item_Tbl_Type
1749 ,   x_rev_component_tbl             IN OUT NOCOPY BOM_BO_PUB.Rev_Component_Tbl_Type
1750 ,   x_ref_designator_tbl            IN OUT NOCOPY BOM_BO_PUB.Ref_Designator_Tbl_Type
1751 ,   x_sub_component_tbl             IN OUT NOCOPY BOM_BO_PUB.Sub_Component_Tbl_Type
1752 ,   x_rev_operation_tbl             IN OUT NOCOPY BOM_RTG_PUB.Rev_operation_Tbl_Type     --add
1753 ,   x_rev_op_resource_tbl           IN OUT NOCOPY BOM_RTG_PUB.Rev_op_resource_Tbl_Type   --add
1754 ,   x_rev_sub_resource_tbl          IN OUT NOCOPY BOM_RTG_PUB.Rev_sub_resource_Tbl_Type  --add
1755 ,   x_Mesg_Token_Tbl                IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
1756 ,   x_return_status                 IN OUT NOCOPY VARCHAR2
1757 )
1758 IS
1759 
1760 l_Mesg_Token_Tbl        Error_Handler.Mesg_Token_Tbl_Type;
1761 l_other_token_tbl       Error_Handler.Token_Tbl_Type;
1762 l_other_message         VARCHAR2(50);
1763 l_err_text              VARCHAR2(2000);
1764 l_valid                 BOOLEAN := TRUE;
1765 l_Return_Status         VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
1766 l_bo_return_status      VARCHAR2(1) := 'S';
1767 l_ref_designator_Rec    BOM_BO_PUB.Ref_Designator_Rec_Type;
1768 l_ref_desg_unexp_Rec    BOM_BO_PUB.Ref_Desg_Unexposed_Rec_Type := p_unexp_ref_desg_rec;
1769 l_old_ref_designator_Rec BOM_BO_PUB.Ref_Designator_Rec_Type := NULL;
1770 l_old_ref_desg_unexp_Rec BOM_BO_PUB.Ref_Desg_Unexposed_Rec_Type := NULL;
1771 l_eco_rec               ENG_ECO_PUB.ECO_Rec_Type := NULL;
1772 l_eco_revision_tbl      ENG_Eco_PUB.Eco_Revision_Tbl_Type;
1773 l_revised_item_tbl      ENG_Eco_PUB.Revised_Item_Tbl_Type;
1774 l_rev_component_tbl     BOM_BO_PUB.Rev_Component_Tbl_Type;
1775 l_ref_designator_tbl    BOM_BO_PUB.Ref_Designator_Tbl_Type := p_ref_designator_tbl;
1776 l_sub_component_tbl     BOM_BO_PUB.Sub_Component_Tbl_Type := p_sub_component_tbl;
1777 l_rev_operation_tbl     BOM_RTG_PUB.Rev_Operation_Tbl_Type;      --add
1778 l_rev_op_resource_tbl   BOM_RTG_PUB.Rev_Op_Resource_Tbl_Type;    --add
1779 l_rev_sub_resource_tbl  BOM_RTG_PUB.Rev_Sub_Resource_Tbl_Type;   --add
1780 l_return_value          NUMBER;
1781 l_Token_Tbl             Error_Handler.Token_Tbl_Type;
1782 
1783 EXC_SEV_QUIT_RECORD     EXCEPTION;
1784 EXC_UNEXP_SKIP_OBJECT   EXCEPTION;
1785 
1786 BEGIN
1787 
1788     -- Begin block that processes revised items. This block holds the exception handlers
1789     -- for header errors.
1790 
1791     FOR I IN 1..l_ref_designator_tbl.COUNT LOOP
1792     BEGIN
1793         --  Load local records.
1794 
1795         l_ref_designator_rec := l_ref_designator_tbl(I);
1796 
1797         l_ref_designator_rec.transaction_type :=
1798                 UPPER(l_ref_designator_rec.transaction_type);
1799 
1800         l_return_status := FND_API.G_RET_STS_SUCCESS;
1801         l_ref_designator_rec.return_status := FND_API.G_RET_STS_SUCCESS;
1802 
1803         -- Process Flow step 3: Verify Reference Designator's existence
1804         --
1805 
1806         IF g_control_rec.check_existence
1807         THEN
1808                 --dbms_output.put_line('Checking Existence');
1809                 Bom_Validate_Ref_Designator.Check_Existence
1810                 (  p_ref_designator_rec         => l_ref_designator_rec
1811                 ,  p_ref_desg_unexp_rec         => l_ref_desg_unexp_rec
1812                 ,  x_old_ref_designator_rec     => l_old_ref_designator_rec
1813                 ,  x_old_ref_desg_unexp_rec     => l_old_ref_desg_unexp_rec
1814                 ,  x_Mesg_Token_Tbl             => l_Mesg_Token_Tbl
1815                 ,  x_return_status              => l_Return_Status
1816                 );
1817 
1818                 --dbms_output.put_line('return_status: ' || l_return_status);
1819 
1820                 IF l_return_status = Error_Handler.G_STATUS_ERROR
1821                 THEN
1822                         RAISE EXC_SEV_QUIT_RECORD;
1823                 ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
1824                 THEN
1825                         RAISE EXC_UNEXP_SKIP_OBJECT;
1826                 END IF;
1827         END IF;
1828 
1829 
1830         -- Set parent revised item attributes
1831         Set_RevItem_Attributes
1832         (  p_revised_item_sequence_id    => l_ref_desg_unexp_rec.revised_item_sequence_id
1833          , p_bo_processed                => 'BOM'
1834         ) ;
1835 
1836 
1837         -- Process Flow step 13 : Database Writes
1838 
1839         IF g_control_rec.write_to_db
1840         THEN
1841                 bom_globals.set_user_id(p_user_id => g_control_rec.last_updated_by);
1842                 bom_globals.set_login_id(p_login_id => g_control_rec.last_update_login);
1843 
1844                 --dbms_output.put_line('Writing to the database');
1845                 Bom_Ref_Designator_Util.Perform_Writes
1846                 (   p_ref_designator_rec        => l_ref_designator_rec
1847                 ,   p_ref_desg_unexp_rec        => l_ref_desg_unexp_rec
1848                 ,   p_control_rec               => g_control_rec
1849                 ,   x_Mesg_Token_Tbl            => l_Mesg_Token_Tbl
1850                 ,   x_return_status             => l_return_status
1851                 );
1852 
1853                 --dbms_output.put_line('return_status: ' || l_return_status);
1854 
1855                 IF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
1856                 THEN
1857                         RAISE EXC_UNEXP_SKIP_OBJECT;
1858                 ELSIF l_return_status ='S' AND
1859                       l_Mesg_Token_Tbl.COUNT <>0
1860                 THEN
1861                         Eco_Error_Handler.Log_Error
1862                         (  p_ref_designator_tbl => l_ref_designator_tbl
1863                         ,  p_sub_component_tbl  => l_sub_component_tbl
1864                         ,  p_mesg_token_tbl     => l_mesg_token_tbl
1865                         ,  p_error_status       => 'W'
1866                         ,  p_error_level        => 5
1867                         ,  p_entity_index       => I
1868                         ,  x_eco_rec            => l_eco_rec
1869                         ,  x_eco_revision_tbl   => l_eco_revision_tbl
1870                         ,  x_revised_item_tbl   => l_revised_item_tbl
1871                         ,  x_rev_component_tbl  => l_rev_component_tbl
1872                         ,  x_sub_component_tbl  => l_sub_component_tbl
1873                         ,  x_ref_designator_tbl => l_ref_designator_tbl
1874                         ,  x_rev_operation_tbl    => l_rev_operation_tbl     --add
1875                         ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl   --add
1876                         ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl  --add
1877                         );
1878                 END IF;
1879         END IF;
1880 
1881         l_ref_designator_tbl(I) := l_ref_designator_rec;
1882 
1883   EXCEPTION
1884 
1885     WHEN EXC_SEV_QUIT_RECORD THEN
1886 
1887         --dbms_output.put_line('Expected error generated');
1888         l_ref_designator_tbl(I) := l_ref_designator_rec;
1889         Eco_Error_Handler.Log_Error
1890                 (  p_ref_designator_tbl   => l_ref_designator_tbl
1891                 ,  p_sub_component_tbl    => l_sub_component_tbl
1892                 ,  p_mesg_token_tbl       => l_mesg_token_tbl
1893                 ,  p_error_status         => FND_API.G_RET_STS_ERROR
1894                 ,  p_error_scope          => Error_Handler.G_SCOPE_RECORD
1895                 ,  p_error_level          => 5
1896                 ,  p_entity_index         => I
1897                 ,  x_eco_rec              => l_eco_rec
1898                 ,  x_eco_revision_tbl     => l_eco_revision_tbl
1899                 ,  x_revised_item_tbl     => l_revised_item_tbl
1900                 ,  x_rev_component_tbl    => l_rev_component_tbl
1901                 ,  x_ref_designator_tbl   => l_ref_designator_tbl
1902                 ,  x_sub_component_tbl    => l_sub_component_tbl
1903                 ,  x_rev_operation_tbl    => l_rev_operation_tbl     --add
1904                 ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl   --add
1905                 ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl  --add
1906                 );
1907 
1908         x_return_status                := l_return_status;
1909         x_Mesg_Token_Tbl               := l_Mesg_Token_Tbl;
1910         x_ECO_rec                      := l_ECO_rec;
1911         x_sub_component_tbl            := l_sub_component_tbl;
1912         x_unexp_ref_desg_rec           := l_ref_desg_unexp_rec;
1913         x_eco_revision_tbl             := l_eco_revision_tbl;
1914         x_revised_item_tbl             := l_revised_item_tbl;
1915         x_ref_designator_tbl           := l_ref_designator_tbl;
1916         x_rev_component_tbl            := l_rev_component_tbl;
1917         x_rev_operation_tbl            := l_rev_operation_tbl;     --add
1918         x_rev_op_resource_tbl          := l_rev_op_resource_tbl;   --add
1919         x_rev_sub_resource_tbl         := l_rev_sub_resource_tbl;  --add
1920 
1921         RETURN;
1922 
1923     WHEN EXC_UNEXP_SKIP_OBJECT THEN
1924 
1925         --dbms_output.put_line('Unexpected error generated');
1926         Eco_Error_Handler.Log_Error
1927                 (  p_sub_component_tbl  => l_sub_component_tbl
1928                 ,  p_mesg_token_tbl     => l_mesg_token_tbl
1929                 ,  p_error_status       => Error_Handler.G_STATUS_UNEXPECTED
1930                 ,  p_other_status       => Error_Handler.G_STATUS_NOT_PICKED
1931                 ,  p_other_message      => l_other_message
1932                 ,  p_other_token_tbl    => l_other_token_tbl
1933                 ,  p_error_level        => 5
1934                 ,  p_entity_index       => I
1935                 ,  x_ECO_rec            => l_ECO_rec
1936                 ,  x_eco_revision_tbl   => l_eco_revision_tbl
1937                 ,  x_revised_item_tbl   => l_revised_item_tbl
1938                 ,  x_rev_component_tbl  => l_rev_component_tbl
1939                 ,  x_ref_designator_tbl => l_ref_designator_tbl
1940                 ,  x_sub_component_tbl  => l_sub_component_tbl
1941                 ,  x_rev_operation_tbl    => l_rev_operation_tbl     --add
1942                 ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl   --add
1943                 ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl  --add
1944                 );
1945 
1946         x_Mesg_Token_Tbl               := l_Mesg_Token_Tbl;
1947         x_ECO_rec                      := l_ECO_rec;
1948         x_sub_component_tbl            := l_sub_component_tbl;
1949         x_unexp_ref_desg_rec           := l_ref_desg_unexp_rec;
1950         x_eco_revision_tbl             := l_eco_revision_tbl;
1951         x_revised_item_tbl             := l_revised_item_tbl;
1952         x_ref_designator_tbl           := l_ref_designator_tbl;
1953         x_rev_component_tbl            := l_rev_component_tbl;
1954         x_rev_operation_tbl            := l_rev_operation_tbl;     --add
1955         x_rev_op_resource_tbl          := l_rev_op_resource_tbl;   --add
1956         x_rev_sub_resource_tbl         := l_rev_sub_resource_tbl;  --add
1957 
1958 
1959         l_return_status := 'U';
1960         IF g_control_rec.write_to_db
1961         THEN
1962                 RAISE;
1963         END IF;
1964 
1965   END;
1966   END LOOP; -- END ref designator processing block
1967 
1968     IF l_return_status in ('Q', 'U')
1969     THEN
1970         x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
1971         x_return_status := l_return_status;
1972         RETURN;
1973     END IF;
1974 
1975     l_bo_return_status := l_return_status;
1976 
1977      x_return_status            := l_bo_return_status;
1978      x_ECO_rec                  := l_ECO_rec;
1979      x_unexp_ref_desg_rec       := l_ref_desg_unexp_Rec;
1980      x_eco_revision_tbl         := l_eco_revision_tbl;
1981      x_revised_item_tbl         := l_revised_item_tbl;
1982      x_rev_component_tbl        := l_rev_component_tbl;
1983      x_ref_designator_tbl       := l_ref_designator_tbl;
1984      x_sub_component_tbl        := l_sub_component_tbl;
1985      x_rev_operation_tbl        := l_rev_operation_tbl;     --add
1986      x_rev_op_resource_tbl      := l_rev_op_resource_tbl;   --add
1987      x_rev_sub_resource_tbl     := l_rev_sub_resource_tbl;  --add
1988      x_Mesg_Token_Tbl           := l_Mesg_Token_Tbl;
1989 
1990 END Ref_Desgs;
1991 
1992 --  Rev_Comps
1993 
1994 PROCEDURE Rev_Comps
1995 (   p_rev_component_tbl             IN  BOM_BO_PUB.Rev_Component_Tbl_Type
1996 ,   p_unexp_rev_comp_rec            IN  BOM_BO_PUB.Rev_Comp_Unexposed_Rec_Type
1997 ,   p_ref_designator_tbl            IN  BOM_BO_PUB.Ref_Designator_Tbl_Type
1998 ,   p_sub_component_tbl             IN  BOM_BO_PUB.Sub_Component_Tbl_Type
1999 ,   x_ECO_rec                       IN OUT NOCOPY ENG_Eco_PUB.Eco_Rec_Type
2000 ,   x_unexp_rev_comp_rec            IN OUT NOCOPY BOM_BO_PUB.Rev_Comp_Unexposed_Rec_Type
2001 ,   x_eco_revision_tbl              IN OUT NOCOPY ENG_Eco_PUB.Eco_Revision_Tbl_Type
2002 ,   x_revised_item_tbl              IN OUT NOCOPY ENG_Eco_PUB.Revised_Item_Tbl_Type
2003 ,   x_rev_component_tbl             IN OUT NOCOPY BOM_BO_PUB.Rev_Component_Tbl_Type
2004 ,   x_ref_designator_tbl            IN OUT NOCOPY BOM_BO_PUB.Ref_Designator_Tbl_Type
2005 ,   x_sub_component_tbl             IN OUT NOCOPY BOM_BO_PUB.Sub_Component_Tbl_Type
2006 ,   x_rev_operation_tbl             IN OUT NOCOPY BOM_RTG_PUB.Rev_operation_Tbl_Type     --add
2007 ,   x_rev_op_resource_tbl           IN OUT NOCOPY BOM_RTG_PUB.Rev_op_resource_Tbl_Type   --add
2008 ,   x_rev_sub_resource_tbl          IN OUT NOCOPY BOM_RTG_PUB.Rev_sub_resource_Tbl_Type  --add
2009 ,   x_Mesg_Token_Tbl                IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
2010 ,   x_return_status                 IN OUT NOCOPY VARCHAR2
2011 )
2012 IS
2013 
2014 l_Mesg_Token_Tbl        Error_Handler.Mesg_Token_Tbl_Type;
2015 l_other_token_tbl       Error_Handler.Token_Tbl_Type;
2016 l_other_message         VARCHAR2(50);
2017 l_err_text              VARCHAR2(2000);
2018 l_valid                 BOOLEAN := TRUE;
2019 l_Return_Status         VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
2020 l_bo_return_status      VARCHAR2(1) := 'S';
2021 l_rev_component_Rec     BOM_BO_PUB.Rev_Component_Rec_Type;
2022 l_rev_comp_unexp_Rec    BOM_BO_PUB.Rev_Comp_Unexposed_Rec_Type := p_unexp_rev_comp_rec;
2023 l_old_rev_component_Rec BOM_BO_PUB.Rev_Component_Rec_Type := NULL;
2024 l_old_rev_comp_unexp_Rec     BOM_BO_PUB.Rev_Comp_Unexposed_Rec_Type := NULL;
2025 l_eco_rec               ENG_ECO_PUB.ECO_Rec_Type := NULL;
2026 l_eco_revision_tbl      ENG_Eco_PUB.Eco_Revision_Tbl_Type;
2027 l_revised_item_tbl      ENG_Eco_PUB.Revised_Item_Tbl_Type;
2028 l_rev_component_tbl     BOM_BO_PUB.Rev_Component_Tbl_Type := p_rev_component_tbl;
2029 l_ref_designator_tbl    BOM_BO_PUB.Ref_Designator_Tbl_Type := p_ref_designator_tbl;
2030 l_sub_component_tbl     BOM_BO_PUB.Sub_Component_Tbl_Type := p_sub_component_tbl;
2031 l_rev_operation_tbl     BOM_RTG_PUB.Rev_Operation_Tbl_Type;     --add
2032 l_rev_op_resource_tbl   BOM_RTG_PUB.Rev_Op_Resource_Tbl_Type;   --add
2033 l_rev_sub_resource_tbl  BOM_RTG_PUB.Rev_Sub_Resource_Tbl_Type;  --add
2034 l_return_value          NUMBER;
2035 l_Token_Tbl             Error_Handler.Token_Tbl_Type;
2036 l_query_op_seq_num      NUMBER := NULL;
2037 l_query_effective_date  DATE := NULL;
2038 l_query_from_unit_number  VARCHAR2(30) := NULL;
2039 
2040 EXC_SEV_QUIT_RECORD     EXCEPTION;
2041 EXC_UNEXP_SKIP_OBJECT   EXCEPTION;
2042 
2043 BEGIN
2044 
2045     -- Begin block that processes revised items. This block holds the exception handlers
2046     -- for header errors.
2047 
2048     FOR I IN 1..l_rev_component_tbl.COUNT LOOP
2049     BEGIN
2050         --  Load local records.
2051 
2052         l_rev_component_rec := l_rev_component_tbl(I);
2053 
2054         l_rev_component_rec.transaction_type :=
2055                 UPPER(l_rev_component_rec.transaction_type);
2056 
2057         l_return_status := FND_API.G_RET_STS_SUCCESS;
2058         l_rev_component_rec.return_status := FND_API.G_RET_STS_SUCCESS;
2059 
2060         -- Process Flow step 3: Verify Revised Component's existence
2061         --
2062 
2063         IF g_control_rec.check_existence
2064         THEN
2065                 --dbms_output.put_line('Checking Existence');
2066                 Bom_Validate_Bom_Component.Check_Existence
2067                 (  p_rev_component_rec          => l_rev_component_rec
2068                 ,  p_rev_comp_unexp_rec         => l_rev_comp_unexp_rec
2069                 ,  x_old_rev_component_rec      => l_old_rev_component_rec
2070                 ,  x_old_rev_comp_unexp_rec     => l_old_rev_comp_unexp_rec
2071                 ,  x_Mesg_Token_Tbl             => l_Mesg_Token_Tbl
2072                 ,  x_return_status              => l_Return_Status
2073                 );
2074 
2075 
2076                 --dbms_output.put_line('return_status: ' || l_return_status);
2077 
2078                 IF l_return_status = Error_Handler.G_STATUS_ERROR
2079                 THEN
2080                         RAISE EXC_SEV_QUIT_RECORD;
2081                 ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
2082                 THEN
2083                         RAISE EXC_UNEXP_SKIP_OBJECT;
2084                 END IF;
2085         END IF;
2086 
2087         -- Set parent revised item attributes
2088         Set_RevItem_Attributes
2089         (  p_revised_item_sequence_id    => l_rev_comp_unexp_rec.revised_item_sequence_id
2090          , p_bo_processed                => 'BOM'
2091         ) ;
2092 
2093 
2094         IF g_control_rec.attribute_defaulting AND
2095            l_rev_component_rec.Transaction_Type = ENG_GLOBALS.G_OPR_CREATE
2096         THEN
2097 
2098                 -- Process Flow step 9: Default missing values for Operation CREATE
2099 
2100                 --dbms_output.put_line('Attribute Defaulting');
2101                 Bom_Default_Bom_Component.Attribute_Defaulting
2102                 (   p_rev_component_rec         => l_rev_component_rec
2103                 ,   p_rev_comp_unexp_rec        => l_rev_comp_unexp_rec
2104                 ,   x_rev_component_rec         => l_rev_component_rec
2105                 ,   x_rev_comp_unexp_rec        => l_rev_comp_unexp_rec
2106                 ,   x_Mesg_Token_Tbl            => l_Mesg_Token_Tbl
2107                 ,   x_return_status             => l_return_status
2108                 );
2109 
2110                 --dbms_output.put_line('pvt item num: ' || to_char(l_rev_component_rec.item_sequence_number));
2111 
2112                 --dbms_output.put_line('return_status: ' || l_return_status);
2113 
2114                 IF l_return_status = Error_Handler.G_STATUS_ERROR
2115                 THEN
2116                         RAISE EXC_SEV_QUIT_RECORD;
2117                 ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
2118                 THEN
2119                         RAISE EXC_UNEXP_SKIP_OBJECT;
2120                 ELSIF l_return_status ='S' AND
2121                       l_Mesg_Token_Tbl.COUNT <>0
2122                 THEN
2123                         Eco_Error_Handler.Log_Error
2124                         (  p_rev_component_tbl    => l_rev_component_tbl
2125                         ,  p_ref_designator_tbl   => l_ref_designator_tbl
2126                         ,  p_sub_component_tbl    => l_sub_component_tbl
2127                         ,  p_mesg_token_tbl       => l_mesg_token_tbl
2128                         ,  p_error_status         => 'W'
2129                         ,  p_error_level          => 4
2130                         ,  p_entity_index         => I
2131                         ,  x_eco_rec              => l_eco_rec
2132                         ,  x_eco_revision_tbl     => l_eco_revision_tbl
2133                         ,  x_revised_item_tbl     => l_revised_item_tbl
2134                         ,  x_rev_component_tbl    => l_rev_component_tbl
2135                         ,  x_ref_designator_tbl   => l_ref_designator_tbl
2136                         ,  x_sub_component_tbl    => l_sub_component_tbl
2137                         ,  x_rev_operation_tbl    => l_rev_operation_tbl     --add
2138                         ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl   --add
2139                         ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl  --add
2140                         );
2141                 END IF;
2142         END IF;
2143 
2144         IF ((g_control_rec.entity_defaulting AND
2145              NOT g_control_rec.attribute_defaulting)
2146             OR
2147             g_control_rec.entity_validation)
2148            AND
2149            (--l_rev_component_rec.transaction_type='UPDATE'
2150             --OR -- commented out validation on update as it not required --Bug 3864772
2151             (l_rev_component_rec.transaction_type = 'CREATE'
2152              AND l_rev_component_rec.acd_type = 2))
2153         THEN
2154                 IF l_rev_component_rec.transaction_type='UPDATE'
2155                 THEN
2156                         l_query_op_seq_num := l_rev_component_rec.new_operation_sequence_number;
2157                         l_query_effective_date := l_rev_component_rec.start_effective_date;
2158                         l_query_from_unit_number := l_rev_component_rec.from_end_item_unit_number;
2159                 ELSE
2160                         l_query_op_seq_num := l_rev_component_rec.old_operation_sequence_number;
2161                         l_query_effective_date := l_rev_component_rec.old_effectivity_date;
2162                         l_query_from_unit_number := l_rev_component_rec.old_from_end_item_unit_number;
2163                 END IF;
2164 
2165                 --dbms_output.put_line('querying row');
2166                 Bom_Bom_Component_Util.Query_Row
2167                    ( p_component_item_id         => l_rev_comp_unexp_rec.component_item_id
2168                    , p_operation_sequence_number => l_query_op_seq_num
2169                    , p_effectivity_date          => l_query_effective_date
2170                    , p_bill_sequence_id          => l_rev_comp_unexp_rec.bill_sequence_id
2171                    , p_from_end_item_number      => l_query_from_unit_number
2172                    , p_Mesg_Token_Tbl            => l_Mesg_Token_Tbl
2173                    , x_Rev_Component_Rec         => l_old_rev_component_rec
2174                    , x_Rev_Comp_Unexp_Rec        => l_old_rev_comp_unexp_rec
2175                    , x_return_status             => l_return_status
2176                    , x_Mesg_Token_Tbl            => l_Mesg_Token_Tbl
2177                    );
2178 
2179                 --dbms_output.put_line('query return_status: ' || l_return_status);
2180 
2181                 IF l_return_status = 'N'
2182                 THEN
2183                         -- Added for Bug1609574
2184                         l_return_status := Error_Handler.G_STATUS_ERROR ;
2185                         l_Token_Tbl(1).token_name := 'REVISED_COMPONENT_NAME';
2186                         l_Token_Tbl(1).token_value := l_rev_component_rec.component_item_name;
2187 
2188                         Error_Handler.Add_Error_Token
2189                         ( p_message_name       => 'BOM_CMP_CREATE_REC_NOT_FOUND'
2190                         , p_mesg_token_tbl     => l_Mesg_Token_Tbl
2191                         , p_token_tbl          => l_Token_Tbl
2192                         , x_Mesg_Token_Tbl     => l_Mesg_Token_Tbl
2193                         );
2194 
2195                         RAISE EXC_SEV_QUIT_RECORD;
2196                 ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
2197                 THEN
2198                         RAISE EXC_UNEXP_SKIP_OBJECT;
2199                 ELSIF l_return_status ='S' AND
2200                       l_Mesg_Token_Tbl.COUNT <>0
2201                 THEN
2202                         Eco_Error_Handler.Log_Error
2203                         (  p_rev_component_tbl    => l_rev_component_tbl
2204                         ,  p_ref_designator_tbl   => l_ref_designator_tbl
2205                         ,  p_sub_component_tbl    => l_sub_component_tbl
2206                         ,  p_mesg_token_tbl       => l_mesg_token_tbl
2207                         ,  p_error_status         => 'W'
2208                         ,  p_error_level          => 4
2209                         ,  p_entity_index         => I
2210                         ,  x_eco_rec              => l_eco_rec
2211                         ,  x_eco_revision_tbl     => l_eco_revision_tbl
2212                         ,  x_revised_item_tbl     => l_revised_item_tbl
2213                         ,  x_rev_component_tbl    => l_rev_component_tbl
2214                         ,  x_ref_designator_tbl   => l_ref_designator_tbl
2215                         ,  x_sub_component_tbl    => l_sub_component_tbl
2216                         ,  x_rev_operation_tbl    => l_rev_operation_tbl    --add
2217                         ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
2218                         ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
2219                         );
2220                 END IF;
2221 
2222 /*              IF l_return_status = 'F'
2223                 THEN
2224                         dbms_output.put_line('queried old record');
2225                 ELSIF l_return_status = 'N'
2226                 THEN
2227                         dbms_output.put_line('old record not found');
2228                 END IF;*/
2229         END IF;
2230 
2231      -- Process Flow step 11 - Entity Level Defaulting
2232 
2233         IF g_control_rec.entity_defaulting
2234         THEN
2235                 --dbms_output.put_line('Entity Defaulting');
2236 
2237                 Bom_Default_Bom_Component.Entity_Defaulting
2238                 (   p_rev_component_rec         => l_rev_component_rec
2239                 ,   p_old_rev_component_rec     => l_old_rev_component_rec
2240                 ,   x_rev_component_rec         => l_rev_component_rec
2241                 );
2242 
2243                 --dbms_output.put_line('pvt item num: ' || to_char(l_rev_component_rec.item_sequence_number));
2244 
2245                 --dbms_output.put_line('return_status: ' || l_return_status);
2246 
2247                 IF l_return_status = Error_Handler.G_STATUS_ERROR
2248                 THEN
2249                         RAISE EXC_SEV_QUIT_RECORD;
2250                 ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
2251                 THEN
2252                         RAISE EXC_UNEXP_SKIP_OBJECT;
2253                 ELSIF l_return_status ='S' AND
2254                       l_Mesg_Token_Tbl.COUNT <>0
2255                 THEN
2256                         Eco_Error_Handler.Log_Error
2257                         (  p_rev_component_tbl    => l_rev_component_tbl
2258                         ,  p_ref_designator_tbl   => l_ref_designator_tbl
2259                         ,  p_sub_component_tbl    => l_sub_component_tbl
2260                         ,  p_mesg_token_tbl       => l_mesg_token_tbl
2261                         ,  p_error_status         => 'W'
2262                         ,  p_error_level          => 4
2263                         ,  p_entity_index         => I
2264                         ,  x_eco_rec              => l_eco_rec
2265                         ,  x_eco_revision_tbl     => l_eco_revision_tbl
2266                         ,  x_revised_item_tbl     => l_revised_item_tbl
2267                         ,  x_rev_component_tbl    => l_rev_component_tbl
2268                         ,  x_ref_designator_tbl   => l_ref_designator_tbl
2269                         ,  x_sub_component_tbl    => l_sub_component_tbl
2270                         ,  x_rev_operation_tbl    => l_rev_operation_tbl    --add
2271                         ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
2272                         ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
2273                         );
2274                 END IF;
2275         END IF;
2276 
2277      -- Process Flow step 12 - Entity Level Validation
2278 
2279         IF g_control_rec.entity_validation
2280         THEN
2281                 --dbms_output.put_line('Entity validation');
2282                 IF l_rev_component_rec.transaction_type = 'DELETE'
2283                 THEN
2284                         NULL;
2285                         /*Eng_Validate_Revised_Item.Check_Entity_Delete
2286                         (  p_rev_component_rec     => l_rev_component_rec
2287                         ,  p_rev_item_unexp_rec   => l_rev_item_unexp_rec
2288                         ,  x_Mesg_Token_Tbl       => l_Mesg_Token_Tbl
2289                         ,  x_return_status        => l_Return_Status
2290                         );*/
2291                 ELSE
2292                         Bom_Validate_Bom_Component.Check_Entity
2293                         (  p_rev_component_rec          => l_rev_component_rec
2294                         ,  p_rev_comp_unexp_rec         => l_rev_comp_unexp_rec
2295                         ,  p_old_rev_component_rec      => l_old_rev_component_rec
2296                         ,  p_old_rev_comp_unexp_rec     => l_old_rev_comp_unexp_rec
2297                         ,  p_control_rec                => g_control_rec
2298                         ,  x_Mesg_Token_Tbl             => l_Mesg_Token_Tbl
2299                         ,  x_return_status              => l_Return_Status
2300                         );
2301                 END IF;
2302 
2303                 --dbms_output.put_line('return_status: ' || l_return_status);
2304 
2305                 IF l_return_status = Error_Handler.G_STATUS_ERROR
2306                 THEN
2307                         RAISE EXC_SEV_QUIT_RECORD;
2308                 ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
2309                 THEN
2310                         RAISE EXC_UNEXP_SKIP_OBJECT;
2311                 ELSIF l_return_status ='S' AND
2312                       l_Mesg_Token_Tbl.COUNT <>0
2313                 THEN
2314                         --dbms_output.put_line('logging warnings');
2315                         Eco_Error_Handler.Log_Error
2316                         (  p_rev_component_tbl    => l_rev_component_tbl
2317                         ,  p_ref_designator_tbl   => l_ref_designator_tbl
2318                         ,  p_sub_component_tbl    => l_sub_component_tbl
2319                         ,  p_mesg_token_tbl       => l_mesg_token_tbl
2320                         ,  p_error_status         => 'W'
2321                         ,  p_error_level          => 4
2322                         ,  p_entity_index         => I
2323                         ,  x_eco_rec              => l_eco_rec
2324                         ,  x_eco_revision_tbl     => l_eco_revision_tbl
2325                         ,  x_revised_item_tbl     => l_revised_item_tbl
2326                         ,  x_rev_component_tbl    => l_rev_component_tbl
2327                         ,  x_ref_designator_tbl   => l_ref_designator_tbl
2328                         ,  x_sub_component_tbl    => l_sub_component_tbl
2329                         ,  x_rev_operation_tbl    => l_rev_operation_tbl    --add
2330                         ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
2331                         ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
2332                         );
2333                 END IF;
2334         END IF;
2335 
2336         -- Process Flow step 13 : Database Writes
2337 
2338         IF g_control_rec.write_to_db
2339         THEN
2340                 bom_globals.set_user_id(p_user_id => g_control_rec.last_updated_by);
2341                 bom_globals.set_login_id(p_login_id => g_control_rec.last_update_login);
2342 
2343                 --dbms_output.put_line('Writing to the database');
2344                 BOM_BOM_Component_Util.Perform_Writes
2345                 (   p_rev_component_rec         => l_rev_component_rec
2346                 ,   p_rev_comp_unexp_rec        => l_rev_comp_unexp_rec
2347                 ,   p_control_rec               => g_control_rec
2348                 ,   x_Mesg_Token_Tbl            => l_Mesg_Token_Tbl
2349                 ,   x_return_status             => l_return_status
2350                 );
2351 
2352                 --dbms_output.put_line('return_status: ' || l_return_status);
2353 
2354                 IF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
2355                 THEN
2356                         RAISE EXC_UNEXP_SKIP_OBJECT;
2357                 ELSIF l_return_status ='S' AND
2358                       l_Mesg_Token_Tbl.COUNT <>0
2359                 THEN
2360                         Eco_Error_Handler.Log_Error
2361                         (  p_rev_component_tbl    => l_rev_component_tbl
2362                         ,  p_ref_designator_tbl   => l_ref_designator_tbl
2363                         ,  p_sub_component_tbl    => l_sub_component_tbl
2364                         ,  p_mesg_token_tbl       => l_mesg_token_tbl
2365                         ,  p_error_status         => 'W'
2366                         ,  p_error_level          => 4 --reverted fix 2774876-- vani
2367                         ,  p_entity_index         => I
2368                         ,  x_eco_rec              => l_eco_rec
2369                         ,  x_eco_revision_tbl     => l_eco_revision_tbl
2370                         ,  x_revised_item_tbl     => l_revised_item_tbl
2371                         ,  x_rev_component_tbl    => l_rev_component_tbl
2372                         ,  x_ref_designator_tbl   => l_ref_designator_tbl
2373                         ,  x_sub_component_tbl    => l_sub_component_tbl
2374                         ,  x_rev_operation_tbl    => l_rev_operation_tbl    --add
2375                         ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
2376                         ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
2377                         );
2378                 END IF;
2379         END IF;
2380 
2381         l_rev_component_tbl(I) := l_rev_component_rec;
2382 
2383   EXCEPTION
2384 
2385     WHEN EXC_SEV_QUIT_RECORD THEN
2386 
2387         --dbms_output.put_line('Expected error generated');
2388         l_rev_component_tbl(I) := l_rev_component_rec;
2389         Eco_Error_Handler.Log_Error
2390                 (  p_rev_component_tbl    => l_rev_component_tbl
2391                 ,  p_ref_designator_tbl   => l_ref_designator_tbl
2392                 ,  p_sub_component_tbl    => l_sub_component_tbl
2393                 ,  p_mesg_token_tbl       => l_mesg_token_tbl
2394                 ,  p_error_status         => FND_API.G_RET_STS_ERROR
2395                 ,  p_error_scope          => Error_Handler.G_SCOPE_RECORD
2396                 ,  p_error_level          => 4
2397                 ,  p_entity_index         => I
2398                 ,  x_eco_rec              => l_eco_rec
2399                 ,  x_eco_revision_tbl     => l_eco_revision_tbl
2400                 ,  x_revised_item_tbl     => l_revised_item_tbl
2401                 ,  x_rev_component_tbl    => l_rev_component_tbl
2402                 ,  x_ref_designator_tbl   => l_ref_designator_tbl
2403                 ,  x_sub_component_tbl    => l_sub_component_tbl
2404                 ,  x_rev_operation_tbl    => l_rev_operation_tbl    --add
2405                 ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
2406                 ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
2407                 );
2408 
2409         x_return_status                := l_return_status;
2410         x_Mesg_Token_Tbl               := l_Mesg_Token_Tbl;
2411         x_ECO_rec                      := l_ECO_rec;
2412         x_rev_component_tbl            := l_rev_component_tbl;
2413         x_unexp_rev_comp_rec           := l_rev_comp_unexp_rec;
2414         x_eco_revision_tbl             := l_eco_revision_tbl;
2415         x_revised_item_tbl             := l_revised_item_tbl;
2416         x_ref_designator_tbl           := l_ref_designator_tbl;
2417         x_sub_component_tbl            := l_sub_component_tbl;
2418         x_rev_operation_tbl            := l_rev_operation_tbl;    --add
2419         x_rev_op_resource_tbl          := l_rev_op_resource_tbl;  --add
2420         x_rev_sub_resource_tbl         := l_rev_sub_resource_tbl; --add
2421                 --dbms_output.put_line('err pvt item num: ' || to_char(l_rev_component_rec.item_sequence_number));
2422 
2423         RETURN;
2424 
2425     WHEN EXC_UNEXP_SKIP_OBJECT THEN
2426 
2427         --dbms_output.put_line('Unexpected error generated');
2428         Eco_Error_Handler.Log_Error
2429                 (  p_rev_component_tbl    => l_rev_component_tbl
2430                 ,  p_ref_designator_tbl   => l_ref_designator_tbl
2431                 ,  p_sub_component_tbl    => l_sub_component_tbl
2432                 ,  p_mesg_token_tbl       => l_mesg_token_tbl
2433                 ,  p_error_status         => Error_Handler.G_STATUS_UNEXPECTED
2434                 ,  p_other_status         => Error_Handler.G_STATUS_NOT_PICKED
2435                 ,  p_other_message        => l_other_message
2436                 ,  p_other_token_tbl      => l_other_token_tbl
2437                 ,  p_error_level          => 4
2438                 ,  p_entity_index         => I
2439                 ,  x_ECO_rec              => l_ECO_rec
2440                 ,  x_eco_revision_tbl     => l_eco_revision_tbl
2441                 ,  x_revised_item_tbl     => l_revised_item_tbl
2442                 ,  x_rev_component_tbl    => l_rev_component_tbl
2443                 ,  x_ref_designator_tbl   => l_ref_designator_tbl
2444                 ,  x_sub_component_tbl    => l_sub_component_tbl
2445                 ,  x_rev_operation_tbl    => l_rev_operation_tbl    --add
2446                 ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
2447                 ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
2448                 );
2449 
2450         l_return_status := 'U';
2451 --dbms_output.put_line('unexp message' || l_mesg_token_tbl(1).message_text);
2452         x_return_status                := l_return_status;
2453         x_Mesg_Token_Tbl               := l_Mesg_Token_Tbl;
2454         x_ECO_rec                      := l_ECO_rec;
2455         x_eco_revision_tbl             := l_eco_revision_tbl;
2456         x_revised_item_tbl             := l_revised_item_tbl;
2457         x_rev_component_tbl            := l_rev_component_tbl;
2458         x_unexp_rev_comp_rec           := l_rev_comp_unexp_rec;
2459         x_ref_designator_tbl           := l_ref_designator_tbl;
2460         x_sub_component_tbl            := l_sub_component_tbl;
2461         x_rev_operation_tbl            := l_rev_operation_tbl;    --add
2462         x_rev_op_resource_tbl          := l_rev_op_resource_tbl;  --add
2463         x_rev_sub_resource_tbl         := l_rev_sub_resource_tbl; --add
2464 
2465   END;
2466   END LOOP; -- END revised items processing block
2467 
2468     IF l_return_status in ('Q', 'U')
2469     THEN
2470         x_return_status := l_return_status;
2471         RETURN;
2472     END IF;
2473 
2474     l_bo_return_status := l_return_status;
2475 
2476      x_return_status            := l_bo_return_status;
2477      x_ECO_rec                  := l_ECO_rec;
2478      x_unexp_rev_comp_rec       := l_rev_comp_unexp_Rec;
2479      x_eco_revision_tbl         := l_eco_revision_tbl;
2480      x_revised_item_tbl         := l_revised_item_tbl;
2481      x_rev_component_tbl        := l_rev_component_tbl;
2482      x_ref_designator_tbl       := l_ref_designator_tbl;
2483      x_sub_component_tbl        := l_sub_component_tbl;    --add
2484      x_rev_op_resource_tbl      := l_rev_op_resource_tbl;  --add
2485      x_rev_sub_resource_tbl     := l_rev_sub_resource_tbl; --add
2486      x_Mesg_Token_Tbl           := l_Mesg_Token_Tbl;
2487                 --dbms_output.put_line('end pvt item num: ' || to_char(l_rev_component_rec.item_sequence_number));
2488 
2489 END Rev_Comps;
2490 
2491 --  Rev_Items
2492 
2493 PROCEDURE Rev_Items
2494 (   p_revised_item_tbl              IN  ENG_Eco_PUB.Revised_Item_Tbl_Type
2495 ,   p_unexp_rev_item_rec            IN  ENG_Eco_PUB.Rev_Item_Unexposed_Rec_Type
2496 ,   p_rev_component_tbl             IN  BOM_BO_PUB.Rev_Component_Tbl_Type
2497 ,   p_ref_designator_tbl            IN  BOM_BO_PUB.Ref_Designator_Tbl_Type
2498 ,   p_sub_component_tbl             IN  BOM_BO_PUB.Sub_Component_Tbl_Type
2499 ,   p_rev_operation_tbl             IN  BOM_RTG_PUB.Rev_Operation_Tbl_Type    --add
2500 ,   p_rev_op_resource_tbl           IN  BOM_RTG_PUB.Rev_Op_Resource_Tbl_Type  --add
2501 ,   p_rev_sub_resource_tbl          IN  BOM_RTG_PUB.Rev_Sub_Resource_Tbl_Type --add
2502 ,   x_ECO_rec                       IN OUT NOCOPY ENG_Eco_PUB.Eco_Rec_Type
2503 ,   x_unexp_rev_item_rec            IN OUT NOCOPY ENG_Eco_PUB.Rev_Item_Unexposed_Rec_Type
2504 ,   x_eco_revision_tbl              IN OUT NOCOPY ENG_Eco_PUB.Eco_Revision_Tbl_Type
2505 ,   x_revised_item_tbl              IN OUT NOCOPY ENG_Eco_PUB.Revised_Item_Tbl_Type
2506 ,   x_rev_component_tbl             IN OUT NOCOPY BOM_BO_PUB.Rev_Component_Tbl_Type
2507 ,   x_ref_designator_tbl            IN OUT NOCOPY BOM_BO_PUB.Ref_Designator_Tbl_Type
2508 ,   x_sub_component_tbl             IN OUT NOCOPY BOM_BO_PUB.Sub_Component_Tbl_Type
2509 ,   x_rev_operation_tbl             IN OUT NOCOPY BOM_RTG_PUB.Rev_operation_Tbl_Type    --add
2510 ,   x_rev_op_resource_tbl           IN OUT NOCOPY BOM_RTG_PUB.Rev_op_resource_Tbl_Type  --add
2511 ,   x_rev_sub_resource_tbl          IN OUT NOCOPY BOM_RTG_PUB.Rev_sub_resource_Tbl_Type --add
2512 ,   x_Mesg_Token_Tbl                IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
2513 ,   x_return_status                 IN OUT NOCOPY VARCHAR2
2514 ,   x_disable_revision              OUT NOCOPY NUMBER --Bug no:3034642
2515 )
2516 IS
2517 
2518 l_Mesg_Token_Tbl        Error_Handler.Mesg_Token_Tbl_Type;
2519 l_other_token_tbl       Error_Handler.Token_Tbl_Type;
2520 l_other_message         VARCHAR2(50);
2521 l_err_text              VARCHAR2(2000);
2522 l_valid                 BOOLEAN := TRUE;
2523 l_Return_Status         VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
2524 l_bo_return_status      VARCHAR2(1) := 'S';
2525 l_revised_item_Rec      Eng_Eco_Pub.Revised_Item_Rec_Type;
2526 l_rev_item_unexp_Rec    Eng_Eco_Pub.Rev_Item_Unexposed_Rec_Type := p_unexp_rev_item_rec;
2527 l_old_rev_item_Rec      Eng_Eco_Pub.Revised_Item_Rec_Type := NULL;
2528 l_old_rev_item_unexp_Rec     Eng_Eco_Pub.Rev_Item_Unexposed_Rec_Type := NULL;
2529 l_eco_rec               ENG_ECO_PUB.ECO_Rec_Type := NULL;
2530 l_eco_revision_tbl      ENG_Eco_PUB.Eco_Revision_Tbl_Type;
2531 l_revised_item_tbl      ENG_Eco_PUB.Revised_Item_Tbl_Type    := p_revised_item_tbl;
2532 l_rev_component_tbl     BOM_BO_PUB.Rev_Component_Tbl_Type    := p_rev_component_tbl;
2533 l_ref_designator_tbl    BOM_BO_PUB.Ref_Designator_Tbl_Type   := p_ref_designator_tbl;
2534 l_sub_component_tbl     BOM_BO_PUB.Sub_Component_Tbl_Type    := p_sub_component_tbl;
2535 l_rev_operation_tbl     BOM_RTG_PUB.Rev_Operation_Tbl_Type    := p_rev_operation_tbl;     --add
2536 l_rev_op_resource_tbl   BOM_RTG_PUB.Rev_Op_Resource_Tbl_Type  := p_rev_op_resource_tbl;   --add
2537 l_rev_sub_resource_tbl  BOM_RTG_PUB.Rev_Sub_Resource_Tbl_Type := p_rev_sub_resource_tbl;  --add
2538 l_return_value          NUMBER;
2539 l_Token_Tbl             Error_Handler.Token_Tbl_Type;
2540 
2541 EXC_SEV_QUIT_RECORD     EXCEPTION;
2542 EXC_UNEXP_SKIP_OBJECT   EXCEPTION;
2543 
2544 BEGIN
2545 
2546 
2547     IF BOM_Globals.get_debug = 'Y'
2548    Then
2549      error_handler.write_debug('at the beginning of rev_item procedure');
2550      error_handler.write_debug('revised item count is');
2551      error_handler.write_debug(l_revised_item_tbl.COUNT);
2552 
2553    END IF;
2554 
2555     -- Begin block that processes revised items. This block holds the exception handlers
2556     -- for header errors.
2557     FOR I IN 1..l_revised_item_tbl.COUNT LOOP
2558     BEGIN
2559         --  Load local records.
2560 
2561         l_revised_item_rec := l_revised_item_tbl(I);
2562 
2563         l_revised_item_rec.transaction_type :=
2564                 UPPER(l_revised_item_rec.transaction_type);
2565 
2566         l_return_status := FND_API.G_RET_STS_SUCCESS;
2567         l_revised_item_rec.return_status := FND_API.G_RET_STS_SUCCESS;
2568 
2569         -- Process Flow step 3: Verify ECO's existence
2570         --
2571 
2572         IF g_control_rec.check_existence
2573         THEN
2574                 --dbms_output.put_line('Checking Existence');
2575                 ENG_Validate_Revised_Item.Check_Existence
2576                 ( p_revised_item_rec    => l_revised_item_rec
2577                 , p_rev_item_unexp_rec  => l_rev_item_unexp_rec
2578                 , x_old_revised_item_rec=> l_old_rev_item_rec
2579                 , x_old_rev_item_unexp_rec  => l_old_rev_item_unexp_rec
2580                 , x_Mesg_Token_Tbl      => l_Mesg_Token_Tbl
2581                 , x_return_status       => l_Return_Status
2582 		,   x_disable_revision    =>   x_disable_revision --Bug no:3034642
2583                 );
2584 IF BOM_Globals.get_debug = 'Y'
2585    Then
2586      error_handler.write_debug('After check existence');
2587  error_handler.write_debug( l_Return_Status);
2588  END IF;
2589                 --dbms_output.put_line('return_status: ' || l_return_status);
2590 
2591                 IF l_return_status = Error_Handler.G_STATUS_ERROR
2592                 THEN
2593                         RAISE EXC_SEV_QUIT_RECORD;
2594                 ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
2595                 THEN
2596                         RAISE EXC_UNEXP_SKIP_OBJECT;
2597                 END IF;
2598         END IF;
2599 
2600         IF g_control_rec.attribute_defaulting AND
2601            l_revised_item_rec.Transaction_Type = ENG_GLOBALS.G_OPR_CREATE
2602         THEN
2603 
2604                 -- Process Flow step 9: Default missing values for Operation CREATE
2605                 --dbms_output.put_line('Attribute Defaulting');
2606                 Eng_Default_Revised_Item.Attribute_Defaulting
2607                 (   p_revised_item_rec   => l_revised_item_rec
2608                 ,   p_rev_item_unexp_rec => l_rev_item_unexp_rec
2609                 ,   x_revised_item_rec   => l_revised_item_rec
2610                 ,   x_rev_item_unexp_rec => l_rev_item_unexp_rec
2611                 ,   x_Mesg_Token_Tbl     => l_Mesg_Token_Tbl
2612                 ,   x_return_status      => l_Return_Status
2613                 );
2614 IF BOM_Globals.get_debug = 'Y'
2615    Then
2616      error_handler.write_debug('After attribute defaulting, the return status is');
2617      error_handler.write_debug( l_Return_Status);
2618    END IF;
2619                 --dbms_output.put_line('return_status: ' || l_return_status);
2620 
2621                 IF l_return_status = Error_Handler.G_STATUS_ERROR
2622                 THEN
2623                         RAISE EXC_SEV_QUIT_RECORD;
2624                 ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
2625                 THEN
2626                         RAISE EXC_UNEXP_SKIP_OBJECT;
2627                 ELSIF l_return_status ='S' AND
2628                       l_Mesg_Token_Tbl.COUNT <>0
2629                 THEN
2630                         Eco_Error_Handler.Log_Error
2631                         (  p_revised_item_tbl     => l_revised_item_tbl
2632                         ,  p_rev_component_tbl    => l_rev_component_tbl
2633                         ,  p_ref_designator_tbl   => l_ref_designator_tbl
2634                         ,  p_sub_component_tbl    => l_sub_component_tbl
2635                         ,  p_mesg_token_tbl       => l_mesg_token_tbl
2636                         ,  p_error_status         => 'W'
2637                         ,  p_error_level          => 3
2638                         ,  p_entity_index         => I
2639                         ,  x_ECO_rec              => l_ECO_rec
2640                         ,  x_eco_revision_tbl     => l_eco_revision_tbl
2641                         ,  x_revised_item_tbl     => l_revised_item_tbl
2642                         ,  x_rev_component_tbl    => l_rev_component_tbl
2643                         ,  x_ref_designator_tbl   => l_ref_designator_tbl
2644                         ,  x_sub_component_tbl    => l_sub_component_tbl
2645                         ,  x_rev_operation_tbl    => l_rev_operation_tbl    --add
2646                         ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
2647                         ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
2648                         );
2649                 END IF;
2650         END IF;
2651 
2652         IF ((g_control_rec.entity_defaulting AND
2653              NOT g_control_rec.attribute_defaulting)
2654             OR
2655             g_control_rec.entity_validation)
2656            AND
2657            l_revised_item_rec.transaction_type='UPDATE'
2658         THEN
2659                 --dbms_output.put_line('querying row');
2660                 ENG_Revised_Item_Util.Query_Row
2661                 ( p_revised_item_id     => l_rev_item_unexp_rec.revised_item_id
2662                 , p_organization_id     => l_rev_item_unexp_rec.organization_id
2663                 , p_change_notice       => l_revised_item_rec.eco_name
2664                 , p_start_eff_date      => l_revised_item_rec.start_effective_date
2665                 , p_new_item_revision   => l_revised_item_rec.new_revised_item_revision
2666                 , p_new_routing_revision => l_revised_item_rec.new_routing_revision --add
2667                 , p_from_end_item_number=> l_revised_item_rec.from_end_item_unit_number
2668                 , p_alternate_designator => l_revised_item_rec.alternate_bom_code -- To Fix Bug 3760265
2669                 , x_revised_item_rec    => l_old_rev_item_rec
2670                 , x_rev_item_unexp_rec  => l_old_rev_item_unexp_rec
2671                 , x_Return_status       => l_return_status
2672                 );
2673 
2674 IF BOM_Globals.get_debug = 'Y'
2675    Then
2676       error_handler.write_debug('After query row, the return status is');
2677      error_handler.write_debug( l_Return_Status);
2678    END IF;
2679 
2680                 --dbms_output.put_line('return_status: ' || l_return_status);
2681 
2682 /*              IF l_return_status = 'F'
2683                 THEN
2684                         dbms_output.put_line('queried old record');
2685                 ELSIF l_return_status = 'N'
2686                 THEN
2687                         dbms_output.put_line('old record not found');
2688                 END IF;*/
2689         END IF;
2690 
2691      -- Process Flow step 11 - Entity Level Defaulting
2692 
2693         IF g_control_rec.entity_defaulting
2694         THEN
2695                 --dbms_output.put_line('Entity Defaulting');
2696 
2697                 Eng_Default_Revised_Item.Entity_Defaulting
2698                 (   p_revised_item_rec          => l_revised_item_rec
2699                 ,   p_rev_item_unexp_rec        => l_rev_item_unexp_rec
2700                 ,   p_old_revised_item_rec      => l_old_rev_item_rec
2701                 ,   p_old_rev_item_unexp_rec    => l_old_rev_item_unexp_rec
2702                 ,   p_control_rec               => g_control_rec
2703                 ,   x_revised_item_rec          => l_revised_item_rec
2704                 ,   x_rev_item_unexp_rec        => l_rev_item_unexp_rec
2705                 ,   x_Mesg_Token_Tbl            => l_Mesg_Token_Tbl
2706                 ,   x_return_status             => l_return_status
2707                 );
2708 
2709 IF BOM_Globals.get_debug = 'Y'
2710    Then
2711       error_handler.write_debug('After eitity default, the return status is');
2712      error_handler.write_debug( l_Return_Status);
2713    END IF;
2714                 --dbms_output.put_line('return_status: ' || l_return_status);
2715 
2716                 IF l_return_status = Error_Handler.G_STATUS_ERROR
2717                 THEN
2718                         RAISE EXC_SEV_QUIT_RECORD;
2719                 ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
2720                 THEN
2721                         RAISE EXC_UNEXP_SKIP_OBJECT;
2722                 ELSIF l_return_status ='S' AND
2723                       l_Mesg_Token_Tbl.COUNT <>0
2724                 THEN
2725                         Eco_Error_Handler.Log_Error
2726                         (  p_ECO_rec              => l_ECO_rec
2727                         ,  p_eco_revision_tbl     => l_eco_revision_tbl
2728                         ,  p_revised_item_tbl     => l_revised_item_tbl
2729                         ,  p_rev_component_tbl    => l_rev_component_tbl
2730                         ,  p_ref_designator_tbl   => l_ref_designator_tbl
2731                         ,  p_sub_component_tbl    => l_sub_component_tbl
2732                         ,  p_rev_operation_tbl    => l_rev_operation_tbl    --add
2733                         ,  p_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
2734                         ,  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
2735                         ,  p_mesg_token_tbl       => l_mesg_token_tbl
2736                         ,  p_error_status         => 'W'
2737                         ,  p_entity_index         => I
2738                         ,  p_error_level          => 3
2739                         ,  x_ECO_rec              => l_ECO_rec
2740                         ,  x_eco_revision_tbl     => l_eco_revision_tbl
2741                         ,  x_revised_item_tbl     => l_revised_item_tbl
2742                         ,  x_rev_component_tbl    => l_rev_component_tbl
2743                         ,  x_ref_designator_tbl   => l_ref_designator_tbl
2744                         ,  x_sub_component_tbl    => l_sub_component_tbl
2745                         ,  x_rev_operation_tbl    => l_rev_operation_tbl    --add
2746                         ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
2747                         ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
2748                         );
2749                 END IF;
2750         END IF;
2751 
2752      -- Process Flow step 12 - Entity Level Validation
2753 
2754         IF g_control_rec.entity_validation
2755         THEN
2756                 --dbms_output.put_line('Entity validation');
2757                 IF l_revised_item_rec.transaction_type = 'DELETE'
2758                 THEN
2759                         Eng_Validate_Revised_Item.Check_Entity_Delete
2760                         (  p_revised_item_rec     => l_revised_item_rec
2761                         ,  p_rev_item_unexp_rec   => l_rev_item_unexp_rec
2762                         ,  x_Mesg_Token_Tbl       => l_Mesg_Token_Tbl
2763                         ,  x_return_status        => l_Return_Status
2764                         );
2765                 ELSE
2766                         Eng_Validate_Revised_Item.Check_Entity
2767                         (  p_revised_item_rec     => l_revised_item_rec
2768                         ,  p_rev_item_unexp_rec   => l_rev_item_unexp_rec
2769                         ,  p_old_revised_item_rec => l_old_rev_item_rec
2770                         ,  p_old_rev_item_unexp_rec => l_old_rev_item_unexp_rec
2771                         ,  p_control_rec          => g_control_rec
2772                         ,  x_Mesg_Token_Tbl       => l_Mesg_Token_Tbl
2773                         ,  x_return_status        => l_Return_Status
2774                         );
2775                 END IF;
2776 
2777 IF BOM_Globals.get_debug = 'Y'
2778    Then
2779       error_handler.write_debug('After entity validation.');
2780      error_handler.write_debug( l_Return_Status);
2781    END IF;
2782 
2783                 --dbms_output.put_line('return_status: ' || l_return_status);
2784 
2785                 IF l_return_status = Error_Handler.G_STATUS_ERROR
2786                 THEN
2787                         RAISE EXC_SEV_QUIT_RECORD;
2788                 ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
2789                 THEN
2790                         RAISE EXC_UNEXP_SKIP_OBJECT;
2791                 ELSIF l_return_status ='S' AND
2792                       l_Mesg_Token_Tbl.COUNT <>0
2793                 THEN
2794                         Eco_Error_Handler.Log_Error
2795                         (  p_ECO_rec              => l_ECO_rec
2796                         ,  p_eco_revision_tbl     => l_eco_revision_tbl
2797                         ,  p_revised_item_tbl     => l_revised_item_tbl
2798                         ,  p_rev_component_tbl    => l_rev_component_tbl
2799                         ,  p_ref_designator_tbl   => l_ref_designator_tbl
2800                         ,  p_sub_component_tbl    => l_sub_component_tbl
2801                         ,  p_rev_operation_tbl    => l_rev_operation_tbl    --add
2802                         ,  p_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
2803                         ,  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
2804                         ,  p_mesg_token_tbl       => l_mesg_token_tbl
2805                         ,  p_error_status         => 'W'
2806                         ,  p_error_level          => 3
2807                         ,  p_entity_index         => I
2808                         ,  x_ECO_rec              => l_ECO_rec
2809                         ,  x_eco_revision_tbl     => l_eco_revision_tbl
2810                         ,  x_revised_item_tbl     => l_revised_item_tbl
2811                         ,  x_rev_component_tbl    => l_rev_component_tbl
2812                         ,  x_ref_designator_tbl   => l_ref_designator_tbl
2813                         ,  x_sub_component_tbl    => l_sub_component_tbl
2814                         ,  x_rev_operation_tbl    => l_rev_operation_tbl    --add
2815                         ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
2816                         ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
2817                         );
2818                 END IF;
2819         END IF;
2820 
2821         -- Process Flow step 13 : Database Writes
2822 
2823         IF g_control_rec.write_to_db
2824         THEN
2825                 eng_globals.set_user_id(p_user_id => g_control_rec.last_updated_by);
2826                 eng_globals.set_login_id(p_login_id => g_control_rec.last_update_login);
2827 
2828                 --dbms_output.put_line('Writing to the database');
2829                 ENG_Revised_Item_Util.Perform_Writes
2830                 (   p_revised_item_rec          => l_revised_item_rec
2831                 ,   p_rev_item_unexp_rec        => l_rev_item_unexp_rec
2832                 ,   p_control_rec               => g_control_rec
2833                 ,   x_Mesg_Token_Tbl            => l_Mesg_Token_Tbl
2834                 ,   x_return_status             => l_return_status
2835                 );
2836 
2837 IF BOM_Globals.get_debug = 'Y'
2838    Then
2839       error_handler.write_debug('After write to db, the return status is');
2840      error_handler.write_debug( l_Return_Status);
2841    END IF;
2842 
2843                 --dbms_output.put_line('return_status: ' || l_return_status);
2844 
2845                 IF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
2846                 THEN
2847                         RAISE EXC_UNEXP_SKIP_OBJECT;
2848                 ELSIF l_return_status ='S' AND
2849                       l_Mesg_Token_Tbl.COUNT <>0
2850                 THEN
2851                         Eco_Error_Handler.Log_Error
2852                         (  p_ECO_rec              => l_ECO_rec
2853                         ,  p_eco_revision_tbl     => l_eco_revision_tbl
2854                         ,  p_revised_item_tbl     => l_revised_item_tbl
2855                         ,  p_rev_component_tbl    => l_rev_component_tbl
2856                         ,  p_ref_designator_tbl   => l_ref_designator_tbl
2857                         ,  p_sub_component_tbl    => l_sub_component_tbl
2858                         ,  p_rev_operation_tbl    => l_rev_operation_tbl    --add
2859                         ,  p_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
2860                         ,  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
2861                         ,  p_mesg_token_tbl       => l_mesg_token_tbl
2862                         ,  p_error_status         => 'W'
2863                         ,  p_error_level          => 3
2864                         ,  p_entity_index         => I
2865                         ,  x_ECO_rec              => l_ECO_rec
2866                         ,  x_eco_revision_tbl     => l_eco_revision_tbl
2867                         ,  x_revised_item_tbl     => l_revised_item_tbl
2868                         ,  x_rev_component_tbl    => l_rev_component_tbl
2869                         ,  x_ref_designator_tbl   => l_ref_designator_tbl
2870                         ,  x_sub_component_tbl    => l_sub_component_tbl
2871                         ,  x_rev_operation_tbl    => l_rev_operation_tbl    --add
2872                         ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
2873                         ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
2874                         );
2875                 END IF;
2876         END IF;
2877 
2878         l_revised_item_tbl(I) := l_revised_item_rec;
2879 
2880   EXCEPTION
2881 
2882     WHEN EXC_SEV_QUIT_RECORD THEN
2883 
2884         --dbms_output.put_line('Expected error generated');
2885         Eco_Error_Handler.Log_Error
2886                 (  p_revised_item_tbl     => l_revised_item_tbl
2887                 ,  p_rev_component_tbl    => l_rev_component_tbl
2888                 ,  p_ref_designator_tbl   => l_ref_designator_tbl
2889                 ,  p_sub_component_tbl    => l_sub_component_tbl
2890                 ,  p_rev_operation_tbl    => l_rev_operation_tbl    --add
2891                 ,  p_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
2892                 ,  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
2893                 ,  p_mesg_token_tbl       => l_mesg_token_tbl
2894                 ,  p_error_status         => FND_API.G_RET_STS_ERROR
2895                 ,  p_error_scope          => Error_Handler.G_SCOPE_RECORD
2896                 ,  p_error_level          => 3
2897                 ,  p_entity_index         => I
2898                 ,  x_ECO_rec              => l_ECO_rec
2899                 ,  x_eco_revision_tbl     => l_eco_revision_tbl
2900                 ,  x_revised_item_tbl     => l_revised_item_tbl
2901                 ,  x_rev_component_tbl    => l_rev_component_tbl
2902                 ,  x_ref_designator_tbl   => l_ref_designator_tbl
2903                 ,  x_sub_component_tbl    => l_sub_component_tbl
2904                 ,  x_rev_operation_tbl    => l_rev_operation_tbl    --add
2905                 ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
2906                 ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
2907                 );
2908 --dbms_output.put_line('logged error: ' || l_return_Status);
2909         x_return_status                := l_return_status;
2910         x_Mesg_Token_Tbl               := l_Mesg_Token_Tbl;
2911         x_ECO_rec                      := l_ECO_rec;
2912         x_unexp_rev_item_rec           := l_rev_item_unexp_Rec;
2913         x_eco_revision_tbl             := l_eco_revision_tbl;
2914         x_revised_item_tbl             := l_revised_item_tbl;
2915         x_rev_component_tbl            := l_rev_component_tbl;
2916         x_ref_designator_tbl           := l_ref_designator_tbl;
2917         x_sub_component_tbl            := l_sub_component_tbl;
2918         x_rev_operation_tbl            := l_rev_operation_tbl;    --add
2919         x_rev_op_resource_tbl          := l_rev_op_resource_tbl;  --add
2920         x_rev_sub_resource_tbl         := l_rev_sub_resource_tbl; --add
2921 
2922         RETURN;
2923 
2924     WHEN EXC_UNEXP_SKIP_OBJECT THEN
2925 
2926         --dbms_output.put_line('Unexpected error generated');
2927         Eco_Error_Handler.Log_Error
2928                 (  p_revised_item_tbl     => l_revised_item_tbl
2929                 ,  p_rev_component_tbl    => l_rev_component_tbl
2930                 ,  p_ref_designator_tbl   => l_ref_designator_tbl
2931                 ,  p_sub_component_tbl    => l_sub_component_tbl
2932                 ,  p_rev_operation_tbl    => l_rev_operation_tbl    --add
2933                 ,  p_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
2934                 ,  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
2935                 ,  p_mesg_token_tbl       => l_mesg_token_tbl
2936                 ,  p_error_status         => Error_Handler.G_STATUS_UNEXPECTED
2937                 ,  p_other_status         => Error_Handler.G_STATUS_NOT_PICKED
2938                 ,  p_other_message        => l_other_message
2939                 ,  p_other_token_tbl      => l_other_token_tbl
2940                 ,  p_error_level          => 3
2941                 ,  x_ECO_rec              => l_ECO_rec
2942                 ,  x_eco_revision_tbl     => l_eco_revision_tbl
2943                 ,  x_revised_item_tbl     => l_revised_item_tbl
2944                 ,  x_rev_component_tbl    => l_rev_component_tbl
2945                 ,  x_ref_designator_tbl   => l_ref_designator_tbl
2946                 ,  x_sub_component_tbl    => l_sub_component_tbl
2947                 ,  x_rev_operation_tbl    => l_rev_operation_tbl    --add
2948                 ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
2949                 ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
2950                 );
2951 
2952         x_return_status                := l_return_status;
2953         x_Mesg_Token_Tbl               := l_Mesg_Token_Tbl;
2954         x_ECO_rec                      := l_ECO_rec;
2955         x_unexp_rev_item_rec           := l_rev_item_unexp_Rec;
2956         x_eco_revision_tbl             := l_eco_revision_tbl;
2957         x_revised_item_tbl             := l_revised_item_tbl;
2958         x_rev_component_tbl            := l_rev_component_tbl;
2959         x_ref_designator_tbl           := l_ref_designator_tbl;
2960         x_sub_component_tbl            := l_sub_component_tbl;
2961         x_rev_operation_tbl            := l_rev_operation_tbl;    --add
2962         x_rev_op_resource_tbl          := l_rev_op_resource_tbl;  --add
2963         x_rev_sub_resource_tbl         := l_rev_sub_resource_tbl; --add
2964 
2965         l_return_status := 'U';
2966 
2967   END;
2968   END LOOP; -- END revised items processing block
2969 
2970     IF l_return_status in ('Q', 'U')
2971     THEN
2972         x_return_status := l_return_status;
2973         RETURN;
2974     END IF;
2975 
2976     l_bo_return_status := l_return_status;
2977 
2978 
2979      --  Load OUT parameters
2980 
2981      x_return_status            := l_bo_return_status;
2982      x_ECO_rec                  := l_ECO_rec;
2983      x_unexp_rev_item_rec       := l_rev_item_unexp_Rec;
2984      x_eco_revision_tbl         := l_eco_revision_tbl;
2985      x_revised_item_tbl         := l_revised_item_tbl;
2986      x_rev_component_tbl        := l_rev_component_tbl;
2987      x_ref_designator_tbl       := l_ref_designator_tbl;
2988      x_sub_component_tbl        := l_sub_component_tbl;
2989      x_rev_operation_tbl        := l_rev_operation_tbl;    --add
2990      x_rev_op_resource_tbl      := l_rev_op_resource_tbl;  --add
2991      x_rev_sub_resource_tbl     := l_rev_sub_resource_tbl; --add
2992      x_Mesg_Token_Tbl           := l_Mesg_Token_Tbl;
2993 
2994 END Rev_Items;
2995 
2996 --  Eco_Rev
2997 
2998 PROCEDURE Eco_Rev
2999 (   p_eco_revision_tbl              IN  ENG_Eco_PUB.Eco_Revision_Tbl_Type
3000 ,   p_unexp_eco_rev_rec             IN  ENG_Eco_PUB.Eco_Rev_Unexposed_Rec_Type
3001 ,   p_revised_item_tbl              IN  ENG_Eco_PUB.Revised_Item_Tbl_Type
3002 ,   p_rev_component_tbl             IN  BOM_BO_PUB.Rev_Component_Tbl_Type
3003 ,   p_ref_designator_tbl            IN  BOM_BO_PUB.Ref_Designator_Tbl_Type
3004 ,   p_sub_component_tbl             IN  BOM_BO_PUB.Sub_Component_Tbl_Type
3005 ,   p_rev_operation_tbl             IN  BOM_RTG_PUB.Rev_operation_Tbl_Type    --add
3006 ,   p_rev_op_resource_tbl           IN  BOM_RTG_PUB.Rev_op_resource_Tbl_Type  --add
3007 ,   p_rev_sub_resource_tbl          IN  BOM_RTG_PUB.Rev_sub_resource_Tbl_Type --add
3008 ,   x_ECO_rec                       IN OUT NOCOPY ENG_Eco_PUB.Eco_Rec_Type
3009 ,   x_unexp_eco_rev_rec             IN OUT NOCOPY ENG_Eco_PUB.Eco_Rev_Unexposed_Rec_Type
3010 ,   x_eco_revision_tbl              IN OUT NOCOPY ENG_Eco_PUB.Eco_Revision_Tbl_Type
3011 ,   x_revised_item_tbl              IN OUT NOCOPY ENG_Eco_PUB.Revised_Item_Tbl_Type
3012 ,   x_rev_component_tbl             IN OUT NOCOPY BOM_BO_PUB.Rev_Component_Tbl_Type
3013 ,   x_ref_designator_tbl            IN OUT NOCOPY BOM_BO_PUB.Ref_Designator_Tbl_Type
3014 ,   x_sub_component_tbl             IN OUT NOCOPY BOM_BO_PUB.Sub_Component_Tbl_Type
3015 ,   x_rev_operation_tbl             IN OUT NOCOPY BOM_RTG_PUB.Rev_operation_Tbl_Type    --add
3016 ,   x_rev_op_resource_tbl           IN OUT NOCOPY BOM_RTG_PUB.Rev_op_resource_Tbl_Type  --add
3017 ,   x_rev_sub_resource_tbl          IN OUT NOCOPY BOM_RTG_PUB.Rev_sub_resource_Tbl_Type --add
3018 ,   x_Mesg_Token_Tbl                IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
3019 ,   x_return_status                 IN OUT NOCOPY VARCHAR2
3020 )
3021 IS
3022 
3023 l_Mesg_Token_Tbl        Error_Handler.Mesg_Token_Tbl_Type;
3024 l_other_token_tbl       Error_Handler.Token_Tbl_Type;
3025 l_other_message         VARCHAR2(50);
3026 l_err_text              VARCHAR2(2000);
3027 l_valid                 BOOLEAN := TRUE;
3028 l_Return_Status         VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
3029 l_bo_return_status      VARCHAR2(1) := 'S';
3030 l_eco_rev_unexp_Rec     Eng_Eco_Pub.Eco_Rev_Unexposed_Rec_Type := p_unexp_eco_rev_rec;
3031 l_eco_rec               ENG_ECO_PUB.ECO_Rec_Type := NULL;
3032 l_eco_revision_rec      ENG_ECO_PUB.Eco_Revision_Rec_Type;
3033 l_eco_revision_tbl      ENG_Eco_PUB.Eco_Revision_Tbl_Type    := p_eco_revision_tbl;
3034 l_revised_item_tbl      ENG_Eco_PUB.Revised_Item_Tbl_Type    := p_revised_item_tbl;
3035 l_rev_component_tbl     BOM_BO_PUB.Rev_Component_Tbl_Type    := p_rev_component_tbl;
3036 l_ref_designator_tbl    BOM_BO_PUB.Ref_Designator_Tbl_Type   := p_ref_designator_tbl;
3037 l_sub_component_tbl     BOM_BO_PUB.Sub_Component_Tbl_Type    := p_sub_component_tbl;
3038 l_rev_operation_tbl     BOM_RTG_PUB.Rev_Operation_Tbl_Type    := p_rev_operation_tbl;    --add
3039 l_rev_op_resource_tbl   BOM_RTG_PUB.Rev_Op_Resource_Tbl_Type  := p_rev_op_resource_tbl;  --add
3040 l_rev_sub_resource_tbl  BOM_RTG_PUB.Rev_Sub_Resource_Tbl_Type := p_rev_sub_resource_tbl; --add
3041 l_return_value          NUMBER;
3042 l_Token_Tbl             Error_Handler.Token_Tbl_Type;
3043 
3044 EXC_SEV_QUIT_RECORD     EXCEPTION;
3045 EXC_UNEXP_SKIP_OBJECT   EXCEPTION;
3046 
3047 BEGIN
3048 
3049     -- Begin block that processes eco revisions. This block holds the exception handlers
3050     -- for header errors.
3051 
3052     FOR I IN 1..l_eco_revision_tbl.COUNT LOOP
3053     BEGIN
3054         --  Load local records.
3055 
3056         --  Load local records.
3057 
3058         l_eco_revision_rec := l_eco_revision_tbl(I);
3059 
3060         l_eco_revision_rec.transaction_type :=
3061                 UPPER(l_eco_revision_rec.transaction_type);
3062 
3063         l_return_status := FND_API.G_RET_STS_SUCCESS;
3064         l_eco_revision_rec.return_status := FND_API.G_RET_STS_SUCCESS;
3065 
3066         IF g_control_rec.attribute_defaulting
3067         THEN
3068 
3069                 --dbms_output.put_line('Attribute Defaulting');
3070                  Eng_Default_ECO_revision.Attribute_Defaulting
3071                         (   p_eco_revision_rec          => l_eco_revision_rec
3072                         ,   p_eco_rev_unexp_rec         => l_eco_rev_unexp_rec
3073                         ,   x_eco_revision_rec          => l_eco_revision_rec
3074                         ,   x_eco_rev_unexp_rec         => l_eco_rev_unexp_Rec
3075                         ,   x_Mesg_Token_Tbl            => l_Mesg_Token_Tbl
3076                         ,   x_return_status             => l_Return_Status
3077                         );
3078 
3079                 --dbms_output.put_line('return_status: ' || l_return_status);
3080 
3081                 IF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
3082                 THEN
3083                         RAISE EXC_UNEXP_SKIP_OBJECT;
3084                 ELSIF l_return_status ='S' AND
3085                       l_Mesg_Token_Tbl.COUNT <>0
3086                 THEN
3087                         Eco_Error_Handler.Log_Error
3088                         (  p_ECO_rec            => l_ECO_rec
3089                         ,  p_eco_revision_tbl   => l_eco_revision_tbl
3090                         ,  p_revised_item_tbl   => l_revised_item_tbl
3091                         ,  p_rev_component_tbl  => l_rev_component_tbl
3092                         ,  p_ref_designator_tbl => l_ref_designator_tbl
3093                         ,  p_sub_component_tbl  => l_sub_component_tbl
3094                         ,  p_rev_operation_tbl    => l_rev_operation_tbl    --add
3095                         ,  p_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
3096                         ,  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
3097                         ,  p_mesg_token_tbl     => l_mesg_token_tbl
3098                         ,  p_error_status       => 'W'
3099                         ,  p_error_level        => 3
3100                         ,  p_entity_index       => I
3101                         ,  x_ECO_rec            => l_ECO_rec
3102                         ,  x_eco_revision_tbl   => l_eco_revision_tbl
3103                         ,  x_revised_item_tbl   => l_revised_item_tbl
3104                         ,  x_rev_component_tbl  => l_rev_component_tbl
3105                         ,  x_ref_designator_tbl => l_ref_designator_tbl
3106                         ,  x_sub_component_tbl  => l_sub_component_tbl
3107                         ,  x_rev_operation_tbl    => l_rev_operation_tbl    --add
3108                         ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
3109                         ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
3110                         );
3111                 END IF;
3112 
3113         END IF;
3114 
3115         -- Process Flow step 13 : Database Writes
3116 
3117         IF g_control_rec.write_to_db
3118         THEN
3119                 eng_globals.set_user_id(p_user_id => g_control_rec.last_updated_by);
3120                 eng_globals.set_login_id(p_login_id => g_control_rec.last_update_login);
3121                 --dbms_output.put_line('Writing to the database');
3122                 ENG_Eco_Revision_Util.Perform_Writes
3123                 (   p_eco_revision_rec          => l_eco_revision_rec
3124                 ,   p_eco_rev_unexp_rec         => l_eco_rev_unexp_rec
3125                 ,   p_control_rec               => g_control_rec
3126                 ,   x_Mesg_Token_Tbl            => l_Mesg_Token_Tbl
3127                 ,   x_return_status             => l_return_status
3128                 );
3129 
3130                 --dbms_output.put_line('return_status: ' || l_return_status);
3131 
3132                 IF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
3133                 THEN
3134                         RAISE EXC_UNEXP_SKIP_OBJECT;
3135                 ELSIF l_return_status ='S' AND
3136                       l_Mesg_Token_Tbl.COUNT <>0
3137                 THEN
3138                         Eco_Error_Handler.Log_Error
3139                         (  p_ECO_rec              => l_ECO_rec
3140                         ,  p_eco_revision_tbl     => l_eco_revision_tbl
3141                         ,  p_revised_item_tbl     => l_revised_item_tbl
3142                         ,  p_rev_component_tbl    => l_rev_component_tbl
3143                         ,  p_ref_designator_tbl   => l_ref_designator_tbl
3144                         ,  p_sub_component_tbl    => l_sub_component_tbl
3145                         ,  p_rev_operation_tbl    => l_rev_operation_tbl    --add
3146                         ,  p_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
3147                         ,  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
3148                         ,  p_mesg_token_tbl       => l_mesg_token_tbl
3149                         ,  p_error_status         => 'W'
3150                         ,  p_error_level          => 3
3151                         ,  p_entity_index         => I
3152                         ,  x_ECO_rec              => l_ECO_rec
3153                         ,  x_eco_revision_tbl     => l_eco_revision_tbl
3154                         ,  x_revised_item_tbl     => l_revised_item_tbl
3155                         ,  x_rev_component_tbl    => l_rev_component_tbl
3156                         ,  x_ref_designator_tbl   => l_ref_designator_tbl
3157                         ,  x_sub_component_tbl    => l_sub_component_tbl
3158                         ,  x_rev_operation_tbl    => l_rev_operation_tbl    --add
3159                         ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
3160                         ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
3161                         );
3162                 END IF;
3163         END IF;
3164 
3165         l_eco_revision_tbl(I)          := l_eco_revision_rec;
3166 
3167         --  For loop exception handler.
3168 
3169 
3170      EXCEPTION
3171 
3172        WHEN EXC_SEV_QUIT_RECORD THEN
3173 
3174         Eco_Error_Handler.Log_Error
3175                 (  p_eco_revision_tbl     => l_eco_revision_tbl
3176                 ,  p_revised_item_tbl     => l_revised_item_tbl
3177                 ,  p_rev_component_tbl    => l_rev_component_tbl
3178                 ,  p_ref_designator_tbl   => l_ref_designator_tbl
3179                 ,  p_sub_component_tbl    => l_sub_component_tbl
3180                 ,  p_rev_operation_tbl    => l_rev_operation_tbl    --add
3181                 ,  p_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
3182                 ,  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
3183                 ,  p_mesg_token_tbl       => l_mesg_token_tbl
3184                 ,  p_error_status         => FND_API.G_RET_STS_ERROR
3185                 ,  p_error_scope          => Error_Handler.G_SCOPE_RECORD
3186                 ,  p_error_level          => 2
3187                 ,  p_entity_index         => I
3188                 ,  x_eco_rec              => l_eco_rec
3189                 ,  x_eco_revision_tbl     => l_eco_revision_tbl
3190                 ,  x_revised_item_tbl     => l_revised_item_tbl
3191                 ,  x_rev_component_tbl    => l_rev_component_tbl
3192                 ,  x_ref_designator_tbl   => l_ref_designator_tbl
3193                 ,  x_sub_component_tbl    => l_sub_component_tbl
3194                 ,  x_rev_operation_tbl    => l_rev_operation_tbl    --add
3195                 ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
3196                 ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
3197                 );
3198 
3199         IF l_bo_return_status = 'S'
3200         THEN
3201                 l_bo_return_status     := l_return_status;
3202         END IF;
3203         x_return_status                := l_bo_return_status;
3204         x_Mesg_Token_Tbl               := l_Mesg_Token_Tbl;
3205         x_eco_revision_tbl             := l_eco_revision_tbl;
3206         x_unexp_eco_rev_rec            := l_eco_rev_unexp_rec;
3207         x_revised_item_tbl             := l_revised_item_tbl;
3208         x_rev_component_tbl            := l_rev_component_tbl;
3209         x_ref_designator_tbl           := l_ref_designator_tbl;
3210         x_sub_component_tbl            := l_sub_component_tbl;
3211 
3212         RETURN;
3213 
3214     WHEN EXC_UNEXP_SKIP_OBJECT THEN
3215 
3216         --dbms_output.put_line('Unexpected error generated');
3217         Eco_Error_Handler.Log_Error
3218                 (  p_eco_revision_tbl     => l_eco_revision_tbl
3219                 ,  p_revised_item_tbl     => l_revised_item_tbl
3220                 ,  p_rev_component_tbl    => l_rev_component_tbl
3221                 ,  p_ref_designator_tbl   => l_ref_designator_tbl
3222                 ,  p_sub_component_tbl    => l_sub_component_tbl
3223                 ,  p_rev_operation_tbl    => l_rev_operation_tbl    --add
3224                 ,  p_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
3225                 ,  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
3226                 ,  p_mesg_token_tbl       => l_mesg_token_tbl
3227                 ,  p_error_status         => FND_API.G_RET_STS_ERROR
3228                 ,  p_error_scope          => Error_Handler.G_SCOPE_RECORD
3229                 ,  p_error_level          => 2
3230                 ,  p_entity_index         => I
3231                 ,  x_eco_rec              => l_eco_rec
3232                 ,  x_eco_revision_tbl     => l_eco_revision_tbl
3233                 ,  x_revised_item_tbl     => l_revised_item_tbl
3234                 ,  x_rev_component_tbl    => l_rev_component_tbl
3235                 ,  x_ref_designator_tbl   => l_ref_designator_tbl
3236                 ,  x_sub_component_tbl    => l_sub_component_tbl
3237                 ,  x_rev_operation_tbl    => l_rev_operation_tbl    --add
3238                 ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
3239                 ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
3240                 );
3241 
3242         x_return_status                := l_bo_return_status;
3243         x_Mesg_Token_Tbl               := l_Mesg_Token_Tbl;
3244         x_eco_revision_tbl             := l_eco_revision_tbl;
3245         x_unexp_eco_rev_rec            := l_eco_rev_unexp_rec;
3246         x_revised_item_tbl             := l_revised_item_tbl;
3247         x_rev_component_tbl            := l_rev_component_tbl;
3248         x_ref_designator_tbl           := l_ref_designator_tbl;
3249         x_sub_component_tbl            := l_sub_component_tbl;
3250 
3251         l_return_status := 'U';
3252 
3253         IF g_control_rec.write_to_db
3254         THEN
3255                 RAISE;
3256         END IF;
3257 
3258   END;
3259   END LOOP; -- END eco revisions processing block
3260 
3261     IF l_return_status in ('Q', 'U')
3262     THEN
3263         x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
3264         x_return_status := l_return_status;
3265         RETURN;
3266     END IF;
3267 
3268     l_bo_return_status := l_return_status;
3269 
3270 
3271      --  Load OUT parameters
3272 
3273      x_return_status            := l_bo_return_status;
3274      x_ECO_rec                  := l_ECO_rec;
3275      x_unexp_eco_rev_rec        := l_eco_rev_unexp_Rec;
3276      x_eco_revision_tbl         := l_eco_revision_tbl;
3277      x_revised_item_tbl         := l_revised_item_tbl;
3278      x_rev_component_tbl        := l_rev_component_tbl;
3279      x_ref_designator_tbl       := l_ref_designator_tbl;
3280      x_sub_component_tbl        := l_sub_component_tbl;
3281      x_Mesg_Token_Tbl           := l_Mesg_Token_Tbl;
3282 
3283 END Eco_Rev;
3284 
3285 --  Eco_Header
3286 
3287 PROCEDURE Eco_Header
3288 (   p_ECO_rec                       IN  ENG_Eco_PUB.Eco_Rec_Type
3289 ,   p_unexp_ECO_rec                 IN  ENG_Eco_PUB.ECO_Unexposed_Rec_Type
3290 ,   p_eco_revision_tbl              IN  ENG_Eco_PUB.Eco_Revision_Tbl_Type
3291 ,   p_revised_item_tbl              IN  ENG_Eco_PUB.Revised_Item_Tbl_Type
3292 ,   p_rev_component_tbl             IN  BOM_BO_PUB.Rev_Component_Tbl_Type
3293 ,   p_ref_designator_tbl            IN  BOM_BO_PUB.Ref_Designator_Tbl_Type
3294 ,   p_sub_component_tbl             IN  BOM_BO_PUB.Sub_Component_Tbl_Type
3295 ,   p_rev_operation_tbl             IN  BOM_RTG_PUB.Rev_operation_Tbl_Type    --add
3296 ,   p_rev_op_resource_tbl           IN  BOM_RTG_PUB.Rev_op_resource_Tbl_Type  --add
3297 ,   p_rev_sub_resource_tbl          IN  BOM_RTG_PUB.Rev_sub_resource_Tbl_Type --add
3298 ,   x_ECO_rec                       IN OUT NOCOPY ENG_Eco_PUB.Eco_Rec_Type
3299 ,   x_unexp_ECO_rec                 IN OUT NOCOPY ENG_Eco_PUB.ECO_Unexposed_Rec_Type
3300 ,   x_eco_revision_tbl              IN OUT NOCOPY ENG_Eco_PUB.Eco_Revision_Tbl_Type
3301 ,   x_revised_item_tbl              IN OUT NOCOPY ENG_Eco_PUB.Revised_Item_Tbl_Type
3302 ,   x_rev_component_tbl             IN OUT NOCOPY BOM_BO_PUB.Rev_Component_Tbl_Type
3303 ,   x_ref_designator_tbl            IN OUT NOCOPY BOM_BO_PUB.Ref_Designator_Tbl_Type
3304 ,   x_sub_component_tbl             IN OUT NOCOPY BOM_BO_PUB.Sub_Component_Tbl_Type
3305 ,   x_Mesg_Token_Tbl                IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
3306 ,   x_rev_operation_tbl             IN OUT NOCOPY BOM_RTG_PUB.Rev_operation_Tbl_Type    --add
3307 ,   x_rev_op_resource_tbl           IN OUT NOCOPY BOM_RTG_PUB.Rev_op_resource_Tbl_Type  --add
3308 ,   x_rev_sub_resource_tbl          IN OUT NOCOPY BOM_RTG_PUB.Rev_sub_resource_Tbl_Type --add
3309 ,   x_return_status                 IN OUT NOCOPY VARCHAR2
3310 )
3311 IS
3312 
3313 l_Mesg_Token_Tbl        Error_Handler.Mesg_Token_Tbl_Type;
3314 l_other_token_tbl       Error_Handler.Token_Tbl_Type;
3315 l_other_message         VARCHAR2(50);
3316 l_err_text              VARCHAR2(2000);
3317 l_valid                 BOOLEAN := TRUE;
3318 l_Return_Status         VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
3319 l_bo_return_status      VARCHAR2(1) := 'S';
3320 l_ECO_Rec               Eng_Eco_Pub.ECO_Rec_Type;
3321 l_eco_unexp_Rec         Eng_Eco_Pub.ECO_Unexposed_Rec_Type := p_unexp_eco_rec;
3322 l_Old_ECO_Rec           Eng_Eco_Pub.ECO_Rec_Type := NULL;
3323 l_Old_ECO_Unexp_Rec     Eng_Eco_Pub.ECO_Unexposed_Rec_Type   := NULL;
3324 l_eco_revision_tbl      ENG_Eco_PUB.Eco_Revision_Tbl_Type    := p_eco_revision_tbl;
3325 l_revised_item_tbl      ENG_Eco_PUB.Revised_Item_Tbl_Type    := p_revised_item_tbl;
3326 l_rev_component_tbl     BOM_BO_PUB.Rev_Component_Tbl_Type    := p_rev_component_tbl;
3327 l_ref_designator_tbl    BOM_BO_PUB.Ref_Designator_Tbl_Type   := p_ref_designator_tbl;
3328 l_sub_component_tbl     BOM_BO_PUB.Sub_Component_Tbl_Type    := p_sub_component_tbl;
3329 l_rev_operation_tbl     BOM_RTG_PUB.Rev_Operation_Tbl_Type    := p_rev_operation_tbl;
3330 l_rev_op_resource_tbl   BOM_RTG_PUB.Rev_Op_Resource_Tbl_Type  := p_rev_op_resource_tbl;
3331 l_rev_sub_resource_tbl  BOM_RTG_PUB.Rev_Sub_Resource_Tbl_Type := p_rev_sub_resource_tbl;
3332 l_return_value          NUMBER;
3333 l_Token_Tbl             Error_Handler.Token_Tbl_Type;
3334 
3335 --10dec
3336 l_ECO_Rec_1               Eng_Eco_Pub.ECO_Rec_Type           := p_ECO_rec;
3337 l_eco_unexp_Rec_1         Eng_Eco_Pub.ECO_Unexposed_Rec_Type := p_unexp_eco_rec;
3338 
3339 
3340 EXC_SEV_QUIT_RECORD     EXCEPTION;
3341 EXC_UNEXP_SKIP_OBJECT   EXCEPTION;
3342 
3343 BEGIN
3344 
3345     -- Begin block that processes header. This block holds the exception handlers
3346     -- for header errors.
3347 
3348     BEGIN
3349 
3350 IF BOM_Globals.get_debug = 'Y'
3351    Then
3352      error_handler.write_debug('start of eco_header.');
3353    END IF;
3354 
3355 
3356 
3357         l_ECO_rec := p_ECO_rec;
3358         l_ECO_rec.transaction_type := UPPER(l_eco_rec.transaction_type);
3359 
3360         l_return_status := FND_API.G_RET_STS_SUCCESS;
3361         l_eco_rec.return_status := FND_API.G_RET_STS_SUCCESS;
3362 
3363         -- Process Flow step 3: Verify ECO's existence
3364         --
3365 
3366         IF g_control_rec.check_existence
3367         THEN
3368 /*
3369 IF BOM_Globals.get_debug = 'Y'
3370    Then
3371      error_handler.write_debug('organization id is');
3372      error_handler.write_debug(' l_eco_unexp_rec.organization_idorganization id is');
3373    END IF;
3374 */
3375 
3376                --dbms_output.put_line('Checking Existence');
3377                 ENG_Validate_Eco.Check_Existence
3378                 ( p_change_notice       => l_eco_rec.ECO_Name
3379                 , p_organization_id     => l_eco_unexp_rec.organization_id
3380                 , p_organization_code   => l_eco_rec.organization_code
3381                 , p_calling_entity      => 'ECO'
3382                 , p_transaction_type    => l_eco_rec.transaction_type
3383                 , x_eco_rec             => l_old_eco_rec
3384                 , x_eco_unexp_rec       => l_old_eco_unexp_rec
3385                 , x_Mesg_Token_Tbl      => l_Mesg_Token_Tbl
3386                 , x_return_status       => l_Return_Status
3387                 );
3388 
3389                 --dbms_output.put_line('return_status: ' || l_return_status);
3390 
3391                 IF l_return_status = Error_Handler.G_STATUS_ERROR
3392                 THEN
3393                         RAISE EXC_SEV_QUIT_RECORD;
3394                 ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
3395                 THEN
3396                         RAISE EXC_UNEXP_SKIP_OBJECT;
3397                 END IF;
3398         END IF;
3399 
3400 IF BOM_Globals.get_debug = 'Y'
3401    Then
3402      error_handler.write_debug('Attribute defaulting.');
3403    END IF;
3404 
3405         IF g_control_rec.attribute_defaulting AND
3406            l_ECO_Rec.Transaction_Type = ENG_GLOBALS.G_OPR_CREATE
3407         THEN
3408 
3409                 -- Process Flow step 9: Default missing values for Operation CREATE
3410 
3411                 --dbms_output.put_line('Attribute Defaulting');
3412                 Eng_Default_ECO.Attribute_Defaulting
3413                 (   p_ECO_rec           => l_ECO_Rec_1
3414                 ,   p_Unexp_ECO_Rec     => l_ECO_Unexp_Rec_1
3415                 ,   x_ECO_rec           => l_ECO_Rec
3416                 ,   x_Unexp_ECO_Rec     => l_ECO_Unexp_Rec
3417                 ,   x_Mesg_Token_Tbl    => l_Mesg_Token_Tbl
3418                 ,   x_return_status     => l_Return_Status
3419                 );
3420 
3421                 --dbms_output.put_line('return_status: ' || l_return_status);
3422 
3423                 IF l_return_status = Error_Handler.G_STATUS_ERROR
3424                 THEN
3425                         RAISE EXC_SEV_QUIT_RECORD;
3426                 ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
3427                 THEN
3428                         RAISE EXC_UNEXP_SKIP_OBJECT;
3429                 ELSIF l_return_status ='S' AND
3430                       l_Mesg_Token_Tbl.COUNT <>0
3431                 THEN
3432                         Eco_Error_Handler.Log_Error
3433                         (  p_ECO_rec              => l_ECO_rec
3434                         ,  p_eco_revision_tbl     => l_eco_revision_tbl
3435                         ,  p_revised_item_tbl     => l_revised_item_tbl
3436                         ,  p_rev_component_tbl    => l_rev_component_tbl
3437                         ,  p_ref_designator_tbl   => l_ref_designator_tbl
3438                         ,  p_sub_component_tbl    => l_sub_component_tbl
3439                         ,  p_rev_operation_tbl    => l_rev_operation_tbl    --add
3440                         ,  p_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
3441                         ,  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
3442                         ,  p_mesg_token_tbl       => l_mesg_token_tbl
3443                         ,  p_error_status         => 'W'
3444                         ,  p_error_level          => 1
3445                         ,  x_ECO_rec              => l_ECO_rec
3446                         ,  x_eco_revision_tbl     => l_eco_revision_tbl
3447                         ,  x_revised_item_tbl     => l_revised_item_tbl
3448                         ,  x_rev_component_tbl    => l_rev_component_tbl
3449                         ,  x_ref_designator_tbl   => l_ref_designator_tbl
3450                         ,  x_sub_component_tbl    => l_sub_component_tbl
3451                         ,  x_rev_operation_tbl    => l_rev_operation_tbl    --add
3452                         ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
3453                         ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
3454                         );
3455                 END IF;
3456         END IF;
3457 
3458 IF BOM_Globals.get_debug = 'Y'
3459    Then
3460      error_handler.write_debug('end of Attribute defaulting..');
3461    END IF;
3462 
3463 
3464         IF g_control_rec.entity_defaulting OR
3465            g_control_rec.entity_validation
3466         THEN
3467                 --dbms_output.put_line('querying row');
3468                 ENG_ECO_Util.Query_Row
3469                 ( p_change_notice       => l_ECO_rec.eco_name
3470                 , p_organization_id     => l_eco_unexp_rec.organization_id
3471                 , x_eco_rec             => l_old_eco_rec
3472                 , x_eco_unexp_rec       => l_old_eco_unexp_rec
3473                 , x_return_status       => l_return_status
3474                 , x_err_text            => l_err_text
3475                 );
3476 /*              IF l_return_status = 'F'
3477                 THEN
3478                         dbms_output.put_line('queried old record');
3479                 ELSIF l_return_status = 'N'
3480                 THEN
3481                         dbms_output.put_line('old record not found');
3482                 END IF;*/
3483         END IF;
3484 IF BOM_Globals.get_debug = 'Y'
3485    Then
3486      error_handler.write_debug('end of query row..');
3487    END IF;
3488 
3489 
3490      -- Process Flow step 11 - Entity Level Defaulting
3491 
3492         IF g_control_rec.entity_defaulting
3493         THEN
3494                 --dbms_output.put_line('Entity Defaulting');
3495 
3496                 ENG_Default_ECO.Entity_Defaulting
3497                 (   p_ECO_rec            => l_ECO_rec
3498                 ,   p_Unexp_ECO_rec      => l_ECO_unexp_rec
3499                 ,   p_Old_ECO_rec        => l_old_ECO_rec
3500                 ,   p_Old_Unexp_ECO_rec  => l_old_ECO_unexp_rec
3501                 ,   p_control_rec        => g_control_rec
3502                 ,   x_ECO_rec            => l_ECO_rec
3503                 ,   x_Unexp_ECO_rec      => l_ECO_unexp_rec
3504                 ,   x_return_status      => l_return_status
3505                 ,   x_Mesg_Token_Tbl     => l_Mesg_Token_Tbl
3506                 );
3507 
3508                 --dbms_output.put_line('return_status: ' || l_return_status);
3509 
3510                 IF l_return_status = Error_Handler.G_STATUS_ERROR
3511                 THEN
3512                         RAISE EXC_SEV_QUIT_RECORD;
3513                 ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
3514                 THEN                       RAISE EXC_UNEXP_SKIP_OBJECT;
3515                 ELSIF l_return_status ='S' AND
3516                       l_Mesg_Token_Tbl.COUNT <>0
3517                 THEN
3518                         Eco_Error_Handler.Log_Error
3519                         (  p_ECO_rec              => l_ECO_rec
3520                         ,  p_eco_revision_tbl     => l_eco_revision_tbl
3521                         ,  p_revised_item_tbl     => l_revised_item_tbl
3522                         ,  p_rev_component_tbl    => l_rev_component_tbl
3523                         ,  p_ref_designator_tbl   => l_ref_designator_tbl
3524                         ,  p_sub_component_tbl    => l_sub_component_tbl
3525                         ,  p_rev_operation_tbl    => l_rev_operation_tbl    --add
3526                         ,  p_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
3527                         ,  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
3528                         ,  p_mesg_token_tbl       => l_mesg_token_tbl
3529                         ,  p_error_status         => 'W'
3530                         ,  p_error_level          => 1
3531                         ,  x_ECO_rec              => l_ECO_rec
3532                         ,  x_eco_revision_tbl     => l_eco_revision_tbl
3533                         ,  x_revised_item_tbl     => l_revised_item_tbl
3534                         ,  x_rev_component_tbl    => l_rev_component_tbl
3535                         ,  x_ref_designator_tbl   => l_ref_designator_tbl
3536                         ,  x_sub_component_tbl    => l_sub_component_tbl
3537                         ,  x_rev_operation_tbl    => l_rev_operation_tbl    --add
3538                         ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
3539                         ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
3540                         );
3541                 END IF;
3542         END IF;
3543 
3544      -- Process Flow step 12 - Entity Level Validation
3545 IF BOM_Globals.get_debug = 'Y'
3546    Then
3547      error_handler.write_debug('After Entity default..');
3548    END IF;
3549 
3550       IF g_control_rec.entity_validation
3551         THEN
3552                 --dbms_output.put_line('Entity validation');
3553                 IF l_eco_rec.transaction_type = 'DELETE'
3554                 THEN
3555                         ENG_Validate_ECO.Check_Delete
3556                         ( p_eco_rec             => l_eco_rec
3557                         , p_Unexp_ECO_rec       => l_ECO_Unexp_Rec
3558                         , x_return_status       => l_return_status
3559                         , x_Mesg_Token_Tbl      => l_Mesg_Token_Tbl
3560                         );
3561 
3562                 ELSE
3563    IF BOM_Globals.get_debug = 'Y'
3564    Then
3565      error_handler.write_debug('Before check entiry..');
3566    END IF;
3567                         Eng_Validate_ECO.Check_Entity
3568                         (  x_return_status        => l_Return_Status
3569                         ,  x_err_text             => l_err_text
3570                         ,  x_Mesg_Token_Tbl       => l_Mesg_Token_Tbl
3571                         ,  p_ECO_rec              => l_ECO_Rec
3572                         ,  p_Unexp_ECO_Rec        => l_ECO_Unexp_Rec
3573                         ,  p_old_ECO_rec          => l_old_ECO_rec
3574                         ,  p_old_unexp_ECO_rec    => l_old_ECO_unexp_rec
3575                         ,  p_control_rec          => g_control_rec
3576                         );
3577 IF BOM_Globals.get_debug = 'Y'
3578    Then
3579      error_handler.write_debug('After check entity..');
3580 
3581 
3582    END IF;
3583                 END IF;
3584 
3585                 --dbms_output.put_line('return_status: ' || l_return_status);
3586 
3587                 IF l_return_status = Error_Handler.G_STATUS_ERROR
3588                 THEN
3589                         RAISE EXC_SEV_QUIT_RECORD;
3590                 ELSIF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
3591                 THEN
3592                         RAISE EXC_UNEXP_SKIP_OBJECT;
3593                 ELSIF l_return_status ='S' AND
3594                       l_Mesg_Token_Tbl.COUNT <>0
3595                 THEN
3596                         Eco_Error_Handler.Log_Error
3597                         (  p_ECO_rec              => l_ECO_rec
3598                         ,  p_eco_revision_tbl     => l_eco_revision_tbl
3599                         ,  p_revised_item_tbl     => l_revised_item_tbl
3600                         ,  p_rev_component_tbl    => l_rev_component_tbl
3601                         ,  p_ref_designator_tbl   => l_ref_designator_tbl
3602                         ,  p_sub_component_tbl    => l_sub_component_tbl
3603                         ,  p_rev_operation_tbl    => l_rev_operation_tbl    --add
3604                         ,  p_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
3605                         ,  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
3606                         ,  p_mesg_token_tbl       => l_mesg_token_tbl
3607                         ,  p_error_status         => 'W'
3608                         ,  p_error_level          => 1
3609                         ,  x_ECO_rec              => l_ECO_rec
3610                         ,  x_eco_revision_tbl     => l_eco_revision_tbl
3611                         ,  x_revised_item_tbl     => l_revised_item_tbl
3612                         ,  x_rev_component_tbl    => l_rev_component_tbl
3613                         ,  x_ref_designator_tbl   => l_ref_designator_tbl
3614                         ,  x_sub_component_tbl    => l_sub_component_tbl
3615                         ,  x_rev_operation_tbl    => l_rev_operation_tbl    --add
3616                         ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
3617                         ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
3618                         );
3619                 END IF;
3620         END IF;
3621 IF BOM_Globals.get_debug = 'Y'
3622    Then
3623      error_handler.write_debug('After check entity..');
3624 END IF;
3625 
3626 
3627         -- Process Flow step 13 : Database Writes
3628 IF BOM_Globals.get_debug = 'Y'
3629    Then
3630      error_handler.write_debug('Before write to db..');
3631 END IF;
3632 
3633         IF g_control_rec.write_to_db
3634         THEN
3635                 eng_globals.set_user_id(p_user_id => g_control_rec.last_updated_by);
3636                 eng_globals.set_login_id(p_login_id => g_control_rec.last_update_login);
3637 
3638 IF BOM_Globals.get_debug = 'Y'
3639    Then
3640      error_handler.write_debug('write_to db is true');
3641 END IF;
3642 
3643 
3644                 --dbms_output.put_line('Writing to the database');
3645                 ENG_ECO_Util.Perform_Writes
3646                 (   p_ECO_rec          => l_ECO_rec
3647                 ,   p_Unexp_ECO_rec    => l_ECO_unexp_rec
3648                 ,   p_old_ECO_rec      => l_old_ECO_rec
3649                 ,   p_control_rec      => g_control_rec
3650                 ,   x_Mesg_Token_Tbl   => l_Mesg_Token_Tbl
3651                 ,   x_return_status    => l_return_status
3652                 );
3653 IF BOM_Globals.get_debug = 'Y'
3654    Then
3655      error_handler.write_debug('After write to db..');
3656 END IF;
3657 
3658 
3659                 IF l_return_status = Error_Handler.G_STATUS_UNEXPECTED
3660                 THEN
3661                         RAISE EXC_UNEXP_SKIP_OBJECT;
3662                 ELSIF l_return_status ='S' AND
3663                       l_Mesg_Token_Tbl.COUNT <>0
3664                 THEN
3665                         Eco_Error_Handler.Log_Error
3666                         (  p_ECO_rec            => l_ECO_rec
3667                         ,  p_eco_revision_tbl   => l_eco_revision_tbl
3668                         ,  p_revised_item_tbl   => l_revised_item_tbl
3669                         ,  p_rev_component_tbl  => l_rev_component_tbl
3670                         ,  p_ref_designator_tbl => l_ref_designator_tbl
3671                         ,  p_sub_component_tbl  => l_sub_component_tbl
3672                         ,  p_rev_operation_tbl    => l_rev_operation_tbl    --add
3673                         ,  p_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
3674                         ,  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
3675                         ,  p_mesg_token_tbl     => l_mesg_token_tbl
3676                         ,  p_error_status       => 'W'
3677                         ,  p_error_level        => 1
3678                         ,  x_ECO_rec            => l_ECO_rec
3679                         ,  x_eco_revision_tbl   => l_eco_revision_tbl
3680                         ,  x_revised_item_tbl   => l_revised_item_tbl
3681                         ,  x_rev_component_tbl  => l_rev_component_tbl
3682                         ,  x_ref_designator_tbl => l_ref_designator_tbl
3683                         ,  x_sub_component_tbl  => l_sub_component_tbl
3684                         ,  x_rev_operation_tbl    => l_rev_operation_tbl    --add
3685                         ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
3686                         ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
3687                         );
3688                 END IF;
3689         END IF;
3690 
3691   EXCEPTION
3692 
3693     WHEN EXC_SEV_QUIT_RECORD THEN
3694 
3695         Eco_Error_Handler.Log_Error
3696                 (  p_ECO_rec              => l_ECO_rec
3697                 ,  p_eco_revision_tbl     => l_eco_revision_tbl
3698                 ,  p_revised_item_tbl     => l_revised_item_tbl
3699                 ,  p_rev_component_tbl    => l_rev_component_tbl
3700                 ,  p_ref_designator_tbl   => l_ref_designator_tbl
3701                 ,  p_sub_component_tbl    => l_sub_component_tbl
3702                 ,  p_rev_operation_tbl    => l_rev_operation_tbl    --add
3703                 ,  p_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
3704                 ,  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
3705                 ,  p_mesg_token_tbl       => l_mesg_token_tbl
3706                 ,  p_error_status         => FND_API.G_RET_STS_ERROR
3707                 ,  p_error_scope          => Error_Handler.G_SCOPE_RECORD
3708                 ,  p_error_level          => 1
3709                 ,  x_ECO_rec              => l_ECO_rec
3710                 ,  x_eco_revision_tbl     => l_eco_revision_tbl
3711                 ,  x_revised_item_tbl     => l_revised_item_tbl
3712                 ,  x_rev_component_tbl    => l_rev_component_tbl
3713                 ,  x_ref_designator_tbl   => l_ref_designator_tbl
3714                 ,  x_sub_component_tbl    => l_sub_component_tbl
3715                 ,  x_rev_operation_tbl    => l_rev_operation_tbl    --add
3716                 ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
3717                 ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
3718                 );
3719 --dbms_output.put_line('logged error: ' || l_return_Status);
3720         x_return_status                := l_return_status;
3721         x_Mesg_Token_Tbl               := l_Mesg_Token_Tbl;
3722         x_ECO_rec                      := l_ECO_rec;
3723         x_unexp_ECO_rec                := l_eco_unexp_Rec;
3724         x_eco_revision_tbl             := l_eco_revision_tbl;
3725         x_revised_item_tbl             := l_revised_item_tbl;
3726         x_rev_component_tbl            := l_rev_component_tbl;
3727         x_ref_designator_tbl           := l_ref_designator_tbl;
3728         x_sub_component_tbl            := l_sub_component_tbl;
3729         x_rev_operation_tbl            := l_rev_operation_tbl;    --add
3730         x_rev_op_resource_tbl          := l_rev_op_resource_tbl;  --add
3731         x_rev_sub_resource_tbl         := l_rev_sub_resource_tbl; --add
3732 
3733         RETURN;
3734 
3735     WHEN EXC_UNEXP_SKIP_OBJECT THEN
3736        Eco_Error_Handler.Log_Error
3737                 (  p_ECO_rec            => l_ECO_rec
3738                 ,  p_eco_revision_tbl   => l_eco_revision_tbl
3739                 ,  p_revised_item_tbl   => l_revised_item_tbl
3740                 ,  p_rev_component_tbl  => l_rev_component_tbl
3741                 ,  p_ref_designator_tbl => l_ref_designator_tbl
3742                 ,  p_sub_component_tbl  => l_sub_component_tbl
3743                 ,  p_rev_operation_tbl    => l_rev_operation_tbl    --add
3744                 ,  p_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
3745                 ,  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
3746                 ,  p_mesg_token_tbl     => l_mesg_token_tbl
3747                 ,  p_error_status       => Error_Handler.G_STATUS_UNEXPECTED
3748                 ,  p_other_status       => Error_Handler.G_STATUS_NOT_PICKED
3749                 ,  p_other_message      => l_other_message
3750                 ,  p_other_token_tbl    => l_other_token_tbl
3751                 ,  p_error_level        => 1
3752                 ,  x_ECO_rec            => l_ECO_rec
3753                 ,  x_eco_revision_tbl   => l_eco_revision_tbl
3754                 ,  x_revised_item_tbl   => l_revised_item_tbl
3755                 ,  x_rev_component_tbl  => l_rev_component_tbl
3756                 ,  x_ref_designator_tbl => l_ref_designator_tbl
3757                 ,  x_sub_component_tbl  => l_sub_component_tbl
3758                 ,  x_rev_operation_tbl    => l_rev_operation_tbl    --add
3759                 ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl  --add
3760                 ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl --add
3761                 );
3762 
3763         x_return_status                := l_return_status;
3764         x_Mesg_Token_Tbl               := l_Mesg_Token_Tbl;
3765         x_ECO_rec                      := l_ECO_rec;
3766         x_unexp_ECO_rec                := l_eco_unexp_Rec;
3767         x_eco_revision_tbl             := l_eco_revision_tbl;
3768         x_revised_item_tbl             := l_revised_item_tbl;
3769         x_rev_component_tbl            := l_rev_component_tbl;
3770         x_ref_designator_tbl           := l_ref_designator_tbl;
3771         x_sub_component_tbl            := l_sub_component_tbl;
3772         x_rev_operation_tbl            := l_rev_operation_tbl;    --add
3773         x_rev_op_resource_tbl          := l_rev_op_resource_tbl;  --add
3774         x_rev_sub_resource_tbl         := l_rev_sub_resource_tbl; --add
3775 
3776         l_return_status := 'U';
3777 
3778         IF g_control_rec.write_to_db
3779         THEN
3780                 RAISE;
3781         END IF;
3782 
3783   END; -- END Header processing block
3784 
3785     IF l_return_status in ('Q', 'U')
3786     THEN
3787         x_return_status := l_return_status;
3788         x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
3789         RETURN;
3790     END IF;
3791 
3792     l_bo_return_status := l_return_status;
3793 
3794 
3795      --  Load OUT parameters
3796 
3797      x_return_status            := l_bo_return_status;
3798      x_ECO_rec                  := l_ECO_rec;
3799      x_unexp_ECO_rec            := l_eco_unexp_Rec;
3800      x_eco_revision_tbl         := l_eco_revision_tbl;
3801      x_revised_item_tbl         := l_revised_item_tbl;
3802      x_rev_component_tbl        := l_rev_component_tbl;
3803      x_ref_designator_tbl       := l_ref_designator_tbl;
3804      x_sub_component_tbl        := l_sub_component_tbl;
3805      x_rev_operation_tbl        := l_rev_operation_tbl;    --add
3806      x_rev_op_resource_tbl      := l_rev_op_resource_tbl;  --add
3807      x_rev_sub_resource_tbl     := l_rev_sub_resource_tbl; --add
3808      x_Mesg_Token_Tbl           := l_Mesg_Token_Tbl;
3809 
3810 END Eco_Header;
3811 
3812 
3813 --  Start of Comments
3814 --  API name    Process_Eco
3815 --  Type        Private
3816 --  Function
3817 --
3818 --  Pre-reqs
3819 --
3820 --  Parameters
3821 --
3822 --  Version     Current version = 1.0
3823 --              Initial version = 1.0
3824 --
3825 --  Notes
3826 --        11-SEP-2000 Modified by Masahiko Mochizuki
3827 --  End of Comments
3828 
3829 PROCEDURE Process_Eco
3830 (   x_return_status                 IN OUT NOCOPY VARCHAR2
3831 ,   x_msg_count                     IN OUT NOCOPY NUMBER
3832 ,   p_control_rec                   IN  BOM_BO_PUB.Control_Rec_Type
3833 ,   p_ECO_rec                       IN  ENG_Eco_PUB.Eco_Rec_Type :=
3834                                         ENG_Eco_PUB.G_MISS_ECO_REC
3835 ,   p_unexp_eco_rec                 IN  ENG_Eco_PUB.ECO_Unexposed_Rec_Type := NULL
3836 ,   p_unexp_rev_item_rec            IN  ENG_Eco_PUB.Rev_Item_Unexposed_Rec_Type := NULL
3837 ,   p_unexp_rev_comp_rec            IN  BOM_BO_PUB.Rev_Comp_Unexposed_Rec_Type := NULL
3838 ,   p_unexp_eco_rev_rec             IN  ENG_Eco_PUB.Eco_Rev_Unexposed_Rec_Type := NULL
3839 ,   p_unexp_sub_comp_rec            IN  BOM_BO_PUB.Sub_Comp_Unexposed_Rec_Type := NULL
3840 ,   p_unexp_ref_desg_rec            IN  BOM_BO_PUB.Ref_Desg_Unexposed_Rec_Type := NULL
3841 ,   p_unexp_rev_op_rec              IN  BOM_RTG_PUB.Rev_Op_Unexposed_Rec_Type := NULL
3842 ,   p_unexp_rev_op_res_rec          IN  BOM_RTG_PUB.Rev_Op_Res_Unexposed_Rec_Type := NULL
3843 ,   p_unexp_rev_sub_res_rec         IN  BOM_RTG_PUB.Rev_Sub_Res_Unexposed_Rec_Type := NULL
3844 ,   p_eco_revision_tbl              IN  ENG_Eco_PUB.Eco_Revision_Tbl_Type :=
3845                                         ENG_Eco_PUB.G_MISS_ECO_REVISION_TBL
3846 ,   p_revised_item_tbl              IN  ENG_Eco_PUB.Revised_Item_Tbl_Type :=
3847                                         ENG_Eco_PUB.G_MISS_REVISED_ITEM_TBL
3848 ,   p_rev_component_tbl             IN  BOM_BO_PUB.Rev_Component_Tbl_Type :=
3849                                         BOM_BO_PUB.G_MISS_REV_COMPONENT_TBL
3850 ,   p_ref_designator_tbl            IN  BOM_BO_PUB.Ref_Designator_Tbl_Type :=
3851                                         BOM_BO_PUB.G_MISS_REF_DESIGNATOR_TBL
3852 ,   p_sub_component_tbl             IN  BOM_BO_PUB.Sub_Component_Tbl_Type :=
3853                                         BOM_BO_PUB.G_MISS_SUB_COMPONENT_TBL
3854 ,   p_rev_operation_tbl             IN  BOM_RTG_PUB.Rev_Operation_Tbl_Type:=
3855                                         BOM_RTG_PUB.G_MISS_REV_OPERATION_TBL
3856 ,   p_rev_op_resource_tbl           IN  BOM_RTG_PUB.Rev_Op_Resource_Tbl_Type :=
3857                                         BOM_RTG_PUB.G_MISS_REV_OP_RESOURCE_TBL
3858 ,   p_rev_sub_resource_tbl          IN  BOM_RTG_PUB.Rev_Sub_Resource_Tbl_Type:=
3859                                         BOM_RTG_PUB.G_MISS_REV_SUB_RESOURCE_TBL
3860 ,   x_ECO_rec                       IN OUT NOCOPY ENG_Eco_PUB.Eco_Rec_Type --ECO 10dec
3861 ,   x_unexp_ECO_rec                 IN OUT NOCOPY ENG_Eco_PUB.ECO_Unexposed_Rec_Type
3862 ,   x_unexp_eco_rev_rec             IN OUT NOCOPY ENG_Eco_PUB.Eco_Rev_Unexposed_Rec_Type
3863 ,   x_unexp_revised_item_rec        IN OUT NOCOPY ENG_Eco_PUB.Rev_Item_Unexposed_Rec_Type
3864 ,   x_unexp_rev_comp_rec            IN OUT NOCOPY BOM_BO_PUB.Rev_Comp_Unexposed_Rec_Type
3865 ,   x_unexp_sub_comp_rec            IN OUT NOCOPY BOM_BO_PUB.Sub_Comp_Unexposed_Rec_Type
3866 ,   x_unexp_ref_desg_rec            IN OUT NOCOPY BOM_BO_PUB.Ref_Desg_Unexposed_Rec_Type
3867 ,   x_unexp_rev_op_rec              IN OUT NOCOPY BOM_RTG_PUB.Rev_Op_Unexposed_Rec_Type
3868 ,   x_unexp_rev_op_res_rec          IN OUT NOCOPY BOM_RTG_PUB.Rev_Op_Res_Unexposed_Rec_Type
3869 ,   x_unexp_rev_sub_res_rec         IN OUT NOCOPY BOM_RTG_PUB.Rev_Sub_Res_Unexposed_Rec_Type
3870 ,   x_eco_revision_tbl              IN OUT NOCOPY ENG_Eco_PUB.Eco_Revision_Tbl_Type
3871 ,   x_revised_item_tbl              IN OUT NOCOPY ENG_Eco_PUB.Revised_Item_Tbl_Type
3872 ,   x_rev_component_tbl             IN OUT NOCOPY BOM_BO_PUB.Rev_Component_Tbl_Type
3873 ,   x_ref_designator_tbl            IN OUT NOCOPY BOM_BO_PUB.Ref_Designator_Tbl_Type
3874 ,   x_sub_component_tbl             IN OUT NOCOPY BOM_BO_PUB.Sub_Component_Tbl_Type
3875 ,   x_rev_operation_tbl             IN OUT NOCOPY BOM_RTG_PUB.Rev_Operation_Tbl_Type
3876 ,   x_rev_op_resource_tbl           IN OUT NOCOPY BOM_RTG_PUB.Rev_Op_Resource_Tbl_Type
3877 ,   x_rev_sub_resource_tbl          IN OUT NOCOPY BOM_RTG_PUB.Rev_Sub_Resource_Tbl_Type
3878 ,   x_disable_revision              OUT NOCOPY NUMBER --Bug no:3034642
3879 )
3880 IS
3881 l_api_name                    CONSTANT VARCHAR2(30):= 'Process_Eco';
3882 l_err_text                    VARCHAR2(240);
3883 l_return_status               VARCHAR2(1);
3884 l_bo_return_status            VARCHAR2(1);
3885 
3886 l_control_rec                 BOM_BO_PUB.Control_Rec_Type;
3887 
3888 l_ECO_rec                     ENG_Eco_PUB.Eco_Rec_Type := p_ECO_rec;
3889 l_unexp_eco_rec               ENG_Eco_PUB.ECO_Unexposed_Rec_Type := p_unexp_eco_rec;
3890 l_eco_revision_rec            ENG_Eco_PUB.Eco_Revision_Rec_Type;
3891 l_eco_revision_tbl            ENG_Eco_PUB.Eco_Revision_Tbl_Type;
3892 l_revised_item_rec            ENG_Eco_PUB.Revised_Item_Rec_Type;
3893 l_revised_item_tbl            ENG_Eco_PUB.Revised_Item_Tbl_Type;
3894 l_rev_component_rec           BOM_BO_PUB.Rev_Component_Rec_Type;
3895 l_rev_component_tbl           BOM_BO_PUB.Rev_Component_Tbl_Type;
3896 l_ref_designator_rec          BOM_BO_PUB.Ref_Designator_Rec_Type;
3897 l_ref_designator_tbl          BOM_BO_PUB.Ref_Designator_Tbl_Type;
3898 l_sub_component_rec           BOM_BO_PUB.Sub_Component_Rec_Type;
3899 l_sub_component_tbl           BOM_BO_PUB.Sub_Component_Tbl_Type;
3900 l_rev_operation_tbl           BOM_RTG_PUB.Rev_Operation_Tbl_Type;     --add
3901 l_rev_op_resource_tbl         BOM_RTG_PUB.Rev_Op_Resource_Tbl_Type;   --add
3902 l_rev_sub_resource_tbl        BOM_RTG_PUB.Rev_Sub_Resource_Tbl_Type;  --add
3903 l_rev_operation_rec           BOM_RTG_PUB.Rev_Operation_Rec_Type;     --add
3904 l_rev_op_resource_rec         BOM_RTG_PUB.Rev_Op_Resource_Rec_Type;   --add
3905 l_rev_sub_resource_rec        BOM_RTG_PUB.Rev_Sub_Resource_Rec_Type;  --add
3906 
3907 l_mesg_token_tbl              Error_Handler.Mesg_Token_Tbl_Type;
3908 l_other_message               VARCHAR2(2000);
3909 l_other_token_tbl             Error_Handler.Token_Tbl_Type;
3910 
3911 EXC_ERR_PVT_API_MAIN          EXCEPTION;
3912 
3913 BEGIN
3914 
3915     --dbms_output.enable(1000000);
3916 
3917     --  Standard call to check for call compatibility
3918 
3919    IF BOM_Globals.get_debug = 'Y'
3920    Then
3921      error_handler.write_debug('here, for test purpose, you can write message.');
3922    END IF;
3923 
3924     --dbms_output.put_line('The following objects will be processed as part of the same business object');
3925     --dbms_output.put_line('| ECO : ' || l_ECO_rec.eco_name);
3926     --dbms_output.put_line('| ECO REVISIONS : ' || to_char(p_eco_revision_tbl.COUNT));
3927     --dbms_output.put_line('| REVISED ITEMS : ' || to_char(p_revised_item_tbl.COUNT));
3928     --dbms_output.put_line('| REVISED COMPS : ' || to_char(p_rev_component_tbl.COUNT));
3929     --dbms_output.put_line('| SUBS. COMPS   : ' || to_Char(p_sub_component_tbl.COUNT));
3930     --dbms_output.put_line('| REFD. DESGS         : ' || to_char(p_ref_designator_tbl.COUNT));
3931     --dbms_output.put_line('|----------------------------------------------------');
3932 
3933     --dbms_output.put_line('Assigning control record to global variable');
3934 
3935   -- Init Global variables.
3936     g_control_rec := p_control_rec;
3937 
3938     bom_globals.set_user_id(p_user_id => g_control_rec.last_updated_by);
3939     bom_rtg_globals.set_user_id(p_user_id => g_control_rec.last_updated_by);
3940     bom_globals.set_login_id(p_login_id => g_control_rec.last_update_login);
3941     bom_rtg_globals.set_login_id(p_login_id => g_control_rec.last_update_login);
3942 
3943    -- bug 3583789 ,Bo_Identifier needs to be set for all the errors/warnings to be shown in the form --vani
3944     Eng_Globals.Set_Bo_Identifier(p_bo_identifier       => 'ECO');
3945 
3946     --  Init local variables
3947 
3948     l_ECO_rec                      := p_ECO_rec;
3949 
3950     --  Init local table variables.
3951 
3952     l_eco_revision_tbl             := p_eco_revision_tbl;
3953     l_revised_item_tbl             := p_revised_item_tbl;
3954     l_rev_component_tbl            := p_rev_component_tbl;
3955     l_ref_designator_tbl           := p_ref_designator_tbl;
3956     l_sub_component_tbl            := p_sub_component_tbl;
3957     l_rev_operation_tbl                 := p_rev_operation_tbl;         --add
3958     l_rev_op_resource_tbl              := p_rev_op_resource_tbl;        --add
3959     l_rev_sub_resource_tbl            := p_rev_sub_resource_tbl;        --add
3960 
3961     -- Initialize System_Information Unit_Effectivity flag
3962 
3963     IF PJM_UNIT_EFF.ENABLED = 'Y'
3964     THEN
3965         ENG_Globals.Set_Unit_Effectivity (TRUE);
3966     ELSE
3967         ENG_Globals.Set_Unit_Effectivity (FALSE);
3968     END IF;
3969 
3970 --  Added by AS on 03/17/99 to fix bug 852322
3971     l_bo_return_status := 'S';
3972 
3973     --  Eco
3974 
3975 /*   Bom_Globals.Set_Debug('Y');
3976     Error_Handler.Open_Debug_Session
3977 	(p_debug_filename	=> 'form_debug.log'
3978          , p_output_dir		=> '/sqlcom/log/dom1151'
3979          , x_return_status	=> l_return_status
3980          , p_mesg_token_tbl	=> l_mesg_token_tbl
3981          , x_mesg_Token_tbl	=> l_mesg_token_tbl
3982 	);
3983 */
3984 
3985 IF BOM_Globals.get_debug = 'Y'
3986    Then
3987      error_handler.write_debug('here, for test purpose, you can write message.');
3988    END IF;
3989 
3990     IF  g_control_rec.process_entity = ENG_GLOBALS.G_ENTITY_ECO
3991     THEN
3992         --dbms_output.put_line('PVT API: Calling ECO_Header');
3993 
3994         Eco_Header
3995         (   p_ECO_rec                   => l_ECO_rec
3996         ,   p_unexp_eco_rec             => l_unexp_eco_rec
3997         ,   p_eco_revision_tbl          => l_eco_revision_tbl
3998         ,   p_revised_item_tbl          => l_revised_item_tbl
3999         ,   p_rev_component_tbl         => l_rev_component_tbl
4000         ,   p_ref_designator_tbl        => l_ref_designator_tbl
4001         ,   p_sub_component_tbl         => l_sub_component_tbl
4002         ,   p_rev_operation_tbl         => l_rev_operation_tbl        --add
4003         ,   p_rev_op_resource_tbl       => l_rev_op_resource_tbl      --add
4004         ,   p_rev_sub_resource_tbl      => l_rev_sub_resource_tbl     --add
4005         ,   x_ECO_rec                   => l_ECO_rec
4006         ,   x_unexp_eco_rec             => x_unexp_eco_rec
4007         ,   x_eco_revision_tbl          => l_eco_revision_tbl
4008         ,   x_revised_item_tbl          => l_revised_item_tbl
4009         ,   x_rev_component_tbl         => l_rev_component_tbl
4010         ,   x_ref_designator_tbl        => l_ref_designator_tbl
4011         ,   x_sub_component_tbl         => l_sub_component_tbl
4012         ,   x_rev_operation_tbl         => l_rev_operation_tbl         --add
4013         ,   x_rev_op_resource_tbl       => l_rev_op_resource_tbl       --add
4014         ,   x_rev_sub_resource_tbl      => l_rev_sub_resource_tbl      --add
4015         ,   x_Mesg_Token_Tbl            => l_Mesg_Token_Tbl
4016         ,   x_return_status             => l_return_status       );
4017 
4018         --dbms_output.put_line('eco hdr return status: ' || l_eco_rec.return_status);
4019 
4020         -- Added by AS on 03/22/99 to fix bug 853529
4021 
4022         IF NVL(l_return_status, 'S') = 'Q'
4023         THEN
4024                 l_return_status := 'F';
4025                 RAISE G_EXC_QUIT_IMPORT;
4026         ELSIF NVL(l_return_status, 'S') = 'U'
4027         THEN
4028                 RAISE G_EXC_QUIT_IMPORT;
4029 
4030         --  Added by AS on 03/17/99 to fix bug 852322
4031         ELSIF NVL(l_return_status, 'S') <> 'S'
4032         THEN
4033                 l_bo_return_status := l_return_status;
4034         END IF;
4035 
4036    END IF;
4037 
4038 IF BOM_Globals.get_debug = 'Y'
4039    Then
4040      error_handler.write_debug('end of ECO header in Process_ECO..');
4041      error_handler.write_debug('here, the process entity is:');
4042      error_handler.write_debug( g_control_rec.process_entity);
4043      error_handler.write_debug( ENG_GLOBALS.G_ENTITY_ECO);
4044 
4045 
4046 END IF;
4047 
4048 --error_Handler.Close_Debug_Session;
4049 
4050 
4051    --dbms_output.put_line('BO error status: ' || l_bo_return_status);
4052 
4053     --  Eco
4054 
4055     IF  g_control_rec.process_entity = ENG_GLOBALS.G_ENTITY_ECO_REVISION
4056     THEN
4057         --dbms_output.put_line('PVT API: Calling ECO_Header');
4058 
4059         Eco_Rev
4060         (   p_eco_revision_tbl          => l_eco_revision_tbl
4061         ,   p_unexp_eco_rev_rec         => p_unexp_eco_rev_rec
4062         ,   p_revised_item_tbl          => l_revised_item_tbl
4063         ,   p_rev_component_tbl         => l_rev_component_tbl
4064         ,   p_ref_designator_tbl        => l_ref_designator_tbl
4065         ,   p_sub_component_tbl         => l_sub_component_tbl
4066         ,   p_rev_operation_tbl         => l_rev_operation_tbl        --add
4067         ,   p_rev_op_resource_tbl       => l_rev_op_resource_tbl      --add
4068         ,   p_rev_sub_resource_tbl      => l_rev_sub_resource_tbl     --add
4069         ,   x_eco_rec                   => l_eco_rec
4070         ,   x_unexp_eco_rev_rec         => x_unexp_eco_rev_rec
4071         ,   x_eco_revision_tbl          => l_eco_revision_tbl
4072         ,   x_revised_item_tbl          => l_revised_item_tbl
4073         ,   x_rev_component_tbl         => l_rev_component_tbl
4074         ,   x_ref_designator_tbl        => l_ref_designator_tbl
4075         ,   x_sub_component_tbl         => l_sub_component_tbl
4076         ,   x_rev_operation_tbl         => l_rev_operation_tbl         --add
4077         ,   x_rev_op_resource_tbl       => l_rev_op_resource_tbl       --add
4078         ,   x_rev_sub_resource_tbl      => l_rev_sub_resource_tbl      --add
4079         ,   x_Mesg_Token_Tbl            => l_Mesg_Token_Tbl
4080         ,   x_return_status             => l_return_status
4081         );
4082 
4083         --dbms_output.put_line('eco revisions return status: ' || l_eco_revision_tbl(1).return_status);
4084 
4085         -- Added by AS on 03/22/99 to fix bug 853529
4086 
4087         IF NVL(l_return_status, 'S') = 'Q'
4088         THEN
4089                 l_return_status := 'F';
4090                 RAISE G_EXC_QUIT_IMPORT;
4091         ELSIF NVL(l_return_status, 'S') = 'U'
4092         THEN
4093                 RAISE G_EXC_QUIT_IMPORT;
4094 
4095         --  Added by AS on 03/17/99 to fix bug 852322
4096         ELSIF NVL(l_return_status, 'S') <> 'S'
4097         THEN
4098                 l_bo_return_status := l_return_status;
4099         END IF;
4100 
4101    END IF;
4102 
4103     --  Revised Items
4104 
4105     IF  g_control_rec.process_entity = ENG_GLOBALS.G_ENTITY_REVISED_ITEM
4106     THEN
4107         --dbms_output.put_line('PVT API: Calling Rev_Items');
4108 
4109         Rev_Items
4110         (   p_revised_item_tbl          => l_revised_item_tbl
4111         ,   p_unexp_rev_item_rec        => p_unexp_rev_item_rec
4112         ,   p_rev_component_tbl         => l_rev_component_tbl
4113         ,   p_ref_designator_tbl        => l_ref_designator_tbl
4114         ,   p_sub_component_tbl         => l_sub_component_tbl
4115         ,   p_rev_operation_tbl         => l_rev_operation_tbl        --add
4116         ,   p_rev_op_resource_tbl       => l_rev_op_resource_tbl      --add
4117         ,   p_rev_sub_resource_tbl      => l_rev_sub_resource_tbl     --add
4118         ,   x_ECO_rec                   => l_ECO_rec
4119         ,   x_unexp_rev_item_rec        => x_unexp_revised_item_rec
4120         ,   x_eco_revision_tbl          => l_eco_revision_tbl
4121         ,   x_revised_item_tbl          => l_revised_item_tbl
4122         ,   x_rev_component_tbl         => l_rev_component_tbl
4123         ,   x_ref_designator_tbl        => l_ref_designator_tbl
4124         ,   x_sub_component_tbl         => l_sub_component_tbl
4125         ,   x_rev_operation_tbl         => l_rev_operation_tbl         --add
4126         ,   x_rev_op_resource_tbl       => l_rev_op_resource_tbl       --add
4127         ,   x_rev_sub_resource_tbl      => l_rev_sub_resource_tbl      --add
4128         ,   x_Mesg_Token_Tbl            => l_Mesg_Token_Tbl
4129         ,   x_return_status             => l_return_status
4130 	,   x_disable_revision          =>  x_disable_revision  --Bug no:3034642
4131         ) ;
4132 
4133 IF BOM_Globals.get_debug = 'Y'
4134    Then
4135      error_handler.write_debug('after rev_items, the return status is');
4136      error_handler.write_debug(l_return_status);
4137    END IF;
4138 
4139         --dbms_output.put_line('rev items return status: ' || l_revised_item_tbl(1).return_status);
4140 
4141         -- Added by AS on 03/22/99 to fix bug 853529
4142 
4143         IF NVL(l_return_status, 'S') = 'Q'
4144         THEN
4145                 l_return_status := 'F';
4146                 RAISE G_EXC_QUIT_IMPORT;
4147         ELSIF NVL(l_return_status, 'S') = 'U'
4148         THEN
4149                 RAISE G_EXC_QUIT_IMPORT;
4150 
4151         --  Added by AS on 03/17/99 to fix bug 852322
4152         ELSIF NVL(l_return_status, 'S') <> 'S'
4153         THEN
4154                 l_bo_return_status := l_return_status;
4155         END IF;
4156 
4157    END IF;
4158 
4159    --dbms_output.put_line('BO error status: ' || l_bo_return_status);
4160 
4161     --  Revised Components
4162 
4163     IF  g_control_rec.process_entity = ENG_GLOBALS.G_ENTITY_REV_COMPONENT
4164     THEN
4165         --dbms_output.put_line('PVT API: Calling Rev_Comps');
4166 
4167         Rev_Comps
4168         (   p_rev_component_tbl         => l_rev_component_tbl
4169         ,   p_unexp_rev_comp_rec        => p_unexp_rev_comp_rec
4170         ,   p_ref_designator_tbl        => l_ref_designator_tbl
4171         ,   p_sub_component_tbl         => l_sub_component_tbl
4172         ,   x_ECO_rec                   => l_ECO_rec
4173         ,   x_unexp_rev_comp_rec        => x_unexp_rev_comp_rec
4174         ,   x_eco_revision_tbl          => l_eco_revision_tbl
4175         ,   x_revised_item_tbl          => l_revised_item_tbl
4176         ,   x_rev_component_tbl         => l_rev_component_tbl
4177         ,   x_ref_designator_tbl        => l_ref_designator_tbl
4178         ,   x_sub_component_tbl         => l_sub_component_tbl
4179         ,   x_rev_operation_tbl         => l_rev_operation_tbl         --add
4180         ,   x_rev_op_resource_tbl       => l_rev_op_resource_tbl       --add
4181         ,   x_rev_sub_resource_tbl      => l_rev_sub_resource_tbl      --add
4182         ,   x_Mesg_Token_Tbl            => l_Mesg_Token_Tbl
4183         ,   x_return_status             => l_return_status
4184         ) ;
4185 
4186         --dbms_output.put_line('rev comps return status: ' || l_return_status);
4187 --dbms_output.put_line('main item num: ' || to_char(l_rev_component_tbl(1).item_sequence_number));
4188         -- Added by AS on 03/22/99 to fix bug 853529
4189 
4190         IF NVL(l_return_status, 'S') = 'Q'
4191         THEN
4192                 l_return_status := 'F';
4193                 RAISE G_EXC_QUIT_IMPORT;
4194         ELSIF NVL(l_return_status, 'S') = 'U'
4195         THEN
4196                 RAISE G_EXC_QUIT_IMPORT;
4197 
4198         --  Added by AS on 03/17/99 to fix bug 852322
4199         ELSIF NVL(l_return_status, 'S') <> 'S'
4200         THEN
4201                 l_bo_return_status := l_return_status;
4202         END IF;
4203 
4204    END IF;
4205 
4206    --dbms_output.put_line('BO error status: ' || l_bo_return_status);
4207 
4208     --  Reference Designators
4209 
4210     IF  g_control_rec.process_entity = ENG_GLOBALS.G_ENTITY_REF_DESIGNATOR
4211     THEN
4212         --dbms_output.put_line('PVT API: Calling Sub_Comps');
4213 
4214         Ref_Desgs
4215         (   p_unexp_ref_desg_rec        => p_unexp_ref_desg_rec
4216         ,   p_ref_designator_tbl        => l_ref_designator_tbl
4217         ,   p_sub_component_tbl         => l_sub_component_tbl
4218         ,   x_ECO_rec                   => l_ECO_rec
4219         ,   x_unexp_ref_desg_rec        => x_unexp_ref_desg_rec
4220         ,   x_eco_revision_tbl          => l_eco_revision_tbl
4221         ,   x_revised_item_tbl          => l_revised_item_tbl
4222         ,   x_rev_component_tbl         => l_rev_component_tbl
4223         ,   x_ref_designator_tbl        => l_ref_designator_tbl
4224         ,   x_sub_component_tbl         => l_sub_component_tbl
4225         ,   x_rev_operation_tbl         => l_rev_operation_tbl         --add
4226         ,   x_rev_op_resource_tbl       => l_rev_op_resource_tbl       --add
4227         ,   x_rev_sub_resource_tbl      => l_rev_sub_resource_tbl      --add
4228         ,   x_Mesg_Token_Tbl            => l_Mesg_Token_Tbl
4229         ,   x_return_status             => l_return_status
4230         ) ;
4231 
4232         --dbms_output.put_line('ref desgs return status: ' || l_ref_designator_tbl(1).return_status);
4233 
4234         -- Added by AS on 03/22/99 to fix bug 853529
4235 
4236         IF NVL(l_return_status, 'S') = 'Q'
4237         THEN
4238                 l_return_status := 'F';
4239                 RAISE G_EXC_QUIT_IMPORT;
4240         ELSIF NVL(l_return_status, 'S') = 'U'
4241         THEN
4242                 RAISE G_EXC_QUIT_IMPORT;
4243 
4244         --  Added by AS on 03/17/99 to fix bug 852322
4245         ELSIF NVL(l_return_status, 'S') <> 'S'
4246         THEN
4247                 l_bo_return_status := l_return_status;
4248         END IF;
4249 
4250    END IF;
4251 
4252    --dbms_output.put_line('BO error status: ' || l_bo_return_status);
4253 
4254     --  Substitute Components
4255 
4256     IF  g_control_rec.process_entity = ENG_GLOBALS.G_ENTITY_SUB_COMPONENT
4257     THEN
4258         --dbms_output.put_line('PVT API: Calling Sub_Comps');
4259 
4260         Sub_Comps
4261         (   p_unexp_sub_comp_rec        => p_unexp_sub_comp_rec
4262         ,   p_ref_designator_tbl        => l_ref_designator_tbl
4263         ,   p_sub_component_tbl         => l_sub_component_tbl
4264         ,   x_ECO_rec                   => l_ECO_rec
4265         ,   x_unexp_sub_comp_rec        => x_unexp_sub_comp_rec
4266         ,   x_eco_revision_tbl          => l_eco_revision_tbl
4267         ,   x_revised_item_tbl          => l_revised_item_tbl
4268         ,   x_rev_component_tbl         => l_rev_component_tbl
4269         ,   x_ref_designator_tbl        => l_ref_designator_tbl
4270         ,   x_sub_component_tbl         => l_sub_component_tbl
4271         ,   x_rev_operation_tbl         => l_rev_operation_tbl         --add
4272         ,   x_rev_op_resource_tbl       => l_rev_op_resource_tbl       --add
4273         ,   x_rev_sub_resource_tbl      => l_rev_sub_resource_tbl      --add
4274         ,   x_Mesg_Token_Tbl            => l_Mesg_Token_Tbl
4275         ,   x_return_status             => l_return_status
4276         ) ;
4277 
4278         --dbms_output.put_line('sub comps return status: ' || l_sub_component_tbl(1).return_status);
4279 
4280         -- Added by AS on 03/22/99 to fix bug 853529
4281 
4282         IF NVL(l_return_status, 'S') = 'Q'
4283         THEN
4284                 l_return_status := 'F';
4285                 RAISE G_EXC_QUIT_IMPORT;
4286         ELSIF NVL(l_return_status, 'S') = 'U'
4287         THEN
4288                 RAISE G_EXC_QUIT_IMPORT;
4289 
4290         --  Added by AS on 03/17/99 to fix bug 852322
4291         ELSIF NVL(l_return_status, 'S') <> 'S'
4292         THEN
4293                 l_bo_return_status := l_return_status;
4294         END IF;
4295 
4296    END IF;
4297 
4298    --dbms_output.put_line('BO error status: ' || l_bo_return_status);
4299 
4300 -- Added by Masahiko Mochizuki on 09/11/00
4301 
4302     --  Revised Operations
4303 
4304     IF  g_control_rec.process_entity = ENG_GLOBALS.G_ENTITY_REV_OPERATION
4305     THEN
4306         --dbms_output.put_line('PVT API: Calling Rev_Ops');
4307 
4308 
4309        Rev_Ops
4310         (   p_rev_operation_tbl         => l_rev_operation_tbl
4311         ,   p_unexp_rev_op_rec          => p_unexp_rev_op_rec
4312         ,   p_rev_op_resource_tbl       => l_rev_op_resource_tbl
4313         ,   p_rev_sub_resource_tbl      => l_rev_sub_resource_tbl
4314         ,   x_ECO_rec                   => l_ECO_rec
4315         ,   x_unexp_rev_op_rec          => x_unexp_rev_op_rec
4316         ,   x_eco_revision_tbl          => l_eco_revision_tbl
4317         ,   x_revised_item_tbl          => l_revised_item_tbl
4318         ,   x_rev_component_tbl         => l_rev_component_tbl
4319         ,   x_ref_designator_tbl        => l_ref_designator_tbl
4320         ,   x_sub_component_tbl         => l_sub_component_tbl
4321         ,   x_rev_operation_tbl         => l_rev_operation_tbl
4322         ,   x_rev_op_resource_tbl       => l_rev_op_resource_tbl
4323         ,   x_rev_sub_resource_tbl      => l_rev_sub_resource_tbl
4324         ,   x_Mesg_Token_Tbl            => l_Mesg_Token_Tbl
4325         ,   x_return_status             => l_return_status
4326         ) ;
4327 
4328         IF NVL(l_return_status, 'S') = 'Q'
4329         THEN
4330                 l_return_status := 'F';
4331                 RAISE G_EXC_QUIT_IMPORT;
4332         ELSIF NVL(l_return_status, 'S') = 'U'
4333         THEN
4334                 RAISE G_EXC_QUIT_IMPORT;
4335 
4336         ELSIF NVL(l_return_status, 'S') <> 'S'
4337         THEN
4338                 l_bo_return_status := l_return_status;
4339         END IF;
4340 
4341    END IF;
4342 
4343    --dbms_output.put_line('BO error status: ' || l_bo_return_status);
4344 
4345 
4346 -- Added by Masahiko Mochizuki on 09/11/00
4347 
4348     --  Revised Operation Resources
4349 
4350     IF  g_control_rec.process_entity = ENG_GLOBALS.G_ENTITY_REV_OP_RESOURCE
4351     THEN
4352         --dbms_output.put_line('PVT API: Calling Rev_Op_Res');
4353 
4354 
4355        Rev_Op_Res
4356         (   p_rev_op_resource_tbl       => l_rev_op_resource_tbl
4357         ,   p_unexp_rev_op_res_rec      => p_unexp_rev_op_res_rec
4358         ,   p_rev_sub_resource_tbl      => l_rev_sub_resource_tbl
4359         ,   x_ECO_rec                   => l_ECO_rec
4360         ,   x_unexp_rev_op_res_rec      => x_unexp_rev_op_res_rec
4361         ,   x_eco_revision_tbl          => l_eco_revision_tbl
4362         ,   x_revised_item_tbl          => l_revised_item_tbl
4363         ,   x_rev_component_tbl         => l_rev_component_tbl
4364         ,   x_ref_designator_tbl        => l_ref_designator_tbl
4365         ,   x_sub_component_tbl         => l_sub_component_tbl
4366         ,   x_rev_operation_tbl         => l_rev_operation_tbl
4367         ,   x_rev_op_resource_tbl       => l_rev_op_resource_tbl
4368         ,   x_rev_sub_resource_tbl      => l_rev_sub_resource_tbl
4369         ,   x_Mesg_Token_Tbl            => l_Mesg_Token_Tbl
4370         ,   x_return_status             => l_return_status
4371         ) ;
4372 
4373         IF NVL(l_return_status, 'S') = 'Q'
4374         THEN
4375                 l_return_status := 'F';
4376                 RAISE G_EXC_QUIT_IMPORT;
4377         ELSIF NVL(l_return_status, 'S') = 'U'
4378         THEN
4379                 RAISE G_EXC_QUIT_IMPORT;
4380 
4381         ELSIF NVL(l_return_status, 'S') <> 'S'
4382         THEN
4383                 l_bo_return_status := l_return_status;
4384         END IF;
4385 
4386    END IF;
4387 
4388    --dbms_output.put_line('BO error status: ' || l_bo_return_status);
4389 
4390 
4391 -- Added by Masahiko Mochizuki on 09/11/00
4392 
4393     --  Revised Sub Operation Resources
4394 
4395     IF  g_control_rec.process_entity = ENG_GLOBALS.G_ENTITY_REV_SUB_RESOURCE
4396     THEN
4397         --dbms_output.put_line('PVT API: Calling Rev_Sub_Res');
4398 
4399 
4400        Rev_Sub_Res
4401         (   p_rev_op_resource_tbl       => l_rev_op_resource_tbl
4402         ,   p_unexp_rev_sub_res_rec     => p_unexp_rev_sub_res_rec
4403         ,   p_rev_sub_resource_tbl      => l_rev_sub_resource_tbl
4404         ,   x_ECO_rec                   => l_ECO_rec
4405         ,   x_unexp_rev_sub_res_rec     => x_unexp_rev_sub_res_rec
4406         ,   x_eco_revision_tbl          => l_eco_revision_tbl
4407         ,   x_revised_item_tbl          => l_revised_item_tbl
4408         ,   x_rev_component_tbl         => l_rev_component_tbl
4409         ,   x_ref_designator_tbl        => l_ref_designator_tbl
4410         ,   x_sub_component_tbl         => l_sub_component_tbl
4411         ,   x_rev_operation_tbl         => l_rev_operation_tbl
4412         ,   x_rev_op_resource_tbl       => l_rev_op_resource_tbl
4413         ,   x_rev_sub_resource_tbl      => l_rev_sub_resource_tbl
4414         ,   x_Mesg_Token_Tbl            => l_Mesg_Token_Tbl
4415         ,   x_return_status             => l_return_status
4416         ) ;
4417 
4418         IF NVL(l_return_status, 'S') = 'Q'
4419         THEN
4420                 l_return_status := 'F';
4421                 RAISE G_EXC_QUIT_IMPORT;
4422         ELSIF NVL(l_return_status, 'S') = 'U'
4423         THEN
4424                 RAISE G_EXC_QUIT_IMPORT;
4425 
4426         ELSIF NVL(l_return_status, 'S') <> 'S'
4427         THEN
4428                 l_bo_return_status := l_return_status;
4429         END IF;
4430 
4431    END IF;
4432 
4433    --dbms_output.put_line('BO error status: ' || l_bo_return_status);
4434 
4435 
4436     --  Done processing, load OUT parameters.
4437    --  Added by AS on 03/17/99 to fix bug 852322
4438     x_return_status                := l_bo_return_status;
4439 
4440     x_ECO_rec                      := l_ECO_rec;
4441     x_eco_revision_tbl             := l_eco_revision_tbl;
4442     x_revised_item_tbl             := l_revised_item_tbl;
4443     x_rev_component_tbl            := l_rev_component_tbl;
4444     x_ref_designator_tbl           := l_ref_designator_tbl;
4445     x_sub_component_tbl            := l_sub_component_tbl;
4446     x_rev_operation_tbl            := l_rev_operation_tbl;         --add
4447     x_rev_op_resource_tbl          := l_rev_op_resource_tbl;       --add
4448     x_rev_sub_resource_tbl         := l_rev_sub_resource_tbl;      --add
4449 
4450     -- Reset system_information business object flags
4451 
4452 IF BOM_Globals.get_debug = 'Y'
4453    Then
4454      error_handler.write_debug('before set global variables.');
4455    END IF;
4456 
4457     ENG_GLOBALS.Set_ECO_Impl( p_eco_impl        => NULL);
4458     ENG_GLOBALS.Set_ECO_Cancl( p_eco_cancl      => NULL);
4459     ENG_GLOBALS.Set_Wkfl_Process( p_wkfl_process=> NULL);
4460     ENG_GLOBALS.Set_ECO_Access( p_eco_access    => NULL);
4461     ENG_GLOBALS.Set_STD_Item_Access( p_std_item_access => NULL);
4462     ENG_GLOBALS.Set_MDL_Item_Access( p_mdl_item_access => NULL);
4463     ENG_GLOBALS.Set_PLN_Item_Access( p_pln_item_access => NULL);
4464     ENG_GLOBALS.Set_OC_Item_Access( p_oc_item_access   => NULL);
4465 IF BOM_Globals.get_debug = 'Y'
4466    Then
4467      error_handler.write_debug('end of process_eco');
4468    END IF;
4469 
4470 EXCEPTION
4471 
4472     WHEN EXC_ERR_PVT_API_MAIN THEN
4473 
4474         Eco_Error_Handler.Log_Error
4475                 (  p_ECO_rec            => l_ECO_rec
4476                 ,  p_eco_revision_tbl   => l_eco_revision_tbl
4477                 ,  p_revised_item_tbl   => l_revised_item_tbl
4478                 ,  p_rev_component_tbl  => l_rev_component_tbl
4479                 ,  p_ref_designator_tbl => l_ref_designator_tbl
4480                 ,  p_sub_component_tbl  => l_sub_component_tbl
4481                 ,  p_rev_operation_tbl     => l_rev_operation_tbl       --add
4482                 ,  p_rev_op_resource_tbl   => l_rev_op_resource_tbl     --add
4483                 ,  p_rev_sub_resource_tbl  => l_rev_sub_resource_tbl    --add
4484                 ,  p_mesg_token_tbl     => l_mesg_token_tbl
4485                 ,  p_error_status       => FND_API.G_RET_STS_UNEXP_ERROR
4486                 ,  p_other_status       => Error_Handler.G_STATUS_NOT_PICKED
4487                 ,  p_other_message      => l_other_message
4488                 ,  p_other_token_tbl    => l_other_token_tbl
4489                 ,  p_error_level        => 0
4490                 ,  x_ECO_rec            => l_ECO_rec
4491                 ,  x_eco_revision_tbl   => l_eco_revision_tbl
4492                 ,  x_revised_item_tbl   => l_revised_item_tbl
4493                 ,  x_rev_component_tbl  => l_rev_component_tbl
4494                 ,  x_ref_designator_tbl => l_ref_designator_tbl
4495                 ,  x_sub_component_tbl  => l_sub_component_tbl
4496                 ,  x_rev_operation_tbl     => l_rev_operation_tbl      --add
4497                 ,  x_rev_op_resource_tbl   => l_rev_op_resource_tbl    --add
4498                 ,  x_rev_sub_resource_tbl  => l_rev_sub_resource_tbl   --add
4499                 );
4500 
4501         x_return_status                := l_return_status;
4502         x_ECO_rec                      := l_ECO_rec;
4503         x_eco_revision_tbl             := l_eco_revision_tbl;
4504         x_revised_item_tbl             := l_revised_item_tbl;
4505         x_rev_component_tbl            := l_rev_component_tbl;
4506         x_ref_designator_tbl           := l_ref_designator_tbl;
4507         x_sub_component_tbl            := l_sub_component_tbl;
4508         x_rev_operation_tbl            := l_rev_operation_tbl;         --add
4509         x_rev_op_resource_tbl          := l_rev_op_resource_tbl;       --add
4510         x_rev_sub_resource_tbl         := l_rev_sub_resource_tbl;      --add
4511 
4512 
4513         -- Reset system_information business object flags
4514 
4515         ENG_GLOBALS.Set_ECO_Impl( p_eco_impl        => NULL);
4516         ENG_GLOBALS.Set_ECO_Cancl( p_eco_cancl      => NULL);
4517         ENG_GLOBALS.Set_Wkfl_Process( p_wkfl_process=> NULL);
4518         ENG_GLOBALS.Set_ECO_Access( p_eco_access    => NULL);
4519         ENG_GLOBALS.Set_STD_Item_Access( p_std_item_access => NULL);
4520         ENG_GLOBALS.Set_MDL_Item_Access( p_mdl_item_access => NULL);
4521         ENG_GLOBALS.Set_PLN_Item_Access( p_pln_item_access => NULL);
4522         ENG_GLOBALS.Set_OC_Item_Access( p_oc_item_access   => NULL);
4523 
4524     WHEN G_EXC_QUIT_IMPORT THEN
4525 
4526         x_return_status                := l_return_status;
4527         x_ECO_rec                      := l_ECO_rec;
4528         x_eco_revision_tbl             := l_eco_revision_tbl;
4529         x_revised_item_tbl             := l_revised_item_tbl;
4530         x_rev_component_tbl            := l_rev_component_tbl;
4531         x_ref_designator_tbl           := l_ref_designator_tbl;
4532         x_sub_component_tbl            := l_sub_component_tbl;
4533         x_rev_operation_tbl            :=  l_rev_operation_tbl;         --add
4534         x_rev_op_resource_tbl          :=  l_rev_op_resource_tbl;       --add
4535         x_rev_sub_resource_tbl         :=  l_rev_sub_resource_tbl;      --add
4536 
4537         -- Reset system_information business object flags
4538 
4539         ENG_GLOBALS.Set_ECO_Impl( p_eco_impl        => NULL);
4540         ENG_GLOBALS.Set_ECO_Cancl( p_eco_cancl      => NULL);
4541         ENG_GLOBALS.Set_Wkfl_Process( p_wkfl_process=> NULL);
4542         ENG_GLOBALS.Set_ECO_Access( p_eco_access    => NULL);
4543         ENG_GLOBALS.Set_STD_Item_Access( p_std_item_access => NULL);
4544         ENG_GLOBALS.Set_MDL_Item_Access( p_mdl_item_access => NULL);
4545         ENG_GLOBALS.Set_PLN_Item_Access( p_pln_item_access => NULL);
4546         ENG_GLOBALS.Set_OC_Item_Access( p_oc_item_access   => NULL);
4547 
4548     WHEN OTHERS THEN
4549 
4550 
4551 IF BOM_Globals.get_debug = 'Y'
4552    Then
4553      error_handler.write_debug('error in process_eco.');
4554    END IF;
4555    Error_Handler.Close_Debug_Session;
4556 
4557         IF g_control_rec.write_to_db
4558         THEN
4559                 RAISE;
4560         END IF;
4561 
4562         IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
4563         THEN
4564                 l_err_text := G_PKG_NAME || ' : Process ECO '
4565                         || substrb(SQLERRM,1,200);
4566                 Error_Handler.Add_Error_Token
4567                         ( p_Message_Text => l_err_text
4568                         , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4569                         , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
4570                         );
4571         END IF;
4572 
4573         Eco_Error_Handler.Log_Error
4574                 (  p_ECO_rec            => l_ECO_rec
4575                 ,  p_eco_revision_tbl   => l_eco_revision_tbl
4576                 ,  p_revised_item_tbl   => l_revised_item_tbl
4577                 ,  p_rev_component_tbl  => l_rev_component_tbl
4578                 ,  p_ref_designator_tbl => l_ref_designator_tbl
4579                 ,  p_sub_component_tbl  => l_sub_component_tbl
4580                 ,  p_rev_operation_tbl    => l_rev_operation_tbl       --add
4581                 ,  p_rev_op_resource_tbl  => l_rev_op_resource_tbl     --add
4582                 ,  p_rev_sub_resource_tbl => l_rev_sub_resource_tbl    --add
4583                 ,  p_mesg_token_tbl     => l_mesg_token_tbl
4584                 ,  p_error_status       => FND_API.G_RET_STS_UNEXP_ERROR
4585                 ,  p_other_status       => Error_Handler.G_STATUS_NOT_PICKED
4586                 ,  p_other_message      => l_other_message
4587                 ,  p_other_token_tbl    => l_other_token_tbl
4588                 ,  p_error_level        => 0
4589                 ,  x_ECO_rec            => l_ECO_rec
4590                 ,  x_eco_revision_tbl   => l_eco_revision_tbl
4591                 ,  x_revised_item_tbl   => l_revised_item_tbl
4592                 ,  x_rev_component_tbl  => l_rev_component_tbl
4593                 ,  x_ref_designator_tbl => l_ref_designator_tbl
4594                 ,  x_sub_component_tbl  => l_sub_component_tbl
4595                 ,  x_rev_operation_tbl    => l_rev_operation_tbl         --add
4596                 ,  x_rev_op_resource_tbl  => l_rev_op_resource_tbl       --add
4597                 ,  x_rev_sub_resource_tbl => l_rev_sub_resource_tbl      --add
4598                 );
4599 
4600         x_return_status                := l_return_status;
4601         x_ECO_rec                      := l_ECO_rec;
4602         x_eco_revision_tbl             := l_eco_revision_tbl;
4603         x_revised_item_tbl             := l_revised_item_tbl;
4604         x_rev_component_tbl            := l_rev_component_tbl;
4605         x_ref_designator_tbl           := l_ref_designator_tbl;
4606         x_sub_component_tbl            := l_sub_component_tbl;
4607         x_rev_operation_tbl            := l_rev_operation_tbl;         --add
4608         x_rev_op_resource_tbl          := l_rev_op_resource_tbl;       --add
4609         x_rev_sub_resource_tbl         := l_rev_sub_resource_tbl;      --add
4610 
4611         -- Reset system_information business object flags
4612 
4613         ENG_GLOBALS.Set_ECO_Impl( p_eco_impl         => NULL);
4614         ENG_GLOBALS.Set_ECO_Cancl( p_eco_cancl       => NULL);
4615         ENG_GLOBALS.Set_Wkfl_Process( p_wkfl_process => NULL);
4616         ENG_GLOBALS.Set_ECO_Access( p_eco_access     => NULL);
4617         ENG_GLOBALS.Set_STD_Item_Access( p_std_item_access => NULL);
4618         ENG_GLOBALS.Set_MDL_Item_Access( p_mdl_item_access => NULL);
4619         ENG_GLOBALS.Set_PLN_Item_Access( p_pln_item_access => NULL);
4620         ENG_GLOBALS.Set_OC_Item_Access( p_oc_item_access   => NULL);
4621 
4622 END process_Eco;
4623 
4624 --  Start of Comments
4625 --  API name    Lock_Eco
4626 --  Type        Private
4627 --  Function
4628 --
4629 --  Pre-reqs
4630 --
4631 --  Parameters
4632 --
4633 --  Version     Current version = 1.0
4634 --              Initial version = 1.0
4635 --
4636 --  Notes
4637 --
4638 --  End of Comments
4639 
4640 PROCEDURE Lock_Eco
4641 (   p_api_version_number            IN  NUMBER
4642 ,   p_init_msg_list                 IN  VARCHAR2 := FND_API.G_FALSE
4643 ,   x_return_status                 IN OUT NOCOPY VARCHAR2
4644 ,   x_msg_count                     IN OUT NOCOPY NUMBER
4645 ,   x_msg_data                      IN OUT NOCOPY VARCHAR2
4646 ,   p_ECO_rec                       IN  ENG_Eco_PUB.Eco_Rec_Type :=
4647                                         ENG_Eco_PUB.G_MISS_ECO_REC
4648 ,   p_eco_revision_tbl              IN  ENG_Eco_PUB.Eco_Revision_Tbl_Type :=
4649                                         ENG_Eco_PUB.G_MISS_ECO_REVISION_TBL
4650 ,   p_revised_item_tbl              IN  ENG_Eco_PUB.Revised_Item_Tbl_Type :=
4651                                         ENG_Eco_PUB.G_MISS_REVISED_ITEM_TBL
4652 ,   p_rev_component_tbl             IN  BOM_BO_PUB.Rev_Component_Tbl_Type :=
4653                                         ENG_Eco_PUB.G_MISS_REV_COMPONENT_TBL
4654 ,   p_ref_designator_tbl            IN  BOM_BO_PUB.Ref_Designator_Tbl_Type :=
4655                                         ENG_Eco_PUB.G_MISS_REF_DESIGNATOR_TBL
4656 ,   p_sub_component_tbl             IN  BOM_BO_PUB.Sub_Component_Tbl_Type :=
4657                                         ENG_Eco_PUB.G_MISS_SUB_COMPONENT_TBL
4658 ,   x_ECO_rec                       IN OUT NOCOPY ENG_Eco_PUB.Eco_Rec_Type
4659 ,   x_eco_revision_tbl              IN OUT NOCOPY ENG_Eco_PUB.Eco_Revision_Tbl_Type
4660 ,   x_revised_item_tbl              IN OUT NOCOPY ENG_Eco_PUB.Revised_Item_Tbl_Type
4661 ,   x_rev_component_tbl             IN OUT NOCOPY BOM_BO_PUB.Rev_Component_Tbl_Type
4662 ,   x_ref_designator_tbl            IN OUT NOCOPY BOM_BO_PUB.Ref_Designator_Tbl_Type
4663 ,   x_sub_component_tbl             IN OUT NOCOPY BOM_BO_PUB.Sub_Component_Tbl_Type
4664 ,   x_err_text                      IN OUT NOCOPY VARCHAR2
4665 )
4666 IS
4667 l_api_version_number          CONSTANT NUMBER := 1.0;
4668 l_api_name                    CONSTANT VARCHAR2(30):= 'Lock_Eco';
4669 l_return_status               VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
4670 l_eco_revision_rec            ENG_Eco_PUB.Eco_Revision_Rec_Type;
4671 l_revised_item_rec            ENG_Eco_PUB.Revised_Item_Rec_Type;
4672 l_rev_component_rec           BOM_BO_PUB.Rev_Component_Rec_Type;
4673 l_ref_designator_rec          BOM_BO_PUB.Ref_Designator_Rec_Type;
4674 l_sub_component_rec           BOM_BO_PUB.Sub_Component_Rec_Type;
4675 BEGIN
4676 
4677     --  Standard call to check for call compatibility
4678 
4679 NULL;
4680 
4681 /*********************** Temporarily commented *****************************
4682 
4683     IF NOT FND_API.Compatible_API_Call
4684            (   l_api_version_number
4685            ,   p_api_version_number
4686            ,   l_api_name
4687            ,   G_PKG_NAME
4688            )
4689     THEN
4690         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4691     END IF;
4692 
4693     --  Initialize message list.
4694 
4695     IF FND_API.to_Boolean(p_init_msg_list) THEN
4696         FND_MSG_PUB.initialize;
4697     END IF;
4698 
4699     --  Set Savepoint
4700 
4701     SAVEPOINT Lock_Eco_PVT;
4702 
4703     --  Lock ECO
4704 
4705     IF p_ECO_rec.operation = ENG_GLOBALS.G_OPR_LOCK THEN
4706 
4707         ENG_Eco_Util.Lock_Row
4708         (   p_ECO_rec                     => p_ECO_rec
4709         ,   x_ECO_rec                     => x_ECO_rec
4710         ,   x_return_status               => l_return_status
4711         ,   x_err_text                    => x_err_text
4712         );
4713 
4714         IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4715             RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4716         ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
4717             RAISE FND_API.G_EXC_ERROR;
4718         END IF;
4719 
4720 
4721     END IF;
4722 
4723     --  Lock eco_revision
4724 
4725     FOR I IN 1..p_eco_revision_tbl.COUNT LOOP
4726 
4727         IF p_eco_revision_tbl(I).operation = ENG_GLOBALS.G_OPR_LOCK THEN
4728 
4729             ENG_Eco_Revision_Util.Lock_Row
4730             (   p_eco_revision_rec            => p_eco_revision_tbl(I)
4731             ,   x_eco_revision_rec            => l_eco_revision_rec
4732             ,   x_return_status               => l_return_status
4733             ,   x_err_text                          => x_err_text
4734             );
4735 
4736             IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4737                 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4738             ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
4739                 RAISE FND_API.G_EXC_ERROR;
4740             END IF;
4741 
4742             x_eco_revision_tbl(I)          := l_eco_revision_rec;
4743 
4744         END IF;
4745 
4746     END LOOP;
4747 
4748     --  Lock revised_item
4749 
4750     FOR I IN 1..p_revised_item_tbl.COUNT LOOP
4751 
4752         IF p_revised_item_tbl(I).operation = ENG_GLOBALS.G_OPR_LOCK THEN
4753 
4754             ENG_Revised_Item_Util.Lock_Row
4755             (   p_revised_item_rec            => p_revised_item_tbl(I)
4756             ,   x_revised_item_rec            => l_revised_item_rec
4757             ,   x_return_status               => l_return_status
4758             ,   x_err_text                    => x_err_text
4759             );
4760 
4761             IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4762                 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4763             ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
4764                 RAISE FND_API.G_EXC_ERROR;
4765             END IF;
4766 
4767             x_revised_item_tbl(I)          := l_revised_item_rec;
4768 
4769         END IF;
4770 
4771     END LOOP;
4772 
4773     --  Lock rev_component
4774 
4775     FOR I IN 1..p_rev_component_tbl.COUNT LOOP
4776 
4777         IF p_rev_component_tbl(I).operation = ENG_GLOBALS.G_OPR_LOCK THEN
4778 
4779             ENG_Rev_Component_Util.Lock_Row
4780             (   p_rev_component_rec           => p_rev_component_tbl(I)
4781             ,   x_rev_component_rec           => l_rev_component_rec
4782             ,   x_return_status               => l_return_status
4783                 ,   x_err_text                      => x_err_text
4784             );
4785 
4786             IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4787                 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4788             ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
4789                 RAISE FND_API.G_EXC_ERROR;
4790             END IF;
4791 
4792             x_rev_component_tbl(I)         := l_rev_component_rec;
4793 
4794         END IF;
4795 
4796     END LOOP;
4797 
4798     --  Lock ref_designator
4799 
4800     FOR I IN 1..p_ref_designator_tbl.COUNT LOOP
4801 
4802         IF p_ref_designator_tbl(I).operation = ENG_GLOBALS.G_OPR_LOCK THEN
4803 
4804             ENG_Ref_Designator_Util.Lock_Row
4805             (   p_ref_designator_rec          => p_ref_designator_tbl(I)
4806             ,   x_ref_designator_rec          => l_ref_designator_rec
4807             ,   x_return_status               => l_return_status
4808               ,   x_err_text                        => x_err_text
4809             );
4810 
4811             IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4812                 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4813             ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
4814                 RAISE FND_API.G_EXC_ERROR;
4815             END IF;
4816 
4817             x_ref_designator_tbl(I)        := l_ref_designator_rec;
4818 
4819         END IF;
4820 
4821     END LOOP;
4822 
4823     --  Lock sub_component
4824 
4825     FOR I IN 1..p_sub_component_tbl.COUNT LOOP
4826 
4827         IF p_sub_component_tbl(I).operation = ENG_GLOBALS.G_OPR_LOCK THEN
4828 
4829             ENG_Sub_Component_Util.Lock_Row
4830             (   p_sub_component_rec           => p_sub_component_tbl(I)
4831             ,   x_sub_component_rec           => l_sub_component_rec
4832             ,   x_return_status               => l_return_status
4833                 ,   x_err_text                      => x_err_text
4834             );
4835 
4836             IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4837                 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4838             ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
4839                 RAISE FND_API.G_EXC_ERROR;
4840             END IF;
4841 
4842             x_sub_component_tbl(I)         := l_sub_component_rec;
4843 
4844         END IF;
4845 
4846     END LOOP;
4847 
4848     --  Set return status
4849 
4850     x_return_status := FND_API.G_RET_STS_SUCCESS;
4851 
4852     --  Get message count and data
4853 
4854     FND_MSG_PUB.Count_And_Get
4855     (   p_count                       => x_msg_count
4856     ,   p_data                        => x_msg_data
4857     );
4858 
4859 
4860 EXCEPTION
4861 
4862     WHEN FND_API.G_EXC_ERROR THEN
4863 
4864         x_return_status := FND_API.G_RET_STS_ERROR;
4865 
4866         --  Get message count and data
4867 
4868         FND_MSG_PUB.Count_And_Get
4869         (   p_count                       => x_msg_count
4870         ,   p_data                        => x_msg_data
4871         );
4872 
4873         --  Rollback
4874 
4875         ROLLBACK TO Lock_Eco_PVT;
4876 
4877     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4878 
4879         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
4880 
4881         --  Get message count and data
4882 
4883         FND_MSG_PUB.Count_And_Get
4884         (   p_count                       => x_msg_count
4885         ,   p_data                        => x_msg_data
4886         );
4887        --  Rollback
4888 
4889         ROLLBACK TO Lock_Eco_PVT;
4890 
4891     WHEN OTHERS THEN
4892 
4893         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
4894 
4895         IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
4896         THEN
4897             FND_MSG_PUB.Add_Exc_Msg
4898             (   G_PKG_NAME
4899             ,   'Lock_Eco'
4900             );
4901         END IF;
4902 
4903         --  Get message count and data
4904 
4905         FND_MSG_PUB.Count_And_Get
4906         (   p_count                       => x_msg_count
4907         ,   p_data                        => x_msg_data
4908         );
4909 
4910         --  Rollback
4911 
4912         ROLLBACK TO Lock_Eco_PVT;
4913 
4914 ****************************************************************************/
4915 
4916 END Lock_Eco;
4917 
4918 END ENG_Form_Eco_PVT;
4919