You are on page 1of 42

create or replace

PACKAGE BODY xx_per_positions_pkg IS
/****************************************************************************
*

Name:xx_per_positions_pkg
Description:This Package has all the procedures used for import of Positions
Author:TCS
Date:10/08/2007 4:54:25 PM
History
Modified By Date Description
T
*****************************************************************************/
/*======================================================================
Validating mandatory columns
=========================================================================*/
PROCEDURE xx_per_positions_prc(p_request_id IN NUMBER, p_commit IN VARCHAR2
) IS
l_org_id NUMBER;
l_grade_id NUMBER;
l_position_id NUMBER;
l_effective_start_date DATE;
l_effective_end_date DATE;
l_position_definition_id NUMBER;
l_object_version_number NUMBER;
l_security_profile_id NUMBER;
l_language_code VARCHAR2(30);
l_name VARCHAR2(240);
l_status VARCHAR2(100);
l_valid_grade_id NUMBER;
l_count NUMBER;
l_read NUMBER;
l_success NUMBER;
l_error NUMBER;
l_commit VARCHAR2(3);
l_pos_ins boolean;
l_grd_ins boolean;
l_poscount NUMBER;
l_job_date DATE;
l_organization_date DATE;
l_hr_org_count NUMBER;
l_pos_name varchar2(60);
l_org_name varchar2(60);
l_working_hours NUMBER;
l_probation_duration NUMBER;
l_probation_unit VARCHAR2(50);
--Cursor for fetching data from staging table
CURSOR cur_pos_val_stg IS
SELECT xxhr.*,
xxhr.rowid
FROM xx_hr_positions_stg xxhr

WHERE processing_status ='N';

BEGIN
fnd_file.PUT_LINE(fnd_file.LOG, 'Mandetory validations started');
fnd_file.PUT_LINE(fnd_file.LOG, 'ORG_ID :' || fnd_profile.VALUE('ORG_ID'))
;
l_org_id := fnd_profile.VALUE('ORG_ID');
l_count := 0;
l_security_profile_id := 62;
l_language_code := hr_api.userenv_lang;
l_status := 'VALID';
l_commit := p_commit;
l_read := 0;
l_success := 0;
l_error := 0;
FOR cur_pos_val_rec IN cur_pos_val_stg
LOOP
l_read := l_read + 1;
l_position_id := NULL;
l_effective_start_date := NULL;
l_effective_end_date := NULL;
l_position_definition_id := NULL;
l_object_version_number := NULL;
l_name := NULL;
g_error_msg := NULL;
g_organization_id := NULL;
g_job_id := NULL;
g_jobname := NULL;
g_availability_status_id := NULL;
g_permanent_flag := NULL;
g_location_id := NULL;
g_business_group_id := NULL;
g_payroll_id := NULL;
g_bargaining_unit_cd := NULL;
g_pay_basis_id := NULL;
g_seasonal_flag := NULL;
g_entry_grade_id := NULL;
g_status := NULL;
g_frequency := NULL;
g_ptype := NULL;
l_job_date := NULL;
l_organization_date := NULL;
l_hr_org_count := 0;
l_pos_name := NULL;
l_org_name := NULL;
l_working_hours := NULL;
l_probation_duration := NULL;
l_probation_unit := NULL;
IF(cur_pos_val_rec.date_effective_name IS NULL) THEN
----checking mandetory column position_name
g_error_msg := 'Position name does not exist';
xx_per_posfail_prc(cur_pos_val_rec.rowid, g_error_msg);
xxph_common_dmg_pkg.insert_error_message_prc(cur_pos_val_rec.transaction
_id, cur_pos_val_rec.component_name, 'Position Name', cur_pos_val_rec.date
_effective_name, 'Data', g_error_msg, '');
fnd_file.PUT_LINE(fnd_file.LOG, 'Position name does not exist');

ELSIF LENGTH(cur_pos_val_rec.date_effective_name) > 120 THEN
g_error_msg := 'Position name must not be more that 120 Characters';
xx_per_posfail_prc(cur_pos_val_rec.rowid, g_error_msg);
xxph_common_dmg_pkg.insert_error_message_prc(cur_pos_val_rec.transacti
on_id, cur_pos_val_rec.component_name, 'Position Name', cur_pos_val_rec.da
te_effective_name, 'Data', g_error_msg, '');
fnd_file.PUT_LINE(fnd_file.LOG, 'Position name must not be more that
120 Characters');
END IF;
IF(cur_pos_val_rec.start_date IS NULL) THEN
---checking mandetory column startdate of position
g_error_msg := 'Start date does not exist';
xx_per_posfail_prc(cur_pos_val_rec.rowid, g_error_msg);
xxph_common_dmg_pkg.insert_error_message_prc(cur_pos_val_rec.transacti
on_id, cur_pos_val_rec.component_name, 'start_date', cur_pos_val_rec.start
_date, 'Data', g_error_msg, '');
fnd_file.PUT_LINE(fnd_file.LOG, 'Start date does not exist');
END IF;
BEGIN
IF(cur_pos_val_rec.position_type IS NULL) THEN
----checking mandetory column position_type
g_error_msg := 'Position type does not exist';
xx_per_posfail_prc(cur_pos_val_rec.rowid, g_error_msg);
xxph_common_dmg_pkg.insert_error_message_prc(cur_pos_val_rec.transac
tion_id, cur_pos_val_rec.component_name, 'position_type', cur_pos_val_rec.
position_type, 'Data', g_error_msg, '');
fnd_file.PUT_LINE(fnd_file.LOG, 'Position type does not exist');
ELSE
SELECT lookup_code ----deriving lookupcode of position_type
INTO g_ptype
FROM hr_lookups
WHERE lookup_type = 'POSITION_TYPE'
AND meaning = cur_pos_val_rec.position_type;
fnd_file.PUT_LINE(fnd_file.LOG, 'Position type' || g_ptype);
END IF;
EXCEPTION
WHEN no_data_found THEN
g_error_msg := 'No position_type exists with this name';
xx_per_posfail_prc(cur_pos_val_rec.rowid, g_error_msg);
xxph_common_dmg_pkg.insert_error_message_prc(cur_pos_val_rec.transacti
on_id, cur_pos_val_rec.component_name, 'position_type', cur_pos_val_rec.po
sition_type, 'Validation', g_error_msg, '');
fnd_file.PUT_LINE(fnd_file.LOG, 'No position_type exists with this n
ame');
WHEN others THEN
g_error_msg := 'Other error in finding position_type';
xx_per_posfail_prc(cur_pos_val_rec.rowid, g_error_msg);
xxph_common_dmg_pkg.insert_error_message_prc(cur_pos_val_rec.transacti
on_id, cur_pos_val_rec.component_name, 'position_type', cur_pos_val_rec.po
sition_type, 'Validation', g_error_msg, '');
fnd_file.PUT_LINE(fnd_file.LOG, 'Other error in finding position_typ
e' || sqlerrm);
END;

BEGIN
IF(cur_pos_val_rec.position_name IS NULL) THEN
----checking mandetory column position_type
g_error_msg := 'Position name does not exist';
xx_per_posfail_prc(cur_pos_val_rec.rowid, g_error_msg);
xxph_common_dmg_pkg.insert_error_message_prc(cur_pos_val_rec.transac
tion_id, cur_pos_val_rec.component_name, 'position_name', cur_pos_val_rec.
position_name, 'Data', g_error_msg, '');
fnd_file.PUT_LINE(fnd_file.LOG, 'Position type does not exist');
ELSE
SELECT meaning ----deriving lookupcode of position_type
INTO l_pos_name
FROM hr_lookups
WHERE lookup_type = 'PH_POSITION_NAME'
AND meaning = cur_pos_val_rec.position_name;
fnd_file.PUT_LINE(fnd_file.LOG, 'Position name' || g_ptype);
END IF;
EXCEPTION
WHEN no_data_found THEN
g_error_msg := 'No position_name exists with this name';
xx_per_posfail_prc(cur_pos_val_rec.rowid, g_error_msg);
xxph_common_dmg_pkg.insert_error_message_prc(cur_pos_val_rec.transacti
on_id, cur_pos_val_rec.component_name, 'position_name', cur_pos_val_rec.po
sition_name, 'Validation', g_error_msg, '');
fnd_file.PUT_LINE(fnd_file.LOG, 'No position_type exists with this n
ame');
WHEN others THEN
g_error_msg := 'Other error in finding position_name';
xx_per_posfail_prc(cur_pos_val_rec.rowid, g_error_msg);
xxph_common_dmg_pkg.insert_error_message_prc(cur_pos_val_rec.transacti
on_id, cur_pos_val_rec.component_name, 'position_name', cur_pos_val_rec.po
sition_name, 'Validation', g_error_msg, '');
fnd_file.PUT_LINE(fnd_file.LOG, 'Other error in finding position_typ
e' || sqlerrm);
END;
BEGIN
IF(cur_pos_val_rec.permanent_position IS NULL) THEN
----checking mandetory column permanent_flag
g_error_msg := 'Permanent flag does not exist';
xx_per_posfail_prc(cur_pos_val_rec.rowid, g_error_msg);
xxph_common_dmg_pkg.insert_error_message_prc(cur_pos_val_rec.transac
tion_id, cur_pos_val_rec.component_name, 'permanent_position', cur_pos_val
_rec.permanent_position, 'Data', g_error_msg, '');
fnd_file.PUT_LINE(fnd_file.LOG, 'Permanent flag does not exist');
ELSE
SELECT lookup_code
INTO g_permanent_flag ----deriving lookupcode for permanent_flag
FROM hr_lookups
WHERE lookup_type = 'YES_NO'
AND meaning = cur_pos_val_rec.permanent_position;
fnd_file.PUT_LINE(fnd_file.LOG, 'Permanent_flag:' || g_permanent_f
lag);
END IF;

insert_error_message_prc(cur_pos_val_rec.permanent_position. xxph_common_dmg_pkg.PUT_LINE(fnd_file. 'Validation'. 'organization_name'.component_name. fnd_file.LOG. 'Organization_name does not exist' ). g_error_msg).rowid.PUT_LINE(fnd_file. cur_pos_val_rec. g_error_msg. xxph_common_dmg_pkg. fnd_file. 'permanent_position'.LOG.no other data is accepted'. xxph_common_dmg_pkg. WHEN others THEN g_error_msg := 'Other error in finding permanent status '.rowid. 'Organization is not an HR Organ ization'). 'organization_name'.trans action_id. cur_pos_val_rec. BEGIN IF(cur_pos_val_rec. g_error_msg. g_error_msg). ''). xx_per_posfail_prc(cur_pos_val_rec. fnd_file.insert_error_message_prc(cur_pos_val_rec.transacti on_id. '').LOG. g_error_msg).PUT_LINE(fnd_file.transacti on_id.component_name. cur_pos_va l_rec. cur_pos_val_r ec. 'Data'. '').component_name. ------------. END. cur_pos_val_ rec.component_name. cur_pos_val_rec. xx_per_posfail_prc(cur_pos_val_rec.organization_name. ------------- UPDATE xx_hr_positions_stg ----updating organization_id in staging t .By Niraj Date:30/08/07 SELECT COUNT(*) INTO l_hr_org_count FROM hr_organization_information WHERE org_information_context = 'CLASS' AND org_information1 = 'HR_ORG' AND org_information2 = 'Y' AND organization_id = g_organization_id. cur_pos_val_rec. fnd_file. EXCEPTION WHEN no_data_found THEN g_error_msg := 'Permanent status should be yes or no. cur_pos_val_r ec.transac tion_id. 'Validation'.organization_name. g_error_msg).insert_error_message_prc(cur_pos_val_rec. IF l_hr_org_count = 0 THEN g_error_msg := 'Organization is not an HR Organization'.insert_error_message_prc(cur_pos_val_rec.rowid. xxph_common_dmg_pkg. ELSE SELECT DISTINCT organization_id INTO g_organization_id -----deriving organization_id FROM hr_organization_units WHERE name = cur_pos_val_rec.organization_name IS NULL) THEN ----checking mandetory column organization g_error_msg := 'Organization_name does not exist'. g_error_msg.PUT_LINE(fnd_file. 'other error in finding permanent st atus' || sqlerrm). xx_per_posfail_prc(cur_pos_val_rec. xx_per_posfail_prc(cur_pos_val_rec. 'PERMANENT STATUS SHOULD BE YES OR N O').permanent_position. 'Organization_name:' || g_organiza tion_id).organization_name. g_error_msg. END IF. '').PUT_LINE(fnd_file. 'Data'. fnd_file.LOG. 'permanent_position'.rowid.LOG.

xxph_common_dmg_pkg. xx_per_posfail_prc(cur_pos_val_rec. g_error_msg).organization_name.rowid. END IF.organization_name. 'Job_band does not exist'). g_error_msg. UPDATE xx_hr_positions_stg SET job_id = g_job_id --------updating staging table with job_id WHERE rowid = cur_pos_val_rec. g_error_msg. 'Other error in finding organization ' || sqlerrm). cur_pos_val_rec. g_error_msg). xx_per_posfail_prc(cur_pos_val_rec. '').LOG.component_name. BEGIN IF(cur_pos_val_rec. fnd_file. fnd_file.LOG.j ob_band. cur_pos_val_rec. ELSIF(cur_pos_val_rec. EXCEPTION WHEN no_data_found THEN g_error_msg := 'Organization does not exist with this name'. g_error_msg). cur_pos_val_rec.job_group IS NULL) THEN ------checking mandetory column jobgroup g_error_msg := 'Job_group does not exist'. g_error_msg.PUT_LINE(fnd_file. 'Jobname:' || g_jobname).component_name. WHEN others THEN g_error_msg := 'Other error in finding organization'. 'job_group'.LOG. cur_pos_val_rec.job_ group. xxph_common_dmg_pkg.PUT_LINE(fnd_file. 'Data'.insert_error_message_prc(cur_pos_val_rec.able SET organization_id = g_organization_id WHERE rowid = cur_pos_val_rec.LOG. ''). ' Organization does not exist with t his name'). cur_pos_val_rec.rowid. g_error_msg).component_name.' || cur_pos_val_rec. fnd_file.job_group || '.PUT_LINE(fnd_file. fnd_file. xxph_common_dmg_pkg. 'organization_name'.LOG. 'organization_name'. cur_pos_val_rec.trans action_id.insert_error_message_prc(cur_pos_val_rec. '').PUT_LINE(fnd_file. xx_per_posfail_prc(cur_pos_val_rec.component_name. fnd_file. g_error_msg. cur_pos_val_re c. 'Validation'.rowid.insert_error_message_prc(cur_pos_val_rec.job_band IS NULL) THEN -------checking mandetory column jobband g_error_msg := 'Job_band does not exist'.PUT_LINE(fnd_file. 'Job_id:' || g_job_id).rowid. fnd_file. END. ELSE g_jobname := cur_pos_val_rec.rowid. 'Validation'.job _band. END IF. . '').PUT_LINE(fnd_file. 'Data'.transacti on_id. cur_pos_val_re c. xxph_common_dmg_pkg.LOG.transac tion_id.transacti on_id. 'job_band'. xx_per_posfail_prc(cur_pos_val_rec. 'Job_group do not exist').insert_error_message_prc(cur_pos_val_rec.rowid. SELECT DISTINCT job_id INTO g_job_id -------deriving job_id by concatinating jobgroup and jobband FROM per_jobs WHERE name = g_jobname.

PUT_LINE(fnd_file.component_name. ''). cur_pos_val_rec. END IF. 'job_name'. fnd_file.component_name. 'Validation'. 'Validation'. '').status IS NULL) THEN g_error_msg := 'Status does not exist'.status . g_error_msg). UPDATE xx_hr_positions_stg SET availability_status_id = g_availability_status_id WHERE rowid = cur_pos_val_rec. xx_per_posfail_prc(cur_pos_val_rec.LOG.insert_error_message_prc(cur_pos_val_rec. xxph_common_dmg_pkg. cur_pos_val_rec.transac tion_id. cur_pos_val_rec. xxph_common_dmg_pkg. 'STATUS:' || g_availability_stat us_id). xx_per_posfail_prc(cur_pos_val_rec. 'Data'. fnd_file. g_jobname. 'No status exists with this name') .component_name. cur_pos_val_rec. g_jobname. xxph_common_dmg_pkg. g_error_msg). cur_pos_val_rec.rowid. 'No job exists with this name'). ELSE SELECT DISTINCT shared_type_id INTO g_availability_status_id ------deriving ststus_id FROM per_shared_types WHERE shared_type_name = cur_pos_val_rec. fnd_file.rowid.rowid.PUT_LINE(fnd_file.component_name. BEGIN IF(cur_pos_val_rec.rowid. END. 'Status does not exist'). g_error_msg. g_error_msg.trans action_id.insert_error_message_prc(cur_pos_val_rec. fnd_file. 'status '. xxph_common_dmg_pkg. g_error_msg). 'Other error in finding job' || sq lerrm).transac tion_id. . cur_pos_val_rec. WHEN others THEN g_error_msg := 'Other error in finding job'. 'status '.LOG.LOG. EXCEPTION WHEN no_data_found THEN g_error_msg := 'No job exists with this name'. 'Validat ion'. WHEN others THEN g_error_msg := 'Other error in finding status'.LOG. cur_pos_val_rec. 'Validat ion'. g_error_msg. 'status '.rowid.status.PUT_LINE(fnd_file. fnd_file. EXCEPTION WHEN no_data_found THEN g_error_msg := 'No status exists with this name'. g_error_msg). 'job_name'.status . -----checking mandetory column status of position xx_per_posfail_prc(cur_pos_val_rec.PUT_LINE(fnd_file. fnd_file. cur_pos_val_rec.insert_error_message_prc(cur_pos_val_rec.PUT_LINE(fnd_file. '').stat us.LOG.LOG. g_error_msg. xx_per_posfail_prc(cur_pos_val_rec.component_name. xxph_common_dmg_pkg. ''). xx_per_posfail_prc(cur_pos_val_rec.PUT_LINE(fnd_file.transac tion_id.rowid.insert_error_message_prc(cur_pos_val_rec.insert_error_message_prc(cur_pos_val_rec. g_error_msg). ''). 'Other error in finding status' || sqlerrm).transac tion_id. g_error_msg.

rowid. g_error_msg.effective_date_from. 'Effective_date_from should be after job effective start date').PUT_LINE(fnd_file. fnd_file. EXCEPTION WHEN too_many_rows THEN g_error_msg := 'TOO_MANY_ROWS error while validating job effective d ate'. 'effective_date_from'. 'TOO_MANY_ROWS error in job_date') .effective_date_from.LOG. cur_ pos_val_rec.transac tion_id. 'effective_date_from'.component_name. WHEN others THEN g_error_msg := 'Error while validating for job effective date as job name not found'. g_error_msg). 'Data'.insert_error_message_prc(cur_pos_val_rec.LOG.effective_date_from. xx_per_posfail_prc(cur_pos_val_rec. xx_per_posfail_prc(cur_pos_val_rec. cur_pos_val_rec. xx_per_posfail_prc(cur_pos_val_rec. 'Effective_date_from does not exis t'). 'effective_date_from'. IF(to_date(cur_pos_val_rec.t ransaction_id. xxph_common_dmg_pkg. ''). '').PUT_LINE(fnd_file. g_error_msg).insert_error_message_prc(cur_pos_val_rec. END IF.LOG. g_error_msg).PUT_LINE(fnd_file.rowid. cur_pos_val_rec. g_error_msg. 'Data'.rowid. . fnd_file.component_name. fnd_file. ''). cur_pos_va l_rec. END IF. 'Data'.effective_date_from IS NOT NULL) THEN SELECT DISTINCT date_from INTO l_job_date FROM per_jobs WHERE name = g_jobname.rowid.effective_date_from IS NULL) THEN ------checking mandetory column effective_date_from g_error_msg := 'Effective_date_from does not exist'. g_error_msg).transac tion_id. END. xxph_common_dmg_pkg.LOG. ''). cur_pos_val_rec. IF(l_job_date IS NOT NULL) THEN fnd_file. g_error_msg.PUT_LINE(fnd_file. 'Miscallaneous error in job_date of position' || sqlerrm).effective_date_from) < to_date(l_job_ date)) THEN g_error_msg := 'Effective_date_from should be after job effect ive start date'. END IF. g_error_msg.component_name.PUT_LINE(fnd_file. xxph_common_dmg_pkg. 'JOB_DATE:' || to_date(l_job_d ate)). xxph_common_dmg_pkg.transac tion_id. 'Data'. BEGIN IF(cur_pos_val_rec.LOG. cur_pos_val_rec.insert_error_message_prc(cur_pos_val_rec. cur_pos_va l_rec.component_name. END IF. IF(cur_pos_val_rec. 'effective_date_from'. cur_pos_va l_rec. xx_per_posfail_prc(cur_pos_val_rec.effective_date_from.insert_error_message_prc(cur_pos_val_rec. fnd_file.

xxph_common_dmg_pkg. IF(l_organization_date IS NOT NULL) THEN fnd_file. xxph_common_dmg_pkg. BEGIN IF(cur_pos_val_rec. xx_per_posfail_prc(cur_pos_val_rec.effective_date_from < l_organization_date) TH EN g_error_msg := 'Effective_date_from should be after organizati on effective start date'. fnd_file.effective_date_from. 'TOO_MANY_ROWS error in organizati on_date of position' || sqlerrm). 'effective_date_from'.transac tion_id. cur_pos_va l_rec. cur_pos_val_rec.PUT_LINE(fnd_file. fnd_file. IF(cur_pos_val_rec. 'effective_date_from'. xxph_common_dmg_pkg.insert_error_message_prc(cur_pos_val_rec. cur_ pos_val_rec. 'effective_date_from'.effective_date_from.component_name.LOG. g_error_msg.LOG.start_date)) THEN g_error_msg := 'Effective_date_from should be after start date'. 'Data'.component_name. END IF. END. xx_per_posfail_prc(cur_pos_val_rec.rowid.organization_name. END. 'Data'. g_error_msg. BEGIN IF(cur_pos_val_rec.tra nsaction_id. END IF. g_error_msg). ''). EXCEPTION WHEN too_many_rows THEN g_error_msg := 'TOO_MANY_ROWS error while validating organization ef fective date'. xx_per_posfail_prc(cur_pos_val_rec. '').insert_error_message_prc(cur_pos_val_rec. 'Effective_date_from should be after organization effective start date').PUT_LINE(fnd_file.component_name. g_error_msg).insert_error_message_prc(cur_pos_val_rec.t ransaction_id.PUT_LINE(fnd_file. g_error_msg). 'Data'.component_name.LOG.PUT_LINE(fnd_file. cur_pos_va l_rec. cur_pos_val_rec. cur_pos_val_rec. 'ORGANIZATION:' || to_date(l_o rganization_date)).effective_date_from IS NOT NULL) THEN SELECT DISTINCT date_from INTO l_organization_date FROM hr_all_organization_units WHERE name = cur_pos_val_rec.effective_date_from.rowid.effective_date_from IS NOT NULL) THEN IF(to_date(cur_pos_val_rec. ''). cur_po . g_error_msg. END IF. 'Error while validating for organi zation effective date as organization name not found' || sqlerrm). 'effective_date_from'. g_error_msg).LOG. xxph_common_dmg_pkg.insert_error_message_prc(cur_pos_val_rec.rowid. WHEN others THEN g_error_msg := 'Error while validating for organization effective da te as organization name not found'. fnd_file.transac tion_id.rowid.effective_date_from) > to_date(cur_pos_ val_rec. cur_pos_val_rec. xx_per_posfail_prc(cur_pos_val_rec.

'Miscallaneous error in effective_ date of position' || sqlerrm).LOG.fte. 'Effective_date_from should be after start date'). cur_pos_val_rec. END IF. g_error_msg. cur_pos_val_rec.s_val_rec.insert_error_message_prc(cur_pos_val_rec. END IF.head count. fnd_file.LOG.transac tion_id. cur_pos_val_rec. cur_pos_val_rec.he adcount. IF(l_poscount <> 0) THEN g_error_msg := 'Position already exist'. END IF.transac tion_id. IF(cur_pos_val_rec.LOG. 'Da ta'.LOG.PUT_LINE(fnd_file. 'Head count should be one for sing le incumbment ' || sqlerrm).PUT_LINE(fnd_file. 'Data'.insert_error_message_prc(cur_pos_val_rec.headcount IS NULL) THEN g_error_msg := 'Head count does not exist'.PUT_LINE(fnd_file.insert_error_message_prc(cur_pos_val_rec. xx_per_posfail_prc(cur_pos_val_rec.rowid. g_error_msg.component_name. cur_pos_val_rec. xxph_common_dmg_pkg. g_error_msg.rowid. ------checking mandetory column fte xx_per_posfail_prc(cur_pos_val_rec. g_error_msg). ''). 'FTE does not exist'). g_error_msg). SELECT COUNT(1) ----checking whether position already exists INTO l_poscount FROM hr_all_positions_f WHERE name = cur_pos_val_rec. 'Head count do not exist'). 'Data'. 'Validation'.trans action_id.effective_date_from.component_name.component_name. xxph_common_dmg_pkg. cur_pos_val_rec. g_error_msg). 'Data'.date_effective_name. g_error_msg). ''). EXCEPTION WHEN others THEN g_error_msg := 'Miscallaneous error in effective_date of position'.effective_date_from. g_error_msg). xxph_common_dmg_pkg.component_name.PUT_LINE(fnd_file. g_error_msg. END IF. EXCEPTION WHEN others THEN g_error_msg := 'Head count should be one for single incumbment'. 'headcount'. cur_pos_va l_rec. 'fte'. xx_per_posfail_prc(cur_pos_val_rec.rowid. '').fte IS NULL) THEN g_error_msg := 'FTE does not exist'. END. fnd_file. END. ''). xx_per_posfail_prc(cur_pos_val_rec. 'headcount'. ''). 'effective_date_from'. fnd_file. ------checking mandetory column fte xx_per_posfail_prc(cur_pos_val_rec. fnd_file. xxph_common_dmg_pkg.LOG. g_error_msg. fnd_file.transac tion_id.rowid.rowid. .PUT_LINE(fnd_file.insert_error_message_prc(cur_pos_val_rec. BEGIN IF(cur_pos_val_rec. cur_pos_val_rec.

.transac tion_id.. fnd_file. g_error_msg..component_name.transac tion_id.organization_name IS NOT NULL) THEN ----deriving business_group_id SELECT DISTINCT business_group_id INTO g_business_group_id FROM hr_organization_units WHERE name = cur_pos_val_rec. 'Validation'. g_error_msg)..organization_name.LOG. 'Validation'.. ''). fnd_file. 'Validation'. WHEN others THEN g_error_msg := 'Other error in finding business group of given organ ization'. cur_pos_val_rec. ''). xxph_common_dmg_pkg.component_name. 'business_group_id'. fnd_file. ''). 'Errror. g_error_msg).rowid. 'business_group_id'.Position already e xist'). xx_per_posfail_prc(cur_pos_val_rec. END IF.insert_error_message_prc(cur_pos_val_rec. fnd_file. END IF.PUT_LINE(fnd_file. g_error_msg.LOG. g_error_msg.transac tion_id. END. 'BUSINESS GROUP:' || g_business_ group_id). 'position'.. 'No organization exists with this business group').PUT_LINE(fnd_file. cur_pos_val_rec. /*==================================================================== ======================= DERIVING BUSINESS_GROUP_ID FROM ORGANIZATION_NAME ===================================================================== =======================*/ BEGIN IF(cur_pos_val_rec.rowid. /*==================================================================== ================= DERIVING LOCATION_ID FROM LOCATION_NAME ================================================================== =====================*/ BEGIN IF(cur_pos_val_rec. g_business_g roup_id. xxph_common_dmg_pkg.PUT_LINE(fnd_file. g_business_g roup_id. xxph_common_dmg_pkg.LOG.insert_error_message_prc(cur_pos_val_rec. xx_per_posfail_prc(cur_pos_val_rec.PUT_LINE(fnd_file.organization_name IS NOT NULL) THEN -----deriving location_id SELECT DISTINCT location_id INTO g_location_id . 'Other error in finding business g roup of given organization' || sqlerrm). UPDATE xx_hr_positions_stg SET business_group_id = g_business_group_id ------updating busines s_group_id in staging_table WHERE rowid = cur_pos_val_rec.. cur_pos_val_rec.component_name. EXCEPTION WHEN no_data_found THEN g_error_msg := 'No organization exists with this business group'.rowid..insert_error_message_prc(cur_pos_val_rec.date_ effective_name. cur_pos_val_rec.LOG.

transac tion_id.PUT_LINE(fnd_file.PUT_LINE(fnd_file. fnd_file.rowid. 'payroll_id:' || g_payroll_id).payroll IS NOT NULL) THEN SELECT DISTINCT payroll_id ----deriving payroll_id INTO g_payroll_id FROM pay_all_payrolls_f WHERE payroll_name = cur_pos_val_rec. cur_pos_val_rec. FROM hr_all_organization_units WHERE name = cur_pos_val_rec.insert_error_message_prc(cur_pos_val_rec. cur_pos_val_rec. 'location_name'.component_name. END IF. cur_pos_val_rec. UPDATE xx_hr_positions_stg ------updating payroll_id in staging_ta ble SET payroll_id = g_payroll_id WHERE rowid = cur_pos_val_rec. ''). xx_per_posfail_prc(cur_pos_val_rec. fnd_file. g_location_id. 'payroll'.rowid. g_error_msg. ''). ' Validation'. cur_pos_val_rec. 'Other error in finding location o f given organization' || sqlerrm).rowid. END IF.transac tion_id. fnd_file.LOG. xxph_common_dmg_pkg. EXCEPTION WHEN no_data_found THEN g_error_msg := 'No location exists with this name'. location_name. 'Validation'.payroll. 'location_id'. /*-------------------------------------------------------------------- ----------------- DERIVING PAYROLL_ID FROM PAYROLL_NAME -------------------------------------------------------------------- -----------------*/ BEGIN IF(cur_pos_val_rec.LOG. g_error_msg).payrol l. xxph_common_dmg_pkg. END. xxph_common_dmg_pkg.insert_error_message_prc(cur_pos_val_rec.PUT_LINE(fnd_file. g_error_msg).rowid.LOG. fnd_file. g_error_msg). WHEN others THEN g_error_msg := 'Other error in finding location of given organizatio n'.PUT_LINE(fnd_file. xx_per_posfail_prc(cur_pos_val_rec.insert_error_message_prc(cur_pos_val_rec. g_error_msg. 'location:' || g_location_id).component_name. fnd_file. '').PUT_LINE(fnd_file. WHEN others THEN .LOG. g_error_msg.organization_name. UPDATE xx_hr_positions_stg ------updating location_id in staging_t able SET location_id = g_location_id WHERE rowid = cur_pos_val_rec. 'No payroll exists with this name' ). cur_pos_val_rec.component_name. 'No location exists with this name ').LOG. 'Validation'.rowid.transac tion_id. EXCEPTION WHEN no_data_found THEN g_error_msg := 'No payroll exists with this name'. xx_per_posfail_prc(cur_pos_val_rec.

bargaining_unit.payrol l. xx_per_posfail_prc(cur_pos_val_rec. xx_per_posfail_prc(cur_pos_val_rec. g_error_msg).transac tion_id. cur_pos_val_rec. END. fnd_file. 'Other error in finding bargaining _unit of given organization' || sqlerrm). cur_pos_val_rec. EXCEPTION WHEN no_data_found THEN g_error_msg := 'No bargaining_unit exists with this name'. '').rowid. xxph_common_dmg_pkg.bargaining_unit IS NOT NULL) THEN ---deriving bargaining_unit lookupcode SELECT lookup_code INTO g_bargaining_unit_cd FROM hr_lookups WHERE lookup_type = 'BARGAINING_UNIT_CODE' AND meaning = cur_pos_val_rec.LOG.PUT_LINE(fnd_file. /* =================================================================== =============== DERIVING V_SEASONAL_FLAG ================================================================== ==================*/ BEGIN IF(cur_pos_val_rec. ''). 'Validation'. g_error_msg). xxph_common_dmg_pkg. g_error_msg.seasonal IS NOT NULL) THEN --deriving seasonal_flag lookupcode SELECT lookup_code INTO g_seasonal_flag . 'Validation'. g_error_msg). g_error_msg. 'payroll'.rowid. cur_pos_val_re c.bargaining_unit. fnd_file. cur_pos_val_rec. 'bargaining_unit:' || g_bargaini ng_unit_cd). WHEN others THEN g_error_msg := 'Other error in finding bargaining_unit of given orga nization'.component_name. END IF.LOG.LOG. '').bargaining_unit.component_name.insert_error_message_prc(cur_pos_val_rec. xx_per_posfail_prc(cur_pos_val_rec.LOG. fnd_file. 'Other error in finding payroll of given organization' || sqlerrm).PUT_LINE(fnd_file.transac tion_id. /*-------------------------------------------------------------------- ----------------- DERIVING BARGAINING_UNIT_CODE FROM BARGAINING_UNIT --------------------------------------------------------------------- ----------------*/ BEGIN IF(cur_pos_val_rec. fnd_file. 'Validation'. 'bargaining_unit'. g_error_msg. END.insert_error_message_prc(cur_pos_val_rec. cur_pos_val_re c.PUT_LINE(fnd_file.component_name. xxph_common_dmg_pkg.rowid.insert_error_message_prc(cur_pos_val_rec.PUT_LINE(fnd_file.transac tion_id. 'bargaining_unit'. 'No bargaining_unit exists with th is name'). g_error_msg := 'Other error in finding payroll of given organization '. cur_pos_val_rec.

'').component_name.LOG. 'Other error in finding seasonal_f lag of given organization' || sqlerrm). ''). EXCEPTION WHEN no_data_found THEN g_error_msg := 'No salary_basis exists with this name'. 'Validation'. END. xxph_common_dmg_pkg. UPDATE xx_hr_positions_stg --------updating paybasis_id in staging table SET pay_basis_id = g_pay_basis_id WHERE rowid = cur_pos_val_rec.rowid.salary_basis. 'salary_basis'.transac tion_id.component_name.insert_error_message_prc(cur_pos_val_rec.LOG. /*-------------------------------------------------------------------- ----------------- DERIVING PAY_BASIS_ID FROM SALARY_BASIS ------------------------------------------------------------------- ------------------*/ BEGIN IF(cur_pos_val_rec.transac . WHEN others THEN g_error_msg := 'Other error in finding seasonal_flag of given organi zation'. xxph_common_dmg_pkg. fnd_file. g_error_msg).insert_error_message_prc(cur_pos_val_rec. cur_pos_val_rec.rowid. EXCEPTION WHEN no_data_found THEN g_error_msg := 'Seasonal status should be yes or no'.salary_basis IS NOT NULL) THEN ----deriving paybasis_id SELECT DISTINCT pay_basis_id INTO g_pay_basis_id FROM per_pay_bases WHERE name = cur_pos_val_rec.PUT_LINE(fnd_file.LOG.rowid. g_error_msg). xx_per_posfail_prc(cur_pos_val_rec. 'Seasonal status should be yes or no'). cur_pos_val_rec.transac tion_id.rowid.LOG. fnd_file.seasonal. 'No salary_basis exists with this name').s alary_basis. FROM hr_lookups WHERE lookup_type = 'YES_NO' AND meaning = cur_pos_val_rec.transac tion_id. g_error_msg. 'seasonal'. xx_per_posfail_prc(cur_pos_val_rec.PUT_LINE(fnd_file. cur_pos_val_rec. xx_per_posfail_prc(cur_pos_val_rec.PUT_LINE(fnd_file. 'pay_basis:' || g_pay_basis_id).rowid. END IF. END IF. xxph_common_dmg_pkg. xx_per_posfail_prc(cur_pos_val_rec. 'Validation'. '').insert_error_message_prc(cur_pos_val_rec. g_error_msg. WHEN others THEN g_error_msg := 'Other error in finding salary_basis of given organiz ation'. fnd_file. g_error_msg). 'seasonal'. cur_pos_val_rec. cur_pos_val_rec. xxph_common_dmg_pkg. cur_pos_val_rec.PUT_LINE(fnd_file.insert_error_message_prc(cur_pos_val_rec. fnd_file. 'Validation'. g_error_msg.component_name.seaso nal.seaso nal. g_error_msg).

'').rowid. cur_pos_val_rec. xx_per_posfail_prc(cur_pos_val_rec. g_error_msg. ''). 'GRADE:' || g_entry_grade_id).transac tion_id. 'grade'. g_error_msg). 'Validation'. ''). xxph_common_dmg_pkg.PUT_LINE(fnd_file. g_error_msg. fnd_file. fnd_file.tion_id.grade. UPDATE xx_hr_positions_stg ------------updating grade_id in stagin g table SET entry_grade_id = g_entry_grade_id WHERE rowid = cur_pos_val_rec. cur_pos_val_rec.rowid. 'salary_basis'.frequency IS NOT NULL) THEN ------deriving lookupcode for frequency SELECT lookup_code INTO g_frequency FROM hr_lookups WHERE meaning = cur_pos_val_rec. g_error_msg.insert_error_message_prc(cur_pos_val_rec. /*--------------------------------------------------------------------------- ---------- DERIVING FREQUENCY ------------------------------------------------------------------------------ ------*/ BEGIN IF(cur_pos_val_rec. 'No grade exists with this name').PUT_LINE(fnd_file. 'Other error in finding entry_grad e of given organization' || sqlerrm). END IF.rowid. --------------------------------------------------------------------------- ---------- /*DERIVING GRADE_ID FROM GRADE_NAME*/ ---------------------------------------------------------------------------- --------- BEGIN IF(cur_pos_val_rec. .LOG.transac tion_id. 'Validation'. cur_pos_val_rec.grade IS NOT NULL) THEN ----deriving grade_id SELECT DISTINCT grade_id INTO g_entry_grade_id FROM per_grades WHERE name = cur_pos_val_rec.component_name.PUT_LINE(fnd_file. xx_per_posfail_prc(cur_pos_val_rec.grade.frequency AND lookup_type = 'FREQUENCY'.LOG. EXCEPTION WHEN no_data_found THEN g_error_msg := 'No grade exists with this name'. cur_pos_val_rec. cur_pos_val_rec.insert_error_message_prc(cur_pos_val_rec. cur_pos_val_rec. WHEN others THEN g_error_msg := 'Other error in finding entry_grade of given organiza tion'. 'Validation'.grade.component_name. 'grade'.s alary_basis. xxph_common_dmg_pkg. END.PUT_LINE(fnd_file. g_error_msg). fnd_file.LOG.LOG.component_name. 'Other error in finding salary_bas is of given organization' || sqlerrm). fnd_file. END.

LOG.LOG. '').cur_pos_val_rec. SAVEPOINT x. cur_pos_val_rec. '').LOG.insert_error_message_prc(cur_pos_val_rec. IF cur_pos_val_rec. 'End of derivations'). fnd_file. --V fro Validate Records ELSE UPDATE xxph. cur_pos_val_rec. END. xx_per_posfail_prc(cur_pos_val_rec.transac tion_id.PUT_LINE(fnd_file. 'Validation'. 'Workings hours should be specifie d along with frequency' || sqlerrm).freq uency. fnd_file.PUT_LINE(fnd_file. 'frequency:' || g_frequency). g_error_msg). .probation_duration = 0 THEN l_probation_duration := NULL. cur_pos_val_rec. END IF.rowid.xxph_common_dmg_pkg.dat e_effective_name.component_name.wor king_hours) INTO l_working_hours FROM dual. 'frequency'.rowid. 'Validation'.PUT_LINE(fnd_file. cur_pos_val_rec.transac tion_id. cur_pos_val_rec. 'No frequency exists with this nam e'). xxph_common_dmg_pkg.xx_hr_positions_stg SET processing_status = 'V' WHERE processing_status = 'N' AND rowid = cur_pos_val_rec. 'frequency'. WHEN others THEN g_error_msg := 'Workings hours should be specified along with freque ncy'. SELECT decode(cur_pos_val_rec.LOG.LOG. '--.transacti on_id. 'HR_POSITIONS'. END IF. g_error_msg. EXCEPTION WHEN no_data_found THEN g_error_msg := 'No frequency exists with this name'.component_name. xxph_common_dmg_pkg. xx_per_posfail_prc(cur_pos_val_rec. IF(g_error_msg IS NULL) THEN UPDATE xxph.working_hours. fnd_file. g_error_msg. cur_pos_val_rec.rowid.PUT_LINE(fnd_file. 'Data'. l_probation_unit := NULL.insert_error_message_prc(cur_pos_val_rec.freq uency. g_error_msg).rowid. fnd_file. -. g_error_msg.xx_hr_positions_stg SET processing_status = 'E' WHERE processing_status = 'N' AND rowid = cur_pos_val_rec.component_name.NULL. fnd_file.0. '').SAVEPOINT x').insert_error_message_prc(cur_pos_val_rec. END IF.PUT_LINE(fnd_file.

p_attribute2 => cur_pos_val_rec. p_pay_freq_payroll_id => g_payroll_id. p_work_term_end_day_cd => NULL. --cur_ pos_val_rec. p_position_type => g_ptype. p_s egment1 => cur_pos_val_rec. p_te rm_start_month_cd => NULL. p_permanent_temporary_flag => g_permanent_ flag. p_attribute4 => cur_pos_val_rec. p_amendment_date => NULL. p_availabi lity_status_id => g_status. p_language_code => l_language_code. p_position_transaction_id => cur_pos_val_rec. p_request_id => NULL. p_effective_date => cur_pos_val_rec. p_segment2 => cur_pos_val_rec.*/ hr_position_api. p_entry_grade_rule_id => NULL. p_am endment_recommendation => NULL. p_relief_positi on_id => NULL.create_position(p_validate => FALSE. p_overl ap_period => NULL.shoe_uniform_eligibility. p_prior_position_id => NULL. -- cur_pos_val_rec. p_frequency => g_frequency.create_position( p_validate => FALSE. p_security_req uirements => NULL. p_review_flag => NULL.organi zation_name.attribute31. p_date_end => cur_pos_val_rec.end_time.attribute32. p_program_application_id => NULL. p_term_start_day_cd => NULL. p_work_period_type_cd => NULL. p_supervisor_id => NULL . p_effective_start_date => l_effective_start_date. p_status => l_status. p_effective_start_date => l_effective_start_date. p_successor_position_id => NULL. p_update_source_cd => NULL . p_entry_grade_id => g_entry_grade_id. p_posit ion_id => l_position_id. p_program_update_date => NULL. p_replacement_required_flag => NULL.transaction_id. p_time_normal_finish => cur_pos_val_rec. p_business_group_id => g_business_group_id. p_probation_period => l_probation_duration. p_program_id => NULL. p_position_definition_id => l_position_definition_id. p_earliest_hi re_date => NULL. --cur_pos_val_rec.position_name. p_supervisor_position_id => NULL.start_date. p_location_id => g_locat ion_id.effective_date_from. p_fill_by_date => NULL. . p_attribute_category => 'PH_ADD_POS_DETAILS'.fte. p_avail_status_prop_end_ date => NULL. p_position_id => l_position_id. p_work_ter m_end_month_cd => NULL. p_job_id => g_job_id.attribute33. p_prob ation_period_unit_cd => l_probation_unit.start_time.registered_nurse. p_segment4 => NULL. IF(l_commit = 'YES') THEN IF g_error_msg IS NULL THEN -------valid records inserted thru api BEGIN /* hr_position_api. p_permit_recruitment_flag => NULL. p_en try_step_id => NULL. p_bargaining _unit_cd => g_bargaining_unit_cd. p_segment3 => NULL. p_comments => NULL. p_position_definition_id => l_pos ition_definition_id. p_pay_term_end_day_cd => NULL. p_working_hours => l_working_hours.effective_date_to. p_object_version_number => l_object_v ersion_number. p_fte => cur_pos_val_rec. p_overlap_unit_cd => NULL. p_attribute3 => cur_pos_val_rec. p_concat_segments => NULL. p_name => l_name. p_effective_end_date => l_effective_end_date. p_pos ting_description => NULL. p_security_profile_id => l_security _profile_id). p _effective_end_date => l_effective_end_date. p_pay_term_end_month_cd => NULL. p_amendment_ref_number => NULL. p_current_job_prop_end _date => NULL.headcount. p_proposed_date_f or_layoff => NULL. p_max_persons => cur_pos_val_rec. p_works_council_approval_flag => NULL. p_seasonal_flag => g_seasonal_flag. p_time_normal_start => cur_pos_val_rec. p_attribute1 => cur_pos_val_ rec. p_pay_basis_id => g_pay_basis_id. p_date_effective = > cur_pos_val_rec. p_organization_id => g_organization_id. p_current_org_prop_end_date => NULL. p_proposed_fte_for_layoff => NULL.meal_coupon_eligibility.direct_patient_staff. p_name => l_name.

p_update_source_cd => NULL. p_date_end => cur_pos_val_rec. p_avail_status_prop_end_date => NULL. p_permit_recruitment_flag => NULL. p_term_start_month_cd => NULL. p_work_period_type_cd => NULL. p_work_term_end_month_cd => NULL. p_time_normal_finish => cur_pos_val_rec. p_posting_description => NULL. p_business_group_id => g_business_group_id. p_entry_step_id => NULL. p_entry_grade_id => g_entry_grade_id. p_replacement_required_flag => NULL. p_time_normal_start => cur_pos_val_rec. p_entry_grade_rule_id => NULL. p_object_version_number => l_object_version_number. p_review_flag => NULL. p_effective_date => cur_pos_val_rec. p_successor_position_id => NULL. p_prior_position_id => NULL. p_amendment_ref_number => NULL.start_time. p_position_type => g_ptype. p_pay_term_end_month_cd => NULL. p_work_term_end_day_cd => NULL. p_frequency => g_frequency. p_pay_term_end_day_cd => NULL.transaction _id. p_status => l_status. p_permanent_temporary_flag => g_permanent_flag. p_language_code => l_language_code.end_time. p_probation_period => l_probation_duration. p_working_hours => l_working_hours. p_current_job_prop_end_date => NULL.start_date.effective_d ate_to. p_earliest_hire_date => NULL.headcount. p_availability_status_id => g_status. p_term_start_day_cd => NULL. p_pay_freq_payroll_id => g_payroll_id. p_max_persons => cur_pos_val_rec. p_bargaining_unit_cd => g_bargaining_unit_cd. p_relief_position_id => NULL. p_amendment_recommendation => NULL. p_security_requirements => NULL. p_organization_id => g_organization_id.fte. p_job_id => g_job_id. p_overlap_period => NULL. p_fill_by_date => NULL. p_probation_period_unit_cd => l_probation_unit. p_current_org_prop_end_date => NULL. p_overlap_unit_cd => NULL. p_amendment_date => NULL. p_works_council_approval_flag => NULL. p_position_transaction_id => cur_pos_val_rec. p_fte => cur_pos_val_rec. p_supervisor_position_id => NULL. p_location_id => g_location_id. .effective_d ate_from. p_comments => NULL. p_seasonal_flag => g_seasonal_flag. p_date_effective => cur_pos_val_rec.

g_error_msg. p_attribute4 => cur_pos_val_rec. p_program_id => NULL. END.GET). 'ORACLE ERROR'. p_program_application_id => NULL. cur_pos_val_rec.direct_pati ent_staff. 'API failed when inserting p osition records: ' || sqlerrm || fnd_message. END IF. EXCEPTION WHEN others THEN g_error_msg := 'API failed when inserting position records: '| | sqlerrm || fnd_message.LOG.rowid.insert_error_message_prc(cur_pos_val_rec. 'Position'.component_name.shoe_unifor m_eligibility. --cur_pos_val_rec.xx_hr_positions_stg SET processing_status = 'E' WHERE processing_status='V' AND rowid = cur_pos_val_rec.registered_ nurse.attribute32. p_attribute_category => 'PH_ADD_POS_DETAILS'. cur_pos_val_rec .rowid. p_program_update_date => NULL.t ransaction_id. p_segment1 => cur_pos_val_rec.position_name. IF g_error_msg IS NOT NULL THEN .rowid. g_error_msg). p_concat_segments => NULL. IF g_error_msg IS NULL THEN UPDATE xxph. p_segment4 => NULL. --cur_pos_val_rec. p_security_profile_id => l_security_profile_id ). p_attribute3 => cur_pos_val_rec. --cur_pos_val_rec. ELSE UPDATE xxph.organizatio n_name. p_request_id => NULL.attribute31.attribute33. xxph_common_dmg_pkg.position_na me. p_attribute2 => cur_pos_val_rec. p_segment3 => NULL. p_segment2 => cur_pos_val_rec. fnd_file. p_pay_basis_id => g_pay_basis_id. xx_per_posfail_prc(cur_pos_val_rec. p_supervisor_id => NULL. l_pos_ins := FALSE. p_proposed_date_for_layoff => NULL. p_proposed_fte_for_layoff => NULL.PUT_LINE(fnd_file. ''). p_attribute1 => cur_pos_val_rec.meal_coupon _eligibility.xx_hr_positions_stg SET processing_status = 'P' WHERE processing_status='V' AND rowid = cur_pos_val_rec.GET. l_success := l_success + 1.

--.conc_request_id. l_ln_application_id NUMBER := fnd_global. fnd_file.PUT_LINE(fnd_file. 'l_commit:' || l_commit). /*==================================================== --MAIN PROCEDURE OF POSITIONS-- =====================================================*/ PROCEDURE xx_load_positions_prc(errbuf OUT VARCHAR2. l_request_id NUMBER := fnd_global. IF(l_commit = 'YES') THEN fnd_file. END IF. UPDATE xxph.resp_id. retcode OUT NUMB ER.LOG. ROLLBACK TO x.xx_hr_validgrade_stg SET conc_req_id = NULL WHERE processing_status = 'V'. /* UPDATE xxph.user_id.fnd_global. END LOOP.LOG.*/ fnd_file. UPDATE xx_hr_positions_stg SET processing_status = 'N'. END IF. END IF. 'Total no of records:' | | l_read). l_error := l_read -l_success. 'Total no of records errored:' || l_ error). END IF.LOG. END xx_per_positions_prc. /* IF(l_read=100) THEN COMMIT.PUT_LINE(fnd_file.*/ COMMIT. l_ln_responsibility_id NUMBER := fnd_global.xx_hr_validgrade_stg SET processing_status = 'N' WHERE processing_status = 'V'. COMMIT. .PUT_LINE(fnd_file. fnd_file. 'Total no of records processed:' || l_success). l_ln_application_id).LOG. p_commit IN VARCHAR2) IS l_ln_user_id NUMBER := fnd_global. l_ln_responsibility_id . conc_req_id = NULL WHERE processing_status = 'V'.apps_initialize(l_ln_user_id. BEGIN fnd_file. 'p_commit:' || p_commit).LOG.PUT_LINE(fnd_file. l_commit VARCHAR2(3) := p_commit.PUT_LINE(fnd_file.prog_appl_id. END IF.

l_commit). processing_status = 'E' WHERE rowid = p_rowid.date_ef fective_name. --xx_grades_output_report_prc(l_request_id.insert_error_message_prc(cur_pos_val_rec. UPDATE xx_hr_positions_stg SET creation_date = sysdate.VALUE('USER_ID').LOG. UPDATE xx_hr_positions_stg SET conc_req_id = l_request_id WHERE processing_status = 'N'. l_commit). last_update_date = sysdate.PUT_LINE(fnd_file. cur_pos_val_rec. fnd_file. 'USER ID: ' || l_ln_user_id || 'RESP ONSIBILITY ID: ' || l_ln_responsibility_id || 'APPLICATION ID: ' || l_ln_applica tion_id).PUT_LINE(fnd_file. BEGIN fnd_file. created_by = v_user_id. last_update_login = v_user_id. l_commit).LOG. p_err_msg IN VARCHAR2) IS v_user_id NUMBER. p_err_msg IN VARCHAR2 . 'FAILURE PROCEDURE').component_name. ------------N for New Records---------*/ fnd_file. xx_per_positions_prc(l_request_id.PUT_LINE(fnd_file. last_updated_by = v_user_id. /*====================================================================== ================== Failure procedure for grades ======================================================================== ================== PROCEDURE xx_per_gradefail_prc(p_rowid IN rowid. COMMIT. 'Error while updating error flag in staging table for rowid' || p_rowid || ' ' || sqlerrm). ------------N for New Records--------- /* UPDATE xx_hr_validgrade_stg SET conc_req_id = l_request_id WHERE processing_status = 'N'.transacti on_id. /*====================================================================== ================== Failure procedure for positions =========================================================================== ===============*/ PROCEDURE xx_per_posfail_prc(p_rowid IN rowid. END xx_load_positions_prc. v_user_id := fnd_profile.xxph_common_dmg_pkg. 'ORACLE ERROR'. EXCEPTION WHEN others THEN -. ''). g_error_msg.LOG. xx_output_report_prc(l_request_id. cur_pos_val_rec. END xx_per_posfail_prc. 'Position'.

. END. EXCEPTION WHEN others THEN fnd_file.LOG.LOG. last_update_login = v_user_id. BEGIN fnd_file. p_commit IN VARCHAR2) IS l_pos_id NUMBER. last_updated_by = v_user_id. processing_status = 'E' WHERE rowid = p_rowid. 'Error While Updating Error Flag in s taging Table for rowid' || p_rowid || ' ' || sqlerrm). last_update_date =SYSDATE. UPDATE xx_hr_validgrade_stg SET creation_date = sysdate. processing_status = 'E' WHERE rowid = p_rowid.PUT_LINE(FND_FILE. p_err_msg IN VARCH AR2) IS v_user_id NUMBER.LOG. 'Failure Procedure'). last_update_login = v_user_id.PUT_LINE(fnd_file.LOG. last_update_date = sysdate. END.VALUE('USER_ID').PUT_LINE(FND_FILE. UPDATE xx_reppos_stg SET creation_date = SYSDATE. 'Error While Updating Error Flag in staging Table for rowid' || p_rowid || ' ' || sqlerrm).VALUE('USER_ID').) IS v_user_id NUMBER. v_user_id := fnd_profile. v_user_id := fnd_profile. created_by = v_user_id. 'Failure Procedure'). created_by = v_user_id. BEGIN FND_FILE.*/ /*===================================================================== ================ Loading Hierarchy and Reporting information ======================================================================= ================*/ /* PROCEDURE xx_per_hierarchies_prc(p_request_id IN NUMBER. last_updated_by = v_user_id. */ /* ===================================================================== =================== Failure procedure for hierarchies ========================================================================= =================*/ /* PROCEDURE xx_per_hierfail_prc(p_rowid IN rowid. EXCEPTION WHEN OTHERS THEN FND_FILE.PUT_LINE(fnd_file.

LOG. g_error_msg := NULL. l_pos_structure_version_id NUMBER. l_hierarchycount := NULL. BEGIN IF(cur_reppos_rec. 'position_id:' || l_pos_id). xxrp.PUT_LINE(FND_FILE. l_success := 0. l_commit VARCHAR2(3). l_position_date := NULL. . END IF.*. BEGIN FND_FILE.position_name IS NOT NULL) THEN-----deriving p osition_id from position_name SELECT DISTINCT position_id INTO l_pos_id FROM hr_all_positions_f WHERE name = cur_reppos_rec.rowid FROM xx_reppos_stg xxrp WHERE processing_status = 'V'. l_business_group_id NUMBER. FOR cur_reppos_rec IN cur_reppos_stg LOOP FND_FILE. l_hierarchycount NUMBER. ' start of mandetory validations of r eporting info'). l_object_version_number NUMBER.position_name. l_pos_structure_element_id NUMBER. --l_effective_start_date DATE.LOG.rowid FROM xx_reppos_stg xxrp WHERE processing_status = 'N'.PUT_LINE(FND_FILE. l_read := l_read + 1.LOG. l_reppositioncount NUMBER. l_parent_position_id NUMBER. l_pos_id := NULL. l_success NUMBER.*. l_pos_structure_version_id := NULL. l_parent_position_id := NULL. l_read := 0. l_error NUMBER. '---------------------------------- ----T1'). l_business_group_id := NULL. xxrp. l_reppositioncount := NULL. CURSOR cur_reppos_stg IS SELECT xxrp. CURSOR cur_reppos_ins IS SELECT xxrp.PUT_LINE(FND_FILE. l_position_date DATE. l_read NUMBER. FND_FILE. l_commit := p_commit. l_error := 0. l_object_version_number := NULL. l_pos_structure_element_id := NULL.

heirarchy IS NULL) THEN ------checking for mandetory column hierarchy .PUT_LINE(FND_FILE. FND_FILE. cur_reppos_rec. 'No position exists with this n ame to attach reporting position').LOG. cur_reppos_rec. 'Validation'. 'OTHER ERROR IN FINDING IN POSI TION' || sqlerrm). ''). '').LOG.position_name.position_name.LOG. xx_per_hierfail_prc(cur_reppos_rec. 'position_name'. END IF.tran saction_id. FND_FILE. FND_FILE.rowid. g_error_msg). 'Validation'. WHEN TOO_MANY_ROWS THEN g_error_msg := 'TOO MANY DATA FOR POSITION_DATE'. 'TOO MANY DATA FOR POSITION').component_name.insert_error_message_prc(cur_reppos_rec.LOG.tran saction_id. cur_reppos_rec .rowid.insert_error_message_prc(cur_reppos_rec.position_name. ''). ''). xxph_common_dmg_pkg. 'position_name'. END. cur_reppos_rec . xx_per_hierfail_prc(cur_reppos_rec.position_name. cur_reppos_rec . g_error_msg).PUT_LINE(FND_FILE. cur_reppos_rec. 'TOO MANY DATA FOR POSITION_DATE' ). BEGIN IF(cur_reppos_rec.tran saction_id.rowid. FND_FILE.PUT_LINE(FND_FILE. BEGIN IF(cur_reppos_rec. xx_per_hierfail_prc(cur_reppos_rec. g_error_msg). 'position_name'. xxph_common_dmg_pkg.tran saction_id.component_name. cur_reppos_rec.position_name IS NOT NULL AND l_pos_id IS NOT NULL) THEN SELECT DISTINCT effective_start_date INTO l_position_date FROM hr_all_positions_f WHERE name = cur_reppos_rec.component_name. EXCEPTION WHEN NO_DATA_FOUND THEN g_error_msg := 'NO DATE EXISTS FOR THIS POSITION'. ''). g_error_msg.insert_error_message_prc(cur_reppos_rec. FND_FILE.PUT_LINE(FND_FILE. g_error_msg).tran saction_id. xxph_common_dmg_pkg. g_error_msg. g_error_msg). 'Validation'.insert_error_message_prc(cur_reppos_rec. g_error_msg. 'Validation'. xx_per_hierfail_prc(cur_reppos_rec. EXCEPTION WHEN NO_DATA_FOUND THEN g_error_msg := 'No position exists with this name to attach repo rting position'. xxph_common_dmg_pkg. 'Date of position'. WHEN TOO_MANY_ROWS THEN g_error_msg := 'TOO MANY DATA FOR POSITION'.LOG.PUT_LINE(FND_FILE. 'NO DATE EXISTS FOR THIS POSITION ' || sqlerrm). xxph_common_dmg_pkg. xx_per_hierfail_prc(cur_reppos_rec. WHEN OTHERS THEN g_error_msg := 'OTHER ERROR IN FINDING IN POSITION'. END. 'Validation'.component_name.rowid. g_error_msg. cur_reppos_rec .component_name.insert_error_message_prc(cur_reppos_rec. 'position_name'. l_position_ date. cur_reppos_rec.rowid. g_error_msg.position_name.

BEGIN IF(cur_reppos_rec. 'v_business_group_id :' || l_bu siness_group_id). g_error_msg). ' MISCELLANEOUS ERROR IN FINDING HEIRARCHY' || sqlerrm). 'TOO MANY ROWS FOR HEIRARCHY NAME '). ELSE SELECT DISTINCT ppsv. xx_per_hierfail_prc(cur_reppos_rec. WHEN TOO_MANY_ROWS THEN g_error_msg := 'TOO MANY ROWS FOR HEIRARCHY NAME'.insert_error_message_prc(cur_reppos_rec. FND_FILE. per_position_structures pps WHERE pps.component_name. FND_FILE. 'REPORTING HIERARCHY DO NOT EXI ST'). cur_reppos_rec.PUT_LINE(FND_FILE.LOG.rowid. END IF.PUT_LINE(FND_FILE.businessgroup_id pps.LOG. 'Validation'. cur_reppos_rec.LOG. FND_FILE. FND_FILE.tr . cur_reppos_rec.LOG.position_structure_id = ppsv. cur_reppos_rec. cur_reppos_rec. g_error_msg.rowid. xx_per_hierfail_prc(cur_reppos_rec. 'HEIRARCHY'. END. g_error_msg. cur_reppos_rec.hei rarchy. WHEN OTHERS THEN g_error_msg := 'MISCELLANEOUS ERROR IN FINDING HEIRARCHY'.LOG.position_structure_id AND pps.insert_error_message_prc(cur_reppos_rec. 'Validation'.component_name. ''). '').heirarchy. 'HEIRARCHY'.heirarchy).component_name. 'Data'.PUT_LINE(FND_FILE. xxph_common_dmg_pkg. FND_FILE.PUT_LINE(FND_FILE. g_error_msg).h eirarchy. g_error_msg).name = cur_reppos_rec.PUT_LINE(FND_FILE. l_business_group_id FROM per_pos_structure_versions ppsv.tran saction_id. g_error_msg.reporting_to_position IS NULL) THEN------check ing mandetory column reportingposition g_error_msg := 'REPORTING TO POSITION DO NOT EXIST'. g_error_msg). '').insert_error_message_prc(cur_reppos_rec.tr ansaction_id. FND_FILE.hei rarchy. 'HEIRARCHY'. xx_per_hierfail_prc(cur_reppos_rec.PUT_LINE(FND_FILE. xxph_common_dmg_pkg. 'NO HEIRARCHY EXISTS WITH THIS NA ME'). xx_per_hierfail_prc(cur_reppos_rec. 'v_pos_structure_version_id:' | | l_pos_structure_version_id). EXCEPTION WHEN NO_DATA_FOUND THEN g_error_msg := 'NO HEIRARCHY EXISTS WITH THIS NAME'.component_name. xxph_common_dmg_pkg.LOG.hei rarchy. g_error_msg).LOG. xxph_common_dmg_pkg.PUT_LINE(FND_FILE. g_error_msg. '').pos_structure_version_id.insert_error_message_prc(cur_reppos_rec. 'herarchy name:' || cur_reppos_ rec. xx_per_hierfail_prc(cur_reppos_rec.rowid. cur_reppos_rec. g_error_msg := 'REPORTING HIERARCHY DO NOT EXIST'.business_group_id INTO l_pos_structure_version_id. 'HEIRARCHY'.rowid. 'Validation'.tran saction_id.rowid. xxph_common_dmg_pkg.tran saction_id. cur_reppos_rec. FND_FILE.insert_error_message_prc(cur_reppos_rec. ----deriving version_id.

g_error_msg.Same Hier archy cannot exist more than once for position'.tran saction_id.reporting_to_position. ELSE SELECT DISTINCT position_id ------deriving parentposition_id INTO l_parent_position_id FROM hr_all_positions_f WHERE name = cur_reppos_rec. FND_FILE. ''). END IF. WHEN TOO_MANY_ROWS THEN g_error_msg := 'TOO MANY ROWS FOR REPORTING TO POSITION '. g_error_msg. FND_FILE. g_error_msg.position_name AND processing_status IN('N'.PUT_LINE(FND_FILE.PUT_LINE(FND_FILE. cur_reppos_rec.PUT_LINE(FND_FILE. cur_re ppos_rec.hei rarchy. 'reporting_to_position'.rowid. cur_reppos_rec. ''). WHEN OTHERS THEN g_error_msg := 'MISCELLANEOUS ERROR REPORTING TO POSITION '. 'reporting_to_position'. xx_per_hierfail_prc(cur_reppos_rec. 'reporting_to_position'.rowid. cur_ reppos_rec. 'reporting_to_position'.ansaction_id. 'parent_position_id:' || l_pare nt_position_id).insert_error_message_prc(cur_reppos_rec. cur_reppos_rec. 'P').reporting_to_position.rowid.LOG.tran saction_id..PUT_LINE(FND_FILE. cur_reppos_rec. g_error_msg).PUT_LINE(FND_FILE. 'Data'. xxph_common_dmg_pkg. 'REPORTING TO POSITION DOES NOT E XIST WITH THIS NAME'). xx_per_hierfail_prc(cur_reppos_rec.component_name. FND_FILE. xxph_common_dmg_pkg. xx_per_hierfail_prc(cur_reppos_rec.Hierarchy already Exist.insert_error_message_prc(cur_reppos_rec.reporting_to_position. ' MISCELLANEOUS ERROR REPORTING T O POSITION' || sqlerrm). 'REPORTING TO POSITION DO NOT E XIST').. ''). cur_reppos_rec. xxph_common_dmg_pkg.. 'Data'. 'Data'.. cur_re ppos_rec. SELECT COUNT(1) INTO l_hierarchycount FROM xxph.LOG.component_name. g_error_msg). EXCEPTION WHEN NO_DATA_FOUND THEN g_error_msg := 'REPORTING TO POSITION DOES NOT EXIST WITH THIS N AME'. 'Data'.insert_error_message_prc(cur_reppos_rec..xx_reppos_stg WHERE heirarchy = cur_reppos_rec.component_name. END. 'HEIRARCHY'.LOG.insert_error_message_prc(cur_reppos_rec. cur_re ppos_rec.. FND_FILE. g_error_msg. '').component_name. xx_per_hierfail_prc(cur_reppos_rec.rowid. FND_FILE.tran saction_id.reporting_to_position. 'Validation'. g_error_msg).heirarchy AND position_name = cur_reppos_rec. g_error_msg). '')..reporting_to_position.tran saction_id. g_error_msg.. xxph_common_dmg_pkg. cur_reppos_rec.LOG.LOG. IF(l_hierarchycount > 1) THEN g_error_msg := 'ERRROR.component_name. 'TOO MANY ROWS FOR REPORTING TO POSITION'). .

--V fro Validate Records ELSE UPDATE xxph..heirarchy AND reporting_to_position = cur_reppos_rec. 'Validations Over' || g_error_msg). xxph_common_dmg_pkg. FND_FILE. p_hr_installed => 'I'...PUT_LINE(FND_FILE.. p_parent_position_id => l_parent_position_id.. ''). SELECT COUNT(1) INTO l_reppositioncount FROM xxph. g_error_msg.reporting_to_position..LOG..xx_reppos_stg WHERE heirarchy = cur_reppos_rec. END IF.. 'updating processing status:' || cu r_reppos_rec....rowid..Reporting to posi tion already Exist.PUT_LINE(FND_FILE.LOG.xx_reppos_stg SET processing_status = 'V' WHERE processing_status = 'N' AND rowid = cur_reppos_rec.rowid.. 'start of insertion').. FND_FILE. IF(l_hierarchycount > 1) THEN g_error_msg := 'ERRROR.. cur_reppos_rec.Same Hierarchy cannot have more than one reporting position') ..create_pos_hierarchy_ele(p_validate => FALSE.insert_error_message_prc(cur_reppos_rec.PUT_LINE(FND_FILE... IF g_error_msg IS NULL THEN UPDATE xxph. p_effective_date => l_position_date.LOG.PUT_LINE(FND_FILE. cur_re ppos_rec. p_pos_structure_version_id => l_pos_structure_version_id.LOG. 'ERRROR.position_name AND processing_status IN('N'. 'Data'..Reporting to position already Exi st. 'Validations Over' || sqlerrm). p_business_group_id => l_business_group_id. xx_per_hierfail_prc(cur_reppos_rec. FND_FILE. IF l_commit = 'YES' THEN IF g_error_msg IS NULL THEN BEGIN FND_FILE.PUT_LINE(FND_FILE.Hierarchy already Exist..LOG. g_error_msg).tran saction_id. FND_FILE..reporting_to_position AND position_name = cur_reppos_rec. END IF.component_name.Same Hierarchy cannot have more than one reporting position'.processing_status). 'ERRROR.xx_reppos_stg SET processing_status = 'E' WHERE processing_status = 'N' AND rowid = cur_reppos_rec.. FND_FILE.Same Hierarchy cannot exist more than once'). 'P'). 'reporting_to_position'.rowid..LOG.PUT_LINE(FND_FILE. . hr_pos_hierarchy_ele_api. p_subordinate_position_id => l_pos_id. END IF..

.component_name. 'Total no of records errored in repor ting info:' || l_error). END IF.xx_reppos_stg SET processing_status = 'P' WHERE processing_status = 'V' AND rowid = cur_reppos_rec.PUT_LINE(FND_FILE.PUT_LINE(FND_FILE. COMMIT.PUT_LINE(FND_FILE. ''). l_ln_application_id). /*==================================================================== ========================= Main Procedure For Hierarchies ================================================================== ==========================*/ /* PROCEDURE xx_load_poshier_prc(errbuf OUT VARCHAR2. l_ln_responsibility_id NUMBER := fnd_global. l_error := l_read -l_success. IF g_error_msg IS NULL THEN UPDATE xxph. p_object_version_number => l_object_version_number). g_error_msg. xxph_common_dmg_pkg.resp_id. l_ln_application_id NUMBER := fnd_global. transaction_id. p_commit IN VARCHAR2) IS l_ln_user_id NUMBER := fnd_global.LOG.PUT_LINE(FND_FILE. FND_FILE.LOG.insert_error_message_prc(cur_reppos_rec. g_error_msg).user_id. 'position_name'. EXCEPTION WHEN OTHERS THEN g_error_msg := 'API FAILED WHEN INSERTING REPORTING_INFORMAT ION:'||SQLERRM. l_success := l_success + 1. l_request_id NUMBER := fnd_global. retcode OUT NUM BER.apps_initialize(l_ln_user_id. l_ln_responsibility_id . l_commit VARCHAR2(3) := p_commit. END xx_per_hierarchies_prc. END IF.prog_appl_id. FND_FILE.position_name. 'Total no of records in reporting inf o:' || l_read). END LOOP. FND_FILE.LOG. 'ORACLE ERROR'. xx_per_hierfail_prc(cur_reppos_rec.LOG. 'API FAILED WHEN INSERTING RE PORTING_INFORMATION' || sqlerrm). cur_reppos _rec.conc_request_id. FND_FILE.rowid. END.rowid. BEGIN ---fnd_global. cur_reppos_rec. --P for processed Records END IF. p_pos_structure_element_id => l_pos_structure_element_id. 'Total no of records processed in rep orting info:' || l_success).

l_commit). xx_per_hierarchies_prc(l_request_id.conc_req_id = p_conc_req_id. UPDATE xxph. COMMIT.xx_reppos_stg SET conc_req_id = l_request_id WHERE processing_status = 'N'. xx_hier_output_report_prc(l_request_id.*/ /*===================================================================== ====================== To Develop the error Report of positions ======================================================================= =========================*/ PROCEDURE xx_output_report_prc(p_request_id IN NUMBER. IF(l_commit = 'YES') THEN UPDATE xxph.xx_hr_positions_stg xxvp. xxvp.transaction_id = xxe.LOG.date_effective_name.LOG. COMMIT. p_commit IN VARCHA R2) IS --cursor to fetch all the valid records processed through this request CURSOR cur_valid_positions(p_conc_req_id NUMBER) IS SELECT xxvp.processing_status = 'V' AND xxvp. END xx_load_poshier_prc. xxe.rowid FROM xxph.PUT_LINE(FND_FILE. 'p_commit:' || p_commit).LOG.xx_hr_positions_stg xxvp WHERE xxvp.error_value.conc_req_id = p_conc_req_id. FND_FILE.error_messg FROM xxph. FND_FILE. xxe. UPDATE xxph. xxe.xx_reppos_stg SET conc_req_id = NULL WHERE processing_status = 'V'.component_name = xxe.transaction_id AND xxvp.*. 'USER ID: ' || l_ln_user_id || 'RESPON SIBILITY ID: ' || l_ln_responsibility_id || 'APPLICATION ID: ' || l_ln_applicati on_id). xx_ph_all_errors xxe WHERE xxvp.error_type.component_name AND xxe. END IF.PUT_LINE(FND_FILE.xx_reppos_stg SET processing_status = 'N' WHERE processing_status = 'V'.error_column. ------------N for New Records--------- FND_FILE. xxe. .PUT_LINE(FND_FILE. 'l_commit:' || l_commit). --cursor to fetch all the error records obtained through this request CURSOR cur_error_records(p_conc_req_id NUMBER) IS SELECT xxvp. l_commit).

'P_Request_id:' || p_reques t_id).transaction_id.OUTPUT.PUT_LINE(fnd_file. rpad(nvl('SAP_Position_name'. ' ') || . valid_positions_rec. END IF. t_count_records NUMBER. ' '). rpad(nvl('================='. ' ').rowid. ' ') || CHR(9) || rpad(nvl('Error_Value'. t_success_records NUMBER. 25.xx_hr_positions_stg SET processing_status = 'E' WHERE rowid = valid_positions_rec. 'error report for posit ions'||SQLERRM. ' '). 'POSITION_NAME'. ' '). ' '). ' ') || CHR(9) || rpad(nvl('Error_Column'. BEGIN IF(p_commit = 'YES') THEN FOR valid_positions_rec IN cur_valid_positions(p_request_id) LOOP --fnd_file. vali d_positions_rec. NULL). END LOOP. ' '). 17.component_name. ' ') || CHR(9) || rpad(nvl('Error_Message'. ' ') || CHR(9) || rpad(nvl('============'. --TO insert error message into error table xxph_common_dmg_pkg. ' ')). IF(t_count = 1) THEN /* Update the staging table with processed status for records t hat are present in standard table*/ UPDATE xx_hr_positions_stg SET processing_status = 'P' WHERE rowid = valid_positions_rec. 25.insert_error_message_prc(valid_positions_rec . t_count NUMBER.PUT_LINE(fnd_file.OUTPUT. 70.date_effective_name. fnd_file. COMMIT. 70. 100. fnd_file. t_error_records NUMBER.PUT_LINE(fnd_file.OUTPUT. END IF.date_effective_name. 30. --To check whether the record exists in standard Table SELECT COUNT(1) INTO t_count FROM hr_all_positions_f WHERE name = valid_positions_rec. END IF. IF(t_count = 0) THEN /* Update the staging table with error status for records that are not present in standard table */ UPDATE xxph. ' '). ' ') || CHR(9) || rpad(nvl('Er ror_Record_Type'.rowid. 'ORACLE_ERROR'.

' '). ' '). 17.OUTPUT. END IF. 'Total Records that are Valid ' || t_success_records).PUT_LINE(fnd_file. ' ').PUT_LINE(fnd_file. SELECT COUNT(1) INTO t_error_records FROM xx_hr_positions_stg xxvp WHERE xxvp. ' ') || CHR(9) || rpad(nvl(error_records_rec. 30. ' '). fnd_file. fnd_file.OUTPUT.error_type.OUTPUT. 100. 'P_Request_id:' || p_request_id). IF(p_commit = 'YES') THEN SELECT COUNT(1) INTO t_success_records FROM xx_hr_positions_stg xxvp WHERE xxvp. END xx_output_report_prc.date _effective_name. ' ') || CHR(9) || rpad(nvl(error_records_rec.PUT_LINE(fnd_file. ' ')). SELECT COUNT(1) INTO t_count_records FROM xx_hr_positions_stg xxvp WHERE xxvp.OUTPUT. rpad(nvl(error_records_rec.OUTPUT. END IF.conc_req_id = p_request_id AND processing_status = 'V'.PUT_LINE(fnd_file. 17.conc_req_id = p_request_id. ' ') || CHR(9) || rpad(nvl('============='.PUT_LINE(fnd_file.er ror_column. 'Total Records Processed with Err or ' || t_error_records).PUT_LINE(fnd_file. ' '). 25. ' ')). ' '). fnd_file.PUT_LINE(fnd_file. 70. 100.CHR(9) || rpad(nvl('==========='.OUTPUT. ' ') || CHR(9) || rpad(nvl(error_records_rec.error_v alue.OUTPUT.error_messg. fnd_file. ' ') || CHR(9) || rpad(nvl('== ==============='. ' '). 30. 'Total Records Processed ' || t_c ount_records). ' ') || CHR(9) || rpad(nvl(error_records_rec. IF(p_commit = 'NO') THEN SELECT COUNT(1) INTO t_success_records FROM xx_hr_positions_stg xxvp WHERE xxvp. 'Total Records Processed Sucess fully ' || t_success_records). ' ').conc_req_id = p_request_id AND processing_status = 'E'. /* ===================================================================== ====================== . fnd_file. END LOOP. '================================ ==============='). FOR error_records_rec IN cur_error_records(p_request_id) LOOP fnd_file.conc_req_id = p_request_id AND processing_status = 'P'. fnd_file.

xxe.error_column. --cursor to fetch all the error records obtained through this request CURSOR cur_grades_error_records(p_conc_req_id NUMBER) IS SELECT xxvg.error_value.rowid.rowid FROM xxph.transaction_id = xxe. To Develop the error Report of grades ==================================================================== ============================ PROCEDURE xx_grades_output_report_prc(p_request_id IN NUMBER. l_grdcount NUMBER.component_name AND xxe. BEGIN IF(p_commit = 'YES') THEN FOR valid_grades_rec IN cur_valid_grades(p_request_id) LOOP --To check whether the record exists in standard Table SELECT COUNT(1) INTO l_grdcount FROM per_valid_grades WHERE position_id IN (SELECT position_id FROM hr_all_positions_f WHERE name = valid_grades_rec.valid_grade.component_name = xxe.xx_hr_validgrade_stg xxvg.*. p_co mmit IN VARCHAR2) IS --cursor to fetch all the valid records processed through this request CURSOR cur_valid_grades(p_conc_req_id NUMBER) IS SELECT xxvg.position_name) . --TO insert error message into error table . xxe.xx_hr_validgrade_stg SET processing_status = 'E' WHERE rowid = valid_grades_rec.processing_status = 'V' AND xxvg. xxe.xx_hr_validgrade_stg xxvg WHERE xxvg. l_grdsuccess_records NUMBER.conc_req_id = p_conc_req_id. xx_ph_all_errors xxe WHERE xxvg.error_messg FROM xxph. l_grdcount_records NUMBER.conc_req_id = p_conc_req_id. l_grderror_records NUMBER. xxvg.error_type. IF(l_grdcount = 0) THEN /* Update the staging table with error status for records that are not present in standard table */ /* UPDATE xxph.transaction_id AND xxvg. xxe.

IF(p_commit = 'YES') THEN SELECT COUNT(1) INTO l_grdsuccess_records FROM xx_hr_validgrade_stg xxvg WHERE xxvg. xxph_common_dmg_pkg.PUT_LINE(fnd_file. 'error report for grades'. 50. SELECT COUNT(1) INTO l_grdcount_records FROM xx_hr_validgrade_stg xxvg WHERE xxvg.Update the staging table with processed status for records t hat are --present in standard table UPDATE xxph.error_type. 'ORACLE_ERROR'. ' ') || CHR(9) || 'Error_Column' || CHR(9) || rpad('Error_Value'. ELSE SELECT COUNT(1) INTO l_grdsuccess_records FROM xx_hr_validgrade_stg xxvg WHERE xxvg.PUT_LINE(fnd_file.conc_req_id = p_request_id AND processing_status = 'P'. valid_grades _rec. 100.valid_grade. ' ') || CHR(9) || rpad(error_gradesrecords_rec. END IF.rowid.error_messg.OUTPUT. rpad(error_gradesrecords_rec. 30. rpad('SAP_Grade_name'. COMMIT. 30.insert_error_message_prc(valid_grades_rec. 50.OUTPUT.xx_hr_validgrade_stg SET processing_status = 'P' WHERE rowid = valid_grades_rec. ' ') || CHR(9) || rpad('Error_Record_Type'. 'Total Records Processed ' || l_g rdcount_records). ' ') || CHR(9) || rpad(error_gradesrecords_rec.component_name. NULL). fnd_file. ' ')).OUTPUT. 100. 30. ' ') || CHR(9) || rpad('Error_Messag e'. 'Valid_grade'. fnd_file.conc_req_id = p_request_id . 50.error_value.error_column. valid_grades_rec.conc_req_id = p_request_id. END IF. fnd_file.PUT_LINE(fnd_file.tr ansaction_id. ' ') || CHR(9) || rpad(error_gradesrecords_rec. END LOOP.OUTPUT. 30. ' ') || CHR(9) || rpad(error_gradesrecords_rec. END LOOP. ' ')). 'Total Records Processed Sucess fully ' || l_grdsuccess_records).va lid_grade. IF(l_grdcount = 1) THEN -. END IF. FOR error_gradesrecords_rec IN cur_grades_error_records(p_request_id) LOOP fnd_file.PUT_LINE(fnd_file.

p_commi t IN VARCHAR2) IS --cursor to fetch all the valid records processed through this request CURSOR cur_valid_hiers(p_conc_req_id NUMBER) IS SELECT xxvh. xxvh.component_name = xxe.processing_status = 'V' AND xxvh.transaction_id = xxe.PUT_LINE(fnd_file.OUTPUT.*. fnd_file.reporting_to_position. /*====================================================================== ===================== To Develop the error Report of hierarchies ======================================================================== ========================*/ /*PROCEDURE xx_hier_output_report_prc(p_request_id IN NUMBER. END xx_grades_output_report_prc. 'Total Records Processed with Err or ' || l_grderror_records).PUT_LINE(fnd_file. l_hiercount NUMBER. xx_ph_all_errors xxe WHERE xxvh.error_value. xxe. xxe. xxvh.xx_reppos_stg xxvh.heirarchy.error_type. l_hiererror_records NUMBER.component_name AND xxe. l_hiercount_records NUMBER. xxvh. l_hiersuccess_records NUMBER. BEGIN IF(p_commit = 'YES') THEN FOR valid_hier_rec IN cur_valid_hiers(p_request_id) LOOP . fnd_file. xxe.error_column.error_messg FROM xxph.conc_req_id = p_conc_req_id.transaction_id AND xxvh.conc_req_id = p_request_id AND processing_status = 'E'. SELECT COUNT(1) INTO l_grderror_records FROM xx_hr_validgrade_stg xxvg WHERE xxvg.position_name. 'Total Records Valid Sucessfull y ' || l_grdsuccess_records).OUTPUT.conc_req_id = p_conc_req_id. --cursor to fetch all the error records obtained through this request CURSOR cur_hier_error_records(p_conc_req_id NUMBER) IS SELECT xxvh.xx_reppos_stg xxvh WHERE xxvh.rowid FROM xxph. xxe. AND processing_status = 'V'. END IF.

50.PUT_LINE(FND_FILE.error_type.insert_error_message_prc(valid_hier_rec.' ') || CHR(9) || RPAD( NVL('SAP_ReportingPosition_Name'. 'valid_ hier_rec.rowid.component_name.' ') || CHR(9) || RPAD(NVL(error_hierrecords_rec. COMMIT. ' ').rowid.' ') || CHR(9) || RPAD(NVL('Error_Message'.Update the staging table with processed status for records that are --present in standard table UPDATE xxph.reporting_to_position.50.' ').' ') || CHR(9) || RPAD(NVL('Error_Value'.' ').50.' ') || CHR(9) || RPAD(NVL( .' '). END IF. END LOOP. --TO insert error message into error table xxph_common_dmg_pkg. END IF.' '). --To check whether the record exists in standard Table SELECT COUNT(1) INTO l_hiercount FROM per_pos_structure_elements WHERE parent_position_id IN (SELECT position_id FROM hr_all_positions_f WHERE name = valid_hier_rec.' ').' ').' ').' ') || CHR(9) ||RPAD(NVL(error_hierrecords_rec. 'error report for hierarchies'. FOR error_hierrecords_rec IN cur_hier_error_records(p_request_id) LOOP FND_FILE.----------'.70.heirarchy.p osition_name.50.' ') || CHR(9) || RPAD(NVL('SAP_Hierarchy'. FND_FILE. IF(l_hiercount = 1) THEN -.50.' ' ) || CHR(9) || RPAD(NVL(error_hierrecords_rec.70.50.' ').xx_reppos_stg SET processing_status = 'P' WHERE rowid = valid_hier_rec.30.error_value.50.' ').30.OUTPUT.xx_reppos_stg SET processing_status = 'E' WHERE rowid = valid_hier_rec.reporting_to_position) . valid_hier_rec. IF(l_hiercount = 0) THEN /* Update the staging table with error status for records tha t are not present in standard table */ /* UPDATE xxph.RPAD(NVL(error_hierrecords_rec. NULL ).PUT_LINE(FND_FILE.50. RPAD(NVL('SAP_Position_Name'.' ') || CHR(9) || RP AD(NVL('Error_Record_Type'.' ') || CHR(9) || RPAD(NVL('Error_Colum n'.' ') || CHR(9) || RPAD(NVL(error_hierrecords_rec. END IF. 'Position Hierarchy'.' ').50.tr ansaction_id. 'ORACLE_ERROR'.OUTPUT.' ') || CHR(9) || RPAD(NVL(error_hierrecords_rec.error_column.' ')).' ').' ').

' '). ELSE SELECT COUNT(1) INTO l_hiersuccess_records FROM xx_reppos_stg xxvh WHERE xxvh.conc_req_id = p_request_id. l_vg_count NUMBER. l_ln_application_id NUMBER := fnd_global. l_login_id NUMBER.OUTPUT. retcode OUT NUMBER.OUTPUT.resp_id.PUT_LINE(FND_FILE. FND_FILE. SELECT COUNT(1) INTO l_hiercount_records FROM xx_reppos_stg xxvh WHERE xxvh. 'Total Records Processed with E rror ' || l_hiererror_records).conc_req_id = p_request_id AND processing_status = 'P'.prog_appl_id. l_pos_count NUMBER. BEGIN . IF(p_commit = 'YES') THEN SELECT COUNT(1) INTO l_hiersuccess_records FROM xx_reppos_stg xxvh WHERE xxvh. FND_FILE.PUT_LINE(FND_FILE.*/ /*===================================================================== ========================== Inserting Data Into Staging Tables ========================================================================== =======================*/ PROCEDURE xx_positions_load_stg_prc(errbuf OUT VARCHAR 2. END LOOP.error_hierrecords_rec.200. l_ln_responsibility_id NUMBER := fnd_global.PUT_LINE(FND_FILE.error_messg.OUTPUT. 'Total Records Valid ' || l_ hiersuccess_records). END IF. p_load_id IN NUMBER. SELECT COUNT(1) INTO l_hiererror_records FROM xx_reppos_stg xxvh WHERE xxvh.conc_req_id = p_request_id AND processing_status = 'E'. FND_FILE. p_vgload_id IN NUMBER) AS l_ln_user_id NUMBER := fnd_global. FND_FILE.user_id. 'Total Records Processed Suce ssfully ' || l_hiersuccess_records).PUT_LINE(FND_FILE. 'Total Records Processed ' || l _hiercount_records). l_request_id NUMBER.OUTPUT.conc_req_id = p_request_id AND processing_status = 'V'. END xx_hier_output_report_prc.' ')).

direct_pa tient_staff. duration_unit. worki ng_hours. headcount.LOG. --attribute33. business_group_ id. conc_req_id) SELECT load_id. permanent _position. salary_basis.nextval. l_login_id := to_number(fnd_profile.PUT_LINE(fnd_file. start_date. processing_status.'). job_band. status. fnd_file. last_update_login. type. position_name. permenant. --attribute40. fnd_file. --attribute31. --attribute37. frequency. -. organization_name.Niraj INSERT INTO xx_hr_positions_stg(batch_id. component_name. NULL.. job_group. payroll. last_updated_by. 'Start Inserting Data ***********'). creation_date. job_band. NULL. --attribute38. NULL. fnd_file.conc_request_id).LOG. headcount. payroll_id. location_id. organization.fnd_global. position_id.LOG. location. NULL. start_date. NULL. fte. date_effective_name. created_by. --attribute34. start_time. fnd_file. fte. --attribute39. --attribute32. seasonal.LOG. last_update_date.l_l n_application_id). payroll. seasonal. job_id.PUT_LINE(fnd_file. 'Loading Data from SAP tables to Ora cle Staging Table. date_effective_name. NULL. end_time. NULL. bargaining_unit.apps_initialize(l_ln_user_id. xx_per_positions_transid_s. '*********************************** ********************************'). entry_grade_id . COMMIT. effective_date_to. . l_request_id := to_number(fnd_global. position_type.VALUE('LOGIN_ID')). position_name. job_group. probation_duration.PUT_LINE(fnd_file. pay_basis_id. /* -. loc ation_name. effective_date_from. transaction_id. availability_status_id. effective_date_from. --attribute36. organization_id. registered_nurse. --attribute35. status. NULL. '*********************************** ********************************').PUT_LINE(fnd_file.. grade.l_ln_responsibility_id.

job_group. NULL. effective_date_from. payroll_id. transaction_id. duration_unit. --attribute37. location_name. effective_date_to. position_type. date_effective_name. availability_status_id. NULL. position_name. l_ln_user_id. 'HR_POSITIONS'. start_time. --attribute38. sysdate. l_request_id FROM ods_sap_hr. NULL. grade. --attribute35. status. --attribute31. l_login_id. NULL. business_group_id. --attribute39. start_date. location_id. */ INSERT INTO xx_hr_positions_stg (batch_id. salary_basis. --attribute34.stg_hr_positiondetails_temp @CRYSTAL WHERE load_id = nvl(p_load_id. organization_id. --attribute33. payroll. working_hours. job_band. sysdate. --attribute32. organization_name. --attribute36. permanent_position. load_id). NULL. 'N'. fte. frequency. . end_time. probation_duration. --attribute40. position_id. job_id. bargaining_unit. seasonal. headcount. l_ln_user_id.

NULL. payroll. NULL. permenant. --attribute38. last_updated_by. seasonal. effective_date_from. shoe_uniform_eligibility. organization. --attribute35. TYPE. NULL. frequency. conc_req_id) SELECT load_id. salary_basis. start_time. status. meal_coupon_eligibility. NULL. --attribute32. location. entry_grade_id. grade. --attribute34. job_group. grade. pay_basis_id. --attribute31. NULL. last_update_login. registered_nurse. created_by. --attribute40. direct_patient_staff. date_effective_name. position_name. duration_unit. NULL. --attribute36. last_update_date. NULL.NEXTVAL. xx_per_positions_transid_s. fte. start_date. probation_duration. NULL. headcount. . working_hours. end_time. salary_basis. --attribute33. job_band. --attribute37. NULL. --attribute39. component_name. NULL. processing_status. creation_date.

l_login_id. --attribute39. --attribute37.PUT_LINE(fnd_file. load_id) AND date_effective_name NOT IN ( SELECT date_e ffective_name FROM xx_hr_po sitions_stg ).LOG.OUTPUT. l_ln_user_id. l_ln_user_id.LOG. duration_unit. --attribute38. --attribute34. transaction_id. 'N'.PUT_LINE(fnd_file. component_name. fnd_file. from_date. to_date. valid_grade. --attribute31. --attribute35. l_request_id FROM ods_sap_hr. frequency.PUT_LINE(fnd_file.conc_req_id = l_request_id. 'HR_POSITIONS'. .PUT_LINE(fnd_file. fnd_file. WHEN others THEN fnd_file. --attribute36. 'No records inserted into the stag ing table in this run' || sqlerrm). 'Number of records successfully inserted into staging table' || ' ' || l_pos_count). EXCEPTION WHEN no_data_found THEN fnd_file. meal_coupon_eligibility. /* INSERT INTO xx_hr_validgrade_stg(batch_id. 'Error while inserting records int o staging table' || sqlerrm). registered_nurse. '============================== ============================================================================'). --attribute33. direct_patient_staff. END. NULL. start_time. end_time.stg_hr_positiondetails_temp @crystal WHERE load_id = nvl(p_load_id. BEGIN SELECT COUNT(1) INTO l_pos_count FROM xx_hr_positions_stg pos WHERE pos. working_hours. probation_duration. SYSDATE.OUTPUT. shoe_uniform_eligibility. position_name. --attribute40. SYSDATE. --attribute32.

creation_date.* processing_status. sysdate. conc_req_id ) SELECT load_id. attribute37. /* attribute31. l_request_id FROM ods_sap_hr. fnd_file. attribute38. WHEN others THEN fnd_file.PUT_LINE(fnd_file.PUT_LINE(fnd_file. EXCEPTION WHEN no_data_found THEN fnd_file. position_name || '.conc_req_id = l_request_id. attribute32. 'Error while inserting records into . created_by. BEGIN SELECT COUNT(1) INTO l_vg_count FROM xx_hr_validgrade_stg vg WHERE vg. END.stg_hr_validgrades_temp @CRYSTAL WHERE load_id = nvl(p_vgload_id. l_login_id. attribute34.LOG. xx_grade_transid_s. COMMIT.nextval. from_date. l_ln_user_id. '============================== ============================================================================'). sysdate.OUTPUT. 'No records inserted into the stag ing table in this run' || sqlerrm). to_date. last_updated_by. attribute40.PUT_LINE(fnd_file. attribute36. attribute35.OUTPUT.' || organization_name. fnd_file. last_update_date. attribute33. 'Number of records successfully inserted into staging table' || ' ' || l_vg_count). l_ln_user_id. load_id).LOG.PUT_LINE(fnd_file.LOG. EXCEPTION WHEN others THEN fnd_file. valid_grade. 'Error while inserting records int o staging table' || sqlerrm).PUT_LINE(fnd_file. attribute39. 'XX_VALID_GRADES'. last_update_login. 'N'.

*/ END xx_positions_load_stg_prc. END xx_per_positions_pkg. / sho err .staging table' || sqlerrm).