DBA Data[Home] [Help]

APPS.BOMPIINQ SQL Statements

The following lines contain the word 'select', 'insert', 'update' or 'delete':

Line: 67

	 SELECT MASTER_ORGANIZATION_ID L_MASTER_ORG
	 FROM MTL_PARAMETERS
	 WHERE ORGANIZATION_ID = c_organization_id;
Line: 86

     /*		SELECT organization_name into l_org_name
		FROM   org_organization_definitions
		WHERE  organization_id = org_id;
Line: 105

		for C1 in (  SELECT orgs.ORGANIZATION_ID
                             FROM ORG_ACCESS_VIEW oav,  MTL_SYSTEM_ITEMS_B msi,
				  MTL_PARAMETERS orgs,  MTL_PARAMETERS child_org
			     WHERE orgs.ORGANIZATION_ID = oav.ORGANIZATION_ID
		             AND msi.ORGANIZATION_ID = orgs.ORGANIZATION_ID
		             AND orgs.MASTER_ORGANIZATION_ID =  child_org.MASTER_ORGANIZATION_ID
		             AND oav.RESPONSIBILITY_ID = FND_PROFILE.Value('RESP_ID')
		             AND oav.RESP_APPLICATION_ID =  FND_PROFILE.value('RESP_APPL_ID')
		             AND msi.INVENTORY_ITEM_ID = item_id
		             AND child_org.ORGANIZATION_ID = org_id
			)
		LOOP
			N:=N+1;
Line: 145

                        select count(*) into dummy from mtl_system_items where
                        organization_id = t_org_code_list(I) and
                        inventory_item_id = item_id;
Line: 161

		/*INSERT INTO BOM_SMALL_IMPL_TEMP
			( SEQUENCE_ID,
			LOWEST_ITEM_ID,
			CURRENT_ITEM_ID,
			PARENT_ITEM_ID,
			ALTERNATE_DESIGNATOR,
			CURRENT_LEVEL,
			SORT_CODE,
			CURRENT_ASSEMBLY_TYPE,
			COMPONENT_SEQUENCE_ID,
			ORGANIZATION_ID,
			LAST_UPDATE_DATE,
			LAST_UPDATED_BY,
			CREATION_DATE,
			CREATED_BY,
			implosion_date)
		VALUES (sequence_id,
			item_id,
			item_id,
			item_id,
			NULL,
			0,
		--	'0000001',
			 Bom_Common_Definitions.G_Bom_Init_SortCode,
			NULL,
			NULL,
			t_org_code_list(I),
			sysdate,
			-1,
			sysdate,
			-1,
			to_date(impl_date, 'YYYY/MM/DD HH24:MI')); */
Line: 194

		  INSERT INTO BOM_SMALL_IMPL_TEMP
			( SEQUENCE_ID,
			LOWEST_ITEM_ID,
			CURRENT_ITEM_ID,
			PARENT_ITEM_ID,
			ALTERNATE_DESIGNATOR,
			CURRENT_LEVEL,
			SORT_CODE,
			CURRENT_ASSEMBLY_TYPE,
			COMPONENT_SEQUENCE_ID,
			ORGANIZATION_ID,
			LAST_UPDATE_DATE,
			LAST_UPDATED_BY,
			CREATION_DATE,
			CREATED_BY,
			IMPLOSION_DATE)
		   (
		    SELECT
			sequence_id,
			item_id,
			item_id,
			item_id,
			NULL,
			0,
			--'0001',
			Bom_Common_Definitions.G_Bom_Init_SortCode,
			NULL,
			NULL,
			t_org_code_list(I),
			sysdate,
			-1,
			sysdate,
			-1,
			to_date(impl_date, 'YYYY/MM/DD HH24:MI')
		    FROM DUAL
		    WHERE NOT EXISTS
		      ( SELECT 'X'
			FROM   BOM_SMALL_IMPL_TEMP
			WHERE  SEQUENCE_ID	        = sequence_id
			AND LOWEST_ITEM_ID	        = item_id
			AND CURRENT_ITEM_ID	        = item_id
			AND PARENT_ITEM_ID	        = item_id
			AND ALTERNATE_DESIGNATOR	IS NULL
			AND CURRENT_LEVEL	        = 0
			AND SORT_CODE			= Bom_Common_Definitions.G_Bom_Init_SortCode
			AND CURRENT_ASSEMBLY_TYPE	IS NULL
			AND COMPONENT_SEQUENCE_ID	IS NULL
			AND ORGANIZATION_ID	        = t_org_code_list(I)
		     )
		);
Line: 345

        SELECT  /*+ ordered first_rows */
	         BITT.LOWEST_ITEM_ID LID,
                 BITT.PARENT_ITEM_ID PID,
                 BBM.ASSEMBLY_ITEM_ID AID,
                 BBM.ALTERNATE_BOM_DESIGNATOR ABD,
                 BITT.SORT_CODE SC,
                 BITT.LOWEST_ALTERNATE_DESIGNATOR LAD,
		 BBM.ASSEMBLY_TYPE CAT,
		 BIC.COMPONENT_SEQUENCE_ID CSI,
      		 BIC.OPERATION_SEQ_NUM OSN,
        	 BIC.EFFECTIVITY_DATE ED,
                 BIC.DISABLE_DATE DD,
                 BIC.BASIS_TYPE BT,
      		 BIC.COMPONENT_QUANTITY CQ,
		 BIC.REVISED_ITEM_SEQUENCE_ID RISD,
		 BIC.CHANGE_NOTICE CN,
		 DECODE(BIC.IMPLEMENTATION_DATE, NULL, 2, 1) IMPF,
		 BBM.ORGANIZATION_ID OI,
		 BIC.FROM_END_ITEM_UNIT_NUMBER FUN,
	         BIC.TO_END_ITEM_UNIT_NUMBER TUN
        FROM
		BOM_SMALL_IMPL_TEMP BITT,
                BOM_INVENTORY_COMPONENTS BIC,
                BOM_BILL_OF_MATERIALS BBM,
		MTL_SYSTEM_ITEMS MSI
	where bitt.current_level = 0
        and   bitt.organization_id = c_org_id
	and   MSI.ORGANIZATION_ID = BBM.ORGANIZATION_ID
	and   MSI.INVENTORY_ITEM_ID = BBM.ASSEMBLY_ITEM_ID
	and   bitt.sequence_id = c_sequence_id
	and   bitt.parent_item_id = bic.component_item_id
	and   bic.bill_sequence_id = bbm.common_bill_sequence_id
	and   bbm.organization_id = c_org_id
	and   NVL(BIC.ECO_FOR_PRODUCTION,2) = 2
	and   (
       		( c_eng_mfg_flag = 1
        	      and bbm.assembly_type = 1
		) /* get only Mfg boms */
        	or
        	(c_eng_mfg_flag = 2
		) /*both Mfg-Eng BOMs in ENG mode*/
	      ) /* end of entire and predicate */
	and ( /* match par alt */
	      ((bbm.alternate_bom_designator is null and
		 	bitt.lowest_alternate_designator is null)
		or
	      (bbm.alternate_bom_designator =
			bitt.lowest_alternate_designator))
     	        or /* Pickup par with spec alt only, if start alt is null,*/
	      ( bitt.lowest_alternate_designator is null /*and bill with spec*/
      		and bbm.alternate_bom_designator is not null
						/* alt doesnt exist */
      		and not exists (select NULL     /*for current item */
                      from bom_bill_of_materials bbm2
                      where bbm2.organization_id = c_org_id
                      and   bbm2.assembly_item_id = bitt.parent_item_id
                      and   bbm2.alternate_bom_designator =
                                bbm.alternate_bom_designator
                      and (
                           (bitt.current_assembly_type = 1
                            and bbm2.assembly_type = 1)
                           or
                           (bitt.current_assembly_type = 2)
                          )
                     ) /* end of subquery */
     	      ) /* end of parent with specific alt */
 	      or /* Pickup prim par only if start alt is not null and bill 4*/
 	      ( bitt.lowest_alternate_designator is not null
						/* same par doesnt */
      		and bbm.alternate_bom_designator is null
						/* exist with this alt */
      		and not exists (select NULL
                      from bom_bill_of_materials bbm2
                      where bbm2.organization_id = c_org_id
                      and   bbm2.assembly_item_id = bbm.assembly_item_id
                      and   bbm2.alternate_bom_designator =
                                bitt.lowest_alternate_designator
                      and (
                           (bitt.current_assembly_type = 1
                            and bbm2.assembly_type = 1)
                           or
                           (bitt.current_assembly_type = 2)
                          )
                     ) /* end of subquery */
     	      ) /* end of parent with null alt */
     	    )/* end of all alternate logic */
	and ( /* Effectivity_control */
	    ( msi.effectivity_control =1   -- Date Effectivity
             AND
            ( /* start of all display options */
     	      ( c_display_option = 2
      		and bic.effectivity_date
         		<= to_date (c_implosion_date, 'YYYY/MM/DD HH24:MI')
      		and  ( bic.disable_date is null
            	       or bic.disable_date >
                	  to_date (c_implosion_date, 'YYYY/MM/DD HH24:MI')
            	     )
     	      ) /* end of CURRENT */
     	      or
     	      c_display_option = 1
     	      or
     	      ( c_display_option = 3
      		and ( bic.disable_date is null
            	      or bic.disable_date >
                   	    to_date (c_implosion_date, 'YYYY/MM/DD HH24:MI')
            	    )
     	      ) /* end of CURRENT_AND_FUTURE */
    	    ) /* end of all display options */
	  ) /* msi.effectivity_control =1 */
           OR  (
		 msi.effectivity_control =2 -- Unit Number Effectivity
                 AND nvl(msi.eam_item_type,0) <> 1 -- do not include serial eff EAM items
	        AND
                 c_unit_number_from is NOT NULL -- Profile Model/Unit Eff=YES
	        AND
                 (c_display_option = 1
                  OR (c_display_option in (2,3) AND bic.disable_date is null))
                AND
		 BIC.FROM_END_ITEM_UNIT_NUMBER <= c_unit_number_to
                AND
		 NVL(BIC.TO_END_ITEM_UNIT_NUMBER,c_unit_number_from) >= c_unit_number_from
            	)
           OR  (
		 msi.effectivity_control =2 -- Unit Number Effectivity
                 AND nvl(msi.eam_item_type,0) = 1 -- include only serial eff EAM items
	        AND
                 c_serial_number_from is NOT NULL -- Serial Effectivity for EAM items
	        AND
                 (c_display_option = 1
                  OR (c_display_option in (2,3) AND bic.disable_date is null))
                AND
		 BIC.FROM_END_ITEM_UNIT_NUMBER <= c_serial_number_to
                AND
		 NVL(BIC.TO_END_ITEM_UNIT_NUMBER,c_serial_number_from) >= c_serial_number_from
            	)
	   ) /* end of effectivity control */
	and ( /* effectivity_control */
           ( msi.effectivity_control =1 -- Date Effectivity
             AND
            ( /* start of implemented yes/no logic */
     	      ( c_implemented_only_option = 1
      		and bic.implementation_date is not null
     	      )
     	      or
     	      ( c_implemented_only_option = 2
      		and ( /* start of all display */
            	( c_display_option = 2
              	  and
              	  bic.effectivity_date =
                	(select max(effectivity_date)
                 	    from bom_inventory_components bic2
                 	    where bic2.bill_sequence_id = bic.bill_sequence_id
                 	    and  bic2.component_item_id = bic.component_item_id
			    and  NVL(BIC2.ECO_FOR_PRODUCTION,2) = 2
                 	    and   decode(bic.implementation_date, NULL,
                          	bic.old_component_sequence_id,
                          	bic.component_sequence_id) =
                        	decode(bic2.implementation_date, NULL,
                          	bic2.old_component_sequence_id,
                          	bic2.component_sequence_id)
                 	    and trunc(bic2.effectivity_date, 'MI') <=
					to_date(c_implosion_date,
                                                'YYYY/MM/DD HH24:MI')
			    and NOT EXISTS (SELECT null
			                  FROM bom_inventory_components bic3
                                         WHERE bic3.bill_sequence_id =
					       bic.bill_sequence_id
					   AND bic3.old_component_sequence_id =
					       bic.component_sequence_id
			                   AND NVL(BIC3.ECO_FOR_PRODUCTION,2)= 2
					   AND bic3.acd_type in (2,3)
					   AND bic3.disable_date <=
                                               to_date(c_implosion_date,
						       'YYYY/MM/DD HH24:MI'))
                 	    and ( bic2.disable_date >
					to_date(c_implosion_date,
                                                'YYYY/MM/DD HH24:MI')
				  or bic2.disable_date is null )
                	) /* end of subquery */
                ) /* end of CURRENT */
          	or
            	( c_display_option = 3
             	  and bic.effectivity_date =
                	(select max(effectivity_date)
                 	    from bom_inventory_components bic2
                 	    where bic2.bill_sequence_id = bic.bill_sequence_id
                 	    and  bic2.component_item_id = bic.component_item_id
			    and  NVL(bic2.ECO_FOR_PRODUCTION,2) = 2
                 	    and   nvl(bic2.old_component_sequence_id,
                                bic2.component_sequence_id) =
                          	nvl(bic.old_component_sequence_id,
                                bic.component_sequence_id)
                 	    and bic2.effectivity_date <=
					to_date(c_implosion_date,
                                                'YYYY/MM/DD HH24:MI')
			    and NOT EXISTS (SELECT null
			                  FROM bom_inventory_components bic4
                                         WHERE bic4.bill_sequence_id =
					       bic.bill_sequence_id
					   AND bic4.old_component_sequence_id =
					       bic.component_sequence_id
			                   AND NVL(bic4.ECO_FOR_PRODUCTION,2)= 2
					   AND bic4.acd_type in (2,3)
					   AND bic4.disable_date <=
                                               to_date(c_implosion_date,
						       'YYYY/MM/DD HH24:MI'))
                	    and ( bic2.disable_date >
					to_date(c_implosion_date,
                                                'YYYY/MM/DD HH24:MI')
                        	  or bic2.disable_date is null )
                	) /* end of subquery */
              		or
			bic.effectivity_date > to_date(c_implosion_date,
                                                'YYYY/MM/DD HH24:MI')
                 ) /* end of current and future */
          	 or
            	 ( c_display_option = 1)
      	       ) /* end of all display */
     	     ) /* end of impl = no */
    	   ) /* end of impl = yes-no */
	  ) /* effectivity_control = 1 */
          OR  /* serial effectivity control */
	   ( MSI.effectivity_control=2  -- Unit Effectivity
             AND nvl(msi.eam_item_type,0) <> 1 -- do not include serial eff EAM items
             AND
		c_unit_number_from is NOT NULL
             AND
            ( /* start of implemented yes/no logic */
     	      ( c_implemented_only_option = 1
      		and bic.implementation_date is not null
     	       )
     	      or
     	      ( c_implemented_only_option = 2 )
	     )
	  ) /* effectivity_control = 2 */
          OR  /* serial effectivity control */
	   ( MSI.effectivity_control=2  -- Serial Effectivity for EAM items
             AND nvl(msi.eam_item_type,0) = 1 -- include only serial eff EAM items
             AND
		c_serial_number_from is NOT NULL
             AND
            ( /* start of implemented yes/no logic */
     	      ( c_implemented_only_option = 1
      		and bic.implementation_date is not null
     	       )
     	      or
     	      ( c_implemented_only_option = 2 )
	     )
	  ) /* effectivity_control = 2 */
	 ) /* effectivity_control*/
	   order by bitt.parent_item_id,
		    bbm.assembly_item_id, bic.operation_seq_num;
Line: 600

      Select 1 dummy
      From mtl_system_items msi1,
           mtl_system_items msi2
      Where msi1.inventory_item_id = P_Parent_Item
      And   msi1.organization_id = org_id
      And   msi2.inventory_item_id = P_Comp_Item
      And   msi2.organization_id = org_id
      And   msi1.bom_item_type = 4 -- Standard
      And   msi1.replenish_to_order_flag = 'Y'
      And   msi1.base_item_id is not null -- configured item
      And   msi2.bom_item_type in (1, 2); -- model or option class
Line: 613

      Select 1 dummy
      From mtl_system_items msi
      Where msi.inventory_item_id = P_Parent_Item
      And   msi.organization_id = org_id
      And   msi.bom_enabled_flag = 'N';
Line: 684

                l_lid1.delete;
Line: 685

                l_pid1.delete;
Line: 686

                l_aid1.delete;
Line: 687

                l_abd1.delete;
Line: 688

                l_sc1.delete;
Line: 689

                l_lad1.delete;
Line: 690

                l_cat1.delete;
Line: 691

                l_csi1.delete;
Line: 692

                l_oi1.delete;
Line: 693

                l_osn1.delete;
Line: 694

                l_ed1.delete;
Line: 695

                l_dd1.delete;
Line: 696

                l_fun1.delete;
Line: 697

                l_tun1.delete;
Line: 698

                l_bt1.delete;
Line: 699

                l_cq1.delete;
Line: 700

                l_risd1.delete;
Line: 701

                l_cn1.delete;
Line: 702

                l_impf1.delete;
Line: 704

                l_lid.delete;
Line: 705

                l_pid.delete;
Line: 706

                l_aid.delete;
Line: 707

                l_abd.delete;
Line: 708

                l_sc.delete;
Line: 709

                l_lad.delete;
Line: 710

                l_cat.delete;
Line: 711

                l_csi.delete;
Line: 712

                l_oi.delete;
Line: 713

                l_osn.delete;
Line: 714

                l_ed.delete;
Line: 715

                l_dd.delete;
Line: 716

                l_fun.delete;
Line: 717

                l_tun.delete;
Line: 718

                l_bt.delete;
Line: 719

                l_cq.delete;
Line: 720

                l_risd.delete;
Line: 721

                l_cn.delete;
Line: 722

                l_impf.delete;
Line: 759

                l_lid.delete(i);
Line: 760

                l_pid.delete(i);
Line: 761

                l_aid.delete(i);
Line: 762

                l_abd.delete(i);
Line: 763

                l_sc.delete(i);
Line: 764

                l_lad.delete(i);
Line: 765

                l_cat.delete(i);
Line: 766

                l_csi.delete(i);
Line: 767

                l_oi.delete(i);
Line: 768

                l_osn.delete(i);
Line: 769

                l_ed.delete(i);
Line: 770

                l_dd.delete(i);
Line: 771

                l_fun.delete(i);
Line: 772

                l_tun.delete(i);
Line: 773

                l_bt.delete(i);
Line: 774

                l_cq.delete(i);
Line: 775

                l_risd.delete(i);
Line: 776

                l_cn.delete(i);
Line: 777

                l_impf.delete(i);
Line: 827

            /*INSERT INTO BOM_SMALL_IMPL_TEMP
                (LOWEST_ITEM_ID,
                 CURRENT_ITEM_ID,
                 PARENT_ITEM_ID,
                 ALTERNATE_DESIGNATOR,
                 CURRENT_LEVEL,
                 SORT_CODE,
                 LOWEST_ALTERNATE_DESIGNATOR,
                 CURRENT_ASSEMBLY_TYPE,
                 SEQUENCE_ID,
                 COMPONENT_SEQUENCE_ID,
                 ORGANIZATION_ID,
                 OPERATION_SEQ_NUM,
                 EFFECTIVITY_DATE,
                 DISABLE_DATE,
                 FROM_END_ITEM_UNIT_NUMBER,
                 TO_END_ITEM_UNIT_NUMBER,
                 COMPONENT_QUANTITY,
                 REVISED_ITEM_SEQUENCE_ID,
                 CHANGE_NOTICE,
                 IMPLEMENTED_FLAG,
                 LAST_UPDATE_DATE,
                 LAST_UPDATED_BY,
                 CREATION_DATE,
                 CREATED_BY,
                 PARENT_SORT_CODE,
		 implosion_date) VALUES (
                l_lid1(i),
                l_pid1(i),
                l_aid1(i),
                l_abd1(i),
                1,
                l_sc1(i),
                l_lad1(i),
                l_cat1(i),
                sequence_id,
                l_csi1(i),
                l_oi1(i),
                l_osn1(i),
                l_ed1(i),
                l_dd1(i),
                l_fun1(i),
                l_tun1(i),
                l_cq1(i),
                l_risd1(i),
                l_cn1(i),
                l_impf1(i),
                sysdate,
                -1,
                sysdate,
                -1,
               decode(length(l_sc1(i)), 7,null,substrb(l_sc1(i),1,length(l_sc1(i))-7)),
	       to_date(impl_date, 'YYYY/MM/DD HH24:MI')); */
Line: 881

	       INSERT INTO BOM_SMALL_IMPL_TEMP
                (LOWEST_ITEM_ID,
                 CURRENT_ITEM_ID,
                 PARENT_ITEM_ID,
                 ALTERNATE_DESIGNATOR,
                 CURRENT_LEVEL,
                 SORT_CODE,
                 LOWEST_ALTERNATE_DESIGNATOR,
                 CURRENT_ASSEMBLY_TYPE,
                 SEQUENCE_ID,
                 COMPONENT_SEQUENCE_ID,
                 ORGANIZATION_ID,
                 OPERATION_SEQ_NUM,
                 EFFECTIVITY_DATE,
                 DISABLE_DATE,
                 FROM_END_ITEM_UNIT_NUMBER,
                 TO_END_ITEM_UNIT_NUMBER,
                 BASIS_TYPE,
                 COMPONENT_QUANTITY,
                 REVISED_ITEM_SEQUENCE_ID,
                 CHANGE_NOTICE,
                 IMPLEMENTED_FLAG,
                 LAST_UPDATE_DATE,
                 LAST_UPDATED_BY,
                 CREATION_DATE,
                 CREATED_BY,
                 PARENT_SORT_CODE,
		 IMPLOSION_DATE)
	     (	SELECT
                l_lid1(i),
                l_pid1(i),
                l_aid1(i),
                l_abd1(i),
                1,
                l_sc1(i),
                l_lad1(i),
                l_cat1(i),
                sequence_id,
                l_csi1(i),
                l_oi1(i),
                l_osn1(i),
                l_ed1(i),
                l_dd1(i),
                l_fun1(i),
                l_tun1(i),
                l_bt1(i),
                l_cq1(i),
                l_risd1(i),
                l_cn1(i),
                l_impf1(i),
                sysdate,
                -1,
                sysdate,
                -1,
               decode(length(l_sc1(i)), 7,null,substrb(l_sc1(i),1,length(l_sc1(i))-7)),
	       to_date(impl_date, 'YYYY/MM/DD HH24:MI')
        FROM  DUAL
	WHERE NOT EXISTS
	       ( SELECT 'X'
		 FROM   BOM_SMALL_IMPL_TEMP
		 WHERE  LOWEST_ITEM_ID            = l_lid1(i)
                 AND CURRENT_ITEM_ID              = l_pid1(i)
                 AND PARENT_ITEM_ID               = l_aid1(i)
                 AND ALTERNATE_DESIGNATOR         = l_abd1(i)
                 AND CURRENT_LEVEL                = 1
                 AND SORT_CODE                    = l_sc1(i)
                 AND SEQUENCE_ID                  = sequence_id
                 AND COMPONENT_SEQUENCE_ID        = l_csi1(i)
                 AND ORGANIZATION_ID              = l_oi1(i)
                 AND PARENT_SORT_CODE             = decode(length(l_sc1(i)), 7,null,substrb(l_sc1(i),1,length(l_sc1(i))-7))
               )
    );
Line: 996

       	SELECT /*+ ordered first_rows */
	       BITT.LOWEST_ITEM_ID LID,
               BITT.PARENT_ITEM_ID PID,
               BBM.ASSEMBLY_ITEM_ID AID,
               BBM.ALTERNATE_BOM_DESIGNATOR ABD,
               BITT.SORT_CODE SC,
               BITT.LOWEST_ALTERNATE_DESIGNATOR LAD,
	       BBM.ASSEMBLY_TYPE CAT,
	       BIC.COMPONENT_SEQUENCE_ID CSI,
      	       BIC.OPERATION_SEQ_NUM OSN,
               BIC.EFFECTIVITY_DATE ED,
               BIC.DISABLE_DATE DD,
               BIC.BASIS_TYPE BT,
      	       BIC.COMPONENT_QUANTITY CQ,
	       BIC.REVISED_ITEM_SEQUENCE_ID RISD,
	       BIC.CHANGE_NOTICE CN,
	       DECODE(BIC.IMPLEMENTATION_DATE, NULL, 2, 1) IMPF,
	       BBM.ORGANIZATION_ID OI,
	       BIC.FROM_END_ITEM_UNIT_NUMBER FUN,
	       BIC.TO_END_ITEM_UNIT_NUMBER TUN
	FROM
		BOM_SMALL_IMPL_TEMP BITT,
                BOM_INVENTORY_COMPONENTS BIC,
                BOM_BILL_OF_MATERIALS BBM,
		MTL_SYSTEM_ITEMS MSI
	where
	bitt.current_level = c_current_level
	and bitt.organization_id = c_org_id
	and msi.organization_id = BBM.organization_id
	and msi.inventory_item_id = BBM.assembly_item_id
	and bitt.sequence_id = c_sequence_id
	and bitt.parent_item_id = bic.component_item_id
	and bic.bill_sequence_id = bbm.common_bill_sequence_id
	and bbm.organization_id = c_org_id
	and NVL(BIC.ECO_FOR_PRODUCTION,2) = 2
	and ( c_eng_mfg_flag = 2 or c_eng_mfg_flag = 1 and
		( c_current_level = 0
		  and bbm.assembly_type = 1
              	  or c_current_level <> 0 and bitt.current_assembly_type = 1
                   and bbm.assembly_type = 1))
	and ( c_current_level = 0
	      or   /* start of all alternate logic */
	      bbm.alternate_bom_designator is null and
	      bitt.lowest_alternate_designator is null
	      or bbm.alternate_bom_designator = bitt.lowest_alternate_designator
              or ( bitt.lowest_alternate_designator is null
                and bbm.alternate_bom_designator is not null
                and not exists (select NULL     /*for current item */
                     	        from bom_bill_of_materials bbm2
                      		where bbm2.organization_id = c_org_id
                      		and   bbm2.assembly_item_id =
					bitt.parent_item_id
                      		and   bbm2.alternate_bom_designator =
                               		 bbm.alternate_bom_designator
                      		and ( bitt.current_assembly_type = 2
                            		or  bbm2.assembly_type = 1
                            		and bitt.current_assembly_type = 1)
                     	       )
                 )
              or /* Pickup prim par only if starting alt is not
			null and bill for .. */
              (bitt.lowest_alternate_designator is not null
               and bbm.alternate_bom_designator is null
      	       and not exists (select NULL
                      		from bom_bill_of_materials bbm2
                      		where bbm2.organization_id = c_org_id
                      		and   bbm2.assembly_item_id =
						bbm.assembly_item_id
                      		and   bbm2.alternate_bom_designator =
                               		 bitt.lowest_alternate_designator
                      		and ( bitt.current_assembly_type = 1
                            		and bbm2.assembly_type = 1
                           		or bitt.current_assembly_type = 2)
                     		)
              )
            )
        and (( msi.effectivity_control=1 -- Date Effectivity Control
	      and bic.effectivity_date <= to_date(c_implosion_date, 'YYYY/MM/DD HH24:MI')
	      and ( bic.disable_date is null or
                    bic.disable_date > to_date(c_implosion_date, 'YYYY/MM/DD HH24:MI'))
	      and ( c_implemented_only_option = 1
                   and bic.implementation_date is not null
                  or
                ( c_implemented_only_option = 2
      	 	  and bic.effectivity_date =
        	    (select max(effectivity_date)
           		from bom_inventory_components bic2
           		where bic.bill_sequence_id = bic2.bill_sequence_id
           		and   bic.component_item_id = bic2.component_item_id
	                and   NVL(BIC2.ECO_FOR_PRODUCTION,2) = 2
           		and   decode(bic.implementation_date, NULL,
				         decode(bic.old_component_sequence_id,null,
						bic.component_sequence_id,
						bic.old_component_sequence_id)
					 ,bic.component_sequence_id) =
			      decode(bic2.implementation_date,NULL,
					decode(bic2.old_component_sequence_id,null,
					     --  bic2.component_sequence_id,bic.old_component_sequence_id)
					     bic2.component_sequence_id,bic2.old_component_sequence_id)  -- For FP Bug 6134733 (Base Bug : 5405194 )
				        , bic2.component_sequence_id)
           		and   bic2.effectivity_date <=
			      to_date(c_implosion_date,'YYYY/MM/DD HH24:MI')
			and NOT EXISTS (SELECT null
			                  FROM bom_inventory_components bic3
                                         WHERE bic3.bill_sequence_id =
					       bic.bill_sequence_id
					   AND bic3.old_component_sequence_id =
					       bic.component_sequence_id
	                                   and NVL(BIC3.ECO_FOR_PRODUCTION,2)= 2
					   AND bic3.acd_type in (2,3)
					   AND bic3.disable_date <= to_date(c_implosion_date,'YYYY/MM/DD HH24:MI'))
           		and   (bic2.disable_date is null
                               or bic2.disable_date > to_date(c_implosion_date,
					      'YYYY/MM/DD HH24:MI')))
		)))
         OR
          ( msi.effectivity_control = 2
            AND
	      BIC.FROM_END_ITEM_UNIT_NUMBER <= NVL(BITT.TO_END_ITEM_UNIT_NUMBER,
                             BIC.FROM_END_ITEM_UNIT_NUMBER)
            AND
		 NVL(BIC.TO_END_ITEM_UNIT_NUMBER,
                        NVL(BITT.FROM_END_ITEM_UNIT_NUMBER,
                             BIC.FROM_END_ITEM_UNIT_NUMBER)) >=
		 NVL(BITT.FROM_END_ITEM_UNIT_NUMBER,
                             BIC.FROM_END_ITEM_UNIT_NUMBER)
	    AND(c_implemented_only_option=1 and bic.implementation_date is not null
                  or  c_implemented_only_option = 2)
            AND bic.from_end_item_unit_number <= decode(msi.eam_item_type,1,c_serial_number_to,c_unit_number_to)
            AND decode(msi.eam_item_type,1,c_serial_number_from,c_unit_number_from) is not null -- exclude serial eff EAM items
            AND bic.to_end_item_unit_number is null
            OR bic.to_end_item_unit_number >= decode(msi.eam_item_type,1,c_serial_number_from,c_unit_number_from)))
	order by bitt.parent_item_id, bbm.assembly_item_id,
		bic.operation_seq_num;
Line: 1134

      Select 1 dummy
      From mtl_system_items msi1,
           mtl_system_items msi2
      Where msi1.inventory_item_id = P_Parent_Item
      And   msi1.organization_id = org_id
      And   msi2.inventory_item_id = P_Comp_Item
      And   msi2.organization_id = org_id
      And   msi1.bom_item_type = 4 -- Standard
      And   msi1.replenish_to_order_flag = 'Y'
      And   msi1.base_item_id is not null -- configured item
      And   msi2.bom_item_type in (1, 2); -- model or option class
Line: 1147

      Select 1 dummy
      From mtl_system_items msi
      Where msi.inventory_item_id = P_Parent_Item
      And   msi.organization_id = org_id
      And   msi.bom_enabled_flag = 'N';
Line: 1215

    SELECT max(MAXIMUM_BOM_LEVEL)
	INTO max_level
	FROM BOM_PARAMETERS
	WHERE ORGANIZATION_ID = org_id;
Line: 1239

                l_lid1.delete;
Line: 1240

                l_pid1.delete;
Line: 1241

                l_aid1.delete;
Line: 1242

                l_abd1.delete;
Line: 1243

                l_sc1.delete;
Line: 1244

                l_lad1.delete;
Line: 1245

                l_cat1.delete;
Line: 1246

                l_csi1.delete;
Line: 1247

                l_oi1.delete;
Line: 1248

                l_osn1.delete;
Line: 1249

                l_ed1.delete;
Line: 1250

                l_dd1.delete;
Line: 1251

                l_fun1.delete;
Line: 1252

                l_tun1.delete;
Line: 1253

                l_bt1.delete;
Line: 1254

                l_cq1.delete;
Line: 1255

                l_risd1.delete;
Line: 1256

                l_cn1.delete;
Line: 1257

                l_impf1.delete;
Line: 1259

                l_lid.delete;
Line: 1260

                l_pid.delete;
Line: 1261

                l_aid.delete;
Line: 1262

                l_abd.delete;
Line: 1263

                l_sc.delete;
Line: 1264

                l_lad.delete;
Line: 1265

                l_cat.delete;
Line: 1266

                l_csi.delete;
Line: 1267

                l_oi.delete;
Line: 1268

                l_osn.delete;
Line: 1269

                l_ed.delete;
Line: 1270

                l_dd.delete;
Line: 1271

                l_fun.delete;
Line: 1272

                l_tun.delete;
Line: 1273

                l_bt.delete;
Line: 1274

                l_cq.delete;
Line: 1275

                l_risd.delete;
Line: 1276

                l_cn.delete;
Line: 1277

                l_impf.delete;
Line: 1320

                                l_lid.delete(i);
Line: 1321

                                l_pid.delete(i);
Line: 1322

                                l_aid.delete(i);
Line: 1323

                                l_abd.delete(i);
Line: 1324

                                l_sc.delete(i);
Line: 1325

                                l_lad.delete(i);
Line: 1326

                                l_cat.delete(i);
Line: 1327

                                l_csi.delete(i);
Line: 1328

                                l_oi.delete(i);
Line: 1329

                                l_osn.delete(i);
Line: 1330

                                l_ed.delete(i);
Line: 1331

                                l_dd.delete(i);
Line: 1332

                                l_fun.delete(i);
Line: 1333

                                l_tun.delete(i);
Line: 1334

                                l_bt.delete(i);
Line: 1335

                                l_cq.delete(i);
Line: 1336

                                l_risd.delete(i);
Line: 1337

                                l_cn.delete(i);
Line: 1338

                                l_impf.delete(i);
Line: 1344

                                l_lid.delete(i);
Line: 1345

                                l_pid.delete(i);
Line: 1346

                                l_aid.delete(i);
Line: 1347

                                l_abd.delete(i);
Line: 1348

                                l_sc.delete(i);
Line: 1349

                                l_lad.delete(i);
Line: 1350

                                l_cat.delete(i);
Line: 1351

                                l_csi.delete(i);
Line: 1352

                                l_oi.delete(i);
Line: 1353

                                l_osn.delete(i);
Line: 1354

                                l_ed.delete(i);
Line: 1355

                                l_dd.delete(i);
Line: 1356

                                l_fun.delete(i);
Line: 1357

                                l_tun.delete(i);
Line: 1358

                                l_bt.delete(i);
Line: 1359

                                l_cq.delete(i);
Line: 1360

                                l_risd.delete(i);
Line: 1361

                                l_cn.delete(i);
Line: 1362

                                l_impf.delete(i);
Line: 1424

	    /*INSERT INTO BOM_SMALL_IMPL_TEMP
                (LOWEST_ITEM_ID,
                 CURRENT_ITEM_ID,
                 PARENT_ITEM_ID,
                 ALTERNATE_DESIGNATOR,
                 CURRENT_LEVEL,
                 SORT_CODE,
                 LOWEST_ALTERNATE_DESIGNATOR,
                 CURRENT_ASSEMBLY_TYPE,
                 SEQUENCE_ID,
                 COMPONENT_SEQUENCE_ID,
                 ORGANIZATION_ID,
                 REVISED_ITEM_SEQUENCE_ID,
                 CHANGE_NOTICE,
                 OPERATION_SEQ_NUM,
                 EFFECTIVITY_DATE,
                 DISABLE_DATE,
		 FROM_END_ITEM_UNIT_NUMBER,
                 TO_END_ITEM_UNIT_NUMBER,
                 COMPONENT_QUANTITY,
                 IMPLEMENTED_FLAG,
                 LAST_UPDATE_DATE,
                 LAST_UPDATED_BY,
                 CREATION_DATE,
                 CREATED_BY,
                 PARENT_SORT_CODE,
		 implosion_date) VALUES (
                l_lid1(i),
                l_pid1(i),
                l_aid1(i),
                l_abd1(i),
                cur_level + 1,
                l_sc1(i),
                l_lad1(i),
                l_cat1(i),
                sequence_id,
                l_csi1(i),
                l_oi1(i),
                l_risd1(i),
                l_cn1(i),
                l_osn1(i),
                l_ed1(i),
                l_dd1(i),
                l_fun1(i),
                l_tun1(i),
                l_cq1(i),
                l_impf1(i),
                sysdate,
                -1,
                sysdate,
                -1,
               decode(length(l_sc1(i)), 7,null,substrb(l_sc1(i),1,length(l_sc1(i))-7)),
	       to_date(impl_date, 'YYYY/MM/DD HH24:MI')); */
Line: 1478

	       INSERT INTO BOM_SMALL_IMPL_TEMP
                (LOWEST_ITEM_ID,
                 CURRENT_ITEM_ID,
                 PARENT_ITEM_ID,
                 ALTERNATE_DESIGNATOR,
                 CURRENT_LEVEL,
                 SORT_CODE,
                 LOWEST_ALTERNATE_DESIGNATOR,
                 CURRENT_ASSEMBLY_TYPE,
                 SEQUENCE_ID,
                 COMPONENT_SEQUENCE_ID,
                 ORGANIZATION_ID,
                 REVISED_ITEM_SEQUENCE_ID,
                 CHANGE_NOTICE,
                 OPERATION_SEQ_NUM,
                 EFFECTIVITY_DATE,
                 DISABLE_DATE,
		 FROM_END_ITEM_UNIT_NUMBER,
                 TO_END_ITEM_UNIT_NUMBER,
                 BASIS_TYPE,
                 COMPONENT_QUANTITY,
                 IMPLEMENTED_FLAG,
                 LAST_UPDATE_DATE,
                 LAST_UPDATED_BY,
                 CREATION_DATE,
                 CREATED_BY,
                 PARENT_SORT_CODE,
		 IMPLOSION_DATE )
	 ( SELECT
                l_lid1(i),
                l_pid1(i),
                l_aid1(i),
                l_abd1(i),
                (cur_level + 1),
                l_sc1(i),
                l_lad1(i),
                l_cat1(i),
                sequence_id,
                l_csi1(i),
                l_oi1(i),
		l_risd1(i),
		l_cn1(i),
                l_osn1(i),
                l_ed1(i),
                l_dd1(i),
                l_fun1(i),
                l_tun1(i),
                l_bt1(i),
                l_cq1(i),
                l_impf1(i),
                sysdate,
                -1,
                sysdate,
                -1,
		decode(length(l_sc1(i)), 7,null,substrb(l_sc1(i),1,length(l_sc1(i))-7)),
		to_date(impl_date, 'YYYY/MM/DD HH24:MI')
        FROM  DUAL
	WHERE NOT EXISTS
	       ( SELECT 'X'
		 FROM   BOM_SMALL_IMPL_TEMP
		 WHERE  LOWEST_ITEM_ID            = l_lid1(i)
                 AND CURRENT_ITEM_ID              = l_pid1(i)
                 AND PARENT_ITEM_ID               = l_aid1(i)
                 AND ALTERNATE_DESIGNATOR         = l_abd1(i)
                 AND CURRENT_LEVEL                = (cur_level + 1)
                 AND SORT_CODE                    = l_sc1(i)
                 AND SEQUENCE_ID                  = sequence_id
                 AND COMPONENT_SEQUENCE_ID        = l_csi1(i)
                 AND ORGANIZATION_ID              = l_oi1(i)
                 AND PARENT_SORT_CODE             = decode(length(l_sc1(i)), 7,null,substrb(l_sc1(i),1,length(l_sc1(i))-7))
               )
    );