DBA Data[Home] [Help]

APPS.CTO_UPDATE_CONFIGS_PK SQL Statements

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

Line: 82

This procedure is called by the Update Existing Configurations batch
progam. It does the following:
	1. Call procedures to populate bcol_upg based on the input params
	2. Delete sourcing for canned configs not to be processed
	3. Update bcol_upg with sequence numbers for batch processing
	4. Call procedure to update items and sourcing
***********************************************************************/
PROCEDURE Update_Configs
(
errbuf OUT NOCOPY varchar2,
retcode OUT NOCOPY varchar2,
p_item IN number,
p_dummy IN varchar2,
p_dummy2 IN varchar2,
p_category_set_id IN number, --bugfix3397123
p_dummy3 IN number, --bugfix3397123
p_cat_id IN number,
p_config_id IN number,
p_changed_src IN varchar2,
p_open_lines IN varchar2,
p_upgrade_mode In Number
) IS



/*
Redundant cursor

CURSOR c_seq(l_seq number) IS
select distinct sequence
from bom_cto_order_lines_upg
where sequence = l_seq;
Line: 134

 select distinct ato_line_id
 from    bom_cto_order_lines_upg
 where  status = 'CTO_SRC'
 and    line_id = ato_line_id;
Line: 165

WriteToLog('Begin Update Existing Configurations with Debug Level: '||gDebugLevel);
Line: 183

   update_atp_attributes(
                          p_item           => p_item,
                          p_cat_id         => p_cat_id,
                          p_config_id      => p_config_id,
                          x_return_status  => x_return_status,
                          x_msg_data       => x_msg_data,
                          x_msg_count      => x_msg_count);
Line: 191

   WriteToLog('Update Existing Configurations completed with SUCCESS');
Line: 201

delete from bom_cto_src_orgs_b
where line_id in (
	select bcolu.line_id
	from bom_cto_order_lines_upg bcolu
	where bcolu.config_item_id is not null
	and not exists (
		select 'exists'
		from oe_order_lines_all oel
		where oel.line_id = bcolu.line_id));
Line: 210

WriteToLog('Rows deleted from bcso_b::'|| sql%rowcount, 1);
Line: 219

WriteToLog('Rows deleted from bcol_upg::'|| sql%rowcount, 1);
Line: 222

select assignment_set_id
into l_cto_aset_id
from mrp_assignment_sets
where assignment_set_name = 'CTO Configuration Updates';
Line: 244

         INSERT INTO mrp_assignment_sets
	 (assignment_set_id ,
	  assignment_set_name,
	  description,
	  created_by,
	  last_updated_by,
	  creation_date,
	  last_update_date
	 )
	 VALUES
	 ( MRP_ASSIGNMENT_SETS_S.nextval,
	   'CTO Configuration Updates',
	   'Exclusively for use by CTO. Used during Upgrade Concurrent programs',
	   FND_GLOBAL.USER_ID,
	   FND_GLOBAL.USER_ID,
	   sysdate,
	   sysdate
	  )
	  returning assignment_set_id INTO l_cto_aset_id;
Line: 265

          WriteToLog('Assignment set name::'|| 'CTO Configuration Updates', 2);
Line: 274

delete from mrp_sr_assignments
where assignment_set_id = l_cto_aset_id;
Line: 277

WriteToLog('Rows deleted from cto assignment set::'|| sql%rowcount, 1);
Line: 315

        delete from mrp_sr_assignments
        where assignment_set_id = l_mrp_aset_id
        and inventory_item_id in
                (select config_item_id
                from bom_ato_configurations bac
                where not exists
                        (select 'exists'
                        from bom_cto_order_lines_upg bcolu
                        where bcolu.config_item_id = bac.config_item_id
                          and rownum = 1) -- bug 13876670
                -- and not on open order lines
                and not exists
                        (select 'exists'
                        from oe_order_lines_all oel,
                        bom_cto_order_lines bcol
                        where bcol.config_item_id = bac.config_item_id
                        and bcol.ato_line_id = oel.ato_line_id
                        and nvl(oel.open_flag, 'N') = 'Y'
                        and oel.item_type_code='CONFIG'
                        and rownum = 1) -- bug 13876670
                -- and item is not pre-configured
                and not exists
                        (select 'pc'
                        from mtl_system_items msi
                        where msi.inventory_item_id = bac.config_item_id
                        -- bug 13876670
                        and msi.auto_created_config_flag = 'N'
                        and msi.organization_id = bac.organization_id
                        and rownum =1
                        ));
Line: 346

        WriteToLog('New Msg: Sourcing deleted::'||sql%rowcount, 2);
Line: 386

        delete from mrp_sr_assignments
        where assignment_set_id = l_mrp_aset_id
          and inventory_item_id in
              (
               select /*+ leading(mcat bac) */ DISTINCT config_item_id -- bug 13876670 added hint
                 from bom_ato_configurations bac,
                      mtl_item_categories mcat
                where bac.base_model_id = mcat.inventory_item_id
                  and mcat.category_id = p_cat_id
                  -- bug 13876670
                  and mcat.category_set_id = p_category_set_id
                  and not exists
                      (select 'exists'
                         from bom_cto_order_lines_upg bcolu
                        where bcolu.config_item_id = bac.config_item_id
                          and rownum = 1 -- 13876670
                      )
                  and NOT EXISTS -- bug 13876670
                      (select 'exists'
                         from oe_order_lines_all oel,
                              bom_cto_order_lines bcol
                        where bcol.config_item_id = bac.config_item_id
                        and   bcol.ato_line_id = oel.ato_line_id
                        and   bcol.config_item_id = oel.inventory_item_id
                        and   oel.item_type_code = 'CONFIG'
                        and   open_flag = 'Y'
                        and rownum = 1 -- 13876670
                      )
                  and not exists
                      (select /*+ no_unnest push_subq */ 'pc'
                         from mtl_system_items msi
                        where msi.inventory_item_id = bac.config_item_id
                          and msi.auto_created_config_flag = 'N'
                          -- 13876670
                          and msi.organization_id = bac.organization_id
                          and rownum = 1
                      )
               );
Line: 426

        WriteToLog('New Msg: Sourcing deleted::'||sql%rowcount, 2);
Line: 461

        delete from mrp_sr_assignments
        where assignment_set_id = l_mrp_aset_id
        and inventory_item_id = p_config_id
        --Bugfix 14359805
        --Exists in BAC
        and exists
                (select 'exists'
                  from bom_ato_configurations bac
                  where bac.config_item_id = p_config_id)
        -- not being upgraded
        and not exists
                (select 'exists'
                from bom_cto_order_lines_upg bcolu
                where bcolu.config_item_id = p_config_id
                  and rownum = 1 -- bug 13876670
                 )
        -- and not on open order lines
        and not exists           /* bug 3399310 sushant changed the query to identify config item exists */
                (select 'exists'
                from oe_order_lines_all oel,
                bom_cto_order_lines bcol
                where bcol.config_item_id = p_config_id
                and bcol.line_id = oel.ato_line_id
                and oel.item_type_code = 'CONFIG'
                and nvl(oel.open_flag, 'N') = 'Y'
                and rownum = 1 -- bug 13876670
                )
        -- and item is not pre-configured
        and not exists
                (select 'pc'
                from mtl_system_items msi
                where msi.inventory_item_id = p_config_id
                -- bug 13876670
                and msi.auto_created_config_flag = 'N'
                and rownum = 1
                );
Line: 498

        WriteToLog('New Msg: Sourcing deleted::'||sql%rowcount, 2);
Line: 521

delete from bom_cto_order_lines_upg bcol1
where ato_line_id not in (select max(bcol2.ato_line_id)
                          from bom_cto_order_lines_upg bcol2
                          where bcol2.config_item_id is not null
                          group by bcol2.config_item_id
                          );
Line: 541

DELETE
 FROM bom_cto_order_lines_upg bcol1
 WHERE rowid IN
   (SELECT rowid
    FROM
     (SELECT rowid,
             --row_number() over(PARTITION BY bcol2.config_item_id ORDER BY bcol2.ato_line_id DESC) rnk
             row_number() over(PARTITION BY bcol2.config_item_id, bcol2.ship_from_org_id ORDER BY bcol2.ato_line_id DESC) rnk
     FROM bom_cto_order_lines_upg bcol2
     WHERE bcol2.config_item_id IS NOT NULL
     )
    WHERE rnk <> 1
   );
Line: 554

WriteToLog('New Msg: Rows deleted from bcolu:: ' ||sql%rowcount, 2);
Line: 559

select count(*)
into l_bcolu_count
from bom_cto_order_lines_upg;
Line: 588

select count(*)
into l_bcolu_count
from bom_cto_order_lines_upg
where status <>'ERROR';
Line: 627

	update bom_cto_order_lines_upg bcolu
	set bcolu.sequence = l_seq_temp
	where bcolu.ato_line_id in
		(select ato_line_id
		from bom_cto_order_lines_upg bcolu2
		where bcolu2.ato_line_id = bcolu2.line_id
		and bcolu2.status IN ('UPG')
		and rownum < G_BATCH_SIZE + 1
		and bcolu2.sequence is null);
Line: 649

WriteToLog('Going for a second update of sequence numbers', 4);
Line: 651

SELECT config_item_id, Max(SEQUENCE)
  BULK COLLECT INTO l_cfg_itm_tbl, l_seq_tbl
    FROM bom_cto_order_lines_upg
     WHERE config_item_id IS NOT NULL
     GROUP BY config_item_id
     HAVING Count(DISTINCT SEQUENCE) > 1;
Line: 658

WriteToLog('Count of rows to be updated:: '|| l_cfg_itm_tbl.count, 1);
Line: 664

   UPDATE bom_cto_order_lines_upg bcol1
   SET bcol1.SEQUENCE = l_seq_tbl(i)
   WHERE ato_line_id IN ( SELECT distinct ato_line_id
                           FROM bom_cto_order_lines_upg bcol2
                            WHERE bcol2.config_item_id = l_cfg_itm_tbl(i)
                        );
Line: 671

   WriteToLog('Rows updated::'|| sql%rowcount, 1);
Line: 680

Cto_Update_Items_Pk.Update_Items_And_Sourcing(
			  p_changed_src     => p_changed_src
			, p_cat_id          => p_cat_id
			, p_upgrade_mode    => p_upgrade_mode
			--Bugfix 10240482: Passing the new parameter p_max_seq
			, p_max_seq         => l_max_seq
			, xReturnStatus     => l_return_status
			, xMsgCount         => l_msg_count
			, xMsgData          => l_msg_data);
Line: 691

	WriteToLog('ERROR: Update_items_and_sourcing returned unexpected error');
Line: 694

	WriteToLog('ERROR: Update_items_and_sourcing returned expected error');
Line: 697

	WriteToLog('Update_items_and_sourcing returned success', 3);
Line: 724

WriteToLog('update_configs: About to generate bom batch ID', 5);
Line: 729

   WriteToLog('update_configs: ' || 'Failed in set_bom_batch_id with unexp error.', 1);
Line: 741

WriteToLog('update_configs:: '||to_char(l_seq));
Line: 744

select 'exists'
into l_exists
from bom_cto_order_lines_upg
where sequence = l_seq
and rownum = 1;
Line: 754

  WriteToLog('update_configs:: No_Data_Found for l_seq:'|| l_seq, 1);
Line: 807

select assignment_set_id
into l_cto_aset_id
from mrp_assignment_sets
where assignment_set_name = 'CTO Configuration Updates';
Line: 823

delete from mrp_sr_assignments
where assignment_set_id = l_cto_aset_id;
Line: 826

WriteToLog('Rows deleted from CTO Seeded Assignment Set::' ||sql%rowcount, 2);
Line: 833

	delete from mtl_item_categories
	where category_id = p_cat_id;
Line: 836

	WriteToLog('Rows deleted from category::'||sql%rowcount, 2);
Line: 857

  WriteToLog('Update Existing Configurations completed with WARNING');
Line: 862

  WriteToLog('Update Existing Configurations completed with SUCCESS');
Line: 870

	WriteToLog('ERROR: Exp error in CTO_Update_Configs_Pk.Update_Configs:: '|| l_stmt_num ||'::'||sqlerrm);
Line: 872

	WriteToLog('Update Existing Configurations completed with ERROR.', 1);
Line: 879

	WriteToLog('ERROR: Unexp error in CTO_Update_Configs_Pk.Update_Configs:: '|| l_stmt_num ||'::'||sqlerrm, 1);
Line: 881

	WriteToLog('Update Existing Configurations completed with ERROR');
Line: 887

	WriteToLog('ERROR: Others error in CTO_Update_Configs_Pk.Update_Configs:: '|| l_stmt_num ||'::'||sqlerrm, 1);
Line: 889

	WriteToLog('Update Existing Configurations completed with ERROR.', 1);
Line: 895

END update_configs;
Line: 913

select distinct bac.config_item_id config_id
from bom_ato_configurations bac,
mtl_system_items msi
where NOT EXISTS
	(select 'exists'
	from bom_cto_order_lines_upg bcolu
	where bcolu.config_item_id = bac.config_item_id)
and bac.base_model_id = msi.inventory_item_id
and bac.organization_id = msi.organization_id
and msi.config_orgs = '3'; -- bug 13362916 removed nvl for performance
Line: 931

select distinct bac.config_item_id config_id
from bom_ato_configurations bac,
mtl_system_items msi
-- item attribute is 3
where bac.base_model_id = msi.inventory_item_id
and bac.organization_id = msi.organization_id
and msi.config_orgs     = '3' -- bug 13362916 removed nvl for performance
-- and is top parent with attribute 3
and NOT EXISTS
	(select 'exists'
	from bom_ato_configurations bac2
	, mtl_system_items msi2
	where bac.config_item_id = bac2.component_item_id
	and bac2.base_model_id = msi2.inventory_item_id
	and bac2.organization_id = msi2.organization_id
	and msi2.config_orgs = '3') -- bug 13362916 removed nvl for performance
-- and not already in bcol_upg
and NOT EXISTS
	(select 'exists'
	from bom_cto_order_lines_upg bcolu
	where bcolu.config_item_id = bac.config_item_id);
Line: 974

		WriteToLog('Match profile is No and you chose not to update existing configurations. No configurations will be updated.');
Line: 987

			-- select all open order lines having config items with attribute in (2,3)
			-- populate into bcol_upg
			-- mark as UPG
			--
			WriteToLog('sql 1', 3);
Line: 993

			select count(line_id)
			into l_count
			from bom_cto_order_lines_upg;
Line: 999

			insert into bom_cto_order_lines_upg
			(
			 ATO_LINE_ID
			, BATCH_ID
			, BOM_ITEM_TYPE
			, COMPONENT_CODE
			, COMPONENT_SEQUENCE_ID
			, CONFIG_ITEM_ID
			, INVENTORY_ITEM_ID
			, ITEM_TYPE_CODE
			, LINE_ID
			, LINK_TO_LINE_ID
			, ORDERED_QUANTITY
			, ORDER_QUANTITY_UOM
			, PARENT_ATO_LINE_ID
			, PERFORM_MATCH
			, PLAN_LEVEL
			, SCHEDULE_SHIP_DATE
			, SHIP_FROM_ORG_ID
			, TOP_MODEL_LINE_ID
			, WIP_SUPPLY_TYPE
			, HEADER_ID
			, LAST_UPDATE_DATE
			, LAST_UPDATED_BY
			, CREATION_DATE
			, CREATED_BY
			, LAST_UPDATE_LOGIN
			, REQUEST_ID
			, PROGRAM_APPLICATION_ID
			, PROGRAM_ID
			, PROGRAM_UPDATE_DATE
			, OPTION_SPECIFIC
			, REUSE_CONFIG
			, QTY_PER_PARENT_MODEL
			, STATUS
			, config_creation
			)
			select distinct
			bcol2.ATO_LINE_ID
			, bcol2.BATCH_ID
			, bcol2.BOM_ITEM_TYPE
			, bcol2.COMPONENT_CODE
			, bcol2.COMPONENT_SEQUENCE_ID
			, bcol2.CONFIG_ITEM_ID
			, bcol2.INVENTORY_ITEM_ID
			, bcol2.ITEM_TYPE_CODE
			, bcol2.LINE_ID
			, bcol2.LINK_TO_LINE_ID
			, bcol2.ORDERED_QUANTITY
			, bcol2.ORDER_QUANTITY_UOM
			, bcol2.PARENT_ATO_LINE_ID
                        , decode(bcol2.perform_match, 'C', 'Y', bcol2.perform_match)  -- Bugfix 8894392
			--, bcol2.PERFORM_MATCH                   --7201878
			--, 'N'		--PERFORM_MATCH
			, bcol2.PLAN_LEVEL
			, bcol2.SCHEDULE_SHIP_DATE
			, bcol2.SHIP_FROM_ORG_ID
			, bcol2.TOP_MODEL_LINE_ID
			, bcol2.WIP_SUPPLY_TYPE
			, bcol2.HEADER_ID
			, sysdate	--LAST_UPDATE_DATE
			, bcol2.LAST_UPDATED_BY
			, sysdate	--CREATION_DATE
			, bcol2.CREATED_BY
			, bcol2.LAST_UPDATE_LOGIN
			, bcol2.REQUEST_ID
			, bcol2.PROGRAM_APPLICATION_ID
			, bcol2.PROGRAM_ID
			, sysdate	--PROGRAM_UPDATE_DATE
			, bcol2.OPTION_SPECIFIC
			, 'N'		--REUSE_CONFIG
			, bcol2.QTY_PER_PARENT_MODEL
			, 'UPG'		--STATUS
			, nvl(mtl.config_orgs, '1')
			--changed the where clause to use a subquery
			--bugfix 3841575
			from bom_cto_order_lines bcol2
			, mtl_system_items mtl
			-- select entire configuration
			where mtl.inventory_item_id =  bcol2.inventory_item_id
			and   mtl.organization_id = bcol2.ship_from_org_id
			and bcol2.ato_line_id in
			            (select distinct bcol1.ato_line_id
                                     from bom_cto_order_lines bcol1
                                     , oe_order_lines_all oel
				     , mtl_system_items msi
				    -- for configs whose models have attr=2,3
				    where bcol1.config_item_id is not null
				    and bcol1.inventory_item_id = msi.inventory_item_id
				    and bcol1.ship_from_org_id = msi.organization_id
				    and msi.config_orgs        in ('2', '3') -- bug 13362916 removed nvl for performance
				      -- and are on open order lines
				    and bcol1.line_id = oel.line_id
				    and oel.open_flag = 'Y'); -- bug 13362916 removed NVL
Line: 1095

			WriteToLog('Rows inserted::'|| to_char(sql%rowcount), 3);
Line: 1099

			-- select all open order lines having canned config items with attribute = 3
			-- populate into bcol_upg
			-- mark as UPG
			--
			WriteToLog('sql 2', 3);
Line: 1105

			insert into bom_cto_order_lines_upg
			(
			 ATO_LINE_ID
			, BATCH_ID
			, BOM_ITEM_TYPE
			, COMPONENT_CODE
			, COMPONENT_SEQUENCE_ID
			, CONFIG_ITEM_ID
			, INVENTORY_ITEM_ID
			, ITEM_TYPE_CODE
			, LINE_ID
			, LINK_TO_LINE_ID
			, ORDERED_QUANTITY
			, ORDER_QUANTITY_UOM
			, PARENT_ATO_LINE_ID
			, PERFORM_MATCH
			, PLAN_LEVEL
			, SCHEDULE_SHIP_DATE
			, SHIP_FROM_ORG_ID
			, TOP_MODEL_LINE_ID
			, WIP_SUPPLY_TYPE
			, HEADER_ID
			, LAST_UPDATE_DATE
			, LAST_UPDATED_BY
			, CREATION_DATE
			, CREATED_BY
			, LAST_UPDATE_LOGIN
			, REQUEST_ID
			, PROGRAM_APPLICATION_ID
			, PROGRAM_ID
			, PROGRAM_UPDATE_DATE
			, OPTION_SPECIFIC
			, REUSE_CONFIG
			, QTY_PER_PARENT_MODEL
			, STATUS
			, config_creation
			)
			select distinct
			bcol2.ATO_LINE_ID
			, bcol2.BATCH_ID
			, bcol2.BOM_ITEM_TYPE
			, bcol2.COMPONENT_CODE
			, bcol2.COMPONENT_SEQUENCE_ID
			, bcol2.CONFIG_ITEM_ID
			, bcol2.INVENTORY_ITEM_ID
			, bcol2.ITEM_TYPE_CODE
			, bcol2.LINE_ID
			, bcol2.LINK_TO_LINE_ID
			, bcol2.ORDERED_QUANTITY
			, bcol2.ORDER_QUANTITY_UOM
			, bcol2.PARENT_ATO_LINE_ID
                        , decode(bcol2.perform_match, 'C', 'Y', bcol2.perform_match)  -- Bugfix 8894392
			--, bcol2.PERFORM_MATCH               --7201878
			--, 'Y'		--PERFORM_MATCH  /* Sushant Made changes for identifying matched items */
			, bcol2.PLAN_LEVEL
			, bcol2.SCHEDULE_SHIP_DATE
			, bcol2.SHIP_FROM_ORG_ID
			, bcol2.TOP_MODEL_LINE_ID
			, bcol2.WIP_SUPPLY_TYPE
			, bcol2.HEADER_ID
			, sysdate	--LAST_UPDATE_DATE
			, bcol2.LAST_UPDATED_BY
			, sysdate	--CREATION_DATE
			, bcol2.CREATED_BY
			, bcol2.LAST_UPDATE_LOGIN
			, bcol2.REQUEST_ID
			, bcol2.PROGRAM_APPLICATION_ID
			, bcol2.PROGRAM_ID
			, sysdate	--PROGRAM_UPDATE_DATE
			, bcol2.OPTION_SPECIFIC
			, 'N'		--REUSE_CONFIG
			, bcol2.QTY_PER_PARENT_MODEL
			, 'UPG'		--STATUS
			, nvl(msi.config_orgs, '1')
			from bom_cto_order_lines bcol1
			, bom_cto_order_lines bcol2
			, bom_ato_configurations bac
			, oe_order_lines_all oel
			, mtl_system_items msi
			-- base model has item attr = 3
			where bac.base_model_id = msi.inventory_item_id
			and bac.organization_id = msi.organization_id
			and msi.config_orgs     = '3' -- bug 13362916 removed nvl for performance
			-- and exists in bcol
			and bac.config_item_id = bcol1.config_item_id
			-- on open order lines
			and bcol1.line_id = oel.line_id
			and oel.open_flag = 'Y' -- bug 13362916 removed NVL
			and bcol2.ato_line_id = bcol1.ato_line_id;
Line: 1194

			WriteToLog('Rows inserted::'|| to_char(sql%rowcount), 3);
Line: 1200

			-- select additional config items with attribute = 3 on closed order lines
			-- populate into bcol_upg
			-- mark as UPG
			--
			-- Commenting as part of Bugfix 8894392
			-- Reasoning: Suppose I had an OSS setup and the configs that have that setup
			-- are all on the closed SO lines. Now, I want to change the OSS for model in
			-- such a way that the shipping warehouse on these closed lines becomes an
			-- invalid org as per new OSS rules. Now when I run UEC for the old configs,
			-- the UEC ended in error saying ship from org is not valid. Thus even though
			-- the lines are closed, I cannot change the OSS setup on the model to make
			-- the old warehouse invalid.
			-- Changed the logic. Now we do not pick up any configs on closed lines. If a
			-- matched CIB = 3 config is not found on any open lines, we look for the config
			-- in bom_ato_configurations table.

			-- Another change is the use of decode while populating perform_match flag.
			-- This flag is now populated using this decode statement:
			-- decode(bcol.perform_match, 'C', 'Y', bcol.perform_match). This is done to make
			-- the behaviour of custom match similar to standard match. A lot of irregularities
			-- arose because of different treatment of custom and standard match in UEC. An
			-- example is:  bcmo and bcso get populated differently for perform_match = C and
			-- perform_match = Y. This resulted in wrong results.

			/*WriteToLog('sql 3', 3);
Line: 1226

			insert into bom_cto_order_lines_upg
			(
			 ATO_LINE_ID
			, BATCH_ID
			, BOM_ITEM_TYPE
			, COMPONENT_CODE
			, COMPONENT_SEQUENCE_ID
			, CONFIG_ITEM_ID
			, INVENTORY_ITEM_ID
			, ITEM_TYPE_CODE
			, LINE_ID
			, LINK_TO_LINE_ID
			, ORDERED_QUANTITY
			, ORDER_QUANTITY_UOM
			, PARENT_ATO_LINE_ID
			, PERFORM_MATCH
			, PLAN_LEVEL
			, SCHEDULE_SHIP_DATE
			, SHIP_FROM_ORG_ID
			, TOP_MODEL_LINE_ID
			, WIP_SUPPLY_TYPE
			, HEADER_ID
			, LAST_UPDATE_DATE
			, LAST_UPDATED_BY
			, CREATION_DATE
			, CREATED_BY
			, LAST_UPDATE_LOGIN
			, REQUEST_ID
			, PROGRAM_APPLICATION_ID
			, PROGRAM_ID
			, PROGRAM_UPDATE_DATE
			, OPTION_SPECIFIC
			, REUSE_CONFIG
			, QTY_PER_PARENT_MODEL
			, STATUS
			, config_creation
			)
			select distinct
			bcol.ATO_LINE_ID
			, bcol.BATCH_ID
			, bcol.BOM_ITEM_TYPE
			, bcol.COMPONENT_CODE
			, bcol.COMPONENT_SEQUENCE_ID
			, bcol.CONFIG_ITEM_ID
			, bcol.INVENTORY_ITEM_ID
			, bcol.ITEM_TYPE_CODE
			, bcol.LINE_ID
			, bcol.LINK_TO_LINE_ID
			, bcol.ORDERED_QUANTITY
			, bcol.ORDER_QUANTITY_UOM
			, bcol.PARENT_ATO_LINE_ID
                        , bcol.PERFORM_MATCH           --7201878
			--, 'Y'		--PERFORM_MATCH  /* Sushant made changes to identify matched items */
			/*, bcol.PLAN_LEVEL
			, bcol.SCHEDULE_SHIP_DATE
			, bcol.SHIP_FROM_ORG_ID
			, bcol.TOP_MODEL_LINE_ID
			, bcol.WIP_SUPPLY_TYPE
			, bcol.HEADER_ID
			, sysdate	--LAST_UPDATE_DATE
			, bcol.LAST_UPDATED_BY
			, sysdate	--CREATION_DATE
			, bcol.CREATED_BY
			, bcol.LAST_UPDATE_LOGIN
			, bcol.REQUEST_ID
			, bcol.PROGRAM_APPLICATION_ID
			, 99		-- matched item on closed line
			, bcol.PROGRAM_UPDATE_DATE
			, bcol.OPTION_SPECIFIC
			, 'N'		--REUSE_CONFIG
			, bcol.QTY_PER_PARENT_MODEL
			, 'UPG'		--STATUS
			, nvl(msi.config_orgs, '1')
			from bom_ato_configurations bac
			, bom_cto_order_lines bcol
			, mtl_system_items msi
			-- base model has item attr = 3
			where bac.base_model_id = msi.inventory_item_id
			and bac.organization_id = msi.organization_id
			and nvl(msi.config_orgs, '1') = '3'
			-- and not already in bcol_upg
			and NOT EXISTS
				(select 'exists'
				from bom_cto_order_lines_upg bcolu
				where bcolu.config_item_id = bac.config_item_id)
			-- select first ato_line_id in bcol
			and bcol.ato_line_id =
				(select bcol1.ato_line_id
				from bom_cto_order_lines bcol1
				where bcol1.config_item_id = bac.config_item_id
				-- pick up only if config is at top level
				and bcol1.line_id = bcol1.ato_line_id
				and rownum = 1)
			;
Line: 1320

			WriteToLog('Rows inserted::'|| to_char(sql%rowcount), 3);*/
Line: 1323

			-- select all individual (not top level) config items in bac having item attribute = 3 and not in bcol_upg
			-- populate into bcol_upg from bcol or bac
			-- mark as UPG
			-- mark with program_id = 99 to indicate that it was populated from bac
			--
			WriteToLog('sql 3', 2);
Line: 1336

				select 'Y'
				into l_exists
				from bom_cto_order_lines_upg
				where config_item_id = v_bac.config_id
				and rownum = 1;
Line: 1369

			-- select all open order lines
			-- populate into bcol_upg
			-- mark as UPG
			-- TEST THIS!!
			--
			WriteToLog('sql 5', 3);
Line: 1376

			insert into bom_cto_order_lines_upg
			(
			 ATO_LINE_ID
			, BATCH_ID
			, BOM_ITEM_TYPE
			, COMPONENT_CODE
			, COMPONENT_SEQUENCE_ID
			, CONFIG_ITEM_ID
			, INVENTORY_ITEM_ID
			, ITEM_TYPE_CODE
			, LINE_ID
			, LINK_TO_LINE_ID
			, ORDERED_QUANTITY
			, ORDER_QUANTITY_UOM
			, PARENT_ATO_LINE_ID
			, PERFORM_MATCH
			, PLAN_LEVEL
			, SCHEDULE_SHIP_DATE
			, SHIP_FROM_ORG_ID
			, TOP_MODEL_LINE_ID
			, WIP_SUPPLY_TYPE
			, HEADER_ID
			, LAST_UPDATE_DATE
			, LAST_UPDATED_BY
			, CREATION_DATE
			, CREATED_BY
			, LAST_UPDATE_LOGIN
			, REQUEST_ID
			, PROGRAM_APPLICATION_ID
			, PROGRAM_ID
			, PROGRAM_UPDATE_DATE
			, OPTION_SPECIFIC
			, REUSE_CONFIG
			, QTY_PER_PARENT_MODEL
			, STATUS
			, CONFIG_CREATION
			)
			select distinct
			bcol.ATO_LINE_ID
			, bcol.BATCH_ID
			, bcol.BOM_ITEM_TYPE
			, bcol.COMPONENT_CODE
			, bcol.COMPONENT_SEQUENCE_ID
			, bcol.CONFIG_ITEM_ID
			, bcol.INVENTORY_ITEM_ID
			, bcol.ITEM_TYPE_CODE
			, bcol.LINE_ID
			, bcol.LINK_TO_LINE_ID
			, bcol.ORDERED_QUANTITY
			, bcol.ORDER_QUANTITY_UOM
			, bcol.PARENT_ATO_LINE_ID
                        , decode(bcol.perform_match, 'C', 'Y', bcol.perform_match)  -- Bugfix 8894392
			--, bcol.PERFORM_MATCH              --7201878
			--, 'N'		--PERFORM_MATCH
			, bcol.PLAN_LEVEL
			, bcol.SCHEDULE_SHIP_DATE
			, bcol.SHIP_FROM_ORG_ID
			, bcol.TOP_MODEL_LINE_ID
			, bcol.WIP_SUPPLY_TYPE
			, bcol.HEADER_ID
			, sysdate	--LAST_UPDATE_DATE
			, bcol.LAST_UPDATED_BY
			, sysdate	--CREATION_DATE
			, bcol.CREATED_BY
			, bcol.LAST_UPDATE_LOGIN
			, bcol.REQUEST_ID
			, bcol.PROGRAM_APPLICATION_ID
			, bcol.PROGRAM_ID
			, sysdate	--PROGRAM_UPDATE_DATE
			, bcol.OPTION_SPECIFIC
			, 'N'		--REUSE_CONFIG
			, bcol.QTY_PER_PARENT_MODEL
			, 'UPG'		--STATUS
			, nvl(msi.CONFIG_ORGS, '1')
			from bom_cto_order_lines bcol
			, oe_order_lines_all oel
			, mtl_system_items msi
			-- select all configs on open order lines
			where bcol.ato_line_id = oel.ato_line_id
			and oel.open_flag = 'Y' -- bug 13362916 removed NVL
			and bcol.inventory_item_id = msi.inventory_item_id
			and bcol.ship_from_org_id = msi.organization_id
                        and oel.item_type_code = 'CONFIG' ; /* added condition for bug 3599397 */
Line: 1460

			WriteToLog('Rows inserted::'|| to_char(sql%rowcount), 3);
Line: 1464

			-- select all open order lines having canned config items with attribute = 3
			-- populate into bcol_upg
			-- mark as UPG
			--
			WriteToLog('sql 6', 3);
Line: 1470

			insert into bom_cto_order_lines_upg
			(
			 ATO_LINE_ID
			, BATCH_ID
			, BOM_ITEM_TYPE
			, COMPONENT_CODE
			, COMPONENT_SEQUENCE_ID
			, CONFIG_ITEM_ID
			, INVENTORY_ITEM_ID
			, ITEM_TYPE_CODE
			, LINE_ID
			, LINK_TO_LINE_ID
			, ORDERED_QUANTITY
			, ORDER_QUANTITY_UOM
			, PARENT_ATO_LINE_ID
			, PERFORM_MATCH
			, PLAN_LEVEL
			, SCHEDULE_SHIP_DATE
			, SHIP_FROM_ORG_ID
			, TOP_MODEL_LINE_ID
			, WIP_SUPPLY_TYPE
			, HEADER_ID
			, LAST_UPDATE_DATE
			, LAST_UPDATED_BY
			, CREATION_DATE
			, CREATED_BY
			, LAST_UPDATE_LOGIN
			, REQUEST_ID
			, PROGRAM_APPLICATION_ID
			, PROGRAM_ID
			, PROGRAM_UPDATE_DATE
			, OPTION_SPECIFIC
			, REUSE_CONFIG
			, QTY_PER_PARENT_MODEL
			, STATUS
			, CONFIG_CREATION
			)
			select distinct
			bcol2.ATO_LINE_ID
			, bcol2.BATCH_ID
			, bcol2.BOM_ITEM_TYPE
			, bcol2.COMPONENT_CODE
			, bcol2.COMPONENT_SEQUENCE_ID
			, bcol2.CONFIG_ITEM_ID
			, bcol2.INVENTORY_ITEM_ID
			, bcol2.ITEM_TYPE_CODE
			, bcol2.LINE_ID
			, bcol2.LINK_TO_LINE_ID
			, bcol2.ORDERED_QUANTITY
			, bcol2.ORDER_QUANTITY_UOM
			, bcol2.PARENT_ATO_LINE_ID
                        , decode(bcol2.perform_match, 'C', 'Y', bcol2.perform_match)  -- Bugfix 8894392
			--, bcol2.PERFORM_MATCH                 --7201878
			--, 'Y'		--PERFORM_MATCH   /* Sushant made changes to identify matched items */
			, bcol2.PLAN_LEVEL
			, bcol2.SCHEDULE_SHIP_DATE
			, bcol2.SHIP_FROM_ORG_ID
			, bcol2.TOP_MODEL_LINE_ID
			, bcol2.WIP_SUPPLY_TYPE
			, bcol2.HEADER_ID
			, sysdate	--LAST_UPDATE_DATE
			, bcol2.LAST_UPDATED_BY
			, sysdate	--CREATION_DATE
			, bcol2.CREATED_BY
			, bcol2.LAST_UPDATE_LOGIN
			, bcol2.REQUEST_ID
			, bcol2.PROGRAM_APPLICATION_ID
			, bcol2.PROGRAM_ID
			, sysdate	--PROGRAM_UPDATE_DATE
			, bcol2.OPTION_SPECIFIC
			, 'N'		--REUSE_CONFIG
			, bcol2.QTY_PER_PARENT_MODEL
			, 'UPG'		--STATUS
			, nvl(msi.CONFIG_ORGS, '1')
			from bom_cto_order_lines bcol1
			, bom_cto_order_lines bcol2
			, bom_ato_configurations bac
			, oe_order_lines_all oel
			, mtl_system_items msi
			-- base model has item attr = 3
			where bac.base_model_id = msi.inventory_item_id
			and bac.organization_id = msi.organization_id
			and msi.config_orgs     = '3' -- bug 13362916 removed nvl for performance
			-- and exists in bcol
			and bac.config_item_id = bcol1.config_item_id
			-- on open order lines
			and bcol1.line_id = oel.line_id
			and oel.open_flag = 'Y' -- bug 13362916 removed nvl
			and bcol2.ato_line_id = bcol1.ato_line_id
			;
Line: 1561

			WriteToLog('Rows inserted::'|| to_char(sql%rowcount), 3);
Line: 1567

			-- select additional TOP LEVEL config items with attribute = 3 on closed order lines
			-- populate into bcol_upg
			-- mark as UPG
			--

			-- commenting as part of Bugfix 8894392
			/*WriteToLog('sql 7', 3);
Line: 1575

			insert into bom_cto_order_lines_upg
			(
			 ATO_LINE_ID
			, BATCH_ID
			, BOM_ITEM_TYPE
			, COMPONENT_CODE
			, COMPONENT_SEQUENCE_ID
			, CONFIG_ITEM_ID
			, INVENTORY_ITEM_ID
			, ITEM_TYPE_CODE
			, LINE_ID
			, LINK_TO_LINE_ID
			, ORDERED_QUANTITY
			, ORDER_QUANTITY_UOM
			, PARENT_ATO_LINE_ID
			, PERFORM_MATCH
			, PLAN_LEVEL
			, SCHEDULE_SHIP_DATE
			, SHIP_FROM_ORG_ID
			, TOP_MODEL_LINE_ID
			, WIP_SUPPLY_TYPE
			, HEADER_ID
			, LAST_UPDATE_DATE
			, LAST_UPDATED_BY
			, CREATION_DATE
			, CREATED_BY
			, LAST_UPDATE_LOGIN
			, REQUEST_ID
			, PROGRAM_APPLICATION_ID
			, PROGRAM_ID
			, PROGRAM_UPDATE_DATE
			, OPTION_SPECIFIC
			, REUSE_CONFIG
			, QTY_PER_PARENT_MODEL
			, STATUS
			, CONFIG_CREATION
			)
			select distinct
			bcol.ATO_LINE_ID
			, bcol.BATCH_ID
			, bcol.BOM_ITEM_TYPE
			, bcol.COMPONENT_CODE
			, bcol.COMPONENT_SEQUENCE_ID
			, bcol.CONFIG_ITEM_ID
			, bcol.INVENTORY_ITEM_ID
			, bcol.ITEM_TYPE_CODE
			, bcol.LINE_ID
			, bcol.LINK_TO_LINE_ID
			, bcol.ORDERED_QUANTITY
			, bcol.ORDER_QUANTITY_UOM
			, bcol.PARENT_ATO_LINE_ID
                        , bcol.PERFORM_MATCH              --7201878
			--, 'N'		--PERFORM_MATCH  /* Sushant made changes to identify matched items */
			/*, bcol.PLAN_LEVEL
			, bcol.SCHEDULE_SHIP_DATE
			, bcol.SHIP_FROM_ORG_ID
			, bcol.TOP_MODEL_LINE_ID
			, bcol.WIP_SUPPLY_TYPE
			, bcol.HEADER_ID
			, sysdate	--LAST_UPDATE_DATE
			, bcol.LAST_UPDATED_BY
			, sysdate	--CREATION_DATE
			, bcol.CREATED_BY
			, bcol.LAST_UPDATE_LOGIN
			, bcol.REQUEST_ID
			, bcol.PROGRAM_APPLICATION_ID
			, 99		-- matched item on closed line
			, bcol.PROGRAM_UPDATE_DATE
			, bcol.OPTION_SPECIFIC
			, 'N'		--REUSE_CONFIG
			, bcol.QTY_PER_PARENT_MODEL
			, 'UPG'		--STATUS
			, nvl(msi.CONFIG_ORGS, '1')
			from bom_ato_configurations bac
			, bom_cto_order_lines bcol
			, mtl_system_items msi
			-- base model has item attr = 3
			where bac.base_model_id = msi.inventory_item_id
			and bac.organization_id = msi.organization_id
			and nvl(msi.config_orgs, '1') = '3'
			-- and is top parent with attribute 3
			and NOT EXISTS
				(select 'exists'
				from bom_ato_configurations bac2
				, mtl_system_items msi2
				where bac.config_item_id = bac2.component_item_id
				and bac2.base_model_id = msi2.inventory_item_id
				and bac2.organization_id = msi2.organization_id
				and nvl(msi2.config_orgs, '1') = '3')
			-- and not already in bcol_upg
			and NOT EXISTS
				(select 'exists'
				from bom_cto_order_lines_upg bcolu
				where bcolu.config_item_id = bac.config_item_id)
			-- select first ato_line_id in bcol
			and bcol.ato_line_id =
				(select bcol1.ato_line_id
				from bom_cto_order_lines bcol1
				where bcol1.config_item_id = bac.config_item_id
				-- pick up only if config is at top level
				and bcol1.line_id = bcol1.ato_line_id
				and rownum = 1)
			;
Line: 1679

			WriteToLog('Rows inserted::'|| to_char(sql%rowcount), 3);*/
Line: 1682

			-- select all top level config items in bac having item attribute = 3 and not in bcol_upg
			-- populate into bcol_upg from bcol or bac
			-- mark as UPG
			-- mark with program_id = 99 to indicate that it was populated from bac
			--
			WriteToLog('sql 8', 3);
Line: 1692

				select 'exists'
				into l_exists
				from bom_cto_order_lines_upg bcolu
				where bcolu.config_item_id = v_bac_top.config_id
				and rownum = 1;
Line: 1769

select /*+ ORDERED */ distinct bac.config_item_id config_id --Bugfix 6617686 Added a hint
from mtl_item_categories mcat,  --Bugfix 6617686: Changed the order of tables
mtl_system_items msi,
bom_ato_configurations bac
where NOT EXISTS
	(select 'exists'
	from bom_cto_order_lines_upg bcolu
	where bcolu.config_item_id = bac.config_item_id)
and bac.base_model_id = msi.inventory_item_id
and bac.organization_id = msi.organization_id
and msi.config_orgs     = '3' -- bug 13362916 removed nvl for performance
-- and base model is in CTO category
and mcat.inventory_item_id = msi.inventory_item_id
and mcat.organization_id = msi.organization_id
and mcat.category_id = p_cat_id;
Line: 1793

select distinct bac.config_item_id config_id  --Bugfix 6617686 Added a hint
from mtl_item_categories mcat, --Bugfix 6617686 Changed the order of tables
mtl_system_items msi,
bom_ato_configurations bac
-- item attribute is 3
where bac.base_model_id = msi.inventory_item_id
and bac.organization_id = msi.organization_id
and msi.config_orgs     = '3'
-- and base model is in CTO category
and mcat.inventory_item_id = msi.inventory_item_id
and mcat.organization_id = msi.organization_id
and mcat.category_id = p_cat_id
-- bug 13876670
and mcat.category_set_id = p_category_set_id
-- and is top parent with attribute 3
and NOT EXISTS
	(select /*+ no_unnest push_subq */ 'exists' -- bug 13876670 added hint
	from bom_ato_configurations bac2
	, mtl_system_items msi2
	where bac.config_item_id = bac2.component_item_id
	and bac2.base_model_id = msi2.inventory_item_id
	and bac2.organization_id = msi2.organization_id
	and msi2.config_orgs     = '3')
-- and not already in bcol_upg
and NOT EXISTS
	(select /*+ index(bcolu BOM_CTO_ORDER_LINES_UPG_N1) */ 'exists' -- 13362916 added hint
	from bom_cto_order_lines_upg bcolu
	where bcolu.config_item_id = bac.config_item_id);
Line: 1842

		WriteToLog('Match profile is No and you chose not to update existing configurations. No configurations will be updated.');
Line: 1856

			-- select all open order lines having config items in l_cat_id with attribute in (2,3)
			-- populate into bcol_upg
			-- mark as UPG
			--
			WriteToLog('sql 1', 3);
Line: 1862

			insert into bom_cto_order_lines_upg
			(
			 ATO_LINE_ID
			, BATCH_ID
			, BOM_ITEM_TYPE
			, COMPONENT_CODE
			, COMPONENT_SEQUENCE_ID
			, CONFIG_ITEM_ID
			, INVENTORY_ITEM_ID
			, ITEM_TYPE_CODE
			, LINE_ID
			, LINK_TO_LINE_ID
			, ORDERED_QUANTITY
			, ORDER_QUANTITY_UOM
			, PARENT_ATO_LINE_ID
			, PERFORM_MATCH
			, PLAN_LEVEL
			, SCHEDULE_SHIP_DATE
			, SHIP_FROM_ORG_ID
			, TOP_MODEL_LINE_ID
			, WIP_SUPPLY_TYPE
			, HEADER_ID
			, LAST_UPDATE_DATE
			, LAST_UPDATED_BY
			, CREATION_DATE
			, CREATED_BY
			, LAST_UPDATE_LOGIN
			, REQUEST_ID
			, PROGRAM_APPLICATION_ID
			, PROGRAM_ID
			, PROGRAM_UPDATE_DATE
			, OPTION_SPECIFIC
			, REUSE_CONFIG
			, QTY_PER_PARENT_MODEL
			, STATUS
			--, SEQUENCE
			, config_creation
			)
			select distinct
			bcol2.ATO_LINE_ID
			, bcol2.BATCH_ID
			, bcol2.BOM_ITEM_TYPE
			, bcol2.COMPONENT_CODE
			, bcol2.COMPONENT_SEQUENCE_ID
			, bcol2.CONFIG_ITEM_ID
			, bcol2.INVENTORY_ITEM_ID
			, bcol2.ITEM_TYPE_CODE
			, bcol2.LINE_ID
			, bcol2.LINK_TO_LINE_ID
			, bcol2.ORDERED_QUANTITY
			, bcol2.ORDER_QUANTITY_UOM
			, bcol2.PARENT_ATO_LINE_ID
                        , decode(bcol2.perform_match, 'C', 'Y', bcol2.perform_match)  -- Bugfix 8894392
			--, bcol2.PERFORM_MATCH           --7201878
			--, 'N'	--bcol2.PERFORM_MATCH
			, bcol2.PLAN_LEVEL
			, bcol2.SCHEDULE_SHIP_DATE
			, bcol2.SHIP_FROM_ORG_ID
			, bcol2.TOP_MODEL_LINE_ID
			, bcol2.WIP_SUPPLY_TYPE
			, bcol2.HEADER_ID
			, sysdate	--LAST_UPDATE_DATE
			, bcol2.LAST_UPDATED_BY
			, sysdate	--CREATION_DATE
			, bcol2.CREATED_BY
			, bcol2.LAST_UPDATE_LOGIN
			, bcol2.REQUEST_ID
			, bcol2.PROGRAM_APPLICATION_ID
			, bcol2.PROGRAM_ID
			, sysdate	--PROGRAM_UPDATE_DATE
			, bcol2.OPTION_SPECIFIC
			, 'N'	--bcol2.REUSE_CONFIG
			, bcol2.QTY_PER_PARENT_MODEL
			, 'UPG'		--STATUS
			--, bcol2.SEQUENCE
			, nvl(msi.config_orgs, '1')
			from bom_cto_order_lines bcol1
			, bom_cto_order_lines bcol2
			, oe_order_lines_all oel
			, mtl_system_items msi
			, mtl_item_categories mcat
			-- select entire configuration
			where bcol2.ato_line_id = bcol1.ato_line_id
			and bcol1.config_item_id is not null
			-- for configs whose models are in CTO category
			and mcat.inventory_item_id = bcol1.inventory_item_id
			and mcat.organization_id = bcol1.ship_from_org_id
			and mcat.category_id = p_cat_id
			-- for configs whose models have attr=2,3
			and bcol1.inventory_item_id = msi.inventory_item_id
			and bcol1.ship_from_org_id = msi.organization_id
			and msi.config_orgs        in ('2', '3') -- bug 13362916 removed nvl for performance
			-- and are on open order lines
			and bcol1.line_id = oel.ato_line_id /* changed line_id to ato_line_id */
			and oel.open_flag = 'Y' -- bug 13362916 removed NVL
                        and oel.item_type_code = 'CONFIG' ; /* added check for config linked to oe */
Line: 1959

			WriteToLog('Rows inserted::'|| to_char(sql%rowcount), 3);
Line: 1963

			-- select all open order lines having canned config items with attribute = 3
			-- populate into bcol_upg
			-- mark as UPG
			--
			WriteToLog('sql 2', 3);
Line: 1969

			insert into bom_cto_order_lines_upg
			(
			 ATO_LINE_ID
			, BATCH_ID
			, BOM_ITEM_TYPE
			, COMPONENT_CODE
			, COMPONENT_SEQUENCE_ID
			, CONFIG_ITEM_ID
			, INVENTORY_ITEM_ID
			, ITEM_TYPE_CODE
			, LINE_ID
			, LINK_TO_LINE_ID
			, ORDERED_QUANTITY
			, ORDER_QUANTITY_UOM
			, PARENT_ATO_LINE_ID
			, PERFORM_MATCH
			, PLAN_LEVEL
			, SCHEDULE_SHIP_DATE
			, SHIP_FROM_ORG_ID
			, TOP_MODEL_LINE_ID
			, WIP_SUPPLY_TYPE
			, HEADER_ID
			, LAST_UPDATE_DATE
			, LAST_UPDATED_BY
			, CREATION_DATE
			, CREATED_BY
			, LAST_UPDATE_LOGIN
			, REQUEST_ID
			, PROGRAM_APPLICATION_ID
			, PROGRAM_ID
			, PROGRAM_UPDATE_DATE
			, OPTION_SPECIFIC
			, REUSE_CONFIG
			, QTY_PER_PARENT_MODEL
			, STATUS
			--, SEQUENCE
			, config_creation
			)
			select distinct
			bcol2.ATO_LINE_ID
			, bcol2.BATCH_ID
			, bcol2.BOM_ITEM_TYPE
			, bcol2.COMPONENT_CODE
			, bcol2.COMPONENT_SEQUENCE_ID
			, bcol2.CONFIG_ITEM_ID
			, bcol2.INVENTORY_ITEM_ID
			, bcol2.ITEM_TYPE_CODE
			, bcol2.LINE_ID
			, bcol2.LINK_TO_LINE_ID
			, bcol2.ORDERED_QUANTITY
			, bcol2.ORDER_QUANTITY_UOM
			, bcol2.PARENT_ATO_LINE_ID
                        , decode(bcol2.perform_match, 'C', 'Y', bcol2.perform_match)  -- Bugfix 8894392
			--, bcol2.PERFORM_MATCH                   --7201878
			--, 'Y'	--bcol2.PERFORM_MATCH /* Sushant made changes to identify matched items */
			, bcol2.PLAN_LEVEL
			, bcol2.SCHEDULE_SHIP_DATE
			, bcol2.SHIP_FROM_ORG_ID
			, bcol2.TOP_MODEL_LINE_ID
			, bcol2.WIP_SUPPLY_TYPE
			, bcol2.HEADER_ID
			, sysdate	--LAST_UPDATE_DATE
			, bcol2.LAST_UPDATED_BY
			, sysdate	--CREATION_DATE
			, bcol2.CREATED_BY
			, bcol2.LAST_UPDATE_LOGIN
			, bcol2.REQUEST_ID
			, bcol2.PROGRAM_APPLICATION_ID
			, bcol2.PROGRAM_ID
			, sysdate	--PROGRAM_UPDATE_DATE
			, bcol2.OPTION_SPECIFIC
			, 'N'	--bcol2.REUSE_CONFIG
			, bcol2.QTY_PER_PARENT_MODEL
			, 'UPG'		--STATUS
			--, bcol2.SEQUENCE
			, nvl(msi.config_orgs, '1')
			from bom_cto_order_lines bcol1
			, bom_cto_order_lines bcol2
			, bom_ato_configurations bac
			, oe_order_lines_all oel
			, mtl_system_items msi
			, mtl_item_categories mcat
			-- base model has item attr = 3
			where bac.base_model_id = msi.inventory_item_id
			and bac.organization_id = msi.organization_id
			and msi.config_orgs     = '3' -- bug 13362916 removed nvl for performance
			-- and exists in bcol
			and bac.config_item_id = bcol1.config_item_id
			-- for configs whose models are in CTO category
			and mcat.inventory_item_id = bcol1.inventory_item_id
			and mcat.organization_id = bcol1.ship_from_org_id
			and mcat.category_id = p_cat_id
			-- on open order lines
			and bcol1.line_id = oel.ato_line_id /* changed line_id to ato_line_id */
			and oel.open_flag = 'Y' -- bug 13362916 removed NVL
			and bcol2.ato_line_id = bcol1.ato_line_id
                        and oel.item_type_code = 'CONFIG' ;  /* added check for config linked to oe */
Line: 2066

			WriteToLog('Rows inserted::'|| to_char(sql%rowcount), 3);
Line: 2072

			-- select additional config items with attribute = 3 on closed order lines
			-- populate into bcol_upg
			-- mark as UPG
			--

			-- commenting as part of Bugfix 8894392
			/*WriteToLog('sql 3', 3);
Line: 2080

			insert into bom_cto_order_lines_upg
			(
			 ATO_LINE_ID
			, BATCH_ID
			, BOM_ITEM_TYPE
			, COMPONENT_CODE
			, COMPONENT_SEQUENCE_ID
			, CONFIG_ITEM_ID
			, INVENTORY_ITEM_ID
			, ITEM_TYPE_CODE
			, LINE_ID
			, LINK_TO_LINE_ID
			, ORDERED_QUANTITY
			, ORDER_QUANTITY_UOM
			, PARENT_ATO_LINE_ID
			, PERFORM_MATCH
			, PLAN_LEVEL
			, SCHEDULE_SHIP_DATE
			, SHIP_FROM_ORG_ID
			, TOP_MODEL_LINE_ID
			, WIP_SUPPLY_TYPE
			, HEADER_ID
			, LAST_UPDATE_DATE
			, LAST_UPDATED_BY
			, CREATION_DATE
			, CREATED_BY
			, LAST_UPDATE_LOGIN
			, REQUEST_ID
			, PROGRAM_APPLICATION_ID
			, PROGRAM_ID
			, PROGRAM_UPDATE_DATE
			, OPTION_SPECIFIC
			, REUSE_CONFIG
			, QTY_PER_PARENT_MODEL
			, STATUS
			--, SEQUENCE
			, config_creation
			)*/
			--select /*+ ORDERED*/ distinct  --Bugfix 6617686 Added a hint
			/*bcol.ATO_LINE_ID
			, bcol.BATCH_ID
			, bcol.BOM_ITEM_TYPE
			, bcol.COMPONENT_CODE
			, bcol.COMPONENT_SEQUENCE_ID
			, bcol.CONFIG_ITEM_ID
			, bcol.INVENTORY_ITEM_ID
			, bcol.ITEM_TYPE_CODE
			, bcol.LINE_ID
			, bcol.LINK_TO_LINE_ID
			, bcol.ORDERED_QUANTITY
			, bcol.ORDER_QUANTITY_UOM
			, bcol.PARENT_ATO_LINE_ID
                        , bcol.PERFORM_MATCH                    --7201878
			--, 'N'	--bcol.PERFORM_MATCH
			, bcol.PLAN_LEVEL
			, bcol.SCHEDULE_SHIP_DATE
			, bcol.SHIP_FROM_ORG_ID
			, bcol.TOP_MODEL_LINE_ID
			, bcol.WIP_SUPPLY_TYPE
			, bcol.HEADER_ID
			, sysdate	--LAST_UPDATE_DATE
			, bcol.LAST_UPDATED_BY
			, sysdate	--CREATION_DATE
			, bcol.CREATED_BY
			, bcol.LAST_UPDATE_LOGIN
			, bcol.REQUEST_ID
			, bcol.PROGRAM_APPLICATION_ID
			, 99		-- matched item on closed line
			, bcol.PROGRAM_UPDATE_DATE
			, bcol.OPTION_SPECIFIC
			, 'N'	--bcol.REUSE_CONFIG
			, bcol.QTY_PER_PARENT_MODEL
			, 'UPG'		--STATUS
			--, bcol.SEQUENCE
			, nvl(msi.config_orgs, '1')
			from mtl_item_categories mcat --Bugfix 6617686 Changed the order of tables
			, mtl_system_items msi
			, bom_ato_configurations bac
                        , bom_cto_order_lines bcol
			-- base model has item attr = 3
			where bac.base_model_id = msi.inventory_item_id
			and bac.organization_id = msi.organization_id
			and nvl(msi.config_orgs, '1') = '3'
			-- and base model is in CTO category
			and mcat.inventory_item_id = msi.inventory_item_id
			and mcat.organization_id = msi.organization_id
			and mcat.category_id = p_cat_id
			-- and not already in bcol_upg
			and NOT EXISTS
				(select 'exists'
				from bom_cto_order_lines_upg bcolu
				where bcolu.config_item_id = bac.config_item_id)
			-- select first ato_line_id in bcol
			and bcol.ato_line_id =
				(select bcol1.ato_line_id
				from bom_cto_order_lines bcol1
				where bcol1.config_item_id = bac.config_item_id
				-- pick up only if config is at top level
				and bcol1.line_id = bcol1.ato_line_id
				and rownum = 1)
			;
Line: 2181

			WriteToLog('Rows inserted::'|| to_char(sql%rowcount), 3);*/
Line: 2184

			-- select all individual (not top level) config items in bac having item attribute = 3 and not in bcol_upg
			-- populate into bcol_upg from bcol or bac
			-- mark as UPG
			-- mark with program_id = 99 to indicate that it was populated from bac
			--
			WriteToLog('sql 4', 3);
Line: 2197

				select 'Y'
				into l_exists
				from bom_cto_order_lines_upg
				where config_item_id = v_bac.config_id
				and rownum = 1;
Line: 2229

			-- select all open order lines
			-- populate into bcol_upg
			-- mark as UPG
			--
			WriteToLog('sql 5', 3);
Line: 2236

			insert into bom_cto_order_lines_upg
			(
			 ATO_LINE_ID
			, BATCH_ID
			, BOM_ITEM_TYPE
			, COMPONENT_CODE
			, COMPONENT_SEQUENCE_ID
			, CONFIG_ITEM_ID
			, INVENTORY_ITEM_ID
			, ITEM_TYPE_CODE
			, LINE_ID
			, LINK_TO_LINE_ID
			, ORDERED_QUANTITY
			, ORDER_QUANTITY_UOM
			, PARENT_ATO_LINE_ID
			, PERFORM_MATCH
			, PLAN_LEVEL
			, SCHEDULE_SHIP_DATE
			, SHIP_FROM_ORG_ID
			, TOP_MODEL_LINE_ID
			, WIP_SUPPLY_TYPE
			, HEADER_ID
			, LAST_UPDATE_DATE
			, LAST_UPDATED_BY
			, CREATION_DATE
			, CREATED_BY
			, LAST_UPDATE_LOGIN
			, REQUEST_ID
			, PROGRAM_APPLICATION_ID
			, PROGRAM_ID
			, PROGRAM_UPDATE_DATE
			, OPTION_SPECIFIC
			, REUSE_CONFIG
			, QTY_PER_PARENT_MODEL
			, STATUS
			--, SEQUENCE
			, CONFIG_CREATION
			)
			select distinct
			bcol.ATO_LINE_ID
			, bcol.BATCH_ID
			, bcol.BOM_ITEM_TYPE
			, bcol.COMPONENT_CODE
			, bcol.COMPONENT_SEQUENCE_ID
			, bcol.CONFIG_ITEM_ID
			, bcol.INVENTORY_ITEM_ID
			, bcol.ITEM_TYPE_CODE
			, bcol.LINE_ID
			, bcol.LINK_TO_LINE_ID
			, bcol.ORDERED_QUANTITY
			, bcol.ORDER_QUANTITY_UOM
			, bcol.PARENT_ATO_LINE_ID
                        , decode(bcol.perform_match, 'C', 'Y', bcol.perform_match)  -- Bugfix 8894392
			--, bcol.PERFORM_MATCH                    --7201878
			--, 'N'	--bcol.PERFORM_MATCH
			, bcol.PLAN_LEVEL
			, bcol.SCHEDULE_SHIP_DATE
			, bcol.SHIP_FROM_ORG_ID
			, bcol.TOP_MODEL_LINE_ID
			, bcol.WIP_SUPPLY_TYPE
			, bcol.HEADER_ID
			, sysdate	--LAST_UPDATE_DATE
			, bcol.LAST_UPDATED_BY
			, sysdate	--CREATION_DATE
			, bcol.CREATED_BY
			, bcol.LAST_UPDATE_LOGIN
			, bcol.REQUEST_ID
			, bcol.PROGRAM_APPLICATION_ID
			, bcol.PROGRAM_ID
			, sysdate	--PROGRAM_UPDATE_DATE
			, bcol.OPTION_SPECIFIC
			, 'N'	--bcol.REUSE_CONFIG
			, bcol.QTY_PER_PARENT_MODEL
			, 'UPG'		--STATUS
			--, bcol.SEQUENCE
			, nvl(msi2.CONFIG_ORGS, '1')
			from bom_cto_order_lines bcol
			, oe_order_lines_all oel
			, mtl_system_items msi2
			-- select all configs on open order lines
			where bcol.ato_line_id = oel.ato_line_id
			and bcol.inventory_item_id = msi2.inventory_item_id
			and bcol.ship_from_org_id = msi2.organization_id
			and oel.open_flag = 'Y' -- 13362916 removed NVL
			and oel.ato_line_id in -- bug 6617686 connect using oel rather than bcol to get better filtering
				(select /*+ leading(MCAT) */ distinct bcol2.ato_line_id --Bugfix 6617686 Added a hint
				from mtl_item_categories mcat --Bugfix 6617686 Changed the order of tables
				, mtl_system_items msi
				, bom_cto_order_lines bcol2
				where bcol2.config_item_id is not null
				and bcol2.inventory_item_id = msi.inventory_item_id
				and bcol2.ship_from_org_id = msi.organization_id
				-- and base model is in CTO category
				and mcat.inventory_item_id = msi.inventory_item_id
				and mcat.organization_id = msi.organization_id
				and mcat.category_id = p_cat_id
                                -- bug 13876670
                                and mcat.category_set_id = p_category_set_id)
                        and oel.item_type_code = 'CONFIG' ;/* original bug detected, added condition for bug 3599397 */
Line: 2336

			WriteToLog('Rows inserted::'|| to_char(sql%rowcount), 3);
Line: 2340

			-- select all open order lines having canned config items with attribute = 3 and assigned to CTO category
			-- populate into bcol_upg
			-- mark as UPG
			-- TEST THIS!!
			--
			WriteToLog('sql 6', 3);
Line: 2347

			insert into bom_cto_order_lines_upg
			(
			 ATO_LINE_ID
			, BATCH_ID
			, BOM_ITEM_TYPE
			, COMPONENT_CODE
			, COMPONENT_SEQUENCE_ID
			, CONFIG_ITEM_ID
			, INVENTORY_ITEM_ID
			, ITEM_TYPE_CODE
			, LINE_ID
			, LINK_TO_LINE_ID
			, ORDERED_QUANTITY
			, ORDER_QUANTITY_UOM
			, PARENT_ATO_LINE_ID
			, PERFORM_MATCH
			, PLAN_LEVEL
			, SCHEDULE_SHIP_DATE
			, SHIP_FROM_ORG_ID
			, TOP_MODEL_LINE_ID
			, WIP_SUPPLY_TYPE
			, HEADER_ID
			, LAST_UPDATE_DATE
			, LAST_UPDATED_BY
			, CREATION_DATE
			, CREATED_BY
			, LAST_UPDATE_LOGIN
			, REQUEST_ID
			, PROGRAM_APPLICATION_ID
			, PROGRAM_ID
			, PROGRAM_UPDATE_DATE
			, OPTION_SPECIFIC
			, REUSE_CONFIG
			, QTY_PER_PARENT_MODEL
			, STATUS
			--, SEQUENCE
			, CONFIG_CREATION
			)
			select distinct
			bcol2.ATO_LINE_ID
			, bcol2.BATCH_ID
			, bcol2.BOM_ITEM_TYPE
			, bcol2.COMPONENT_CODE
			, bcol2.COMPONENT_SEQUENCE_ID
			, bcol2.CONFIG_ITEM_ID
			, bcol2.INVENTORY_ITEM_ID
			, bcol2.ITEM_TYPE_CODE
			, bcol2.LINE_ID
			, bcol2.LINK_TO_LINE_ID
			, bcol2.ORDERED_QUANTITY
			, bcol2.ORDER_QUANTITY_UOM
			, bcol2.PARENT_ATO_LINE_ID
                        , decode(bcol2.perform_match, 'C', 'Y', bcol2.perform_match)  -- Bugfix 8894392
			--, bcol2.PERFORM_MATCH                   --7201878
			--, 'Y'	--bcol2.PERFORM_MATCH  /* Sushant made changes to identify matched items */
			, bcol2.PLAN_LEVEL
			, bcol2.SCHEDULE_SHIP_DATE
			, bcol2.SHIP_FROM_ORG_ID
			, bcol2.TOP_MODEL_LINE_ID
			, bcol2.WIP_SUPPLY_TYPE
			, bcol2.HEADER_ID
			, sysdate	--LAST_UPDATE_DATE
			, bcol2.LAST_UPDATED_BY
			, sysdate	--CREATION_DATE
			, bcol2.CREATED_BY
			, bcol2.LAST_UPDATE_LOGIN
			, bcol2.REQUEST_ID
			, bcol2.PROGRAM_APPLICATION_ID
			, bcol2.PROGRAM_ID
			, sysdate	--PROGRAM_UPDATE_DATE
			, bcol2.OPTION_SPECIFIC
			, 'N'	--bcol2.REUSE_CONFIG
			, bcol2.QTY_PER_PARENT_MODEL
			, 'UPG'		--STATUS
			--, bcol2.SEQUENCE
			, nvl(msi.CONFIG_ORGS, '1')
			from bom_cto_order_lines bcol1
			, bom_cto_order_lines bcol2
			, bom_ato_configurations bac
			, oe_order_lines_all oel
			, mtl_system_items msi
			, mtl_item_categories mcat
			-- base model has item attr = 3
			where bac.base_model_id = msi.inventory_item_id
			and bac.organization_id = msi.organization_id
			and msi.config_orgs     = '3' -- bug 13362916 removed nvl for performance
			-- and exists in bcol
			and bac.config_item_id = bcol1.config_item_id
			-- on open order lines
			and bcol1.line_id = oel.line_id
			and oel.open_flag = 'Y' -- bug 13362916 removed nvl
			and bcol2.ato_line_id = bcol1.ato_line_id
			-- and base model is in CTO category
			and mcat.inventory_item_id = msi.inventory_item_id
			and mcat.organization_id = msi.organization_id
			and mcat.category_id = p_cat_id
                        -- bug 13876670
                        and mcat.category_set_id = p_category_set_id;
Line: 2446

			WriteToLog('Rows inserted::'|| to_char(sql%rowcount), 3);
Line: 2452

			-- select additional TOP LEVEL config items with attribute = 3 on closed order lines
			-- populate into bcol_upg
			-- mark as UPG
			--
			-- commenting as part of Bugfix 8894392
			/*WriteToLog('sql 7', 3);
Line: 2459

			insert into bom_cto_order_lines_upg
			(
			 ATO_LINE_ID
			, BATCH_ID
			, BOM_ITEM_TYPE
			, COMPONENT_CODE
			, COMPONENT_SEQUENCE_ID
			, CONFIG_ITEM_ID
			, INVENTORY_ITEM_ID
			, ITEM_TYPE_CODE
			, LINE_ID
			, LINK_TO_LINE_ID
			, ORDERED_QUANTITY
			, ORDER_QUANTITY_UOM
			, PARENT_ATO_LINE_ID
			, PERFORM_MATCH
			, PLAN_LEVEL
			, SCHEDULE_SHIP_DATE
			, SHIP_FROM_ORG_ID
			, TOP_MODEL_LINE_ID
			, WIP_SUPPLY_TYPE
			, HEADER_ID
			, LAST_UPDATE_DATE
			, LAST_UPDATED_BY
			, CREATION_DATE
			, CREATED_BY
			, LAST_UPDATE_LOGIN
			, REQUEST_ID
			, PROGRAM_APPLICATION_ID
			, PROGRAM_ID
			, PROGRAM_UPDATE_DATE
			, OPTION_SPECIFIC
			, REUSE_CONFIG
			, QTY_PER_PARENT_MODEL
			, STATUS
			--, SEQUENCE
			, CONFIG_CREATION
			)*/
			--select /*+ leading(MCAT) */ distinct
			/*bcol.ATO_LINE_ID
			, bcol.BATCH_ID
			, bcol.BOM_ITEM_TYPE
			, bcol.COMPONENT_CODE
			, bcol.COMPONENT_SEQUENCE_ID
			, bcol.CONFIG_ITEM_ID
			, bcol.INVENTORY_ITEM_ID
			, bcol.ITEM_TYPE_CODE
			, bcol.LINE_ID
			, bcol.LINK_TO_LINE_ID
			, bcol.ORDERED_QUANTITY
			, bcol.ORDER_QUANTITY_UOM
			, bcol.PARENT_ATO_LINE_ID
                        , bcol.PERFORM_MATCH                    --7201878
			--, 'Y'	--bcol.PERFORM_MATCH /* Sushant made changes to identify matched items */
			/*, bcol.PLAN_LEVEL
			, bcol.SCHEDULE_SHIP_DATE
			, bcol.SHIP_FROM_ORG_ID
			, bcol.TOP_MODEL_LINE_ID
			, bcol.WIP_SUPPLY_TYPE
			, bcol.HEADER_ID
			, sysdate	--LAST_UPDATE_DATE
			, bcol.LAST_UPDATED_BY
			, sysdate	--CREATION_DATE
			, bcol.CREATED_BY
			, bcol.LAST_UPDATE_LOGIN
			, bcol.REQUEST_ID
			, bcol.PROGRAM_APPLICATION_ID
			, 99		-- matched item on closed line
			, bcol.PROGRAM_UPDATE_DATE
			, bcol.OPTION_SPECIFIC
			, 'N'	--bcol.REUSE_CONFIG
			, bcol.QTY_PER_PARENT_MODEL
			, 'UPG'		--STATUS
			--, bcol.SEQUENCE
			, nvl(msi.CONFIG_ORGS, '1')
			from bom_ato_configurations bac
			, bom_cto_order_lines bcol
			, mtl_system_items msi
			, mtl_item_categories mcat
			-- base model has item attr = 3
			where bac.base_model_id = msi.inventory_item_id
			and bac.organization_id = msi.organization_id
			and nvl(msi.config_orgs, '1') = '3'
			-- and base model is in CTO category
			and mcat.inventory_item_id = msi.inventory_item_id
			and mcat.organization_id = msi.organization_id
			and mcat.category_id = p_cat_id
			-- and is top parent with attribute 3
			and NOT EXISTS
				(select 'exists'
				from bom_ato_configurations bac2
				, mtl_system_items msi2
				where bac.config_item_id = bac2.component_item_id
				and bac2.base_model_id = msi2.inventory_item_id
				and bac2.organization_id = msi2.organization_id
				and nvl(msi2.config_orgs, '1') = '3')
			-- and not already in bcol_upg
			and NOT EXISTS
				(select 'exists'
				from bom_cto_order_lines_upg bcolu
				where bcolu.config_item_id = bac.config_item_id)
			-- select first ato_line_id in bcol
			and bcol.ato_line_id =
				(select bcol1.ato_line_id
				from bom_cto_order_lines bcol1
				where bcol1.config_item_id = bac.config_item_id
				-- pick up only if config is at top level
				and bcol1.line_id = bcol1.ato_line_id
				and rownum = 1)
			;
Line: 2570

			WriteToLog('Rows inserted::'|| to_char(sql%rowcount), 3);*/
Line: 2573

			-- select all top level config items in bac having item attribute = 3 and not in bcol_upg
			-- populate into bcol_upg from bcol or bac
			-- mark as UPG
			-- mark with program_id = 99 to indicate that it was populated from bac
			--
			WriteToLog('sql 8', 3);
Line: 2583

				select 'exists'
				into l_exists
				from bom_cto_order_lines_upg bcolu
				where bcolu.config_item_id = v_bac_top.config_id
				and rownum = 1;
Line: 2675

		WriteToLog('Match profile is No and you chose not to update existing configurations. No configurations will be updated.');
Line: 2682

	select nvl(msi.config_orgs, '1')
	into l_attribute
	from mtl_system_items msi
	where msi.inventory_item_id =
		(select msi2.base_item_id
		from mtl_system_items msi2
		where msi2.inventory_item_id = p_config_id
		and rownum = 1)
	and rownum = 1;
Line: 2701

			-- select all open order lines having this config item
			-- populate into bcol_upg
			-- mark as UPG
			--
			WriteToLog('sql 1', 3);
Line: 2707

			insert into bom_cto_order_lines_upg
			(
			 ATO_LINE_ID
			, BATCH_ID
			, BOM_ITEM_TYPE
			, COMPONENT_CODE
			, COMPONENT_SEQUENCE_ID
			, CONFIG_ITEM_ID
			, INVENTORY_ITEM_ID
			, ITEM_TYPE_CODE
			, LINE_ID
			, LINK_TO_LINE_ID
			, ORDERED_QUANTITY
			, ORDER_QUANTITY_UOM
			, PARENT_ATO_LINE_ID
			, PERFORM_MATCH
			, PLAN_LEVEL
			, SCHEDULE_SHIP_DATE
			, SHIP_FROM_ORG_ID
			, TOP_MODEL_LINE_ID
			, WIP_SUPPLY_TYPE
			, HEADER_ID
			, LAST_UPDATE_DATE
			, LAST_UPDATED_BY
			, CREATION_DATE
			, CREATED_BY
			, LAST_UPDATE_LOGIN
			, REQUEST_ID
			, PROGRAM_APPLICATION_ID
			, PROGRAM_ID
			, PROGRAM_UPDATE_DATE
			, OPTION_SPECIFIC
			, REUSE_CONFIG
			, QTY_PER_PARENT_MODEL
			, STATUS
			--, SEQUENCE
			, CONFIG_CREATION
			)
			select distinct
			bcol2.ATO_LINE_ID
			, bcol2.BATCH_ID
			, bcol2.BOM_ITEM_TYPE
			, bcol2.COMPONENT_CODE
			, bcol2.COMPONENT_SEQUENCE_ID
			, bcol2.CONFIG_ITEM_ID
			, bcol2.INVENTORY_ITEM_ID
			, bcol2.ITEM_TYPE_CODE
			, bcol2.LINE_ID
			, bcol2.LINK_TO_LINE_ID
			, bcol2.ORDERED_QUANTITY
			, bcol2.ORDER_QUANTITY_UOM
			, bcol2.PARENT_ATO_LINE_ID
			, decode(bcol2.perform_match, 'C', 'Y', bcol2.perform_match)  -- Bugfix 8894392
			--, bcol2.perform_match  -- Sushant Changed as part of bug 3472654  'N'
			, bcol2.PLAN_LEVEL
			, bcol2.SCHEDULE_SHIP_DATE
			, bcol2.SHIP_FROM_ORG_ID
			, bcol2.TOP_MODEL_LINE_ID
			, bcol2.WIP_SUPPLY_TYPE
			, bcol2.HEADER_ID
			, sysdate	--LAST_UPDATE_DATE
			, bcol2.LAST_UPDATED_BY
			, sysdate	--CREATION_DATE
			, bcol2.CREATED_BY
			, bcol2.LAST_UPDATE_LOGIN
			, bcol2.REQUEST_ID
			, bcol2.PROGRAM_APPLICATION_ID
			, bcol2.PROGRAM_ID
			, sysdate	--PROGRAM_UPDATE_DATE
			, bcol2.OPTION_SPECIFIC
			, 'N'	--bcol2.REUSE_CONFIG
			, bcol2.QTY_PER_PARENT_MODEL
			, 'UPG'		--STATUS
			--, bcol2.SEQUENCE
			, nvl(msi.config_orgs, '1')
			from bom_cto_order_lines bcol1
			, bom_cto_order_lines bcol2
			, oe_order_lines_all oel
			, mtl_system_items msi
			, oe_order_lines_all oel2 --bugfix 3371155
			-- select entire configuration
			where bcol2.ato_line_id = bcol1.ato_line_id
			-- to get item attribute
			and msi.inventory_item_id = bcol2.inventory_item_id
			and msi.organization_id = bcol2.ship_from_org_id
			-- for this config
			and bcol1.config_item_id = p_config_id
			-- and are on open order lines
			and bcol1.line_id = oel.line_id
			and oel.open_flag = 'Y' -- bug 13362916 removed nvl
			--bugfix  3371155
			 and bcol1.ato_line_id = oel2.ato_line_id
                        and oel2.item_type_code = 'CONFIG'
			--end 3371155
			;
Line: 2803

			WriteToLog('Rows inserted::'|| to_char(sql%rowcount), 3);
Line: 2808

			-- select all open order lines having this canned config item, only if it has attribute = 3
			-- populate into bcol_upg
			-- mark as UPG
			--
			IF (l_attribute = 3) THEN
			WriteToLog('sql 2', 3);
Line: 2815

			insert into bom_cto_order_lines_upg
			(
			 ATO_LINE_ID
			, BATCH_ID
			, BOM_ITEM_TYPE
			, COMPONENT_CODE
			, COMPONENT_SEQUENCE_ID
			, CONFIG_ITEM_ID
			, INVENTORY_ITEM_ID
			, ITEM_TYPE_CODE
			, LINE_ID
			, LINK_TO_LINE_ID
			, ORDERED_QUANTITY
			, ORDER_QUANTITY_UOM
			, PARENT_ATO_LINE_ID
			, PERFORM_MATCH
			, PLAN_LEVEL
			, SCHEDULE_SHIP_DATE
			, SHIP_FROM_ORG_ID
			, TOP_MODEL_LINE_ID
			, WIP_SUPPLY_TYPE
			, HEADER_ID
			, LAST_UPDATE_DATE
			, LAST_UPDATED_BY
			, CREATION_DATE
			, CREATED_BY
			, LAST_UPDATE_LOGIN
			, REQUEST_ID
			, PROGRAM_APPLICATION_ID
			, PROGRAM_ID
			, PROGRAM_UPDATE_DATE
			, OPTION_SPECIFIC
			, REUSE_CONFIG
			, QTY_PER_PARENT_MODEL
			, STATUS
			--, SEQUENCE
			, CONFIG_CREATION
			)
			select distinct
			bcol2.ATO_LINE_ID
			, bcol2.BATCH_ID
			, bcol2.BOM_ITEM_TYPE
			, bcol2.COMPONENT_CODE
			, bcol2.COMPONENT_SEQUENCE_ID
			, bcol2.CONFIG_ITEM_ID
			, bcol2.INVENTORY_ITEM_ID
			, bcol2.ITEM_TYPE_CODE
			, bcol2.LINE_ID
			, bcol2.LINK_TO_LINE_ID
			, bcol2.ORDERED_QUANTITY
			, bcol2.ORDER_QUANTITY_UOM
			, bcol2.PARENT_ATO_LINE_ID
                        , decode(bcol2.perform_match, 'C', 'Y', bcol2.perform_match)  -- Bugfix 8894392
			--, bcol2.PERFORM_MATCH                   --7201878
			--, 'Y'	--bcol2.PERFORM_MATCH /* Sushant made change to identify matched items */
			, bcol2.PLAN_LEVEL
			, bcol2.SCHEDULE_SHIP_DATE
			, bcol2.SHIP_FROM_ORG_ID
			, bcol2.TOP_MODEL_LINE_ID
			, bcol2.WIP_SUPPLY_TYPE
			, bcol2.HEADER_ID
			, sysdate	--LAST_UPDATE_DATE
			, bcol2.LAST_UPDATED_BY
			, sysdate	--CREATION_DATE
			, bcol2.CREATED_BY
			, bcol2.LAST_UPDATE_LOGIN
			, bcol2.REQUEST_ID
			, bcol2.PROGRAM_APPLICATION_ID
			, bcol2.PROGRAM_ID
			, sysdate	--PROGRAM_UPDATE_DATE
			, bcol2.OPTION_SPECIFIC
			, 'N'	--bcol2.REUSE_CONFIG
			, bcol2.QTY_PER_PARENT_MODEL
			, 'UPG'		--STATUS
			--, bcol2.SEQUENCE
			, nvl(msi.config_orgs, '1')
			from bom_cto_order_lines bcol1
			, bom_cto_order_lines bcol2
			, bom_ato_configurations bac
			, oe_order_lines_all oel
			, mtl_system_items msi
			where bac.config_item_id = p_config_id
			-- and exists in bcol
			and bac.config_item_id = bcol1.config_item_id
			-- on open order lines
			and bcol1.line_id = oel.line_id
			and oel.open_flag = 'Y' -- bug 13362916. removed nvl
			and bcol2.ato_line_id = bcol1.ato_line_id
			-- to get item attribute
			and msi.inventory_item_id = bcol2.inventory_item_id
			and msi.organization_id = bcol2.ship_from_org_id;
Line: 2907

			WriteToLog('Rows inserted::'|| to_char(sql%rowcount), 3);
Line: 2914

			-- select this config item on closed order lines, only if attribute = 3 and not already in bcol_upg
			-- populate into bcol_upg
			-- mark as UPG
			--
			-- commenting as part of Bugfix 8894392
			/*IF (l_attribute = 3) THEN
				WriteToLog('sql 3', 3);
Line: 2922

				insert into bom_cto_order_lines_upg
				(
				 ATO_LINE_ID
				, BATCH_ID
				, BOM_ITEM_TYPE
				, COMPONENT_CODE
				, COMPONENT_SEQUENCE_ID
				, CONFIG_ITEM_ID
				, INVENTORY_ITEM_ID
				, ITEM_TYPE_CODE
				, LINE_ID
				, LINK_TO_LINE_ID
				, ORDERED_QUANTITY
				, ORDER_QUANTITY_UOM
				, PARENT_ATO_LINE_ID
				, PERFORM_MATCH
				, PLAN_LEVEL
				, SCHEDULE_SHIP_DATE
				, SHIP_FROM_ORG_ID
				, TOP_MODEL_LINE_ID
				, WIP_SUPPLY_TYPE
				, HEADER_ID
				, LAST_UPDATE_DATE
				, LAST_UPDATED_BY
				, CREATION_DATE
				, CREATED_BY
				, LAST_UPDATE_LOGIN
				, REQUEST_ID
				, PROGRAM_APPLICATION_ID
				, PROGRAM_ID
				, PROGRAM_UPDATE_DATE
				, OPTION_SPECIFIC
				, REUSE_CONFIG
				, QTY_PER_PARENT_MODEL
				, STATUS
				, CONFIG_CREATION
				)
				select distinct
				bcol.ATO_LINE_ID
				, bcol.BATCH_ID
				, bcol.BOM_ITEM_TYPE
				, bcol.COMPONENT_CODE
				, bcol.COMPONENT_SEQUENCE_ID
				, bcol.CONFIG_ITEM_ID
				, bcol.INVENTORY_ITEM_ID
				, bcol.ITEM_TYPE_CODE
				, bcol.LINE_ID
				, bcol.LINK_TO_LINE_ID
				, bcol.ORDERED_QUANTITY
				, bcol.ORDER_QUANTITY_UOM
				, bcol.PARENT_ATO_LINE_ID
                                , bcol.PERFORM_MATCH                    --7201878
				--, 'Y'	--bcol.PERFORM_MATCH  /* Sushant made changes to identify matched items */
				/*, bcol.PLAN_LEVEL
				, bcol.SCHEDULE_SHIP_DATE
				, bcol.SHIP_FROM_ORG_ID
				, bcol.TOP_MODEL_LINE_ID
				, bcol.WIP_SUPPLY_TYPE
				, bcol.HEADER_ID
				, sysdate	--LAST_UPDATE_DATE
				, bcol.LAST_UPDATED_BY
				, sysdate	--CREATION_DATE
				, bcol.CREATED_BY
				, bcol.LAST_UPDATE_LOGIN
				, bcol.REQUEST_ID
				, bcol.PROGRAM_APPLICATION_ID
				, 99		-- matched item on closed line
				, bcol.PROGRAM_UPDATE_DATE
				, bcol.OPTION_SPECIFIC
				, 'N'	--bcol.REUSE_CONFIG
				, bcol.QTY_PER_PARENT_MODEL
				, 'UPG'		--STATUS
				, nvl(msi.config_orgs, '1')
				from bom_ato_configurations bac
				, bom_cto_order_lines bcol
				, mtl_system_items msi
				where bac.config_item_id = p_config_id
				and NOT EXISTS
					(select 'exists'
					from bom_cto_order_lines_upg bcolu
					where bcolu.config_item_id = bac.config_item_id)
				-- select first ato_line_id in bcol
				and bcol.ato_line_id =
					(select bcol1.ato_line_id
					from bom_cto_order_lines bcol1
					where bcol1.config_item_id = bac.config_item_id
					-- pick up only if config is at top level
					and bcol1.line_id = bcol1.ato_line_id
					and rownum = 1)
				-- to get item attribute
				and msi.inventory_item_id = bcol.inventory_item_id
				and msi.organization_id = bcol.ship_from_org_id;
Line: 3015

				WriteToLog('Rows inserted::'|| to_char(sql%rowcount), 3);
Line: 3035

			select 'Y'
			into l_exists
			from bom_cto_order_lines_upg
			where config_item_id = p_config_id
			and rownum = 1;
Line: 3102

select
bom_cto_order_lines_s1.nextval,		-- line_id
substr(bac.component_code, (instr(bac.component_code, '-', -1)+1)),	-- inventory_item_id
bac.component_item_id,			-- header_id::storing comp_item_id here for intermediate processing
bac.component_code,			-- component_code
msi.bom_item_type,			-- bom_item_type
msi.primary_uom_code,			-- order_quantity_uom
bac.component_quantity,			-- ordered_quantity
bac.component_quantity,			-- per_quantity
sysdate,				-- schedule_ship_date
'N' , -- option_specific BUGFIX 3602292 defaulted this value to N as model will not have option_specific_sourced flag.
nvl(msi.config_orgs, '1'),		-- config_orgs
sysdate,				-- creation_date
nvl(Fnd_Global.USER_ID, -1),		-- created_by
sysdate,				-- last_update_date
nvl(Fnd_Global.USER_ID, -1),		-- last_updated_by
cto_update_configs_pk.bac_program_id,	-- program_id
'Y',					-- perform_match  /* Sushant made changes to identify matched items */
'N',					-- reuse_config
bac.organization_id
from bom_ato_configurations bac,
mtl_system_items msi
where bac.config_item_id = p_config_id
-- and bac.component_item_id <> bac.base_model_id -- not pick up top model
and msi.inventory_item_id = substr(bac.component_code, (instr(bac.component_code, '-', -1)+1))	-- bac.component_item_id
and msi.organization_id = bac.organization_id;
Line: 3152

	select base_model_id
	into l_base_model_id
	from bom_ato_configurations
	where config_item_id = p_config_id
	and rownum = 1;
Line: 3190

		t_bcol(l_index).last_update_date,
		t_bcol(l_index).last_updated_by,
		t_bcol(l_index).program_id,
		t_bcol(l_index).perform_match,
		t_bcol(l_index).reuse_config,
                t_bcol(l_index).ship_from_org_id;
Line: 3251

           select bom_cto_order_lines_s1.nextval
           into l_header_id
           from dual;
Line: 3340

                      INSERT INTO bom_cto_order_lines_upg(
                           HEADER_ID ,
                           LINE_ID ,
                           LINK_TO_LINE_ID ,
                           ATO_LINE_ID ,
                           PARENT_ATO_LINE_ID ,
                           TOP_MODEL_LINE_ID ,
                           PLAN_LEVEL ,
                           WIP_SUPPLY_TYPE ,
                           PERFORM_MATCH ,
                           BOM_ITEM_TYPE ,
                           COMPONENT_CODE ,
                           COMPONENT_SEQUENCE_ID ,
                           CONFIG_ITEM_ID ,
                           INVENTORY_ITEM_ID ,
                           ITEM_TYPE_CODE ,
                           BATCH_ID ,
                           ORDERED_QUANTITY ,
                           ORDER_QUANTITY_UOM ,
                           SCHEDULE_SHIP_DATE ,
                           SHIP_FROM_ORG_ID ,
                           LAST_UPDATE_DATE ,
                           LAST_UPDATED_BY ,
                           CREATION_DATE ,
                           CREATED_BY ,
                           LAST_UPDATE_LOGIN ,
                           REQUEST_ID ,
                           PROGRAM_APPLICATION_ID ,
                           PROGRAM_ID ,
                           PROGRAM_UPDATE_DATE ,
                           QTY_PER_PARENT_MODEL,
                           OPTION_SPECIFIC,
                           REUSE_CONFIG,
                           STATUS,
                           SEQUENCE,
                           CONFIG_CREATION
                           )
                      VALUES (
                           t_bcol(i).header_id,
                           t_bcol(i).line_id,
                           t_bcol(i).link_to_line_id,
                           t_bcol(i).ato_line_id,
                           t_bcol(i).parent_ato_line_id,
                           t_bcol(i).top_model_line_id,
                           t_bcol(i).plan_level,
                           t_bcol(i).wip_supply_type,
                           'Y',       -- perform_match BUGFIX 3567693
                           t_bcol(i).bom_item_type,
                           t_bcol(i).component_code,
                           t_bcol(i).component_sequence_id,
                           t_bcol(i).config_item_id,
                           t_bcol(i).inventory_item_id,
                           decode(t_bcol(i).line_id, t_bcol(i).ato_line_id, 'MODEL', decode(t_bcol(i).bom_item_type, '4', 'OPTION', 'CLASS')),
                           null,      -- batch_id
                           t_bcol(i).ordered_quantity,
                           t_bcol(i).order_quantity_uom,
                           t_bcol(i).schedule_ship_date,
                           t_bcol(i).ship_from_org_id,
                           t_bcol(i).last_update_date,
                           t_bcol(i).last_updated_by,
                           t_bcol(i).creation_date,
                           t_bcol(i).created_by,
                           t_bcol(i).last_update_login,
                           null,      -- request_id
                           null,      -- program_application_id
                           t_bcol(i).program_id,
                           null,      -- program_update_date
                           t_bcol(i).qty_per_parent_model,
                           t_bcol(i).option_specific,
                           'N',
                           'UPG',
                           null,
                           t_bcol(i).config_creation
                           );
Line: 3415

              WriteToLog('populate_bcolu_from_bac: Inserted ' || t_bcol(i).line_id);
Line: 3426

            select 'Y'
            into l_exists
            from bom_cto_order_lines_upg
            where config_item_id = p_config_id
            and rownum = 1;
Line: 3440

                    WriteToLog('populate_bcolu_from_bac: inserting in bcolu in status ERROR');
Line: 3442

                    INSERT INTO bom_cto_order_lines_upg(
                          HEADER_ID ,
                          LINE_ID ,
                          ATO_LINE_ID ,
                          PARENT_ATO_LINE_ID ,
                          TOP_MODEL_LINE_ID ,
                          PERFORM_MATCH ,
                          BOM_ITEM_TYPE ,
                          COMPONENT_CODE ,
                          CONFIG_ITEM_ID ,
                          INVENTORY_ITEM_ID ,
                          ITEM_TYPE_CODE ,
                          BATCH_ID ,
                          ORDERED_QUANTITY ,
                          ORDER_QUANTITY_UOM ,
                          SCHEDULE_SHIP_DATE ,
                          SHIP_FROM_ORG_ID ,
                          LAST_UPDATE_DATE ,
                          LAST_UPDATED_BY ,
                          CREATION_DATE ,
                          CREATED_BY ,
                          LAST_UPDATE_LOGIN ,
                          REQUEST_ID ,
                          PROGRAM_APPLICATION_ID ,
                          PROGRAM_ID ,
                          PROGRAM_UPDATE_DATE ,
                          QTY_PER_PARENT_MODEL,
                          OPTION_SPECIFIC,
                          REUSE_CONFIG,
                          STATUS,
                          SEQUENCE,
                          CONFIG_CREATION
                    )
                    VALUES (
                          t_bcol(i).header_id,
                          t_bcol(i).line_id,
                          l_top_model_line_id,
                          l_top_model_line_id,
                          l_top_model_line_id,
                          'Y',  -- perform_match
                          t_bcol(i).bom_item_type,
                          t_bcol(i).component_code,
                          t_bcol(i).config_item_id,
                          t_bcol(i).inventory_item_id,
                          decode(t_bcol(i).line_id, l_top_model_line_id, 'MODEL', decode(t_bcol(i).bom_item_type, '4', 'OPTION', 'CLASS')),
                          null, -- batch_id
                          t_bcol(i).ordered_quantity,
                          t_bcol(i).order_quantity_uom,
                          t_bcol(i).schedule_ship_date,
                          t_bcol(i).ship_from_org_id,
                          t_bcol(i).last_update_date,
                          t_bcol(i).last_updated_by,
                          t_bcol(i).creation_date,
                          t_bcol(i).created_by,
                          t_bcol(i).last_update_login,
                          null, -- request_id
                          null, -- program_application_id
                          t_bcol(i).program_id,
                          null, -- program_update_date
                          t_bcol(i).qty_per_parent_model,
                          t_bcol(i).option_specific,
                          'N',
                          'ERROR',
                          null,
                          t_bcol(i).config_creation
                    );
Line: 3547

select
bom_cto_order_lines_s1.nextval,		-- line_id
substr(bac.component_code, (instr(bac.component_code, '-', -1)+1)),	-- inventory_item_id
bac.component_item_id,			-- header_id::storing comp_item_id here for intermediate processing
substr(bac.component_code, (instr(bac.component_code, '-', 1)+1)),	-- component_code
--bac.config_item_id,			-- config_item_id
msi.bom_item_type,			-- bom_item_type
msi.primary_uom_code,			-- order_quantity_uom
bac.component_quantity,			-- ordered_quantity
bac.component_quantity,			-- per_quantity
sysdate,				-- schedule_ship_date
nvl(to_char(msi.option_specific_sourced),'N'),		-- option_specific --bugfix3845686
nvl(msi.config_orgs, '1'),		-- config_orgs
sysdate,				-- creation_date
nvl(Fnd_Global.USER_ID, -1),		-- created_by
sysdate,				-- last_update_date
nvl(Fnd_Global.USER_ID, -1),		-- last_updated_by
cto_update_configs_pk.bac_program_id,	-- program_id
bac.organization_id                     --Bugfix 10240482
from bom_ato_configurations bac,
mtl_system_items msi
where bac.config_item_id = l_curr_config_id
and bac.component_item_id <> bac.base_model_id --not pick up top model
and msi.inventory_item_id = bac.component_item_id
and msi.organization_id = bac.organization_id;
Line: 3603

	select nvl(msi.config_orgs, '1'), inventory_item_id
	into l_item_attr, l_child_model_id
	from mtl_system_items msi
	where msi.inventory_item_id = (select base_item_id --bugfix3845686
	                               from mtl_system_items
				       where inventory_item_id = t_bcol(l_parent_index).header_id
				       and rownum =1)
	--and msi.organization_id = t_bcol(l_parent_index).ship_from_org_id;
Line: 3620

		select substrb(concatenated_segments,1,50) name
		into l_child_model_name
		from mtl_system_items_kfv msi
		where msi.inventory_item_id = l_child_model_id
		and rownum=1;/* Fixed bug 3529482 */
Line: 3661

				t_bcol(l_index).last_update_date,
				t_bcol(l_index).last_updated_by,
				t_bcol(l_index).program_id,
				t_bcol(l_index).ship_from_org_id;  --Bugfix 10240482;
Line: 3802

			v_raw_line_id.delete;
Line: 3842

                                select
				bic.wip_supply_type,
				bic.component_sequence_id
				into p_t_bcol(v_item).wip_supply_type,
				p_t_bcol(v_item).component_sequence_id
				from bom_bill_of_materials bbom,
				bom_inventory_components bic
				where bbom.bill_sequence_id =
					(select common_bill_sequence_id
					from bom_bill_of_materials
					where assembly_item_id = p_t_bcol(v_parent_item).inventory_item_id
					and alternate_bom_designator is null
					and rownum = 1)
				and bbom.common_bill_sequence_id = bic.bill_sequence_id
				and bic.component_item_id = p_t_bcol(v_item).inventory_item_id
				and rownum = 1;
Line: 3927

			v_raw_line_id.delete;
Line: 3956

	p_t_bcol.delete;
Line: 3992

select distinct substrb(concatenated_segments,1,50) name,msi.inventory_item_id
item_id
from bom_cto_order_lines_upg bcolu,
mtl_system_items_kfv msi
where bcolu.config_item_id is not null
and bcolu.config_item_id = msi.inventory_item_id
and bcolu.ship_from_org_id = msi.organization_id
and ((bcolu.config_creation = '3'
	and exists (select 'exists'
		from bom_cto_order_lines_upg bcolu1
		where bcolu1.config_item_id = bcolu.config_item_id
		and bcolu1.status = 'MRP_SRC'
		and rownum = 1))
or (bcolu.config_creation <> '3'
	and not exists (select 'exists'
		from bom_cto_order_lines_upg bcolu1
		where bcolu1.config_item_id = bcolu.config_item_id
		and bcolu1.status <> 'MRP_SRC')))
order by 1;  -- Modified by Renga for bug 3930047
Line: 4017

select distinct substrb(concatenated_segments,1,50) name,
                 msi.inventory_item_id item_id
from bom_cto_order_lines_upg bcolu,
mtl_system_items_kfv msi
where bcolu.config_item_id is not null
and bcolu.config_item_id = msi.inventory_item_id
and bcolu.ship_from_org_id = msi.organization_id
and not exists (select 'exists'
		from bom_cto_order_lines_upg bcolu1
		where bcolu1.config_item_id = bcolu.config_item_id
		and bcolu1.status = 'MRP_SRC')
order by 1;  -- Modified by Renga for bug 3930047
Line: 4036

select distinct substrb(concatenated_segments,1,50) name,
        msi.inventory_item_id item_id,
	oeh.order_number,
	decode(bcolu.status, 'MRP_SRC', 'was successfully processed', 'errored out') status
from bom_cto_order_lines_upg bcolu,
mtl_system_items_kfv msi,
oe_order_lines_all oel,
oe_order_headers_all oeh
where bcolu.config_item_id is not null
and bcolu.config_item_id = msi.inventory_item_id
and bcolu.ship_from_org_id = msi.organization_id
and config_creation <> '3'
and exists (select 'exists'
	from bom_cto_order_lines_upg bcolu1
	where bcolu1.config_item_id = bcolu.config_item_id
	and bcolu1.status = 'MRP_SRC')
and exists (select 'exists'
	from bom_cto_order_lines_upg bcolu1
	where bcolu1.config_item_id = bcolu.config_item_id
	and bcolu1.status <> 'MRP_SRC')
and oel.line_id = bcolu.ato_line_id
and oel.header_id = oeh.header_id
order by name, status;
Line: 4130

SELECT bom_item_type,
       wip_supply_type,
       config_creation,
       config_item_id,
       inventory_item_id,
       parent_ato_line_id,
       ato_line_id,
       line_id,
       ship_from_org_id
FROM   bom_cto_order_lines_upg
WHERE ato_line_id in ( SELECT DISTINCT bupg1.ato_line_id
                       FROM  bom_cto_order_lines_upg bupg1
		       WHERE bupg1.config_creation = 3);
Line: 4257

  UPDATE bom_cto_order_lines_upg
  SET status  = 'ERROR'
  WHERE ato_line_id = t_ato_line_id(j);
Line: 4262

  oe_debug_pub.add('Updated '||sql%rowcount||'lines with error status',1);
Line: 4270

	WriteToLog('ERROR: Unexp error in CTO_Update_Configs_Pk.Check_invalid_configurations:: '|| l_stmt_num ||'::'||sqlerrm, 1);
Line: 4272

	WriteToLog('Update Existing Configurations completed with ERROR');
Line: 4283

Procedure update_atp_attributes(
                          p_item          IN  Number,
                          p_cat_id        IN  Number,
                          p_config_id     IN  Number,
                          x_return_status OUT NOCOPY varchar2,
                          x_msg_data      OUT NOCOPY Varchar2,
                          x_msg_count     OUT NOCOPY Number) is
Begin
   WriteToLog('   Entering Update_atp_attributes procedure');
Line: 4296

      update mtl_system_items_b msic
      set    (atp_components_flag,atp_flag) = (select CTO_CONFIG_ITEM_PK.evaluate_atp_attributes(nvl(msim.atp_flag,'N'),nvl(msim.atp_components_flag,'N')),CTO_CONFIG_ITEM_PK.get_atp_flag
                                         from   mtl_system_items_b msim
                                         where  msim.inventory_item_id = msic.base_item_id
				          and    msim.organization_id   = msic.organization_id)

      where msic.base_item_id is not null
      and   'x'= (select 'x'
              from mtl_system_items_b msim1
              where msim1.inventory_item_id = msic.base_item_id
              and   msim1.organization_id   = msic.organization_id);
Line: 4310

      WriteToLog(' Number of records updated = '||sql%rowcount);
Line: 4314

      update mtl_system_items_b msic
      set    (atp_components_flag,atp_flag) = (select CTO_CONFIG_ITEM_PK.evaluate_atp_attributes(nvl(msim.atp_flag,'N'),nvl(msim.atp_components_flag,'N')),CTO_CONFIG_ITEM_PK.get_atp_flag
                                        from   mtl_system_items_b msim
                                        where  msim.inventory_item_id = msic.base_item_id
				        and    msim.organization_id   = msic.organization_id)
      where msic.inventory_item_id in (select msi.inventory_item_id
                                       from mtl_system_items_b msi,
				            mtl_item_categories mcat
				       where msi.base_item_id = mcat.inventory_item_id
				       and   mcat.category_id = p_cat_id)
     and exists (select 'x' from mtl_system_items_b msim
                 where  msim.inventory_item_id = msic.base_item_id
                 and    msim.organization_id   = msic.organization_id);
Line: 4328

      WriteToLog(' Number of records updated = '||sql%rowcount);
Line: 4332

     update mtl_system_items_b msic
     set    (atp_components_flag,atp_flag)  = (select CTO_CONFIG_ITEM_PK.evaluate_atp_attributes(msim.atp_flag,msim.atp_components_flag),CTO_CONFIG_ITEM_PK.get_atp_flag
                                        from   mtl_system_items_b msim
                                        where  msim.inventory_item_id = msic.base_item_id
				        and    msim.organization_id   = msic.organization_id)
     where  msic.inventory_item_id = p_config_id
     and    exists (select 'x' from mtl_system_items_b msim
                    where  msim.inventory_item_id = msic.base_item_id
                    and    msim.organization_id   = msic.organization_id);
Line: 4341

      WriteToLog(' Number of records updated = '||sql%rowcount);
Line: 4344

End Update_atp_attributes;