XXSDL No Sgwi Payroll Int PKG
XXSDL No Sgwi Payroll Int PKG
XXSDL No Sgwi Payroll Int PKG
--
+==================================================================================
==================================+
-- | HP ENTERPRISE SERVICES INDIA
|
-- |
===================================================================================
================================|
-- | DESCRIPTION : This sql file creates the Package Spec for the providing
handling the Mass Dispute Functionality for Norway |
-- |
|
-- | Version Date Author Brief Description of
Modification |
-- | ======= ====== ========
================================== |
-- | 1.00 01-APR-2020 Nandini Chakrabarti Initial Version
--
+==================================================================================
==================================+
g_request_id NUMBER;
g_user_id NUMBER;
FUNCTION print_nid_dup_det (
per_id NUMBER
) RETURN NUMBER;
FUNCTION validate_dups (
payroll_name VARCHAR2
) RETURN NUMBER;
FUNCTION print_bank_dup_det (
per_id NUMBER
) RETURN NUMBER;
FUNCTION validate_bank_dups (
payroll_name VARCHAR2
) RETURN NUMBER;
FUNCTION check_residential_address (
l_payroll_name VARCHAR2
) RETURN NUMBER;
PROCEDURE xxsdl_no_sgwi_pay_masterdata_p (
p_errbuff OUT NOCOPY VARCHAR2,
p_retcode OUT NOCOPY VARCHAR2,
p_flag IN VARCHAR2,
p_payroll_group IN VARCHAR2,
p_payroll_name IN VARCHAR2,
p_effective_date IN VARCHAR2
-- Removing Paramter p_person_location_type for Global Payroll Project
Commented by Srikkanth M
-- p_person_location_type IN VARCHAR2
);
PROCEDURE xxsdl_no_sgwi_pay_element_p (
p_errbuff OUT NOCOPY VARCHAR2,
p_retcode OUT NOCOPY VARCHAR2,
p_flag IN VARCHAR2,
p_payroll_group IN VARCHAR2,
p_payroll_name IN VARCHAR2,
p_effective_date IN VARCHAR2
-- Removing Paramter p_person_location_type for Global Payroll Project
Commented by Srikkanth M
-- p_person_location_type IN VARCHAR2
);
END xxsdl_no_sgwi_payroll_int_pkg;
/
PROCEDURE log (
p_text VARCHAR2
);
PROCEDURE xxsdl_no_sgwi_pay_masterdata_p (
p_errbuff OUT NOCOPY VARCHAR2,
p_retcode OUT NOCOPY VARCHAR2,
p_flag IN VARCHAR2,
p_payroll_group IN VARCHAR2,
p_payroll_name IN VARCHAR2,
p_effective_date IN VARCHAR2
-- Removing Paramter p_person_location_type for Global Payroll Project
Commented by Srikkanth M
-- p_person_location_type IN VARCHAR2
) IS
l_count NUMBER := 1;
l_file_path VARCHAR2(1000);
l_file_name VARCHAR2(200);
l_file VARCHAR2(100);
l_file_handle utl_file.file_type;
l_file_handle1 utl_file.file_type;
l_instance v$instance.instance_name%TYPE;
l_output VARCHAR2(30000);
l_output1 VARCHAR2(30000);
p_from_date DATE;
p_to_date DATE;
l_from_date DATE;
l_to_date DATE;
q_from_date DATE;
q_to_date DATE;
l_effective_date DATE;
l_payroll_cnt NUMBER := 0;
l_db_name VARCHAR2(20);
l_pay_group VARCHAR2(20);
l_nid_val NUMBER;
l_bank_val NUMBER;
l_val_pay_name VARCHAR2(100);
l_emp_val NUMBER;
CURSOR c1 IS
SELECT DISTINCT
*
FROM
xxsdl_no_sgwi_pay_master_stg
ORDER BY
employee_number,
payroll_leave_date DESC;
CURSOR c_sgwi_payroll (
p_from_date DATE,
p_to_date DATE,
l_from_date DATE,
l_to_date DATE,
q_from_date DATE,
q_to_date DATE,
l_payroll_name VARCHAR2,
l_business_group_id NUMBER,
l_secondary_payroll VARCHAR2,
l_effective_date DATE,
l_payroll_id NUMBER
) IS
SELECT
papf.employee_number,
(
CASE
WHEN (
SELECT
effective_start_date
FROM
per_all_people_f
WHERE
person_id = papf.person_id
AND effective_start_date = (
SELECT
MIN(effective_start_date)
FROM
per_all_people_f
WHERE
person_id = papf.person_id
AND business_group_id = papf.business_group_id
AND employee_number IS NOT NULL
)
AND ( ( nvl(
original_date_of_hire, effective_start_date
) <= q_to_date
AND creation_date BETWEEN l_from_date AND l_to_date
)
OR ( creation_date <= q_to_date
AND nvl(
original_date_of_hire, effective_start_date
) BETWEEN q_from_date AND q_to_date ) )
) IS NOT NULL THEN
'Starter'
/* Starter logic added to identify rehire employees */
/*Added by Rajitha */
WHEN (
SELECT
COUNT(*)
FROM
per_periods_of_service
WHERE
person_id = papf.person_id
) > 1
AND (
SELECT
MAX(date_start)
FROM
per_periods_of_service
WHERE
person_id = papf.person_id
) BETWEEN l_from_date AND l_to_date THEN
'Starter'
/*Leaver logic as per RFCHCM2016033*/
WHEN (
SELECT
actual_termination_date
FROM
per_periods_of_service
WHERE
1 = 1
AND last_update_date BETWEEN l_from_date AND l_to_date
AND actual_termination_date <= l_to_date
AND person_id = papf.person_id
) IS NOT NULL THEN
'Leaver'
WHEN ( ( ppf.payroll_id = (
SELECT
payroll_id
FROM
per_all_assignments_f
WHERE
person_id = papf.person_id
AND primary_flag = 'Y'
AND effective_start_date = (
SELECT
MAX(effective_start_date)
FROM
per_all_assignments_f
WHERE
person_id = papf.person_id
)
AND ( ( effective_start_date <= q_to_date
AND last_update_date BETWEEN l_from_date AND
l_to_date )
OR ( last_update_date <= q_to_date
AND effective_start_date BETWEEN l_from_date AND
l_to_date ) )
) )
AND ( ppf.attribute1 <> (
SELECT
attribute1
FROM
pay_payrolls_f
WHERE
payroll_id IN (
SELECT
payroll_id
FROM
per_all_assignments_f
WHERE
person_id = papf.person_id
AND primary_flag = 'Y'
AND effective_end_date = (
SELECT
MAX(effective_start_date) - 1
FROM
per_all_assignments_f
WHERE
person_id = papf.person_id
)
AND ( ( effective_end_date <= q_to_date
AND last_update_date BETWEEN l_from_date
AND l_to_date )
OR ( last_update_date <= q_to_date
AND effective_end_date BETWEEN
l_from_date AND l_to_date ) )
)
AND trunc(sysdate) BETWEEN effective_start_date AND
effective_end_date
) ) ) THEN
'IN'
ELSE
NULL
END
) starter_or_leaver,
papf.person_id,
papf.business_group_id,
replace(
papf.last_name, ',', NULL
) sur_name,
replace(
papf.middle_names, ',', NULL
) middle_name,
replace(
papf.first_name, ',', NULL
) fornames,
papf.title title,
to_char(
nvl(
papf.original_date_of_hire, papf.start_date
), 'YYYY-MM-DD'
) start_date,
to_char(
papf.date_of_birth, 'YYYY-MM-DD'
) dob,
/*(SELECT proposed_salary_n
FROM per_pay_Proposals
WHERE assignment_id=paaf.assignment_id
AND TRUNC(nvl(to_date(:l_effective_date), sysdate)) BETWEEN
change_date AND NVL(date_to,'31-DEC-4712')
AND approved='Y'
) Annual_Salary,*/
(
CASE
WHEN p_payroll_group IN ( 'AN' ) THEN
( nvl(
(
SELECT
to_char(
e.screen_entry_value
)
FROM
apps.pay_element_entries_f b,
apps.pay_element_links_f c, apps.pay_element_entry_values_f e, apps.
pay_element_types_f_tl f, apps.pay_input_values_f
g
WHERE
1 = 1
AND f.element_name = 'Local Salary Payment'
AND b.assignment_id = paaf.assignment_id
AND b.element_link_id = c.element_link_id
AND c.element_type_id = f.element_type_id
AND g.element_type_id = f.element_type_id
AND f.language = 'US'
AND b.element_entry_id = e.element_entry_id
AND e.screen_entry_value IS NOT NULL
AND trunc(sysdate) BETWEEN b.effective_start_date AND
b.effective_end_date
AND trunc(sysdate) BETWEEN e.effective_start_date AND
e.effective_end_date
AND g.name = 'Currency'
AND g.input_value_id = e.input_value_id
),(substr(
pb.name, - 3
))
) )
ELSE
substr(
pb.name, - 3
)
END
) salary_currency,
--substr(pb.name,-3) Salary_Currency,
nvl(
ppd.segment1, ''
) upn, -- added by Naveed on 05-feb-2019
40 hours_per_week,
replace(
pj.name, '..', NULL
) job_title,
(
SELECT DISTINCT
full_name
FROM
per_all_people_f
WHERE
person_id = paaf.supervisor_id
AND trunc(
nvl(
l_effective_date, sysdate
)
) BETWEEN effective_start_date AND effective_end_date
) line_manager,
paaf.ass_attribute17 fte,
(
SELECT
meaning
FROM
hr_lookups
WHERE
lookup_type = 'EMP_CAT'
AND lookup_code = paaf.employment_category
) parttime_or_fulltime,
(
SELECT
t.description
FROM
fnd_flex_values_tl t,
fnd_flex_values b,
fnd_flex_value_sets s
WHERE
b.flex_value_id = t.flex_value_id
AND b.flex_value_set_id = s.flex_value_set_id
AND t.language = userenv(
'LANG'
)
AND s.flex_value_set_name = 'SDRL_GL_HQ_LEGAL_ENTITY'
AND flex_value = hsc.segment1
) legal,
hsc.segment1 legal_entity_code,
--Replaced hsc.segment1 with
ASS_Attribute under RFC
--
DECODE(ppg.segment2, 'ON', 'Onshore', 'OFF', 'Offshore', NULL) Onshore,
/**** Norway person type OF/ON*** Added by Nandini for Norwagian
Payroll****RITM0174520********/
decode(
ppg.segment2, 'ON', 'Onshore', 'OFF', 'Offshore', NULL
) onshore,/*person_location_type,*/
WHEN
-- Removing Paramter p_person_location_type for Global Payroll
Project Commented by Srikkanth M
-- p_person_location_type
decode(
ppg.segment2, 'ON', 'ONSHORE', 'OFF', 'OFFSHORE', NULL
) IN ( 'ONSHORE' )
AND (
SELECT
COUNT(DISTINCT ppg2.segment2)
FROM
pay_people_groups ppg2,
per_all_assignments_f paaf2
WHERE
paaf2.people_group_id = ppg2.people_group_id
AND paaf2.person_id = paaf.person_id
) > 1 THEN
(
SELECT
to_char(
MIN(paaf1.effective_end_date), 'YYYY-MM-DD'
)
FROM
per_all_assignments_f paaf1,
pay_people_groups ppg1
WHERE
paaf1.people_group_id = ppg1.people_group_id
AND paaf1.person_id = paaf.person_id
AND ppg1.segment2 = 'ON'
AND EXISTS (
SELECT
1
FROM
pay_people_groups ppg2,
per_all_assignments_f paaf2
WHERE
paaf2.people_group_id = ppg2.people_group_id
AND ppg2.segment2 = 'OFF'
AND paaf2.person_id = paaf1.person_id
AND paaf2.effective_start_date <
paaf1.effective_start_date
)
)
WHEN
-- Removing Paramter p_person_location_type for Global Payroll
Project Commented by Srikkanth M
-- p_person_location_type
decode(
ppg.segment2, 'ON', 'ONSHORE', 'OFF', 'OFFSHORE', NULL
) IN ( 'ONSHORE' )
AND (
SELECT
COUNT(DISTINCT ppg2.segment2)
FROM
pay_people_groups ppg2,
per_all_assignments_f paaf2
WHERE
paaf2.people_group_id = ppg2.people_group_id
AND paaf2.person_id = paaf.person_id
) = 1 THEN
(
SELECT
to_char(
MIN(paaf1.effective_start_date), 'YYYY-MM-DD'
)
FROM
per_all_assignments_f paaf1
WHERE
paaf1.person_id = paaf.person_id
AND paaf1.payroll_id = 66
)
ELSE
NULL
END
) off_on_effdt,
--to_char(paaf.effective_start_date, 'YYYY-MM-DD')
off_on_effdt,
haou.name organization,
pcak.segment1 profit_centre,
ppd.segment5 region,
haou.attribute20 rig_name,
ppd.segment7 rig_type,
(
SELECT
location_code
FROM
hr_locations_all
WHERE
location_id = paaf.location_id
) rig_location,
(
SELECT
meaning
FROM
hr_lookups
WHERE
lookup_type = 'EMPLOYEE_CATG'
AND lookup_code = paaf.employee_category
) employee_category,
pg.name grade,
(
SELECT
user_status
FROM
per_assignment_status_types
WHERE
assignment_status_type_id = paaf.assignment_status_type_id
) assignment_status,
hapf.attribute2 job_category,
(
SELECT
ppei1.pei_information1
FROM
per_people_extra_info ppei1
WHERE
ppei1.information_type = 'SG_PASSPORT_INFO'
AND ppei1.person_id = papf.person_id
AND ROWNUM < 2
) passport,
NULL entitlement_daily_rate,
NULL entitlement_hourly_rate,
NULL employment_status,
(
SELECT
meaning
FROM
hr_lookups hl
WHERE
lookup_type = 'NATIONALITY'
AND hl.lookup_code = papf.nationality
) nationality,
papf.national_identifier social_security_number,
nvl(
paaf.ass_attribute26, NULL
) paying_legal_entity,
/**** Norway Legal Entity start date*** Added by Nandini for
Norwagian Payroll****SOW025********/
(
CASE
WHEN ( p_payroll_group IN ( 'NO' ) )
AND hsc.segment1 IN ( '841', '816' ) THEN
(
CASE
WHEN trunc(
nvl(
papf.original_date_of_hire, papf.effective_start_date
)
) >= TO_DATE('01-01-2019', 'mm-dd-yyyy') THEN
to_char(
nvl(
papf.original_date_of_hire, papf.effective_start_date
), 'YYYY-MM-DD'
)
WHEN trunc(
nvl(
papf.original_date_of_hire, papf.effective_start_date
)
) < TO_DATE('01-01-2019', 'mm-dd-yyyy') THEN
(
SELECT
to_char(
MIN(paaf4.effective_start_date), 'YYYY-MM-DD'
)
FROM
per_all_assignments_f paaf4
WHERE
1 = 1--paaf4.payroll_id in (142, 66)
AND paaf4.soft_coding_keyflex_id IN ( 40089, 64, 68,
69, 55089, 325095 )
AND paaf4.person_id = paaf.person_id
AND trunc(
paaf4.effective_start_date
) >= TO_DATE('04-01-2011', 'mm-dd-yyyy')
)
ELSE
NULL
END
)
ELSE
NULL
END
) no_le_st_dt,
-- Added By Anil
ppinf.pei_information16 ach_routing_number,
--ppinf.pei_information4 bank_account_number,
nvl(
ppinf.pei_information6, ppinf.pei_information4
) bank_account_number, -- added as per
RITM0198449
ppinf.pei_information12 bic_swift,
ppinf.pei_information6 iban,
ppinf.pei_information3 payee_name,
(
SELECT
meaning
FROM
hr_lookups hl
WHERE
lookup_type = 'MAR_STATUS'
AND hl.lookup_code = papf.marital_status
) marital_status,
/*(SELECT TO_CHAR (change_date,
'YYYY-MM-DD'
)
FROM per_pay_proposals
WHERE assignment_id = paaf.assignment_id
AND TRUNC (NVL (l_effective_date, SYSDATE))
BETWEEN change_date
AND NVL (date_to, '31-DEC-4712')
AND approved = 'Y') salary_effective_date,*/ -- commented by
Subhashree to add leavers salary for the current month
ELSE
(
SELECT
proposed_salary_n
FROM
per_pay_proposals
WHERE
assignment_id = paaf.assignment_id
AND ( ( trunc(
nvl(
l_effective_date, sysdate
)
) BETWEEN change_date AND nvl(
date_to, '31-DEC-4712'
) )
OR ( ( nvl(
date_to, '31-DEC-4712'
) BETWEEN l_from_date AND l_to_date )
AND date_to = (
SELECT
MAX(date_to)
FROM
per_pay_proposals
WHERE
assignment_id = paaf.assignment_id
)
AND ( pps.actual_termination_date BETWEEN
l_from_date AND l_to_date ) ) )
AND approved = 'Y'
)
END
) annual_salary,
/*(SELECT proposed_salary_n
FROM per_pay_Proposals
WHERE assignment_id=paaf.assignment_id
AND TRUNC(nvl(to_date(:l_effective_date), sysdate))
BETWEEN change_date AND NVL(date_to,'31-DEC-4712')
AND approved='Y'
) Annual_Salary,*/
(
CASE
WHEN p_payroll_group IN ( 'AN' ) THEN
( nvl(
(
SELECT
to_char(
e.screen_entry_value
)
FROM
apps.pay_element_entries_f b,
apps.pay_element_links_f c, apps.pay_element_entry_values_f e, apps.
pay_element_types_f_tl f, apps.pay_input_values_f
g
WHERE
1 = 1
AND f.element_name = 'Local Salary Payment'
AND b.assignment_id = paaf.assignment_id
AND b.element_link_id = c.element_link_id
AND c.element_type_id = f.element_type_id
AND g.element_type_id = f.element_type_id
AND f.language = 'US'
AND b.element_entry_id = e.element_entry_id
AND e.screen_entry_value IS NOT NULL
AND trunc(sysdate) BETWEEN b.effective_start_date AND
b.effective_end_date
AND trunc(sysdate) BETWEEN e.effective_start_date AND
e.effective_end_date
AND g.name = 'Currency'
AND g.input_value_id = e.input_value_id
),(substr(
pb.name, - 3
))
) )
ELSE
substr(
pb.name, - 3
)
END
) salary_currency,
--substr(pb.name,-3) Salary_Currency,
nvl(
ppd.segment1, ''
) upn, -- added by Naveed on 05-feb-2019
40 hours_per_week,
replace(
pj.name, '..', NULL
) job_title,
(
SELECT DISTINCT
full_name
FROM
per_all_people_f
WHERE
person_id = paaf.supervisor_id
AND trunc(
nvl(
l_effective_date, sysdate
)
) BETWEEN effective_start_date AND effective_end_date
) line_manager,
paaf.ass_attribute17 fte,
(
SELECT
meaning
FROM
hr_lookups
WHERE
lookup_type = 'EMP_CAT'
AND lookup_code = paaf.employment_category
) parttime_or_fulltime,
(
SELECT DISTINCT
t.description
FROM
fnd_flex_values_tl t,
fnd_flex_values b,
fnd_flex_value_sets s,
hr_soft_coding_keyflex hsc1,
per_all_assignments_f paaf1
WHERE
b.flex_value_id = t.flex_value_id
AND b.flex_value_set_id = s.flex_value_set_id
AND t.language = userenv(
'LANG'
)
AND s.flex_value_set_name = 'SDRL_GL_HQ_LEGAL_ENTITY'
AND paaf1.soft_coding_keyflex_id = hsc1.soft_coding_keyflex_id
AND trunc(
nvl(
l_effective_date, sysdate
)
) BETWEEN paaf1.effective_start_date AND
paaf1.effective_end_date
-- Added By Subhashree
AND paaf1.person_id = papf.person_id
AND flex_value = hsc1.segment1
AND paaf1.primary_flag = 'Y'
) legal, --Added by pradeep
-- Added By Subhashree
WHEN
-- Removing Paramter p_person_location_type for Global Payroll
Project Commented by Srikkanth M
-- p_person_location_type
decode(
ppg.segment2, 'ON', 'ONSHORE', 'OFF', 'OFFSHORE', NULL
) IN ( 'ONSHORE' )
AND (
SELECT
COUNT(DISTINCT ppg2.segment2)
FROM
pay_people_groups ppg2,
per_all_assignments_f paaf2
WHERE
paaf2.people_group_id = ppg2.people_group_id
AND paaf2.person_id = paaf.person_id
) > 1 THEN
(
SELECT
to_char(
MIN(paaf1.effective_end_date), 'YYYY-MM-DD'
)
FROM
per_all_assignments_f paaf1,
pay_people_groups ppg1
WHERE
paaf1.people_group_id = ppg1.people_group_id
AND paaf1.person_id = paaf.person_id
AND ppg1.segment2 = 'ON'
AND EXISTS (
SELECT
1
FROM
pay_people_groups ppg2,
per_all_assignments_f paaf2
WHERE
paaf2.people_group_id = ppg2.people_group_id
AND ppg2.segment2 = 'OFF'
AND paaf2.person_id = paaf1.person_id
AND paaf2.effective_start_date <
paaf1.effective_start_date
)
)
WHEN
-- Removing Paramter p_person_location_type for Global Payroll
Project Commented by Srikkanth M
-- p_person_location_type
decode(
ppg.segment2, 'ON', 'ONSHORE', 'OFF', 'OFFSHORE', NULL
) IN ( 'ONSHORE' )
AND (
SELECT
COUNT(DISTINCT ppg2.segment2)
FROM
pay_people_groups ppg2,
per_all_assignments_f paaf2
WHERE
paaf2.people_group_id = ppg2.people_group_id
AND paaf2.person_id = paaf.person_id
) = 1 THEN
(
SELECT
to_char(
MIN(paaf1.effective_start_date), 'YYYY-MM-DD'
)
FROM
per_all_assignments_f paaf1
WHERE
paaf1.person_id = paaf.person_id
AND paaf1.payroll_id = 66
)
ELSE
NULL
END
) off_on_effdt,
--to_char(paaf.effective_start_date, 'YYYY-MM-DD')
off_on_effdt,
haou.name organization,
pcak.segment1 profit_centre,
ppd.segment5 region,
haou.attribute20 rig_name,
ppd.segment7 rig_type,
(
SELECT
location_code
FROM
hr_locations_all
WHERE
location_id = paaf.location_id
) rig_location,
(
SELECT
meaning
FROM
hr_lookups
WHERE
lookup_type = 'EMPLOYEE_CATG'
AND lookup_code = paaf.employee_category
) employee_category,
pg.name grade,
(
SELECT
user_status
FROM
per_assignment_status_types
WHERE
assignment_status_type_id = paaf.assignment_status_type_id
) assignment_status,
hapf.attribute2 job_category,
(
SELECT
ppei1.pei_information1
FROM
per_people_extra_info ppei1
WHERE
ppei1.information_type = 'SG_PASSPORT_INFO'
AND ppei1.person_id = papf.person_id
AND ROWNUM < 2
) passport,
NULL entitlement_daily_rate,
NULL entitlement_hourly_rate,
NULL employment_status,
(
SELECT
meaning
FROM
hr_lookups hl
WHERE
lookup_type = 'NATIONALITY'
AND hl.lookup_code = papf.nationality
) nationality,
papf.national_identifier social_security_number,
nvl(
paaf.ass_attribute26, NULL
) paying_legal_entity,
-- Added By Anil
ppinf.pei_information16 ach_routing_number,
--ppinf.pei_information4 bank_account_number,
nvl(
ppinf.pei_information6, ppinf.pei_information4
) bank_account_number, -- added as per
RITM0198449
ppinf.pei_information12 bic_swift,
ppinf.pei_information6 iban,
ppinf.pei_information3 payee_name,
(
SELECT
meaning
FROM
hr_lookups hl
WHERE
lookup_type = 'MAR_STATUS'
AND hl.lookup_code = papf.marital_status
) marital_status,
/*(SELECT TO_CHAR (change_date,
'YYYY-MM-DD'
)
FROM per_pay_proposals
WHERE assignment_id = paaf.assignment_id
AND TRUNC (NVL (l_effective_date, SYSDATE))
BETWEEN change_date
AND NVL (date_to, '31-DEC-4712')
AND approved = 'Y') salary_effective_date,*/ -- commented by
Subhashree to add leavers salary for the current month
ELSE
(
SELECT
proposed_salary_n
FROM
per_pay_proposals
WHERE
assignment_id = paaf.assignment_id
AND ( ( trunc(
nvl(
l_effective_date, sysdate
)
) BETWEEN change_date AND nvl(
date_to, '31-DEC-4712'
) )
OR ( ( nvl(
date_to, '31-DEC-4712'
) BETWEEN l_from_date AND l_to_date )
AND date_to = (
SELECT
MAX(date_to)
FROM
per_pay_proposals
WHERE
assignment_id = paaf.assignment_id
)
AND ( pps.actual_termination_date BETWEEN
l_from_date AND l_to_date ) ) )
AND approved = 'Y'
)
END
) annual_salary,
/*(SELECT proposed_salary_n
FROM per_pay_Proposals
WHERE assignment_id=paaf.assignment_id
AND TRUNC(nvl(to_date(:l_effective_date), sysdate)) BETWEEN
change_date AND NVL(date_to,'31-DEC-4712')
AND approved='Y'
) Annual_Salary,*/
(
CASE
WHEN p_payroll_group IN ( 'AN' ) THEN
( nvl(
(
SELECT
to_char(
e.screen_entry_value
)
FROM
apps.pay_element_entries_f b,
apps.pay_element_links_f c, apps.pay_element_entry_values_f e, apps.
pay_element_types_f_tl f, apps.pay_input_values_f
g
WHERE
1 = 1
AND f.element_name = 'Local Salary Payment'
AND b.assignment_id = paaf.assignment_id
AND b.element_link_id = c.element_link_id
AND c.element_type_id = f.element_type_id
AND g.element_type_id = f.element_type_id
AND f.language = 'US'
AND b.element_entry_id = e.element_entry_id
AND e.screen_entry_value IS NOT NULL
AND trunc(sysdate) BETWEEN b.effective_start_date AND
b.effective_end_date
AND trunc(sysdate) BETWEEN e.effective_start_date AND
e.effective_end_date
AND g.name = 'Currency'
AND g.input_value_id = e.input_value_id
),(substr(
pb.name, - 3
))
) )
ELSE
substr(
pb.name, - 3
)
END
) salary_currency,
--substr(pb.name,-3) Salary_Currency,
nvl(
ppd.segment1, ''
) upn, -- added by Naveed on 05-feb-2019
40 hours_per_week,
replace(
pj.name, '..', NULL
) job_title,
(
SELECT DISTINCT
full_name
FROM
per_all_people_f
WHERE
person_id = paaf.supervisor_id
AND trunc(
nvl(
l_effective_date, sysdate
)
) BETWEEN effective_start_date AND effective_end_date
) line_manager,
paaf.ass_attribute17 fte,
(
SELECT
meaning
FROM
hr_lookups
WHERE
lookup_type = 'EMP_CAT'
AND lookup_code = paaf.employment_category
) parttime_or_fulltime,
(
SELECT
t.description
FROM
fnd_flex_values_tl t,
fnd_flex_values b,
fnd_flex_value_sets s
WHERE
b.flex_value_id = t.flex_value_id
AND b.flex_value_set_id = s.flex_value_set_id
AND t.language = userenv(
'LANG'
)
AND s.flex_value_set_name = 'SDRL_GL_HQ_LEGAL_ENTITY'
AND flex_value = hsc.segment1
) legal,
hsc.segment1,
--DECODE(ppg.segment2, 'ON', 'Onshore', 'OFF',
'Offshore', NULL) Onshore,
WHEN
-- Removing Paramter p_person_location_type for Global Payroll
Project Commented by Srikkanth M
-- p_person_location_type
decode(
ppg.segment2, 'ON', 'ONSHORE', 'OFF', 'OFFSHORE', NULL
) IN ( 'ONSHORE' )
AND (
SELECT
COUNT(DISTINCT ppg2.segment2)
FROM
pay_people_groups ppg2,
per_all_assignments_f paaf2
WHERE
paaf2.people_group_id = ppg2.people_group_id
AND paaf2.person_id = paaf.person_id
) > 1 THEN
(
SELECT
to_char(
MIN(paaf1.effective_end_date), 'YYYY-MM-DD'
)
FROM
per_all_assignments_f paaf1,
pay_people_groups ppg1
WHERE
paaf1.people_group_id = ppg1.people_group_id
AND paaf1.person_id = paaf.person_id
AND ppg1.segment2 = 'ON'
AND EXISTS (
SELECT
1
FROM
pay_people_groups ppg2,
per_all_assignments_f paaf2
WHERE
paaf2.people_group_id = ppg2.people_group_id
AND ppg2.segment2 = 'OFF'
AND paaf2.person_id = paaf1.person_id
AND paaf2.effective_start_date <
paaf1.effective_start_date
)
)
WHEN
-- Removing Paramter p_person_location_type for Global Payroll
Project Commented by Srikkanth M
-- p_person_location_type
decode(
ppg.segment2, 'ON', 'ONSHORE', 'OFF', 'OFFSHORE', NULL
) IN ( 'ONSHORE' )
AND (
SELECT
COUNT(DISTINCT ppg2.segment2)
FROM
pay_people_groups ppg2,
per_all_assignments_f paaf2
WHERE
paaf2.people_group_id = ppg2.people_group_id
AND paaf2.person_id = paaf.person_id
) = 1 THEN
(
SELECT
to_char(
MIN(paaf1.effective_start_date), 'YYYY-MM-DD'
)
FROM
per_all_assignments_f paaf1
WHERE
paaf1.person_id = paaf.person_id
AND paaf1.payroll_id = 66
)
ELSE
NULL
END
) off_on_effdt,
--to_char(paaf.effective_start_date, 'YYYY-MM-DD')
off_on_effdt,
haou.name organization,
pcak.segment1 profit_centre,
ppd.segment5 region,
haou.attribute20 rig_name,
ppd.segment7 rig_type,
(
SELECT
location_code
FROM
hr_locations_all
WHERE
location_id = paaf.location_id
) rig_location,
(
SELECT
meaning
FROM
hr_lookups
WHERE
lookup_type = 'EMPLOYEE_CATG'
AND lookup_code = paaf.employee_category
) employee_category,
pg.name grade,
(
SELECT
user_status
FROM
per_assignment_status_types
WHERE
assignment_status_type_id = paaf.assignment_status_type_id
) assignment_status,
hapf.attribute2 job_category,
(
SELECT
ppei1.pei_information1
FROM
per_people_extra_info ppei1
WHERE
ppei1.information_type = 'SG_PASSPORT_INFO'
AND ppei1.person_id = papf.person_id
AND ROWNUM < 2
) passport,
NULL entitlement_daily_rate,
NULL entitlement_hourly_rate,
NULL employment_status,
(
SELECT
meaning
FROM
hr_lookups hl
WHERE
lookup_type = 'NATIONALITY'
AND hl.lookup_code = papf.nationality
) nationality,
papf.national_identifier social_security_number,
nvl(
paaf.ass_attribute26, NULL
) paying_legal_entity,
-- Added By Anil
ppinf.pei_information16 ach_routing_number,
--ppinf.pei_information4 bank_account_number,
nvl(
ppinf.pei_information6, ppinf.pei_information4
) bank_account_number, -- added as per
RITM0198449
ppinf.pei_information12 bic_swift,
ppinf.pei_information6 iban,
ppinf.pei_information3 payee_name,
(
SELECT
meaning
FROM
hr_lookups hl
WHERE
lookup_type = 'MAR_STATUS'
AND hl.lookup_code = papf.marital_status
) marital_status,
/*(SELECT TO_CHAR (change_date,
'YYYY-MM-DD'
)
FROM per_pay_proposals
WHERE assignment_id = paaf.assignment_id
AND TRUNC (NVL (l_effective_date, SYSDATE))
BETWEEN change_date
AND NVL (date_to, '31-DEC-4712')
AND approved = 'Y') salary_effective_date,*/ -- commented by
Subhashree to add leavers salary for the current month
ELSE
(
SELECT
proposed_salary_n
FROM
per_pay_proposals
WHERE
assignment_id = paaf.assignment_id
AND ( ( trunc(
nvl(
l_effective_date, sysdate
)
) BETWEEN change_date AND nvl(
date_to, '31-DEC-4712'
) )
OR ( ( nvl(
date_to, '31-DEC-4712'
) BETWEEN l_from_date AND l_to_date )
AND date_to = (
SELECT
MAX(date_to)
FROM
per_pay_proposals
WHERE
assignment_id = paaf.assignment_id
)
AND ( pps.actual_termination_date BETWEEN
l_from_date AND l_to_date ) ) )
AND approved = 'Y'
)
END
) annual_salary,
/*(SELECT proposed_salary_n
FROM per_pay_Proposals
WHERE assignment_id=paaf.assignment_id
AND TRUNC(nvl(to_date(:l_effective_date), sysdate)) BETWEEN
change_date AND NVL(date_to,'31-DEC-4712')
AND approved='Y'
) Annual_Salary,*/
(
CASE
WHEN p_payroll_group IN ( 'AN' ) THEN
( nvl(
(
SELECT
to_char(
e.screen_entry_value
)
FROM
apps.pay_element_entries_f b,
apps.pay_element_links_f c, apps.pay_element_entry_values_f e, apps.
pay_element_types_f_tl f, apps.pay_input_values_f
g
WHERE
1 = 1
AND f.element_name = 'Local Salary Payment'
AND b.assignment_id = paaf.assignment_id
AND b.element_link_id = c.element_link_id
AND c.element_type_id = f.element_type_id
AND g.element_type_id = f.element_type_id
AND f.language = 'US'
AND b.element_entry_id = e.element_entry_id
AND e.screen_entry_value IS NOT NULL
AND trunc(sysdate) BETWEEN b.effective_start_date AND
b.effective_end_date
AND trunc(sysdate) BETWEEN e.effective_start_date AND
e.effective_end_date
AND g.name = 'Currency'
AND g.input_value_id = e.input_value_id
),(substr(
pb.name, - 3
))
) )
ELSE
substr(
pb.name, - 3
)
END
) salary_currency,
--substr(pb.name,-3) Salary_Currency,
nvl(
ppd.segment1, ''
) upn, -- added by Naveed on 05-feb-2019
40 hours_per_week,
replace(
pj.name, '..', NULL
) job_title,
(
SELECT DISTINCT
full_name
FROM
per_all_people_f
WHERE
person_id = paaf.supervisor_id
AND trunc(
nvl(
l_effective_date, sysdate
)
) BETWEEN effective_start_date AND effective_end_date
) line_manager,
paaf.ass_attribute17 fte,
(
SELECT
meaning
FROM
hr_lookups
WHERE
lookup_type = 'EMP_CAT'
AND lookup_code = paaf.employment_category
) parttime_or_fulltime,
(
SELECT
t.description
FROM
fnd_flex_values_tl t,
fnd_flex_values b,
fnd_flex_value_sets s
WHERE
b.flex_value_id = t.flex_value_id
AND b.flex_value_set_id = s.flex_value_set_id
AND t.language = userenv(
'LANG'
)
AND s.flex_value_set_name = 'SDRL_GL_HQ_LEGAL_ENTITY'
AND flex_value = hsc.segment1
) legal,
hsc.segment1 legal_entity_code,
--DECODE(ppg.segment2, 'ON',
'Onshore', 'OFF', 'Offshore', NULL) Onshore,
/**** Norway person type OF/ON*** Added by Nandini for Norwagian
Payroll****RITM0174520********/
decode(
ppg.segment2, 'ON', 'Onshore', 'OFF', 'Offshore', NULL
) onshore,/*person_location_type,*/
WHEN
-- Removing Paramter p_person_location_type for Global Payroll
Project Commented by Srikkanth M
-- p_person_location_type
decode(
ppg.segment2, 'ON', 'ONSHORE', 'OFF', 'OFFSHORE', NULL
) IN ( 'ONSHORE' )
AND (
SELECT
COUNT(DISTINCT ppg2.segment2)
FROM
pay_people_groups ppg2,
per_all_assignments_f paaf2
WHERE
paaf2.people_group_id = ppg2.people_group_id
AND paaf2.person_id = paaf.person_id
) > 1 THEN
(
SELECT
to_char(
MIN(paaf1.effective_end_date), 'YYYY-MM-DD'
)
FROM
per_all_assignments_f paaf1,
pay_people_groups ppg1
WHERE
paaf1.people_group_id = ppg1.people_group_id
AND paaf1.person_id = paaf.person_id
AND ppg1.segment2 = 'ON'
AND EXISTS (
SELECT
1
FROM
pay_people_groups ppg2,
per_all_assignments_f paaf2
WHERE
paaf2.people_group_id = ppg2.people_group_id
AND ppg2.segment2 = 'OFF'
AND paaf2.person_id = paaf1.person_id
AND paaf2.effective_start_date <
paaf1.effective_start_date
)
)
WHEN
-- Removing Paramter p_person_location_type for Global Payroll
Project Commented by Srikkanth M
-- p_person_location_type
decode(
ppg.segment2, 'ON', 'ONSHORE', 'OFF', 'OFFSHORE', NULL
) IN ( 'ONSHORE' )
AND (
SELECT
COUNT(DISTINCT ppg2.segment2)
FROM
pay_people_groups ppg2,
per_all_assignments_f paaf2
WHERE
paaf2.people_group_id = ppg2.people_group_id
AND paaf2.person_id = paaf.person_id
) = 1 THEN
(
SELECT
to_char(
MIN(paaf1.effective_start_date), 'YYYY-MM-DD'
)
FROM
per_all_assignments_f paaf1
WHERE
paaf1.person_id = paaf.person_id
AND paaf1.payroll_id = 66
)
ELSE
NULL
END
) off_on_effdt,
--to_char(paaf.effective_start_date, 'YYYY-MM-DD')
off_on_effdt,
haou.name organization,
pcak.segment1 profit_centre,
ppd.segment5 region,
haou.attribute20 rig_name,
ppd.segment7 rig_type,
(
SELECT
location_code
FROM
hr_locations_all
WHERE
location_id = paaf.location_id
) rig_location,
(
SELECT
meaning
FROM
hr_lookups
WHERE
lookup_type = 'EMPLOYEE_CATG'
AND lookup_code = paaf.employee_category
) employee_category,
pg.name grade,
(
SELECT
user_status
FROM
per_assignment_status_types
WHERE
assignment_status_type_id = paaf.assignment_status_type_id
) assignment_status,
hapf.attribute2 job_category,
(
SELECT
ppei1.pei_information1
FROM
per_people_extra_info ppei1
WHERE
ppei1.information_type = 'SG_PASSPORT_INFO'
AND ppei1.person_id = papf.person_id
AND ROWNUM < 2
) passport,
NULL entitlement_daily_rate,
NULL entitlement_hourly_rate,
NULL employment_status,
(
SELECT
meaning
FROM
hr_lookups hl
WHERE
lookup_type = 'NATIONALITY'
AND hl.lookup_code = papf.nationality
) nationality,
papf.national_identifier social_security_number,
nvl(
paaf.ass_attribute26, NULL
) paying_legal_entity,
CURSOR g_payroll_names IS
SELECT
payroll_name
FROM
pay_all_payrolls_f
WHERE
1 = 1
AND attribute1 = p_payroll_group
AND nvl(
l_effective_date, sysdate
) BETWEEN effective_start_date AND effective_end_date;
/* CURSOR l_pay_group IS
select attribute1 from
(
select attribute1,count(payroll_name)count_payroll
from pay_payrolls_f
where trunc(sysdate) between effective_start_date and effective_end_date and
attribute1 is not null group by attribute1
)
where count_payroll > 1; */
BEGIN
l_effective_date := fnd_date.canonical_to_date(p_effective_date);
SELECT
16
|| '-'
|| ( to_char(
add_months(
nvl(
l_effective_date, sysdate
), - 1
), 'MON-YYYY'
) )
INTO p_from_date
FROM
dual;
SELECT
15
|| '-'
|| ( to_char(
nvl(
l_effective_date, sysdate
), 'MON-YYYY'
) )
INTO p_to_date
FROM
dual;
SELECT
1
|| '-'
|| ( to_char(
add_months(
nvl(
l_effective_date, sysdate
), - 1
), 'MON-YYYY'
) )
INTO q_from_date
FROM
dual;
SELECT
20
|| '-'
|| ( to_char(
nvl(
l_effective_date, sysdate
), 'MON-YYYY'
) )
INTO q_to_date
FROM
dual;
SELECT
'01'
|| '-'
|| to_char(
nvl(
l_effective_date, sysdate
), 'MON-YYYY'
)
INTO l_from_date
FROM
dual;
SELECT
last_day(
nvl(
l_effective_date, sysdate
)
)
INTO l_to_date
FROM
dual;
SELECT
directory_path
INTO l_file_path
FROM
dba_directories
WHERE
directory_name = 'XXSDL_SAFEGUARD'; --- Added by TCS on 14th
Jul'21
fnd_file.put_line(
fnd_file.log,
'XXSDL_SAFEGUARD Directory Path - ' || l_file_path
); --- Added by TCS on 14th Jul'21
SELECT
name
INTO l_db_name
FROM
v$pdbs; --- Modified by TCS on 06-JUL-2021
SELECT
*
INTO l_pay_group
FROM
(
SELECT
(
CASE
WHEN (
SELECT
attribute1
FROM
(
SELECT
attribute1,
COUNT(payroll_name) count_payroll
FROM
pay_payrolls_f
WHERE
trunc(sysdate) BETWEEN effective_start_date
AND effective_end_date
AND attribute1 IS NOT NULL
GROUP BY
attribute1
)
WHERE
count_payroll > 1
AND attribute1 = p_payroll_group
) IS NULL THEN
'XX'
ELSE
p_payroll_group
END
)
FROM
dual
);
-- if (l_emp_val= 1) then
-- --dbms_output.put_line('Test');
-- FND_FILE.PUT_LINE(FND_FILE.LOG, 'Within loop: Employees
with Non Residential Address Type Records Found');
-- end if;
IF ( l_emp_val = 1 ) THEN
--dbms_output.put_line('Test');
fnd_file.put_line(
fnd_file.log,
' '
);
fnd_file.put_line(
fnd_file.log,
'+*****************************' ||
'**********************************************+'
);
fnd_file.put_line(
fnd_file.log,
' ' || 'END OF
REPORT'
);
fnd_file.put_line(
fnd_file.log,
'+*****************************' ||
'**********************************************+'
);
END IF;
l_nid_val := validate_dups(l_pay_name.payroll_name);
l_bank_val := validate_bank_dups(l_pay_name.payroll_name);
fnd_file.put_line(
fnd_file.log,
'+*****************************' ||
'**********************************************+'
);
IF ( l_nid_val <> 0 ) THEN
p_retcode := 2;
p_errbuff := 'The program has completed with error, please
check the log file for further details';
RETURN;
ELSIF ( l_nid_val = -1 ) THEN
p_retcode := 1;
p_errbuff := 'The program has completed with warning, please
check the log file for further details';
END IF;
END LOOP;
/* ELSE
IF (l_nid_val <> 0)
THEN
p_retcode := 2;
p_errbuff :=
'The program has completed with error, please check the log file for
further details';
RETURN;
ELSIF (l_nid_val = -1)
THEN
p_retcode := 1;
p_errbuff :=
'The program has completed with warning, please check the log file
for further details';
END IF; */
END IF;
-- if (l_emp_val= 1) then
-- --dbms_output.put_line('Test');
-- FND_FILE.PUT_LINE(FND_FILE.LOG, 'Within loop: Employees
with Non Residential Address Type Records Found');
-- end if;
IF ( l_emp_val = 1 ) THEN
--dbms_output.put_line('Test');
fnd_file.put_line(
fnd_file.log,
' '
);
fnd_file.put_line(
fnd_file.log,
'+*****************************' ||
'**********************************************+'
);
fnd_file.put_line(
fnd_file.log,
' ' || 'END OF
REPORT'
);
fnd_file.put_line(
fnd_file.log,
'+*****************************' ||
'**********************************************+'
);
END IF;
-- l_emp_val := check_residential_address (l_pay_name.payroll_name);
-- if (l_emp_val= 1) then
-- --dbms_output.put_line('Test');
-- FND_FILE.PUT_LINE(FND_FILE.LOG, 'Within loop: THIS IS A
TEST');
--
-- end if;
l_nid_val := validate_dups(l_pay_name.payroll_name);
l_bank_val := validate_bank_dups(l_pay_name.payroll_name);
fnd_file.put_line(
fnd_file.log,
'+*****************************' ||
'**********************************************+'
);
IF ( l_nid_val <> 0 ) THEN
p_retcode := 2;
p_errbuff := 'The program has completed with error, please
check the log file for further details';
RETURN;
ELSIF ( l_nid_val = -1 ) THEN
p_retcode := 1;
p_errbuff := 'The program has completed with warning, please
check the log file for further details';
END IF;
END LOOP;
/* ELSE
IF (l_nid_val <> 0)
THEN
p_retcode := 2;
p_errbuff :=
'The program has completed with error, please check the log file for
further details';
RETURN;
ELSIF (l_nid_val = -1)
THEN
p_retcode := 1;
p_errbuff :=
'The program has completed with warning, please check the log file
for further details';
END IF; */
END IF;
RETURN;
ELSIF (l_nid_val = -1 OR l_bank_val = -1)
THEN
p_retcode := 0;
p_errbuff :=
'Please check the log file for further details';
END IF;
END LOOP;
ELSE
l_nid_val := validate_dups (p_payroll_name);
l_bank_val :=
validate_bank_dups (p_payroll_name, q_from_date, l_to_date);
RETURN;
ELSIF (l_nid_val = -1 OR l_bank_val = -1)
THEN
p_retcode := 0;
p_errbuff :=
'Please check the log file for further details';
END IF;
IF (p_payroll_name IS NULL)
THEN
FOR l_pay_name IN g_payroll_names
LOOP
l_nid_val := validate_dups (l_pay_name.payroll_name);
l_bank_val :=
validate_bank_dups (l_pay_name.payroll_name,
q_from_date,
l_to_date
);
RETURN;
begin
FND_FILE.PUT_LINE(FND_FILE.LOG, 'THIS IS A TEST');
end;
END IF;
END LOOP;
END IF;*/
l_file_handle := utl_file.fopen(
l_file_path,
l_file,
'W'
);
utl_file.put_line(
l_file_handle,
utl_raw.cast_to_varchar2(utl_raw.convert(
utl_raw.cast_to_raw(nvl(
p_payroll_name,
p_payroll_group
'AMERICAN_AMERICA.JA16SJISTILDE',
'AMERICAN_AMERICA.AL32UTF8'
))
);
utl_file.put_line(
l_file_handle,
utl_raw.cast_to_varchar2(utl_raw.convert(
utl_raw.cast_to_raw('--------------------------------------------------------------
------------'),
'AMERICAN_AMERICA.JA16SJISTILDE',
'AMERICAN_AMERICA.AL32UTF8'
))
);
utl_file.put_line(
l_file_handle,
utl_raw.cast_to_varchar2(utl_raw.convert(
utl_raw.cast_to_raw('employee_number'
|| ','
|| 'starter_or_leaver'
|| ','
|| 'Fornames'
|| ','
|| 'Middle_Name'
|| ','
|| 'Sur_Name'
|| ','
|| 'Title'
|| ','
|| 'Start_Date'
|| ','
|| 'DOB'
|| ','
|| 'Company_End_DATE'
|| ','
|| 'Tel_number'
|| ','
|| 'Gender'
|| ','
|| 'Email_Address'
|| ','
|| 'Address Type'
|| ','
|| 'Address1'
|| ','
|| 'Address2'
|| ','
|| 'Address3'
|| ','
|| 'City'
|| ','
|| 'State'
|| ','
|| 'Zip_Code'
|| ','
|| 'Country'
|| ','
|| 'Payroll_to_Join'
|| ','
|| 'Payroll_start_Date'
|| ','
|| 'Payroll_join_date'
|| ','
|| 'Payroll_End_date'
|| ','
|| 'Payroll_leave_date'
|| ','
|| 'Bank_Name'
|| ','
|| 'Bank_Number'
|| ','
|| 'ACH_Routing_Number'
|| ','
|| 'Bank_Account_Number'
|| ','
|| 'BIC_Swift'
|| ','
|| 'IBAN'
|| ','
|| 'Payee_Name'
|| ','
|| 'Marital_status'
|| ','
|| 'Salary_Effective_Date'
|| ','
|| 'Annual_Salary'
|| ','
|| 'Salary_Currency'
|| ','
|| 'Hours_Per_Week'
|| ','
|| 'Job_Title'
|| ','
|| 'Line_Manager'
|| ','
|| 'FTE'
|| ','
|| 'Parttime_or_fulltime'
|| ','
|| 'Entitlement_Daily_Rate'
|| ','
|| 'Entitlement_Hourly_Rate'
|| ','
|| 'Legal'
|| ','
|| 'Legal_Entity_Code'
|| ','
|| 'Onshore'
|| ','
|| 'Organization'
|| ','
|| 'Profit_Centre'
|| ','
|| 'Region'
|| ','
|| 'Rig_Name'
|| ','
|| 'Rig_Type'
|| ','
|| 'Rig_Location'
|| ','
|| 'Employee_Category'
|| ','
|| 'Grade'
|| ','
|| 'Employment_Status'
|| ','
|| 'Passport'
|| ','
|| 'Nationality'
|| ','
|| 'BR_Codigo'
|| ','
|| ','
|| ','
|| ','
|| ','
|| ','
|| 'Life_Cycle'
|| ','
|| 'Paying_Legal_Entity_Code'),
'AMERICAN_AMERICA.JA16SJISTILDE',
'AMERICAN_AMERICA.AL32UTF8'
))
);
END IF;
'--------------------------------------------------------------------------'
);
fnd_file.put_line(
fnd_file.output,
'employee_number'
|| ','
|| 'starter_or_leaver'
|| ','
|| 'Fornames'
|| ','
|| 'Middle_Name'
|| ','
|| 'Sur_Name'
|| ','
|| 'Title'
|| ','
|| 'Start_Date'
|| ','
|| 'DOB'
|| ','
|| 'Company_End_DATE'
|| ','
|| 'Tel_number'
|| ','
|| 'Gender'
|| ','
|| 'Email_Address'
|| ','
|| 'Address Type'
|| ','
|| 'Address1'
|| ','
|| 'Address2'
|| ','
|| 'Address3'
|| ','
|| 'City'
|| ','
|| 'State'
|| ','
|| 'Zip_Code'
|| ','
|| 'Country'
|| ','
|| 'Payroll_to_Join'
|| ','
|| 'Payroll_start_Date'
|| ','
|| 'Payroll_join_date'
|| ','
|| 'Payroll_End_date'
|| ','
|| 'Payroll_leave_date'
|| ','
|| 'Bank_Name'
|| ','
|| 'Bank_Number'
|| ','
|| 'ACH_Routing_Number'
|| ','
|| 'Bank_Account_Number'
|| ','
|| 'BIC_Swift'
|| ','
|| 'IBAN'
|| ','
|| 'Payee_Name'
|| ','
|| 'Marital_status'
|| ','
|| 'Salary_Effective_Date'
|| ','
|| 'Annual_Salary'
|| ','
|| 'Salary_Currency'
|| ','
|| 'Hours_Per_Week'
|| ','
|| 'Job_Title'
|| ','
|| 'Line_Manager'
|| ','
|| 'FTE'
|| ','
|| 'Parttime_or_fulltime'
|| ','
|| 'Entitlement_Daily_Rate'
|| ','
|| 'Entitlement_Hourly_Rate'
|| ','
|| 'Legal'
|| ','
|| 'Legal_Entity_Code'
|| ','
|| 'Onshore'
|| ','
|| 'Off_On_Effdt' --added by Nandini
|| ',' --added by Nandini
|| 'Organization'
|| ','
|| 'Profit_Centre'
|| ','
|| 'Region'
|| ','
|| 'Rig_Name'
|| ','
|| 'Rig_Type'
|| ','
|| 'Rig_Location'
|| ','
|| 'Employee_Category'
|| ','
|| 'Grade'
|| ','
|| 'Employment_Status'
|| ','
|| 'Passport'
|| ','
|| 'Nationality'
|| ','
|| 'Social_Security_Number'
|| ','
|| 'BR_Codigo'
|| ','
|| 'NO_UPN' -- added by Naveed on 05-feb-2019
|| ','
|| 'NO_LE_ST_DT' ---- added by Nandini
|| ','
|| 'NO_ASS_EFFDT' ---- added by Nandini
|| ','
|| 'NO_REG' ---- added by Nandini
|| ','
|| 'NO_INTRINN' ---- added by Nandini
|| ',' ---- added by Nandini
|| 'COLLECTIVE_BARGAINING_DATE' ---- added
by Srikkanth M
|| ',' ---- added by
Srikkanth M
|| 'Life_Cycle'
|| ','
|| 'Paying_Legal_Entity_Code'
);
FOR l_sgwi_payroll IN c_sgwi_payroll(
p_from_date,
p_to_date,
l_from_date,
l_to_date,
q_from_date,
q_to_date,
i.payroll_name,
i.business_group_id,
i.attribute2,
l_effective_date,
i.payroll_id
) LOOP
IF
p_flag = 'Y'
AND p_payroll_group != l_pay_group
THEN
l_output := l_sgwi_payroll.employee_number
|| ','
|| l_sgwi_payroll.starter_or_leaver
|| ','
|| l_sgwi_payroll.fornames
|| ','
|| l_sgwi_payroll.middle_name
|| ','
|| l_sgwi_payroll.sur_name
|| ','
|| l_sgwi_payroll.title
|| ','
|| l_sgwi_payroll.start_date
|| ','
|| l_sgwi_payroll.dob
|| ','
|| l_sgwi_payroll.company_end_date
|| ','
|| l_sgwi_payroll.tel_number
|| ','
|| l_sgwi_payroll.gender
|| ','
|| replace(
replace(
l_sgwi_payroll.email_address,
chr(10),
''
),
chr(13),
''
)
|| ','
|| l_sgwi_payroll.address_type
|| ','
|| replace(
l_sgwi_payroll.address1,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.address2,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.address3,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.city,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.state,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.zip_code,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.country,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.payroll_to_join,
' ',
'-'
)
|| ','
|| l_sgwi_payroll.payroll_start_date
|| ','
|| l_sgwi_payroll.payroll_join_date
|| ','
|| l_sgwi_payroll.payroll_end_date
|| ','
|| l_sgwi_payroll.payroll_leave_date
|| ','
|| ' '
|| ','
|| ' '
|| ','
|| ' '
|| ','
|| ' '
|| ','
--|| ' ' -- commented by
naveed on 11-feb-2019 for UPN changes
|| l_sgwi_payroll.bic_swift -- added by
naveed on 11-feb-2019 for UPN changes
|| ','
--|| ' ' -- commented by
naveed on 11-feb-2019 for UPN changes
|| l_sgwi_payroll.iban --
added by naveed on 11-feb-2019 for UPN changes
|| ','
|| ' '
|| ','
|| l_sgwi_payroll.marital_status
|| ','
|| l_sgwi_payroll.salary_effective_date
|| ','
|| l_sgwi_payroll.annual_salary
|| ','
|| l_sgwi_payroll.salary_currency
|| ','
|| l_sgwi_payroll.hours_per_week
|| ','
|| replace(
l_sgwi_payroll.job_title,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.line_manager,
',',
''
)
|| ','
|| l_sgwi_payroll.fte
|| ','
|| l_sgwi_payroll.parttime_or_fulltime
|| ','
|| l_sgwi_payroll.entitlement_daily_rate
|| ','
|| l_sgwi_payroll.entitlement_hourly_rate
|| ','
|| replace(
l_sgwi_payroll.legal,
',',
''
)
|| ','
|| l_sgwi_payroll.legal_entity_code
|| ','
|| l_sgwi_payroll.onshore
|| ','
|| l_sgwi_payroll.off_on_effdt -- added by
Nandini
|| ',' --added by Nandini
|| replace(
l_sgwi_payroll.organization,
',',
''
)
|| ','
|| l_sgwi_payroll.profit_centre
|| ','
|| replace(
l_sgwi_payroll.region,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.rig_name,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.rig_type,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.rig_location,
',',
''
)
|| ','
|| l_sgwi_payroll.employee_category
|| ','
|| l_sgwi_payroll.grade
|| ','
|| l_sgwi_payroll.assignment_status
|| ','
|| l_sgwi_payroll.passport
|| ','
|| l_sgwi_payroll.nationality
|| ','
|| l_sgwi_payroll.social_security_number
|| ','
|| l_sgwi_payroll.br_codigo
|| ','
|| l_sgwi_payroll.upn -- added by Naveed
on 05-feb-2019
|| ','
|| l_sgwi_payroll.no_le_st_dt ---- added
by Nandini for Norwegian payroll
|| ',' ---- added by Nandini for
Norwegian payroll
|| l_sgwi_payroll.no_ass_effdt ---- added
by Nandini for Norwegian payroll
|| ',' ---- added by Nandini for
Norwegian payroll
|| l_sgwi_payroll.no_reg ---- added
by Nandini for Norwegian payroll
|| ',' ---- added by Nandini for
Norwegian payroll
|| l_sgwi_payroll.no_intrinn ---- added
by Nandini for Norwegian payroll
|| ',' ---- added by Nandini for
Norwegian payroll
||
l_sgwi_payroll.collective_bargaining_date ---- added by Srikkanth M for Norwegian
payroll
|| ',' ---- added by Srikkanth M
for Norwegian payroll
|| l_sgwi_payroll.life_cycle
|| ' '
|| chr(13);
utl_file.put_line(
l_file_handle,
utl_raw.cast_to_varchar2(utl_raw.convert(
utl_raw.cast_to_raw(l_output),
'AMERICAN_AMERICA.JA16SJISTILDE',
'AMERICAN_AMERICA.AL32UTF8'
))
);
END IF;
l_output1 := l_sgwi_payroll.employee_number
|| ','
|| l_sgwi_payroll.starter_or_leaver
|| ','
|| l_sgwi_payroll.fornames
|| ','
|| l_sgwi_payroll.middle_name
|| ','
|| l_sgwi_payroll.sur_name
|| ','
|| l_sgwi_payroll.title
|| ','
|| l_sgwi_payroll.start_date
|| ','
|| l_sgwi_payroll.dob
|| ','
|| l_sgwi_payroll.company_end_date
|| ','
|| l_sgwi_payroll.tel_number
|| ','
|| l_sgwi_payroll.gender
|| ','
|| replace(
replace(
l_sgwi_payroll.email_address,
chr(10),
''
),
chr(13),
''
)
|| ','
|| l_sgwi_payroll.address_type
|| ','
|| replace(
l_sgwi_payroll.address1,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.address2,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.address3,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.city,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.state,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.zip_code,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.country,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.payroll_to_join,
' ',
'-'
)
|| ','
|| l_sgwi_payroll.payroll_start_date
|| ','
|| l_sgwi_payroll.payroll_join_date
|| ','
|| l_sgwi_payroll.payroll_end_date
|| ','
|| l_sgwi_payroll.payroll_leave_date
|| ','
|| replace(
l_sgwi_payroll.bank_name,
',',
''
)
|| ','
|| l_sgwi_payroll.bank_number
|| ','
|| ' '
|| ','
|| l_sgwi_payroll.bank_account_number
|| ','
--|| ' ' -- commented by naveed
on 11-feb-2019 for UPN changes
|| l_sgwi_payroll.bic_swift -- added by
naveed on 11-feb-2019 for UPN changes
|| ','
--|| ' ' -- commented by naveed
on 11-feb-2019 for UPN changes
|| l_sgwi_payroll.iban -- added by naveed
on 11-feb-2019 for UPN changes
|| ','
|| ' '
|| ','
|| l_sgwi_payroll.marital_status
|| ','
|| l_sgwi_payroll.salary_effective_date
|| ','
|| l_sgwi_payroll.annual_salary
|| ','
|| l_sgwi_payroll.salary_currency
|| ','
|| l_sgwi_payroll.hours_per_week
|| ','
|| replace(
l_sgwi_payroll.job_title,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.line_manager,
',',
''
)
|| ','
|| l_sgwi_payroll.fte
|| ','
|| l_sgwi_payroll.parttime_or_fulltime
|| ','
|| l_sgwi_payroll.entitlement_daily_rate
|| ','
|| l_sgwi_payroll.entitlement_hourly_rate
|| ','
|| replace(
l_sgwi_payroll.legal,
',',
''
)
|| ','
|| l_sgwi_payroll.legal_entity_code
|| ','
|| l_sgwi_payroll.onshore
|| ','
|| l_sgwi_payroll.off_on_effdt -- added by
Nandini
|| ',' --added by Nandini
|| replace(
l_sgwi_payroll.organization,
',',
''
)
|| ','
|| l_sgwi_payroll.profit_centre
|| ','
|| replace(
l_sgwi_payroll.region,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.rig_name,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.rig_type,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.rig_location,
',',
''
)
|| ','
|| l_sgwi_payroll.employee_category
|| ','
|| l_sgwi_payroll.grade
|| ','
|| l_sgwi_payroll.assignment_status
|| ','
|| l_sgwi_payroll.passport
|| ','
|| l_sgwi_payroll.nationality
|| ','
|| l_sgwi_payroll.social_security_number
|| ','
|| l_sgwi_payroll.br_codigo
|| ','
|| l_sgwi_payroll.upn -- added by Naveed on
05-feb-2019
|| ','
|| l_sgwi_payroll.no_le_st_dt ---- added by
Nandini for Norwegian payroll
|| ',' ---- added by Nandini for
Norwegian payroll
|| l_sgwi_payroll.no_ass_effdt ---- added by
Nandini for Norwegian payroll
|| ',' ---- added by Nandini for
Norwegian payroll
|| l_sgwi_payroll.no_reg ---- added by
Nandini for Norwegian payroll
|| ',' ---- added by Nandini for
Norwegian payroll
|| l_sgwi_payroll.no_intrinn ---- added by
Nandini for Norwegian payroll
|| ',' ---- added by Nandini for
Norwegian payroll
|| l_sgwi_payroll.collective_bargaining_date
---- added by Srikkanth M for Norwegian payroll
|| ',' ---- added by Srikkanth M for
Norwegian payroll
|| l_sgwi_payroll.life_cycle
|| ','
|| l_sgwi_payroll.paying_legal_entity
|| chr(13);
--Writing the File
fnd_file.put_line(
fnd_file.output,
l_output1
);
END LOOP;
fnd_file.put_line(
fnd_file.output,
'--------------------------------------------------------------------------'
|| chr(13)
|| chr(13)
);
END LOOP;
/*--If payroll name is null and pay group has multiple payrolls --*/
/*--Included to reorder the output file sent to Safeguard such that
employees leaving the payroll will appear in the end of the report--*/
IF p_payroll_name IS NULL THEN
IF
p_payroll_group = l_pay_group
AND p_flag = 'Y'
THEN
EXECUTE IMMEDIATE 'TRUNCATE TABLE
XXSDL.XXSDL_NO_SGWI_PAY_MASTER_STG';
FOR i_payroll IN (
SELECT
payroll_name,
business_group_id,
attribute2,
payroll_id
FROM
pay_all_payrolls_f
WHERE
attribute1 = p_payroll_group
AND nvl(
l_effective_date, sysdate
) BETWEEN effective_start_date AND
effective_end_date
) LOOP
FOR l_sgwi_payroll IN c_sgwi_payroll(
p_from_date,
p_to_date,
l_from_date,
l_to_date,
q_from_date,
q_to_date,
i_payroll.payroll_name,
i_payroll.business_group_id,
i_payroll.attribute2,
l_effective_date,
i_payroll.payroll_id
) LOOP
INSERT INTO xxsdl_no_sgwi_pay_master_stg (
employee_number,
starter_or_leaver,
fornames,
middle_name,
sur_name,
title,
start_date,
dob,
company_end_date,
tel_number,
gender,
email_address,
address_type,
address1,
address2,
address3,
city,
state,
zip_code,
country,
payroll_to_join,
payroll_start_date,
payroll_join_date,
payroll_end_date,
payroll_leave_date,
bank_name,
bank_number,
ach_routing_number,
bank_account_number,
bic_swift,
iban,
payee_name,
marital_status,
salary_effective_date,
annual_salary,
salary_currency,
hours_per_week,
job_title,
line_manager,
fte,
parttime_or_fulltime,
entitlement_daily_rate,
entitlement_hourly_rate,
legal,
legal_entity_code,
onshore,
off_on_effdt, -- added by Nandini
organization,
profit_centre,
region,
rig_name,
rig_type,
rig_location,
employee_category,
grade,
employment_status,
passport,
nationality,
social_security_number,
br_codigo,
upn, -- added by Naveed on 05-feb-2019
no_le_st_dt, --- added by Nandini
no_ass_effdt,--- added by Nandini
no_reg, --- added by Nandini
no_intrinn, --- added by Nandini
collective_bargaining_date,
life_cycle
) VALUES (
l_sgwi_payroll.employee_number,
l_sgwi_payroll.starter_or_leaver,
l_sgwi_payroll.fornames,
l_sgwi_payroll.middle_name,
l_sgwi_payroll.sur_name,
l_sgwi_payroll.title,
l_sgwi_payroll.start_date,
l_sgwi_payroll.dob,
l_sgwi_payroll.company_end_date,
l_sgwi_payroll.tel_number,
l_sgwi_payroll.gender,
l_sgwi_payroll.email_address,
l_sgwi_payroll.address_type,
l_sgwi_payroll.address1,
l_sgwi_payroll.address2,
l_sgwi_payroll.address3,
l_sgwi_payroll.city,
l_sgwi_payroll.state,
l_sgwi_payroll.zip_code,
l_sgwi_payroll.country,
l_sgwi_payroll.payroll_to_join,
l_sgwi_payroll.payroll_start_date,
l_sgwi_payroll.payroll_join_date,
l_sgwi_payroll.payroll_end_date,
l_sgwi_payroll.payroll_leave_date,
l_sgwi_payroll.bank_name,
l_sgwi_payroll.bank_number,
l_sgwi_payroll.ach_routing_number,
l_sgwi_payroll.bank_account_number,
l_sgwi_payroll.bic_swift,
l_sgwi_payroll.iban,
l_sgwi_payroll.payee_name,
l_sgwi_payroll.marital_status,
l_sgwi_payroll.salary_effective_date,
l_sgwi_payroll.annual_salary,
l_sgwi_payroll.salary_currency,
l_sgwi_payroll.hours_per_week,
l_sgwi_payroll.job_title,
l_sgwi_payroll.line_manager,
l_sgwi_payroll.fte,
l_sgwi_payroll.parttime_or_fulltime,
l_sgwi_payroll.entitlement_daily_rate,
l_sgwi_payroll.entitlement_hourly_rate,
l_sgwi_payroll.legal,
l_sgwi_payroll.legal_entity_code,
l_sgwi_payroll.onshore,
l_sgwi_payroll.off_on_effdt, -- added by
Nandini
l_sgwi_payroll.organization,
l_sgwi_payroll.profit_centre,
l_sgwi_payroll.region,
l_sgwi_payroll.rig_name,
l_sgwi_payroll.rig_type,
l_sgwi_payroll.rig_location,
l_sgwi_payroll.employee_category,
l_sgwi_payroll.grade,
l_sgwi_payroll.assignment_status,
l_sgwi_payroll.passport,
l_sgwi_payroll.nationality,
l_sgwi_payroll.social_security_number,
l_sgwi_payroll.br_codigo, -- Added By Anil
l_sgwi_payroll.upn, -- added by Naveed on 05-
feb-2019
l_sgwi_payroll.no_le_st_dt, ---- added by
Nandini for Norwegian payroll
l_sgwi_payroll.no_ass_effdt, ---- added by
Nandini for Norwegian payroll
l_sgwi_payroll.no_reg, ---- added by
Nandini for Norwegian payroll
l_sgwi_payroll.no_intrinn, ---- added by
Nandini for Norwegian payroll
l_sgwi_payroll.collective_bargaining_date,
---- added by Srikkanth M for Norwegian payroll
l_sgwi_payroll.life_cycle
);
END LOOP;
COMMIT;
END LOOP;
FOR l_sgwi IN (
SELECT DISTINCT
*
FROM
xxsdl_no_sgwi_pay_master_stg
ORDER BY
employee_number,
payroll_leave_date
) LOOP
IF l_sgwi.br_codigo IS NOT NULL THEN
l_output := l_sgwi.employee_number
|| ','
|| l_sgwi.starter_or_leaver
|| ','
|| l_sgwi.fornames
|| ','
|| l_sgwi.middle_name
|| ','
|| l_sgwi.sur_name
|| ','
|| l_sgwi.title
|| ','
|| l_sgwi.start_date
|| ','
|| l_sgwi.dob
|| ','
|| l_sgwi.company_end_date
|| ','
|| l_sgwi.tel_number
|| ','
|| l_sgwi.gender
|| ','
|| replace(
l_sgwi.email_address,
chr(10),
''
)
|| ','
|| l_sgwi.address_type
|| ','
|| replace(
l_sgwi.address1,
',',
''
)
|| ','
|| replace(
l_sgwi.address2,
',',
''
)
|| ','
|| replace(
l_sgwi.address3,
',',
''
)
|| ','
|| replace(
l_sgwi.city,
',',
''
)
|| ','
|| replace(
l_sgwi.zip_code,
',',
''
)
|| ','
|| replace(
l_sgwi.country,
',',
''
)
|| ','
|| replace(
l_sgwi.payroll_to_join,
' ',
'-'
)
|| ','
|| l_sgwi.payroll_start_date
|| ','
|| l_sgwi.payroll_join_date
|| ','
|| l_sgwi.payroll_end_date
|| ','
|| l_sgwi.payroll_leave_date
|| ','
|| l_sgwi.bank_name
|| ','
|| l_sgwi.bank_number
|| ','
|| l_sgwi.ach_routing_number
|| ','
|| l_sgwi.bank_account_number
|| ','
|| l_sgwi.bic_swift
|| ','
|| l_sgwi.iban
|| ','
|| l_sgwi.payee_name
|| ','
|| l_sgwi.marital_status
|| ','
|| l_sgwi.salary_effective_date
|| ','
|| l_sgwi.annual_salary
|| ','
|| l_sgwi.salary_currency
|| ','
|| l_sgwi.hours_per_week
|| ','
|| replace(
l_sgwi.job_title,
',',
''
)
|| ','
|| replace(
l_sgwi.line_manager,
',',
''
)
|| ','
|| l_sgwi.fte
|| ','
|| l_sgwi.parttime_or_fulltime
|| ','
|| l_sgwi.entitlement_daily_rate
|| ','
|| l_sgwi.entitlement_hourly_rate
|| ','
|| replace(
l_sgwi.legal,
',',
''
)
|| ','
|| l_sgwi.legal_entity_code
|| ','
|| l_sgwi.onshore
|| ','
|| l_sgwi.off_on_effdt -- added by
Nandini
|| ',' -- added by Nandini
|| replace(
l_sgwi.organization,
',',
''
)
|| ','
|| l_sgwi.profit_centre
|| ','
|| replace(
l_sgwi.region,
',',
''
)
|| ','
|| replace(
l_sgwi.rig_name,
',',
''
)
|| ','
|| replace(
l_sgwi.rig_type,
',',
''
)
|| ','
|| replace(
l_sgwi.rig_location,
',',
''
)
|| ','
|| l_sgwi.employee_category
|| ','
|| l_sgwi.grade
|| ','
|| l_sgwi.employment_status
|| ','
|| l_sgwi.passport
|| ','
|| l_sgwi.nationality
|| ','
|| l_sgwi.social_security_number
|| ','
|| l_sgwi.br_codigo
|| ','
|| l_sgwi.upn -- added by Naveed on
05-feb-2019
|| ','
|| l_sgwi.no_le_st_dt ---- added by
Nandini for Norwegian payroll
|| ',' ---- added by Nandini
for Norwegian payroll
|| l_sgwi.no_ass_effdt ---- added by
Nandini for Norwegian payroll
|| ',' ---- added by Nandini
for Norwegian payroll
|| l_sgwi.no_reg ---- added by
Nandini for Norwegian payroll
|| ',' ---- added by Nandini
for Norwegian payroll
|| l_sgwi.no_intrinn ---- added by
Nandini for Norwegian payroll
|| ',' ---- added by Nandini
for Norwegian payroll
|| l_sgwi.collective_bargaining_date
---- added by Srikkanth M for Norwegian payroll
|| ',' ---- added by
Srikkanth M for Norwegian payroll
|| l_sgwi.life_cycle
|| ','
|| ' '
|| chr(13);
ELSE
l_output := l_sgwi.employee_number
|| ','
|| l_sgwi.starter_or_leaver
|| ','
|| l_sgwi.fornames
|| ','
|| l_sgwi.middle_name
|| ','
|| l_sgwi.sur_name
|| ','
|| l_sgwi.title
|| ','
|| l_sgwi.start_date
|| ','
|| l_sgwi.dob
|| ','
|| l_sgwi.company_end_date
|| ','
|| l_sgwi.tel_number
|| ','
|| l_sgwi.gender
|| ','
|| replace(
l_sgwi.email_address,
chr(10),
''
)
|| ','
|| l_sgwi.address_type
|| ','
|| replace(
l_sgwi.address1,
',',
''
)
|| ','
|| replace(
l_sgwi.address2,
',',
''
)
|| ','
|| replace(
l_sgwi.address3,
',',
''
)
|| ','
|| replace(
l_sgwi.city,
',',
''
)
|| ','
|| replace(
l_sgwi.state,
',',
''
)
|| ','
|| replace(
l_sgwi.zip_code,
',',
''
)
|| ','
|| replace(
l_sgwi.country,
',',
''
)
|| ','
|| replace(
l_sgwi.payroll_to_join,
' ',
'-'
)
|| ','
|| l_sgwi.payroll_start_date
|| ','
|| l_sgwi.payroll_join_date
|| ','
|| l_sgwi.payroll_end_date
|| ','
|| l_sgwi.payroll_leave_date
|| ','
|| ' '
|| ','
|| ' '
|| ','
|| ' '
|| ','
|| ' '
|| ','
-- || ' ' --
commented by naveed on 11-feb-2019 for UPN changes
|| l_sgwi.bic_swift --
added by naveed on 11-feb-2019 for UPN changes
|| ','
--|| ' ' --
commented by naveed on 11-feb-2019 for UPN changes
|| l_sgwi.iban --
added by naveed on 11-feb-2019 for UPN changes
|| ','
|| ' '
|| ','
|| l_sgwi.marital_status
|| ','
|| l_sgwi.salary_effective_date
|| ','
|| l_sgwi.annual_salary
|| ','
|| l_sgwi.salary_currency
|| ','
|| l_sgwi.hours_per_week
|| ','
|| replace(
l_sgwi.job_title,
',',
''
)
|| ','
|| replace(
l_sgwi.line_manager,
',',
''
)
|| ','
|| l_sgwi.fte
|| ','
|| l_sgwi.parttime_or_fulltime
|| ','
|| l_sgwi.entitlement_daily_rate
|| ','
|| l_sgwi.entitlement_hourly_rate
|| ','
|| replace(
l_sgwi.legal,
',',
''
)
|| ','
|| l_sgwi.legal_entity_code
|| ','
|| l_sgwi.onshore
|| ','
|| l_sgwi.off_on_effdt -- added by
Nandini
|| ',' -- added by Nandini
|| replace(
l_sgwi.organization,
',',
''
)
|| ','
|| l_sgwi.profit_centre
|| ','
|| replace(
l_sgwi.region,
',',
''
)
|| ','
|| replace(
l_sgwi.rig_name,
',',
''
)
|| ','
|| replace(
l_sgwi.rig_type,
',',
''
)
|| ','
|| replace(
l_sgwi.rig_location,
',',
''
)
|| ','
|| l_sgwi.employee_category
|| ','
|| l_sgwi.grade
|| ','
|| l_sgwi.employment_status
|| ','
|| l_sgwi.passport
|| ','
|| l_sgwi.nationality
|| ','
|| l_sgwi.social_security_number
|| ','
|| l_sgwi.br_codigo
|| ','
|| l_sgwi.upn -- added by Naveed on
05-feb-2019
|| ','
|| l_sgwi.no_le_st_dt ---- added by
Nandini for Norwegian payroll
|| ',' ---- added by Nandini
for Norwegian payroll
|| l_sgwi.no_ass_effdt ---- added by
Nandini for Norwegian payroll
|| ',' ---- added by Nandini
for Norwegian payroll
|| l_sgwi.no_reg ---- added by
Nandini for Norwegian payroll
|| ',' ---- added by Nandini
for Norwegian payroll
|| l_sgwi.no_intrinn ---- added by
Nandini for Norwegian payroll
|| ',' ---- added by Nandini
for Norwegian payroll
|| l_sgwi.collective_bargaining_date
---- added by Srikkanth M for Norwegian payroll
|| ',' ---- added by
Srikkanth M for Norwegian payroll
|| l_sgwi.life_cycle
|| ','
|| ' '
|| chr(13);
END IF;
utl_file.put_line(
l_file_handle,
utl_raw.cast_to_varchar2(utl_raw.convert(
utl_raw.cast_to_raw(l_output),
'AMERICAN_AMERICA.JA16SJISTILDE',
'AMERICAN_AMERICA.AL32UTF8'
))
);
END LOOP;
END IF;
END IF;
/*--If payroll group and payroll name both are provided--*/
ELSE
fnd_file.put_line(
fnd_file.output,
p_payroll_name || ' Master Data'
);
fnd_file.put_line(
fnd_file.output,
'--------------------------------------------------------------------------'
);
fnd_file.put_line(
fnd_file.output,
'employee_number'
|| ','
|| 'starter_or_leaver'
|| ','
|| 'Fornames'
|| ','
|| 'Middle_Name'
|| ','
|| 'Sur_Name'
|| ','
|| 'Title'
|| ','
|| 'Start_Date'
|| ','
|| 'DOB'
|| ','
|| 'Company_End_DATE'
|| ','
|| 'Tel_number'
|| ','
|| 'Gender'
|| ','
|| 'Email_Address'
|| ','
|| 'Address Type'
|| ','
|| 'Address1'
|| ','
|| 'Address2'
|| ','
|| 'Address3'
|| ','
|| 'City'
|| ','
|| 'State'
|| ','
|| 'Zip_Code'
|| ','
|| 'Country'
|| ','
|| 'Payroll_to_Join'
|| ','
|| 'Payroll_start_Date'
|| ','
|| 'Payroll_join_date'
|| ','
|| 'Payroll_End_date'
|| ','
|| 'Payroll_leave_date'
|| ','
|| 'Bank_Name'
|| ','
|| 'Bank_Number'
|| ','
|| 'ACH_Routing_Number'
|| ','
|| 'Bank_Account_Number'
|| ','
|| 'BIC_Swift'
|| ','
|| 'IBAN'
|| ','
|| 'Payee_Name'
|| ','
|| 'Marital_status'
|| ','
|| 'Salary_Effective_Date'
|| ','
|| 'Annual_Salary'
|| ','
|| 'Salary_Currency'
|| ','
|| 'Hours_Per_Week'
|| ','
|| 'Job_Title'
|| ','
|| 'Line_Manager'
|| ','
|| 'FTE'
|| ','
|| 'Parttime_or_fulltime'
|| ','
|| 'Entitlement_Daily_Rate'
|| ','
|| 'Entitlement_Hourly_Rate'
|| ','
|| 'Legal'
|| ','
|| 'Legal_Entity_Code'
|| ','
|| 'Onshore'
|| ','
|| 'Off_On_Effdt' --added by Nandini
|| ',' --added by Nandini
|| 'Organization'
|| ','
|| 'Profit_Centre'
|| ','
|| 'Region'
|| ','
|| 'Rig_Name'
|| ','
|| 'Rig_Type'
|| ','
|| 'Rig_Location'
|| ','
|| 'Employee_Category'
|| ','
|| 'Grade'
|| ','
|| 'Employment_Status'
|| ','
|| 'Passport'
|| ','
|| 'Nationality'
|| ','
|| 'Social_Security_Number'
|| ','
|| 'BR_Codigo'
|| ','
|| 'NO_UPN' -- added by Naveed on 05-feb-2019
|| ','
|| 'NO_LE_ST_DT' ---- added by Nandini
|| ','
|| 'NO_ASS_EFFDT' ---- added by Nandini
|| ','
|| 'NO_REG' ---- added by Nandini
|| ','
|| 'NO_INTRINN' ---- added by Nandini
|| ',' ---- added by Nandini
|| 'COLLECTIVE_BARGAINING_DATE' ---- added by
Srikkanth M
|| ',' ---- added by Srikkanth M
|| 'Life_Cycle'
|| ','
|| 'Paying_Legal_Entity_Code'
);
FOR i IN (
SELECT
business_group_id,
attribute2,
payroll_id
FROM
pay_all_payrolls_f
WHERE
payroll_name = p_payroll_name
AND nvl(
l_effective_date, sysdate
) BETWEEN effective_start_date AND effective_end_date
) LOOP
FOR l_sgwi_payroll IN c_sgwi_payroll(
p_from_date,
p_to_date,
l_from_date,
l_to_date,
q_from_date,
q_to_date,
p_payroll_name,
i.business_group_id,
i.attribute2,
l_effective_date,
i.payroll_id
) LOOP
IF
p_flag = 'Y'
AND p_payroll_group = 'BR'
THEN
l_output := l_sgwi_payroll.employee_number
|| ','
|| l_sgwi_payroll.starter_or_leaver
|| ','
|| l_sgwi_payroll.fornames
|| ','
|| l_sgwi_payroll.middle_name
|| ','
|| l_sgwi_payroll.sur_name
|| ','
|| l_sgwi_payroll.title
|| ','
|| l_sgwi_payroll.start_date
|| ','
|| l_sgwi_payroll.dob
|| ','
|| l_sgwi_payroll.company_end_date
|| ','
|| l_sgwi_payroll.tel_number
|| ','
|| l_sgwi_payroll.gender
|| ','
|| replace(
replace(
l_sgwi_payroll.email_address,
chr(10),
''
),
chr(13),
''
)
|| ','
|| l_sgwi_payroll.address_type
|| ','
|| replace(
l_sgwi_payroll.address1,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.address2,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.address3,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.city,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.state,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.zip_code,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.country,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.payroll_to_join,
' ',
'-'
)
|| ','
|| l_sgwi_payroll.payroll_start_date
|| ','
|| l_sgwi_payroll.payroll_join_date
|| ','
|| l_sgwi_payroll.payroll_end_date
|| ','
|| l_sgwi_payroll.payroll_leave_date
|| ','
|| l_sgwi_payroll.bank_name
|| ','
|| l_sgwi_payroll.bank_number
|| ','
|| l_sgwi_payroll.ach_routing_number
|| ','
|| l_sgwi_payroll.bank_account_number
|| ','
|| l_sgwi_payroll.bic_swift
|| ','
|| l_sgwi_payroll.iban
|| ','
|| l_sgwi_payroll.payee_name
|| ','
|| l_sgwi_payroll.marital_status
|| ','
|| l_sgwi_payroll.salary_effective_date
|| ','
|| l_sgwi_payroll.annual_salary
|| ','
|| l_sgwi_payroll.salary_currency
|| ','
|| l_sgwi_payroll.hours_per_week
|| ','
|| replace(
l_sgwi_payroll.job_title,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.line_manager,
',',
''
)
|| ','
|| l_sgwi_payroll.fte
|| ','
|| l_sgwi_payroll.parttime_or_fulltime
|| ','
|| l_sgwi_payroll.entitlement_daily_rate
|| ','
|| l_sgwi_payroll.entitlement_hourly_rate
|| ','
|| replace(
l_sgwi_payroll.legal,
',',
''
)
|| ','
|| l_sgwi_payroll.legal_entity_code
|| ','
|| l_sgwi_payroll.onshore
|| ','
|| l_sgwi_payroll.off_on_effdt -- added by
Nandini
|| ',' --added by Nandini
|| replace(
l_sgwi_payroll.organization,
',',
''
)
|| ','
|| l_sgwi_payroll.profit_centre
|| ','
|| replace(
l_sgwi_payroll.region,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.rig_name,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.rig_type,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.rig_location,
',',
''
)
|| ','
|| l_sgwi_payroll.employee_category
|| ','
|| l_sgwi_payroll.grade
|| ','
|| l_sgwi_payroll.assignment_status
|| ','
|| l_sgwi_payroll.passport
|| ','
|| l_sgwi_payroll.nationality
|| ','
|| l_sgwi_payroll.social_security_number
|| ','
|| l_sgwi_payroll.br_codigo
|| ','
|| l_sgwi_payroll.upn -- added by Naveed
on 05-feb-2019
|| ','
|| l_sgwi_payroll.no_le_st_dt ---- added
by Nandini for Norwegian payroll
|| ',' ---- added by Nandini for
Norwegian payroll
|| l_sgwi_payroll.no_ass_effdt ---- added
by Nandini for Norwegian payroll
|| ',' ---- added by Nandini for
Norwegian payroll
|| l_sgwi_payroll.no_reg ---- added
by Nandini for Norwegian payroll
|| ',' ---- added by Nandini for
Norwegian payroll
|| l_sgwi_payroll.no_intrinn ---- added
by Nandini for Norwegian payroll
|| ',' ---- added by Nandini for
Norwegian payroll
||
l_sgwi_payroll.collective_bargaining_date ---- added by Srikkanth M for Norwegian
payroll
|| ',' ---- added by Srikkanth M
for Norwegian payroll
|| l_sgwi_payroll.life_cycle
|| ' '
|| chr(13);
utl_file.put_line(
l_file_handle,
utl_raw.cast_to_varchar2(utl_raw.convert(
utl_raw.cast_to_raw(l_output),
'AMERICAN_AMERICA.JA16SJISTILDE',
'AMERICAN_AMERICA.AL32UTF8'
))
);
ELSIF
p_flag = 'Y'
AND p_payroll_group <> 'BR'
THEN
l_output := l_sgwi_payroll.employee_number
|| ','
|| l_sgwi_payroll.starter_or_leaver
|| ','
|| l_sgwi_payroll.fornames
|| ','
|| l_sgwi_payroll.middle_name
|| ','
|| l_sgwi_payroll.sur_name
|| ','
|| l_sgwi_payroll.title
|| ','
|| l_sgwi_payroll.start_date
|| ','
|| l_sgwi_payroll.dob
|| ','
|| l_sgwi_payroll.company_end_date
|| ','
|| l_sgwi_payroll.tel_number
|| ','
|| l_sgwi_payroll.gender
|| ','
|| replace(
replace(
l_sgwi_payroll.email_address,
chr(10),
''
),
chr(13),
''
)
|| ','
|| l_sgwi_payroll.address_type
|| ','
|| replace(
l_sgwi_payroll.address1,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.address2,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.address3,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.city,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.state,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.zip_code,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.country,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.payroll_to_join,
' ',
'-'
)
|| ','
|| l_sgwi_payroll.payroll_start_date
|| ','
|| l_sgwi_payroll.payroll_join_date
|| ','
|| l_sgwi_payroll.payroll_end_date
|| ','
|| l_sgwi_payroll.payroll_leave_date
|| ','
|| ' '
|| ','
|| ' '
|| ','
|| ' '
|| ','
|| ' '
|| ','
--|| ' ' -- commented by
naveed on 11-feb-2019 for UPN changes
|| l_sgwi_payroll.bic_swift -- added by
naveed on 11-feb-2019 for UPN changes
|| ','
--|| ' ' -- commented by
naveed on 11-feb-2019 for UPN changes
|| l_sgwi_payroll.iban -- added by
naveed on 11-feb-2019 for UPN changes
|| ','
|| ' '
|| ','
|| l_sgwi_payroll.marital_status
|| ','
|| l_sgwi_payroll.salary_effective_date
|| ','
|| l_sgwi_payroll.annual_salary
|| ','
|| l_sgwi_payroll.salary_currency
|| ','
|| l_sgwi_payroll.hours_per_week
|| ','
|| replace(
l_sgwi_payroll.job_title,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.line_manager,
',',
''
)
|| ','
|| l_sgwi_payroll.fte
|| ','
|| l_sgwi_payroll.parttime_or_fulltime
|| ','
|| l_sgwi_payroll.entitlement_daily_rate
|| ','
|| l_sgwi_payroll.entitlement_hourly_rate
|| ','
|| replace(
l_sgwi_payroll.legal,
',',
''
)
|| ','
|| l_sgwi_payroll.legal_entity_code
|| ','
|| l_sgwi_payroll.onshore
|| ','
|| l_sgwi_payroll.off_on_effdt -- added by
Nandini
|| ',' --added by Nandini
|| replace(
l_sgwi_payroll.organization,
',',
''
)
|| ','
|| l_sgwi_payroll.profit_centre
|| ','
|| replace(
l_sgwi_payroll.region,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.rig_name,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.rig_type,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.rig_location,
',',
''
)
|| ','
|| l_sgwi_payroll.employee_category
|| ','
|| l_sgwi_payroll.grade
|| ','
|| l_sgwi_payroll.assignment_status
|| ','
|| l_sgwi_payroll.passport
|| ','
|| l_sgwi_payroll.nationality
|| ','
|| l_sgwi_payroll.social_security_number
|| ','
|| l_sgwi_payroll.br_codigo
|| ','
|| l_sgwi_payroll.upn -- added by Naveed
on 05-feb-2019
|| ','
|| l_sgwi_payroll.no_le_st_dt ---- added
by Nandini for Norwegian payroll
|| ',' ---- added by Nandini for
Norwegian payroll
|| l_sgwi_payroll.no_ass_effdt ---- added
by Nandini for Norwegian payroll
|| ',' ---- added by Nandini for
Norwegian payroll
|| l_sgwi_payroll.no_reg ---- added
by Nandini for Norwegian payroll
|| ',' ---- added by Nandini for
Norwegian payroll
|| l_sgwi_payroll.no_intrinn ---- added
by Nandini for Norwegian payroll
|| ',' ---- added by Nandini for
Norwegian payroll
||
l_sgwi_payroll.collective_bargaining_date ---- added by Srikkanth M for Norwegian
payroll
|| ',' ---- added by Srikkanth M
for Norwegian payroll
|| l_sgwi_payroll.life_cycle
|| ' '
|| chr(13);
utl_file.put_line(
l_file_handle,
utl_raw.cast_to_varchar2(utl_raw.convert(
utl_raw.cast_to_raw(l_output),
'AMERICAN_AMERICA.JA16SJISTILDE',
'AMERICAN_AMERICA.AL32UTF8'
))
);
ELSE
GOTO print_output;
END IF;
-- modified by pradeep on 30th Nov 17 due to duplication issue
<< print_output >> l_output1 :=
l_sgwi_payroll.employee_number
|| ','
||
l_sgwi_payroll.starter_or_leaver
|| ','
|| l_sgwi_payroll.fornames
|| ','
||
l_sgwi_payroll.middle_name
|| ','
|| l_sgwi_payroll.sur_name
|| ','
|| l_sgwi_payroll.title
|| ','
||
l_sgwi_payroll.start_date
|| ','
|| l_sgwi_payroll.dob
|| ','
||
l_sgwi_payroll.company_end_date
|| ','
||
l_sgwi_payroll.tel_number
|| ','
|| l_sgwi_payroll.gender
|| ','
|| replace(
replace(
l_sgwi_payroll.email_address,
chr(10),
''
),
chr(13),
''
)
|| ','
||
l_sgwi_payroll.address_type
|| ','
|| replace(
l_sgwi_payroll.address1,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.address2,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.address3,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.city,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.state,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.zip_code,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.country,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.payroll_to_join,
' ',
'-'
)
|| ','
||
l_sgwi_payroll.payroll_start_date
|| ','
||
l_sgwi_payroll.payroll_join_date
|| ','
||
l_sgwi_payroll.payroll_end_date
|| ','
||
l_sgwi_payroll.payroll_leave_date
|| ','
|| replace(
l_sgwi_payroll.bank_name,
',',
''
)
|| ','
||
l_sgwi_payroll.bank_number
|| ','
|| ' '
|| ','
||
l_sgwi_payroll.bank_account_number
|| ','
--|| ' ' -- commented by
naveed on 11-feb-2019 for UPN changes
|| l_sgwi_payroll.bic_swift
-- added by naveed on 11-feb-2019 for UPN changes
|| ','
--|| ' ' -- commented by
naveed on 11-feb-2019 for UPN changes
|| l_sgwi_payroll.iban
-- added by naveed on 11-feb-2019 for UPN changes
|| ','
|| ' '
|| ','
||
l_sgwi_payroll.marital_status
|| ','
||
l_sgwi_payroll.salary_effective_date
|| ','
||
l_sgwi_payroll.annual_salary
|| ','
||
l_sgwi_payroll.salary_currency
|| ','
||
l_sgwi_payroll.hours_per_week
|| ','
|| replace(
l_sgwi_payroll.job_title,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.line_manager,
',',
''
)
|| ','
|| l_sgwi_payroll.fte
|| ','
||
l_sgwi_payroll.parttime_or_fulltime
|| ','
||
l_sgwi_payroll.entitlement_daily_rate
|| ','
||
l_sgwi_payroll.entitlement_hourly_rate
|| ','
|| replace(
l_sgwi_payroll.legal,
',',
''
)
|| ','
||
l_sgwi_payroll.legal_entity_code
|| ','
|| l_sgwi_payroll.onshore
|| ','
||
l_sgwi_payroll.off_on_effdt -- added by Nandini
|| ',' --added by Nandini
|| replace(
l_sgwi_payroll.organization,
',',
''
)
|| ','
||
l_sgwi_payroll.profit_centre
|| ','
|| replace(
l_sgwi_payroll.region,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.rig_name,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.rig_type,
',',
''
)
|| ','
|| replace(
l_sgwi_payroll.rig_location,
',',
''
)
|| ','
||
l_sgwi_payroll.employee_category
|| ','
|| l_sgwi_payroll.grade
|| ','
||
l_sgwi_payroll.assignment_status
|| ','
|| l_sgwi_payroll.passport
|| ','
||
l_sgwi_payroll.nationality
|| ','
||
l_sgwi_payroll.social_security_number
|| ','
|| l_sgwi_payroll.br_codigo
|| ','
|| l_sgwi_payroll.upn --
added by Naveed on 05-feb-2019
|| ','
||
l_sgwi_payroll.no_le_st_dt ---- added by Nandini for Norwegian payroll
|| ',' ---- added
by Nandini for Norwegian payroll
||
l_sgwi_payroll.no_ass_effdt ---- added by Nandini for Norwegian payroll
|| ',' ---- added
by Nandini for Norwegian payroll
|| l_sgwi_payroll.no_reg
---- added by Nandini for Norwegian payroll
|| ',' ---- added
by Nandini for Norwegian payroll
||
l_sgwi_payroll.no_intrinn ---- added by Nandini for Norwegian payroll
|| ',' ---- added
by Nandini for Norwegian payroll
||
l_sgwi_payroll.collective_bargaining_date ---- added by Srikkanth M for Norwegian
payroll
|| ',' ---- added
by Srikkanth M for Norwegian payroll
||
l_sgwi_payroll.life_cycle
|| ','
||
l_sgwi_payroll.paying_legal_entity
|| chr(13);
--Writing the File
fnd_file.put_line(
fnd_file.output,
l_output1
);
--Writing the File -- to dsiplay the output in case of file
transfer
END LOOP;
END LOOP;
END IF;
utl_file.fclose(l_file_handle);
IF ( p_flag = 'Y' ) THEN
transfer_file(
'XXSDL_SAFEGUARD',
l_file,
'/PAYROLL/Safeguard/Outbound/'
|| l_db_name
|| '/'
|| l_file
); --Modified by TCS on 14th Jul,2021
END IF;
END IF;
EXCEPTION
WHEN OTHERS THEN
log('The error is un-expected, please contact the technical support
representative to assist on this');
log('Error Code: ' || sqlcode);
log('Error Msg: ' || sqlerrm);
p_retcode := 2;
p_errbuff := 'Un-expected error occurred while fetching the Employee
Master Data, Please check the log file for details';
END xxsdl_no_sgwi_pay_masterdata_p;
l_count NUMBER := 1;
l_file_path1 VARCHAR2(1000);
l_file_name VARCHAR2(200);
l_file1 VARCHAR2(100);
l_file_handle utl_file.file_type;
l_file_handle1 utl_file.file_type;
l_instance v$instance.instance_name%TYPE;
l_output VARCHAR2(30000);
l_output1 VARCHAR2(30000);
p_from_date DATE;
p_to_date DATE;
l_from_date DATE;
l_to_date DATE;
q_from_date DATE;
q_to_date DATE;
l_effective_date DATE;
l_db_name VARCHAR2(20);
CURSOR c_sgwi_pay_ele (
p_from_date DATE,
p_to_date DATE,
q_from_date DATE,
q_to_date DATE,
l_payroll_name VARCHAR2,
l_business_group_id NUMBER,
l_secondary_payroll VARCHAR2,
l_effective_date DATE
) IS
SELECT
*
FROM
(
SELECT DISTINCT
*
FROM
( (
SELECT
papf.employee_number,
replace(
papf.first_name, ',', NULL
) fornames,
replace(
papf.last_name, ',', NULL
) sur_name,
pet.element_name,
to_char(
pee.effective_start_date, 'YYYY-MM-DD'
) effective_start_date,
--TO_CHAR (pee.effective_end_date,
'YYYY-MM-DD' ) effective_end_date,
replace(
to_char(
pee.effective_end_date, 'YYYY-MM-DD'
), '4712-12-31', NULL
) effective_end_date,
-- Added By Subhashree
--
MAX(DECODE(piv.name,xedsv.input_name1,piv.name)) input_name1,
xedsv.input_name1,
MAX(decode(
piv.name, xedsv.input_name1, pev.screen_entry_value
)) input_value1,
--
MAX(DECODE(piv.name,xedsv.input_name2,piv.name)) input_name2,
xedsv.input_name2,
MAX(decode(
piv.name, xedsv.input_name2, pev.screen_entry_value
)) input_value2,
--
MAX(DECODE(piv.name,xedsv.input_name3,piv.name)) input_name3,
xedsv.input_name3,
MAX(decode(
piv.name, xedsv.input_name3, pev.screen_entry_value
)) input_value3,
--
MAX(DECODE(piv.name,xedsv.input_name4,piv.name)) input_name4,
xedsv.input_name4,
MAX(decode(
piv.name, xedsv.input_name4, pev.screen_entry_value
)) input_value4,
--
MAX(DECODE(piv.name,xedsv.input_name5,piv.name)) input_name5,
xedsv.input_name5,
MAX(decode(
piv.name, xedsv.input_name5, pev.screen_entry_value
)) input_value5,
--
MAX(DECODE(piv.name,xedsv.input_name6,piv.name)) input_name6,
xedsv.input_name6,
(
CASE
WHEN ppd.segment7 IN ( 'Tender Barges', 'Semi-
tender' )
AND pet.element_name = 'Offshore Premium New'
THEN
NULL
ELSE
MAX(decode(
piv.name, xedsv.input_name6,
pev.screen_entry_value
))
END
) input_value6,
--
MAX(DECODE(piv.name,xedsv.input_name7,piv.name)) input_name7,
xedsv.input_name7,
MAX(decode(
piv.name, xedsv.input_name7, pev.screen_entry_value
)) input_value7,
--
MAX(DECODE(piv.name,xedsv.input_name8,piv.name)) input_name8 ,
xedsv.input_name8,
(
CASE
WHEN ppd.segment7 NOT IN ( 'Tender Barges', 'Semi-
tender' )
AND pet.element_name = 'Offshore Premium New'
THEN
NULL
ELSE
MAX(decode(
piv.name, xedsv.input_name8,
pev.screen_entry_value
))
END
) input_value8,
--
MAX(DECODE(piv.name,xedsv.input_name9,piv.name)) input_name9 ,
xedsv.input_name9,
MAX(decode(
piv.name, xedsv.input_name9, pev.screen_entry_value
)) input_value9,
--
MAX(DECODE(piv.name,xedsv.input_name10,piv.name)) input_name10,
xedsv.input_name10,
MAX(decode(
piv.name, xedsv.input_name10,
pev.screen_entry_value
)) input_value10,
--
MAX(DECODE(piv.name,xedsv.input_name11,piv.name)) input_name11,
xedsv.input_name11,
MAX(decode(
piv.name, xedsv.input_name11,
pev.screen_entry_value
)) input_value11,
BEGIN
l_effective_date := fnd_date.canonical_to_date(p_effective_date);
SELECT
16
|| '-'
|| ( to_char(
add_months(
nvl(
l_effective_date, sysdate
), - 1
), 'MON-YYYY'
) )
INTO p_from_date
FROM
dual;
SELECT
15
|| '-'
|| ( to_char(
nvl(
l_effective_date, sysdate
), 'MON-YYYY'
) )
INTO p_to_date
FROM
dual;
SELECT
10
|| '-'
|| ( to_char(
add_months(
nvl(
l_effective_date, sysdate
), - 1
), 'MON-YYYY'
) )
INTO q_from_date
FROM
dual;
SELECT
10
|| '-'
|| ( to_char(
nvl(
l_effective_date, sysdate
), 'MON-YYYY'
) )
INTO q_to_date
FROM
dual;
SELECT
'01'
|| '-'
|| to_char(
nvl(
l_effective_date, sysdate
), 'MON-YYYY'
)
INTO l_from_date
FROM
dual;
SELECT
last_day(
nvl(
l_effective_date, sysdate
)
)
INTO l_to_date
FROM
dual;
SELECT
directory_path
INTO l_file_path1
FROM
dba_directories
WHERE
directory_name = 'XXSDL_SAFEGUARD'; --- Added by TCS on 14th Jul'21
fnd_file.put_line(
fnd_file.log,
'XXSDL_SAFEGUARD Directory Path - ' || l_file_path1
); --- Added by TCS on 14th Jul'21
SELECT
name
INTO l_db_name
FROM
v$pdbs; --- Modified by TCS on 06-JUL-2021
l_file_handle1 := utl_file.fopen(
l_file_path1,
l_file1,
'W'
);
utl_file.put_line(
l_file_handle1,
utl_raw.cast_to_varchar2(utl_raw.convert(
utl_raw.cast_to_raw(nvl(
p_payroll_name,
p_payroll_group
'AMERICAN_AMERICA.JA16SJISTILDE',
'AMERICAN_AMERICA.AL32UTF8'
))
);
utl_file.put_line(
l_file_handle1,
utl_raw.cast_to_varchar2(utl_raw.convert(
utl_raw.cast_to_raw('--------------------------------------------------------------
------------'),
'AMERICAN_AMERICA.JA16SJISTILDE',
'AMERICAN_AMERICA.AL32UTF8'
))
);
utl_file.put_line(
l_file_handle1,
utl_raw.cast_to_varchar2(utl_raw.convert(
utl_raw.cast_to_raw('employee_number'
|| ','
|| 'Fornames'
|| ','
|| 'Sur_Name'
|| ','
|| 'element_name'
|| ','
|| 'effective_start_date'
|| ','
|| 'effective_end_date'
|| ','
|| 'input_name1'
|| ','
|| 'input_value1'
|| ','
|| 'input_name2'
|| ','
|| 'input_value2'
|| ','
|| 'input_name3'
|| ','
|| 'input_value3'
|| ','
|| 'input_name4'
|| ','
|| 'input_value4'
|| ','
|| 'input_name5'
|| ','
|| 'input_value5'
|| ','
|| 'input_name6'
|| ','
|| 'input_value6'
|| ','
|| 'input_name7'
|| ','
|| 'input_value7'
|| ','
|| 'input_name8'
|| ','
|| 'input_value8'
|| ','
|| 'input_name9'
|| ','
|| 'input_value9'
|| ','
|| 'input_name10'
|| ','
|| 'input_value10'
|| ','
|| 'input_name11'
|| ','
|| 'input_value11'
|| ','
|| 'input_name12'
|| ','
|| 'input_value12'
|| ','
|| 'input_name13'
|| ','
|| 'input_value13'
|| ','
|| 'input_name14'
|| ','
|| 'input_value14'
|| ','
|| 'input_name15'
|| ','
|| 'input_value15'
|| ','
|| 'input_name16'
|| ','
|| 'input_value16'
|| ','
|| 'input_name17'
|| ','
|| 'input_value17'
|| ','
|| 'input_name18'
|| ','
|| 'input_value18'
|| ','
|| 'input_name19'
|| ','
|| 'input_value19'
|| ','
|| 'input_name20'
|| ','
|| 'input_value20'
|| ','
|| 'input_name21'
|| ','
|| 'input_value21'
|| ','
|| 'input_name22'
|| ','
|| 'input_value22'),
'AMERICAN_AMERICA.JA16SJISTILDE',
'AMERICAN_AMERICA.AL32UTF8'
))
);
END IF;
/*-- If payroll group is given and payroll name is null--*/
IF p_payroll_name IS NULL THEN
FOR i IN (
SELECT
payroll_name,
business_group_id,
attribute2
FROM
pay_all_payrolls_f
WHERE
attribute1 = p_payroll_group
AND nvl(
l_effective_date, sysdate
) BETWEEN effective_start_date AND effective_end_date
) LOOP
fnd_file.put_line(
fnd_file.output,
i.payroll_name || ' Permanent Entitlements'
);
fnd_file.put_line(
fnd_file.output,
'--------------------------------------------------------------------------'
);
fnd_file.put_line(
fnd_file.output,
'employee_number'
|| ','
|| 'Fornames'
|| ','
|| 'Sur_Name'
|| ','
|| 'element_name'
|| ','
|| 'effective_start_date'
|| ','
|| 'effective_end_date'
|| ','
|| 'input_name1'
|| ','
|| 'input_value1'
|| ','
|| 'input_name2'
|| ','
|| 'input_value2'
|| ','
|| 'input_name3'
|| ','
|| 'input_value3'
|| ','
|| 'input_name4'
|| ','
|| 'input_value4'
|| ','
|| 'input_name5'
|| ','
|| 'input_value5'
|| ','
|| 'input_name6'
|| ','
|| 'input_value6'
|| ','
|| 'input_name7'
|| ','
|| 'input_value7'
|| ','
|| 'input_name8'
|| ','
|| 'input_value8'
|| ','
|| 'input_name9'
|| ','
|| 'input_value9'
|| ','
|| 'input_name10'
|| ','
|| 'input_value10'
|| ','
|| 'input_name11'
|| ','
|| 'input_value11'
|| ','
|| 'input_name12'
|| ','
|| 'input_value12'
|| ','
|| 'input_name13'
|| ','
|| 'input_value13'
|| ','
|| 'input_name14'
|| ','
|| 'input_value14'
|| ','
|| 'input_name15'
|| ','
|| 'input_value15'
|| ','
|| 'input_name16'
|| ','
|| 'input_value16'
|| ','
|| 'input_name17'
|| ','
|| 'input_value17'
|| ','
|| 'input_name18'
|| ','
|| 'input_value18'
|| ','
|| 'input_name19'
|| ','
|| 'input_value19'
|| ','
|| 'input_name20'
|| ','
|| 'input_value20'
|| ','
|| 'input_name21'
|| ','
|| 'input_value21'
|| ','
|| 'input_name22'
|| ','
|| 'input_value22'
);
utl_file.put_line(
l_file_handle1,
utl_raw.cast_to_varchar2(utl_raw.convert(
utl_raw.cast_to_raw(l_output),
'AMERICAN_AMERICA.JA16SJISTILDE',
'AMERICAN_AMERICA.AL32UTF8'
))
);
END IF;
l_output1 := l_sgwi_pay_ele.employee_number
|| ','
|| l_sgwi_pay_ele.fornames
|| ','
|| l_sgwi_pay_ele.sur_name
|| ','
|| l_sgwi_pay_ele.element_name
|| ','
|| l_sgwi_pay_ele.effective_start_date
|| ','
|| l_sgwi_pay_ele.effective_end_date
|| ','
|| l_sgwi_pay_ele.input_name1
|| ','
|| l_sgwi_pay_ele.input_value1
|| ','
|| l_sgwi_pay_ele.input_name2
|| ','
|| l_sgwi_pay_ele.input_value2
|| ','
|| l_sgwi_pay_ele.input_name3
|| ','
|| l_sgwi_pay_ele.input_value3
|| ','
|| l_sgwi_pay_ele.input_name4
|| ','
|| l_sgwi_pay_ele.input_value4
|| ','
|| l_sgwi_pay_ele.input_name5
|| ','
|| l_sgwi_pay_ele.input_value5
|| ','
|| l_sgwi_pay_ele.input_name6
|| ','
|| l_sgwi_pay_ele.input_value6
|| ','
|| l_sgwi_pay_ele.input_name7
|| ','
|| l_sgwi_pay_ele.input_value7
|| ','
|| l_sgwi_pay_ele.input_name8
|| ','
|| l_sgwi_pay_ele.input_value8
|| ','
|| l_sgwi_pay_ele.input_name9
|| ','
|| l_sgwi_pay_ele.input_value9
|| ','
|| l_sgwi_pay_ele.input_name10
|| ','
|| l_sgwi_pay_ele.input_value10
|| ','
|| l_sgwi_pay_ele.input_name11
|| ','
|| l_sgwi_pay_ele.input_value11
|| ','
|| l_sgwi_pay_ele.input_name12
|| ','
|| l_sgwi_pay_ele.input_value12
|| ','
|| l_sgwi_pay_ele.input_name13
|| ','
|| l_sgwi_pay_ele.input_value13
|| ','
|| l_sgwi_pay_ele.input_name14
|| ','
|| l_sgwi_pay_ele.input_value14
|| ','
|| l_sgwi_pay_ele.input_name15
|| ','
|| l_sgwi_pay_ele.input_value15
|| ','
|| l_sgwi_pay_ele.input_name16
|| ','
|| l_sgwi_pay_ele.input_value16
|| ','
|| l_sgwi_pay_ele.input_name17
|| ','
|| l_sgwi_pay_ele.input_value17
|| ','
|| l_sgwi_pay_ele.input_name18
|| ','
|| l_sgwi_pay_ele.input_value18
|| ','
|| l_sgwi_pay_ele.input_name19
|| ','
|| l_sgwi_pay_ele.input_value19
|| ','
|| l_sgwi_pay_ele.input_name20
|| ','
|| l_sgwi_pay_ele.input_value20
|| ','
|| l_sgwi_pay_ele.input_name21
|| ','
|| l_sgwi_pay_ele.input_value21
|| ','
|| l_sgwi_pay_ele.input_name22
|| ','
|| l_sgwi_pay_ele.input_value22
|| chr(13);
fnd_file.put_line(
fnd_file.output,
l_output1
);
END LOOP;
fnd_file.put_line(
fnd_file.output,
'--------------------------------------------------------------------------'
|| chr(13)
|| chr(13)
);
END LOOP;
/*--If payroll group and payroll name both are provided--*/
ELSE
fnd_file.put_line(
fnd_file.output,
p_payroll_name || ' Permanent Entitlements'
);
fnd_file.put_line(
fnd_file.output,
'--------------------------------------------------------------------------'
);
fnd_file.put_line(
fnd_file.output,
'employee_number'
|| ','
|| 'Fornames'
|| ','
|| 'Sur_Name'
|| ','
|| 'element_name'
|| ','
|| 'effective_start_date'
|| ','
|| 'effective_end_date'
|| ','
|| 'input_name1'
|| ','
|| 'input_value1'
|| ','
|| 'input_name2'
|| ','
|| 'input_value2'
|| ','
|| 'input_name3'
|| ','
|| 'input_value3'
|| ','
|| 'input_name4'
|| ','
|| 'input_value4'
|| ','
|| 'input_name5'
|| ','
|| 'input_value5'
|| ','
|| 'input_name6'
|| ','
|| 'input_value6'
|| ','
|| 'input_name7'
|| ','
|| 'input_value7'
|| ','
|| 'input_name8'
|| ','
|| 'input_value8'
|| ','
|| 'input_name9'
|| ','
|| 'input_value9'
|| ','
|| 'input_name10'
|| ','
|| 'input_value10'
|| ','
|| 'input_name11'
|| ','
|| 'input_value11'
|| ','
|| 'input_name12'
|| ','
|| 'input_value12'
|| ','
|| 'input_name13'
|| ','
|| 'input_value13'
|| ','
|| 'input_name14'
|| ','
|| 'input_value14'
|| ','
|| 'input_name15'
|| ','
|| 'input_value15'
|| ','
|| 'input_name16'
|| ','
|| 'input_value16'
|| ','
|| 'input_name17'
|| ','
|| 'input_value17'
|| ','
|| 'input_name18'
|| ','
|| 'input_value18'
|| ','
|| 'input_name19'
|| ','
|| 'input_value19'
|| ','
|| 'input_name20'
|| ','
|| 'input_value20'
|| ','
|| 'input_name21'
|| ','
|| 'input_value21'
|| ','
|| 'input_name22'
|| ','
|| 'input_value22'
);
FOR i IN (
SELECT
business_group_id,
attribute2
FROM
pay_all_payrolls_f
WHERE
payroll_name = p_payroll_name
AND nvl(
l_effective_date, sysdate
) BETWEEN effective_start_date AND effective_end_date
) LOOP
FOR l_sgwi_pay_ele IN c_sgwi_pay_ele(
p_from_date,
p_to_date,
q_from_date,
q_to_date,
p_payroll_name,
i.business_group_id,
i.attribute2,
l_effective_date
) LOOP
IF p_flag = 'Y' THEN
l_output := l_sgwi_pay_ele.employee_number
|| ','
|| l_sgwi_pay_ele.fornames
|| ','
|| l_sgwi_pay_ele.sur_name
|| ','
|| l_sgwi_pay_ele.element_name
|| ','
|| l_sgwi_pay_ele.effective_start_date
|| ','
|| l_sgwi_pay_ele.effective_end_date
|| ','
|| l_sgwi_pay_ele.input_name1
|| ','
|| l_sgwi_pay_ele.input_value1
|| ','
|| l_sgwi_pay_ele.input_name2
|| ','
|| l_sgwi_pay_ele.input_value2
|| ','
|| l_sgwi_pay_ele.input_name3
|| ','
|| l_sgwi_pay_ele.input_value3
|| ','
|| l_sgwi_pay_ele.input_name4
|| ','
|| l_sgwi_pay_ele.input_value4
|| ','
|| l_sgwi_pay_ele.input_name5
|| ','
|| l_sgwi_pay_ele.input_value5
|| ','
|| l_sgwi_pay_ele.input_name6
|| ','
|| l_sgwi_pay_ele.input_value6
|| ','
|| l_sgwi_pay_ele.input_name7
|| ','
|| l_sgwi_pay_ele.input_value7
|| ','
|| l_sgwi_pay_ele.input_name8
|| ','
|| l_sgwi_pay_ele.input_value8
|| ','
|| l_sgwi_pay_ele.input_name9
|| ','
|| l_sgwi_pay_ele.input_value9
|| ','
|| l_sgwi_pay_ele.input_name10
|| ','
|| l_sgwi_pay_ele.input_value10
|| ','
|| l_sgwi_pay_ele.input_name11
|| ','
|| l_sgwi_pay_ele.input_value11
|| ','
|| l_sgwi_pay_ele.input_name12
|| ','
|| l_sgwi_pay_ele.input_value12
|| ','
|| l_sgwi_pay_ele.input_name13
|| ','
|| l_sgwi_pay_ele.input_value13
|| ','
|| l_sgwi_pay_ele.input_name14
|| ','
|| l_sgwi_pay_ele.input_value14
|| ','
|| l_sgwi_pay_ele.input_name15
|| ','
|| l_sgwi_pay_ele.input_value15
|| ','
|| l_sgwi_pay_ele.input_name16
|| ','
|| l_sgwi_pay_ele.input_value16
|| ','
|| l_sgwi_pay_ele.input_name17
|| ','
|| l_sgwi_pay_ele.input_value17
|| ','
|| l_sgwi_pay_ele.input_name18
|| ','
|| l_sgwi_pay_ele.input_value18
|| ','
|| l_sgwi_pay_ele.input_name19
|| ','
|| l_sgwi_pay_ele.input_value19
|| ','
|| l_sgwi_pay_ele.input_name20
|| ','
|| l_sgwi_pay_ele.input_value20
|| ','
|| l_sgwi_pay_ele.input_name21
|| ','
|| l_sgwi_pay_ele.input_value21
|| ','
|| l_sgwi_pay_ele.input_name22
|| ','
|| l_sgwi_pay_ele.input_value22
|| chr(13);
utl_file.put_line(
l_file_handle1,
utl_raw.cast_to_varchar2(utl_raw.convert(
utl_raw.cast_to_raw(l_output),
'AMERICAN_AMERICA.JA16SJISTILDE',
'AMERICAN_AMERICA.AL32UTF8'
))
);
END IF;
l_output1 := l_sgwi_pay_ele.employee_number
|| ','
|| l_sgwi_pay_ele.fornames
|| ','
|| l_sgwi_pay_ele.sur_name
|| ','
|| l_sgwi_pay_ele.element_name
|| ','
|| l_sgwi_pay_ele.effective_start_date
|| ','
|| l_sgwi_pay_ele.effective_end_date
|| ','
|| l_sgwi_pay_ele.input_name1
|| ','
|| l_sgwi_pay_ele.input_value1
|| ','
|| l_sgwi_pay_ele.input_name2
|| ','
|| l_sgwi_pay_ele.input_value2
|| ','
|| l_sgwi_pay_ele.input_name3
|| ','
|| l_sgwi_pay_ele.input_value3
|| ','
|| l_sgwi_pay_ele.input_name4
|| ','
|| l_sgwi_pay_ele.input_value4
|| ','
|| l_sgwi_pay_ele.input_name5
|| ','
|| l_sgwi_pay_ele.input_value5
|| ','
|| l_sgwi_pay_ele.input_name6
|| ','
|| l_sgwi_pay_ele.input_value6
|| ','
|| l_sgwi_pay_ele.input_name7
|| ','
|| l_sgwi_pay_ele.input_value7
|| ','
|| l_sgwi_pay_ele.input_name8
|| ','
|| l_sgwi_pay_ele.input_value8
|| ','
|| l_sgwi_pay_ele.input_name9
|| ','
|| l_sgwi_pay_ele.input_value9
|| ','
|| l_sgwi_pay_ele.input_name10
|| ','
|| l_sgwi_pay_ele.input_value10
|| ','
|| l_sgwi_pay_ele.input_name11
|| ','
|| l_sgwi_pay_ele.input_value11
|| ','
|| l_sgwi_pay_ele.input_name12
|| ','
|| l_sgwi_pay_ele.input_value12
|| ','
|| l_sgwi_pay_ele.input_name13
|| ','
|| l_sgwi_pay_ele.input_value13
|| ','
|| l_sgwi_pay_ele.input_name14
|| ','
|| l_sgwi_pay_ele.input_value14
|| ','
|| l_sgwi_pay_ele.input_name15
|| ','
|| l_sgwi_pay_ele.input_value15
|| ','
|| l_sgwi_pay_ele.input_name16
|| ','
|| l_sgwi_pay_ele.input_value16
|| ','
|| l_sgwi_pay_ele.input_name17
|| ','
|| l_sgwi_pay_ele.input_value17
|| ','
|| l_sgwi_pay_ele.input_name18
|| ','
|| l_sgwi_pay_ele.input_value18
|| ','
|| l_sgwi_pay_ele.input_name19
|| ','
|| l_sgwi_pay_ele.input_value19
|| ','
|| l_sgwi_pay_ele.input_name20
|| ','
|| l_sgwi_pay_ele.input_value20
|| ','
|| l_sgwi_pay_ele.input_name21
|| ','
|| l_sgwi_pay_ele.input_value21
|| ','
|| l_sgwi_pay_ele.input_name22
|| ','
|| l_sgwi_pay_ele.input_value22
|| chr(13);
fnd_file.put_line(
fnd_file.output,
l_output1
);
END LOOP;
END LOOP;
utl_file.fclose(l_file_handle1);
END IF;
SELECT
name
INTO l_db_name
FROM
v$pdbs; --- Modified by TCS on 06-JUL-2021
END IF;
EXCEPTION
WHEN utl_file.invalid_path THEN
fnd_file.put_line(
fnd_file.log,
'ERROR: INVALID_PATH IN SUB-PROC ' || sqlerrm
);
utl_file.fclose_all;
p_retcode := 2;
p_errbuff := 'Un-expected error occurred while fetching the Permanent
Entitlements data, Please check the log file for details';
WHEN utl_file.invalid_mode THEN
fnd_file.put_line(
fnd_file.log,
'ERROR: INVALID_MODE IN SUB-PROC ' || sqlerrm
);
utl_file.fclose_all;
p_retcode := 2;
p_errbuff := 'Un-expected error occurred while fetching the Permanent
Entitlements data, Please check the log file for details';
WHEN utl_file.invalid_filehandle THEN
fnd_file.put_line(
fnd_file.log,
'ERROR: INVALID_FILEHANDLE IN SUB-PROC ' || sqlerrm
);
utl_file.fclose_all;
p_retcode := 2;
p_errbuff := 'Un-expected error occurred while fetching the Permanent
Entitlements data, Please check the log file for details';
WHEN utl_file.invalid_operation THEN
fnd_file.put_line(
fnd_file.log,
'ERROR: INVALID_OPERATION IN SUB-PROC ' || sqlerrm
);
utl_file.fclose_all;
p_retcode := 2;
p_errbuff := 'Un-expected error occurred while fetching the Permanent
Entitlements data, Please check the log file for details';
WHEN utl_file.read_error THEN
fnd_file.put_line(
fnd_file.log,
'ERROR: READ_ERROR IN SUB-PROC ' || sqlerrm
);
utl_file.fclose_all;
p_retcode := 2;
p_errbuff := 'Un-expected error occurred while fetching the Permanent
Entitlements data, Please check the log file for details';
WHEN utl_file.write_error THEN
fnd_file.put_line(
fnd_file.log,
'ERROR: WRITE_ERROR IN SUB-PROC ' || sqlerrm
);
utl_file.fclose_all;
p_retcode := 2;
p_errbuff := 'Un-expected error occurred while fetching the Permanent
Entitlements data, Please check the log file for details';
WHEN utl_file.internal_error THEN
fnd_file.put_line(
fnd_file.log,
'ERROR: INTERNAL_ERROR IN SUB-PROC ' || sqlerrm
);
utl_file.fclose_all;
p_retcode := 2;
p_errbuff := 'Un-expected error occurred while fetching the Permanent
Entitlements data, Please check the log file for details';
WHEN utl_file.invalid_maxlinesize THEN
fnd_file.put_line(
fnd_file.log,
'ERROR: INVALID_MAXLINESIZE IN SUB-PROC ' || sqlerrm
);
utl_file.fclose_all;
p_retcode := 2;
p_errbuff := 'Un-expected error occurred while fetching the Permanent
Entitlements data, Please check the log file for details';
WHEN no_data_found THEN
fnd_file.put_line(
fnd_file.log,
'ERROR: NO_DATA_FOUND IN SUB-PROC ' || sqlerrm
);
utl_file.fclose_all;
p_retcode := 2;
p_errbuff := 'Un-expected error occurred while fetching the Permanent
Entitlements data, Please check the log file for details';
WHEN value_error THEN
fnd_file.put_line(
fnd_file.log,
'ERROR: VALUE_ERROR IN SUB-PROC' || sqlerrm
);
utl_file.fclose_all;
p_retcode := 2;
p_errbuff := 'Un-expected error occurred while fetching the Permanent
Entitlements data, Please check the log file for details';
WHEN OTHERS THEN
fnd_file.put_line(
fnd_file.log,
'ERROR: OTHERS IN SUB-PROC ' || sqlerrm
);
utl_file.fclose_all;
p_retcode := 2;
p_errbuff := 'Un-expected error occurred while fetching the Permanent
Entitlements data, Please check the log file for details';
END xxsdl_no_sgwi_pay_element_p;
PROCEDURE transfer_file (
p_from VARCHAR2,
p_file VARCHAR2,
p_to VARCHAR2
) IS
l_conn utl_tcp.connection;
l_db VARCHAR2(250); --- added by TCS on 30th April 2021
l_tag VARCHAR2(100); --- added by TCS on 30th April 2021
l_host VARCHAR2(250); --- added by TCS on 30th April 2021
l_port NUMBER(20); --- added by TCS on 30th April 2021
l_user VARCHAR2(250); --- added by TCS on 30th April 2021
l_pass VARCHAR2(250); --- added by TCS on 30th April 2021
BEGIN
fnd_file.put_line(
fnd_file.log,
'Transfer:'
|| p_from
|| ':'
|| p_file
|| ':'
|| p_to
|| ':'
);
BEGIN
SELECT
name
INTO l_db
FROM
v$pdbs; --- Modified by TCS on 06-JUL-2021
EXCEPTION
WHEN no_data_found THEN
fnd_file.put_line(
fnd_file.log,
'ERROR: NO_DATA_FOUND IN FETCHING INSTANCE DETAILS
' || sqlerrm
);
WHEN OTHERS THEN
fnd_file.put_line(
fnd_file.log,
'ERROR: UNEXPECTED ERROR IN FETCHING INSTANCE
DETAILS ' || sqlerrm
);
END;
BEGIN
SELECT
meaning,
attribute1,
attribute2,
attribute3
INTO
l_host,
l_user,
l_pass,
l_port
FROM
fnd_lookup_values
WHERE
lookup_type = 'XXSDL_FTP_SERVER'
AND language = 'US'
AND enabled_flag = 'Y'
AND end_date_active IS NULL
AND tag = l_tag;
EXCEPTION
WHEN no_data_found THEN
fnd_file.put_line(
fnd_file.log,
'ERROR: NO_DATA_FOUND IN FTP LOOKUP ' || sqlerrm
);
WHEN OTHERS THEN
fnd_file.put_line(
fnd_file.log,
'ERROR: UNEXPECTED ERROR IN FETCHING FTP DETAILS '
|| sqlerrm
);
END;
fnd_file.put_line(
fnd_file.log,
'For Environment '
|| l_db
|| ', FTP Server fetched - '
|| l_host
);
BEGIN
l_conn := xxsdl_ftp.login(
p_host => l_host,
p_port => l_port,
p_user => l_user,
p_pass => l_pass
);
EXCEPTION
WHEN OTHERS THEN
l_conn := xxsdl_ftp.login(
p_host => l_host,
p_port => l_port,
p_user => l_user,
p_pass => l_pass
);
END;
/*l_conn :=
xxsdl_ftp.login ('sdrlhpprftp01p.corp.local', --- commented out by TCS
on 30th April 2021
'21',
'regnhk',
'ftp2nt'
); */
xxsdl_ftp.binary(p_conn => l_conn);
xxsdl_ftp.put(
p_conn => l_conn,
p_from_dir => p_from,
p_from_file => p_file,
p_to_file => p_to
);
xxsdl_ftp.logout(l_conn);
END;
PROCEDURE log (
p_text VARCHAR2
) IS
BEGIN
fnd_file.put_line(
fnd_file.log,
p_text
);
END;
/*Function to validate if duplicate Additional NIDs exist for any of the employees
belonging to the payroll*/
FUNCTION validate_dups (
payroll_name VARCHAR2
) RETURN NUMBER IS
l_validate NUMBER;
CURSOR c_nid_dups (
l_payroll_name VARCHAR2
) IS
SELECT
ppei.person_id,
COUNT(ppei.person_id),
ppei.pei_attribute_category
FROM
per_people_extra_info ppei
WHERE
1 = 1
AND ppei.information_type = 'SG_NATIONAL_IDENTIFIER'
AND ppei.pei_information2 IS NULL
AND ppei.person_id IN (
SELECT DISTINCT
papf.person_id
FROM
per_all_people_f papf, per_all_assignments_f paaf,
pay_all_payrolls_f ppf
WHERE
1 = 1
AND sysdate BETWEEN papf.effective_start_date AND
papf.effective_end_date
AND sysdate BETWEEN paaf.effective_start_date AND
paaf.effective_end_date
AND papf.person_id = paaf.person_id
AND paaf.payroll_id = ppf.payroll_id
AND ppf.payroll_name = l_payroll_name
)
GROUP BY
ppei.person_id,
ppei.pei_attribute_category
HAVING
COUNT(ppei.person_id) > 1;
TYPE tt_c_nid_dups IS
TABLE OF c_nid_dups%rowtype INDEX BY PLS_INTEGER;
l_tt_c_nid_dups tt_c_nid_dups;
BEGIN
l_validate := 0;
OPEN c_nid_dups(payroll_name);
--LOOP
FETCH c_nid_dups
BULK COLLECT INTO l_tt_c_nid_dups;
ELSE
l_validate := 0;
END IF;
/*Function to fetch employee details having diplicate Additional NIDs and print*/
FUNCTION print_nid_dup_det (
per_id NUMBER
) RETURN NUMBER IS
l_success NUMBER;
l_emp_num per_all_people_f.employee_number%TYPE;
l_attr_categ per_people_extra_info.pei_attribute_category%TYPE;
BEGIN
--log(' printing per Id: '||per_id);
SELECT DISTINCT
papf.employee_number,
ppei.pei_attribute_category
INTO
l_emp_num,
l_attr_categ
FROM
per_all_people_f papf,
per_people_extra_info ppei
WHERE
1 = 1
AND papf.person_id = ppei.person_id
AND sysdate BETWEEN papf.effective_start_date AND
papf.effective_end_date
AND ppei.information_type = 'SG_NATIONAL_IDENTIFIER'
AND papf.current_employee_flag = 'Y'
AND papf.person_id = per_id;
FUNCTION validate_bank_dups (
payroll_name VARCHAR2
-- q_from_date DATE,
-- l_to_date DATE,
) RETURN NUMBER IS
l_validate NUMBER;
CURSOR c_bank_dups (
l_payroll_name VARCHAR2
) IS
SELECT
ppei.person_id,
COUNT(ppei.person_id)
FROM
per_people_extra_info ppei
WHERE
1 = 1
AND ppei.information_type = 'SO_BANK_DETAILS'
AND ppei.pei_information5 = 'Salary'
AND nvl(
to_date(
ppei.pei_information10, 'YYYY-MM-DD HH24:MI:SS'
), sysdate
) >= trunc(sysdate)
AND ppei.person_id IN (
SELECT DISTINCT
papf.person_id
FROM
per_all_people_f papf, per_all_assignments_f paaf,
pay_all_payrolls_f ppf
WHERE
1 = 1
AND sysdate BETWEEN papf.effective_start_date AND
papf.effective_end_date
AND sysdate BETWEEN paaf.effective_start_date AND
paaf.effective_end_date
-- AND ( paaf.effective_start_date
-- BETWEEN q_from_date
-- AND l_to_date
-- OR paaf.last_update_date
-- BETWEEN q_from_date
-- AND l_to_date
-- )
/*Added by Rajitha*/
AND papf.person_id = paaf.person_id
AND paaf.payroll_id = ppf.payroll_id
AND ppf.payroll_name = l_payroll_name
)
GROUP BY
ppei.person_id
HAVING
COUNT(ppei.person_id) > 1;
TYPE tt_c_bank_dups IS
TABLE OF c_bank_dups%rowtype INDEX BY PLS_INTEGER;
l_tt_c_bank_dups tt_c_bank_dups;
BEGIN
l_validate := 0;
OPEN c_bank_dups(payroll_name);
--LOOP
FETCH c_bank_dups
BULK COLLECT INTO l_tt_c_bank_dups;
ELSE
l_validate := 0;
END IF;
FUNCTION print_bank_dup_det (
per_id NUMBER
) RETURN NUMBER IS
l_success NUMBER;
l_emp_num per_all_people_f.employee_number%TYPE;
BEGIN
SELECT DISTINCT
papf.employee_number
INTO l_emp_num
FROM
per_all_people_f papf,
per_people_extra_info ppei
WHERE
1 = 1
AND papf.person_id = ppei.person_id
AND sysdate BETWEEN papf.effective_start_date AND
papf.effective_end_date
AND ppei.information_type = 'SO_BANK_DETAILS'
--AND papf.current_employee_flag='Y' --Commented by Rajitha
AND papf.person_id = per_id;
FUNCTION check_residential_address (
l_payroll_name VARCHAR2
) RETURN NUMBER IS
l_success NUMBER;
l_emp_num per_all_people_f.employee_number%TYPE;
l_effective_date DATE;
l_to_date DATE;
q_from_date DATE;
q_to_date DATE;
CURSOR cur_empnonresaddress IS
SELECT DISTINCT
papf.employee_number
INTO l_emp_num
FROM
per_all_people_f papf,
per_all_assignments_f paaf,
per_addresses pa,
pay_all_payrolls_f ppf
WHERE
1 = 1
AND papf.person_id = pa.person_id
AND papf.person_id = paaf.person_id
AND trunc(sysdate) BETWEEN papf.effective_start_date AND
papf.effective_end_date
AND pa.primary_flag = 'Y'
AND pa.address_type NOT LIKE '%RA%'
AND paaf.payroll_id = ppf.payroll_id
AND ppf.payroll_name = l_payroll_name
AND trunc(sysdate) BETWEEN papf.effective_start_date AND
papf.effective_end_date
AND trunc(sysdate) BETWEEN paaf.effective_start_date AND
paaf.effective_end_date
AND trunc(
nvl(
to_date(
l_effective_date, 'DD-MON-YYYY'
), sysdate
)
) BETWEEN date_from AND nvl(
pa.date_to, '31-DEC-4712'
);
BEGIN
FOR i IN cur_empnonresaddress LOOP
log(' Employee with employee number '
|| ' '
|| i.employee_number
|| ' '
|| ' has no Active primary Residential Address Type ');
l_success := 1;
END LOOP;
RETURN l_success;
EXCEPTION
WHEN too_many_rows THEN
log(' Employee with employee number '
|| l_emp_num
|| ' has more than one residential address type ');
l_success := 1;
RETURN l_success;
WHEN no_data_found THEN
l_success := 1;
RETURN l_success;
WHEN OTHERS THEN
log(' Error occurred while printing details of employees residential
address Type, please contact HPE representative');
log(' Error Code: ' || sqlcode);
log(' Error Msg: ' || sqlerrm);
l_success := 0;
RETURN l_success;
END;
END xxsdl_no_sgwi_payroll_int_pkg;