Oracle Conversion Process With Example
Oracle Conversion Process With Example
Step2: Create the Sequence and Trigger for above staging table to insert the sequence and status as N
CREATE SEQUENCE apps.xxcust_items_conv_s
START WITH 1
INCREMENT BY 1;
BEFORE INSERT
ON apps.xxcust_items_conv_stg
FOR EACH ROW
BEGIN
IF :NEW.transaction_id_stg IS NULL
THEN
SELECT xxcust_items_conv_s.NEXTVAL,'N',
SYSDATE
INTO :NEW.transaction_id_stg, :NEW.status_stg,
:NEW.creation_date
FROM DUAL;
END IF;
END;
Step3: Create the control file with extension as “.ctl” to load the data into staging table
OPTIONS (SKIP=1)
LOAD DATA
Infile 'Items.csv'
Truncate
into table xxcust_items_conv_stg fields terminated by "," optionally enclosed by '"'
TRAILING NULLCOLS
(
LS_ITEM_NUMBER "ltrim(rtrim(:LS_ITEM_NUMBER))"
,LS_DESCRIPTION "ltrim(rtrim(:LS_DESCRIPTION))"
,LS_ORGANIZATION_CODE "ltrim(rtrim(:LS_ORGANIZATION_CODE))"
,LS_PR_UNIT_OF_MEASURE "ltrim(rtrim(:LS_PR_UNIT_OF_MEASURE))"
,LS_TEMPLATE_NAME "ltrim(rtrim(:LS_TEMPLATE_NAME))"
,LS_COS_ACCOUNT "ltrim(rtrim(:LS_COS_ACCOUNT))"
,LS_EXPENSE_ACCOUNT "ltrim(rtrim(:LS_EXPENSE_ACCOUNT))"
,LS_SALES_ACCOUNT "ltrim(rtrim(:LS_SALES_ACCOUNT))"
)
Step4: Upload the Control file and data file into server $XXCUST_TOP/bin location (/u02/E-
BIZ/apps/apps_st/appl/XXCUST/12.0.0/bin)
Step5: Execute the below command to load the data into staging table
sqlldr control=XXCUST_ITEMS_CONV.ctl
Enter the DB user name and Password : apps/apps
Oracle Conversion Process With Example OracleApps88
Step6: Verify the staging table data is inserted or not (Make sure to insert the all record in data file if any records are not
inserted verify and insert again)
Step7: Create the Specification and package body with all the validations
CREATE OR REPLACE PACKAGE xxcust_items_conv_pkg
AS
/*
*************************************************************************
** Business Object: ITEMS,
** File Name: xxcust_items_conv_PKG.PKS
** File Type: PACKAGE SPECIFICATION
** Purpose: CONVERT LEGACY ITEMS DATA INTO ORACLE
*************************************************************************
*/
PROCEDURE MAP;
PROCEDURE VALIDATE;
PROCEDURE LOAD;
END xxcust_items_conv_pkg;
/
fnd_file.put_line (fnd_file.LOG,'+-----------------------------------------------------------+');
fnd_file.put_line (fnd_file.LOG, 'Starting VALIDATE Procedure ');
VALIDATE;
fnd_file.put_line (fnd_file.LOG,'+-----------------------------------------------------------+');
fnd_file.put_line (fnd_file.LOG, 'Starting LOAD Procedure ');
LOAD;
END;
/*
*************************************************************************
Oracle Conversion Process With Example OracleApps88
/*
**------------------------------------------------------------------------
** Procedure Name: MAP
** Purpose :Procedure to map the staging table fields.
**------------------------------------------------------------------------
*/
PROCEDURE MAP
IS
BEGIN
/*==========================================================================
=================
Default Organization Code to V1
============================================================================
==============*/
UPDATE xxcust_items_conv_stg
SET ls_organization_code = 'V1';
COMMIT;
/*==========================================================================
=================
Update Status of the Duplicate Records (Records given in data file and already present in Oracle)
============================================================================
==============*/
UPDATE xxcust_items_conv_stg a
SET status_stg = 'ME',
ERROR_CODE =
ERROR_CODE
|| 'Duplicate Combination of Item and Organization;'
WHERE ls_item_number IN
(SELECT segment1
FROM mtl_system_items_b m
WHERE m.segment1 = a.ls_item_number
AND m.organization_id IN
(SELECT organization_id
FROM mtl_parameters p
WHERE p.organization_code IN ('V1')));
COMMIT;
/*==========================================================================
=================
Default Cost of Sales Account
============================================================================
==============*/
Oracle Conversion Process With Example OracleApps88
UPDATE xxcust_items_conv_stg
SET ls_cos_account = '01-600-5110-0000-000';
COMMIT;
/*==========================================================================
=================
Default Expense Account
============================================================================
==============*/
UPDATE xxcust_items_conv_stg
SET ls_expense_account = '01-000-2440-0000-000';
COMMIT;
/*==========================================================================
=================
Default Sales Account
============================================================================
==============*/
UPDATE xxcust_items_conv_stg
SET ls_sales_account = '01-110-9110-0000-000';
COMMIT;
/*==========================================================================
=================
Default Template Name to 'Finish Good' if it is NULL
============================================================================
==============*/
UPDATE xxcust_items_conv_stg
SET ls_template_name = 'Finished Good'
WHERE ls_template_name IS NULL;
COMMIT;
/*==========================================================================
=================
Default Primary Unit Of Measure
============================================================================
==============*/
UPDATE xxcust_items_conv_stg
SET ls_pr_unit_of_measure = 'Each'
WHERE ls_pr_unit_of_measure IS NULL;
COMMIT;
/*==========================================================================
=================
Oracle Conversion Process With Example OracleApps88
============================================================================
==============*/
UPDATE xxcust_items_conv_stg
SET status_stg = 'M'
WHERE status_stg = 'N';
COMMIT;
END MAP;
/*
**------------------------------------------------------------------------
** Procedure Name: VALIDATE
** Purpose :Procedure to validate the staging table fields.
**------------------------------------------------------------------------
*/
PROCEDURE VALIDATE
IS
l_organization_id NUMBER;
l_template_id NUMBER;
l_planner_code VARCHAR2 (50);
l_buyer_id NUMBER;
l_subinv_name VARCHAR2 (100);
l_sa_id NUMBER;
l_cogs_id NUMBER;
l_primary_uom mtl_units_of_measure.uom_code%TYPE;
l_buyer_name po_agents_name_v.full_name%TYPE;
l_buyer_id po_agents_name_v.buyer_id%TYPE;
l_planner_code mtl_planners.planner_code%TYPE;
l_cos_account_id NUMBER;
l_expense_account_id NUMBER;
l_sales_account_id NUMBER;
CURSOR cur_org_code
IS
SELECT DISTINCT ls_organization_code
FROM xxcust_items_conv_stg
WHERE ls_organization_code IS NOT NULL;
CURSOR cur_uom_code
IS
SELECT DISTINCT ls_pr_unit_of_measure FROM xxcust_items_conv_stg;
CURSOR cur_item_template
IS
SELECT DISTINCT ls_template_name
FROM xxcust_items_conv_stg
WHERE ls_template_name IS NOT NULL;
CURSOR cur_item_cos_account
IS
SELECT DISTINCT ls_cos_account
FROM xxcust_items_conv_stg
WHERE 1 = 1;
CURSOR cur_item_expense_account
IS
Oracle Conversion Process With Example OracleApps88
CURSOR cur_item_sales_account
IS
SELECT DISTINCT ls_sales_account
FROM xxcust_items_conv_stg
WHERE 1 = 1;
BEGIN
/*==========================================================================
=================
Validation for Organization if it is null
============================================================================
==============*/
BEGIN
UPDATE xxcust_items_conv_stg
SET status_stg = 'VE',
ERROR_CODE =
ERROR_CODE || 'Organization Code Cannot Be NULL;;'
WHERE ls_organization_code IS NULL;
EXCEPTION
WHEN OTHERS
THEN
UPDATE xxcust_items_conv_stg
SET status_stg = 'VE',
ERROR_CODE =
ERROR_CODE || 'Organization Code Cannot Be NULL;;'
WHERE ls_organization_code IS NULL;
END;
COMMIT;
/*==========================================================================
=================
Validation for Organization id
============================================================================
==============*/
FOR org_code_rec IN cur_org_code
LOOP
BEGIN
SELECT organization_id
INTO l_organization_id
FROM mtl_parameters
WHERE organization_code = org_code_rec.ls_organization_code;
UPDATE xxcust_items_conv_stg
SET organization_id = l_organization_id
WHERE ls_organization_code = org_code_rec.ls_organization_code;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
UPDATE xxcust_items_conv_stg
SET status_stg = 'VE',
Oracle Conversion Process With Example OracleApps88
ERROR_CODE =
ERROR_CODE
|| 'Organization Code does not exist in Oracle;;'
WHERE ls_organization_code =
org_code_rec.ls_organization_code;
WHEN OTHERS
THEN
UPDATE xxcust_items_conv_stg
SET status_stg = 'VE',
ERROR_CODE =
ERROR_CODE
|| 'Organization Code does not exist in Oracle;;'
WHERE ls_organization_code =
org_code_rec.ls_organization_code;
END;
END LOOP;
COMMIT;
/*==========================================================================
=================
Validation for Primary UOM Code
============================================================================
==============*/
FOR uom_code_rec IN cur_uom_code
LOOP
BEGIN
SELECT uom_code
INTO l_primary_uom
FROM mtl_units_of_measure
WHERE NVL (disable_date, SYSDATE + 1) > SYSDATE
AND unit_of_measure =
LTRIM (RTRIM (uom_code_rec.ls_pr_unit_of_measure));
UPDATE xxcust_items_conv_stg
SET pr_uom_code = l_primary_uom
WHERE ls_pr_unit_of_measure = uom_code_rec.ls_pr_unit_of_measure;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
UPDATE xxcust_items_conv_stg
SET status_stg = 'VE',
ERROR_CODE = ERROR_CODE || 'Invalid Primary UOM Code;;'
WHERE ls_pr_unit_of_measure =
uom_code_rec.ls_pr_unit_of_measure;
WHEN OTHERS
THEN
UPDATE xxcust_items_conv_stg
SET status_stg = 'VE',
ERROR_CODE = ERROR_CODE || 'Invalid Primary UOM Code;;'
WHERE ls_pr_unit_of_measure =
uom_code_rec.ls_pr_unit_of_measure;
END;
END LOOP;
Oracle Conversion Process With Example OracleApps88
COMMIT;
/*==========================================================================
=================
Validation for Template id
============================================================================
==============*/
FOR item_template_rec IN cur_item_template
LOOP
BEGIN
SELECT template_id
INTO l_template_id
FROM mtl_item_templates
WHERE template_name = item_template_rec.ls_template_name;
UPDATE xxcust_items_conv_stg
SET template_id = l_template_id
WHERE ls_template_name = item_template_rec.ls_template_name;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
UPDATE xxcust_items_conv_stg
SET status_stg = 'VE',
ERROR_CODE = ERROR_CODE || 'Invalid Template id;;'
WHERE ls_template_name = item_template_rec.ls_template_name;
WHEN OTHERS
THEN
UPDATE xxcust_items_conv_stg
SET status_stg = 'VE',
ERROR_CODE = ERROR_CODE || 'Invalid Template id;;'
WHERE ls_template_name = item_template_rec.ls_template_name;
END;
END LOOP;
COMMIT;
/*==========================================================================
=================
Validation for COS Account
============================================================================
==============*/
FOR item_cos_account_rec IN cur_item_cos_account
LOOP
IF item_cos_account_rec.ls_cos_account IS NOT NULL
THEN
BEGIN
SELECT code_combination_id
INTO l_cos_account_id
FROM gl_code_combinations_kfv
WHERE 1 = 1 AND chart_of_accounts_id = 101
AND concatenated_segments =
item_cos_account_rec.ls_cos_account
AND enabled_flag = 'Y';
Oracle Conversion Process With Example OracleApps88
UPDATE xxcust_items_conv_stg
SET cos_account_id = l_cos_account_id
WHERE ls_cos_account = item_cos_account_rec.ls_cos_account;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
UPDATE xxcust_items_conv_stg
SET status_stg = 'VE',
ERROR_CODE = ERROR_CODE || 'Invalid COS Account;;'
WHERE ls_cos_account = item_cos_account_rec.ls_cos_account;
WHEN OTHERS
THEN
UPDATE xxcust_items_conv_stg
SET status_stg = 'VE',
ERROR_CODE = ERROR_CODE || 'Invalid COS Account;;'
WHERE ls_cos_account = item_cos_account_rec.ls_cos_account;
END;
END IF;
END LOOP;
COMMIT;
/*==========================================================================
=================
Validation for Expense Account
============================================================================
==============*/
FOR item_expense_account_rec IN cur_item_expense_account
LOOP
IF item_expense_account_rec.ls_expense_account IS NOT NULL
THEN
BEGIN
SELECT code_combination_id
INTO l_expense_account_id
FROM gl_code_combinations_kfv
WHERE 1 = 1 AND chart_of_accounts_id = 101
AND concatenated_segments =
item_expense_account_rec.ls_expense_account
AND enabled_flag = 'Y';
UPDATE xxcust_items_conv_stg
SET expense_account_id = l_expense_account_id
WHERE ls_expense_account =
item_expense_account_rec.ls_expense_account;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
UPDATE xxcust_items_conv_stg
SET status_stg = 'VE',
ERROR_CODE =
ERROR_CODE || 'Invalid Expense Account;;'
WHERE ls_expense_account =
item_expense_account_rec.ls_expense_account;
WHEN OTHERS
THEN
Oracle Conversion Process With Example OracleApps88
UPDATE xxcust_items_conv_stg
SET status_stg = 'VE',
ERROR_CODE =
ERROR_CODE || 'Invalid Expense Account;;'
WHERE ls_expense_account =
item_expense_account_rec.ls_expense_account;
END;
END IF;
END LOOP;
COMMIT;
/*==========================================================================
=================
Validation for Sales Account
============================================================================
==============*/
FOR item_sales_account_rec IN cur_item_sales_account
LOOP
BEGIN
SELECT code_combination_id
INTO l_sales_account_id
FROM gl_code_combinations_kfv
WHERE enabled_flag = 'Y'
AND concatenated_segments =
item_sales_account_rec.ls_sales_account;
COMMIT;
UPDATE xxcust_items_conv_stg
SET status_stg = 'V'
WHERE status_stg = 'M';
COMMIT;
Oracle Conversion Process With Example OracleApps88
END VALIDATE;
/*
**------------------------------------------------------------------------
** Procedure Name: LOAD
** Purpose :Procedure to write the errored data into the errors table.
**------------------------------------------------------------------------
*/
PROCEDURE LOAD
IS
l_transaction_type VARCHAR2 (10) := 'CREATE';
l_process_flag NUMBER := 1;
l_user_id NUMBER;
l_creation_date DATE := SYSDATE;
l_last_update_date DATE := SYSDATE;
l_organization_id NUMBER;
CURSOR cur_items
IS
SELECT *
FROM xxcust_items_conv_stg
WHERE status_stg = 'V';
BEGIN
BEGIN
SELECT user_id
INTO l_user_id
FROM fnd_user
WHERE user_name = 'OPERATIONS';
EXCEPTION
WHEN NO_DATA_FOUND
THEN
l_user_id := 0;
END;
items_rec.organization_id,
items_rec.pr_uom_code,
items_rec.template_id,
items_rec.cos_account_id,
items_rec.expense_account_id,
items_rec.sales_account_id,
l_last_update_date,
l_user_id,
l_process_flag,
112,
--MOD (items_rec.transaction_id_stg, 5),
l_transaction_type,
items_rec.transaction_id_stg);
EXCEPTION
WHEN OTHERS
THEN
UPDATE xxcust_items_conv_stg
SET status_stg = 'LE'
WHERE status_stg = 'V'
AND transaction_id_stg = items_rec.transaction_id_stg;
COMMIT;
DBMS_OUTPUT.put_line (SQLERRM);
END;
END LOOP;
UPDATE xxcust_items_conv_stg
SET status_stg = 'L'
WHERE status_stg = 'V';
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
fnd_file.
put_line (fnd_file.LOG,
'Unexpected error occurred in load procedure ->');
END LOAD;
END xxcust_items_conv_pkg;
/
Query the request group : All Inclusive GUI and add the concurrent program
Field Value
Group All Inclusive GUI
Application Inventory
Program XXCUST Item Conversion Program
Step12: Goto the Inventory responsibility and run the submit the concurrent program to validate the data and insert into
interface table
Nav : Inventory, Vision Operations (USA) View Requests Submit New Request Single Request
Oracle Conversion Process With Example OracleApps88
Step 13: Once the program is completed then verify the staging table and interface table
Oracle Conversion Process With Example OracleApps88
Step14: Once data loaded into interface table submit item interface program insert the data into staging table
Nav : Inventory, Vision Operations (USA) Items Import Import Items
Step15: Once the program is completed check the base table and application to all the fields are populated or not
Oracle Conversion Process With Example OracleApps88