Вы находитесь на странице: 1из 43

CREATE OR REPLACE PACKAGE BODY APPS.

"XXSCC_SIT_APRVL_PKG_1"

/*=================================================================================
===================*
| ORIGINAL AUTHOR: Shreyas S
|
| CREATION DATE: 22-Mar_2011
|
| PACKAGE NAME: XXSCC_SIT_APRVL_PKG
|
|
|
| DESCRIPTION
|
| This package returns the List of Approvers including FYI Notifications for
S.I.T requests |
| as per S.C.C requirements.
|
|
|
|
|
|
|

*==================================================================================
===================*/
AS
--
g_wf_aprvr_udt VARCHAR2 (30) DEFAULT 'XXSCC_HRMS_WF_APPROVERS';
g_udt_col_wf VARCHAR2 (30) DEFAULT 'SSHR';
g_olm_aprvr_udt VARCHAR2 (30) DEFAULT 'XXSCC_OLM_ENROLMENT_APPROVERS';
g_udt_col_olm VARCHAR2 (30) DEFAULT 'SCC';
--
g_hr_mgr VARCHAR2 (60) DEFAULT 'HR Manager';
g_trv_spec VARCHAR2 (60) DEFAULT 'Travel Specialist';
g_tmkp_opr_ho VARCHAR2 (60) DEFAULT 'Timekeeping Operator HO';
g_tmkp_opr_pl VARCHAR2 (60) DEFAULT 'Timekeeping Operator Plant';
g_gvmt_rln_spec VARCHAR2 (60) DEFAULT 'Government Relations Specialist';
g_ctrllr_prsnl VARCHAR2 (60) DEFAULT 'Controller Personnel';
g_chf_acc VARCHAR2 (60) DEFAULT 'Chief Accountant';
g_pay_spec VARCHAR2 (60) DEFAULT 'Payroll Specialist';
g_sfty_mgr VARCHAR2 (60) DEFAULT 'Safety Manager';
g_prsnl_proc VARCHAR2 (60) DEFAULT 'Personnel Processor';
g_sr_prsnl_proc VARCHAR2 (60) DEFAULT 'Sr. Personnel Processor';
g_ins_spec VARCHAR2 (60) DEFAULT 'Insurance Specialist';
g_housing_ctrlr_pl VARCHAR2 (60) DEFAULT 'Housing Controller Plant';
g_housing_ctrlr_ho VARCHAR2 (60) DEFAULT 'Housing Controller HO';
g_pp_bank_loan VARCHAR2 (60) DEFAULT 'Personnel Processor BL';
g_pp_furn_loan VARCHAR2 (60) DEFAULT 'Personnel Processor FL';
g_pp_car_loan VARCHAR2 (60) DEFAULT 'Personnel Processor CL';
g_pp_intro_ltr_ho VARCHAR2 (60) DEFAULT 'Personnel Processor IL HO';
g_pp_intro_ltr_pl VARCHAR2 (60) DEFAULT 'Personnel Processor IL Plant';

--
g_dept_type VARCHAR2 (60) DEFAULT 'Department';
g_divsn_type VARCHAR2 (60) DEFAULT 'Division';
g_section_type VARCHAR2 (60) DEFAULT 'Section';
--
g_abs_loc_ain_dar VARCHAR2 (60) DEFAULT 'Ain Dar Plant';
g_abs_loc_hofuf VARCHAR2 (60) DEFAULT 'Hofuf Plant';
g_pp1 VARCHAR2 (10) DEFAULT 'PP1';
g_pp2 VARCHAR2 (10) DEFAULT 'PP2';
g_pp3 VARCHAR2 (10) DEFAULT 'PP3';
---g_reg_payroll VARCHAR2 (60) DEFAULT 'SCC Regular Payroll';
--
g_dummy_value VARCHAR2 (30) DEFAULT 'XXXXX';
--
FUNCTION get_id_flex_num
(
p_str_code IN VARCHAR2)
RETURN NUMBER
IS
l_id NUMBER DEFAULT NULL;
BEGIN
SELECT id_flex_num
INTO l_id
FROM fnd_id_flex_structures
WHERE id_flex_structure_code = p_str_code;
RETURN l_id;
END;
--
--
FUNCTION get_person_id
(
p_employee_number IN VARCHAR2)
RETURN NUMBER
IS
--
--Cursor to get the person_id from employee number
--
CURSOR curs_emp_num
IS
SELECT person_id
FROM per_people_x
WHERE employee_number = p_employee_number;
-- AND ROWNUM = 1;
--
l_pers_id NUMBER;
BEGIN
OPEN curs_emp_num;
FETCH curs_emp_num INTO l_pers_id;

CLOSE curs_emp_num;
--
RETURN l_pers_id;
END;
--
FUNCTION cstm_aprvr_grp
(
p_txn_id IN NUMBER)
RETURN xxscc_sshr_aprvl_tab_type PIPELINED
IS
-- ID Flex Numbers will be Hardcoded, to identify different Requests.
g_ser_req_id NUMBER := get_id_flex_num ('XXSCC_Application_Service_Req');--
Application Service Request
g_auth_req_id NUMBER := get_id_flex_num ('XXSCC_Application_Autho_Req'); --ITD
App Authorization Request
g_oper_req_id NUMBER := get_id_flex_num ('XXSCC_Operations_Service_Req'); --ITD
Operations Service Request
g_oper_auth_id NUMBER := get_id_flex_num ('XXSCC_Oprations_Autho_Req'); --ITD
Operations AUthorization Request
g_app_chng_id NUMBER := get_id_flex_num ('XXSCC_App_change_Request'); --ITD
OApplications Change Request
g_oper_chng_id NUMBER := get_id_flex_num ('XXSCC_Oper_Change_Request'); ---ITD
Operations change Request
g_ser_requ_id NUMBER := get_id_flex_num ('XXSCC_Application_Service_Req.');--
Application Service Request.
g_over_time_id NUMBER := get_id_flex_num ('XXSCC_OVERTIME_REQUEST');
---- Overtime Request
g_mis_punch_id NUMBER := get_id_flex_num ('XXSCC_Miss_Punch_Amendment'); ----
Miss Punch Amendment Request
g_shrt_leav_id NUMBER := get_id_flex_num ('XXSCC_Late_Arrival_Short_Leave');
---- Late Arrival/Short Leave Req.
g_lieu_leav_id NUMBER := get_id_flex_num ('XXSCC_Lieu_Leave_Request'); ---- Lieu
Leave Request
g_shft_chng_id NUMBER := get_id_flex_num ('XXSCC_Shift_Change');
---- Shift Change Request
g_Shft_Sch_Chng_id NUMBER := get_id_flex_num ('XXSCC_Shift_Sc_Amendment'); ----
Shift Schedule Amendment Req
g_Manl_Pay_Corr_id NUMBER := get_id_flex_num ('XXSCC_Manual_Pay_Correction');
----Manual Pay Correction
g_Week_off_cmpnsn_id NUMBER := get_id_flex_num ('XXSCC_WEEK_OFF_COMPENSATION');
---- Week Off Compensation Request
g_Issue_Co_Bdge_id NUMBER := get_id_flex_num ('XXSCC_Issue_Company_Badeg_id');
---- Re-Issue Company Badge ID
g_Busins_card_id NUMBER := get_id_flex_num ('XXSCC_Business_Card_Req');
----Business Card Requisition
g_courier_ser_id NUMBER := get_id_flex_num ('XXSCC_Courier_Ser_Request');
-----Courier Service Request
g_Ktchn_itm_id NUMBER := get_id_flex_num ('XXSCC_Kiten_Item_Req');
----Kitchen Item Requisition
g_clning_itm_id NUMBER := get_id_flex_num ('XXSCC_Clean_Item_Requisition');
----Cleaning Item Requisition
g_mobile_repr_id NUMBER := get_id_flex_num ('XXSCC_Mobile_Phone_Repair');
---Mobile Phone Repair Request
g_mobile_req_id NUMBER := get_id_flex_num ('XXSCC_Mobile_Phone_Requisition');
----Mobile Phone Requisition
g_work_mtn_id NUMBER := get_id_flex_num ('XXSCC_Work_Maintenance_Req');
----Work Maintenance Requisition
g_forms_req_id NUMBER := get_id_flex_num ('XXSCC_Forms_Requisition');
--------Forms Requisition
g_stationery_req_id NUMBER := get_id_flex_num ('XXSCC_Stationery_Requisition');
-----Stationery Reuisition
g_fcsimile_tran_id NUMBER := get_id_flex_num ('XXSCC_FACSIMILE_TRANSMISSION');
-----Telefacsimile Transmission Req
g_veh_req_id NUMBER := get_id_flex_num ('XXSCC_Vehicle_Requisition');
-----Vehicle Requisition
g_veh_req2_id NUMBER := get_id_flex_num ('XXSCC_Vehicle_Requisition_2');
-----Vehicle Requisition
g_cnten_meal_id NUMBER := get_id_flex_num ('XXSCC_Canteen_Meal_Req_Cntrctr');
-----Canteen Meals Request
g_guest_hse_id NUMBER := get_id_flex_num ('XXSCC_GUEST_HOUSE_REQUEST');
-----Guest House Request
g_Accomodation_id NUMBER := get_id_flex_num ('XXSCC_Accomodation_Request');
---- Accomodation Request
g_tele_ser_req_id NUMBER := get_id_flex_num ('XXSCC_Telephone_Service_Req');
---- Telephone Service Request
g_tele_chng_req_id NUMBER := get_id_flex_num ('XXSCC_Telecom_Change_Request');
----Telecommunication Change Req
g_visitors_acc_id NUMBER := get_id_flex_num ('XXSCC_Visitors_Access_Form');
----Visitors Access Form

--
-- CURSORS DECLRN
-- Get Ana_Crit_ID from S.I.T Transaction
CURSOR curs_txn_det
IS
SELECT hatv.number_value
FROM hr_api_transaction_values hatv,
hr_api_transactions hat,
hr_api_transaction_steps hats
WHERE hat.transaction_id = p_txn_id
AND hatv.NAME = 'P_ANALYSIS_CRITERIA_ID'
AND hat.transaction_id = hats.transaction_id
AND hats.transaction_step_id = hatv.transaction_step_id
AND ROWNUM = 1;
-- Get SIT details of requestor
CURSOR curs_req_sit_details (cp_ana_cri_id IN NUMBER)
IS
SELECT pac.segment1,
pac.segment2,
pac.segment3,
pac.segment4,
pac.segment5,
pac.segment6,
pac.segment17,
pac.id_flex_num
FROM per_analysis_criteria pac
WHERE pac.analysis_criteria_id = cp_ana_cri_id;
-- Get Assg Details od requestor
CURSOR curs_req_assg_details (cp_pers_id IN NUMBER)
IS
SELECT paaf.organization_id,
hla.location_code,
paaf.supervisor_id,
prl.payroll_Name
FROM per_all_people_f papf,
per_all_assignments_f paaf,
hr_locations_all hla,
pay_all_payrolls_f prl
WHERE papf.person_id = cp_pers_id
AND papf.person_id = paaf.person_id
AND paaf.location_id = hla.location_id
AND paaf.payroll_id = prl.payroll_id
AND paaf.primary_flag = 'Y'
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;
-- Check Divsn / Dept
CURSOR curs_div_dep_check (cp_org_id IN NUMBER)
IS
SELECT hl.meaning
FROM hr_all_organization_units haou,
hr_lookups hl
WHERE haou.organization_id = cp_org_id
AND hl.lookup_type = 'ORG_TYPE'
AND haou.TYPE = hl.lookup_code;
-- Get lookup code/ type for Divsn / Dept
CURSOR csr_get_div_dep_type (cp_dep_mng IN VARCHAR2)
IS
SELECT lookup_code
FROM hr_lookups
WHERE lookup_type = 'ORG_TYPE'
AND meaning = cp_dep_mng;
-- Get Dept id of requestor's Head OF Divsn / Dept
CURSOR csr_get_dept_id (cp_org_id IN NUMBER, cp_org_type IN VARCHAR2)
IS
SELECT hoh.child_organization_id
FROM hrfv_organization_hierarchies hoh,
hr_all_organization_units haou
WHERE haou.TYPE = cp_org_type
AND haou.organization_id = hoh.child_organization_id
START WITH haou.organization_id = cp_org_id
CONNECT BY PRIOR hoh.parent_organization_id = hoh.child_organization_id;
--Cursor to get the department manager
CURSOR csr_dept_mgr (cp_dept_id VARCHAR2)
IS
SELECT ppf.employee_number
FROM hr_all_organization_units org,
hr_all_organization_units_tl org_tl,
hr_organization_information org_info2,
per_all_people_f ppf
WHERE org.organization_id = cp_dept_id
AND org_info2.organization_id = org.organization_id
AND org_info2.org_information_context = 'Organization Name Alias'
AND org_info2.org_information2 = TO_CHAR (ppf.person_id(+))
AND org.organization_id = org_tl.organization_id
AND org_tl.LANGUAGE = USERENV ('LANG')
AND EXISTS
(SELECT NULL
FROM hr_org_info_types_by_class oitbc,
hr_organization_information org_info
WHERE org_info.organization_id = org.organization_id
AND org_info.org_information_context = 'CLASS'
AND org_info.org_information2 = 'Y'
AND oitbc.org_classification = org_info.org_information1
AND oitbc.org_information_type = 'Organization Name Alias'
)
AND SYSDATE BETWEEN NVL (ppf.effective_start_date, SYSDATE) AND NVL
(ppf.effective_end_date, SYSDATE);
-- Get Employee Number from UDT for respective Approver
CURSOR csr_get_udt_value ( p_udt_name VARCHAR2, p_col_name VARCHAR2, p_row_name
VARCHAR2 )
IS
SELECT pucif.VALUE
FROM pay_user_tables put,
pay_user_columns puc,
pay_user_rows_f purf,
pay_user_column_instances_f pucif
WHERE put.user_table_name = p_udt_name
AND puc.user_column_name = p_col_name
AND purf.row_low_range_or_name = p_row_name
AND puc.user_table_id = put.user_table_id
AND puc.user_column_id = pucif.user_column_id
AND purf.user_row_id = pucif.user_row_id
AND TRUNC (SYSDATE) BETWEEN purf.effective_start_date AND
purf.effective_end_date
AND TRUNC (SYSDATE) BETWEEN pucif.effective_start_date AND
pucif.effective_end_date;

------
CURSOR curs_sup_id (cp_persn_id NUMBER)
IS
SELECT papf2.employee_number
FROM per_all_assignments_f paaf,
per_all_people_f papf1,
per_all_people_f papf2
WHERE papf1.person_id = cp_persn_id
AND paaf.primary_flag = 'Y'
AND papf1.person_id = paaf.person_id
AND papf2.person_id = paaf.supervisor_id
AND TRUNC (SYSDATE) BETWEEN papf1.effective_start_date AND
papf1.effective_end_date
AND TRUNC (SYSDATE) BETWEEN papf2.effective_start_date AND
papf2.effective_end_date
AND TRUNC (SYSDATE) BETWEEN paaf.effective_start_date AND
paaf.effective_end_date;
---------

l_ana_cri_id NUMBER;
l_id_flex_num NUMBER;
l_person_id NUMBER;
l_locn_code VARCHAR2 (20);
l_payroll VARCHAR2 (40);
l_org_id NUMBER;
l_org_type VARCHAR2 (40);
l_sup_id NUMBER;
l_sup_num VARCHAR2 (20);
l_supervisor_id VARCHAR2 (40);
l_emp_num VARCHAR2 (20);
l_grade VARCHAR2 (20);
l_grade_id NUMBER;
l_seg1 VARCHAR2 (5000);
l_seg2 VARCHAR2 (5000);
l_seg3 VARCHAR2 (5000);
l_seg4 VARCHAR2 (5000);
l_seg5 VARCHAR2 (5000);
l_seg6 VARCHAR2 (5000);
l_seg17 VARCHAR2 (5000);
l_dep_mng VARCHAR2 (20);
l_dept_type VARCHAR2 (40);
l_div_type VARCHAR2 (40);
l_sect_type VARCHAR2 (40);
l_dept_id NUMBER;
l_div_id NUMBER;
l_sect_id NUMBER;
l_dept_head VARCHAR2 (30);
l_div_head VARCHAR2 (30);
l_sect_head VARCHAR2 (30);
l_pp_bl VARCHAR2 (10);
l_pp_fl VARCHAR2 (10);
l_pp_cl VARCHAR2 (10);
l_pp_il_ho VARCHAR2 (10);
l_pp_il_pl VARCHAR2 (10);
l_txn_count NUMBER;
--
l_trv_spec VARCHAR2 (10);
l_hr_mgr VARCHAR2 (10);
l_tmkp_opr_ho VARCHAR2 (10);
l_tmkp_opr_pl VARCHAR2 (10);
l_gvmt_rln_spec VARCHAR2 (10);
l_ctrllr_prsnl VARCHAR2 (10);
l_pay_spec VARCHAR2 (10);
l_chf_acc VARCHAR2 (10);
l_sr_prsnl_proc VARCHAR2 (10);
l_ins_spec VARCHAR2 (10);
l_housing_ctrlr_pl VARCHAR2 (10);
l_housing_ctrlr_ho VARCHAR2 (10);
--
l_level1 VARCHAR2 (60) DEFAULT NULL;
l_level2 VARCHAR2 (60) DEFAULT NULL;
l_level3 VARCHAR2 (60) DEFAULT NULL;
l_level4 VARCHAR2 (60) DEFAULT NULL;
l_level5 VARCHAR2 (60) DEFAULT NULL;
l_level6 VARCHAR2 (60) DEFAULT NULL;
l_level17 VARCHAR2 (60) DEFAULT NULL;
v_department Varchar2(100) :='';
v_dpet_head_id number;

BEGIN
DBMS_OUTPUT.put_line ('**** APPROVERS *****');
OPEN curs_txn_det;
FETCH curs_txn_det INTO l_ana_cri_id;

CLOSE curs_txn_det;
DBMS_OUTPUT.put_line ('Ana Cri ID: ' || l_ana_cri_id);
OPEN curs_req_sit_details (l_ana_cri_id);
FETCH curs_req_sit_details INTO l_seg1, l_seg2, l_seg3,
l_seg4,l_seg5,l_seg6,l_seg17,l_id_flex_num;

CLOSE curs_req_sit_details;
DBMS_OUTPUT.put_line ('ID Flex Num: ' || l_id_flex_num);
--
BEGIN

SELECT hats.CREATOR_PERSON_ID
INTO l_person_id
FROM hr_api_transaction_steps hats
WHERE hats.transaction_id = p_txn_id;

DBMS_OUTPUT.put_line ('l_person_id: ' || l_person_id);

---- Updated on 26-Feb-2018--------------------

/* SELECT hatv.number_value
INTO l_person_id
FROM hr_api_transaction_steps hats,
hr_api_transactions hat,
hr_api_transaction_values hatv
WHERE hat.transaction_id = p_txn_id
AND hatv.NAME = 'P_PERSON_ID'
AND hat.transaction_id = hats.transaction_id
AND hats.transaction_step_id = hatv.transaction_step_id
AND ROWNUM = 1;
*/
EXCEPTION
WHEN OTHERS THEN
raise_application_error (-20007, 'Person ID not found.' || SQLERRM );
END;
--
OPEN curs_req_assg_details (l_person_id);
FETCH curs_req_assg_details INTO l_org_id, l_locn_code, l_sup_id, l_payroll;

CLOSE curs_req_assg_details;
--
DBMS_OUTPUT.put_line ('Locn: ' || l_locn_code);
DBMS_OUTPUT.put_line ('Org: ' || l_org_id);
--DBMS_OUTPUT.put_line ('Payroll: ' || l_payroll);
BEGIN
SELECT employee_number
INTO l_emp_num
FROM per_all_people_f
WHERE person_id = l_person_id
AND ROWNUM = 1
and sysdate between EFFECTIVE_START_DATE and EFFECTIVE_END_DATE;
EXCEPTION
WHEN OTHERS THEN
raise_application_error (-20007, 'Unable to fetch Employee number for
employee.' || SUBSTR (SQLERRM, 1, 240) );
END;
BEGIN
SELECT employee_number
INTO l_sup_num
FROM per_all_people_f
WHERE person_id = l_sup_id
AND TRUNC (SYSDATE) BETWEEN effective_start_date AND effective_end_date;
EXCEPTION
WHEN OTHERS THEN
raise_application_error (-20007, 'Supervisor not defined pl. contact your
manager or HR Dept.' || SUBSTR (SQLERRM, 1, 240) );
END;
BEGIN
SELECT grade_id
INTO l_grade_id
FROM per_all_assignments_f
WHERE person_id = l_person_id
AND primary_flag = 'Y'
AND TRUNC (SYSDATE) BETWEEN effective_start_date AND effective_end_date;
EXCEPTION
WHEN OTHERS THEN
raise_application_error (-20007, 'Unable to fetch Grade ID for employee.' ||
SUBSTR (SQLERRM, 1, 240) );
END;
--
BEGIN
SELECT NAME INTO l_grade FROM per_grades WHERE grade_id = l_grade_id;
EXCEPTION
WHEN OTHERS THEN
raise_application_error (-20007, 'Unable to fetch Grade for employee.' ||
SUBSTR (SQLERRM, 1, 240) );
END;
---
------
Begin
SELECT papf2.employee_number
into l_supervisor_id
FROM per_all_assignments_f paaf,
per_all_people_f papf1,
per_all_people_f papf2
WHERE papf1.person_id = l_person_id----.creator_person_id
AND paaf.primary_flag = 'Y'
AND papf1.person_id = paaf.person_id
AND papf2.person_id = paaf.supervisor_id
AND TRUNC (SYSDATE) BETWEEN papf1.effective_start_date
AND papf1.effective_end_date
AND TRUNC (SYSDATE) BETWEEN papf2.effective_start_date
AND papf2.effective_end_date
AND TRUNC (SYSDATE) BETWEEN paaf.effective_start_date
AND paaf.effective_end_date;
EXCEPTION
WHEN OTHERS THEN
raise_application_error (-20007, 'Supervisor does not exist Please contact your
manager or HR Department' || SQLERRM );
END;
------------------------
---
Begin
select ASS_ATTRIBUTE7
into v_department
from per_assignments_x a,
per_people_x b
where a.PERSON_ID=b.PERSON_ID
and a.PERSON_ID = l_person_id
and a.PRIMARY_FLAG='Y';

exception
when others then
raise_application_error (-20007, 'Unable to fetch Department Name' || SUBSTR
(SQLERRM, 1, 240) );
end;
-----

--
DBMS_OUTPUT.put_line ('Org Mng: ' || l_dep_mng);
DBMS_OUTPUT.put_line ('Org Type: ' || l_org_type);
DBMS_OUTPUT.put_line ('Seg 1: ' || l_seg1);
DBMS_OUTPUT.put_line ('Seg 2: ' || l_seg2);
DBMS_OUTPUT.put_line ('Seg 3: ' || l_seg3);
DBMS_OUTPUT.put_line ('Seg 4: ' || l_seg4);
DBMS_OUTPUT.put_line ('Seg 5: ' || l_seg5);
DBMS_OUTPUT.put_line ('Seg 6: ' || l_seg6);
DBMS_OUTPUT.put_line ('Seg 17: ' || l_seg17);
DBMS_OUTPUT.put_line ('Grade: ' || l_grade);

--
OPEN csr_get_div_dep_type (g_dept_type);
FETCH csr_get_div_dep_type INTO l_dept_type;

CLOSE csr_get_div_dep_type;
--
OPEN csr_get_div_dep_type (g_divsn_type);
FETCH csr_get_div_dep_type INTO l_div_type;

CLOSE csr_get_div_dep_type;
--
OPEN csr_get_div_dep_type (g_section_type);
FETCH csr_get_div_dep_type INTO l_sect_type;

CLOSE csr_get_div_dep_type;
-- Fetching Department / Division / Section Managers
OPEN csr_get_dept_id (l_org_id, l_dept_type);
FETCH csr_get_dept_id INTO l_dept_id;

CLOSE csr_get_dept_id;
--
OPEN csr_get_dept_id (l_org_id, l_div_type);
FETCH csr_get_dept_id INTO l_div_id;

CLOSE csr_get_dept_id;
--
OPEN csr_get_dept_id (l_org_id, l_sect_type);
FETCH csr_get_dept_id INTO l_sect_id;

CLOSE csr_get_dept_id;
--

dbms_output.PUT_LINE('l_dept_id :'||l_dept_id);
OPEN csr_dept_mgr (l_dept_id);
FETCH csr_dept_mgr INTO l_dept_head;

CLOSE csr_dept_mgr;
--
OPEN csr_dept_mgr (l_div_id);
FETCH csr_dept_mgr INTO l_div_head;

CLOSE csr_dept_mgr;
--
OPEN csr_dept_mgr (l_sect_id);
FETCH csr_dept_mgr INTO l_sect_head;

CLOSE csr_dept_mgr;
--
OPEN csr_get_udt_value (g_wf_aprvr_udt, g_udt_col_wf, g_pp_bank_loan);
FETCH csr_get_udt_value INTO l_pp_bl;

CLOSE csr_get_udt_value;
--
OPEN csr_get_udt_value (g_wf_aprvr_udt, g_udt_col_wf, g_pp_furn_loan);
FETCH csr_get_udt_value INTO l_pp_fl;

CLOSE csr_get_udt_value;
--
OPEN csr_get_udt_value (g_wf_aprvr_udt, g_udt_col_wf, g_pp_car_loan);
FETCH csr_get_udt_value INTO l_pp_cl;
CLOSE csr_get_udt_value;
OPEN csr_get_udt_value (g_wf_aprvr_udt, g_udt_col_wf, g_pp_intro_ltr_ho);
FETCH csr_get_udt_value INTO l_pp_il_ho;

CLOSE csr_get_udt_value;
--
OPEN csr_get_udt_value (g_wf_aprvr_udt, g_udt_col_wf, g_pp_intro_ltr_pl);
FETCH csr_get_udt_value INTO l_pp_il_pl;

CLOSE csr_get_udt_value;
--
--
OPEN csr_get_udt_value (g_wf_aprvr_udt, g_udt_col_wf, g_trv_spec);
FETCH csr_get_udt_value INTO l_trv_spec;

CLOSE csr_get_udt_value;
--
OPEN csr_get_udt_value (g_wf_aprvr_udt, g_udt_col_wf, g_hr_mgr);
FETCH csr_get_udt_value INTO l_hr_mgr;

CLOSE csr_get_udt_value;
--
OPEN csr_get_udt_value (g_wf_aprvr_udt, g_udt_col_wf, g_tmkp_opr_ho);
FETCH csr_get_udt_value INTO l_tmkp_opr_ho;

CLOSE csr_get_udt_value;
--
OPEN csr_get_udt_value (g_wf_aprvr_udt, g_udt_col_wf, g_tmkp_opr_pl);
FETCH csr_get_udt_value INTO l_tmkp_opr_pl;

CLOSE csr_get_udt_value;
--
OPEN csr_get_udt_value (g_wf_aprvr_udt, g_udt_col_wf, g_gvmt_rln_spec);
FETCH csr_get_udt_value INTO l_gvmt_rln_spec;

CLOSE csr_get_udt_value;
--
OPEN csr_get_udt_value (g_wf_aprvr_udt, g_udt_col_wf, g_ctrllr_prsnl);
FETCH csr_get_udt_value INTO l_ctrllr_prsnl;

CLOSE csr_get_udt_value;
--
OPEN csr_get_udt_value (g_wf_aprvr_udt, g_udt_col_wf, g_pay_spec);
FETCH csr_get_udt_value INTO l_pay_spec;

CLOSE csr_get_udt_value;
--
OPEN csr_get_udt_value (g_wf_aprvr_udt, g_udt_col_wf, g_chf_acc);
FETCH csr_get_udt_value INTO l_chf_acc;

CLOSE csr_get_udt_value;
--
OPEN csr_get_udt_value (g_wf_aprvr_udt, g_udt_col_wf, g_sr_prsnl_proc);
FETCH csr_get_udt_value INTO l_sr_prsnl_proc;

CLOSE csr_get_udt_value;
--
OPEN csr_get_udt_value (g_wf_aprvr_udt, g_udt_col_wf, g_ins_spec);
FETCH csr_get_udt_value INTO l_ins_spec;

CLOSE csr_get_udt_value;
--
OPEN csr_get_udt_value (g_wf_aprvr_udt, g_udt_col_wf, g_housing_ctrlr_ho);
FETCH csr_get_udt_value INTO l_housing_ctrlr_ho;

CLOSE csr_get_udt_value;
--
OPEN csr_get_udt_value (g_wf_aprvr_udt, g_udt_col_wf, g_housing_ctrlr_pl);
FETCH csr_get_udt_value INTO l_housing_ctrlr_pl;

CLOSE csr_get_udt_value;
--
DBMS_OUTPUT.put_line ('dept mgr: ' || l_dept_head);
--
DBMS_OUTPUT.put_line ('Begin TA');
-- Business Rules for Different S.I.T Requests are checked here.
-- **************************************

if l_dept_head is not null then


select person_id into v_dpet_head_id
from per_all_people_f
where employee_number=l_dept_head;
end if;

----.Application Service Request


IF l_id_flex_num = g_ser_req_id then

if l_person_id=v_dpet_head_id then

l_level1 := l_sup_num;
--l_level2 := l_dept_head;
l_level2 := 530032;
l_level3 := 340100;
else
IF v_department in ('02-Cement Grinding & Dispatch','02-Clinkerization','02-
Raw Meal Preparation') Then
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 530923;
l_level4 := 530032;
l_level5 := 340100;
elsif v_department in ('01-Electrical','01-Electronics','01-Mechanical','01-
Preventive Maintenance') Then
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 330832;
l_level4 := 530032;
l_level5 := 340100;

else
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 530032;
l_level4 := 340100;
END IF;
END IF;
END IF;

--- ITD Applicaiton Authorization Request


IF l_id_flex_num = g_auth_req_id then
if l_person_id=v_dpet_head_id then

l_level1 := l_sup_num;
--l_level2 := l_dept_head;
l_level2 := 530032;
l_level3 := 340100;
l_level4 := 540039;
else
IF v_department in ('02-Cement Grinding & Dispatch','02-
Clinkerization','02-Raw Meal Preparation') Then
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 530923;
l_level4 := 530032;
l_level5 := 340100;
l_level6 := 540039;
elsif v_department in ('01-Electrical','01-Electronics','01-Mechanical','01-
Preventive Maintenance') Then
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 330832;
l_level4 := 530032;
l_level5 := 340100;
l_level6 := 540039;

else
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 530032;
l_level4 := 340100;
l_level5 := 540039;
END IF;
END IF;

end if;

----ITD Operation Authorization Request

if l_person_id=v_dpet_head_id then

l_level1 := l_sup_num;
--l_level2 := l_dept_head;
l_level2 := 530032;
l_level3 := 340100;
else
IF l_id_flex_num = g_oper_auth_id then
IF v_department in ('02-Cement Grinding & Dispatch','02-Clinkerization','02-
Raw Meal Preparation') Then
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 530923;
l_level4 := 530032;
l_level5 := 340100;
elsif v_department in ('01-Electrical','01-Electronics','01-Mechanical','01-
Preventive Maintenance') Then
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 330832;
l_level4 := 530032;
l_level5 := 340100;

else
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 530032;
l_level4 := 340100;
END IF;
END IF;
END IF;

/*--- IF l_seg5 IN ('2-Internet Access Group B','3-Internet Access Group C','4-


Internet Access Group D','5-Internet Access Group E') then
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 540123;
l_level4 := 340100;
END IF;*/

---ITD Operation Service Request


IF l_id_flex_num = g_oper_req_id then
if l_person_id=v_dpet_head_id then

l_level1 := l_sup_num;
--l_level2 := l_dept_head;
l_level2 := 530032;
l_level3 := 340100;

else
IF v_department in ('02-Cement Grinding & Dispatch','02-Clinkerization','02-
Raw Meal Preparation') Then
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 530923;
l_level4 := 530032;
l_level5 := 340100;
elsif v_department in ('01-Electrical','01-Electronics','01-Mechanical','01-
Preventive Maintenance') Then
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 330832;
l_level4 := 530032;
l_level5 := 340100;

else
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 530032;
l_level4 := 340100;
END IF;
END IF;

END IF;
---ITD Application Change Request
IF l_id_flex_num = g_app_chng_id then
if l_person_id=v_dpet_head_id then
l_level1 := l_sup_num;
--l_level2 := l_dept_head;
l_level3 := 530032;
l_level4 := 340100;
else
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 530032;
l_level4 := 340100;

END IF;
END IF;

---ITD Operations Change Request


IF l_id_flex_num = g_oper_chng_id then
if l_person_id=v_dpet_head_id then
l_level1 := l_sup_num;
-- l_level2 := l_dept_head;
l_level3 := 540123;
l_level4 := 340100;
ELSE
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 540123;
l_level4 := 340100;

END IF;
END IF;
------
----Telecommunication Change Req

IF l_id_flex_num = g_tele_chng_req_id then


if l_person_id=v_dpet_head_id then
l_level1 := l_sup_num;
--l_level2 := l_dept_head;
l_level3 := 540123;
l_level4 := 340100;
ELSE
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 540123;
l_level4 := 340100;

END IF;
END IF;

----Visitors_Access_From

IF l_id_flex_num = g_visitors_acc_id THEN


IF l_seg6 IN ('Process Area') THEN

IF l_seg2 IN ('49-Plant Maintenance') THEN


l_level1 := l_dept_head;
l_level2 := 330819;
l_level3 := 540015;
l_level4 := 200022;
l_level5 := 200023;
ELSIF l_seg2 IN ('20-Machanical','21-Electrical','22-Electronics','19-
Preventive Maintenance') THEN
l_level1 := l_dept_head;
l_level2 := 330832;
l_level3 := 330819;
l_level4 := 540015;
l_level5 := 200022;
l_level6 := 200023;
ELSE
l_level1 := l_dept_head;
l_level2 := 540015;
l_level3 := 200022;
l_level4 := 200023;

END IF;

-- ELSIF l_seg6 IN ('Process Area') THEN


--
-- l_level1 := l_dept_head;
-- --- l_level2 := 330819;
-- l_level3 := 540015;
-- l_level4 := 200022;
-- l_level5 := 200023;
ELSE

l_level1 := l_dept_head;
l_level2 := 200022;
l_level3 := 200023;
END IF;
END IF;
-- END IF;

-- END IF;

----TK Approved Overtime


IF l_id_flex_num = g_over_time_id THEN
IF l_locn_code IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN

IF ((trunc(sysdate)-trunc(fnd_date.CANONICAL_TO_DATE(l_seg4))) >= 30) then


--(trunc(sysdate)-trunc(fnd_date.CANONICAL_TO_DATE(l_seg4))) >= 30) then

if v_department in ('05-Human Resources','05-Material Supply','05-Relations


& Support Svs','05-Finance','05-Information Technology','05-Sales') then
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 104356;
l_level4 := 104282;
elsif v_department in ('01-Electrical','01-Electronics','01-
Mechanical','01-Preventive Maintenance') Then
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 330832;
l_level4 := 330819;
l_level5 := 104356;
elsif v_department in ('02-Cement Grinding & Dispatch','02-
Clinkerization','02-Raw Meal Preparation') Then
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 530923;
l_level4 := 330819;
l_level5 := 104356;
else
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 330819;
l_level4 := 104356;
End if;
else
if v_department in ('05-Human Resources','05-Material Supply','05-Relations
& Support Svs','05-Finance','05-Information Technology','05-Sales') then
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 104356;
l_level4 := 104282;
elsif v_department in ('01-Electrical','01-Electronics','01-
Mechanical','01-Preventive Maintenance') Then
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 330832;
l_level4 := 330819;
elsif v_department in ('02-Cement Grinding & Dispatch','02-
Clinkerization','02-Raw Meal Preparation') Then
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 530923;
l_level4 := 330819;
else
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 330819;
End if;
end if;
ELSIF l_locn_code NOT IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN
IF ((trunc(sysdate)-trunc(fnd_date.CANONICAL_TO_DATE(l_seg4))) >= 30 or
(trunc(sysdate)-trunc(fnd_date.CANONICAL_TO_DATE(l_seg4))) >= 30) then
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 104356;
l_level4 := 104282;

else
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 104356;
l_level4 := 104282;
end if;

END IF;
END IF;

------
--- TK Mis Punch Form
IF l_id_flex_num = g_mis_punch_id THEN
if l_person_id=v_dpet_head_id then
l_level1 := l_sup_num;
--l_level2 := l_dept_head;
ELSIF ((trunc(sysdate)-trunc(fnd_date.CANONICAL_TO_DATE(l_seg5))) >= 30) /*or
*/ then
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 104356;

ELSE

IF ((trunc(sysdate)-trunc(fnd_date.CANONICAL_TO_DATE(l_seg5))) <= 30) Then

l_level1 := l_sup_num;
l_level2 := l_dept_head;

ELSE
l_level1 := l_sup_num;
l_level2 := l_dept_head;
END IF;
END IF;
END IF;
--end if
----
---TK Late or Short Leave Request Late Arrival
IF l_id_flex_num = g_shrt_leav_id THEN
IF l_locn_code IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN

IF l_seg4 IN ('Short Leave') then

--l_level1 := l_sup_num;
l_level2 := 200022;
l_level3 := 200023;

else
l_level1 := l_sup_num;
l_level2 := l_dept_head;
--- l_level3 := 104356;

END IF;

ELSIF l_locn_code Not IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) then

IF l_seg4 IN ('Short Leave') then

l_level1 := l_sup_num;
--l_level2 := 200022;
--l_level3 := 200023;

else
l_level1 := l_sup_num;
l_level2 := l_dept_head;
--l_level3 := 104356;

END IF;
END IF;
END IF;
-- END IF;

------
---TK Lieu Leave Request
IF l_id_flex_num = g_lieu_leav_id THEN
IF ((trunc(sysdate)-trunc(fnd_date.CANONICAL_TO_DATE(l_seg4))) >= 30)
then
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 104356;

ELSE

IF ((trunc(sysdate)-trunc(fnd_date.CANONICAL_TO_DATE(l_seg4))) <= 30) Then

l_level1 := l_sup_num;
l_level2 := l_dept_head;
end if;
End if;

END IF;
----
---TK Shift Change Request
IF l_id_flex_num = g_shft_chng_id THEN

IF ((trunc(sysdate)-trunc(fnd_date.CANONICAL_TO_DATE(l_seg5))) >= 30) then

l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 104356;

ELSE

IF ((trunc(sysdate)-trunc(fnd_date.CANONICAL_TO_DATE(l_seg5))) <= 30) Then

l_level1 := l_sup_num;
l_level2 := l_dept_head;
end if;

END IF;
END IF;
------
--- TK Shift Schedule Amendment Request
IF l_id_flex_num = g_Shft_Sch_Chng_id THEN

IF ((trunc(sysdate)-trunc(fnd_date.CANONICAL_TO_DATE(l_seg6))) >= 30) /*or


*/ then
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 104356;

ELSE

IF ((trunc(sysdate)-trunc(fnd_date.CANONICAL_TO_DATE(l_seg6))) <= 30) Then

l_level1 := l_sup_num;
l_level2 := l_dept_head;
END IF;

END IF;
END IF;
----
----TK Manual Pay Correction Form
IF l_id_flex_num = g_Manl_Pay_Corr_id then
l_level1 := 104356;
l_level2 := 104387;
l_level3 := 104282;
l_level4 := 330868;

END IF;
------
--- TK Week Off Compensation Request
IF l_id_flex_num = g_Week_off_cmpnsn_id THEN

IF ((trunc(sysdate)-trunc(fnd_date.CANONICAL_TO_DATE(l_seg4))) >= 30) then

l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 104356;

ELSE
IF ((trunc(sysdate)-trunc(fnd_date.CANONICAL_TO_DATE(l_seg4))) <= 30) then

l_level1 := l_sup_num;
l_level2 := l_dept_head;

END IF;
END IF;

END IF;
-----
--- TK Issue Company Badge ID
IF l_id_flex_num = g_Issue_Co_Bdge_id THEN
IF l_seg17 IN ('Yes') then
l_level1 := 104387;
l_level2 := 104282;
l_level3 := 330833;
l_level4 := 330868;
ELSE

l_level1 := 104356;

END IF;
END IF;
---END IF;
--
------Business Card Requisition
IF l_id_flex_num = g_Busins_card_id THEN
IF l_locn_code IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN

l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 330819;
l_level4 := 104524;
l_level5 := 651320;
l_level6 := 104282;
ELSE

IF l_locn_code NOT IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN

l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 530754;
l_level4 := 104137;
l_level5 := 104282;

END IF;
END IF;
END IF;
----
----Courier Service Request

IF l_id_flex_num = g_courier_ser_id THEN

IF l_seg2 IN ('Private') THEN

l_level1 := 651377;

ELSE

IF l_seg2 NOT IN ('Private') THEN

l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 651377;
l_level4 := 104137;
l_level5 := 104282;
END IF;
END IF;
END IF;
---------Kitchen Item Requisition

IF l_id_flex_num = g_Ktchn_itm_id THEN


IF l_locn_code IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN

l_level1 := l_sup_num;
-- l_level2 := l_dept_head;
l_level3 := 104330;
l_level4 := 104524;
l_level5 := 651320;

ELSE

IF l_locn_code NOT IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN

l_level1 := 530754;
l_level2 := 104137;

END IF;
END IF;
END IF;
----
------Cleaning Item Requisition
IF l_id_flex_num = g_clning_itm_id THEN
IF l_locn_code IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN
l_level1 := l_sup_num;
-- l_level2 := l_dept_head;
l_level3 := 104330;
l_level4 := 104524;
l_level5 := 651320;

ELSE
IF l_locn_code NOT IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN

l_level1 := 530754;
l_level2 := 104137;
END IF;
END IF;
END IF;

----

-----Mobile Service Request Or Mobile Phone Repair Request


IF l_id_flex_num = g_mobile_repr_id THEN
if l_person_id=v_dpet_head_id then
l_level1 := l_sup_num;
-- l_level2 := l_dept_head;
l_level3 := 740073;
l_level4 := 540123;
l_level5 := 340100;

ELSE
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 740073;
l_level4 := 540123;
l_level5 := 340100;
END IF;

END IF;

-----Mobile Phone Requisition

IF l_id_flex_num = g_mobile_req_id THEN

if l_person_id=v_dpet_head_id then
l_level1 := l_sup_num;
-- l_level2 := l_dept_head;
l_level3 := 740073;
l_level4 := 540123;
l_level5 := 340100;

ELSE
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 740073;
l_level4 := 540123;
l_level5 := 340100;
end if;
END IF;
-----Work Maintenance Requisition
IF l_id_flex_num = g_work_mtn_id THEN
IF l_locn_code IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN

l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 651320;

ELSE

IF l_locn_code NOT IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN


l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 530895;
l_level4 := 104137;
--l_level5 := 104282;

END IF;
END IF;
END IF;
---- Forms Requisition
IF l_id_flex_num = g_forms_req_id THEN

IF l_locn_code IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN


l_level1 := l_sup_num;
--- l_level2 := l_dept_head;
l_level3 := 104330;
l_level4 := 104524;
l_level5 := 651320;

ELSE

IF l_locn_code NOT IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN


l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 530754;
l_level4 := 104137;
--l_level5 := 104282;

END IF;
END IF;
END IF;

---------------------- Stationery Requisition


IF l_id_flex_num = g_stationery_req_id THEN
IF l_locn_code IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 104524;
l_level4 := 104330;
l_level5 := 651320;

ELSE
IF l_locn_code NOT IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 530754;
l_level4 := 104137;

END IF;
END IF;
END IF;
------------------- Facsimile Request
IF l_id_flex_num = g_fcsimile_tran_id THEN

IF

l_seg4 IN ('Personal Account') then

l_level4 := 651377;

ELSE

IF

l_seg4 NOT IN ('Personal Account') then

l_level1 := l_sup_num;
l_level1 := l_dept_head;
l_level2 := 651377;
l_level3 := 104137;
l_level4 := 104282;

END IF;
END IF;
END IF;

---------------------- Vehicle Requisition


IF l_id_flex_num = g_veh_req_id THEN

IF l_locn_code IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN


l_level1 := l_sup_num;
--- l_level2 := l_dept_head;
l_level2 := 200024;
l_level3 := 103977;
l_level4 := 651320;
l_level5 := 200022;

ELSE
IF l_locn_code NOT IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 740212;
l_level4 := 104137;
--l_level5 := 104282;

END IF;
END IF;
END IF;

---------------------- Vehicle Requisition2


IF l_id_flex_num = g_veh_req2_id THEN

IF l_locn_code IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN


---l_level1 := l_sup_num;
l_level1 := 200024;
l_level2 :=200021;

ELSE
IF l_locn_code NOT IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 740212;
l_level4 := 104137;
-- l_level5 := 104282;

END IF;
END IF;
END IF;
----
-------Canteen Meals Request
IF l_id_flex_num = g_cnten_meal_id THEN
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 651320;
l_level4 := 651291;

END IF;
---
-------Guest House Request
IF l_id_flex_num = g_guest_hse_id THEN

l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 103675;
l_level4 := 651291;
l_level5 := 651320;
l_level6 := 104282;
END IF;
------

-------Accomodation Request
IF l_id_flex_num = g_Accomodation_id THEN

l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 330819;
l_level4 := 200025;
l_level5 := 651320;
l_level6 := 104282;

END IF;
---
-------Telephone Service Request

IF l_id_flex_num = g_tele_ser_req_id THEN


if l_person_id=v_dpet_head_id then
l_level1 := l_sup_num;
-- l_level2 := l_dept_head;
l_level3 := 740073;
l_level4 := 540123;
l_level5 := 340100;
ELSE
l_level1 := l_sup_num;
l_level2 := l_dept_head;
l_level3 := 740073;
l_level4 := 540123;
l_level5 := 340100;
END IF;
END IF;

---
-- ****************************************
DBMS_OUTPUT.put_line ('Sup: ' || l_sup_num);
DBMS_OUTPUT.put_line ('HOD: ' || l_dept_head);
l_level1 := NVL (l_level1, g_dummy_value);
l_level2 := NVL (l_level2, g_dummy_value);
l_level3 := NVL (l_level3, g_dummy_value);
l_level4 := NVL (l_level4, g_dummy_value);
l_level5 := NVL (l_level5, g_dummy_value);
l_level6 := NVL (l_level6, g_dummy_value);
DBMS_OUTPUT.put_line ('Level1: ' || l_level1);
DBMS_OUTPUT.put_line ('Level2: ' || l_level2);
DBMS_OUTPUT.put_line ('Level3: ' || l_level3);
DBMS_OUTPUT.put_line ('Level4: ' || l_level4);
DBMS_OUTPUT.put_line ('Level5: ' || l_level5);
DBMS_OUTPUT.put_line ('Level6: ' || l_level6);
-- ****************************************

DBMS_OUTPUT.put_line ('l_level1 ' || l_level1);


DBMS_OUTPUT.put_line ('g_dummy_value ' || g_dummy_value);
DBMS_OUTPUT.put_line ('l_emp_num ' || l_emp_num );

IF (l_level1 <> g_dummy_value) --AND (l_emp_num NOT IN (l_level1)))


THEN
DBMS_OUTPUT.put_line ('Level1.1: ' || l_level1);
PIPE ROW ('person_id:' || get_person_id (l_level1));
END IF;

--
IF /* Remove start ( */(l_level2 <> g_dummy_value) --AND (l_emp_num NOT IN
(l_level2))) 17-Sep-18
THEN
DBMS_OUTPUT.put_line ('Level2.2: ' || l_level2);
PIPE ROW ('person_id:' || get_person_id (l_level2));
END IF;

--
IF (l_level3 <> g_dummy_value) --AND (l_emp_num NOT IN (l_level3)))
THEN
DBMS_OUTPUT.put_line ('Level3.3: ' || l_level3);
PIPE ROW ('person_id:' || get_person_id (l_level3));
END IF;

--
IF (l_level4 <> g_dummy_value) --AND (l_emp_num NOT IN (l_level4)))
THEN
DBMS_OUTPUT.put_line ('Level4.4: ' || l_level4);
PIPE ROW ('person_id:' || get_person_id (l_level4));
END IF;

--
IF (l_level5 <> g_dummy_value) --AND (l_emp_num NOT IN (l_level5)))
THEN
DBMS_OUTPUT.put_line ('Level5.5: ' || l_level5);
PIPE ROW ('person_id:' || get_person_id (l_level5));
END IF;
--
IF (l_level6 <> g_dummy_value) --AND (l_emp_num NOT IN (l_level6)))
THEN
DBMS_OUTPUT.put_line ('Level6.6: ' || l_level6);
PIPE ROW ('person_id:' || get_person_id (l_level6));
END IF;
--

RETURN;
EXCEPTION
WHEN OTHERS THEN
raise_application_error (-20006, 'ERROR 1: Some Critical Error Occured, Contact
System Administrator.' || SUBSTR (SQLERRM, 1, 2000) );
DBMS_OUTPUT.put_line ('Error1: ' || SQLERRM);
END cstm_aprvr_grp;
--
FUNCTION cstm_fyi_grp_1
(
p_txn_id IN NUMBER)
RETURN xxscc_sshr_aprvl_tab_type PIPELINED
IS
-- ID Flex Numbers will be Hardcoded, to identify different Requests.
g_ser_req_id NUMBER := get_id_flex_num ('XXSCC_Application_Service_Req');--
Application Service Request
g_auth_req_id NUMBER := get_id_flex_num ('XXSCC_Application_Autho_Req'); --ITD
App Authorization Request
g_oper_req_id NUMBER := get_id_flex_num ('XXSCC_Operations_Service_Req');
--ITD Operations Service Request
g_oper_auth_id NUMBER := get_id_flex_num ('XXSCC_Oprations_Autho_Req'); --ITD
Operations AUthorization Request
g_ser_requ_id NUMBER := get_id_flex_num ('XXSCC_Application_Service_Req.');--
Application Service Request.
g_over_time_id NUMBER := get_id_flex_num ('XXSCC_OVERTIME_REQUEST');
----Overtime Amendment Form
g_mis_punch_id NUMBER := get_id_flex_num ('XXSCC_Miss_Punch_Amendment');
----Miss Punch Amendment Form
g_shrt_leav_id NUMBER := get_id_flex_num ('XXSCC_Late_Arrival_Short_Leave' );
----Late OR Short Leave Form
g_lieu_leav_id NUMBER := get_id_flex_num ('XXSCC_Lieu_Leave_Request');
----Lieu Leave Amendment Form
g_shft_chng_id NUMBER := get_id_flex_num ('XXSCC_Shift_Change');
----Shift Change
g_Shft_Sch_Chng_id NUMBER := get_id_flex_num ('XXSCC_Shift_Sc_Amendment');
----Shift Schedule Amendment
g_Manl_Pay_Corr_id NUMBER := get_id_flex_num ('XXSCC_Manual_Pay_Correction');
----Manual Pay Correction
g_Week_off_cmpnsn_id NUMBER := get_id_flex_num ('XXSCC_WEEK_OFF_COMPENSATION');
----Week Off Compensation Request
g_Issue_Co_Bdge_id NUMBER := get_id_flex_num ('XXSCC_Issue_Company_Badeg_id');
----Issue Company Badge ID
g_Busins_card_id NUMBER := get_id_flex_num ('XXSCC_Business_Card_Req');
----Business Card Requisition
g_Ktchn_itm_id NUMBER := get_id_flex_num ('XXSCC_Kiten_Item_Req');
----Kitchen Item Requisition
g_clning_itm_id NUMBER := get_id_flex_num ('XXSCC_Clean_Item_Requisition');
----Cleaning Item Requisition
g_mobile_repr_id NUMBER := get_id_flex_num ('XXSCC_Mobile_Phone_Repair');
---Mobile Phone Repair Request
g_mobile_req_id NUMBER := get_id_flex_num ('XXSCC_Mobile_Phone_Requisition');
----Mobile Phone Requisition
g_courier_ser_id NUMBER := get_id_flex_num ('XXSCC_Courier_Ser_Request');
-----Courier Service Request
g_work_mtn_id NUMBER := get_id_flex_num ('XXSCC_Work_Maintenance_Req');
----Work Maintenance Requisition
g_forms_req_id NUMBER := get_id_flex_num ('XXSCC_Forms_Requisition');
--------Forms Requisition
g_stationery_req_id NUMBER := get_id_flex_num ('XXSCC_Stationery_Requisition');
-----Stationery Reuisition
g_fcsimile_tran_id NUMBER := get_id_flex_num ('XXSCC_FACSIMILE_TRANSMISSION');
-----Telefacsimile Transmission Req
g_veh_req_id NUMBER := get_id_flex_num ('XXSCC_Vehicle_Requisition');
-----Vehicle Requisition
g_veh_req2_id NUMBER := get_id_flex_num ('XXSCC_Vehicle_Requisition_2');
-----Vehicle Requisition
g_cnten_meal_id NUMBER := get_id_flex_num ('XXSCC_Canteen_Meal_Req_Cntrctr');
-----Canteen Meals Request
g_guest_hse_id NUMBER := get_id_flex_num ('XXSCC_GUEST_HOUSE_REQUEST');
-----Guest House Request
g_Accomodation_id NUMBER := get_id_flex_num ('XXSCC_Accomodation_Request');
---- Accomodation Request
g_tele_ser_req_id NUMBER := get_id_flex_num ('XXSCC_Telephone_Service_Req');
---- Telephone Service Request
g_tele_chng_req_id NUMBER := get_id_flex_num ('XXSCC_Telecom_Change_Request');
----Telecommunication Change Req
g_visitors_acc_id NUMBER := get_id_flex_num ('XXSCC_Visitors_Access_Form');
----Visitors Access Form
------
-- CURSORS DECLRN
-- Get Ana_Crit_ID from S.I.T Transaction
-- dbms_output.put_line('Cursor Declrn');
CURSOR curs_txn_det
IS
SELECT hatv.number_value
FROM hr_api_transaction_values hatv,
hr_api_transactions hat,
hr_api_transaction_steps hats
WHERE hat.transaction_id = p_txn_id
AND hatv.NAME = 'P_ANALYSIS_CRITERIA_ID'
AND hat.transaction_id = hats.transaction_id
AND hats.transaction_step_id = hatv.transaction_step_id
AND ROWNUM = 1;
-- Get SIT details of requestor
CURSOR curs_req_sit_details (cp_ana_cri_id IN NUMBER)
IS
SELECT pac.segment1,
pac.segment2,
pac.segment3,
pac.segment4,
pac.id_flex_num
FROM per_analysis_criteria pac
--per_person_analyses ppa
WHERE pac.analysis_criteria_id = cp_ana_cri_id;
-- Get Assg Details od requestor
CURSOR curs_req_assg_details (cp_pers_id IN NUMBER)
IS
SELECT paaf.organization_id,
hla.location_code
FROM per_all_people_f papf,
per_all_assignments_f paaf,
hr_locations_all hla
WHERE papf.person_id = cp_pers_id
AND papf.person_id = paaf.person_id
AND paaf.location_id = hla.location_id
AND paaf.primary_flag = 'Y'
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;
-- Get Employee Number from UDT for respective Approver
CURSOR csr_get_udt_value ( p_udt_name VARCHAR2, p_col_name VARCHAR2, p_row_name
VARCHAR2 )
IS
SELECT pucif.VALUE
FROM pay_user_tables put,
pay_user_columns puc,
pay_user_rows_f purf,
pay_user_column_instances_f pucif
WHERE put.user_table_name = p_udt_name
AND puc.user_column_name = p_col_name
AND purf.row_low_range_or_name = p_row_name
AND puc.user_table_id = put.user_table_id
AND puc.user_column_id = pucif.user_column_id
AND purf.user_row_id = pucif.user_row_id
AND TRUNC (SYSDATE) BETWEEN purf.effective_start_date AND
purf.effective_end_date
AND TRUNC (SYSDATE) BETWEEN pucif.effective_start_date AND
pucif.effective_end_date;

CURSOR csr_dept_mgr (cp_dept_id VARCHAR2)


IS
SELECT ppf.employee_number
FROM hr_all_organization_units org,
hr_all_organization_units_tl org_tl,
hr_organization_information org_info2,
per_all_people_f ppf
WHERE org.organization_id = cp_dept_id
AND org_info2.organization_id = org.organization_id
AND org_info2.org_information_context = 'Organization Name Alias'
AND org_info2.org_information2 = TO_CHAR (ppf.person_id(+))
AND org.organization_id = org_tl.organization_id
AND org_tl.LANGUAGE = USERENV ('LANG')
AND EXISTS
(SELECT NULL
FROM hr_org_info_types_by_class oitbc,
hr_organization_information org_info
WHERE org_info.organization_id = org.organization_id
AND org_info.org_information_context = 'CLASS'
AND org_info.org_information2 = 'Y'
AND oitbc.org_classification = org_info.org_information1
AND oitbc.org_information_type = 'Organization Name Alias'
)
AND SYSDATE BETWEEN NVL (ppf.effective_start_date, SYSDATE) AND NVL
(ppf.effective_end_date, SYSDATE);

CURSOR csr_get_div_dep_type (cp_dep_mng IN VARCHAR2)


IS
SELECT lookup_code
FROM hr_lookups
WHERE lookup_type = 'ORG_TYPE'
AND meaning = cp_dep_mng;

CURSOR csr_get_dept_id (cp_org_id IN NUMBER, cp_org_type IN VARCHAR2)


IS
SELECT hoh.child_organization_id
FROM hrfv_organization_hierarchies hoh,
hr_all_organization_units haou
WHERE haou.TYPE = cp_org_type
AND haou.organization_id = hoh.child_organization_id
START WITH haou.organization_id = cp_org_id
CONNECT BY PRIOR hoh.parent_organization_id = hoh.child_organization_id;

CURSOR curs_div_dep_check (cp_org_id IN NUMBER)


IS
SELECT hl.meaning
FROM hr_all_organization_units haou,
hr_lookups hl
WHERE haou.organization_id = cp_org_id
AND hl.lookup_type = 'ORG_TYPE'
AND haou.TYPE = hl.lookup_code;

l_ana_cri_id NUMBER;
l_id_flex_num NUMBER;
l_person_id NUMBER;
l_locn_code VARCHAR2 (20);
l_org_id NUMBER;
l_org_type VARCHAR2 (40);
l_seg1 VARCHAR2 (5000);
l_seg2 VARCHAR2 (5000);
l_seg3 VARCHAR2 (5000);
l_seg4 VARCHAR2 (5000);
l_dep_mng VARCHAR2 (20);
l_sup_id NUMBER;
l_sup_num VARCHAR2 (20);
l_supervisor_id VARCHAR2 (40);
l_grade VARCHAR2 (20);
l_grade_id NUMBER;
l_emp_num VARCHAR2 (20);
l_dept_id NUMBER;
l_dept_head VARCHAR2 (20);
l_txn_count NUMBER;
--
l_trv_spec VARCHAR2 (10);
l_hr_mgr VARCHAR2 (10);
l_gvmt_rln_spec VARCHAR2 (10);
l_ctrllr_prsnl VARCHAR2 (10);
l_pay_spec VARCHAR2 (10);
l_chf_acc VARCHAR2 (10);
l_sr_prsnl_proc VARCHAR2 (10);
l_ins_spec VARCHAR2 (10);
l_housing_ctrlr_pl VARCHAR2 (10);
l_housing_ctrlr_ho VARCHAR2 (10);
l_tmkp_opr_ho VARCHAR2 (10);
l_tmkp_opr_pl VARCHAR2 (10);
l_dept_type varchar2(50);
l_div_type VARCHAR2 (40);
l_div_head varchar2(50);
l_div_id number;
l_sect_id number;
l_sect_head varchar2(200);
l_sect_type varchar2(200);
v_department Varchar2(100) :='';
--
l_level1 VARCHAR2 (60) DEFAULT NULL;
l_level2 VARCHAR2 (60) DEFAULT NULL;
l_level3 VARCHAR2 (60) DEFAULT NULL;
l_level4 VARCHAR2 (60) DEFAULT NULL;
l_level5 VARCHAR2 (60) DEFAULT NULL;
--dbms_output.put_line('Cursors opened');
BEGIN
DBMS_OUTPUT.put_line ('**** FYI *****');
OPEN curs_txn_det;
FETCH curs_txn_det INTO l_ana_cri_id;

CLOSE curs_txn_det;
OPEN curs_req_sit_details (l_ana_cri_id);
FETCH curs_req_sit_details INTO l_seg1, l_seg2, l_seg3, l_seg4,l_id_flex_num;

CLOSE curs_req_sit_details;
--
BEGIN
SELECT hatv.number_value
INTO l_person_id
FROM hr_api_transaction_steps hats,
hr_api_transactions hat,
hr_api_transaction_values hatv
WHERE hat.transaction_id = p_txn_id
AND hatv.NAME = 'P_PERSON_ID'
AND hat.transaction_id = hats.transaction_id
AND hats.transaction_step_id = hatv.transaction_step_id
AND ROWNUM = 1;
EXCEPTION
WHEN OTHERS THEN
raise_application_error (-20007, 'Person ID not found.' || SQLERRM );
END;
--
DBMS_OUTPUT.put_line ('Person ID: ' || l_person_id);
OPEN curs_req_assg_details (l_person_id);
FETCH curs_req_assg_details INTO l_org_id, l_locn_code;

CLOSE curs_req_assg_details;
--
BEGIN
SELECT employee_number
INTO l_emp_num
FROM per_all_people_f
WHERE person_id = l_person_id
AND ROWNUM = 1;
END;
--
/*BEGIN
SELECT employee_number
INTO l_sup_num
FROM per_all_people_f
WHERE person_id = l_sup_id
AND TRUNC (SYSDATE) BETWEEN effective_start_date AND effective_end_date;
EXCEPTION
WHEN OTHERS THEN
raise_application_error (-20007, 'Supervisor not defined pl. contact your
manager or HR Dept.' || SUBSTR (SQLERRM, 1, 240) );
END;*/
--
BEGIN
SELECT grade_id
INTO l_grade_id
FROM per_all_assignments_f
WHERE person_id = l_person_id
AND primary_flag = 'Y'
AND TRUNC (SYSDATE) BETWEEN effective_start_date AND effective_end_date;
EXCEPTION
WHEN OTHERS THEN
raise_application_error (-20007, 'Unable to fetch Grade ID for employee.' ||
SUBSTR (SQLERRM, 1, 240) );
END;
--
BEGIN
SELECT NAME INTO l_grade FROM per_grades WHERE grade_id = l_grade_id;
EXCEPTION
WHEN OTHERS THEN
raise_application_error (-20007, 'Unable to fetch Grade for employee.' ||
SUBSTR (SQLERRM, 1, 240) );
END;
---
Begin
select ASS_ATTRIBUTE7
into v_department
from per_assignments_x a,
per_people_x b
where a.PERSON_ID=b.PERSON_ID
and a.PERSON_ID = l_person_id
and a.PRIMARY_FLAG='Y';

exception
when others then
raise_application_error (-20007, 'Unable to fetch Department Name' || SUBSTR
(SQLERRM, 1, 240) );
end;
----
DBMS_OUTPUT.put_line ('Employee Number: ' || l_emp_num);
DBMS_OUTPUT.put_line ('Entering UDT');
-- Getting Approver ID's
OPEN csr_get_udt_value (g_wf_aprvr_udt, g_udt_col_wf, g_trv_spec);
FETCH csr_get_udt_value INTO l_trv_spec;

CLOSE csr_get_udt_value;
--
OPEN csr_get_udt_value (g_wf_aprvr_udt, g_udt_col_wf, g_hr_mgr);
FETCH csr_get_udt_value INTO l_hr_mgr;

CLOSE csr_get_udt_value;
--
OPEN csr_get_udt_value (g_wf_aprvr_udt, g_udt_col_wf, g_tmkp_opr_ho);
FETCH csr_get_udt_value INTO l_tmkp_opr_ho;

CLOSE csr_get_udt_value;
--
OPEN csr_get_udt_value (g_wf_aprvr_udt, g_udt_col_wf, g_tmkp_opr_pl);
FETCH csr_get_udt_value INTO l_tmkp_opr_pl;

CLOSE csr_get_udt_value;
--
OPEN csr_get_udt_value (g_wf_aprvr_udt, g_udt_col_wf, g_gvmt_rln_spec);
FETCH csr_get_udt_value INTO l_gvmt_rln_spec;

CLOSE csr_get_udt_value;
DBMS_OUTPUT.put_line ('Govt Relns' || l_gvmt_rln_spec);
--
OPEN csr_get_udt_value (g_wf_aprvr_udt, g_udt_col_wf, g_pay_spec);
FETCH csr_get_udt_value INTO l_pay_spec;

CLOSE csr_get_udt_value;
--
OPEN csr_get_udt_value (g_wf_aprvr_udt, g_udt_col_wf, g_chf_acc);
FETCH csr_get_udt_value INTO l_chf_acc;

CLOSE csr_get_udt_value;
--
OPEN csr_get_udt_value (g_wf_aprvr_udt, g_udt_col_wf, g_sr_prsnl_proc);
FETCH csr_get_udt_value INTO l_sr_prsnl_proc;

CLOSE csr_get_udt_value;
--
OPEN csr_get_udt_value (g_wf_aprvr_udt, g_udt_col_wf, g_ins_spec);
FETCH csr_get_udt_value INTO l_ins_spec;

CLOSE csr_get_udt_value;
--
OPEN csr_get_udt_value (g_wf_aprvr_udt, g_udt_col_wf, g_housing_ctrlr_ho);
FETCH csr_get_udt_value INTO l_housing_ctrlr_ho;

CLOSE csr_get_udt_value;
--
OPEN csr_get_udt_value (g_wf_aprvr_udt, g_udt_col_wf, g_housing_ctrlr_pl);
FETCH csr_get_udt_value INTO l_housing_ctrlr_pl;

CLOSE csr_get_udt_value;
------
--------------DEPARTMENT
OPEN csr_get_div_dep_type (g_dept_type);
FETCH csr_get_div_dep_type INTO l_dept_type;
CLOSE csr_get_div_dep_type;
OPEN csr_get_div_dep_type (g_divsn_type);
FETCH csr_get_div_dep_type INTO l_div_type;
CLOSE csr_get_div_dep_type;

OPEN csr_get_div_dep_type (g_section_type);


FETCH csr_get_div_dep_type INTO l_sect_type;

CLOSE csr_get_div_dep_type;
-- Fetching Department / Division / Section Managers
OPEN csr_get_dept_id (l_org_id, l_dept_type);
FETCH csr_get_dept_id INTO l_dept_id;

CLOSE csr_get_dept_id;
--
OPEN csr_get_dept_id (l_org_id, l_div_type);
FETCH csr_get_dept_id INTO l_div_id;

CLOSE csr_get_dept_id;
--
OPEN csr_get_dept_id (l_org_id, l_sect_type);
FETCH csr_get_dept_id INTO l_sect_id;

CLOSE csr_get_dept_id;
--
OPEN csr_dept_mgr (l_dept_id);
FETCH csr_dept_mgr INTO l_dept_head;

CLOSE csr_dept_mgr;
DBMS_OUTPUT.put_line ('csr_dept_mgr' || l_dept_head);
--
OPEN csr_dept_mgr (l_div_id);
FETCH csr_dept_mgr INTO l_div_head;

CLOSE csr_dept_mgr;
--
OPEN csr_dept_mgr (l_sect_id);
FETCH csr_dept_mgr INTO l_sect_head;

CLOSE csr_dept_mgr;
---

DBMS_OUTPUT.put_line ('HR Mgr' || l_hr_mgr);


DBMS_OUTPUT.put_line ('Sen. Prsl' || l_sr_prsnl_proc);
DBMS_OUTPUT.put_line ('Ins Spec' || l_ins_spec);
DBMS_OUTPUT.put_line ('Trav Spec' || l_trv_spec);
--
-- Business Rules for Different S.I.T Requests are checked here.
-- **************************************

----Application Service Request


IF l_id_flex_num = g_ser_req_id THEN
l_level1 := '530032';
l_level2 := '200020';

END IF;

----Duplicate Application Service Request


IF l_id_flex_num = g_ser_requ_id THEN
l_level1 := '530032';
l_level2 := '200020';

END IF;

--- Application Authorization Request


IF l_id_flex_num = g_auth_req_id THEN
l_level1 := '530032';
l_level2 := '540039';
l_level3 := '200020';
END IF;

--- Operation Authorization Request


IF l_id_flex_num = g_oper_auth_id THEN
l_level1 := '540123';
l_level2 := '200020';

END IF;

---Operations Service Request


IF l_id_flex_num = g_oper_req_id THEN
l_level1 := '540123';
l_level2 := '200020';

END IF;
-----
----Telephone Service Request

IF l_id_flex_num = g_tele_ser_req_id THEN


l_level1 := 540074;
l_level2 := 740073;

END IF;
------Telecommunication Change Request
IF l_id_flex_num = g_tele_chng_req_id then
l_level1 := 540074;
l_level2 := 740073;

END IF;
-------
---TK Approved Overtime
IF l_id_flex_num = g_over_time_id THEN
l_level1 := '200021';
END IF;
----
--- TK Mis Punch Form

IF l_id_flex_num = g_mis_punch_id THEN


l_level1 := '200021';
END IF;
---

--TK Late or Short Leave Request

IF l_id_flex_num = g_shrt_leav_id THEN

---IF l_locn_code IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN

IF l_seg4 IN ('Short Leave') then


l_level1 := l_dept_head;
l_level2 := '200021';

ELSE

IF l_seg4 NOT IN ('Short Leave') THEN

l_level1 := '200021';

END IF;
END IF;
END IF;
------
--TK Lieu Leave Request

IF l_id_flex_num = g_lieu_leav_id THEN


l_level1 := '200021';
END IF;

--------

---TK Shift Change Request


IF l_id_flex_num = g_shft_chng_id THEN
IF l_locn_code IN (g_abs_loc_ain_dar, g_abs_loc_hofuf)
AND v_department in ('05-Human Resources','05-Material Supply','05-Relations &
Support Svs','05-Finance','05-Information Technology','05-Sales') then

l_level1 := '200021';

ELSE

IF l_locn_code IN (g_abs_loc_ain_dar, g_abs_loc_hofuf)


AND v_department not in ('05-Human Resources','05-Material Supply','05-
Relations & Support Svs','05-Finance','05-Information Technology','05-Sales') then
l_level1 := '330832';
l_level2 := '200021';

ELSE
IF l_locn_code NOT IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN

l_level1 := '200021';

END IF;
END IF;
END IF;
END IF;

-------
--- TK Shift Schedule Request
IF l_id_flex_num = g_Shft_Sch_Chng_id THEN
IF l_locn_code IN (g_abs_loc_ain_dar, g_abs_loc_hofuf)
AND v_department in ('05-Human Resources','05-Material Supply','05-Relations &
Support Svs','05-Finance','05-Information Technology','05-Sales') then

l_level1 := '200021';

ELSE

IF l_locn_code IN (g_abs_loc_ain_dar, g_abs_loc_hofuf)


AND v_department not in ('05-Human Resources','05-Material Supply','05-
Relations & Support Svs','05-Finance','05-Information Technology','05-Sales') then
l_level1 := '330832';
l_level2 := '200021';

ELSE
IF l_locn_code NOT IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN

l_level1 := '200021';

END IF;
END IF;
END IF;
END IF;
-----
---TK Manual Pay Correction Form

IF l_id_flex_num = g_Manl_Pay_Corr_id then


l_level1 := '200021';
l_level2 := '104631';
END IF;

--- TK Week Off Compensation Request


IF l_id_flex_num = g_Week_off_cmpnsn_id THEN
l_level1 := '200021';
END IF;

----- TK Issue Company Badge ID

IF l_id_flex_num = g_Issue_Co_Bdge_id THEN


l_level1 := '200021';

END IF;

------Business Card Requisition


IF l_id_flex_num = g_Busins_card_id THEN
IF l_locn_code IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN

l_level1 := 530698;
ELSE
IF l_locn_code NOT IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN

l_level1 := 104137;
l_level2 := 530754;
END IF;
END IF;
END IF;

------------------- Facsimile Request


IF l_id_flex_num = g_fcsimile_tran_id THEN

l_level2 := 651377;
l_level3 := 104137;

END IF;

----Courier Service Request


IF l_id_flex_num = g_courier_ser_id THEN

l_level3 := 651377;
l_level4 := 104137;

END IF;

----- Kitchen Item Requisition COS

IF l_id_flex_num = g_Ktchn_itm_id THEN


IF l_locn_code IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN

l_level1 := 651320;
ELSE
IF l_locn_code NOT IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN

l_level1 := 530754;
l_level2 := 104137;

END IF;
END IF;
END IF;

---- Cleaning Item Requisition COS

IF l_id_flex_num = g_clning_itm_id THEN


IF l_locn_code IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN

l_level1 := 651320;
ELSE
IF l_locn_code NOT IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN

l_level1 := 530754;
l_level2 := 104137;

END IF;
END IF;
END IF;

-----Mobile Phone Repair Request


IF l_id_flex_num = g_mobile_repr_id THEN
l_level1 := 540074;
l_level2 := 740073;

END IF;
-----Mobile Phone Requisition

IF l_id_flex_num = g_mobile_req_id THEN


l_level1 := 540074;
l_level2 := 740073;

END IF;

-----Work Maintenance Requisition


IF l_id_flex_num = g_work_mtn_id THEN
l_level1 := 104137;
l_level2 := 530754;
l_level3 := 530895;
END IF;
----
------- Forms Requisition Commumnication and Office Services
IF l_id_flex_num = g_forms_req_id THEN
IF l_locn_code IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN
l_level1 := 651320;

ELSE
IF l_locn_code NOT IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN
l_level1 := 104137;
l_level2 := 530754;

END IF;
END IF;
END IF;
-----Stationery Requisition

IF l_id_flex_num = g_stationery_req_id THEN


IF l_locn_code IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN
l_level1 := 651320;

ELSE
IF l_locn_code NOT IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN
l_level1 := 104137;
l_level2 := 530754;

END IF;
END IF;
END IF;

---- Vehicle Requisition


IF l_id_flex_num = g_veh_req_id THEN
IF l_locn_code IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN
l_level1 := 103977;
l_level2 := 200024;
l_level3 := 651433;
l_level4 := 651273;
l_level5 := 651320;

ELSE

IF l_locn_code NOT IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN

l_level1 := 104137;
l_level2 := 530754;
l_level3 := 740212;

END IF;
END IF;
END IF;

---- Vehicle Requisition 2


IF l_id_flex_num = g_veh_req2_id THEN
IF l_locn_code IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN
l_level1 := 103977;
l_level2 := 651433;
l_level3 := 651273;
l_level4 := 651320;
ELSE

IF l_locn_code NOT IN (g_abs_loc_ain_dar, g_abs_loc_hofuf) THEN


l_level1 := 104137;
l_level2 := 530754;
END IF;
END IF;
END IF;
--------
---Guest House Request
IF l_id_flex_num = g_guest_hse_id THEN

l_level1 := 103675;

END IF;

-----Accomodation Request
IF l_id_flex_num = g_Accomodation_id THEN

l_level1 := 103675;
END IF;
-----

---
DBMS_OUTPUT.put_line ('Begin LF');
DBMS_OUTPUT.put_line ('Level 1: ' || l_level1);
DBMS_OUTPUT.put_line ('Level 2: ' || l_level2);
DBMS_OUTPUT.put_line ('Level 3: ' || l_level3);
DBMS_OUTPUT.put_line ('Level 4: ' || l_level4);
DBMS_OUTPUT.put_line ('Level 5: ' || l_level5);
-- **********************************************
l_level1 := NVL (l_level1, g_dummy_value);
l_level2 := NVL (l_level2, g_dummy_value);
l_level3 := NVL (l_level3, g_dummy_value);
l_level4 := NVL (l_level4, g_dummy_value);
l_level5 := NVL (l_level5, g_dummy_value);
-- **********************************************
IF ((l_level1 <> g_dummy_value) AND (l_emp_num NOT IN (l_level1))) THEN
PIPE ROW ('person_id:' || get_person_id (l_level1));
END IF;
--
IF ((l_level2 <> g_dummy_value) AND (l_emp_num NOT IN (l_level2))) THEN
PIPE ROW ('person_id:' || get_person_id (l_level2));
END IF;
--
IF ((l_level3 <> g_dummy_value) AND (l_emp_num NOT IN (l_level3))) THEN
PIPE ROW ('person_id:' || get_person_id (l_level3));
END IF;
--
IF ((l_level4 <> g_dummy_value) AND (l_emp_num NOT IN (l_level4))) THEN
PIPE ROW ('person_id:' || get_person_id (l_level4));
END IF;
RETURN;
EXCEPTION
WHEN OTHERS THEN
raise_application_error (-20006, 'ERROR 2: Some Critical Error Occured, Contact
System Administrator.' || SUBSTR (SQLERRM, 1, 200) );
END cstm_fyi_grp_1;
PROCEDURE Manual_Pay_Element_Correction(
x_retcode OUT NOCOPY VARCHAR2
,x_errbuf OUT NOCOPY VARCHAR2
)

IS
--

l_effective_start_date date;
l_effective_end_date date;
l_element_entry_id number;
l_object_version_number number;
l_create_warning boolean;
l_validate boolean :=FALSE;

v_element_link_id number;
v_ass_loc varchar2(100);
v_element_hrs_value_id number;
v_sdate date;

cursor c is select
ppa.person_id,assignment_id,date_from,
paaf.LOCATION_ID,paaf.organization_id,

segment1,segment2,segment3,segment4,segment5,segment6,segment7,segment8,segment9,
fnd_date.string_to_date(segment13,'YYYY/MM/DD HH24:MI:SS')
correction_date
from per_person_analyses ppa,
per_analysis_criteria pac,
per_all_assignments_f paaf
where ppa.id_flex_num = 50545
and ppa.person_id = paaf.person_id
and paaf.assignment_id = 4824
and (segment18 = 'No' or segment18 is null)
and ppa.ANALYSIS_CRITERIA_ID = pac.ANALYSIS_CRITERIA_ID
and sysdate between effective_start_date and effective_end_date;

-- to_date(p_period, wf_core.canonical_date_mask)

p_data c%rowtype;

begin

OPEN c;

LOOP

v_element_link_id := null;
v_element_hrs_value_id := null;

FETCH c INTO p_data;


EXIT WHEN c%NOTFOUND;

-- Fetch Location

select loc.location_code
into v_ass_loc
from hr_locations_v loc,
per_all_assignments_f asg
where loc.location_id = asg.location_id
and effective_start_Date = (select max(effective_start_date)
from per_all_assignments_f asg1
where assignment_id = p_data.assignment_id)
and assignment_id = p_data.assignment_id;

-- Fetch Element Link Id for OT Hrs element


select element_link_id
into v_element_link_id
from pay_element_types_f pt,
pay_element_links_f pl
where pt.element_type_id = pl.element_type_id
and pt.business_group_id = 81
and upper(pt.element_name) = upper(p_data.segment6)
and pt.effective_end_date = '31-DEC-4712';

-- Fetch Input Value Id for

select input_value_id
into v_element_hrs_value_id
from pay_element_types_f pet,
pay_input_values_f piv
where pet.element_type_id= piv.element_type_id
and pet.business_group_id = 81
and upper(piv.name) like upper('Hours%')
and upper(pet.element_name) = upper(p_data.segment6)
and pet.effective_end_date = '31-DEC-4712';

pay_element_entry_api.create_element_entry
(p_validate => l_validate
,p_effective_date => p_data.correction_date --sysdate
,p_business_group_id => 81
,p_assignment_id => p_data.assignment_id
,p_element_link_id => v_element_link_id --in number
,p_entry_type => 'E' --in Entry_Type in HR_lookups
Table
,p_input_value_id1 => v_element_hrs_value_id -- this has to be fetched from
element link table
--,p_input_value_id5 => 180
,p_entry_value1 => p_data.segment8
--,p_entry_value5 => p_data.start_date
,p_effective_start_date => l_effective_start_date
,p_effective_end_date => l_effective_end_date
,p_element_entry_id => l_element_entry_id
,p_object_version_number => l_object_version_number
,p_create_warning => l_create_warning -- out nocopy boolean
);

--l_count := l_count + 1 ;

UPDATE per_analysis_criteria a
set segment18 = 'Yes'
Where a.id_flex_num = 50545
and a.ANALYSIS_CRITERIA_ID IN
(SELECT ppa.ANALYSIS_CRITERIA_ID
from per_person_analyses ppa,
per_analysis_criteria pac
where ppa.id_flex_num = 50545
and ppa.ANALYSIS_CRITERIA_ID =
pac.ANALYSIS_CRITERIA_ID
and person_id = p_data.person_id
and (segment18 = 'No' or segment18 is null));

end loop;
close c;
commit;

--DBMS_OUTPUT.PUT_LINE( 'No of Successfull Records '|| l_count );

EXCEPTION
WHEN OTHERS THEN
x_retcode := 2;
x_errbuf := SUBSTRB(sqlerrm,1,255);
dbms_output.put_line('errbuf='||x_errbuf);
--ROLLBACK;
--RAISE;

/*
when others then

l_err := substr(ltrim(sqlerrm),1,100);

insert into xx_error_log1


(emp_no, error_desc, run_date,period)
values (p_data.employee_code, l_err , sysdate,p_data.period);

update xx_empwise_pay
set posted = 'Y'
where rowid = p_data.row_id;
*/
end Manual_Pay_Element_Correction;

END xxscc_sit_aprvl_pkg_1;

Вам также может понравиться