DBA Data[Home] [Help]

PACKAGE BODY: APPS.ENG_DEFAULT_REV_COMPONENT

Source


1 PACKAGE BODY ENG_Default_Rev_Component AS
2 /* $Header: ENGDCMPB.pls 115.19 2002/12/13 00:35:51 bbontemp ship $ */
3 
4 --  Global constant holding the package name
5 
6 G_PKG_NAME	CONSTANT VARCHAR2(30) := 'ENG_Default_Rev_Component';
7 
8 --  Package global used within the package.
9 
10 g_rev_component_rec	Bom_Bo_Pub.Rev_Component_Rec_Type;
11 g_Rev_Comp_Unexp_Rec	Bom_Bo_Pub.Rev_Comp_Unexposed_Rec_Type;
12 x_text			VARCHAR2(80);
13 
14 /*****************************************************************************
15 * Following are all get functions which will be used by the attribute
16 * defaulting procedure. Each column that need to be defaulted has one GET
17 * function.
18 *****************************************************************************/
19 
20 FUNCTION Get_Required_For_Revenue
21 RETURN NUMBER
22 IS
23 BEGIN
24 
25     RETURN 2;   -- Return FALSE which is 2
26 
27 END Get_Required_For_Revenue;
28 
29 FUNCTION Get_Component_Sequence
30 RETURN NUMBER
31 IS
32 CURSOR Comp_Seq IS
33 	SELECT Bom_Inventory_Components_S.NEXTVAL Component_Sequence
34 	  FROM SYS.DUAL;
35 BEGIN
36 
37     FOR c_Comp_Seq IN Comp_Seq LOOP
38 	RETURN c_Comp_Seq.Component_Sequence;
39     END LOOP ;
40 
41 END Get_Component_Sequence;
42 
43 -- Added by AS on 07/08 as part of adding unit effectivity capability
44 -- into the packages.
45 
46 FUNCTION Get_To_End_Item_Number
47 RETURN VARCHAR2
48 IS
49 CURSOR c_To_End_Item_Number IS
50 	SELECT To_End_Item_Unit_Number
51 	  FROM BOM_Inventory_Components
52 	 WHERE component_sequence_id =
53 		g_rev_comp_unexp_rec.old_component_sequence_id;
54 BEGIN
55     FOR To_End_Item_Number IN c_To_End_Item_Number
56     LOOP
57 	RETURN To_End_Item_Number.To_End_Item_Unit_Number;
58     END LOOP;
59 END Get_To_End_Item_Number;
60 
61 FUNCTION Get_Operation_Seq_Num
62 RETURN NUMBER
63 IS
64 BEGIN
65 
66     RETURN 1;
67 
68 END Get_Operation_Seq_Num;
69 
70 FUNCTION Get_Item_Num
71 RETURN NUMBER
72 IS
73 p_Item_Seq_Increment NUMBER;
74  CURSOR GetItemSeq IS
75       SELECT nvl(max(item_num), 0) + P_Item_Seq_Increment default_seq
76         FROM bom_inventory_components
77        WHERE bill_sequence_id = g_rev_Comp_Unexp_rec.Bill_Sequence_Id;
78 BEGIN
79 	p_Item_Seq_Increment:=fnd_profile.value('BOM:ITEM_SEQUENCE_INCREMENT');
80 
81 	FOR l_Def_Item_Seq IN GetItemSeq LOOP
82 		RETURN l_Def_Item_Seq.Default_Seq;
83 	END LOOP;
84 
85 	-- If for some reason the For loop does not execute then default the
86 	-- Item num to 10
87 	RETURN 10;
88 
89 END Get_Item_Num;
90 
91 FUNCTION Get_Pick_Components
92 RETURN NUMBER
93 IS
94 l_pick_components NUMBER;
95  CURSOR GetPickComps IS
96       SELECT decode(pick_components_flag, 'Y', 1, 2) pick_comps
97         FROM mtl_system_items
98        WHERE inventory_item_id = g_rev_comp_Unexp_rec.component_item_id
99          AND organization_id   = g_rev_comp_Unexp_rec.organization_id;
100 BEGIN
101 
102     for pick_comps_loop in GetPickComps loop
103  	l_pick_components := pick_comps_loop.pick_comps;
104     end loop;
105 
106     RETURN (l_pick_components);
107 END Get_Pick_Components;
108 
109 FUNCTION Get_Component_Quantity
110 RETURN NUMBER
111 IS
112 BEGIN
113 
114     RETURN 1;  --Default the qty should be 1.
115 
116 END Get_Component_Quantity;
117 
118 FUNCTION Get_Component_Yield_Factor
119 RETURN NUMBER
120 IS
121 BEGIN
122 
123     RETURN 1;
124 
125 END Get_Component_Yield_Factor;
126 
127 FUNCTION Get_Effectivity_Date
128 RETURN DATE
129 IS
130 CURSOR c_EffectiveDate IS
131 	SELECT scheduled_date
132 	  FROM eng_revised_items
133 	 WHERE revised_item_sequence_id =
134 	   g_Rev_Comp_Unexp_Rec.revised_item_sequence_id;
135 BEGIN
136 
137     FOR x_EffectiveDate IN c_EffectiveDate LOOP
138 	RETURN x_EffectiveDate.scheduled_date;
139     END LOOP;
140 
141     RETURN SYSDATE;
142 
143 END Get_Effectivity_Date;
144 
145 FUNCTION Get_Planning_Factor
146 RETURN NUMBER
147 IS
148 BEGIN
149 
150     RETURN 100;
151 
152 END Get_Planning_Factor;
153 
154 FUNCTION Get_Quantity_Related
155 RETURN NUMBER
156 IS
157 BEGIN
158 	RETURN 2;
159 
160 END Get_Quantity_Related;
161 
162 FUNCTION Get_So_Basis
163 RETURN NUMBER
164 IS
165 BEGIN
166 
167     RETURN 2;
168 
169 END Get_So_Basis;
170 
171 FUNCTION Get_Optional
172 RETURN NUMBER
173 IS
174 BEGIN
175 
176     RETURN 2;
177 
178 END Get_Optional;
179 
180 FUNCTION Get_Mutually_Exclusive
181 RETURN NUMBER
182 IS
183 BEGIN
184 
185     RETURN 2;
186 
187 END Get_Mutually_Exclusive;
188 
189 /****************************************************************************
190 *
191 * If the item attribute Default_Include_In_Cost_Rollup IS NULL or Yes then
192 * Include_In_Cost_Rollup is YES (1) Else Include_In_Cost_Rollup is NO (2)
193 *
194 *****************************************************************************/
195 FUNCTION Get_Include_In_Cost_Rollup
196 RETURN NUMBER
197 IS
198 CURSOR c_DefaultRollup is
199 	SELECT default_include_in_rollup_flag
200 	  FROM mtl_system_items
201 	 WHERE inventory_item_id = g_Rev_Comp_Unexp_Rec.component_item_id
202 	   AND organization_id   = g_Rev_Comp_Unexp_Rec.organization_id;
203 BEGIN
204 
205 	-- The default for this value comes from the Mtl_System_Items
206 	-- Table field Default_Include_In_Rollup_Flag
207     FOR l_DefaultRollup in c_DefaultRollup LOOP
208 	IF l_DefaultRollup.Default_include_in_rollup_flag IS NULL OR
209 	   l_DefaultRollup.Default_include_in_rollup_flag = 'Y'
210 	THEN
211 		RETURN 1;
212 	ELSE
213 		RETURN 2;
214 	END IF;
215     END LOOP;
216 
217 END Get_Include_In_Cost_Rollup;
218 
219 /*****************************************************************************
220 *
221 * If the Assembly item has ATP Components flag as yes and the component item
222 * attribute is Check_ATP yes then ECO can allow Check_ATP as YES (1) else
223 * Check_ATP is NO (2)
224 *
225 ******************************************************************************/
226 
227 FUNCTION Get_Check_Atp
228 RETURN NUMBER
229 IS
230 CURSOR c_CheckATP IS
231 	SELECT 1 atp_allowed
232 	  FROM mtl_system_items assy,
233 	       mtl_system_items comp
234 	 WHERE assy.organization_id     = g_Rev_Comp_Unexp_Rec.organization_id
235 	   AND assy.inventory_item_id   = g_Rev_Comp_Unexp_Rec.Revised_item_id
236 	   AND assy.atp_components_flag = 'Y'
237 	   AND comp.organization_id   = g_Rev_Comp_Unexp_Rec.organization_id
238 	   AND comp.inventory_item_id = g_Rev_Comp_Unexp_Rec.component_item_id
239 	   AND comp.atp_flag IN ( 'Y', 'C', 'R');
240 
241 BEGIN
242 
243     FOR CheckAtp IN c_CheckATP LOOP
244 	IF CheckAtp.atp_allowed = 1 THEN
245 		RETURN 1;
246 	ELSE
247 		RETURN 2;
248 	END IF;
249     END LOOP;
250 
251     RETURN 2; -- If no records are retrived.
252 END Get_Check_Atp;
253 
254 FUNCTION Get_Shipping_Allowed
255 RETURN NUMBER
256 IS
257 BEGIN
258 
259     RETURN 2;
260 
261 END Get_Shipping_Allowed;
262 
263 FUNCTION Get_Required_To_Ship
264 RETURN NUMBER
265 IS
266 BEGIN
267 
268     RETURN 2;
269 
270 END Get_Required_To_Ship;
271 
272 FUNCTION Get_Include_On_Ship_Docs
273 RETURN NUMBER
274 IS
275 BEGIN
276 
277      RETURN 2;
278 
279 END Get_Include_On_Ship_Docs;
280 
281 FUNCTION get_bom_item_type
282 RETURN NUMBER IS
283 l_bom_item_type	NUMBER;
284 BEGIN
285 	SELECT bom_item_type
286 	  INTO l_bom_item_type
287 	  FROM mtl_system_items msi
288 	 WHERE msi.inventory_item_id = g_Rev_Comp_Unexp_rec.component_item_id
289 	   AND msi.organization_id   = g_Rev_Comp_Unexp_rec.organization_id;
290 
291 	   RETURN l_bom_item_type;
292 
293 END;
294 
295 /****************************************************************************
296 *
297 * Check if revised_item has a bill_sequence_id.
298 * If it does then retun that as the default value, if not then generate the
299 * Bill_Sequence_Id from the Sequence.
300 *
301 *****************************************************************************/
302 FUNCTION Get_Bill_Sequence
303 RETURN NUMBER
304 IS
305 CURSOR c_CheckForNew IS
306        SELECT Bill_Sequence_Id
307 	 FROM bom_bill_of_materials bom
308         WHERE bom.assembly_item_id =
309 	      g_Rev_Comp_Unexp_Rec.revised_item_id
310 	  AND bom.organization_id =
311 	      g_Rev_Comp_Unexp_Rec.organization_id
312 	  AND NVL(bom.alternate_bom_designator, 'NONE') =
313 	      NVL(g_rev_component_rec.alternate_bom_code, 'NONE');
314 
315 CURSOR c_CheckBillInRevisedItem IS
316 	SELECT bill_sequence_id
317 	  FROM eng_revised_items
318 	 WHERE revised_item_sequence_id =
319 		g_rev_comp_unexp_rec.revised_item_sequence_id;
320 
321 l_bill_sequence_id	NUMBER;
322 BEGIN
323 
324 	FOR CheckBill IN c_CheckBillInRevisedItem LOOP
325 		IF CheckBill.Bill_Sequence_Id IS NOT NULL THEN
326 			l_Bill_Sequence_Id := CheckBill.Bill_Sequence_Id;
327 			RETURN l_Bill_Sequence_Id;
328 		END IF;
329 	END LOOP;
330 
331 	--
332 	-- If bill sequence id is not found in Eng_Revised_Items
333 	-- Only then go to the Bom Table to look for Bill_Sequence_Id
334 	--
335 	OPEN c_CheckForNew;
336 	FETCH c_CheckForNew INTO l_bill_sequence_id;
337 	CLOSE c_CheckForNew;
338 
339 	IF l_Bill_Sequence_Id IS NULL
340 	THEN
341 		SELECT BOM_INVENTORY_COMPONENTS_S.NextVal
342         	  INTO l_Bill_Sequence_Id
343         	  FROM SYS.DUAL;
344 
345 	    RETURN l_Bill_Sequence_id;
346 	ELSE
347 		Return l_bill_sequence_id;
348 
349 	END IF;
350 END;
351 
352 PROCEDURE Get_Flex_Rev_Component
353 IS
354 BEGIN
355 
356     --  In the future call Flex APIs for defaults
357 
358     IF g_rev_component_rec.attribute_category = FND_API.G_MISS_CHAR THEN
359         g_rev_component_rec.attribute_category := NULL;
360     END IF;
361 
362     IF g_rev_component_rec.attribute1 = FND_API.G_MISS_CHAR THEN
363         g_rev_component_rec.attribute1 := NULL;
364     END IF;
365 
366     IF g_rev_component_rec.attribute2 = FND_API.G_MISS_CHAR THEN
367         g_rev_component_rec.attribute2 := NULL;
368     END IF;
369 
370     IF g_rev_component_rec.attribute3 = FND_API.G_MISS_CHAR THEN
371         g_rev_component_rec.attribute3 := NULL;
372     END IF;
373 
374     IF g_rev_component_rec.attribute4 = FND_API.G_MISS_CHAR THEN
375         g_rev_component_rec.attribute4 := NULL;
376     END IF;
377 
378     IF g_rev_component_rec.attribute5 = FND_API.G_MISS_CHAR THEN
379         g_rev_component_rec.attribute5 := NULL;
380     END IF;
381 
382     IF g_rev_component_rec.attribute6 = FND_API.G_MISS_CHAR THEN
383         g_rev_component_rec.attribute6 := NULL;
384     END IF;
385 
386     IF g_rev_component_rec.attribute7 = FND_API.G_MISS_CHAR THEN
387         g_rev_component_rec.attribute7 := NULL;
388     END IF;
389 
390     IF g_rev_component_rec.attribute8 = FND_API.G_MISS_CHAR THEN
391         g_rev_component_rec.attribute8 := NULL;
392     END IF;
393 
394     IF g_rev_component_rec.attribute9 = FND_API.G_MISS_CHAR THEN
395         g_rev_component_rec.attribute9 := NULL;
396     END IF;
397 
398     IF g_rev_component_rec.attribute10 = FND_API.G_MISS_CHAR THEN
399         g_rev_component_rec.attribute10 := NULL;
400     END IF;
401 
402     IF g_rev_component_rec.attribute11 = FND_API.G_MISS_CHAR THEN
403         g_rev_component_rec.attribute11 := NULL;
404     END IF;
405 
406     IF g_rev_component_rec.attribute12 = FND_API.G_MISS_CHAR THEN
407         g_rev_component_rec.attribute12 := NULL;
408     END IF;
409 
410     IF g_rev_component_rec.attribute13 = FND_API.G_MISS_CHAR THEN
411         g_rev_component_rec.attribute13 := NULL;
412     END IF;
413 
414     IF g_rev_component_rec.attribute14 = FND_API.G_MISS_CHAR THEN
415         g_rev_component_rec.attribute14 := NULL;
416     END IF;
417 
418     IF g_rev_component_rec.attribute15 = FND_API.G_MISS_CHAR THEN
419         g_rev_component_rec.attribute15 := NULL;
420     END IF;
421 
422 END Get_Flex_Rev_Component;
423 
424 /*****************************************************************************
425 * Parameters IN	: Revised component exposed column record
426 *		  Revised Component unexposed column record
427 * Parameters OUT: Revised Component record after defaulting
428 *		  Revised component unexposed columns record after defaulting
429 *		  Mesg Token Table
430 *		  Return_Status
431 * Purpose	: Attribute defaulting proc. defualts columns to appropriate
432 *		  values. Defualting will happen for exposed as well as
433 *		  unexposed columns.
434 *****************************************************************************/
435 PROCEDURE Attribute_Defaulting
436 (   p_rev_component_rec		IN  Bom_Bo_Pub.Rev_Component_Rec_Type
437 ,   p_Rev_Comp_Unexp_Rec	IN  Bom_Bo_Pub.Rev_Comp_Unexposed_Rec_Type
438 ,   x_rev_component_rec		IN OUT NOCOPY Bom_Bo_Pub.Rev_Component_Rec_Type
439 ,   x_Rev_Comp_Unexp_Rec	IN OUT NOCOPY Bom_Bo_Pub.Rev_Comp_Unexposed_Rec_Type
440 ,   x_Mesg_Token_Tbl		OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
441 ,   x_Return_Status		OUT NOCOPY VARCHAR2
442 )
443 IS
444 l_pick_components 	NUMBER := 0;
445 BEGIN
446 
447 --dbms_output.put_line('Within the Rev. Component Defaulting . . . ');
448 
449     --  Initialize package global records
450 
451     g_rev_component_rec := p_rev_component_rec;
452     g_Rev_Comp_Unexp_Rec := p_Rev_Comp_Unexp_Rec;
453 
454     --  Default missing attributes.
455 
456 --dbms_output.put_line('Withing the entity level defaulting . . . ');
457 
458     /*******************************************************************
459     --
460     -- Default Component_Sequence_Id
461     --
462     ********************************************************************/
463     IF g_Rev_Comp_Unexp_Rec.component_sequence_id IS NULL OR
467     END IF;
464        g_Rev_Comp_Unexp_Rec.component_sequence_id = FND_API.G_MISS_NUM
465     THEN
466         g_Rev_Comp_Unexp_Rec.component_sequence_id := Get_Component_Sequence;
468 
469     /*******************************************************************
470     --
471     -- Default Bill_Sequence_Id
472     --
473     ********************************************************************/
474 
475     IF g_Rev_Comp_Unexp_rec.bill_sequence_id IS NULL THEN
476 
477         g_Rev_Comp_Unexp_Rec.bill_sequence_id := get_bill_sequence;
478 
479 --dbms_output.put_line('Generated Bill Sequence_id . . . ' ||
480 --		     to_char(g_rev_comp_Unexp_rec.bill_sequence_id));
481     END IF;
482 
483     /*******************************************************************
484     --
485     -- Default Required_For_Revenue
486     --
487     ********************************************************************/
488 
489     IF g_rev_component_rec.required_for_revenue IS NULL  THEN
490 
491         g_rev_component_rec.required_for_revenue := Get_Required_For_Revenue;
492 
493     END IF;
494 
495     /*******************************************************************
496     --
497     -- Default Planning_Factor
498     --
499     ********************************************************************/
500 
501     IF g_rev_component_rec.planning_percent IS NULL  THEN
502 
503         g_rev_component_rec.planning_percent := Get_Planning_Factor;
504 
505     END IF;
506 
507     /*******************************************************************
508     --
509     -- Default Operation_Seq_Num
510     --
511     ********************************************************************/
512 
513     IF g_rev_component_rec.operation_sequence_number IS NULL THEN
514 
515         g_rev_component_rec.operation_sequence_number := Get_Operation_Seq_Num;
516 
517     END IF;
518 
519 --dbms_output.put_line('After defaulting operation seq num . . .');
520 
521     /*******************************************************************
522     --
523     -- Default To_End_Item_Unit_Number
524     --
525     ********************************************************************/
526 
527     IF NVL(g_rev_component_rec.acd_type, FND_API.G_MISS_NUM) = 3 AND
528        g_rev_component_rec.to_end_item_unit_number IS NULL THEN
529 
530         g_rev_component_rec.to_end_item_unit_number := Get_To_End_Item_Number;
531 
532     END IF;
533 
534 --dbms_output.put_line('After defaulting to_end_item_unit_num. .');
535 
536     /*******************************************************************
537     --
538     -- Default Item_Num
539     --
540     ********************************************************************/
541 
542     IF g_rev_component_rec.item_sequence_number IS NULL THEN
543 
544         g_rev_component_rec.item_sequence_number := Get_Item_Num;
545 
546     END IF;
547 
548 --dbms_output.put_line('After defaulting item num . . . ');
549 
550     /*******************************************************************
551     --
552     -- Default Component_Quantity
553     --
554     ********************************************************************/
555 
556     IF g_rev_component_rec.quantity_per_assembly IS NULL THEN
557 
558         g_rev_component_rec.quantity_per_assembly := Get_Component_Quantity;
559 
560     END IF;
561 
562 --dbms_output.put_line('After defaulting component qunatity . . .');
563 
564     /*******************************************************************
565     --
566     -- Default Component_Yield_Factor (Projected_Yield)
567     --
568     ********************************************************************/
569 
570     IF g_rev_component_rec.projected_yield IS NULL THEN
571 
572         g_rev_component_rec.projected_yield := Get_Component_Yield_Factor;
573 
574     END IF;
575 
576 --dbms_output.put_line('After defaulting component yeild factor . . .');
577 
578     /*******************************************************************
579     --
580     -- Default Pick_Components
581     --
582     ********************************************************************/
583 
584     IF g_Rev_Comp_Unexp_Rec.pick_components IS NULL OR
585        g_rev_comp_unexp_rec.pick_components = FND_API.G_MISS_NUM
586     THEN
587 	g_Rev_Comp_Unexp_Rec.pick_components := Get_Pick_Components;
588     END IF;
589 
590 --dbms_output.put_line('After defaulting pick components . . .');
591 
592     /*******************************************************************
593     --
594     -- Default Effectivity Date
595     --
596     ********************************************************************/
597 
598     IF g_rev_component_rec.start_effective_date IS NULL THEN
599 
600         g_rev_component_rec.start_effective_date := Get_Effectivity_Date;
601 
602     END IF;
603 
604     /*******************************************************************
605     --
606     -- Default Disable Date
607     --
608     ********************************************************************/
609     IF g_rev_component_rec.disable_date = FND_API.G_MISS_DATE THEN
610 	g_rev_component_rec.disable_date := NULL;
611     END IF;
612 
613 --dbms_output.put_line('After Effectivity Defaulted . . .');
614 
615     /*******************************************************************
616     --
617     -- Default Planning Factor (Planning_Percent)
618     --
619     ********************************************************************/
620 
624 
621     IF g_rev_component_rec.planning_percent IS NULL THEN
622 
623         g_rev_component_rec.planning_percent := Get_Planning_Factor;
625     END IF;
626 
627     /*******************************************************************
628     --
629     -- Default Quantity Related
630     --
631     ********************************************************************/
632 
633     IF g_rev_component_rec.quantity_related IS NULL THEN
634 
635         g_rev_component_rec.quantity_related := Get_Quantity_Related;
636 
637     END IF;
638 
639     /*******************************************************************
640     --
641     -- Default  SO_Basis
642     --
643     ********************************************************************/
644     IF g_rev_component_rec.so_basis IS NULL THEN
645 
646         g_rev_component_rec.so_basis := Get_So_Basis;
647 
648     END IF;
649 
650     /*******************************************************************
651     --
652     -- Default Optional
653     --
654     ********************************************************************/
655     IF g_rev_component_rec.optional IS NULL THEN
656 
657         g_rev_component_rec.optional := Get_Optional;
658 
659     END IF;
660 
661     /*******************************************************************
662     --
663     -- Default Mutually_Exclusive_Options (Mutually_Exclusive)
664     --
665     ********************************************************************/
666     IF g_rev_component_rec.mutually_exclusive IS NULL THEN
667 
668         g_rev_component_rec.mutually_exclusive := Get_Mutually_Exclusive;
669 
670     END IF;
671 
672 --dbms_output.put_line('After Mutually Exclusive defualting . . . ');
673 
674     /*******************************************************************
675     --
676     -- Default Include_In_Cost_Rollup
677     --
678     ********************************************************************/
679     IF g_rev_component_rec.include_in_cost_rollup IS NULL THEN
680 
681         g_rev_component_rec.include_in_cost_rollup :=
682 						Get_Include_In_Cost_Rollup;
683 
684     END IF;
685 
686 --dbms_output.put_line('After include in cost rollup defualting . . . ');
687 
688     /*******************************************************************
689     --
690     -- Default Check_ATP
691     --
692     ********************************************************************/
693     IF g_rev_component_rec.check_atp IS NULL THEN
694 
695         g_rev_component_rec.check_atp := Get_Check_Atp;
696 
697     END IF;
698 
699 --dbms_output.put_line('After Check ATP Defualted . . . ');
700 
701     /*******************************************************************
702     --
703     -- Default Shipping Allowed
704     --
705     ********************************************************************/
706     IF g_rev_component_rec.shipping_allowed IS NULL THEN
707 
708         g_rev_component_rec.shipping_allowed := Get_Shipping_Allowed;
709 
710     END IF;
711 
712     /*******************************************************************
713     --
714     -- Default Required_To_Ship
715     --
716     ********************************************************************/
717     IF g_rev_component_rec.required_to_ship IS NULL THEN
718 
719         g_rev_component_rec.required_to_ship := Get_Required_To_Ship;
720 
721     END IF;
722 
723     /*******************************************************************
724     --
725     -- Default Include_On_Ship_Docs
726     --
727     ********************************************************************/
728     IF g_rev_component_rec.include_on_ship_docs IS NULL THEN
729 
730         g_rev_component_rec.include_on_ship_docs := Get_Include_On_Ship_Docs;
731 
732     END IF;
733 
734     /*******************************************************************
735     --
736     -- Default Supply Subinventory
737     -- If the user is trying to NULL to subinventory, then NULL out
738     -- Supply Locator also.
739     --
740     ********************************************************************/
741     IF g_rev_component_rec.supply_subinventory = FND_API.G_MISS_CHAR THEN
742  	g_rev_component_rec.supply_subinventory := NULL;
743 	g_Rev_Comp_Unexp_Rec.Supply_Locator_Id  := NULL;
744     END IF;
745 
746 --dbms_output.put_line('Subinventory . . . ' ||
747 --		     g_rev_component_rec.supply_subinventory );
748 
749     IF g_rev_component_rec.comments = FND_API.G_MISS_CHAR THEN
750 	g_rev_component_rec.comments := NULL;
751     END IF;
752 
753     IF g_rev_component_rec.wip_supply_type = FND_API.G_MISS_NUM THEN
754 	g_rev_component_rec.wip_supply_type := NULL;
755     END IF;
756 
757     IF g_rev_comp_Unexp_rec.bom_item_type IS NULL OR
758        g_rev_comp_unexp_rec.bom_item_type = FND_API.G_MISS_NUM
759     THEN
760 	g_rev_comp_Unexp_rec.bom_item_type := get_bom_item_type;
761     END IF;
762 
763     IF g_rev_component_rec.acd_type = FND_API.G_MISS_NUM THEN
764 	g_rev_component_rec.acd_type := NULL;
765     END IF;
766 
767     IF g_rev_comp_unexp_rec.supply_locator_id = FND_API.G_MISS_NUM THEN
768 	g_rev_comp_unexp_rec.supply_locator_id := NULL;
769     END IF;
770 
771     IF g_rev_component_rec.attribute_category = FND_API.G_MISS_CHAR
772     OR  g_rev_component_rec.attribute1 = FND_API.G_MISS_CHAR
773     OR  g_rev_component_rec.attribute2 = FND_API.G_MISS_CHAR
774     OR  g_rev_component_rec.attribute3 = FND_API.G_MISS_CHAR
775     OR  g_rev_component_rec.attribute4 = FND_API.G_MISS_CHAR
779     OR  g_rev_component_rec.attribute8 = FND_API.G_MISS_CHAR
776     OR  g_rev_component_rec.attribute5 = FND_API.G_MISS_CHAR
777     OR  g_rev_component_rec.attribute6 = FND_API.G_MISS_CHAR
778     OR  g_rev_component_rec.attribute7 = FND_API.G_MISS_CHAR
780     OR  g_rev_component_rec.attribute9 = FND_API.G_MISS_CHAR
781     OR  g_rev_component_rec.attribute10 = FND_API.G_MISS_CHAR
782     OR  g_rev_component_rec.attribute11 = FND_API.G_MISS_CHAR
783     OR  g_rev_component_rec.attribute12 = FND_API.G_MISS_CHAR
784     OR  g_rev_component_rec.attribute13 = FND_API.G_MISS_CHAR
785     OR  g_rev_component_rec.attribute14 = FND_API.G_MISS_CHAR
786     OR  g_rev_component_rec.attribute15 = FND_API.G_MISS_CHAR
787     THEN
788 
789         Get_Flex_Rev_Component;
790 
791     END IF;
792 
793   x_rev_component_rec := g_rev_component_rec;
794   x_Rev_Comp_Unexp_Rec := g_Rev_Comp_Unexp_Rec;
795 
796 --dbms_output.put_line('Getting out of Attribute Defualting . . . ');
797 
798 END Attribute_Defaulting;
799 
800 /******************************************************************************
801 * Procedure	: Populate_Null_Columns (earlier called Complete_Record)
802 * Parameters IN	: Revised Component exposed column record
803 *		  Revised Component DB record of exposed columns
804 *		  Revised Component unexposed column record
805 *		  Revised Component DB record of unexposed columns
806 * Parameters OUT: Revised Component exposed Record
807 * 		  Revised Component Unexposed Record
808 * Purpose	: Complete record will compare the database record with the
809 *		  user given record and will complete the user record with
810 *		  values from the database record, for all columns that the
811 *		  user has left NULL.
812 ******************************************************************************/
813 PROCEDURE Populate_Null_Columns
814 ( p_rev_component_rec		IN  Bom_Bo_Pub.Rev_Component_Rec_Type
815 , p_old_rev_component_rec	IN  Bom_Bo_Pub.Rev_Component_Rec_Type
816 , p_Rev_Comp_Unexp_Rec		IN  Bom_Bo_Pub.Rev_Comp_Unexposed_Rec_Type
817 , p_Old_Rev_Comp_Unexp_Rec	IN  Bom_Bo_Pub.Rev_Comp_Unexposed_Rec_Type
818 , x_Rev_Component_Rec		IN OUT NOCOPY Bom_Bo_Pub.Rev_Component_Rec_Type
819 , x_Rev_Comp_Unexp_Rec		IN OUT NOCOPY Bom_Bo_Pub.Rev_Comp_Unexposed_Rec_Type
820 )
821 IS
822 l_rev_component_rec	Bom_Bo_Pub.Rev_Component_Rec_Type :=
823 			p_rev_component_rec;
824 l_Rev_Comp_Unexp_Rec	Bom_Bo_Pub.Rev_Comp_Unexposed_Rec_Type :=
825 			p_Rev_Comp_Unexp_Rec;
826 BEGIN
827 
828     IF l_rev_component_rec.supply_subinventory IS NULL THEN
829         l_rev_component_rec.supply_subinventory :=
830 	p_old_rev_component_rec.supply_subinventory;
831 
832     ELSIF l_rev_component_rec.Supply_Subinventory IS NOT NULL AND
833 	  l_rev_component_rec.Supply_Subinventory <>
834 	  p_old_rev_component_rec.supply_subinventory AND
835 	  ( ( l_rev_comp_unexp_rec.supply_locator_id     IS NOT NULL AND
836 	      p_old_rev_comp_unexp_rec.supply_locator_id IS NOT NULL
837 	     ) AND
838 	     ( l_rev_comp_unexp_rec.supply_locator_id =
839 	       p_old_rev_comp_unexp_rec.supply_locator_id OR
840 	       ( l_rev_comp_unexp_rec.supply_locator_id IS NOT NULL AND
841 		 l_rev_comp_unexp_rec.supply_locator_id = FND_API.G_MISS_NUM
842 		)
843 	      )
844 	   )
845     THEN
846 	   l_rev_comp_unexp_rec.supply_locator_id := NULL;
847 	   -- Give out a warning indicating the locator has been made NULL.
848 
849     ELSIF l_rev_component_rec.Supply_Subinventory IS NOT NULL AND
850           l_rev_component_rec.Supply_Subinventory <>
851           p_old_rev_component_rec.supply_subinventory AND
852 	  l_rev_comp_unexp_rec.supply_locator_id = FND_API.G_MISS_NUM
853     THEN
854 --	  dbms_output.put_line('Supply Locator made NULL . . .');
855 
856            l_rev_comp_unexp_rec.supply_locator_id := NULL;
857            -- Give out a warning indicating the locator has been made NULL.
858 
859     ELSIF l_rev_component_rec.Supply_Subinventory IS NOT NULL AND
860 	  l_rev_component_rec.Supply_Subinventory =
861           p_old_rev_component_rec.supply_subinventory  AND
862 	  p_rev_comp_unexp_rec.supply_locator_id IS NULL
863     THEN
864 	  l_rev_comp_unexp_rec.supply_locator_id :=
865 	  p_old_rev_comp_unexp_rec.supply_locator_id;
866     END IF;
867 
868     IF l_rev_component_rec.required_for_revenue IS NULL
869     THEN
870         l_rev_component_rec.required_for_revenue :=
871 	p_old_rev_component_rec.required_for_revenue;
872     END IF;
873 
874     IF l_rev_component_rec.maximum_allowed_quantity IS NULL
875     THEN
876         l_rev_component_rec.maximum_allowed_quantity :=
877 	p_old_rev_component_rec.maximum_allowed_quantity;
878     END IF;
879 
880     IF l_rev_component_rec.wip_supply_type IS NULL THEN
881         l_rev_component_rec.wip_supply_type :=
882 	p_old_rev_component_rec.wip_supply_type;
883     END IF;
884 
885     IF l_rev_component_rec.operation_sequence_number IS NULL
886     THEN
887         l_rev_component_rec.operation_sequence_number :=
888 	p_old_rev_component_rec.operation_sequence_number;
889     END IF;
890 
891     IF l_rev_component_rec.item_sequence_number IS NULL THEN
892         l_rev_component_rec.item_sequence_number :=
893 	p_old_rev_component_rec.item_sequence_number;
894     END IF;
895 
896     IF l_rev_component_rec.quantity_per_assembly IS NULL THEN
897         l_rev_component_rec.quantity_per_assembly :=
898 	p_old_rev_component_rec.quantity_per_assembly;
899     END IF;
900 
901     IF l_rev_component_rec.projected_yield IS NULL
902     THEN
903         l_rev_component_rec.projected_yield :=
904 	p_old_rev_component_rec.projected_yield;
905     END IF;
906 
907     IF l_rev_component_rec.comments IS NULL
908     THEN
909         l_rev_component_rec.comments :=
913     IF l_rev_component_rec.disable_date IS NULL THEN
910 	p_old_rev_component_rec.comments ;
911     END IF;
912 
914         l_rev_component_rec.disable_date :=
915 	p_old_rev_component_rec.disable_date;
916     END IF;
917 
918     IF l_rev_component_rec.attribute_category IS NULL THEN
919         l_rev_component_rec.attribute_category :=
920 	p_old_rev_component_rec.attribute_category;
921     END IF;
922 
923     IF l_rev_component_rec.attribute1 IS NULL THEN
924         l_rev_component_rec.attribute1 := p_old_rev_component_rec.attribute1;
925     END IF;
926 
927     IF l_rev_component_rec.attribute2  IS NULL THEN
928         l_rev_component_rec.attribute2 := p_old_rev_component_rec.attribute2;
929     END IF;
930 
931     IF l_rev_component_rec.attribute3 IS NULL THEN
932         l_rev_component_rec.attribute3 := p_old_rev_component_rec.attribute3;
933     END IF;
934 
935     IF l_rev_component_rec.attribute4 IS NULL THEN
936         l_rev_component_rec.attribute4 := p_old_rev_component_rec.attribute4;
937     END IF;
938 
939     IF l_rev_component_rec.attribute5 IS NULL THEN
940         l_rev_component_rec.attribute5 := p_old_rev_component_rec.attribute5;
941     END IF;
942 
943     IF l_rev_component_rec.attribute6 IS NULL THEN
944         l_rev_component_rec.attribute6 := p_old_rev_component_rec.attribute6;
945     END IF;
946 
947     IF l_rev_component_rec.attribute7 IS NULL THEN
948         l_rev_component_rec.attribute7 := p_old_rev_component_rec.attribute7;
949     END IF;
950 
951     IF l_rev_component_rec.attribute8 IS NULL THEN
952         l_rev_component_rec.attribute8 := p_old_rev_component_rec.attribute8;
953     END IF;
954 
955     IF l_rev_component_rec.attribute9 IS NULL THEN
956         l_rev_component_rec.attribute9 := p_old_rev_component_rec.attribute9;
957     END IF;
958 
959     IF l_rev_component_rec.attribute10 IS NULL THEN
960         l_rev_component_rec.attribute10 := p_old_rev_component_rec.attribute10;
961     END IF;
962 
963     IF l_rev_component_rec.attribute11 IS NULL THEN
964         l_rev_component_rec.attribute11 := p_old_rev_component_rec.attribute11;
965     END IF;
966 
967     IF l_rev_component_rec.attribute12 IS NULL THEN
968         l_rev_component_rec.attribute12 := p_old_rev_component_rec.attribute12;
969     END IF;
970 
971     IF l_rev_component_rec.attribute13 IS NULL THEN
972         l_rev_component_rec.attribute13 := p_old_rev_component_rec.attribute13;
973     END IF;
974 
975     IF l_rev_component_rec.attribute14 IS NULL THEN
976         l_rev_component_rec.attribute14 := p_old_rev_component_rec.attribute14;
977     END IF;
978 
979     IF l_rev_component_rec.attribute15 IS NULL THEN
980         l_rev_component_rec.attribute15 := p_old_rev_component_rec.attribute15;
981     END IF;
982 
983     IF l_rev_component_rec.planning_percent IS NULL
984     THEN
985         l_rev_component_rec.planning_percent :=
986 	p_old_rev_component_rec.planning_percent;
987     END IF;
988 
989     IF l_rev_component_rec.quantity_related IS NULL THEN
990         l_rev_component_rec.quantity_related :=
991 	p_old_rev_component_rec.quantity_related;
992     END IF;
993 
994     IF l_rev_component_rec.so_basis IS NULL THEN
995         l_rev_component_rec.so_basis := p_old_rev_component_rec.so_basis;
996     END IF;
997 
998     IF l_rev_component_rec.optional IS NULL THEN
999         l_rev_component_rec.optional := p_old_rev_component_rec.optional;
1000     END IF;
1001 
1002     IF l_rev_component_rec.mutually_exclusive IS NULL THEN
1003         l_rev_component_rec.mutually_exclusive :=
1004 	p_old_rev_component_rec.mutually_exclusive;
1005     END IF;
1006 
1007     IF l_rev_component_rec.include_in_cost_rollup IS NULL THEN
1008         l_rev_component_rec.include_in_cost_rollup :=
1009 	p_old_rev_component_rec.include_in_cost_rollup;
1010     END IF;
1011 
1012     IF l_rev_component_rec.check_atp IS NULL THEN
1013         l_rev_component_rec.check_atp := p_old_rev_component_rec.check_atp;
1014     END IF;
1015 
1016     IF l_rev_component_rec.shipping_allowed IS NULL THEN
1017         l_rev_component_rec.shipping_allowed :=
1018 	p_old_rev_component_rec.shipping_allowed;
1019     END IF;
1020 
1021     IF l_rev_component_rec.required_to_ship IS NULL THEN
1022         l_rev_component_rec.required_to_ship :=
1023 	p_old_rev_component_rec.required_to_ship;
1024     END IF;
1025 
1026     IF l_rev_component_rec.include_on_ship_docs IS NULL THEN
1027         l_rev_component_rec.include_on_ship_docs :=
1028 	p_old_rev_component_rec.include_on_ship_docs;
1029     END IF;
1030 
1031     IF l_rev_component_rec.minimum_allowed_quantity IS NULL THEN
1032         l_rev_component_rec.minimum_allowed_quantity :=
1033 	p_old_rev_component_rec.minimum_allowed_quantity;
1034     END IF;
1035 
1036     IF l_rev_component_rec.acd_type IS NULL THEN
1037        l_rev_component_rec.acd_type := p_old_rev_component_rec.acd_type;
1038     END IF;
1039 
1040     --
1041     -- Also copy the Unexposed Columns from Database to New record
1042     --
1043     IF l_rev_component_rec.transaction_type <> Bom_GLOBALS.G_OPR_CREATE THEN
1044 
1045 	l_Rev_Comp_Unexp_Rec.component_sequence_id :=
1046 	p_Old_Rev_Comp_Unexp_Rec.component_sequence_id;
1047 
1048     	l_Rev_Comp_Unexp_Rec.old_component_Sequence_id :=
1049     	p_Old_Rev_Comp_Unexp_Rec.old_component_Sequence_id;
1050 
1051 	l_Rev_Comp_Unexp_Rec.Revised_Item_Sequence_Id :=
1052 	p_Old_Rev_Comp_Unexp_Rec.Revised_Item_Sequence_Id;
1053 
1054 --	dbms_output.put_line('Comp Seq: ' ||
1055 --		to_char(l_Rev_Comp_Unexp_Rec.component_sequence_id));
1056 
1057     END IF;
1058 
1059     l_Rev_Comp_Unexp_Rec.Bom_Item_Type :=
1060     p_Old_Rev_Comp_Unexp_Rec.Bom_Item_Type;
1061 
1062     l_Rev_Comp_Unexp_Rec.Include_On_Bill_Docs :=
1063     p_Old_Rev_Comp_Unexp_Rec.Include_On_Bill_Docs;
1064 
1065     l_rev_comp_unexp_rec.pick_components :=
1066     p_old_rev_comp_unexp_rec.pick_components;
1067 
1068 
1069     x_Rev_Component_Rec := l_rev_component_rec;
1070     x_Rev_Comp_Unexp_Rec := l_Rev_Comp_Unexp_Rec;
1071 
1072 END Populate_Null_Columns;
1073 
1074 PROCEDURE Entity_Defaulting
1075 (   p_rev_component_rec             IN  Bom_Bo_Pub.Rev_Component_Rec_Type
1076 ,   p_old_rev_component_rec         IN  Bom_Bo_Pub.Rev_Component_Rec_Type :=
1077                                         Bom_Bo_Pub.G_MISS_REV_COMPONENT_REC
1078 ,   x_rev_component_rec             IN OUT NOCOPY Bom_Bo_Pub.Rev_Component_Rec_Type
1079 )
1080 IS
1081 BEGIN
1082 
1083     --  Load out record
1084 
1085     x_rev_component_rec := p_rev_component_rec;
1086 
1087     IF p_rev_component_rec.maximum_allowed_quantity IS NOT NULL AND
1088        p_rev_component_rec.minimum_allowed_quantity IS NULL
1089     THEN
1090         x_rev_component_rec.minimum_allowed_quantity :=
1091 			p_rev_component_rec.quantity_per_assembly;
1092     END IF;
1093 
1094     IF p_rev_component_rec.maximum_allowed_quantity IS NULL AND
1095        p_rev_component_rec.minimum_allowed_quantity IS NOT NULL
1096     THEN
1097         x_rev_component_rec.maximum_allowed_quantity :=
1098 		p_rev_component_rec.quantity_per_assembly;
1099     END IF;
1100 
1101 END Entity_Defaulting;
1102 
1103 
1104 END ENG_Default_Rev_Component;