DBA Data[Home] [Help]

PACKAGE BODY: APPS.BOM_DEFAULT_OP_SEQ

Source


1 PACKAGE BODY BOM_Default_Op_Seq AS
2 /* $Header: BOMDOPSB.pls 120.1 2005/06/06 06:14:47 appldev  $ */
3 
4 /****************************************************************************
5 --
6 --  Copyright (c) 2000 Oracle Corporation, Redwood Shores, CA, USA
7 --  All rights reserved.
8 --
9 --  FILENAME
10 --
11 --     BOMDOPSB.pls
12 --
13 --  DESCRIPTION
14 --
15 --      Body of package BOM_Default_Op_Seq
16 --
17 --  NOTES
18 --
19 --  HISTORY
20 --
21 --  07-AUG-00 Masanori Kimizuka Initial Creation
22 --
23 ****************************************************************************/
24 
25     G_Pkg_Name      VARCHAR2(30) := 'BOM_Default_Op_Seq';
26     l_EVENT                       CONSTANT NUMBER := 1 ;
27     l_PROCESS                     CONSTANT NUMBER := 2 ;
28     l_LINE_OP                     CONSTANT NUMBER := 3 ;
29     l_ACD_ADD                     CONSTANT NUMBER := 1 ;
30     l_ACD_CHANGE                  CONSTANT NUMBER := 2 ;
31     l_ACD_DISABLE                 CONSTANT NUMBER := 3 ;
32     l_MODEL                       CONSTANT NUMBER := 1 ;
33     l_OPTION_CLASS                CONSTANT NUMBER := 2 ;
34 
35 
36     /*******************************************************************
37     * Following are all get functions which will be used by the attribute
38     * defaulting procedure. Each column needing to be defaulted has one GET
39     * function.
40     ********************************************************************/
41 
42     -- Operation_Sequence_Id
43     FUNCTION Get_Operation_Sequence_Id RETURN NUMBER
44     IS
45        CURSOR l_op_seq_cur IS
46        SELECT Bom_Operation_Sequences_S.NEXTVAL Op_Seq_Id
47        FROM SYS.DUAL ;
48     BEGIN
49        FOR l_op_seq_rec IN l_op_seq_cur LOOP
50           RETURN l_op_seq_rec.Op_Seq_Id ;
51        END LOOP ;
52        RETURN NULL ;
53     END Get_Operation_Sequence_Id ;
54 
55 
56     -- Routing_Sequence_Id
57     FUNCTION Get_Routing_Sequence_Id(  p_revised_item_id        IN  NUMBER
58                                      , p_organization_id        IN  NUMBER
59                                      , p_alternate_routing_code IN  VARCHAR2 )
60     RETURN NUMBER
61     IS
62     /*******************************************************************
63     * Check if revised_item has a routing_sequence_id.
64     * If it does then retun that as the default value, if not then
65     * generate the Routing_Sequence_Id from the Sequence.
66     **********************************************************************/
67         CURSOR l_check_for_new_csr(  p_revised_item_id NUMBER
68                                    , p_organization_id NUMBER
69                                    , p_alternate_routing_code VARCHAR2 )
70         IS
71            SELECT routing_sequence_id
72            FROM   bom_operational_routings bor
73            WHERE  bor.assembly_item_id = p_revised_item_id
74            AND    bor.organization_id  = p_organization_id
75            AND    NVL(bor.alternate_routing_designator, FND_API.G_MISS_CHAR) =
76                   NVL(p_alternate_routing_code, FND_API.G_MISS_CHAR);
77 
78 
79         CURSOR l_rtg_seq_csr  IS
80         SELECT Bom_Operational_Routings_S.NEXTVAL Rtg_Seq_Id
81         FROM SYS.DUAL ;
82 
83         l_routing_sequence_id  NUMBER;
84 
85     BEGIN
86 
87         --
88         -- Check if routing sequence id exists in Eng_Revised_Items
89         -- but through global record. Hopefully the ECO object
90         -- will have set this.
91         IF BOM_Rtg_Globals.Get_Routing_Sequence_Id IS NOT NULL THEN
92           l_routing_sequence_id :=
93           BOM_Rtg_Globals.Get_Routing_Sequence_Id;
94           RETURN l_routing_sequence_id ;
95         END IF;
96 
97         --
98         -- If routing sequence id is not found in Eng_Revised_Items
99         -- Only then go to the Rtg Table to look for Bill_Sequence_Id
100         --
101 
102         OPEN  l_check_for_new_csr(   p_revised_item_id
103                                    , p_organization_id
104                                    , p_alternate_routing_code)  ;
105         FETCH l_check_for_new_csr INTO l_routing_sequence_id;
106         CLOSE l_check_for_new_csr ;
107 
108         --
109         -- If routing sequence id is not found in Rtg Table
110         -- generate the Routing_Sequence_Id from the Sequence.
111         --
112 
113         IF l_routing_sequence_id IS NULL
114         THEN
115            FOR l_rtg_seq_rec IN l_rtg_seq_csr LOOP
116               RETURN l_rtg_seq_rec.Rtg_Seq_Id ;
117            END LOOP ;
118         ELSE
119            RETURN l_routing_sequence_id ;
120         END IF;
121 
122         RETURN NULL ;
123 
124     END Get_Routing_Sequence_Id ;
125 
126     -- Operation_Type
127     FUNCTION Get_Operation_Type
128     RETURN NUMBER
129     IS
130     BEGIN
131 
132             RETURN 1 ;   -- Return 1 : Event
133 
134     END Get_Operation_Type ;
135 
136     -- Start_Effective_Date
137     FUNCTION Get_Start_Effective_Date
138     RETURN DATE
139     IS
140        l_current_date DATE := NULL ;
141     BEGIN
142 /** time **/
143         SELECT SYSDATE   -- Changed for bug 2647027
144 --        SELECT TRUNC(SYSDATE)
145         INTO l_current_date
146         FROM SYS.DUAL ;
147 
148         RETURN l_current_date ;
149 
150     END  Get_Start_Effective_Date ;
151 
152 
153 
154     -- Count_Point_Type
155     FUNCTION Get_Count_Point_Type
156     RETURN NUMBER
157     IS
158     BEGIN
159 
160             RETURN 1 ;   -- Return Yes-Autocharge which is 1
161 
162     END Get_Count_Point_Type ;
163 
164 
165     -- BackFlush_Flag
166     FUNCTION Get_BackFlush_Flag
167     RETURN NUMBER
168     IS
169     BEGIN
170 
171             RETURN 1 ;   -- Return Yes which is 1
172 
173     END Get_BackFlush_Flag ;
174 
175     -- Reference_Flag
176     FUNCTION Get_Reference_Flag(p_std_op_code IN VARCHAR2)
177     RETURN NUMBER
178     IS
179     BEGIN
180 
181        IF ( p_std_op_code IS NULL
182             OR p_std_op_code = FND_API.G_MISS_CHAR )
183        THEN
184             RETURN 2 ;   -- Return No which is 2
185 
186        ELSE
187             RETURN 1 ;   -- Return Yes which is 1
188        END IF ;
189 
190     END Get_Reference_Flag  ;
191 
192 
193     -- Option_Dependent_Flag
194     FUNCTION Get_Option_Dependent_Flag
195                     (  p_revised_item_id   IN NUMBER
196                      , p_organization_id   IN NUMBER
197                     )
198 
199     RETURN NUMBER
200     IS
201 
202          g_assy_item_type NUMBER ;
203 
204     BEGIN
205           -- If Assembly Item Type = Model or Option, Return 1:Yes
206           -- Else If Assembly Item Type = Standard, Return 2:No
207           SELECT  bom_item_type
208           INTO    g_assy_item_type
209           FROM    MTL_SYSTEM_ITEMS
210           WHERE   organization_id   = p_organization_id
211           AND     inventory_item_id = p_revised_item_id ;
212 
213           IF g_assy_item_type in ( l_MODEL,l_OPTION_CLASS )
214           THEN
215               RETURN 1 ;   -- Return Yes which is 1
216           ELSE
217               RETURN 2 ;   -- Return No which is 2
218           END IF;
219 
220     END Get_Option_Dependent_Flag ;
221 
222 
223     -- Minimum_Transfer_Quantity
224     FUNCTION Get_Minimum_Transfer_Quantity
225     RETURN NUMBER
226     IS
227     BEGIN
228 
229             RETURN 0 ;   -- Return 0 : 0 qty
230 
231     END Get_Minimum_Transfer_Quantity ;
232 
233     -- User_Labor_Time
234     FUNCTION Get_User_Labor_Time
235     RETURN NUMBER
236     IS
237     BEGIN
238 
239             RETURN 0 ;   -- Return 0 : 0 time
240 
241     END Get_User_Labor_Time ;
242 
243     -- User_Machine_Time
244     FUNCTION Get_User_Machine_Time
245     RETURN NUMBER
246     IS
247     BEGIN
248 
249             RETURN 0 ;   -- Return 0 : 0 time
250 
251     END Get_User_Machine_Time ;
252 
253     -- User_Elapsed_Time
254     FUNCTION Get_User_Elapsed_Time
255              (  p_user_labor_time   IN NUMBER
256               , p_user_machine_time IN NUMBER )
257     RETURN NUMBER
258     IS
259         l_user_elapsed_time NUMBER := NULL ;
260 
261     BEGIN
262             l_user_elapsed_time :=
263               NVL(p_user_labor_time , 0 )  +
264               NVL(p_user_machine_time, 0 ) ;
265 
266 
267             RETURN l_user_elapsed_time  ;
268 
269     END Get_User_Elapsed_Time ;
270 
271 
272     -- Include_In_Rollup
273     FUNCTION Get_Include_In_Rollup
274     RETURN NUMBER
275     IS
276     BEGIN
277 
278             RETURN 1 ;   -- Return 1 : Yes
279 
280     END Get_Include_In_Rollup ;
281 
282 
283     -- Get_Op_Yield_Enabled_Flag
284     FUNCTION Get_Op_Yield_Enabled_Flag
285     RETURN NUMBER
286     IS
287     BEGIN
288 
289             RETURN 1 ;   -- Return 1 : Yes
290 
291     END Get_Op_Yield_Enabled_Flag ;
292 
293 
294     PROCEDURE Get_Flex_Op_Seq
295     (  p_com_operation_rec    IN  Bom_Rtg_Pub.Com_Operation_Rec_Type
296      , x_com_operation_rec    IN OUT NOCOPY Bom_Rtg_Pub.Com_Operation_Rec_Type
297     )
298     IS
299         l_com_operation_rec      Bom_Rtg_Pub.Com_Operation_Rec_Type ;
300         l_com_op_unexp_rec       Bom_Rtg_Pub.Com_Op_Unexposed_Rec_Type ;
301 
302     BEGIN
303        --  Initialize operation exp and unexp record
304        l_com_operation_rec  := p_com_operation_rec ;
305 
306         --  In the future call Flex APIs for defaults
307 
308         IF l_com_operation_rec.attribute_category = FND_API.G_MISS_CHAR THEN
309             l_com_operation_rec.attribute_category := NULL;
310         END IF;
311 
312         IF l_com_operation_rec.attribute1 = FND_API.G_MISS_CHAR THEN
313             l_com_operation_rec.attribute1 := NULL;
314         END IF;
315 
316         IF l_com_operation_rec.attribute2 = FND_API.G_MISS_CHAR THEN
317             l_com_operation_rec.attribute2 := NULL;
318         END IF;
319 
320         IF l_com_operation_rec.attribute3 = FND_API.G_MISS_CHAR THEN
321             l_com_operation_rec.attribute3 := NULL;
322         END IF;
323 
324         IF l_com_operation_rec.attribute4 = FND_API.G_MISS_CHAR THEN
325             l_com_operation_rec.attribute4 := NULL;
326         END IF;
327 
328         IF l_com_operation_rec.attribute5 = FND_API.G_MISS_CHAR THEN
329             l_com_operation_rec.attribute5 := NULL;
330         END IF;
331 
332         IF l_com_operation_rec.attribute6 = FND_API.G_MISS_CHAR THEN
333             l_com_operation_rec.attribute6 := NULL;
334         END IF;
335 
336         IF l_com_operation_rec.attribute7 = FND_API.G_MISS_CHAR THEN
337             l_com_operation_rec.attribute7 := NULL;
338         END IF;
339 
340         IF l_com_operation_rec.attribute8 = FND_API.G_MISS_CHAR THEN
341             l_com_operation_rec.attribute8 := NULL;
342         END IF;
343 
344         IF l_com_operation_rec.attribute9 = FND_API.G_MISS_CHAR THEN
345             l_com_operation_rec.attribute9 := NULL;
346         END IF;
347 
348         IF l_com_operation_rec.attribute10 = FND_API.G_MISS_CHAR THEN
349             l_com_operation_rec.attribute10 := NULL;
350         END IF;
351 
352         IF l_com_operation_rec.attribute11 = FND_API.G_MISS_CHAR THEN
353             l_com_operation_rec.attribute11 := NULL;
354         END IF;
355 
356         IF l_com_operation_rec.attribute12 = FND_API.G_MISS_CHAR THEN
357             l_com_operation_rec.attribute12 := NULL;
358         END IF;
359 
360         IF l_com_operation_rec.attribute13 = FND_API.G_MISS_CHAR THEN
361             l_com_operation_rec.attribute13 := NULL;
362         END IF;
363 
364         IF l_com_operation_rec.attribute14 = FND_API.G_MISS_CHAR THEN
365             l_com_operation_rec.attribute14 := NULL;
366         END IF;
367 
368         IF l_com_operation_rec.attribute15 = FND_API.G_MISS_CHAR THEN
369             l_com_operation_rec.attribute15 := NULL;
370         END IF;
371 
372         x_com_operation_rec := l_com_operation_rec ;
373 
374     END Get_Flex_Op_Seq ;
375 
376 
377     /******************************************************************
378     * Procedure : Default_Std_Op_Attributes internally
379     *                     called by RTG BO and by ECO BO
380     * Parameters IN : Common Operation exposed column record
381     *                 Common Operation unexposed column record
382     *                 Common Old Operation exposed column record
383     *                 Common Old Operation unexposed column record
384     * Parameters out: Return Status
385     *                 Message Token Table
386     * Purpose   :     Check_Ref_Operation validate Reference flag and
387     *                 Standard Operation. If Std Op is not null
388     *                 Set Standard Operation infor to exposed and unexposed
389     *                 coulumns regarding reference flag
390     **********************************************************************/
391     PROCEDURE Default_Std_Op_Attributes
392     (  p_com_operation_rec        IN  Bom_Rtg_Pub.Com_Operation_Rec_Type
393      , p_com_op_unexp_rec         IN  Bom_Rtg_Pub.Com_Op_Unexposed_Rec_Type
394      , x_com_operation_rec        IN OUT NOCOPY Bom_Rtg_Pub.Com_Operation_Rec_Type
395      , x_com_op_unexp_rec         IN OUT NOCOPY Bom_Rtg_Pub.Com_Op_Unexposed_Rec_Type
396      , x_mesg_token_tbl           IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
397      , x_return_status            IN OUT NOCOPY VARCHAR2
398     )
399    IS
400     -- Variables
401     l_std_op_found      BOOLEAN ; -- Indicate Std OP is found
402     l_copy_std_op       BOOLEAN ; -- Indicate Copy Std Op has been proceeded
403 
404     l_com_operation_rec      Bom_Rtg_Pub.Com_Operation_Rec_Type;
405     l_com_op_unexp_rec       Bom_Rtg_Pub.Com_Op_Unexposed_Rec_Type;
406 
407     -- Error Handlig Variables
408     l_return_status   VARCHAR2(1);
409     l_err_text        VARCHAR2(2000) ;
410     l_Mesg_Token_Tbl  Error_Handler.Mesg_Token_Tbl_Type ;
411     l_token_tbl       Error_Handler.Token_Tbl_Type;
412 
413     -- Exception
414     EXIT_CHECK_REF_STD_OP EXCEPTION ;
415 
416     -- Check if the operatin already has resources
417     CURSOR l_exist_res_cur (p_op_seq_id NUMBER)
421        WHERE EXISTS ( SELECT NULL
418     IS
419        SELECT 'Resource Exist'
420        FROM   DUAL
422                       FROM   BOM_OPERATION_RESOURCES
423                       WHERE  operation_sequence_id = p_op_seq_id
424                     ) ;
425 
426     -- Get Standard Operation Info.
427     CURSOR l_stdop_csr(   p_std_op_id      NUMBER
428                         , p_op_type        NUMBER
429                         , p_rtg_seq_id     NUMBER
430                         , p_org_id         NUMBER
431                         , p_dept_id        NUMBER
432                         , p_rit_seq_id     NUMBER
433                       )
434     IS
435        SELECT   bso.department_id
436               , bso.minimum_transfer_quantity
437               , bso.count_point_type
438               , bso.operation_description
439               , bso.backflush_flag
440               , bso.option_dependent_flag
441               , bso.attribute_category
442               , bso.attribute1
443               , bso.attribute2
444               , bso.attribute3
445               , bso.attribute4
446               , bso.attribute5
447               , bso.attribute6
448               , bso.attribute7
449               , bso.attribute8
450               , bso.attribute9
451               , bso.attribute10
452               , bso.attribute11
453               , bso.attribute12
454               , bso.attribute13
455               , bso.attribute14
456               , bso.attribute15
457               , bso.operation_yield_enabled
458               , bso.shutdown_type
459               , bso.yield  --bug 3572770
460 	      , bso.lowest_acceptable_yield  -- Added for MES Enhancement
461 	      ,	bso.use_org_settings
462 	      ,	bso.queue_mandatory_flag
463 	      ,	bso.run_mandatory_flag
464 	      ,	bso.to_move_mandatory_flag
465 	      ,	bso.show_next_op_by_default
466 	      ,	bso.show_scrap_code
467 	      ,	bso.show_lot_attrib
468 	      ,	bso.track_multiple_res_usage_dates  -- End of MES Changes
469        FROM     BOM_STANDARD_OPERATIONS  bso
470               , bom_operational_routings bor
471        WHERE   NVL(bso.operation_type,1 )
472                                = DECODE(p_op_type, FND_API.G_MISS_NUM, 1
473                                         , NVL(p_op_type, 1))
474        AND     NVL(bso.line_id, FND_API.G_MISS_NUM)
475                                = NVL(bor.line_id, FND_API.G_MISS_NUM)
476        AND    bor.routing_sequence_id   = p_rtg_seq_id
477        AND    bso.organization_id       = p_org_id
478        AND    bso.standard_operation_id = p_std_op_id
479        UNION
480        SELECT   bso.department_id
481               , bso.minimum_transfer_quantity
482               , bso.count_point_type
483               , bso.operation_description
484               , bso.backflush_flag
485               , bso.option_dependent_flag
486               , bso.attribute_category
487               , bso.attribute1
488               , bso.attribute2
489               , bso.attribute3
490               , bso.attribute4
491               , bso.attribute5
492               , bso.attribute6
493               , bso.attribute7
494               , bso.attribute8
495               , bso.attribute9
496               , bso.attribute10
497               , bso.attribute11
498               , bso.attribute12
499               , bso.attribute13
500               , bso.attribute14
501               , bso.attribute15
502               , bso.operation_yield_enabled
503               , bso.shutdown_type
504               , bso.yield  --bug 3572770
505 	      , bso.lowest_acceptable_yield  -- Added for MES Enhancement
506 	      ,	bso.use_org_settings
507 	      ,	bso.queue_mandatory_flag
508 	      ,	bso.run_mandatory_flag
509 	      ,	bso.to_move_mandatory_flag
510 	      ,	bso.show_next_op_by_default
511 	      ,	bso.show_scrap_code
512 	      ,	bso.show_lot_attrib
513 	      ,	bso.track_multiple_res_usage_dates  -- End of MES Changes
514        FROM     BOM_STANDARD_OPERATIONS  bso
515              -- , ENG_REVISED_ITEMS        eri   --Bug : 3640944 By AMALVIYA
516        WHERE   NVL(bso.operation_type, 1)
517                  = DECODE( p_op_type, FND_API.G_MISS_NUM, 1
518                          , NVL(p_op_type, 1 ) )
519        -- AND     NVL(bso.line_id, FND_API.G_MISS_NUM)
520        --                      = NVL(eri.line_id, FND_API.G_MISS_NUM)
521        -- AND     eri.revised_item_sequence_id =  p_rev_item_sequence_id
522        AND    BOM_Rtg_Globals.Get_Routing_Sequence_Id   IS NULL
523        AND    bso.organization_id       = p_org_id
524        AND    bso.standard_operation_id = p_std_op_id
525        ;
526 
527 
528     BEGIN
529 
530           --  Initialize operation exp and unexp record
531           l_com_operation_rec  := p_com_operation_rec ;
532           l_com_op_unexp_rec   := p_com_op_unexp_rec ;
533 
534           -- Set the first token to be equal to the operation sequence number
535           l_Token_Tbl(1).token_name  := 'OP_SEQ_NUMBER';
536           l_Token_Tbl(1).token_value := p_com_operation_rec.operation_sequence_number ;
537 
538           l_return_status            := FND_API.G_RET_STS_SUCCESS;
539 
540           --
541           -- Standard Operation has changed to not null value
542           --
543           IF  NVL(l_com_operation_rec.acd_type,l_ACD_ADD) = l_ACD_ADD
547              l_copy_std_op   := TRUE ;
544               -- OR l_com_operation_rec.acd_type = l_ACD_CHANGE
545           THEN
546 
548              --
549              -- Check if the operation already has resources
550              --
551              /*******************************************************
552              -- This check is no longer used.
553              --
554              FOR l_exist_res_rec IN l_exist_res_cur
555                   (  p_op_seq_id  => l_com_op_unexp_rec.operation_sequence_id )
556              LOOP
557                 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
558                 THEN
559                     Error_Handler.Add_Error_Token
560                    (  p_message_name   => 'BOM_OP_CANNOT_COPY_STD_OP'
561                     , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
562                     , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
563                     , p_Token_Tbl      => l_Token_Tbl
564                    ) ;
565                 END IF ;
566 
567                 l_return_status := FND_API.G_RET_STS_ERROR ;
568                 l_copy_std_op   := FALSE ;
569              END LOOP ;
570 
571              IF l_com_operation_rec.acd_type = l_ACD_CHANGE
572              THEN
573                   FOR l_exist_res_rec IN l_exist_res_cur
574                   (  p_op_seq_id  => l_com_op_unexp_rec.old_operation_sequence_id )
575                   LOOP
576                      IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
577                      THEN
578                         Error_Handler.Add_Error_Token
579                         (  p_message_name   => 'BOM_OP_CANNOT_COPY_STD_OP'
580                          , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
581                          , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
582                          , p_Token_Tbl      => l_Token_Tbl
583                         ) ;
584                      END IF ;
585 
586                      l_return_status := FND_API.G_RET_STS_ERROR ;
587                      l_copy_std_op   := FALSE ;
588                   END LOOP ;
589              END IF ;
590 
591              *******************************************************/
592 
593 
594              IF l_copy_std_op AND l_com_operation_rec.reference_flag <> 1 -- Yes
595              THEN
596                 l_std_op_found := FALSE ;
597                 --
598                 -- Get Standard Operatin Information
599                 --
600 
601 /*
602 IF BOM_Rtg_Globals.Get_Debug = 'Y' THEN
603        Error_Handler.Write_Debug('std op id  '||to_char(l_com_op_unexp_rec.standard_operation_id) ) ;
604        Error_Handler.Write_Debug('op type    '||to_char(l_com_operation_rec.operation_type) ) ;
605        Error_Handler.Write_Debug('rtg seq id  '||to_char(l_com_op_unexp_rec.routing_sequence_id) ) ;
606        Error_Handler.Write_Debug('org id  '||to_char(l_com_op_unexp_rec.organization_id) ) ;
607        Error_Handler.Write_Debug('dept id  '||to_char(l_com_op_unexp_rec.department_id) ) ;
608        Error_Handler.Write_Debug('rev seq id  '||to_char(l_com_op_unexp_rec.revised_item_sequence_id) ) ;
609 END IF ;
610 */
611 
612 
613                 FOR l_stdop_rec IN l_stdop_csr
614                       (   p_std_op_id  => l_com_op_unexp_rec.standard_operation_id
615                         , p_op_type    => l_com_operation_rec.operation_type
616                         , p_rtg_seq_id => l_com_op_unexp_rec.routing_sequence_id
617                         , p_org_id     => l_com_op_unexp_rec.organization_id
618                         , p_dept_id    => l_com_op_unexp_rec.department_id
619                         , p_rit_seq_id => l_com_op_unexp_rec.revised_item_sequence_id
620                       )
621                 LOOP
622                    l_std_op_found := TRUE ;
623 
624                    --
625                    -- Set Standard Operation Value to Operation Exp and Unexp Rec.
626                    --
627        IF BOM_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug
628        ('Set Standard Operation Value to Null Operation columns.. . . ' ) ;
629        END IF ;
630 
631 
632                    IF  l_com_op_unexp_rec.department_id IS NULL OR
633                        l_com_op_unexp_rec.department_id = FND_API.G_MISS_NUM
634                    THEN
635                        l_com_op_unexp_rec.department_id := l_stdop_rec.department_id ;
636                    END IF ;
637 
638                    IF  l_com_operation_rec.count_point_type  IS NULL OR
639                        l_com_operation_rec.count_point_type  = FND_API.G_MISS_NUM
640                    THEN
641                        l_com_operation_rec.count_point_type  := l_stdop_rec.count_point_type  ;
642                    END IF ;
643 
644                    IF  l_com_operation_rec.backflush_flag  IS NULL OR
645                        l_com_operation_rec.backflush_flag   = FND_API.G_MISS_NUM
646                    THEN
647                        l_com_operation_rec.backflush_flag := l_stdop_rec.backflush_flag ;
648                    END IF ;
649 
650                    IF  l_com_operation_rec.minimum_transfer_quantity IS NULL OR
651                        l_com_operation_rec.minimum_transfer_quantity = FND_API.G_MISS_NUM
652                    THEN
653                        l_com_operation_rec.minimum_transfer_quantity := l_stdop_rec.minimum_transfer_quantity ;
654                    END IF ;
655 
656                    IF  l_com_operation_rec.option_dependent_flag IS NULL OR
660                    END IF ;
657                        l_com_operation_rec.option_dependent_flag  = FND_API.G_MISS_NUM
658                    THEN
659                        l_com_operation_rec.option_dependent_flag := l_stdop_rec.option_dependent_flag ;
661 
662 
663                    IF  l_com_operation_rec.operation_description  IS NULL OR
664                        l_com_operation_rec.operation_description   = FND_API.G_MISS_CHAR
665                    THEN
666                        l_com_operation_rec.operation_description := l_stdop_rec.operation_description ;
667                    END IF ;
668 
669                    -- Added condition for Bug1744254
670                    IF  ( l_com_operation_rec.op_yield_enabled_flag IS NULL OR
671                          l_com_operation_rec.op_yield_enabled_flag = FND_API.G_MISS_NUM )
672                    AND  BOM_Rtg_Globals.Get_CFM_Rtg_Flag = BOM_Rtg_Globals.G_LOT_RTG
673                    THEN
674                        l_com_operation_rec.op_yield_enabled_flag := l_stdop_rec.operation_yield_enabled ;
675                        l_com_operation_rec.yield := l_stdop_rec.yield; --bug 3572770
676                    END IF ;
677 
678                    -- Added by MK on 04/10/2001 for eAM changes
679                    IF  l_com_operation_rec.shutdown_type IS NULL OR
680                        l_com_operation_rec.shutdown_type = FND_API.G_MISS_CHAR
681                    THEN
682                        l_com_operation_rec.shutdown_type := l_stdop_rec.shutdown_type ;
683                    END IF ;
684 
685                    l_com_operation_rec.attribute_category        := NVL(l_com_operation_rec.attribute_category
686                                                                        ,l_stdop_rec.attribute_category) ;
687                    l_com_operation_rec.attribute1   := NVL(l_com_operation_rec.attribute1,l_stdop_rec.attribute1) ;
688                    l_com_operation_rec.attribute2   := NVL(l_com_operation_rec.attribute2,l_stdop_rec.attribute2) ;
689                    l_com_operation_rec.attribute3   := NVL(l_com_operation_rec.attribute3,l_stdop_rec.attribute3) ;
690                    l_com_operation_rec.attribute4   := NVL(l_com_operation_rec.attribute4,l_stdop_rec.attribute4) ;
691                    l_com_operation_rec.attribute5   := NVL(l_com_operation_rec.attribute5,l_stdop_rec.attribute5) ;
692                    l_com_operation_rec.attribute6   := NVL(l_com_operation_rec.attribute6,l_stdop_rec.attribute6) ;
693                    l_com_operation_rec.attribute7   := NVL(l_com_operation_rec.attribute7,l_stdop_rec.attribute7) ;
694                    l_com_operation_rec.attribute8   := NVL(l_com_operation_rec.attribute8,l_stdop_rec.attribute8) ;
695                    l_com_operation_rec.attribute9   := NVL(l_com_operation_rec.attribute9,l_stdop_rec.attribute9) ;
696                    l_com_operation_rec.attribute10  := NVL(l_com_operation_rec.attribute10,l_stdop_rec.attribute10) ;
697                    l_com_operation_rec.attribute11  := NVL(l_com_operation_rec.attribute11,l_stdop_rec.attribute11) ;
698                    l_com_operation_rec.attribute12  := NVL(l_com_operation_rec.attribute12,l_stdop_rec.attribute12) ;
699                    l_com_operation_rec.attribute13  := NVL(l_com_operation_rec.attribute13,l_stdop_rec.attribute13) ;
700                    l_com_operation_rec.attribute14  := NVL(l_com_operation_rec.attribute14,l_stdop_rec.attribute14) ;
701                    l_com_operation_rec.attribute15  := NVL(l_com_operation_rec.attribute15,l_stdop_rec.attribute15) ;
702 
703                    l_com_op_unexp_rec.Lowest_acceptable_yield         := NVL(l_com_op_unexp_rec.Lowest_acceptable_yield,l_stdop_rec.Lowest_acceptable_yield) ; -- Added for MES Enhancement
704                    l_com_op_unexp_rec.Use_org_settings                := NVL(l_com_op_unexp_rec.Use_org_settings,l_stdop_rec.Use_org_settings) ;
705 		   l_com_op_unexp_rec.Queue_mandatory_flag            := NVL(l_com_op_unexp_rec.Queue_mandatory_flag,l_stdop_rec.Queue_mandatory_flag) ;
706 		   l_com_op_unexp_rec.Run_mandatory_flag              := NVL(l_com_op_unexp_rec.Run_mandatory_flag,l_stdop_rec.Run_mandatory_flag) ;
707 		   l_com_op_unexp_rec.To_move_mandatory_flag          := NVL(l_com_op_unexp_rec.To_move_mandatory_flag,l_stdop_rec.To_move_mandatory_flag) ;
708 		   l_com_op_unexp_rec.Show_next_op_by_default         := NVL(l_com_op_unexp_rec.Show_next_op_by_default,l_stdop_rec.Show_next_op_by_default) ;
709 		   l_com_op_unexp_rec.Show_scrap_code	              := NVL(l_com_op_unexp_rec.Show_scrap_code,l_stdop_rec.Show_scrap_code) ;
710 		   l_com_op_unexp_rec.Show_lot_attrib	              := NVL(l_com_op_unexp_rec.Show_lot_attrib,l_stdop_rec.Show_lot_attrib) ;
711 		   l_com_op_unexp_rec.Track_multiple_res_usage_dates  := NVL(l_com_op_unexp_rec.Track_multiple_res_usage_dates,l_stdop_rec.Track_multiple_res_usage_dates) ; -- End of MES Changes
712 
713                 END LOOP ;  -- copy standard operation
714 
715           --
716           --  If reference flag is Yes( operation columns corresponding to
717           --  columns in Standard Operations), the values should not be changed
718           --  when referenced.
719           --
720           ELSIF l_copy_std_op AND  l_com_operation_rec.reference_flag = 1 -- Yes
721           THEN
722 
723 IF BOM_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug
724     ('Reference flag is Yes, then the operation columns corresponding to in Standard Operations . . . ' ) ;
725 END IF ;
726              --
727              -- Get Standard Operatin Information
728              --
729              FOR l_stdop_rec IN l_stdop_csr
730                       (   p_std_op_id  => l_com_op_unexp_rec.standard_operation_id
734                         , p_dept_id    => l_com_op_unexp_rec.department_id
731                         , p_op_type    => l_com_operation_rec.operation_type
732                         , p_rtg_seq_id => l_com_op_unexp_rec.routing_sequence_id
733                         , p_org_id     => l_com_op_unexp_rec.organization_id
735                         , p_rit_seq_id => l_com_op_unexp_rec.revised_item_sequence_id
736                       )
737              LOOP
738 
739 IF BOM_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug
740     ('Std operation info should be copied over to the columns. . . ' ) ;
741 END IF ;
742 
743                 -- Set Standard Operation Info.
744                 IF  l_com_op_unexp_rec.department_id IS NULL OR
745                        l_com_op_unexp_rec.department_id = FND_API.G_MISS_NUM
746                 THEN
747                        l_com_op_unexp_rec.department_id := l_stdop_rec.department_id ;
748                 END IF ;
749 
750                 l_com_operation_rec.minimum_transfer_quantity := l_stdop_rec.minimum_transfer_quantity;
751                 l_com_operation_rec.count_point_type := l_stdop_rec.count_point_type ;
752                 l_com_operation_rec.operation_description := l_stdop_rec.operation_description ;
753 
754 
755                 -- l_com_operation_rec.option_dependent_flag := l_stdop_rec.option_dependent_flag ;
756                 IF  l_com_operation_rec.option_dependent_flag IS NULL OR
757                     l_com_operation_rec.option_dependent_flag  = FND_API.G_MISS_NUM
758                 THEN
759                     l_com_operation_rec.option_dependent_flag := l_stdop_rec.option_dependent_flag ;
760                 END IF ;
761 
762                 -- Added by MK on 04/10/2001 for eAM changes
763                 l_com_operation_rec.shutdown_type := l_stdop_rec.shutdown_type ;
764 
765                 l_com_operation_rec.attribute_category := l_stdop_rec.attribute_category ;
766                 l_com_operation_rec.attribute1  := l_stdop_rec.attribute1 ;
767                 l_com_operation_rec.attribute2  := l_stdop_rec.attribute2 ;
768                 l_com_operation_rec.attribute3  := l_stdop_rec.attribute3 ;
769                 l_com_operation_rec.attribute4  := l_stdop_rec.attribute4 ;
770                 l_com_operation_rec.attribute5  := l_stdop_rec.attribute5 ;
771                 l_com_operation_rec.attribute6  := l_stdop_rec.attribute6 ;
772                 l_com_operation_rec.attribute7  := l_stdop_rec.attribute7 ;
773                 l_com_operation_rec.attribute8  := l_stdop_rec.attribute8 ;
774                 l_com_operation_rec.attribute9  := l_stdop_rec.attribute9 ;
775                 l_com_operation_rec.attribute10 := l_stdop_rec.attribute10 ;
776                 l_com_operation_rec.attribute11 := l_stdop_rec.attribute11 ;
777                 l_com_operation_rec.attribute12 := l_stdop_rec.attribute12 ;
778                 l_com_operation_rec.attribute13 := l_stdop_rec.attribute13 ;
779                 l_com_operation_rec.attribute14 := l_stdop_rec.attribute14 ;
780                 l_com_operation_rec.attribute15 := l_stdop_rec.attribute15 ;
781                 l_com_operation_rec.backflush_flag := l_stdop_rec.backflush_flag;
782 
783                 l_com_op_unexp_rec.Lowest_acceptable_yield         := l_stdop_rec.Lowest_acceptable_yield ; -- Added for MES Enhancement
784                 l_com_op_unexp_rec.Use_org_settings                := l_stdop_rec.Use_org_settings ;
785                 l_com_op_unexp_rec.Queue_mandatory_flag            := l_stdop_rec.Queue_mandatory_flag ;
786 	        l_com_op_unexp_rec.Run_mandatory_flag              := l_stdop_rec.Run_mandatory_flag ;
787 	        l_com_op_unexp_rec.To_move_mandatory_flag          := l_stdop_rec.To_move_mandatory_flag ;
788 	        l_com_op_unexp_rec.Show_next_op_by_default         := l_stdop_rec.Show_next_op_by_default ;
789 	        l_com_op_unexp_rec.Show_scrap_code	           := l_stdop_rec.Show_scrap_code ;
790 	        l_com_op_unexp_rec.Show_lot_attrib	           := l_stdop_rec.Show_lot_attrib ;
791    	        l_com_op_unexp_rec.Track_multiple_res_usage_dates  := l_stdop_rec.Track_multiple_res_usage_dates ; -- End of MES Changes
792 
793 
794                 -- Added condition for Bug1744254
795                 IF BOM_Rtg_Globals.Get_CFM_Rtg_Flag = BOM_Rtg_Globals.G_LOT_RTG THEN
796                     l_com_operation_rec.op_yield_enabled_flag := l_stdop_rec.operation_yield_enabled;
797                     l_com_operation_rec.yield := l_stdop_rec.yield; --bug 3572770
798                 END IF ;
799 
800              END LOOP ; -- copy standard operation
801 
802           END IF ; -- Ref Flag is Yes
803 
804        END IF ; -- Acd Type : Add
805 
806 IF BOM_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug
807     ('Default Standard Operation Attributes  was processed. . . ' || l_return_status);
808 END IF ;
809 
810        --
811        -- Return Common Operation Record
812        --
813        x_com_operation_rec  := l_com_operation_rec ;
814        x_com_op_unexp_rec   := l_com_op_unexp_rec ;
815 
816        --
817        -- Return Error Status
818        --
819        x_return_status  := l_return_status;
820        x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
821 
822 
823     EXCEPTION
824        WHEN EXIT_CHECK_REF_STD_OP THEN
825 
826           --
827           -- Return Common Operation Record
828           --
829           x_com_operation_rec  := l_com_operation_rec ;
830           x_com_op_unexp_rec   := l_com_op_unexp_rec ;
831 
835           x_return_status  := l_return_status;
832           --
833           -- Return Error Status
834           --
836           x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
837 
838 
839        WHEN OTHERS THEN
840           IF BOM_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug
841           ('Some unknown error in Entity Validation(Default Std Op) . . .' || SQLERRM );
842           END IF ;
843 
844 
845           l_err_text := G_PKG_NAME || ' Validation (Entity Validation(Default Std Op)) '
846                                 || substrb(SQLERRM,1,200);
847           -- dbms_output.put_line('Unexpected Error: '||l_err_text);
848 
849           Error_Handler.Add_Error_Token
850           (  p_message_name   => NULL
851            , p_message_text   => l_err_text
852            , p_mesg_token_tbl => l_mesg_token_tbl
853            , x_mesg_token_tbl => l_mesg_token_tbl
854           ) ;
855 
856           -- Return the status and message table.
857           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
858           x_mesg_token_tbl := l_mesg_token_tbl ;
859 
860     END Default_Std_Op_Attributes;
861 
862     /*********************************************************************
863     * Procedure : Attribute_Defaulting by RTG BO
864     * Parameters IN : Operation exposed column record
865     *                 Operation unexposed column record
866     * Parameters out: Operation exposed column record after defaulting
867     *                 Operation unexposed column record after defaulting
868     *                 Return Status
869     *                 Message Token Table
870     * Purpose   : Convert Routing Operation to Common Operation and
871     *             Call Attribute_Defaulting for Common
872     *             This procedure will default values in all the operation
873     *             fields that the user has left unfilled.
874     **********************************************************************/
875     PROCEDURE Attribute_Defaulting
876     (  p_operation_rec     IN  Bom_Rtg_Pub.Operation_Rec_Type
877      , p_op_unexp_rec      IN  Bom_Rtg_Pub.Op_Unexposed_Rec_Type
878      , x_operation_rec     IN OUT NOCOPY Bom_Rtg_Pub.Operation_Rec_Type
879      , x_op_unexp_rec      IN OUT NOCOPY Bom_Rtg_Pub.Op_Unexposed_Rec_Type
880      , x_mesg_token_tbl    IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
881      , x_return_status     IN OUT NOCOPY VARCHAR2
882     )
883     IS
884         l_com_operation_rec      Bom_Rtg_Pub.Com_Operation_Rec_Type ;
885         l_com_op_unexp_rec       Bom_Rtg_Pub.Com_Op_Unexposed_Rec_Type ;
886 
887         l_return_status VARCHAR2(1);
888         l_err_text  VARCHAR2(2000) ;
889         l_Mesg_Token_Tbl    Error_Handler.Mesg_Token_Tbl_Type;
890 
891     BEGIN
892 
893         x_return_status := FND_API.G_RET_STS_SUCCESS;
894 
895         -- Convert Routing Operation to Common Operation
896         Bom_Rtg_Pub.Convert_RtgOp_To_ComOp
897         (  p_rtg_operation_rec      => p_operation_rec
898          , p_rtg_op_unexp_rec       => p_op_unexp_rec
899          , x_com_operation_rec      => l_com_operation_rec
900          , x_com_op_unexp_rec       => l_com_op_unexp_rec
901         ) ;
902 
903 
904         -- Once the record transfer is done call the common
905         -- operation attribute defaulting
906         --
907         BOM_Default_Op_Seq.Attribute_Defaulting
908         (  p_com_operation_rec     => l_com_operation_rec
909          , p_com_op_unexp_rec      => l_com_op_unexp_rec
910          , p_control_Rec => Bom_Rtg_Pub.G_Default_Control_Rec
911          , x_com_operation_rec     => l_com_operation_rec
912          , x_com_op_unexp_rec      => l_com_op_unexp_rec
913          , x_return_status         => x_return_status
914          , x_mesg_token_tbl        => x_mesg_token_tbl
915         ) ;
916 
917 
918         -- Convert the Common record to Routing Record
919         Bom_Rtg_Pub.Convert_ComOp_To_RtgOp
920         (  p_com_operation_rec      => l_com_operation_rec
921          , p_com_op_unexp_rec       => l_com_op_unexp_rec
922          , x_rtg_operation_rec      => x_operation_rec
923          , x_rtg_op_unexp_rec       => x_op_unexp_rec
924          ) ;
925 
926 
927     END Attribute_Defaulting ;
928 
929     /********************************************************************
930     * Procedure : Attribute_Defaulting by ECO BO
931     * Parameters IN : Revised Operation exposed column record
932     *                 Revised Operation unexposed column record
933     * Parameters out: Revised Operation exposed column record after defaulting
934     *                 Revised Operation unexposed column record after defaulting
935     *                 Return Status
936     *                 Message Token Table
937     * Purpose   : Convert Routing Operation to Common Operation and
938     *             Call Attribute_Defaulting for Common
939     *             This procedure will default values in all the operation.
940     *             fields that the user has left unfilled.
941     *********************************************************************/
942     PROCEDURE Attribute_Defaulting
943     (  p_rev_operation_rec    IN  Bom_Rtg_Pub.Rev_Operation_Rec_Type
944      , p_rev_op_unexp_rec     IN  Bom_Rtg_Pub.Rev_Op_Unexposed_Rec_Type
945      , p_control_Rec          IN  Bom_Rtg_Pub.Control_Rec_Type
946      , x_rev_operation_rec    IN OUT NOCOPY Bom_Rtg_Pub.Rev_Operation_Rec_Type
950     )
947      , x_rev_op_unexp_rec     IN OUT NOCOPY Bom_Rtg_Pub.Rev_Op_Unexposed_Rec_Type
948      , x_mesg_token_tbl       IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
949      , x_return_status        IN OUT NOCOPY VARCHAR2
951     IS
952         l_com_operation_rec      Bom_Rtg_Pub.Com_Operation_Rec_Type ;
953         l_com_op_unexp_rec       Bom_Rtg_Pub.Com_Op_Unexposed_Rec_Type ;
954 
955         l_return_status VARCHAR2(1);
956         l_err_text  VARCHAR2(2000) ;
957         l_Mesg_Token_Tbl    Error_Handler.Mesg_Token_Tbl_Type;
958 
959     BEGIN
960 
961         x_return_status := FND_API.G_RET_STS_SUCCESS;
962 
963 
964         -- Convert Revised Operation to Common Operation
965         Bom_Rtg_Pub.Convert_EcoOp_To_ComOp
966         (  p_rev_operation_rec      => p_rev_operation_rec
967          , p_rev_op_unexp_rec       => p_rev_op_unexp_rec
968          , x_com_operation_rec      => l_com_operation_rec
969          , x_com_op_unexp_rec       => l_com_op_unexp_rec
970         ) ;
971 
972 
973         -- Once the record transfer is done call the common
974         -- operation attribute defaulting
975         --
976         BOM_Default_Op_Seq.Attribute_Defaulting
977         (  p_com_operation_rec     => l_com_operation_rec
978          , p_com_op_unexp_rec      => l_com_op_unexp_rec
979          , p_control_Rec => Bom_Rtg_Pub.G_Default_Control_Rec
980          , x_com_operation_rec     => l_com_operation_rec
981          , x_com_op_unexp_rec      => l_com_op_unexp_rec
982          , x_return_status         => x_return_status
983          , x_mesg_token_tbl        => x_mesg_token_tbl
984         ) ;
985 
986         -- Convert the Common record to Revised Operation record
987         Bom_Rtg_Pub.Convert_ComOp_To_EcoOp
988         (  p_com_operation_rec      => l_com_operation_rec
989          , p_com_op_unexp_rec       => l_com_op_unexp_rec
990          , x_rev_operation_rec      => x_rev_operation_rec
991          , x_rev_op_unexp_rec       => x_rev_op_unexp_rec
992          ) ;
993 
994     END Attribute_Defaulting ;
995 
996 
997 
998     /********************************************************************
999     * Procedure : Attribute_Defaulting for Common
1000     *                       and internally called by RTG BO and ECO BO
1001     * Parameters IN : Common Operation exposed column record
1002     *                 Common Operation unexposed column record
1003     * Parameters out: Common Operation exposed column record after defaulting
1004     *                 Common Operation unexposed column record after defaulting
1005     *                 Return Status
1006     *                 Message Token Table
1007     * Purpose   : Attribute defaulting proc. defualts columns to
1008     *             appropriate values. Defualting will happen for
1009     *             exposed as well as unexposed columns.
1010     *********************************************************************/
1011     PROCEDURE Attribute_Defaulting
1012     (  p_com_operation_rec    IN  Bom_Rtg_Pub.Com_Operation_Rec_Type
1013      , p_com_op_unexp_rec     IN  Bom_Rtg_Pub.Com_Op_Unexposed_Rec_Type
1014      , p_control_Rec          IN  Bom_Rtg_Pub.Control_Rec_Type
1015      , x_com_operation_rec    IN OUT NOCOPY Bom_Rtg_Pub.Com_Operation_Rec_Type
1016      , x_com_op_unexp_rec     IN OUT NOCOPY Bom_Rtg_Pub.Com_Op_Unexposed_Rec_Type
1017      , x_mesg_token_tbl       IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
1018      , x_return_status        IN OUT NOCOPY VARCHAR2
1019     )
1020 
1021     IS
1022 
1023         l_com_operation_rec      Bom_Rtg_Pub.Com_Operation_Rec_Type ;
1024         l_com_op_unexp_rec       Bom_Rtg_Pub.Com_Op_Unexposed_Rec_Type ;
1025 
1026         l_return_status VARCHAR2(1);
1027         l_temp_return_status VARCHAR2(1);
1028         l_err_text  VARCHAR2(2000) ;
1029         l_Mesg_Token_Tbl    Error_Handler.Mesg_Token_Tbl_Type;
1030         l_Temp_Mesg_Token_Tbl    Error_Handler.Mesg_Token_Tbl_Type;
1031 
1032 
1033     BEGIN
1034 
1035             IF BOM_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug
1036             ('Within the Rev. Operation Attr. Defaulting...') ;
1037             END IF ;
1038 
1039             l_return_status := FND_API.G_RET_STS_SUCCESS ;
1040             x_return_status := FND_API.G_RET_STS_SUCCESS ;
1041 
1042             --  Initialize operation exp and unexp record
1043             l_com_operation_rec  := p_com_operation_rec ;
1044             l_com_op_unexp_rec   := p_com_op_unexp_rec ;
1045 
1046             /***********************************************************
1047             --
1048             -- Default ACD Type
1049             --
1050             ***********************************************************/
1051 
1052             IF l_com_operation_rec.acd_type  =  FND_API.G_MISS_NUM
1053             THEN
1054                 l_com_operation_rec.acd_type  := NULL ;
1055             END IF;
1056 
1057 
1058 
1059             /***********************************************************
1060             --
1061             -- Default Operation_Sequence_Id
1062             --
1063             ***********************************************************/
1064             IF l_com_op_unexp_rec.operation_sequence_id IS NULL OR
1065                l_com_op_unexp_rec.operation_sequence_id = FND_API.G_MISS_NUM
1066             THEN
1067 
1068                 l_com_op_unexp_rec.operation_sequence_id :=
1069                 Get_Operation_Sequence_Id ;
1073             --
1070             END IF ;
1071 
1072             /***********************************************************
1074             -- Default Operation_Type
1075             --
1076             ***********************************************************/
1077             IF ( BOM_Rtg_Globals.Get_CFM_Rtg_Flag <> BOM_Rtg_Globals.G_FLOW_RTG
1078                  OR BOM_Rtg_Globals.Get_Bo_Identifier = BOM_Rtg_Globals.G_ECO_BO
1079                )
1080                AND (  l_com_operation_rec.operation_type IS NULL
1081                    OR l_com_operation_rec.operation_type =  FND_API.G_MISS_NUM
1082                   )
1083             THEN
1084                l_com_operation_rec.operation_type :=
1085                Get_Operation_Type ;
1086             END IF ;
1087 
1088 
1089             /***********************************************************
1090             --
1091             -- Default Effectivity_Date for Process/Line Op in Flow Rtg
1092             --
1093             ***********************************************************/
1094             IF ( BOM_Rtg_Globals.Get_CFM_Rtg_Flag = BOM_Rtg_Globals.G_FLOW_RTG
1095                  OR BOM_Rtg_Globals.Get_Bo_Identifier = BOM_Rtg_Globals.G_RTG_BO)
1096             AND  l_com_operation_rec.operation_type IN (l_PROCESS ,l_LINE_OP )
1097             THEN
1098                l_com_operation_rec.start_effective_date :=
1099                Get_Start_Effective_Date ;
1100             END IF ;
1101 
1102 
1103             /************************************************************
1104             --
1105             -- Default Reference_Flag
1106             --
1107             ************************************************************/
1108 
1109             IF l_com_operation_rec.reference_flag IS NULL OR
1110                l_com_operation_rec.reference_flag = FND_API.G_MISS_NUM
1111             THEN
1112                l_com_operation_rec.reference_flag :=
1113                     Get_Reference_Flag
1114                     (p_std_op_code => l_com_operation_rec.standard_operation_code ) ;
1115             END IF ;
1116 
1117             /************************************************************
1118             --
1119             -- Default Option_Dependent_Flag
1120             --
1121             ************************************************************/
1122 
1123             IF l_com_operation_rec.option_dependent_flag IS NULL OR
1124                l_com_operation_rec.option_dependent_flag = FND_API.G_MISS_NUM
1125             THEN
1126                 l_com_operation_rec.option_dependent_flag :=
1127                     Get_Option_Dependent_Flag
1128                     (  p_revised_item_id        => l_com_op_unexp_rec.revised_item_id
1129                      , p_organization_id        => l_com_op_unexp_rec.organization_id
1130                     ) ;
1131             END IF;
1132 
1133 
1134 
1135             IF ( l_com_operation_rec.standard_operation_code IS NULL
1136                 OR l_com_operation_rec.standard_operation_code = FND_API.G_MISS_CHAR
1137                )
1138             THEN
1139 
1140                 /*********************************************************
1141                 --
1142                 -- Default Count_Point_Type
1143                 --
1144                 ***********************************************************/
1145 
1146                 IF l_com_operation_rec.count_point_type IS NULL OR
1147                  l_com_operation_rec.count_point_type =  FND_API.G_MISS_NUM
1148                 THEN
1149 
1150                     l_com_operation_rec.count_point_type :=
1151                     Get_Count_Point_Type ;
1152                 END IF;
1153 
1154                 /************************************************************
1155                 --
1156                 -- Default BackFlush_Flag
1157                 --
1158                 ************************************************************/
1159 
1160                 IF l_com_operation_rec.backflush_flag IS NULL OR
1161                    l_com_operation_rec.backflush_flag = FND_API.G_MISS_NUM
1162                 THEN
1163                    l_com_operation_rec.backflush_flag :=
1164                     Get_BackFlush_Flag ;
1165                 END IF;
1166 
1167                 /************************************************************
1168                 -- Option Dependent should be defaulted even if Std Op is not NULL
1169                 -- Default Option_Dependent_Flag
1170                 --
1171                 IF l_com_operation_rec.option_dependent_flag IS NULL OR
1172                    l_com_operation_rec.option_dependent_flag = FND_API.G_MISS_NUM
1173                 THEN
1174                    l_com_operation_rec.option_dependent_flag :=
1175                     Get_Option_Dependent_Flag
1176                     (  p_revised_item_id        => l_com_op_unexp_rec.revised_item_id
1177                      , p_organization_id        => l_com_op_unexp_rec.organization_id
1178                     ) ;
1179                 END IF;
1180 
1181                 ************************************************************/
1182 
1183                 /************************************************************
1184                 --
1185                 -- Default Minimum_Transfer_Quantity
1186                 --
1187                 ************************************************************/
1188 
1189                 IF l_com_operation_rec.minimum_transfer_quantity IS NULL OR
1193                     Get_Minimum_Transfer_Quantity ;
1190                    l_com_operation_rec.minimum_transfer_quantity = FND_API.G_MISS_NUM
1191                 THEN
1192                    l_com_operation_rec.minimum_transfer_quantity :=
1194                 END IF;
1195 
1196 
1197             ELSE
1198 
1199                 /************************************************************
1200                 --
1201                 -- Defualt Std Op Attributes
1202                 --
1203                 ************************************************************/
1204                Default_Std_Op_Attributes
1205                ( p_com_operation_rec     => l_com_operation_rec
1206                , p_com_op_unexp_rec      => l_com_op_unexp_rec
1207                , x_com_operation_rec     => l_com_operation_rec
1208                , x_com_op_unexp_rec      => l_com_op_unexp_rec
1209                , x_return_status         => l_temp_return_status
1210                , x_mesg_token_tbl        => l_temp_mesg_token_tbl
1211                ) ;
1212 
1213 
1214                IF l_temp_return_status = FND_API.G_RET_STS_ERROR
1215                THEN
1216                    l_mesg_token_tbl := l_temp_mesg_token_tbl ;
1217                    l_return_status  := FND_API.G_RET_STS_ERROR ;
1218                END IF ;
1219 
1220 
1221             END IF ; -- if Std Op is null or not null
1222 
1223 
1224 
1225             -- Check if the parent routing is Flow Routing
1226             IF    BOM_Rtg_Globals.Get_CFM_Rtg_Flag = BOM_Rtg_Globals.G_FLOW_RTG
1227             THEN
1228                IF BOM_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug
1229                 ('Attr. Defaulting for Flow Routing...' || to_char(l_com_op_unexp_rec.routing_sequence_id)) ;
1230                END IF ;
1231 
1232                /************************************************************
1233                --
1234                -- Default User_Labor_Time
1235                --
1236                ************************************************************/
1237 
1238                 IF l_com_operation_rec.user_labor_time IS NULL OR
1239                    l_com_operation_rec.user_labor_time = FND_API.G_MISS_NUM
1240                 THEN
1241                    l_com_operation_rec.user_labor_time := Get_User_Labor_Time ;
1242                 END IF ;
1243 
1244 
1245                /************************************************************
1246                --
1247                -- Default User_Machine_Time
1248                --
1249                ************************************************************/
1250 
1251                 IF l_com_operation_rec.user_machine_time IS NULL OR
1252                    l_com_operation_rec.user_machine_time = FND_API.G_MISS_NUM
1253                 THEN
1254                    l_com_operation_rec.user_machine_time := Get_User_Machine_Time ;
1255                 END IF ;
1256 
1257 
1258                /************************************************************
1259                --
1260                -- Default User_Elapsed_Time
1261                --
1262                -- Defaulting User_Elapsed Time is moved to Entity Defaulting
1263                 IF l_com_operation_rec.user_elapsed_time IS NULL OR
1264                    l_com_operation_rec.user_elapsed_time = FND_API.G_MISS_NUM
1265                 THEN
1266                    l_com_operation_rec.user_elapsed_time :=
1267                       Get_User_Elapsed_Time ;
1268                 END IF ;
1269                ************************************************************/
1270             END IF ;
1271 
1272 
1273             -- Removed condition for Bug1744254
1274             -- Include_In_Rollup and Op_Yield_Enabled_Flag are not
1275             -- only for Lot Based Routing
1276 
1277             -- Check if the parent routing is Lot Based Routing
1278             -- IF    BOM_Rtg_Globals.Get_CFM_Rtg_Flag = BOM_Rtg_Globals.G_LOT_RTG
1279             -- THEN
1280 
1281             --   IF BOM_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug
1282             --    ('Attr. Defaulting for Lot Based Routing...' || to_char(l_com_op_unexp_rec.routing_sequence_id)) ;
1283             --   END IF ;
1284 
1285                /************************************************************
1286                --
1287                -- Default Include_In_Rollup
1288                --
1289                ************************************************************/
1290 
1291                 IF l_com_operation_rec.include_in_rollup IS NULL OR
1292                    l_com_operation_rec.include_in_rollup = FND_API.G_MISS_NUM
1293                 THEN
1294                    l_com_operation_rec.include_in_rollup := Get_Include_In_Rollup ;
1295                 END IF ;
1296 
1297 
1298                /************************************************************
1299                --
1300                -- Default Op_Yield_Enabled_Flag
1301                --
1302                ************************************************************/
1303 
1304                 IF l_com_operation_rec.op_yield_enabled_flag IS NULL OR
1305                    l_com_operation_rec.op_yield_enabled_flag = FND_API.G_MISS_NUM
1306                 THEN
1307                    l_com_operation_rec.op_yield_enabled_flag := Get_Op_Yield_Enabled_Flag ;
1308                 END IF ;
1309 
1310             -- END IF ;
1311 
1312 
1316             --
1313             /*************************************************************
1314             --
1315             -- Default Routing_Sequence_Id
1317             --
1318             **************************************************************/
1319 
1320             IF l_com_op_unexp_rec.routing_sequence_id IS NULL
1321                AND BOM_Rtg_Globals.Get_Bo_Identifier = BOM_Rtg_Globals.G_ECO_BO
1322                AND l_com_operation_rec.transaction_type = BOM_Rtg_Globals.G_OPR_CREATE
1323                AND l_com_operation_rec.acd_type = 1 -- Add
1324             THEN
1325                 l_com_op_unexp_rec.routing_sequence_id :=
1326                 Get_Routing_Sequence_Id
1327                   (  p_revised_item_id        => l_com_op_unexp_rec.revised_item_id
1328                    , p_organization_id        => l_com_op_unexp_rec.organization_id
1329                    , p_alternate_routing_code => l_com_operation_rec.alternate_routing_code) ;
1330 
1331 
1332                IF BOM_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug
1333                 ('Generated Routing_Sequence_Id...' || to_char(l_com_op_unexp_rec.routing_sequence_id)) ;
1334                END IF ;
1335             END IF ;
1336 
1337 
1338             /***********************************************************
1339             --
1340             -- Default Old_Operation_Sequence_Number
1341             --
1342             ***********************************************************/
1343             IF ( BOM_Rtg_Globals.Get_Bo_Identifier = BOM_Rtg_Globals.G_ECO_BO
1344                )
1345                AND (  l_com_operation_rec.old_operation_sequence_number IS NULL
1346                    OR l_com_operation_rec.old_operation_sequence_number =  FND_API.G_MISS_NUM
1347                   )
1348                AND l_com_operation_rec.transaction_type = BOM_Rtg_Globals.G_OPR_CREATE
1349                AND l_com_operation_rec.acd_type IN (2,3 )  -- Add
1350             THEN
1351                l_com_operation_rec.old_operation_sequence_number :=
1352                    l_com_operation_rec.operation_sequence_number ;
1353             END IF ;
1354 /* Added for Bug 3117219  */
1355 
1356           IF  BOM_Rtg_Globals.Get_Bo_Identifier = BOM_Rtg_Globals.G_ECO_BO
1357             AND l_com_operation_rec.disable_date is NULL
1358              AND l_com_operation_rec.acd_type = 3 then
1359 
1360               l_com_operation_rec.disable_date :=
1361                                     l_com_operation_rec.start_effective_date;
1362 
1363 
1364           END IF;
1365 /* end of Bug 3117219 */
1366             /*************************************************************
1367             --
1368             -- Default Old_Operation_Sequence_Id
1369             --
1370             --
1371             **************************************************************/
1372 
1373             IF (l_com_op_unexp_rec.old_operation_sequence_id IS NULL
1374                 OR l_com_op_unexp_rec.old_operation_sequence_id = FND_API.G_MISS_NUM)
1375                AND BOM_Rtg_Globals.Get_Bo_Identifier = BOM_Rtg_Globals.G_ECO_BO
1376                AND l_com_operation_rec.transaction_type = BOM_Rtg_Globals.G_OPR_CREATE
1377                AND l_com_operation_rec.acd_type = 1 -- Add
1378             THEN
1379                 l_com_op_unexp_rec.old_operation_sequence_id :=  l_com_op_unexp_rec.operation_sequence_id ;
1380 
1381                IF BOM_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug
1382                 ('Set current op seq id to old op seq id as default value.')  ;
1383                END IF ;
1384             END IF ;
1385 
1386             /************************************************************
1387             --
1388             -- Default Operation Sequence's FlexFields
1389             --
1390             ************************************************************/
1391 
1392             IF  l_com_operation_rec.attribute_category = FND_API.G_MISS_CHAR
1393             OR  l_com_operation_rec.attribute1  = FND_API.G_MISS_CHAR
1394             OR  l_com_operation_rec.attribute2  = FND_API.G_MISS_CHAR
1395             OR  l_com_operation_rec.attribute3  = FND_API.G_MISS_CHAR
1396             OR  l_com_operation_rec.attribute4  = FND_API.G_MISS_CHAR
1397             OR  l_com_operation_rec.attribute5  = FND_API.G_MISS_CHAR
1398             OR  l_com_operation_rec.attribute6  = FND_API.G_MISS_CHAR
1399             OR  l_com_operation_rec.attribute7  = FND_API.G_MISS_CHAR
1400             OR  l_com_operation_rec.attribute8  = FND_API.G_MISS_CHAR
1401             OR  l_com_operation_rec.attribute9  = FND_API.G_MISS_CHAR
1402             OR  l_com_operation_rec.attribute10 = FND_API.G_MISS_CHAR
1403             OR  l_com_operation_rec.attribute11 = FND_API.G_MISS_CHAR
1404             OR  l_com_operation_rec.attribute12 = FND_API.G_MISS_CHAR
1405             OR  l_com_operation_rec.attribute13 = FND_API.G_MISS_CHAR
1406             OR  l_com_operation_rec.attribute14 = FND_API.G_MISS_CHAR
1407             OR  l_com_operation_rec.attribute15 = FND_API.G_MISS_CHAR
1408             THEN
1409 
1410                 Get_Flex_Op_Seq(  p_com_operation_rec => l_com_operation_rec
1411                                 , x_com_operation_rec => l_com_operation_rec ) ;
1412 
1413             END IF;
1414 
1415         x_com_operation_rec := l_com_operation_rec ;
1416         x_com_op_unexp_rec  := l_com_op_unexp_rec ;
1417         x_return_status     := l_return_status ;
1418         x_mesg_token_tbl    := l_mesg_token_tbl ;
1419 
1420         IF BOM_Rtg_Globals.Get_Debug = 'Y' THEN
1424 
1421          Error_Handler.Write_Debug('Getting out of Operation Attribute Defualting...');
1422         END IF ;
1423 
1425     EXCEPTION
1426        WHEN OTHERS THEN
1427           IF BOM_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug
1428           ('Some unknown error in Attribute Defaulting . . .' || SQLERRM );
1429           END IF ;
1430 
1431 
1432           l_err_text := G_PKG_NAME || ' Default (Attr. Defaulting) '
1433                                 || substrb(SQLERRM,1,200);
1434           -- dbms_output.put_line('Unexpected Error: '||l_err_text);
1435 
1436           Error_Handler.Add_Error_Token
1437           (  p_message_name   => NULL
1438            , p_message_text   => l_err_text
1439            , p_mesg_token_tbl => l_mesg_token_tbl
1440            , x_mesg_token_tbl => l_mesg_token_tbl
1441           ) ;
1442 
1443           -- Return the status and message table.
1444           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1445           x_mesg_token_tbl := l_mesg_token_tbl ;
1446 
1447 
1448     END Attribute_Defaulting ;
1449 
1450 
1451 
1452     /******************************************************************
1453     * Procedure : Populate_Null_Columns used by Rtg BO(Update or Delete)
1454     * Parameters IN : Operation exposed column record
1455     *                 Operation unexposed column record
1456     *                 Old Operation exposed column record
1457     *                 Old Operation unexposed column record
1458     * Parameters out: Operation exposed column record after populating null columns
1459     *                 Operation unexposed column record after populating null columns
1460     * Purpose   : Convert Routing Operation to Common Operation and
1461     *             Call Populate_Null_Columns for Common.
1462     *             The procedure will populate the NULL columns from the record that
1463     *             is queried from the database.
1464     ********************************************************************/
1465     PROCEDURE Populate_Null_Columns
1466     (  p_operation_rec          IN  Bom_Rtg_Pub.Operation_Rec_Type
1467      , p_op_unexp_rec           IN  Bom_Rtg_Pub.Op_Unexposed_Rec_Type
1468      , p_old_operation_rec      IN  Bom_Rtg_Pub.Operation_Rec_Type
1469      , p_old_op_unexp_rec       IN  Bom_Rtg_Pub.Op_Unexposed_Rec_Type
1470      , x_operation_rec          IN OUT NOCOPY Bom_Rtg_Pub.Operation_Rec_Type
1471      , x_op_unexp_rec           IN OUT NOCOPY Bom_Rtg_Pub.Op_Unexposed_Rec_Type
1472     )
1473 
1474     IS
1475         l_com_operation_rec      Bom_Rtg_Pub.Com_Operation_Rec_Type ;
1476         l_com_op_unexp_rec       Bom_Rtg_Pub.Com_Op_Unexposed_Rec_Type ;
1477         l_old_com_operation_rec  Bom_Rtg_Pub.Com_Operation_Rec_Type ;
1478         l_old_com_op_unexp_rec   Bom_Rtg_Pub.Com_Op_Unexposed_Rec_Type ;
1479 
1480 
1481     BEGIN
1482 
1483         -- Convert Routing Operation to Common Operation
1484         Bom_Rtg_Pub.Convert_RtgOp_To_ComOp
1485         (  p_rtg_operation_rec      => p_operation_rec
1486          , p_rtg_op_unexp_rec       => p_op_unexp_rec
1487          , x_com_operation_rec      => l_com_operation_rec
1488          , x_com_op_unexp_rec       => l_com_op_unexp_rec
1489         ) ;
1490 
1491         -- Also Convert Old Routing Operation to Old Common Operation
1492         Bom_Rtg_Pub.Convert_RtgOp_To_ComOp
1493         (  p_rtg_operation_rec      => p_old_operation_rec
1494          , p_rtg_op_unexp_rec       => p_old_op_unexp_rec
1495          , x_com_operation_rec      => l_old_com_operation_rec
1496          , x_com_op_unexp_rec       => l_old_com_op_unexp_rec
1497         ) ;
1498 
1499         --
1500         -- Once the record transfer is done call the common
1501         -- operation populate null columns
1502         --
1503         Bom_Default_Op_Seq.Populate_Null_Columns
1504         (  p_com_operation_rec     => l_com_operation_rec
1505          , p_com_op_unexp_rec      => l_com_op_unexp_rec
1506          , p_old_com_operation_rec => l_old_com_operation_rec
1507          , p_old_com_op_unexp_rec  => l_old_com_op_unexp_rec
1508          , x_com_operation_rec     => l_com_operation_rec
1509          , x_com_op_unexp_rec      => l_com_op_unexp_rec
1510         ) ;
1511 
1512         --
1513         -- On return from the populate null columns, save the defaulted
1514         -- record back in the RTG BO's records
1515         --
1516 
1517         -- Convert the Common record to Routing Record
1518         Bom_Rtg_Pub.Convert_ComOp_To_RtgOp
1519         (  p_com_operation_rec      => l_com_operation_rec
1520          , p_com_op_unexp_rec       => l_com_op_unexp_rec
1521          , x_rtg_operation_rec      => x_operation_rec
1522          , x_rtg_op_unexp_rec       => x_op_unexp_rec
1523          ) ;
1524 
1525     END Populate_Null_Columns;
1526 
1527 
1528 
1529 
1530     /******************************************************************
1531     * Procedure : Populate_Null_Columns used
1532     *            used by ECO BO(Update, Delete or Create with ACD_Type:2 Change)
1533     * Parameters IN : Revised Operation exposed column record
1534     *                 Revised Operation unexposed column record
1535     *                 Old Revised Operation exposed column record
1536     *                 Old Revised Operation unexposed column record
1537     * Parameters out: Revised Operation exposed column record after
1538     *                 populating null columns
1539     *                 Revised Operation unexposed column record after
1543     *             The procedure will populate the NULL columns from the record that
1540     *                 populating null columns
1541     * Purpose   : Convert Revised Operation to Common Operation and
1542     *             Call Populate_Null_Columns for Common.
1544     *             is queried from the database.
1545     ********************************************************************/
1546     PROCEDURE Populate_Null_Columns
1547     (  p_rev_operation_rec      IN  Bom_Rtg_Pub.Rev_Operation_Rec_Type
1548      , p_rev_op_unexp_rec       IN  Bom_Rtg_Pub.Rev_Op_Unexposed_Rec_Type
1549      , p_old_rev_operation_rec  IN  Bom_Rtg_Pub.Rev_Operation_Rec_Type
1550      , p_old_rev_op_unexp_rec   IN  Bom_Rtg_Pub.Rev_Op_Unexposed_Rec_Type
1551      , x_rev_operation_rec      IN OUT NOCOPY Bom_Rtg_Pub.Rev_Operation_Rec_Type
1552      , x_rev_op_unexp_rec       IN OUT NOCOPY Bom_Rtg_Pub.Rev_Op_Unexposed_Rec_Type )
1553     IS
1554         l_com_operation_rec      Bom_Rtg_Pub.Com_Operation_Rec_Type ;
1555         l_com_op_unexp_rec       Bom_Rtg_Pub.Com_Op_Unexposed_Rec_Type ;
1556         l_old_com_operation_rec  Bom_Rtg_Pub.Com_Operation_Rec_Type ;
1557         l_old_com_op_unexp_rec   Bom_Rtg_Pub.Com_Op_Unexposed_Rec_Type ;
1558 
1559 
1560     BEGIN
1561 
1562 
1563         -- Convert Revised Operation to Common Operation
1564         Bom_Rtg_Pub.Convert_EcoOp_To_ComOp
1565         (  p_rev_operation_rec      => p_rev_operation_rec
1566          , p_rev_op_unexp_rec       => p_rev_op_unexp_rec
1567          , x_com_operation_rec      => l_com_operation_rec
1568          , x_com_op_unexp_rec       => l_com_op_unexp_rec
1569         ) ;
1570 
1571         -- Also Convert Old Revised Operation to Old Common Operation
1572         Bom_Rtg_Pub.Convert_EcoOp_To_ComOp
1573         (  p_rev_operation_rec      => p_old_rev_operation_rec
1574          , p_rev_op_unexp_rec       => p_old_rev_op_unexp_rec
1575          , x_com_operation_rec      => l_old_com_operation_rec
1576          , x_com_op_unexp_rec       => l_old_com_op_unexp_rec
1577         ) ;
1578 
1579 
1580         --
1581         -- Once the record transfer is done call the
1582         -- common operation populate null columns
1583         --
1584         Bom_Default_Op_Seq.Populate_Null_Columns
1585         (  p_com_operation_rec     => l_com_operation_rec
1586          , p_com_op_unexp_rec      => l_com_op_unexp_rec
1587          , p_old_com_operation_rec => l_old_com_operation_rec
1588          , p_old_com_op_unexp_rec  => l_old_com_op_unexp_rec
1589          , x_com_operation_rec     => l_com_operation_rec
1590          , x_com_op_unexp_rec      => l_com_op_unexp_rec
1591         ) ;
1592 
1593         --
1594         -- On return from the populate null columns, save the defaulted
1595         -- record back in the RTG BO's records
1596         --
1597 
1598         -- Convert the Common record to Revised Operation record
1599         Bom_Rtg_Pub.Convert_ComOp_To_EcoOp
1600         (  p_com_operation_rec      => l_com_operation_rec
1601          , p_com_op_unexp_rec       => l_com_op_unexp_rec
1602          , x_rev_operation_rec      => x_rev_operation_rec
1603          , x_rev_op_unexp_rec       => x_rev_op_unexp_rec
1604          ) ;
1605 
1606     END Populate_Null_Columns;
1607 
1608 
1609     /*******************************************************************
1610     * Procedure : Populate_Null_Columns for Common
1611     *             and internally called by RTG BO and ECO BO
1612     * Parameters IN : Common Operation exposed column record
1613     *                 Common Operation unexposed column record
1614     *                 Old Common Operation exposed column record
1615     *                 Old Common Operation unexposed column record
1616     * Parameters out: Common Operation exposed column record after populating null columns
1617     *                 Common Operation unexposed column record after populating null columns
1618     * Purpose   : Complete record will compare the database record with
1619     *             the user given record and will complete the user
1620     *             record with values from the database record, for all
1621     *             columns that the user has left NULL.
1622     ********************************************************************/
1623     PROCEDURE Populate_Null_Columns
1624     (  p_com_operation_rec      IN  Bom_Rtg_Pub.Com_Operation_Rec_Type
1625      , p_com_op_unexp_rec       IN  Bom_Rtg_Pub.Com_Op_Unexposed_Rec_Type
1626      , p_old_com_operation_rec  IN  Bom_Rtg_Pub.Com_Operation_Rec_Type
1627      , p_old_com_op_unexp_rec   IN  Bom_Rtg_Pub.Com_Op_Unexposed_Rec_Type
1628      , x_com_operation_rec      IN OUT NOCOPY Bom_Rtg_Pub.Com_Operation_Rec_Type
1629      , x_com_op_unexp_rec       IN OUT NOCOPY Bom_Rtg_Pub.Com_Op_Unexposed_Rec_Type
1630     )
1631     IS
1632 
1633        l_com_operation_rec      Bom_Rtg_Pub.Com_Operation_Rec_Type ;
1634        l_com_op_unexp_rec       Bom_Rtg_Pub.Com_Op_Unexposed_Rec_Type ;
1635 
1636     BEGIN
1637             IF BOM_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug
1638                  ('Within the Rev. Operation Populate null columns...') ;
1639             END IF ;
1640 
1641             --  Initialize operation exp and unexp record
1642             l_com_operation_rec  := p_com_operation_rec ;
1643             l_com_op_unexp_rec   := p_com_op_unexp_rec ;
1644 
1645 
1646             -- Exposed Column
1647             IF BOM_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug
1651             IF l_com_operation_rec.operation_type IN (l_PROCESS, l_LINE_OP)
1648                  ('Populate null exposed columns......') ;
1649             END IF ;
1650 
1652             THEN
1653                l_com_operation_rec.start_effective_date
1654                := p_old_com_operation_rec.start_effective_date ;
1655             END IF ;
1656 
1657             IF l_com_operation_rec.ACD_Type IS NULL
1658             THEN
1659                l_com_operation_rec.ACD_Type
1660                := p_old_com_operation_rec.ACD_Type ;
1661             END IF ;
1662 
1663             IF l_com_operation_rec.Op_Lead_Time_Percent IS NULL
1664             THEN
1665                l_com_operation_rec.Op_Lead_Time_Percent
1666                := p_old_com_operation_rec.Op_Lead_Time_Percent ;
1667             END IF ;
1668 
1669             IF l_com_operation_rec.Minimum_Transfer_Quantity IS NULL
1670             THEN
1671                l_com_operation_rec.Minimum_Transfer_Quantity
1672                := p_old_com_operation_rec.Minimum_Transfer_Quantity ;
1673             END IF ;
1674 
1675 
1676             IF l_com_operation_rec.Count_Point_Type IS NULL
1677             THEN
1678                l_com_operation_rec.Count_Point_Type
1679                := p_old_com_operation_rec.Count_Point_Type ;
1680             END IF;
1681 
1682             IF l_com_operation_rec.Operation_Description IS NULL
1683             THEN
1684                l_com_operation_rec.Operation_Description
1685                := p_old_com_operation_rec.Operation_Description ;
1686             END IF ;
1687 
1688             IF l_com_operation_rec.Disable_Date IS NULL
1689             THEN
1690                l_com_operation_rec.Disable_Date
1691                := p_old_com_operation_rec.Disable_Date ;
1692             END IF ;
1693 
1694             IF l_com_operation_rec.Backflush_Flag IS NULL
1695             THEN
1696                l_com_operation_rec.Backflush_Flag
1697                := p_old_com_operation_rec.Backflush_Flag ;
1698             END IF ;
1699 
1700             IF l_com_operation_rec.Option_Dependent_Flag IS NULL
1701             THEN
1702                l_com_operation_rec.Option_Dependent_Flag
1703                := p_old_com_operation_rec.Option_Dependent_Flag ;
1704             END IF ;
1705 
1706             IF l_com_operation_rec.Reference_Flag IS NULL
1707             THEN
1708                l_com_operation_rec.Reference_Flag
1709                := p_old_com_operation_rec.Reference_Flag ;
1710             END IF ;
1711 
1712             IF l_com_operation_rec.Yield IS NULL
1713             THEN
1714                l_com_operation_rec.Yield
1715                := p_old_com_operation_rec.Yield ;
1716             END IF ;
1717 
1718             IF l_com_operation_rec.Cumulative_Yield IS NULL
1719             THEN
1720                l_com_operation_rec.Cumulative_Yield
1721                := p_old_com_operation_rec.Cumulative_Yield ;
1722             END IF ;
1723 
1724             IF l_com_operation_rec.Reverse_CUM_Yield IS NULL
1725             THEN
1726                l_com_operation_rec.Reverse_CUM_Yield
1727                := p_old_com_operation_rec.Reverse_CUM_Yield ;
1728             END IF ;
1729 
1730 
1731             /* Comment out calculated op times columns and
1732             -- User Elapsed Time.
1733 
1734             IF l_com_operation_rec.Calculated_Labor_Time IS NULL
1735             THEN
1736                l_com_operation_rec.Calculated_Labor_Time
1737                := p_old_com_operation_rec.Calculated_Labor_Time ;
1738             END IF ;
1739 
1740             IF l_com_operation_rec.Calculated_Machine_Time IS NULL
1741             THEN
1742                l_com_operation_rec.Calculated_Machine_Time
1743                := p_old_com_operation_rec.Calculated_Machine_Time ;
1744             END IF ;
1745 
1746             IF l_com_operation_rec.Calculated_Elapsed_Time IS NULL
1747             THEN
1748                l_com_operation_rec.Calculated_Elapsed_Time
1749                := p_old_com_operation_rec.Calculated_Elapsed_Time ;
1750             END IF ;
1751             */
1752 
1753             IF l_com_operation_rec.User_Labor_Time IS NULL
1754             THEN
1755                l_com_operation_rec.User_Labor_Time
1756                := p_old_com_operation_rec.User_Labor_Time ;
1757             END IF ;
1758 
1759             IF l_com_operation_rec.User_Machine_Time IS NULL
1760             THEN
1761                l_com_operation_rec.User_Machine_Time
1762                := p_old_com_operation_rec.User_Machine_Time ;
1763             END IF ;
1764 
1765             IF l_com_operation_rec.Net_Planning_Percent IS NULL
1766             THEN
1767                l_com_operation_rec.Net_Planning_Percent
1768                := p_old_com_operation_rec.Net_Planning_Percent ;
1769             END IF ;
1770 
1771 
1772             IF l_com_operation_rec.Include_In_Rollup IS NULL
1773             THEN
1774                l_com_operation_rec.Include_In_Rollup
1775                := p_old_com_operation_rec.Include_In_Rollup ;
1776             END IF ;
1777 
1778             IF l_com_operation_rec.Op_Yield_Enabled_Flag IS NULL
1779             THEN
1780                l_com_operation_rec.Op_Yield_Enabled_Flag
1781                := p_old_com_operation_rec.Op_Yield_Enabled_Flag ;
1782             END IF ;
1783 
1784             -- Added by MK on 04/10/2001 for eAM changes
1785             IF l_com_operation_rec.Shutdown_Type IS NULL
1789             END IF ;
1786             THEN
1787                l_com_operation_rec.Shutdown_Type
1788                := p_old_com_operation_rec.Shutdown_Type ;
1790 
1791             -- Added for long description (Bug 2689249)
1792 	    IF l_com_operation_rec.long_description IS NULL
1793             THEN
1794                l_com_operation_rec.long_description
1795                := p_old_com_operation_rec.long_description ;
1796             END IF ;
1797 
1798 
1799             -- Populate Null Columns for FlexFields
1800             IF l_com_operation_rec.attribute_category IS NULL THEN
1801                 l_com_operation_rec.attribute_category :=
1802                 p_old_com_operation_rec.attribute_category;
1803             END IF;
1804 
1805             IF l_com_operation_rec.attribute1 IS NULL THEN
1806                 l_com_operation_rec.attribute1 :=
1807                 p_old_com_operation_rec.attribute1;
1808             END IF;
1809 
1810             IF l_com_operation_rec.attribute2  IS NULL THEN
1811                 l_com_operation_rec.attribute2 :=
1812                 p_old_com_operation_rec.attribute2;
1813             END IF;
1814 
1815             IF l_com_operation_rec.attribute3 IS NULL THEN
1816                 l_com_operation_rec.attribute3 :=
1817                 p_old_com_operation_rec.attribute3;
1818             END IF;
1819 
1820             IF l_com_operation_rec.attribute4 IS NULL THEN
1821                 l_com_operation_rec.attribute4 :=
1822                 p_old_com_operation_rec.attribute4;
1823             END IF;
1824 
1825             IF l_com_operation_rec.attribute5 IS NULL THEN
1826                 l_com_operation_rec.attribute5 :=
1827                 p_old_com_operation_rec.attribute5;
1828             END IF;
1829 
1830             IF l_com_operation_rec.attribute6 IS NULL THEN
1831                 l_com_operation_rec.attribute6 :=
1832                 p_old_com_operation_rec.attribute6;
1833             END IF;
1834 
1835             IF l_com_operation_rec.attribute7 IS NULL THEN
1836                 l_com_operation_rec.attribute7 :=
1837                 p_old_com_operation_rec.attribute7;
1838             END IF;
1839 
1840             IF l_com_operation_rec.attribute8 IS NULL THEN
1841                 l_com_operation_rec.attribute8 :=
1842                 p_old_com_operation_rec.attribute8;
1843             END IF;
1844 
1845             IF l_com_operation_rec.attribute9 IS NULL THEN
1846                 l_com_operation_rec.attribute9 :=
1847                 p_old_com_operation_rec.attribute9;
1848             END IF;
1849 
1850             IF l_com_operation_rec.attribute10 IS NULL THEN
1851                 l_com_operation_rec.attribute10 :=
1852                 p_old_com_operation_rec.attribute10;
1853             END IF;
1854 
1855             IF l_com_operation_rec.attribute11 IS NULL THEN
1856                 l_com_operation_rec.attribute11 :=
1857                 p_old_com_operation_rec.attribute11;
1858             END IF;
1859 
1860             IF l_com_operation_rec.attribute12 IS NULL THEN
1861                 l_com_operation_rec.attribute12 :=
1862                 p_old_com_operation_rec.attribute12;
1863             END IF;
1864 
1865             IF l_com_operation_rec.attribute13 IS NULL THEN
1866                 l_com_operation_rec.attribute13 :=
1867                 p_old_com_operation_rec.attribute13;
1868             END IF;
1869 
1870             IF l_com_operation_rec.attribute14 IS NULL THEN
1871                 l_com_operation_rec.attribute14 :=
1872                 p_old_com_operation_rec.attribute14;
1873             END IF;
1874 
1875             IF l_com_operation_rec.attribute15 IS NULL THEN
1876                 l_com_operation_rec.attribute15 :=
1877                 p_old_com_operation_rec.attribute15;
1878             END IF;
1879 
1880 
1881             --
1882             -- Also copy the Unexposed Columns from Database to New record
1883             --
1884        IF BOM_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug
1885             ('Populate Null Unexposed columns......') ;
1886        END IF ;
1887 
1888 
1889            IF l_com_operation_rec.transaction_type <> BOM_Rtg_Globals.G_OPR_CREATE
1890            THEN
1891 
1892               l_com_op_unexp_rec.Revised_Item_Sequence_Id
1893               := p_old_com_op_unexp_rec.Revised_Item_Sequence_Id ;
1894 
1895               l_com_op_unexp_rec.Operation_Sequence_Id
1896               := p_old_com_op_unexp_rec.Operation_Sequence_Id ;
1897 
1898               l_com_op_unexp_rec.Old_Operation_Sequence_Id
1899               := p_old_com_op_unexp_rec.Old_Operation_Sequence_Id ;
1900 
1901 
1902               IF BOM_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug('Op Seq: ' ||
1903                  to_char(l_com_op_unexp_rec.operation_sequence_id)) ;
1904               END IF ;
1905 
1906            ELSIF l_com_operation_rec.transaction_type = BOM_Rtg_Globals.G_OPR_CREATE
1907            THEN
1908               /***********************************************************
1909               --
1910               -- Default Operation_Sequence_Id
1911               --
1912               ***********************************************************/
1913               IF l_com_op_unexp_rec.operation_sequence_id IS NULL OR
1914                  l_com_op_unexp_rec.operation_sequence_id = FND_API.G_MISS_NUM
1915               THEN
1916                   l_com_op_unexp_rec.operation_sequence_id :=
1920 
1917                   Get_Operation_Sequence_Id ;
1918               END IF ;
1919            END IF;
1921 
1922            IF l_com_op_unexp_rec.Standard_Operation_Id IS NULL OR
1923               l_com_op_unexp_rec.Standard_Operation_Id = FND_API.G_MISS_NUM
1924 
1925            THEN
1926               l_com_op_unexp_rec.Standard_Operation_Id
1927               := p_old_com_op_unexp_rec.Standard_Operation_Id ;
1928            END IF ;
1929 
1930            IF l_com_op_unexp_rec.Department_Id IS NULL OR
1931               l_com_op_unexp_rec.Department_Id = FND_API.G_MISS_NUM
1932            THEN
1933               l_com_op_unexp_rec.Department_Id
1934               := p_old_com_op_unexp_rec.Department_Id ;
1935            END IF ;
1936 
1937            IF l_com_op_unexp_rec.Process_Op_Seq_Id IS NULL OR
1938               l_com_op_unexp_rec.Process_Op_Seq_Id = FND_API.G_MISS_NUM
1939            THEN
1940               l_com_op_unexp_rec.Process_Op_Seq_Id
1941               := p_old_com_op_unexp_rec.Process_Op_Seq_Id ;
1942            END IF ;
1943 
1944            IF l_com_op_unexp_rec.Line_Op_Seq_Id IS NULL OR
1945               l_com_op_unexp_rec.Line_Op_Seq_Id = FND_API.G_MISS_NUM
1946            THEN
1947               l_com_op_unexp_rec.Line_Op_Seq_Id
1948               := p_old_com_op_unexp_rec.Line_Op_Seq_Id ;
1949            END IF ;
1950 
1951 
1952            IF l_com_op_unexp_rec.User_Elapsed_Time IS NULL OR
1953               l_com_op_unexp_rec.Line_Op_Seq_Id = FND_API.G_MISS_NUM
1954            THEN
1955                l_com_op_unexp_rec.User_Elapsed_Time
1956                := p_old_com_op_unexp_rec.User_Elapsed_Time ;
1957            END IF ;
1958 
1959 
1960            /***********************************************************
1961            -- Rev Op:  Trans Type : CREATE
1962            --          Acd Type - Change , Disable
1963            --          Old Op's Reference Flag - Yes
1964            -- Default  Old Operatio's Std Op Attrributes
1965            ***********************************************************/
1966            IF   l_com_operation_rec.transaction_type = BOM_Rtg_Globals.G_OPR_CREATE
1967            AND  p_old_com_operation_rec.Reference_Flag = 1 -- Yes
1968            THEN
1969 
1970 IF BOM_Rtg_Globals.Get_Debug = 'Y' THEN
1971     Error_Handler.Write_Debug('Set Op attr. of old operation to current rev op. . .') ;
1972 END IF ;
1973                 l_com_op_unexp_rec.department_id
1974                 := p_old_com_op_unexp_rec.department_id ;
1975                 l_com_operation_rec.minimum_transfer_quantity
1976                 := p_old_com_operation_rec.minimum_transfer_quantity;
1977                 l_com_operation_rec.count_point_type
1978                 := p_old_com_operation_rec.count_point_type ;
1979                 l_com_operation_rec.operation_description
1980                 := p_old_com_operation_rec.operation_description ;
1981                 l_com_operation_rec.option_dependent_flag
1982                 := p_old_com_operation_rec.option_dependent_flag ;
1983                 l_com_operation_rec.attribute_category
1984                 := p_old_com_operation_rec.attribute_category ;
1985                 l_com_operation_rec.attribute1
1986                 := p_old_com_operation_rec.attribute1 ;
1987                 l_com_operation_rec.attribute2
1988                 := p_old_com_operation_rec.attribute2 ;
1989                 l_com_operation_rec.attribute3
1990                 := p_old_com_operation_rec.attribute3 ;
1991                 l_com_operation_rec.attribute4
1992                 := p_old_com_operation_rec.attribute4 ;
1993                 l_com_operation_rec.attribute5
1994                 := p_old_com_operation_rec.attribute5 ;
1995                 l_com_operation_rec.attribute6
1996                 := p_old_com_operation_rec.attribute6 ;
1997                 l_com_operation_rec.attribute7
1998                 := p_old_com_operation_rec.attribute7 ;
1999                 l_com_operation_rec.attribute8
2000                 := p_old_com_operation_rec.attribute8 ;
2001                 l_com_operation_rec.attribute9
2002                 := p_old_com_operation_rec.attribute9 ;
2003                 l_com_operation_rec.attribute10
2004                 := p_old_com_operation_rec.attribute10 ;
2005                 l_com_operation_rec.attribute11
2006                 := p_old_com_operation_rec.attribute11 ;
2007                 l_com_operation_rec.attribute12
2008                 := p_old_com_operation_rec.attribute12 ;
2009                 l_com_operation_rec.attribute13
2010                 := p_old_com_operation_rec.attribute13 ;
2011                 l_com_operation_rec.attribute14
2012                 := p_old_com_operation_rec.attribute14 ;
2013                 l_com_operation_rec.attribute15
2014                 := p_old_com_operation_rec.attribute15 ;
2015                 l_com_operation_rec.backflush_flag
2016                 := p_old_com_operation_rec.backflush_flag;
2017                 l_com_operation_rec.include_in_rollup
2018                 := p_old_com_operation_rec.include_in_rollup;
2019                 l_com_operation_rec.op_yield_enabled_flag
2020                 := p_old_com_operation_rec.op_yield_enabled_flag;
2021 
2022 
2023            END IF ;
2024 
2025            --  Return operation exp and unexp record
2026            x_com_operation_rec  := l_com_operation_rec ;
2027            x_com_op_unexp_rec   := l_com_op_unexp_rec ;
2028 
2029     END Populate_Null_Columns;
2030 
2031 
2035     *                 Operation unexposed column record
2032     /*********************************************************************
2033     * Procedure : Entity_Defaulting by RTG BO
2034     * Parameters IN : Operation exposed column record
2036     * Parameters out: Operation exposed column record after defaulting
2037     *                 Operation unexposed column record after defaulting
2038     *                 Return Status
2039     *                 Message Token Table
2040     * Purpose   : Convert Routing Operation to Common Operation and
2041     *             Call Entity_Defaulting for Common
2042     *             This procedure will entity default values in all the operation.
2043     *             fields that the user has left unfilled.
2044     **********************************************************************/
2045     PROCEDURE Entity_Defaulting
2046     (  p_operation_rec     IN  Bom_Rtg_Pub.Operation_Rec_Type
2047      , p_op_unexp_rec      IN  Bom_Rtg_Pub.Op_Unexposed_Rec_Type
2048      , x_operation_rec     IN OUT NOCOPY Bom_Rtg_Pub.Operation_Rec_Type
2049      , x_op_unexp_rec      IN OUT NOCOPY Bom_Rtg_Pub.Op_Unexposed_Rec_Type
2050      , x_mesg_token_tbl    IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
2051      , x_return_status     IN OUT NOCOPY VARCHAR2
2052     )
2053     IS
2054         l_com_operation_rec      Bom_Rtg_Pub.Com_Operation_Rec_Type ;
2055         l_com_op_unexp_rec       Bom_Rtg_Pub.Com_Op_Unexposed_Rec_Type ;
2056 
2057         l_return_status VARCHAR2(1);
2058         l_err_text  VARCHAR2(2000) ;
2059         l_Mesg_Token_Tbl    Error_Handler.Mesg_Token_Tbl_Type;
2060 
2061     BEGIN
2062 
2063         x_return_status := FND_API.G_RET_STS_SUCCESS;
2064 
2065         --
2066         -- The record definition of Revised Operation in ECO BO is
2067         -- slightly different than the operation definition of RTG BO
2068         -- So, we will copy the values of RTG BO Record into an Common
2069         -- BO compatible record before we make a call to the
2070         -- Entity Defaulting procedure.
2071         --
2072 
2073         -- Convert Routing Operation to Common Operation
2074         Bom_Rtg_Pub.Convert_RtgOp_To_ComOp
2075         (  p_rtg_operation_rec      => p_operation_rec
2076          , p_rtg_op_unexp_rec       => p_op_unexp_rec
2077          , x_com_operation_rec      => l_com_operation_rec
2078          , x_com_op_unexp_rec       => l_com_op_unexp_rec
2079         ) ;
2080 
2081 
2082         -- Once the record transfer is done call the
2083         -- common operation attribute defaulting
2084         --
2085         BOM_Default_Op_Seq.Entity_Defaulting
2086         (  p_com_operation_rec     => l_com_operation_rec
2087          , p_com_op_unexp_rec      => l_com_op_unexp_rec
2088          , p_control_Rec => Bom_Rtg_Pub.G_Default_Control_Rec
2089          , x_com_operation_rec     => l_com_operation_rec
2090          , x_com_op_unexp_rec      => l_com_op_unexp_rec
2091          , x_return_status         => x_return_status
2092          , x_mesg_token_tbl        => x_mesg_token_tbl
2093         ) ;
2094 
2095 
2096         -- Convert the Common record to Routing Record
2097         Bom_Rtg_Pub.Convert_ComOp_To_RtgOp
2098         (  p_com_operation_rec      => l_com_operation_rec
2099          , p_com_op_unexp_rec       => l_com_op_unexp_rec
2100          , x_rtg_operation_rec      => x_operation_rec
2101          , x_rtg_op_unexp_rec       => x_op_unexp_rec
2102          ) ;
2103 
2104     END Entity_Defaulting ;
2105 
2106     /*********************************************************************
2107     * Procedure : Entity_Defaulting by ECOBO
2108     * Parameters IN : Revised Operation exposed column record
2109     *                 Revised Operation unexposed column record
2110     * Parameters out: Revised Operation exposed column record after defaulting
2111     *                 Revised Operation unexposed column record after defaulting
2112     *                 Return Status
2113     *                 Message Token Table
2114     * Purpose   : Convert Routing Operation to ECO Operation and
2115     *             Call Entity_Defaulting for ECO BO.
2116     *             This procedure will entity default values in all the operation.
2117     *             fields that the user has left unfilled.
2118     **********************************************************************/
2119     PROCEDURE Entity_Defaulting
2120     (  p_rev_operation_rec    IN  Bom_Rtg_Pub.Rev_Operation_Rec_Type
2121      , p_rev_op_unexp_rec     IN  Bom_Rtg_Pub.Rev_Op_Unexposed_Rec_Type
2122      , p_control_Rec          IN  Bom_Rtg_Pub.Control_Rec_Type
2123      , x_rev_operation_rec    IN OUT NOCOPY Bom_Rtg_Pub.Rev_Operation_Rec_Type
2124      , x_rev_op_unexp_rec     IN OUT NOCOPY Bom_Rtg_Pub.Rev_Op_Unexposed_Rec_Type
2125      , x_mesg_token_tbl       IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
2126      , x_return_status        IN OUT NOCOPY VARCHAR2
2127     )
2128 
2129     IS
2130         l_com_operation_rec      Bom_Rtg_Pub.Com_Operation_Rec_Type ;
2131         l_com_op_unexp_rec       Bom_Rtg_Pub.Com_Op_Unexposed_Rec_Type ;
2132         l_return_status VARCHAR2(1);
2133         l_err_text  VARCHAR2(2000) ;
2134         l_Mesg_Token_Tbl    Error_Handler.Mesg_Token_Tbl_Type;
2135 
2136     BEGIN
2137 
2138         x_return_status := FND_API.G_RET_STS_SUCCESS;
2139 
2140         --
2141         -- The record definition of Revised Operation in ECO BO is
2142         -- slightly different than the operation definition of RTG BO
2146         --
2143         -- So, we will copy the values of RTG BO Record into a common
2144         -- BO compatible record before we make a call to the
2145         -- Entity Defaulting procedure.
2147 
2148         -- Convert Revised Operation to Common Operation
2149         Bom_Rtg_Pub.Convert_EcoOp_To_ComOp
2150         (  p_rev_operation_rec      => p_rev_operation_rec
2151          , p_rev_op_unexp_rec       => p_rev_op_unexp_rec
2152          , x_com_operation_rec      => l_com_operation_rec
2153          , x_com_op_unexp_rec       => l_com_op_unexp_rec
2154         ) ;
2155 
2156 
2157         -- Once the record transfer is done call the ECO BO's
2158         -- revised operation attribute defaulting
2159         --
2160         BOM_Default_Op_Seq.Entity_Defaulting
2161         (  p_com_operation_rec     => l_com_operation_rec
2162          , p_com_op_unexp_rec      => l_com_op_unexp_rec
2163          , p_control_Rec => Bom_Rtg_Pub.G_Default_Control_Rec
2164          , x_com_operation_rec     => l_com_operation_rec
2165          , x_com_op_unexp_rec      => l_com_op_unexp_rec
2166          , x_return_status         => x_return_status
2167          , x_mesg_token_tbl        => x_mesg_token_tbl
2168         ) ;
2169 
2170 
2171         -- Convert the Common record to Revised Operation record
2172         Bom_Rtg_Pub.Convert_ComOp_To_EcoOp
2173         (  p_com_operation_rec      => l_com_operation_rec
2174          , p_com_op_unexp_rec       => l_com_op_unexp_rec
2175          , x_rev_operation_rec      => x_rev_operation_rec
2176          , x_rev_op_unexp_rec       => x_rev_op_unexp_rec
2177          ) ;
2178 
2179 
2180     END Entity_Defaulting ;
2181 
2182 
2183 
2184     /********************************************************************
2185     * Procedure : Entity_Defaulting for Common
2186     *               internally called by RTG BO and ECO BO
2187     * Parameters IN : Common Operation exposed column record
2188     *                 Common Operation unexposed column record
2189     * Parameters out: Common Operation exposed column record after defaulting
2190     *                 Commond Operation unexposed column record after defaulting
2191     *                 Return Status
2192     *                 Message Token Table
2193     * Purpose   : Entity defaulting proc. defualts columns to
2194     *             appropriate values. Defualting will happen for
2195     *             exposed as well as unexposed columns.
2196     *********************************************************************/
2197     PROCEDURE Entity_Defaulting
2198     (  p_com_operation_rec    IN  Bom_Rtg_Pub.Com_Operation_Rec_Type
2199      , p_com_op_unexp_rec     IN  Bom_Rtg_Pub.Com_Op_Unexposed_Rec_Type
2200      , p_control_Rec          IN  Bom_Rtg_Pub.Control_Rec_Type
2201      , x_com_operation_rec    IN OUT NOCOPY Bom_Rtg_Pub.Com_Operation_Rec_Type
2202      , x_com_op_unexp_rec     IN OUT NOCOPY Bom_Rtg_Pub.Com_Op_Unexposed_Rec_Type
2203      , x_mesg_token_tbl       IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
2204      , x_return_status        IN OUT NOCOPY VARCHAR2
2205     )
2206 
2207     IS
2208 
2209         l_com_operation_rec      Bom_Rtg_Pub.Com_Operation_Rec_Type ;
2210         l_com_op_unexp_rec       Bom_Rtg_Pub.Com_Op_Unexposed_Rec_Type ;
2211 
2212         l_return_status VARCHAR2(1);
2213         l_err_text  VARCHAR2(2000) ;
2214         l_Mesg_Token_Tbl    Error_Handler.Mesg_Token_Tbl_Type;
2215 
2216 
2217     BEGIN
2218 
2219         IF BOM_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug
2220             ('Within the Rev. Operation Entity Defaulting...') ;
2221         END IF ;
2222 
2223         x_return_status := FND_API.G_RET_STS_SUCCESS;
2224         l_return_status := FND_API.G_RET_STS_SUCCESS;
2225 
2226         --  Initialize operation exp and unexp record
2227         l_com_operation_rec  := p_com_operation_rec ;
2228         l_com_op_unexp_rec   := p_com_op_unexp_rec ;
2229 
2230         IF  BOM_Rtg_Globals.Get_Bo_Identifier = BOM_Rtg_Globals.G_ECO_BO
2231         THEN
2232            l_com_operation_rec.new_start_effective_date := NULL ;
2233         END IF ;
2234 
2235         IF l_com_operation_rec.alternate_routing_code = FND_API.G_MISS_CHAR
2236         THEN
2237             l_com_operation_rec.alternate_routing_code := NULL ;
2238         END IF ;
2239 
2240         IF ( BOM_Rtg_Globals.Get_CFM_Rtg_Flag <>  BOM_Rtg_Globals.G_FLOW_RTG
2241             OR  BOM_Rtg_Globals.Get_Bo_Identifier = BOM_Rtg_Globals.G_ECO_BO)
2242         AND (l_com_operation_rec.operation_type = NULL OR
2243             l_com_operation_rec.operation_type = FND_API.G_MISS_NUM )
2244         THEN
2245            l_com_operation_rec.operation_type := l_EVENT ;
2246         END IF ;
2247 
2248 
2249         IF l_com_operation_rec.User_Labor_Time = FND_API.G_MISS_NUM
2250         THEN
2251                l_com_operation_rec.User_Labor_Time := NULL ;
2252         END IF ;
2253 
2254         IF l_com_operation_rec.User_Machine_Time = FND_API.G_MISS_NUM
2255         THEN
2256                l_com_operation_rec.User_Machine_Time := NULL ;
2257         END IF ;
2258 
2259         -- Set User Elapsed Time
2260         l_com_op_unexp_rec.User_Elapsed_Time :=
2261              Get_User_Elapsed_Time
2265 
2262              (  p_user_labor_time   => l_com_operation_rec.User_Labor_Time
2263               , p_user_machine_time => l_com_operation_rec.User_Machine_Time
2264              ) ;
2266         -- Set missing column values to Null
2267         IF l_com_op_unexp_rec.department_id = FND_API.G_MISS_NUM
2268         THEN
2269            l_com_op_unexp_rec.department_id := NULL ;
2270         END IF;
2271 
2272         IF l_com_op_unexp_rec.standard_operation_id = FND_API.G_MISS_NUM
2273         THEN
2274            l_com_op_unexp_rec.standard_operation_id := NULL ;
2275         END IF;
2276 
2277         IF (l_com_operation_rec.Process_Seq_Number  = FND_API.G_MISS_NUM
2278             AND l_com_operation_rec.Process_Code = FND_API.G_MISS_CHAR )
2279         OR  l_com_op_unexp_rec.process_op_seq_id = FND_API.G_MISS_NUM
2280         THEN
2281                l_com_op_unexp_rec.process_op_seq_id := NULL ;
2282         END IF ;
2283 
2284         IF (l_com_operation_rec.Line_Op_Seq_Number  = FND_API.G_MISS_NUM
2285             AND l_com_operation_rec.Line_Op_Code = FND_API.G_MISS_CHAR)
2286         OR l_com_op_unexp_rec.line_op_seq_id = FND_API.G_MISS_NUM
2287         THEN
2288                l_com_op_unexp_rec.line_op_seq_id := NULL ;
2289         END IF ;
2290 
2291         IF l_com_operation_rec.new_operation_sequence_number = FND_API.G_MISS_NUM
2292         THEN
2293                l_com_operation_rec.new_operation_sequence_number := NULL ;
2294         END IF ;
2295 
2296         IF l_com_operation_rec.new_start_effective_date = FND_API.G_MISS_DATE
2297         THEN
2298                l_com_operation_rec.new_start_effective_date := NULL ;
2299         END IF ;
2300 
2301         IF l_com_operation_rec.Disable_Date = FND_API.G_MISS_DATE
2302         THEN
2303                l_com_operation_rec.Disable_Date := NULL ;
2304         END IF ;
2305 
2306         IF l_com_operation_rec.Op_Lead_Time_Percent = FND_API.G_MISS_NUM
2307         THEN
2308                l_com_operation_rec.Op_Lead_Time_Percent := NULL ;
2309         END IF ;
2310 
2311         IF l_com_operation_rec.Minimum_Transfer_Quantity = FND_API.G_MISS_NUM
2312         THEN
2313                l_com_operation_rec.Minimum_Transfer_Quantity := NULL ;
2314         END IF ;
2315 
2316         IF l_com_operation_rec.Operation_Description = FND_API.G_MISS_CHAR
2317         THEN
2318                l_com_operation_rec.Operation_Description := NULL ;
2319         END IF ;
2320 
2321         IF l_com_operation_rec.Yield = FND_API.G_MISS_NUM
2322         THEN
2323                l_com_operation_rec.Yield := NULL ;
2324         END IF ;
2325 
2326         IF l_com_operation_rec.Cumulative_Yield = FND_API.G_MISS_NUM
2327         THEN
2328                l_com_operation_rec.Cumulative_Yield := NULL ;
2329         END IF ;
2330 
2331         IF l_com_operation_rec.Reverse_CUM_Yield = FND_API.G_MISS_NUM
2332         THEN
2333                l_com_operation_rec.Reverse_CUM_Yield := NULL ;
2334         END IF ;
2335 
2336         /* Following calc op times columns no longer used
2337         IF l_com_operation_rec.Calculated_Labor_Time = FND_API.G_MISS_NUM
2338         THEN
2339                l_com_operation_rec.Calculated_Labor_Time := NULL ;
2340         END IF ;
2341 
2342         IF l_com_operation_rec.Calculated_Machine_Time = FND_API.G_MISS_NUM
2343         THEN
2344                l_com_operation_rec.Calculated_Machine_Time := NULL ;
2345         END IF ;
2346 
2347         IF l_com_operation_rec.Calculated_Elapsed_Time = FND_API.G_MISS_NUM
2348         THEN
2349                l_com_operation_rec.Calculated_Elapsed_Time := NULL ;
2350         END IF ;
2351         */
2352 
2353 
2354         IF l_com_operation_rec.Net_Planning_Percent = FND_API.G_MISS_NUM
2355         THEN
2356                l_com_operation_rec.Net_Planning_Percent := NULL ;
2357         END IF ;
2358 
2359         IF l_com_operation_rec.original_system_reference = FND_API.G_MISS_CHAR THEN
2360                 l_com_operation_rec.original_system_reference := NULL ;
2361         END IF;
2362 
2363         -- Added by MK on 04/10/2001 for eAM changes
2364         IF l_com_operation_rec.Shutdown_Type = FND_API.G_MISS_CHAR THEN
2365                 l_com_operation_rec.Shutdown_Type := NULL ;
2366         END IF;
2367 
2368         -- Added for long description (Bug 2689249)
2369 	IF l_com_operation_rec.long_description = FND_API.G_MISS_CHAR THEN
2370                 l_com_operation_rec.long_description := NULL ;
2371         END IF;
2372 
2373 
2374         -- FlexFields
2375         IF l_com_operation_rec.attribute_category = FND_API.G_MISS_CHAR THEN
2376                 l_com_operation_rec.attribute_category := NULL ;
2377         END IF;
2378 
2379         IF l_com_operation_rec.attribute1 = FND_API.G_MISS_CHAR THEN
2380                 l_com_operation_rec.attribute1 := NULL ;
2381         END IF;
2382 
2383         IF l_com_operation_rec.attribute2  = FND_API.G_MISS_CHAR THEN
2384                 l_com_operation_rec.attribute2 := NULL ;
2385         END IF;
2386 
2387         IF l_com_operation_rec.attribute3 = FND_API.G_MISS_CHAR THEN
2388                 l_com_operation_rec.attribute3 := NULL ;
2389         END IF;
2390 
2391         IF l_com_operation_rec.attribute4 = FND_API.G_MISS_CHAR THEN
2392                 l_com_operation_rec.attribute4 := NULL ;
2393         END IF;
2394 
2395         IF l_com_operation_rec.attribute5 = FND_API.G_MISS_CHAR THEN
2396                 l_com_operation_rec.attribute5 := NULL ;
2397         END IF;
2398 
2399         IF l_com_operation_rec.attribute6 = FND_API.G_MISS_CHAR THEN
2400                 l_com_operation_rec.attribute6 := NULL ;
2401         END IF;
2402 
2403         IF l_com_operation_rec.attribute7 = FND_API.G_MISS_CHAR THEN
2404                 l_com_operation_rec.attribute7 := NULL ;
2405         END IF;
2406 
2407         IF l_com_operation_rec.attribute8 = FND_API.G_MISS_CHAR THEN
2408                 l_com_operation_rec.attribute8 := NULL ;
2409         END IF;
2410 
2411         IF l_com_operation_rec.attribute9 = FND_API.G_MISS_CHAR THEN
2412                 l_com_operation_rec.attribute9 := NULL ;
2413         END IF;
2414 
2415         IF l_com_operation_rec.attribute10 = FND_API.G_MISS_CHAR THEN
2416                 l_com_operation_rec.attribute10 := NULL ;
2417         END IF;
2418 
2419         IF l_com_operation_rec.attribute11 = FND_API.G_MISS_CHAR THEN
2420                 l_com_operation_rec.attribute11 := NULL ;
2421         END IF;
2422 
2423         IF l_com_operation_rec.attribute12 = FND_API.G_MISS_CHAR THEN
2424                 l_com_operation_rec.attribute12 := NULL ;
2425         END IF;
2426 
2427         IF l_com_operation_rec.attribute13 = FND_API.G_MISS_CHAR THEN
2428                 l_com_operation_rec.attribute13 := NULL ;
2429         END IF;
2430 
2431         IF l_com_operation_rec.attribute14 = FND_API.G_MISS_CHAR THEN
2432                 l_com_operation_rec.attribute14 := NULL ;
2433         END IF;
2434 
2435         IF l_com_operation_rec.attribute15 = FND_API.G_MISS_CHAR THEN
2436                 l_com_operation_rec.attribute15 := NULL ;
2437         END IF;
2438 
2439         -- Return the status and message table.
2440         x_return_status  := l_return_status ;
2441         x_mesg_token_tbl := l_mesg_token_tbl ;
2442 
2443         -- Return the common operation records after entity defaulting.
2444         x_com_operation_rec  := l_com_operation_rec ;
2445         x_com_op_unexp_rec   := l_com_op_unexp_rec ;
2446 
2447 
2448     EXCEPTION
2449        WHEN OTHERS THEN
2450           IF BOM_Rtg_Globals.Get_Debug = 'Y' THEN Error_Handler.Write_Debug
2451           ('Some unknown error in Entity Defaulting . . .' || SQLERRM );
2452           END IF ;
2453 
2454 
2455           l_err_text := G_PKG_NAME || ' Defaulting (Entity Defaulting) '
2456                                 || substrb(SQLERRM,1,200);
2457           -- dbms_output.put_line('Unexpected Error: '||l_err_text);
2458 
2459           Error_Handler.Add_Error_Token
2460           (  p_message_name   => NULL
2461            , p_message_text   => l_err_text
2462            , p_mesg_token_tbl => l_mesg_token_tbl
2463            , x_mesg_token_tbl => l_mesg_token_tbl
2464           ) ;
2465 
2466           -- Return the status and message table.
2467           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2468           x_mesg_token_tbl := l_mesg_token_tbl ;
2469 
2470     END Entity_Defaulting ;
2471 
2472 
2473 
2474 END BOM_Default_Op_Seq ;