DBA Data[Home] [Help]

PACKAGE BODY: APPS.BOM_DEFAULT_RTG_HEADER

Source


1 PACKAGE BODY BOM_Default_Rtg_Header AS
2 /* $Header: BOMDRTGB.pls 120.1 2006/04/06 06:08:11 bbpatel noship $*/
3 /****************************************************************************
4 --
5 --  Copyright (c) 2000 Oracle Corporation, Redwood Shores, CA, USA
6 --  All rights reserved.
7 --
8 --  FILENAME
9 --
10 --      BOMDRTGB.pls
11 --
12 --  DESCRIPTION
13 --
14 --      Body of package BOM_Default_Rtg_Header
15 --
16 --  NOTES
17 --
18 --  HISTORY
19 --  07-AUG-2000 Biao Zhang    Initial Creation
20 --
21 ****************************************************************************/
22         G_PKG_NAME      CONSTANT VARCHAR2(30) := 'Rtg_Default_Rtg_Header';
23 
24 
25         /********************************************************************
26         * Function      : Get_Routing_Sequence
27         * Return        : NUMBER
28         * Purpose       : Function will return the routing_sequence_id.
29         *
30         **********************************************************************/
31         FUNCTION Get_Routing_Sequence
32         RETURN NUMBER
33         IS
34                 l_routing_sequence_id      NUMBER := NULL;
35         BEGIN
36 
37                 SELECT bom_operational_routings_s.nextval
38                   INTO l_routing_sequence_id
39                   FROM sys.dual;
40 
41                 RETURN l_routing_sequence_id;
42 
43                 EXCEPTION
44 
45                 WHEN OTHERS THEN
46                         RETURN NULL;
47 
48         END Get_routing_Sequence;
49 
50         PROCEDURE Get_Flex_Rtg_Header
51           (  p_rtg_header_rec IN  Bom_Rtg_Pub.Rtg_Header_Rec_Type
52            , x_rtg_header_rec IN OUT NOCOPY Bom_Rtg_Pub.Rtg_Header_Rec_Type
53           )
54         IS
55         BEGIN
56 
57             --  In the future call Flex APIs for defaults
58                 x_rtg_header_rec := p_rtg_header_rec;
59 
60                 IF p_rtg_header_rec.attribute_category =FND_API.G_MISS_CHAR THEN
61                         x_rtg_header_rec.attribute_category := NULL;
62                 END IF;
63 
64                 IF p_rtg_header_rec.attribute1 = FND_API.G_MISS_CHAR THEN
65                         x_rtg_header_rec.attribute1  := NULL;
66                 END IF;
67 
68                 IF p_rtg_header_rec.attribute2 = FND_API.G_MISS_CHAR THEN
69                         x_rtg_header_rec.attribute2  := NULL;
70                 END IF;
71 
72                 IF p_rtg_header_rec.attribute3 = FND_API.G_MISS_CHAR THEN
73                         x_rtg_header_rec.attribute3  := NULL;
74                 END IF;
75 
76                 IF p_rtg_header_rec.attribute4 = FND_API.G_MISS_CHAR THEN
77                         x_rtg_header_rec.attribute4  := NULL;
78                 END IF;
79 
80                 IF p_rtg_header_rec.attribute5 = FND_API.G_MISS_CHAR THEN
81                         x_rtg_header_rec.attribute5  := NULL;
82                 END IF;
83 
84                 IF p_rtg_header_rec.attribute6 = FND_API.G_MISS_CHAR THEN
85                         x_rtg_header_rec.attribute6  := NULL;
86                 END IF;
87 
88                 IF p_rtg_header_rec.attribute7 = FND_API.G_MISS_CHAR THEN
89                         x_rtg_header_rec.attribute7  := NULL;
90                 END IF;
91 
92                 IF p_rtg_header_rec.attribute8 = FND_API.G_MISS_CHAR THEN
93                         x_rtg_header_rec.attribute8  := NULL;
94                 END IF;
95 
96                 IF p_rtg_header_rec.attribute9 = FND_API.G_MISS_CHAR THEN
97                         x_rtg_header_rec.attribute9  := NULL;
98                 END IF;
99 
100                 IF p_rtg_header_rec.attribute10 = FND_API.G_MISS_CHAR THEN
101                         x_rtg_header_rec.attribute10 := NULL;
102                 END IF;
103 
104                 IF p_rtg_header_rec.attribute11 = FND_API.G_MISS_CHAR THEN
105                         x_rtg_header_rec.attribute11 := NULL;
106                 END IF;
107 
108                 IF p_rtg_header_rec.attribute12 = FND_API.G_MISS_CHAR THEN
109                         x_rtg_header_rec.attribute12 := NULL;
110                 END IF;
111 
112                 IF p_rtg_header_rec.attribute13 = FND_API.G_MISS_CHAR THEN
113                         x_rtg_header_rec.attribute13 := NULL;
114                 END IF;
115 
116                 IF p_rtg_header_rec.attribute14 = FND_API.G_MISS_CHAR THEN
117                         x_rtg_header_rec.attribute14 := NULL;
118                 END IF;
119 
120                 IF p_rtg_header_rec.attribute15 = FND_API.G_MISS_CHAR THEN
121                         x_rtg_header_rec.attribute15 := NULL;
122                 END IF;
123 
124 
125         END Get_Flex_Rtg_Header;
126 
127         -- Get_Cfm_Routing_Flag
128         FUNCTION Get_Cfm_Routing_Flag
129         RETURN NUMBER
130         IS
131         BEGIN
132             RETURN 2 ;   -- Return 2 : Standard Routing
133         END Get_Cfm_Routing_Flag ;
134 
135         -- Get_Mixed_Model_Map_Flag
136         FUNCTION  Get_Mixed_Model_Map_Flag
137         RETURN NUMBER
138         IS
139         BEGIN
140             RETURN 2 ;   -- Return 2 : No
141         END Get_Mixed_Model_Map_Flag ;
142 
143         -- Get_Ctp_Flag
144         FUNCTION   Get_Ctp_Flag
145         RETURN NUMBER
146         IS
147         BEGIN
148             RETURN 2 ;   -- Return 2 : No
149         END Get_Ctp_Flag ;
150 
151 
152         -- Get_Eng_Routing_Flag
153         FUNCTION   Get_Eng_Routing_Flag( p_assembly_item_id  NUMBER
154                                        , p_org_id            NUMBER)
155         RETURN NUMBER
156         IS
157             p_eng_routng_flag NUMBER ;
158             CURSOR get_routing_flag_csr (  p_assembly_item_id  NUMBER
159                                          , p_org_id            NUMBER )
160             IS
161                 SELECT DECODE(eng_item_flag, 'Y', 1, 2)  eng_routing_flag
162                 FROM mtl_system_items
163                 WHERE inventory_item_id = p_assembly_item_id
164                 AND   organization_id = p_org_id;
165 
166 
167 
168 
169         BEGIN
170 
171             FOR get_routing_flag_rec  IN get_routing_flag_csr
172                                          (  p_assembly_item_id
173                                           , p_org_id )
174             LOOP
175 
176                  RETURN get_routing_flag_rec.eng_routing_flag ;
177 
178             END LOOP ;
179 
180             RETURN 2 ;   -- Return 2 : No - Mfg Routing
181 
182         END Get_Eng_Routing_Flag ;
183 
184 -- Added for SSOS (bug 2689249)
185 	FUNCTION   Get_Ser_Num_Control_Code( p_assembly_item_id  NUMBER
186 						, p_org_id            NUMBER)
187         RETURN NUMBER
188         IS
189             p_serial_number_control_code NUMBER ;
190             CURSOR GET_SER_NUM_CONTROL_CODE_csr (  p_assembly_item_id  NUMBER
191 							, p_org_id            NUMBER )
192             IS
193                 SELECT serial_number_control_code
194                 FROM mtl_system_items
195                 WHERE inventory_item_id = p_assembly_item_id
196                 AND   organization_id = p_org_id;
197 
198         BEGIN
199 
200             FOR GET_SER_NUM_CONTROL_CODE_rec  IN GET_SER_NUM_CONTROL_CODE_csr
201 							(  p_assembly_item_id
202 							, p_org_id )
203             LOOP
204 
205                  RETURN GET_SER_NUM_CONTROL_CODE_rec.serial_number_control_code ;
206 
207             END LOOP ;
208 
209         END Get_Ser_Num_Control_Code ;
210 
211 
212         /*********************************************************************
213         * Procedure     : Attribute_Defaulting
214         * Parameters IN : Rtg Header exposed record
215         *                 Rtg Header unexposed record
216         * Parameters out: Rtg Header exposed record after defaulting
217         *                 Rtg Header unexposed record after defaulting
218         *                 Mesg_Token_Table
219         *                 Return_Status
220         * Purpose       : Attribute Defaulting will default the necessary null
221         *                 attribute with appropriate values.
222         **********************************************************************/
223         PROCEDURE Attribute_Defaulting
224         (  p_rtg_header_rec          IN  Bom_Rtg_Pub.Rtg_Header_Rec_Type
225          , p_rtg_header_unexp_rec    IN  Bom_Rtg_Pub.Rtg_Header_Unexposed_Rec_Type
226          , x_rtg_header_rec          IN OUT NOCOPY Bom_Rtg_Pub.Rtg_Header_Rec_Type
227          , x_rtg_header_unexp_rec    IN OUT NOCOPY Bom_Rtg_Pub.Rtg_Header_Unexposed_Rec_Type
228          , x_mesg_token_tbl          IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
229          , x_return_status           IN OUT NOCOPY VARCHAR2
230          )
231         IS
232           --bug:4285921 Cursor to get completion subinventory and locator id.
233           CURSOR  l_CommonRtg_csr (P_CommRtgSeqId NUMBER, P_OrgId NUMBER, P_Alt VARCHAR2) IS
234             SELECT
235               COMPLETION_SUBINVENTORY,
236               COMPLETION_LOCATOR_ID
237             FROM
238               BOM_OPERATIONAL_ROUTINGS
239             WHERE
240                 ROUTING_SEQUENCE_ID = P_CommRtgSeqId
241             AND ORGANIZATION_ID     = P_OrgId
242             AND NVL(ALTERNATE_ROUTING_DESIGNATOR, 'primary alternate') =
243                   NVL(P_Alt, 'primary alternate');
244         BEGIN
245 
246                 x_rtg_header_rec := p_rtg_header_rec;
247                 x_rtg_header_unexp_rec := p_rtg_header_unexp_rec;
248                 x_return_status := FND_API.G_RET_STS_SUCCESS;
249 
250                 IF p_rtg_header_unexp_rec.routing_sequence_id IS NULL OR
251                    p_rtg_header_unexp_rec.routing_sequence_id = FND_API.G_MISS_NUM
252                 THEN
253                         x_rtg_header_unexp_rec.routing_sequence_id :=
254                                 Get_Routing_Sequence;
255 
256                         IF BOM_Rtg_Globals.Get_Debug = 'Y'
257                         THEN Error_Handler.Write_Debug('New Routing Sequence Id :  '
258                              || to_char(x_rtg_header_unexp_rec.routing_sequence_id));
259                         END IF;
260 
261                 END IF;
262 
263                 IF  p_rtg_header_rec.cfm_routing_flag = FND_API.G_MISS_NUM
264                 OR  p_rtg_header_rec.cfm_routing_flag IS NULL
265                 THEN
266                         x_rtg_header_rec.cfm_routing_flag  := Get_Cfm_Routing_Flag ;
267                 END IF;
268 
269                 IF p_rtg_header_rec.mixed_model_map_flag =FND_API.G_MISS_NUM
270                 OR p_rtg_header_rec.mixed_model_map_flag IS NULL
271                 THEN
272                         x_rtg_header_rec.mixed_model_map_flag  := Get_Mixed_Model_Map_Flag ;
273                 END IF;
274 
275                 IF p_rtg_header_rec.ctp_flag =FND_API.G_MISS_NUM
276                 OR p_rtg_header_rec.ctp_flag IS NULL
277                 THEN
278                         x_rtg_header_rec.ctp_flag  := Get_Ctp_Flag ;
279                 END IF;
280 
281                 IF p_rtg_header_rec.eng_routing_flag = FND_API.G_MISS_NUM
282                 OR p_rtg_header_rec.eng_routing_flag IS NULL
283                 THEN
284                         x_rtg_header_rec.eng_routing_flag
285                            := Get_Eng_Routing_Flag
286                               ( p_assembly_item_id => p_rtg_header_unexp_rec.assembly_item_id
287                               , p_org_id => p_rtg_header_unexp_rec.organization_id )   ;
288 
289                 END IF ;
290 
291                 IF p_rtg_header_rec.total_cycle_time = FND_API.G_MISS_NUM THEN
292                         x_rtg_header_rec.total_cycle_time := NULL  ;
293                 END IF;
294 
295                 Get_Flex_Rtg_Header(  p_rtg_header_rec => x_rtg_header_rec
296                                     , x_rtg_header_rec => x_rtg_header_rec
297                                     );
298 
299                 --bug:4285921 begins
300                 -- Called for CREATE.
301                 -- Take values of completion_subinventory and completion_locator_id
302                 -- from input if specified, else take it from common routing.
303                 IF NVL(p_rtg_header_unexp_rec.common_routing_sequence_id, FND_API.G_MISS_NUM) <>
304                       FND_API.G_MISS_NUM
305                 THEN
306                   FOR l_CommonRtg_rec IN
307                         l_CommonRtg_csr
308                           (
309                             P_CommRtgSeqId => p_rtg_header_unexp_rec.common_routing_sequence_id,
310                             P_OrgId => p_rtg_header_unexp_rec.organization_id,
311                             P_Alt => p_rtg_header_rec.alternate_routing_code
312                            )
313                   LOOP
314                     x_rtg_header_rec.completion_subinventory :=
315                       NVL(p_rtg_header_rec.completion_subinventory,l_CommonRtg_rec.completion_subinventory);
316                     x_rtg_header_unexp_rec.completion_locator_id :=
317                       NVL(p_rtg_header_unexp_rec.completion_locator_id,l_CommonRtg_rec.completion_locator_id);
318                   END LOOP; -- common routing
319                 END IF; -- set common routing info
320                 --bug:4285921 ends
321 
322         END Attribute_Defaulting;
323 
324         /*********************************************************************
325         * Procedure     : Entity_Attribute_Defaulting
326         * Parameters IN : Rtg Header exposed record
327         *                 Rtg Header unexposed record
328         * Parameters out: Rtg Header exposed record after defaulting
329         *                 Rtg Header unexposed record after defaulting
330         *                 Mesg_Token_Table
331         *                 Return_Status
332         * Purpose       : Entity Attribute Defaulting will default the necessary
333         *                 entity level attribute with appropriate values.
334         **********************************************************************/
335         PROCEDURE Entity_Attribute_Defaulting
336         (  p_rtg_header_rec             IN  Bom_Rtg_Pub.Rtg_Header_Rec_Type
337          , p_rtg_header_unexp_rec       IN  Bom_Rtg_Pub.Rtg_Header_Unexposed_Rec_Type
338          , x_rtg_header_rec             IN OUT NOCOPY Bom_Rtg_Pub.Rtg_Header_Rec_Type
339          , x_rtg_header_unexp_rec       IN OUT NOCOPY Bom_Rtg_Pub.Rtg_Header_Unexposed_Rec_Type
340          , x_mesg_token_tbl             IN OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
341          , x_return_status              IN OUT NOCOPY VARCHAR2
342          )
343         IS
344 
345                 l_token_tbl      Error_Handler.Token_Tbl_Type;
346                 l_Mesg_Token_Tbl Error_Handler.Mesg_Token_Tbl_Type;
347 
348         BEGIN
349 
350                 x_rtg_header_rec := p_rtg_header_rec;
351                 x_rtg_header_unexp_rec := p_rtg_header_unexp_rec;
352                 x_return_status := FND_API.G_RET_STS_SUCCESS;
353 
354                 IF   (p_rtg_header_unexp_rec.routing_sequence_id IS NOT NULL
355                       AND   p_rtg_header_unexp_rec.routing_sequence_id <> FND_API.G_MISS_NUM)
356                 AND  ( p_rtg_header_unexp_rec.common_routing_sequence_id IS NULL
357                       OR p_rtg_header_unexp_rec.common_routing_sequence_id
358                                                           =  FND_API.G_MISS_NUM )
359                 THEN
360                      x_rtg_header_unexp_rec.common_routing_sequence_id :=
361                                 p_rtg_header_unexp_rec.routing_sequence_id;
362                 END IF;
363 
364                 IF p_rtg_header_unexp_rec.common_routing_sequence_id
365                           =  p_rtg_header_unexp_rec.routing_sequence_id
366                 THEN
367                         x_rtg_header_unexp_rec.common_assembly_item_id := NULL ;
368 
369                 ELSIF p_rtg_header_unexp_rec.common_assembly_item_id = FND_API.G_MISS_NUM
370                 THEN
371                         x_rtg_header_unexp_rec.common_assembly_item_id := NULL ;
375                 AND p_rtg_header_rec.eng_routing_flag <> FND_API.G_MISS_NUM
372                 END IF ;
373 
374                 IF  p_rtg_header_rec.eng_routing_flag IS NOT NULL
376                 AND ( p_rtg_header_unexp_rec.routing_type IS NULL
377                       OR  p_rtg_header_unexp_rec.routing_type = FND_API.G_MISS_NUM)
378                 THEN
379                     SELECT DECODE(p_rtg_header_rec.eng_routing_flag, 1, 2, 1)
380                     INTO  x_rtg_header_unexp_rec.routing_type
381                     FROM SYS.DUAL ;
382                 END IF;
383 
384 
385                 IF p_rtg_header_rec.total_cycle_time = FND_API.G_MISS_NUM THEN
386                         x_rtg_header_rec.total_cycle_time := NULL   ;
387                 END IF;
388 
389                 IF p_rtg_header_rec.alternate_routing_code = FND_API.G_MISS_CHAR
390                 THEN
391                         x_rtg_header_rec.alternate_routing_code := NULL ;
392                 END IF ;
393 
394                 IF p_rtg_header_rec.completion_subinventory = FND_API.G_MISS_CHAR
395                 THEN
396                         x_rtg_header_rec.completion_subinventory := NULL ;
397                 END IF ;
398 
399                 IF p_rtg_header_unexp_rec.completion_locator_id = FND_API.G_MISS_NUM
400                 THEN
401                         x_rtg_header_unexp_rec.completion_locator_id := NULL ;
402                 END IF ;
403 
404                 IF p_rtg_header_unexp_rec.line_id = FND_API.G_MISS_NUM
405                 OR p_rtg_header_unexp_rec.line_id IS NULL
406                 THEN
407                         x_rtg_header_unexp_rec.line_id := NULL ;
408                         x_rtg_header_rec.line_code := NULL ;
409                 END IF ;
410 
411                 IF p_rtg_header_rec.priority = FND_API.G_MISS_NUM THEN
412                         x_rtg_header_rec.priority := NULL ;
413                 END IF ;
414 
415                 IF p_rtg_header_rec.total_cycle_time =  FND_API.G_MISS_NUM THEN
416                         x_rtg_header_rec.total_cycle_time := NULL ;
417                 END IF ;
418 
419                 IF p_rtg_header_rec.routing_comment = FND_API.G_MISS_CHAR
420                 THEN
421                         x_rtg_header_rec.routing_comment := NULL ;
422                 END IF ;
423 
424                 IF p_rtg_header_rec.ser_start_op_seq = FND_API.G_MISS_NUM   -- Added for SSOS (bug 2689249)
425                 THEN
426                         x_rtg_header_rec.ser_start_op_seq := NULL ;
427                 ELSIF p_rtg_header_rec.ser_start_op_seq IS NOT NULL THEN
428       --bug:5137686 Allow SSOS for network routing also.
429 			IF (     ( BOM_Rtg_Globals.Get_Cfm_Rtg_Flag <> BOM_Rtg_Globals.G_STD_RTG )
430            AND ( BOM_Rtg_Globals.Get_Cfm_Rtg_Flag <> BOM_Rtg_Globals.G_LOT_RTG ) )
431          AND
432 			    ( BOM_Rtg_Globals.Get_Eam_Item_Type <>  BOM_Rtg_Globals.G_ASSET_ACTIVITY ) THEN -- SSOS is for Std routings only
433 			    x_rtg_header_rec.ser_start_op_seq := NULL ;
434 			    IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
435 			    THEN
436 /*
437 			    l_token_tbl(1).token_name  := 'ASSEMBLY_ITEM_NAME';
438 			    l_token_tbl(1).token_value :=
439                                         p_rtg_header_rec.assembly_item_name;
440 */
441 				Error_Handler.Add_Error_Token
442 				(  x_Mesg_token_tbl => l_Mesg_Token_Tbl
443 				, p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
444 				, p_message_name   => 'BOM_NON_STD_RTG_SSOS_IGNORED'
445 				, p_token_tbl      => l_token_tbl
446 				, p_message_type   => 'W'
447 				);
448 			    END IF ;
449 			END IF;
450 			IF Get_Ser_Num_Control_Code
451                               ( p_assembly_item_id => p_rtg_header_unexp_rec.assembly_item_id
452                               , p_org_id => p_rtg_header_unexp_rec.organization_id ) <> 2 THEN
453 			    x_rtg_header_rec.ser_start_op_seq := NULL ;
454 /*
455 			    l_token_tbl(1).token_name  := 'ASSEMBLY_ITEM_NAME';
456 			    l_token_tbl(1).token_value :=
457                                         p_rtg_header_rec.assembly_item_name;
458 */
459 			    IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
460 			    THEN
461 
462 				Error_Handler.Add_Error_Token
463 				(  x_Mesg_token_tbl => l_Mesg_Token_Tbl
464 				, p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
465 				, p_message_name   => 'BOM_NON_PREDEF_SSOS_IGNORED'
466 				, p_token_tbl      => l_token_tbl
467 				, p_message_type   => 'W'
468 				);
469 			    END IF ;
470 			END IF;
471 		END IF ;
472 
473 
474                 --
475                 -- Defaulting for non operated columns in
476                 -- Standard Routing and Lot Based Routing
477                 --
478                 IF p_rtg_header_rec.cfm_routing_flag IN ( 2 , 3)
479                 AND  (x_rtg_header_rec.line_code IS NOT NULL
480                      OR  x_rtg_header_rec.mixed_model_map_flag <> 2
481                      OR  x_rtg_header_rec.total_cycle_time IS NOT NULL)
482                 THEN
483                      x_rtg_header_rec.line_code := NULL ;
484                      x_rtg_header_rec.mixed_model_map_flag:= 2 ;
485                      x_rtg_header_rec.total_cycle_time := NULL;
486 
487 
488                      l_token_tbl(1).token_name  := 'ASSEMBLY_ITEM_NAME';
489                      l_token_tbl(1).token_value :=
490                                         p_rtg_header_rec.assembly_item_name;
491 
495                         Error_Handler.Add_Error_Token
492                      IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
493                      THEN
494 
496                         (  x_Mesg_token_tbl => l_Mesg_Token_Tbl
497                          , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
498                          , p_message_name   => 'BOM_RTG_FLOW_ATTR_IGNORED'
499                          , p_token_tbl      => l_token_tbl
500                          , p_message_type   => 'W'
501                          );
502                      END IF ;
503 
504                 END IF;
505 
506                 x_mesg_token_tbl := l_Mesg_Token_Tbl ;
507 
508         END Entity_Attribute_Defaulting;
509 
510         /******************************************************************
511         * Procedure     : Populate_Null_Columns
512         * Parameters IN : Rtg Header Exposed column record
513         *                 Rtg Header Unexposed column record
514         *                 Old Rtg Header Exposed Column Record
515         *                 Old Rtg Header Unexposed Column Record
516         * Parameters out: Rtg Header Exposed column record after populating
517         *                 Rtg Header Unexposed Column record after  populating
518         * Purpose       : This procedure will look at the columns that the user
519         *                 has not filled in and will assign those columns a
520         *                 value from the old record.
521         *                 This procedure is not called CREATE
522         ********************************************************************/
523         PROCEDURE Populate_Null_Columns
524         (  p_rtg_header_rec           IN  Bom_Rtg_Pub.Rtg_Header_Rec_Type
525          , p_rtg_header_unexp_rec     IN  Bom_Rtg_Pub.Rtg_Header_Unexposed_Rec_Type
526          , p_old_rtg_header_rec       IN  Bom_Rtg_Pub.Rtg_Header_Rec_Type
527          , p_old_rtg_header_unexp_rec IN  Bom_Rtg_Pub.Rtg_Header_Unexposed_Rec_Type
528          , x_rtg_header_rec           IN OUT NOCOPY Bom_Rtg_Pub.Rtg_Header_Rec_Type
529          , x_rtg_header_unexp_rec     IN OUT NOCOPY Bom_Rtg_Pub.Rtg_Header_Unexposed_Rec_Type
530         )
531         IS
532           --bug:4285921 Cursor to get completion subinventory and locator id.
533           CURSOR  l_CommonRtg_csr (P_CommRtgSeqId NUMBER, P_OrgId NUMBER, P_Alt VARCHAR2) IS
534             SELECT
535               COMPLETION_SUBINVENTORY,
536               COMPLETION_LOCATOR_ID
537             FROM
538               BOM_OPERATIONAL_ROUTINGS
539             WHERE
540                 ROUTING_SEQUENCE_ID = P_CommRtgSeqId
541             AND ORGANIZATION_ID     = P_OrgId
542             AND NVL(ALTERNATE_ROUTING_DESIGNATOR, 'primary alternate') =
543                   NVL(P_Alt, 'primary alternate');
544         BEGIN
545                 x_rtg_header_rec := p_rtg_header_rec;
546                 x_rtg_header_unexp_rec := p_rtg_header_unexp_rec;
547 
548 
549                 IF( p_rtg_header_rec.eng_routing_flag IS NULL  OR
550                     p_rtg_header_rec.eng_routing_flag  = FND_API.G_MISS_NUM )
551                 THEN
552                         x_rtg_header_unexp_rec.routing_type :=
553                                 p_old_rtg_header_unexp_rec.routing_type ;
554                 END IF;
555 
556 
557                 IF p_rtg_header_rec.Routing_Comment IS NULL
558                 THEN
559                         x_rtg_header_rec.Routing_Comment :=
560                                 p_old_rtg_header_rec.Routing_Comment ;
561                 END IF;
562 
563                 IF p_rtg_header_rec.CFM_Routing_Flag IS NULL
564                 OR p_rtg_header_rec.CFM_Routing_Flag = FND_API.G_MISS_NUM
565                 THEN
566                         x_rtg_header_rec.CFM_Routing_Flag :=
567                                 p_old_rtg_header_rec.CFM_Routing_Flag ;
568                 END IF ;
569 
570                 IF p_rtg_header_rec.Mixed_Model_Map_Flag IS NULL
571                 OR p_rtg_header_rec.Mixed_Model_Map_Flag = FND_API.G_MISS_NUM
572                 THEN
573                         x_rtg_header_rec.Mixed_Model_Map_Flag :=
574                                 p_old_rtg_header_rec.Mixed_Model_Map_Flag ;
575                 END IF ;
576 
577                 IF p_rtg_header_rec.CTP_Flag IS NULL
578                 OR p_rtg_header_rec.CTP_Flag = FND_API.G_MISS_NUM
579                 THEN
580                         x_rtg_header_rec.CTP_Flag :=
581                                 p_old_rtg_header_rec.CTP_Flag ;
582                 END IF ;
583 
584                 IF p_rtg_header_rec.Priority IS NULL
585                 THEN
586                         x_rtg_header_rec.Priority :=
587                                 p_old_rtg_header_rec.Priority ;
588                 END IF ;
589 
590                 IF p_rtg_header_rec.Total_Cycle_Time IS NULL
591                 THEN
592                         x_rtg_header_rec.Total_Cycle_Time :=
593                                 p_old_rtg_header_rec.Total_Cycle_Time ;
594                 END IF ;
595 
596                 IF p_rtg_header_rec.ser_start_op_seq IS NULL  -- Added for SSOS (bug 2689249)
597                 THEN
598                         x_rtg_header_rec.ser_start_op_seq :=
599                                 p_old_rtg_header_rec.ser_start_op_seq;
600                 END IF ;
601 
602                 --
606                    p_rtg_header_rec.attribute_category = FND_API.G_MISS_CHAR
603                 -- Populate Null or missng flex field columns
604                 --
605                 IF p_rtg_header_rec.attribute_category IS NULL OR
607                 THEN
608                         x_rtg_header_rec.attribute_category :=
609                                 p_old_rtg_header_rec.attribute_category;
610 
611                 END IF;
612 
613                 IF p_rtg_header_rec.attribute1 = FND_API.G_MISS_CHAR OR
614                    p_rtg_header_rec.attribute1 IS NULL
615                 THEN
616                         x_rtg_header_rec.attribute1  :=
617                                 p_old_rtg_header_rec.attribute1;
618                 END IF;
619 
620                 IF p_rtg_header_rec.attribute2 = FND_API.G_MISS_CHAR OR
621                    p_rtg_header_rec.attribute2 IS NULL
622                 THEN
623                         x_rtg_header_rec.attribute2  :=
624                                 p_old_rtg_header_rec.attribute2;
625                 END IF;
626 
627                 IF p_rtg_header_rec.attribute3 = FND_API.G_MISS_CHAR OR
628                    p_rtg_header_rec.attribute3 IS NULL
629                 THEN
630                         x_rtg_header_rec.attribute3  :=
631                                 p_old_rtg_header_rec.attribute3;
632                 END IF;
633 
634                 IF p_rtg_header_rec.attribute4 = FND_API.G_MISS_CHAR OR
635                    p_rtg_header_rec.attribute4 IS NULL
636                 THEN
637                         x_rtg_header_rec.attribute4  :=
638                                 p_old_rtg_header_rec.attribute4;
639                 END IF;
640 
641                 IF p_rtg_header_rec.attribute5 = FND_API.G_MISS_CHAR OR
642                    p_rtg_header_rec.attribute5 IS NULL
643                 THEN
644                         x_rtg_header_rec.attribute5  :=
645                                 p_old_rtg_header_rec.attribute5;
646                 END IF;
647 
648                 IF p_rtg_header_rec.attribute6 = FND_API.G_MISS_CHAR OR
649                    p_rtg_header_rec.attribute6 IS NULL
650                 THEN
651                         x_rtg_header_rec.attribute6  :=
652                                 p_old_rtg_header_rec.attribute6;
653                 END IF;
654 
655                 IF p_rtg_header_rec.attribute7 = FND_API.G_MISS_CHAR OR
656                    p_rtg_header_rec.attribute7 IS NULL
657                 THEN
658                         x_rtg_header_rec.attribute7  :=
659                                 p_old_rtg_header_rec.attribute7;
660                 END IF;
661 
662                 IF p_rtg_header_rec.attribute8 = FND_API.G_MISS_CHAR OR
663                    p_rtg_header_rec.attribute8 IS NULL
664                 THEN
665                         x_rtg_header_rec.attribute8  :=
666                                 p_old_rtg_header_rec.attribute8;
667                 END IF;
668 
669                 IF p_rtg_header_rec.attribute9 = FND_API.G_MISS_CHAR OR
670                    p_rtg_header_rec.attribute9 IS NULL
671                 THEN
672                         x_rtg_header_rec.attribute9  :=
673                                 p_old_rtg_header_rec.attribute9;
674                 END IF;
675 
676                 IF p_rtg_header_rec.attribute10 = FND_API.G_MISS_CHAR OR
677                    p_rtg_header_rec.attribute10 IS NULL
678                 THEN
679                         x_rtg_header_rec.attribute10 :=
680                                 p_old_rtg_header_rec.attribute10;
681                 END IF;
682 
683                 IF p_rtg_header_rec.attribute11 = FND_API.G_MISS_CHAR OR
684                    p_rtg_header_rec.attribute11 IS NULL
685                 THEN
686                         x_rtg_header_rec.attribute11 :=
687                                 p_old_rtg_header_rec.attribute11;
688                 END IF;
689 
690                 IF p_rtg_header_rec.attribute12 = FND_API.G_MISS_CHAR OR
691                    p_rtg_header_rec.attribute12 IS NULL
692                 THEN
693                         x_rtg_header_rec.attribute12 :=
694                                 p_old_rtg_header_rec.attribute12;
695                 END IF;
696 
697                 IF p_rtg_header_rec.attribute13 = FND_API.G_MISS_CHAR OR
698                    p_rtg_header_rec.attribute13 IS NULL
699                 THEN
700                         x_rtg_header_rec.attribute13 :=
701                                 p_old_rtg_header_rec.attribute13;
702                 END IF;
703 
704                 IF p_rtg_header_rec.attribute14 = FND_API.G_MISS_CHAR OR
705                    p_rtg_header_rec.attribute14 IS NULL
706                 THEN
707                         x_rtg_header_rec.attribute14 :=
708                                 p_old_rtg_header_rec.attribute14;
709                 END IF;
710 
711                 IF p_rtg_header_rec.attribute15 = FND_API.G_MISS_CHAR OR
712                    p_rtg_header_rec.attribute15 IS NULL
713                 THEN
714                         x_rtg_header_rec.attribute15 :=
715                                 p_old_rtg_header_rec.attribute15;
716                 END IF;
717 
718                 --
719                 -- Get the unexposed columns from the database and return
720                 -- them as the unexposed columns for the current record.
721                 --
722                 x_rtg_header_unexp_rec.routing_sequence_id
723                          := p_old_rtg_header_unexp_rec.routing_sequence_id;
724 
725                 IF p_rtg_header_unexp_rec.Common_Assembly_Item_Id = FND_API.G_MISS_NUM
726                 OR p_rtg_header_unexp_rec.Common_Assembly_Item_Id IS NULL
727                 THEN
728                     x_rtg_header_unexp_rec.Common_Assembly_Item_Id
729                          := p_old_rtg_header_unexp_rec.Common_Assembly_Item_Id ;
730                 END IF ;
731 
735                     x_rtg_header_unexp_rec.Common_Routing_Sequence_Id
732                 IF p_rtg_header_unexp_rec.Common_Routing_Sequence_Id = FND_API.G_MISS_NUM
733                 OR p_rtg_header_unexp_rec.Common_Routing_Sequence_Id IS NULL
734                 THEN
736                          := p_old_rtg_header_unexp_rec.Common_Routing_Sequence_Id ;
737                 END IF ;
738 
739                 IF p_rtg_header_unexp_rec.Line_Id = FND_API.G_MISS_NUM
740                 OR p_rtg_header_unexp_rec.Line_Id IS NULL
741                 THEN
742 
743                      x_rtg_header_unexp_rec.Line_Id
744                          := p_old_rtg_header_unexp_rec.Line_Id ;
745                 END IF ;
746 
747 
748                 --bug:4285921 begins
749                 -- Called during Update.
750                 -- Take values of completion_subinventory and completion_locator_id
751                 -- from input if specified, else from common routing.
752 
753                 FOR l_CommonRtg_rec IN
754                         l_CommonRtg_csr
755                           (
756                             P_CommRtgSeqId => p_rtg_header_unexp_rec.common_routing_sequence_id,
757                             P_OrgId => p_rtg_header_unexp_rec.organization_id,
758                             P_Alt => p_rtg_header_rec.alternate_routing_code
759                            )
760                 LOOP
761                   x_rtg_header_rec.completion_subinventory :=
762                     NVL(p_rtg_header_rec.completion_subinventory,l_CommonRtg_rec.completion_subinventory);
763 
764                   IF       ( p_rtg_header_rec.Completion_Subinventory IS NOT NULL )
765                       AND  ( p_rtg_header_rec.Completion_Subinventory <>
766                                p_old_rtg_header_rec.Completion_Subinventory )
767                       AND
768                        (
769                           (
770                                 p_rtg_header_unexp_rec.Completion_Locator_Id IS NOT NULL
771                            AND  p_old_rtg_header_unexp_rec.Completion_Locator_Id IS NOT NULL
772                           )
773                         AND
774                           (
775                               p_rtg_header_unexp_rec.Completion_Locator_Id =
776                                   p_old_rtg_header_unexp_rec.Completion_Locator_Id
777                           OR
778                             (
779                                 p_rtg_header_unexp_rec.Completion_Locator_Id IS NOT NULL
780                             AND p_rtg_header_unexp_rec.Completion_Locator_Id = FND_API.G_MISS_NUM
781                             )
782                           )
783                         )
784                   THEN
785                     x_rtg_header_unexp_rec.Completion_Locator_Id := NULL;
786                   ELSIF
787                     (
788                           p_rtg_header_rec.Completion_Subinventory IS NOT NULL
789                       AND p_rtg_header_rec.Completion_Subinventory <>
790                             p_old_rtg_header_rec.Completion_Subinventory
791                       AND p_rtg_header_unexp_rec.Completion_Locator_Id = FND_API.G_MISS_NUM
792                     )
793                   THEN
794                      x_rtg_header_unexp_rec.Completion_Locator_Id := NULL;
795                   ELSIF
796                     (
797                           p_rtg_header_rec.Completion_Subinventory IS NOT NULL
798                     AND   p_rtg_header_rec.Completion_Subinventory =
799                             p_old_rtg_header_rec.Completion_Subinventory
800                     AND   p_rtg_header_unexp_rec.Completion_Locator_Id IS NULL
801                     )
802                   THEN
803                     x_rtg_header_unexp_rec.Completion_Locator_Id :=
804                       NVL(p_rtg_header_unexp_rec.Completion_Locator_Id,l_CommonRtg_rec.completion_locator_id);
805                   ELSIF p_rtg_header_rec.Completion_Location_Name IS NULL
806                   THEN
807                     x_rtg_header_unexp_rec.Completion_Locator_Id :=
808                       NVL(p_rtg_header_unexp_rec.Completion_Locator_Id,l_CommonRtg_rec.completion_locator_id);
809                   END IF;
810                 END LOOP; -- common routing
811                 --bug:4285921 ends
812 
813         END Populate_Null_Columns;
814 
815 END BOM_Default_Rtg_Header;