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

Sync Assignment Costing and Create Auto User with responsibility

================================================================

CREATE OR REPLACE PACKAGE APPS.XXLAM_HR_SYS_SCHED_PROC_PKG is

PROCEDURE SYNC_ASG_COST(ERRBUF out nocopy varchar2,


RETCODE out nocopy number,
p_business_group_id in number);

Procedure CREATE_PASSPORT_RELEASE_REQ(ERRBUF out nocopy varchar2,


RETCODE out nocopy number,
p_business_group_id in number);

Procedure Zap_CARRYOVER_Element_Entries(P_PERSON_ID IN NUMBER,


P_TERM_DATE IN DATE);

Procedure CORRECT_ASG_PURCHASING_COSTING(ERRBUF out nocopy varchar2,


RETCODE out nocopy number);

Procedure CORRECT_EMAIL(ERRBUF out nocopy varchar2,


RETCODE out nocopy number,
p_person_Id NUMBER,
p_email_address VARCHAR2,
p_ad_user VARCHAr2,
p_domain_name_id VARCHAR2);

PROCEDURE USER_CREATION_RESP_ASG(ERRBUF out nocopy varchar2,


RETCODE out nocopy number,
p_business_group_id in number);

PROCEDURE CREATE_USER(p_user_name IN VARCHAR2,


p_password IN VARCHAR2,
p_full_name VARCHAR2,
p_email_address VARCHAR2 DEFAULT NULL,
p_person_id IN NUMBER,
p_error OUT VARCHAR2);

PROCEDURE CREATE_RESP(p_emp_no IN VARCHAR2,


p_person_id IN NUMBER,
p_resp_key IN VARCHAR2,
p_resp_app VARCHAR2,
p_error OUT varchar2);

Procedure DECIMAL_CARRYOVER(ERRBUF out nocopy varchar2,


RETCODE out nocopy number,
p_DATE_CHAR IN VARCHAR2);

PROCEDURE XXLEL_UPDATE_IT_TASKS(errbuf OUT varchar2, retcode OUT varchar2);

FUNCTION GET_MOBILE_NUMBER(P_EMPLOYEE_NUMBER IN VARCHAR2) RETURN VARCHAR2;


END;
/

===================================================================================
=======================

CREATE OR REPLACE PACKAGE BODY APPS.XXLAM_HR_SYS_SCHED_PROC_PKG is


PROCEDURE SYNC_ASG_COST(ERRBUF out nocopy varchar2,
RETCODE out nocopy number,
p_business_group_id in number) IS

/*Out Variables*/

L_CNT NUMBER := 0;
v_loc VARCHAR2(100) := NULL;
v_Error VARCHAR2(1000) := NULL;
v_object_version_number NUMBER := NULL;
pp_Effective_start_Date DATE := NULL;
pp_effective_end_Date DATE := NULL;
v_mode VARCHAR2(100) := 'CORRECTION';
pp_combination_name VARCHAR2(100) := NULL;
pp_cost_allocation_id NUMBER := NULL;
pp_cost_allocation_keyflex_id NUMBER := NULL;
l_cost_cnt NUMBER := 0;
v_new_date DATE := sysdate;
l_conc_request_id NUMBER; --:= fnd_global.conc_request_id;
v_ERRBUF VARCHAR2(3000) := NULL;
v_RETCODE NUMBER := NULL;
CURSOR crsr_emp IS

select ppg.SEGMENT6,
ppg.SEGMENT7,
DECODE(ppg.segment9,
'030201',
'030200',
'030500',
'030400',
ppg.segment9) segment9, --ppg.segment9,
paa.assignment_id,--paa.effective_Start_Date,
greatest(paa.effective_start_Date, TO_DATE('01-JAN-2015'))
EFFECTIVE_START_DATE,
paa.assignment_number
from per_all_assignments_f paa,
pay_people_groups ppg,
per_all_people_f pap
where paa.primary_flag = 'Y'
and nvl(paa.people_group_id, 61) = ppg.people_group_id
and ppg.SEGMENT6 is not null
and ppg.SEGMENT7 is not null
and ppg.segment9 is not null
and paa.person_Id = pap.person_Id
and trunc(sysdate) between pap.effective_start_date and
pap.effective_End_Date
-- and pap.employee_number = '0012059'
and ( /*--pap.employee_number in (select employee_number from
xxlel.xxlam_hr_upl_bu_final_280915)
-- or pap.employee_number in ( select employee_number from
xxlel.xxlam_hr_upl_pos_final_280915) or
*/
-- paa.assignment_number in
-- ('0013494') or
-- ( paa.assignment_number in
-- ('0013494') and paa.effective_Start_Date>= TO_DATE('01-MAY-
2017')) or
paa.assignment_Id not in (select assignment_Id from Pay_Cost_Allocations_f)
or
paa.last_update_date >
(select max(t.execution_date) from XXLAM_HR_SYS_ASG_COSTING_T t)
/*
paa.assignment_id in (select assignment_Id from
xxlel.XXLAM_HR_UPL_EXP_CAT_FINAL
where processed = 'Y'
and paa.effective_End_Date >= TO_DATE('01-FEB-2017')*/
)

-- and nvl(paa.Effective_End_Date, TO_DATE('31-DEC-4712')) >=


-- TO_DATE('31-DEC-4712')

and pap.employee_number is not null


-- and paa.assignment_number in ('0000019', '0000068', '0000720')
order by paa.assignment_id, paa.effective_Start_Date;

CURSOR crsr_cost(p_asg_id number, p_eff_date date, P_ass_18 varchar2, p_ass_19


varchar2) is
select pcaf.cost_allocation_id,
pcaf.effective_start_date,
pcaf.object_version_number,
pcaf.proportion,
k.segment4,
k.segment6,
k.segment8
from pay_Cost_allocations_f pcaf, pay_cost_allocation_keyflex k
where p_eff_date between pcaf.effective_start_date and
pcaf.effective_end_date
and pcaf.assignment_id = p_asg_id
and k.cost_allocation_keyflex_id = pcaf.cost_allocation_keyflex_id
-- and nvl(k.segment4, 'X') || nvl(k.segment6, 'X') <>
-- p_ass_18 || p_ass_19
;

-- select t.*
-- from XXLAM_HR_SYS_UPL_ASG_COST_TEMP T
-- where t.processed is null
-- and rownum = 1
-- and t.assignment_id = 1871
/* and t.cost_allocation_id not in
(select pcaf.cost_allocation_id
from pay_cost_allocations_f pcaf
having count(*) >1
group by pcaf.cost_allocation_id
)
*/
-- and t.recno in (62,63)
--and t.assignment_id = 2196
--;

BEGIN
l_conc_request_id := fnd_global.conc_request_id;
FOR rec IN crsr_emp LOOP
BEGIN
V_ERROR := NULL;
pp_Effective_start_Date := NULL;
pp_effective_end_Date := NULL;
v_object_version_number := NULL;
pp_combination_name := NULL;
pp_cost_allocation_id := NULL;
pp_cost_allocation_keyflex_id := NULL;
v_loc := NULL;
l_cost_cnt := 0;

FOR c in crsr_cost(rec.assignment_id,
rec.effective_start_date,
rec.segment6,
rec.segment7) loop
l_cost_cnt := l_cost_Cnt + 1;
-- DBMS_OUTPUT.PUT_LINE(rec.assignment_Id);

end loop;
/*
IF(rec.effective_end_date <> TO_DATE('31-DEC-4712','DD-MON-YYYY') AND
rec.effective_start_date = rec.min_eff_start_date) THEN
v_mode := 'UPDATE_CHANGE_INSERT';
ELSE v_mode := 'CORRECTION';
END IF;
*/
-- initiate_data_upload_user(ele_rcrd.business_group_id);
IF (l_cost_cnt = 0) THEN
BEGIN

hr_general.g_data_migrator_mode := 'Y';
COMMIT;
pay_cost_allocation_api.CREATE_COST_ALLOCATION(p_validate
=> FALSE,
p_effective_date
=> rec.effective_start_date,
p_assignment_id
=> rec.assignment_id,
p_proportion
=> 1,
p_business_group_id
=> p_business_group_id,
p_segment4
=> rec.segment6,
p_segment6
=> rec.segment7,
p_segment8
=> rec.segment9,
p_combination_name
=> pp_combination_name,
p_cost_allocation_id
=> pp_cost_allocation_id,

p_cost_allocation_keyflex_id => pp_cost_allocation_keyflex_id,


p_effective_start_date
=> pp_Effective_start_Date,
p_effective_end_date
=> pp_effective_end_Date,
p_object_version_number
=> v_object_version_number);
/*
UPDATE_COST_ALLOCATION(p_validate => FALSE,
p_effective_date
=> rec.effective_start_date,
p_datetrack_update_mode
=> v_mode,
p_cost_allocation_id
=> rec.cost_allocation_id,
p_object_version_number
=> v_object_version_number,
p_segment1
=> '',
p_segment2
=> '',
p_segment3 => '',
p_segment11 =>
rec.ora_company,
p_segment12 =>
rec.ora_dept_code,
p_segment13
=>rec.ora_gl_code,
p_segment14 =>
rec.ora_loc_code,
p_segment15 =>
rec.ora_cnrt_code,
p_segment16 =>
rec.ora_company,
--
p_concat_segments => '----'||rec.ora_dept_code||'--'||rec.ora_loc_code||'-'||
rec.ora_cnrt_code||'---',
p_combination_name
=> pp_combination_name,

p_cost_allocation_keyflex_id => v_cost_allocation_keyflex_id,


p_effective_start_date
=> pp_Effective_start_Date,
p_effective_end_date
=> pp_effective_end_Date);

*/
L_CNT := L_CNT + 1;
fnd_file.put_line(fnd_file.output,
rec.assignment_number || '~' ||
LPAD(TO_CHAR(rec.assignment_id), 7, ' ') || '~' ||
LPAD(TO_CHAR(pp_cost_allocation_keyflex_id),
7,
' ') || '~' || '1-OK');

COMMIT;

BEGIN
INSERT INTO xxlam_hr_sys_asg_cost_log_t T
VALUES
(l_conc_request_id,
v_new_date,
rec.assignment_id,
rec.effective_start_date,
1,
pp_cost_allocation_keyflex_id,
'NEW');
EXCEPTION
WHEN OTHERS THEN
fnd_file.put_line(fnd_file.output,
rec.assignment_number || '~' ||
LPAD(TO_CHAR(rec.assignment_id), 7, ' ') || '~'
||
'1.5-ER' || '~' || V_ERROR);

END;
EXCEPTION
WHEN OTHERS THEN
V_ERROR := SQLERRM;
fnd_file.put_line(fnd_file.output,
rec.assignment_number || '~' ||
LPAD(TO_CHAR(rec.assignment_id), 7, ' ') || '~' ||
'1-ER' || '~' || V_ERROR);

END;
ELSE

FOR c in crsr_cost(rec.assignment_id,
rec.effective_start_date,
rec.segment6,
rec.segment7) loop
-- IF(l_cost_cnt = 0) THEN
-- DBMS_OUTPUT.PUT_LINE(rec.assignment_Id||'~'||c.segment4||'~'||
c.segment6||'~'||c.segment8||'~'||rec.segment6||'~'||rec.segment7||'~'||
rec.segment9);
IF nvl(c.segment4, 'X') || nvl(c.segment6, 'X') ||
nvl(c.segment8, 'X') <>
rec.segment6 || rec.segment7 || rec.segment9 THEN
-- p_ass_18 || p_ass_19
BEGIN

V_ERROR := NULL;
v_mode := 'CORRECTION';
pp_Effective_start_Date := NULL;
pp_effective_end_Date := NULL;

v_object_version_number := NULL;
pp_combination_name := NULL;
pp_cost_allocation_id := NULL;
pp_cost_allocation_keyflex_id := NULL;
v_object_version_number := c.object_version_number;

IF (c.effective_Start_date < rec.effective_start_date) then


v_mode := 'UPDATE';
END IF;
hr_general.g_data_migrator_mode := 'Y';
commit;
pay_cost_allocation_api.UPDATE_COST_ALLOCATION(p_validate
=> FALSE,
p_effective_date
=> rec.effective_start_date,

p_datetrack_update_mode => v_mode,


p_cost_allocation_id
=> c.cost_allocation_id
--
,p_object_version_number => v_object_version_number
,
p_segment4
=> rec.segment6,
p_segment6
=> rec.segment7,
p_segment8
=> rec.segment9,
p_combination_name
=> pp_combination_name,

p_cost_allocation_keyflex_id => pp_cost_allocation_keyflex_id,

p_effective_start_date => pp_Effective_start_Date,


p_effective_end_date
=> pp_effective_end_Date,

p_object_version_number => v_object_version_number);


/*
UPDATE_COST_ALLOCATION(p_validate => FALSE,
p_effective_date
=> rec.effective_start_date,

p_datetrack_update_mode => v_mode,

p_cost_allocation_id => rec.cost_allocation_id,

p_object_version_number => v_object_version_number,


p_segment1
=> '',
p_segment2
=> '',
p_segment3 => '',
p_segment11 =>
rec.ora_company,
p_segment12 =>
rec.ora_dept_code,
p_segment13
=>rec.ora_gl_code,
p_segment14 =>
rec.ora_loc_code,
p_segment15 =>
rec.ora_cnrt_code,
p_segment16 =>
rec.ora_company,
--
p_concat_segments => '----'||rec.ora_dept_code||'--'||rec.ora_loc_code||'-'||
rec.ora_cnrt_code||'---',
p_combination_name
=> pp_combination_name,

p_cost_allocation_keyflex_id => v_cost_allocation_keyflex_id,

p_effective_start_date => pp_Effective_start_Date,

p_effective_end_date => pp_effective_end_Date);

*/
L_CNT := L_CNT + 1;
fnd_file.put_line(fnd_file.output,
rec.assignment_number || '~' ||
LPAD(TO_CHAR(rec.assignment_id), 7, ' ') || '~'
||
LPAD(TO_CHAR(pp_cost_allocation_keyflex_id),
7,
' ') || '~' || '2-OK');

COMMIT;

BEGIN
INSERT INTO xxlam_hr_sys_asg_cost_log_t T
VALUES
(l_conc_request_id,
v_new_date,
rec.assignment_id,
rec.effective_start_date,
c.proportion,
pp_cost_allocation_keyflex_id,
v_mode);
EXCEPTION
WHEN OTHERS THEN
fnd_file.put_line(fnd_file.output,
rec.assignment_number || '~' ||
LPAD(TO_CHAR(rec.assignment_id),
7,
' ') || '~' || '2.5-ER' || '~' ||
V_ERROR);
END;
EXCEPTION
WHEN OTHERS THEN
V_ERROR := SQLERRM;
fnd_file.put_line(fnd_file.output,
rec.assignment_number || '~' ||
LPAD(TO_CHAR(rec.assignment_id), 7, ' ') || '~'
||
LPAD(TO_CHAR(pp_cost_allocation_keyflex_id),
7,
' ') || '~' || '2-ER' || '~' ||
V_ERROR);
-- V_ERROR);
END;
END IF;
END LOOP;

END IF;
/* IF (V_ERROR IS NOT NULL) THEN

ROLLBACK;

UPDATE XXLAM_HR_SYS_UPL_ASG_COST_TEMP Q
SET PROCESSED = 'N', ERROR = V_ERROR
WHERE Q.Assignment_Id = rec.assignment_id
and q.effective_start_date = rec.effective_start_date;
COMMIT;
ELSE
UPDATE XXLAM_HR_SYS_UPL_ASG_COST_TEMP Q
SET PROCESSED = 'Y'
WHERE Q.ASSIGNMENT_ID = rec.assignment_id
and q.effective_start_date = rec.effective_start_date;
COMMIT;
END IF;
*/
END;
END LOOP;
INSERT INTO XXLAM_HR_SYS_ASG_COSTING_T
VALUES
(l_conc_request_id, v_new_date);

fnd_file.put_line(fnd_file.output, L_CNT);
dbms_output.put_line(l_cnt);
COMMIT;
v_ERROR := NULL;
v_ERRBUF := NULL;
v_retcode := NULL;
BEGIN
XXLAM_HR_SYS_ALERTS_PKG.ALERT_GENERATOR(ERRBUF => v_ERRBUF,
RETCODE => v_retcode,
p_Alert_ID => 'HCM0021');
fnd_file.put_line(fnd_file.output,
'NEW_TASK>' ||
TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') || '>');
EXCEPTION
WHEN OTHERS THEN
v_error := SQLERRM;
fnd_file.put_line(fnd_file.output,
'NEW_TASK>' ||
TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') || '>' ||
v_error);
END;

v_ERROR := NULL;
v_ERRBUF := NULL;
v_retcode := NULL;
BEGIN
XXLAM_HR_SYS_ALERTS_PKG.ALERT_GENERATOR(ERRBUF => v_ERRBUF,
RETCODE => v_retcode,
p_Alert_ID => 'HCM0024');
fnd_file.put_line(fnd_file.output,
'COMPLETE_CHKLST>' ||
TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') || '>');
EXCEPTION
WHEN OTHERS THEN
v_error := SQLERRM;
fnd_file.put_line(fnd_file.output,
'COMPLETE_CHKLST>:' ||
TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') || '>' ||
v_error);
END;

v_ERROR := NULL;
v_ERRBUF := NULL;
v_retcode := NULL;
BEGIN
XXLAM_HR_SYS_ALERTS_PKG.ALERT_GENERATOR(ERRBUF => v_ERRBUF,
RETCODE => v_retcode,
p_Alert_ID => 'HCM0038');
fnd_file.put_line(fnd_file.output,
'IT NEW TASK>' ||
TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') || '>');
EXCEPTION
WHEN OTHERS THEN
v_error := SQLERRM;
fnd_file.put_line(fnd_file.output,
'IT NEW TASK>:' ||
TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') || '>' ||
v_error);
END;

v_ERROR := NULL;
v_ERRBUF := NULL;
v_retcode := NULL;
BEGIN
XXLAM_HR_SYS_ALERTS_PKG.ALERT_GENERATOR(ERRBUF => v_ERRBUF,
RETCODE => v_retcode,
p_Alert_ID => 'HCM0039');
fnd_file.put_line(fnd_file.output,
'IT TASK COMPLETION>' ||
TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') || '>');
EXCEPTION
WHEN OTHERS THEN
v_error := SQLERRM;
fnd_file.put_line(fnd_file.output,
'IT TASK COMPLETION>:' ||
TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') || '>' ||
v_error);
END;

v_ERROR := NULL;
v_ERRBUF := NULL;
v_retcode := NULL;
BEGIN
XXLAM_HR_SYS_ALERTS_PKG.ALERT_GENERATOR(ERRBUF => v_ERRBUF,
RETCODE => v_retcode,
p_Alert_ID => 'HCM0025');
fnd_file.put_line(fnd_file.output,
'EXIT_CHKLST>:' ||
TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') || '>');
EXCEPTION
WHEN OTHERS THEN
v_error := SQLERRM;
fnd_file.put_line(fnd_file.output,
'EXIT_CHKLST>:' ||
TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') || '>' ||
v_error);
END;

v_ERROR := NULL;
v_ERRBUF := NULL;
v_retcode := NULL;
BEGIN
XXLAM_HR_SYS_ALERTS_PKG.ALERT_GENERATOR(ERRBUF => v_ERRBUF,
RETCODE => v_retcode,
p_Alert_ID => 'HCM0044');
fnd_file.put_line(fnd_file.output,
'STLL>' ||
TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') || '>');
EXCEPTION
WHEN OTHERS THEN
v_error := SQLERRM;
fnd_file.put_line(fnd_file.output,
'STLL>:' ||
TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') || '>' ||
v_error);
END;

v_ERROR := NULL;
v_ERRBUF := NULL;
v_retcode := NULL;
BEGIN
XXLAM_HR_SYS_ALERTS_PKG.ALERT_GENERATOR(ERRBUF => v_ERRBUF,
RETCODE => v_retcode,
p_Alert_ID => 'HCM0071');
fnd_file.put_line(fnd_file.output,
'ITNJ>' ||
TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') || '>');
EXCEPTION
WHEN OTHERS THEN
v_error := SQLERRM;
fnd_file.put_line(fnd_file.output,
'ITNJ>:' ||
TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') || '>' ||
v_error);
END;

v_ERROR := NULL;
v_ERRBUF := NULL;
v_retcode := NULL;
BEGIN
XXLAM_HR_SYS_ALERTS_PKG.ALERT_GENERATOR(ERRBUF => v_ERRBUF,
RETCODE => v_retcode,
p_Alert_ID => 'HCM0049');
fnd_file.put_line(fnd_file.output,
'EXIT_SURVEY>' ||
TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') || '>');
EXCEPTION
WHEN OTHERS THEN
v_error := SQLERRM;
fnd_file.put_line(fnd_file.output,
'EXIT_SURVEY>:' ||
TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') || '>' ||
v_error);
END;

END SYNC_ASG_COST;

Procedure CREATE_PASSPORT_RELEASE_REQ(ERRBUF out nocopy varchar2,


RETCODE out nocopy number,
p_business_group_id in number) IS

V_Error Varchar2(1000);
L_Cnt Number := 0;

Pp_Effective_Start_Date Date;
Pp_Effective_End_Date Date;
Pp_Full_Name Varchar2(1000);
Pp_Comment_Id Number;
Pp_Name_Combination_Warning Boolean;
Pp_Assign_Payroll_Warning Boolean;
Pp_Orig_Hire_Warning Boolean;
p_analysis_criteria_id Number;
p_person_analysis_id Number;
p_pea_object_version_number Number;
L_ID_FLEX_NUM NUMBER := NULL;

Cursor Get_Employee Is
-- select * from xxmb_sshr_user;
select /*t.name||': '||TO_CHAR(a.date_start,'DD-Mon-YYYY')||' To '||
TO_CHAR(a.date_end,'DD-Mon-YYYY'), */
TO_CHAR(a.absence_attendance_id) ABS_ATT_ID_CH,
a.person_Id,
(select p.employee_number
from per_all_people_F p
where trunc(sysdate) between p.effective_Start_Date and
p.effective_end_Date
and p.person_id = a.person_id) EMP_NO,
t.name,
a.date_start,
a.date_end,
--least(a.date_start,
least(a.date_Start,
nvl(FND_DATE.string_to_date(a.attribute4,
'YYYY/MM/DD HH24:MI:SS'),
TO_DATE('31-DEC-4712'))) - 1 REQ_REL_DATE,
greatest(a.date_end,
nvl(FND_DATE.string_to_date(a.attribute5,
'YYYY/MM/DD HH24:MI:SS'),
TO_DATE('01-JAN-1950'))) + 1 EXP_RETURN_DATE,
Fnd_Date.Date_To_Canonical(TO_CHAR(least(a.date_Start,

nvl(FND_DATE.string_to_date(a.attribute4,

'YYYY/MM/DD HH24:MI:SS'),
TO_DATE('31-DEC-4712'))) - 1,
'DD-MON-YYYY')) REQ_REL_DATE_CH,
Fnd_Date.Date_To_Canonical(TO_CHAR(greatest(a.date_end,

nvl(FND_DATE.string_to_date(a.attribute5,

'YYYY/MM/DD HH24:MI:SS'),
TO_DATE('01-JAN-1950'))) +
1,
'DD-MON-YYYY')) EXP_RETURN_DATE_CH
from per_absence_attendances a, per_absence_attendance_types t
where nvl(a.attribute1, 'X') = 'Y'
and date_start >= TO_DATE('01-FEB-2014')
and a.absence_attendance_type_id = t.absence_attendance_type_id
and date_start <= TRUNC(SYSDATE) + 10
-- and a.person_Id = 5145
and to_char(a.absence_attendance_id) not in
(select reason_code from xxlam_hr_sys_sit_pass_rel_v);

Begin

BEGIN
SELECT STT.ID_FLEX_NUM
INTO L_ID_FLEX_NUM
FROM fnd_id_flex_structures_tl stt
WHERE stt.id_flex_structure_name = 'Passport Release Request';

EXCEPTION
WHEN OTHERS THEN
L_ID_FLEX_NUM := NULL;
v_error := 'ID_FLEX_NUM not found';
return;
END;

For Emp In Get_Employee Loop


V_Error := Null;

Pp_Effective_Start_Date := Null;
Pp_Effective_End_Date := Null;
Pp_Full_Name := Null;
Pp_Comment_Id := Null;
Pp_Name_Combination_Warning := Null;
Pp_Assign_Payroll_Warning := Null;
Pp_Orig_Hire_Warning := Null;
p_analysis_criteria_id := Null;
p_person_analysis_id := Null;
p_pea_object_version_number := Null;

Begin
hr_general.g_data_migrator_mode := 'Y';
hr_sit_api.create_sit(p_validate => FALSE,
p_person_id => emp.person_id,
p_business_group_id => p_business_group_Id,
p_id_flex_num => L_ID_FLEX_NUM,
p_effective_date => trunc(sysdate),
p_date_from => trunc(sysdate),
p_segment1 =>
Fnd_Date.Date_To_Canonical(TO_CHAR(trunc(sysdate),

'DD-MON-YYYY')),
p_segment2 => emp.ABS_ATT_ID_CH,
p_segment3 => emp.exp_return_date_ch,
p_segment4 => emp.req_rel_date_Ch,
/* p_segment5 => l_SEGMENT5,

p_segment6 => l_SEGMENT6,

p_segment7 => l_SEGMENT7,

p_segment8 => l_SEGMENT8,

p_segment9 => l_SEGMENT9,

p_segment10 => l_SEGMENT10,

p_segment11 => l_segment11,

p_segment12 => l_SEGMENT12,

p_segment13 => l_SEGMENT13,


p_segment14 => l_SEGMENT14,

p_segment15 => l_SEGMENT15,

p_segment16 => l_SEGMENT16,

p_segment17 => l_SEGMENT17,

p_segment18 => l_SEGMENT18,

p_segment19 => l_SEGMENT19,*/


p_segment20 => emp.name,
p_analysis_criteria_id =>
p_analysis_criteria_id,
p_person_analysis_id => p_person_analysis_id,
p_pea_object_version_number =>
p_pea_object_version_number);

L_Cnt := L_Cnt + 1;
Exception
When Others Then
V_Error := Sqlerrm;
Dbms_Output.Put_Line(Emp.Emp_no || '~' || V_Error);
End;
If (V_Error Is Not Null) Then

Rollback;

INSERT INTO XXLAM_HR_SYS_LV_PP_REL_SYNC_T q


VALUES
(emp.abs_att_id_ch,
emp.person_Id,
emp.emp_no,
emp.name,
emp.date_start,
emp.date_end,
emp.req_rel_Date,
emp.exp_return_date,
emp.req_rel_Date_ch,
emp.exp_return_Date_ch,
sysdate,
NULL,
NULL,
NULL,
V_ERROR);

Commit;
Else
INSERT INTO XXLAM_HR_SYS_LV_PP_REL_SYNC_T q
VALUES
(emp.abs_att_id_ch,
emp.person_Id,
emp.emp_no,
emp.name,
emp.date_start,
emp.date_end,
emp.req_rel_Date,
emp.exp_return_date,
emp.req_rel_Date_ch,
emp.exp_return_Date_ch,
sysdate,
P_PERSON_ANALYSIS_ID,
P_ANALYSIS_CRITERIA_ID,
P_PEA_OBJECT_VERSION_NUMBER,
NULL);

Commit;
End If;

End Loop;

Dbms_Output.Put_Line(L_Cnt);

END CREATE_PASSPORT_RELEASE_REQ;

Procedure Zap_CARRYOVER_Element_Entries(P_PERSON_ID IN NUMBER,


P_TERM_DATE IN DATE) Is

V_Error Varchar2(1000);
L_Cnt Number := 0;

-- v_job_group_id NUMBER;
-- v_job_id NUMBER;
V_Object_Version_Number Number;
-- v_job_definition_id NUMBER;
-- v_name VARCHAR2(1000);
Pp_Effective_Start_Date Date := Null;
Pp_Effective_End_Date Date := Null;
Pp_Delete_Warning Boolean := Null;

Cursor Get_Rec Is
Select Distinct paa.assignment_number,
paa.assignment_id,
paa.person_Id,
petf.element_name,
Pee.Element_Entry_Id,
Pee.Object_Version_Number,
Pee.Effective_Start_Date,
Pee.Effective_End_Date
From Pay_Element_Entries_f Pee,
Pay_Element_Types_f Petf,
Per_All_Assignments_f Paa
Where /*pee.element_link_id in(16740,
*/
Paa.Assignment_Id = Pee.Assignment_Id
--and pee.effective_start_date >= TO_DATE('01-FEB-2013')
And Pee.Effective_Start_Date Between Paa.Effective_Start_Date And
Paa.Effective_End_Date
And Pee.Element_Type_Id = Petf.Element_Type_Id
And Upper(Petf.Element_Name) in
(Upper('Admin Annual Leave Accrual Plan Carried Over'),
Upper('Admin Annual Leave Accrual Plan Residual'))
AND PAA.PERSON_ID = P_PERSON_ID
And Pee.Effective_Start_Date > P_TERM_DATE
-- And To_Date('31-MAY-2013') Between Pee.Effective_Start_Date And
--Pee.Effective_End_Date
And Paa.Business_Group_Id = 81
-- and rownum = 1
-- And Paa.Assignment_Number = '0012059'
/* and pee.element_link_id in
( select pelf.element_link_id,

pelf.object_Version_number,
petf.element_name,
pec.classification_name,

DECODE(petf.processing_type, 'N', 'Nonrecurring', 'Recurring') Processing_type,


pelf.standard_link_flag,
(select k.cnrt_code
from
tg_pay_cost_alloc_kf_v k, hr_all_organization_units hou
where
k.COST_ALLOCATION_KEYFLEX_ID =

hou.cost_allocation_keyflex_id
and
hou.organization_id = pelf.organization_id) CNRT_CODE,

hr_general.DECODE_ORGANIZATION(pelf.organization_id) ORGANIZATION,

hr_general.decode_job(pelf.job_id) JOB,

hr_general.DECODE_PEOPLE_GROUP(pelf.people_group_id) ROSTER,

TO_CHAR(pelf.effective_start_date, 'DD-MON-YYYY') effective_start_date,

TO_CHAR(pelf.effective_end_date, 'DD-MON-YYYY') effective_End_Date,


(select c.segment13
from
pay_cost_allocation_keyflex c
where
c.cost_allocation_keyflex_id =

pelf.cost_allocation_keyflex_id) COSTING_GL_CODE,
(select b.segment13
from
pay_cost_allocation_keyflex b
where
b.cost_allocation_keyflex_id =

pelf.balancing_keyflex_id) BALANCING_GL_CODE,
(select v.DEFAULT_VALUE
from
pay_link_input_values_f v
where v.ELEMENT_LINK_ID
= pelf.element_link_id
and v.DEFAULT_VALUE is
not null) AMOUNT

from Pay_element_types_f
petf,
pay_element_links_f
pelf,

pay_element_classifications pec
where petf.element_type_Id =
pelf.element_type_id
and pelf.business_group_id =
82
and pec.classification_id =
petf.classification_id
--and petf.element_name =
'FAPCO F2 O and M Co Mobile Patrol Allowance'
--and pelf.creation_date >=
TRUNC(SYSDATE) -1
and (select k.cnrt_code
from
tg_pay_cost_alloc_kf_v k, hr_all_organization_units hou
where
k.COST_ALLOCATION_KEYFLEX_ID =

hou.cost_allocation_keyflex_id
and
hou.organization_id = pelf.organization_id) in
('132001', '132002',
'132003', '132004', '132005', '132007')
and petf.element_name not in
('EK ETD Operator Allowance')
and petf.element_name
not in ('EK Cargo MHB Allowance')
and pelf.effective_end_date >
TO_DATE('31-JAN-2013')
and pelf.effective_start_date
< TO_DATE('01-FEB-2013'))*/
;
--and rownum <=200;
/*
and petf.element_name ='DNATA Cargo Svs FG8 TWO Allowance'; */
/* select t.*,
pee.element_entry_id,
pee.effective_start_date,
pee.object_version_number
--pay.payroll_name,tg_payroll_general_pkg.GET_MAX_ELEMENT_ENTRY_ID(paa.business_gro
up_id,paa.assignment_id,t.allowance,TO_DATE('31-JAN-2012'),TO_DATE('31-JAN-2012'))
ELE--,( select * from tg_payroll_results_v v
from TG_UPL_DELETE_ELE_ENTRIES_2 t,
per_all_people_F pap,
per_all_assignments_f paa,
pay_all_payrolls_f pay,
pay_element_entries_f pee,
pay_element_types_f petf
where trunc(sysdate) between pap.effective_start_date and
pap.effective_end_date
-- and pee.effective_start_date >= TO_DATE('01-FEB-2012')
and pap.current_employee_flag = 'Y'
and replace(t.emp_no, 'TG', '0') = pap.employee_number
and pap.person_id = paa.person_id
and trunc(sysdate) between paa.effective_start_date and
paa.effective_end_date
and pay.payroll_id = paa.payroll_id
and pee.assignment_id = paa.assignment_id
and pee.element_type_id = petf.element_type_id
and petf.element_name = t.allowance
-- and paa.assignment_id not in
-- (select pac.assignment_id
-- from pay_assignment_actions pac, pay_payroll_actions ppa
-- where pac.payroll_action_id = ppa.payroll_action_id
-- and ppa.action_type in ('Q', 'R'))
-- and t.emp_no in ('TG06174'
--,'TG54072')
and t.processed is null
--and j.job_name like 'D%'
-- and j.name in ('Apprentice', 'Assistant')
;*/

Begin
For Rec In Get_Rec Loop
V_Error := Null;

Pp_Effective_Start_Date := Null;
Pp_Effective_End_Date := Null;
Pp_Delete_Warning := Null;

If (V_Error Is Null) Then


Begin

/* SELECT t.job_group_id
into v_job_group_Id
from per_job_groups t
where t.business_group_id = p_business_group_id;
*/
/*
hr_job_api.create_job(p_validate => FALSE,
p_business_group_id => p_business_group_id,
p_date_from => TO_DATE('01-JAN-1900'),
p_job_group_id => v_job_group_Id,
p_segment1 => rec.job_code,
p_job_id => v_job_id,
p_object_version_number => v_object_version_number,
p_job_definition_id => v_job_definition_id,
p_name => v_name);
*/

Pay_Element_Entry_Api.Delete_Element_Entry(P_Validate =>
False,
P_Datetrack_Delete_Mode =>
'ZAP',
P_Effective_Date =>
Rec.Effective_Start_Date,
P_Element_Entry_Id =>
Rec.Element_Entry_Id,
P_Object_Version_Number =>
Rec.Object_Version_Number,
P_Effective_Start_Date =>
Pp_Effective_Start_Date,
P_Effective_End_Date =>
Pp_Effective_End_Date,
P_Delete_Warning =>
Pp_Delete_Warning);

Commit;

-- DBMS_OUTPUT.PUT_LINE(REC.REC_NO || '~' || PP_DELETE_WARNING);

L_Cnt := L_Cnt + 1;
Exception
When Others Then
V_Error := Sqlerrm;
DBMS_OUTPUT.PUT_LINE(RPAD(REC.ASSIGNMENT_NUMBER, 10, ' ') || '|' ||
RPAD(REC.ELEMENT_NAME, 40, ' ') || '|' ||
TO_CHAR(REC.EFFECTIVE_START_DATE,
'DD-Mon-YYYY') || '|' || V_Error);
End;
End If;
/* IF (V_ERROR IS NOT NULL) THEN

ROLLBACK;

UPDATE TG_UPL_DELETE_ELE_ENTRIES_2 Q
SET PROCESSED = 'N', ERROR = V_ERROR
WHERE Q.REC_NO = REC.REC_NO;
COMMIT;
ELSE
UPDATE TG_UPL_DELETE_ELE_ENTRIES_2 Q
SET PROCESSED = 'Y'
WHERE Q.REC_NO = REC.REC_NO;
COMMIT;
END IF;
*/

End Loop;

Dbms_Output.Put_Line(L_Cnt);

End Zap_CARRYOVER_Element_Entries;

Procedure CORRECT_ASG_PURCHASING_COSTING(ERRBUF out nocopy varchar2,


RETCODE out nocopy number) Is

V_Error Varchar2(1000);
L_Cnt Number := 0;
-- v_DATE DATE:= NULL;

V_Job_Group_Id Number;
V_Job_Id Number;
V_Object_Version_Number Number;
V_Job_Definition_Id Number;
V_Name Varchar2(1000);
V_Mode Varchar2(100);

Pp_Object_Version_Number Number;
Pp_Special_Ceiling_Step_Id Number;
Pp_People_Group_Id Number;
Pp_Soft_Coding_Keyflex_Id Number;
V_Group_Name Varchar2(1000);
Pp_Effective_Start_Date Date;
Pp_Effective_End_Date Date;
V_Org_Now_No_Manager_Warning Boolean;
V_Other_Manager_Warning Boolean;
V_Spp_Delete_Warning Boolean;
V_Entries_Changed_Warning Varchar2(1000);
V_Tax_District_Changed_Warning Boolean;
Pp_Concatenated_Segments Varchar2(1000);
Pp_No_Managers_Warning Boolean;
Pp_Other_Manager_Warning Boolean;
Pp_Comment_Id Number;
l_concat_seg VARCHAR2(300);
l_code_comb_id NUMBER;
l_total NUMBER := 0;

Cursor Get_Rec Is
/*Select Distinct Paa.Assignment_Id,
Paa.Business_Group_Id,
Paa.Assignment_Number,
Paa.Object_Version_Number,
Paa.Special_Ceiling_Step_Id,
-- paa.people_group_id,
-- paa.soft_coding_keyflex_id,
Paa.Effective_Start_Date,
pap.employee_number,
(select k.COMPANY
from XXLAM_HR_SYS_COST_ALLOC_KF_V k,
hr_all_organization_units hou
where hou.organization_id = paa.ORGANIZATION_ID
and k.cost_allocation_keyflex_id =
hou.cost_allocation_keyflex_id) COMPANY_CODE,
(select k.DEPARTMENT
from XXLAM_HR_SYS_COST_ALLOC_KF_V k,
hr_all_organization_units hou
where hou.organization_id = paa.ORGANIZATION_ID
and k.cost_allocation_keyflex_id =
hou.cost_allocation_keyflex_id) DEPARTMENT_CODE,
'5106018' NATURAL_ACCOUNT,

ppg.SEGMENT6 EXPENSE_CATEGORY,
'0000' ACTIVITY,
ppg.SEGMENT7 VIRTUAL_LOCATION,
'00000000' PROJECT_NUMBER,
ppg.segment9 VALUE_STREAM,
'000' INTERCOMPANY,
'00000' FUTURE_1,
'00000' FUTURE_2,
paa.default_code_comb_id

From Per_All_Assignments_f Paa,


Per_All_People_f Pap,
pay_people_Groups ppg
Where TRUNC(SYSDATE) Between Paa.Effective_Start_Date And
Paa.Effective_End_Date
and TRUNC(SYSDATE) Between Pap.Effective_Start_Date And
Pap.Effective_End_Date
and nvl(paa.people_group_id, 61) = ppg.people_group_Id
And Pap.Person_Id = Paa.Person_Id
and paa.primary_flag = 'Y'
And Pap.Current_Employee_Flag = 'Y'
and pap.employee_number <> '0011833'
-- And Pap.Employee_Number in( '0012059')
And Trunc(Sysdate) Between Pap.Effective_Start_Date And
Pap.Effective_End_Date
-- and paa.job_id is null
And Paa.Business_Group_Id = 81
and paa.organization_Id <> 81
and ppg.segment6 is not null
and ppg.segment7 is not null
and ppg.segment9 is not null
and (paa.default_code_comb_id is null or
(
-- and paa.default_code_comb_id
((select k.COMPANY
from XXLAM_HR_SYS_COST_ALLOC_KF_V k,
hr_all_organization_units hou
where hou.organization_id = paa.ORGANIZATION_ID
and k.cost_allocation_keyflex_id =
hou.cost_allocation_keyflex_id) || '-' ||
(select k.DEPARTMENT
from XXLAM_HR_SYS_COST_ALLOC_KF_V k,
hr_all_organization_units hou
where hou.organization_id = paa.ORGANIZATION_ID
and k.cost_allocation_keyflex_id =
hou.cost_allocation_keyflex_id) || '-' || '5106018' || '-'
||

ppg.SEGMENT6 || '-' || '0000' || '-' || ppg.SEGMENT7 || '-' ||


'00000000' || '-' || ppg.segment9 || '-' || '000' || '-' ||
'00000' || '-' || '00000') not in
(select g.concatenated_segments
from gl_code_combinations_kfv g
where g.code_combination_id = paa.default_code_comb_id)))
UNION
Select Distinct Paa.Assignment_Id,
Paa.Business_Group_Id,
Paa.Assignment_Number,
Paa.Object_Version_Number,
Paa.Special_Ceiling_Step_Id,
-- paa.people_group_id,
-- paa.soft_coding_keyflex_id,
Paa.Effective_Start_Date,
pap.employee_number,
'101' COMPANY_CODE,
'271010' DEPARTMENT_CODE,
'5106018' NATURAL_ACCOUNT,

'41' EXPENSE_CATEGORY,
'0000' ACTIVITY,
ppg.SEGMENT7 VIRTUAL_LOCATION,
'00000000' PROJECT_NUMBER,
'090100' VALUE_STREAM,
'000' INTERCOMPANY,
'00000' FUTURE_1,
'00000' FUTURE_2,
paa.default_code_comb_id

From Per_All_Assignments_f Paa,


Per_All_People_f Pap,
pay_people_Groups ppg
Where TRUNC(SYSDATE) Between Paa.Effective_Start_Date And
Paa.Effective_End_Date
and TRUNC(SYSDATE) Between Pap.Effective_Start_Date And
Pap.Effective_End_Date
and nvl(paa.people_group_id, 61) = ppg.people_group_Id
And Pap.Person_Id = Paa.Person_Id
and paa.primary_flag = 'Y'
And Pap.Current_Employee_Flag = 'Y'
-- And Pap.Employee_Number in( '0012059')
And Trunc(Sysdate) Between Pap.Effective_Start_Date And
Pap.Effective_End_Date
-- and paa.job_id is null
And Paa.Business_Group_Id = 81
and paa.organization_Id <> 81
and ppg.segment6 is not null
and ppg.segment7 is not null
and ppg.segment9 is not null
and pap.employee_number = '0011833'

-- and pap.employee_number = '0012059'

; */

Select Distinct Paa.Assignment_Id,


Paa.Business_Group_Id,
Paa.Assignment_Number,
Paa.Object_Version_Number,
Paa.Special_Ceiling_Step_Id,
-- paa.people_group_id,
-- paa.soft_coding_keyflex_id,
Paa.Effective_Start_Date,
pap.employee_number,
(select k.COMPANY
from XXLAM_HR_SYS_COST_ALLOC_KF_V k,
hr_all_organization_units hou
where hou.organization_id = paa.ORGANIZATION_ID
and k.cost_allocation_keyflex_id =
hou.cost_allocation_keyflex_id) COMPANY_CODE,
(select k.DEPARTMENT
from XXLAM_HR_SYS_COST_ALLOC_KF_V k,
hr_all_organization_units hou
where hou.organization_id = paa.ORGANIZATION_ID
and k.cost_allocation_keyflex_id =
hou.cost_allocation_keyflex_id) DEPARTMENT_CODE,
'5106018' NATURAL_ACCOUNT,

ppg.SEGMENT6 EXPENSE_CATEGORY,
'0000' ACTIVITY,
ppg.SEGMENT7 VIRTUAL_LOCATION,
'00000000' PROJECT_NUMBER,
ppg.segment9 VALUE_STREAM,
'000' INTERCOMPANY,
'00000' FUTURE_1,
'00000' FUTURE_2,
paa.default_code_comb_id

From Per_All_Assignments_f Paa,


Per_All_People_f Pap,
pay_people_Groups ppg
Where TRUNC(SYSDATE) Between Paa.Effective_Start_Date And
Paa.Effective_End_Date
and TRUNC(SYSDATE) Between Pap.Effective_Start_Date And
Pap.Effective_End_Date
and nvl(paa.people_group_id, 61) = ppg.people_group_Id
And Pap.Person_Id = Paa.Person_Id
and paa.primary_flag = 'Y'
And Pap.Current_Employee_Flag = 'Y'
-- And Pap.Employee_Number in( '0012059')
And Trunc(Sysdate) Between Pap.Effective_Start_Date And
Pap.Effective_End_Date
-- and paa.job_id is null
And Paa.Business_Group_Id = 81
and paa.organization_Id <> 81
and ppg.segment6 is not null
and ppg.segment7 is not null
and ppg.segment9 is not null
and (paa.default_code_comb_id is null or
(
-- and paa.default_code_comb_id
((select k.COMPANY
from XXLAM_HR_SYS_COST_ALLOC_KF_V k,
hr_all_organization_units hou
where hou.organization_id = paa.ORGANIZATION_ID
and k.cost_allocation_keyflex_id =
hou.cost_allocation_keyflex_id) || '-' ||
(select k.DEPARTMENT
from XXLAM_HR_SYS_COST_ALLOC_KF_V k,
hr_all_organization_units hou
where hou.organization_id = paa.ORGANIZATION_ID
and k.cost_allocation_keyflex_id =
hou.cost_allocation_keyflex_id) || '-' || '5106018' || '-'
||

ppg.SEGMENT6 || '-' || '0000' || '-' || ppg.SEGMENT7 || '-' ||


'00000000' || '-' || ppg.segment9 || '-' || '000' || '-' ||
'00000' || '-' || '00000') not in
(select g.concatenated_segments
from gl_code_combinations_kfv g
where g.code_combination_id = paa.default_code_comb_id)))
-- and pap.employee_number = '0012059'

Begin
For Rec In Get_Rec Loop
V_Error := Null;
l_total := l_total + 1;

Pp_Object_Version_Number := Rec.Object_Version_Number;
Pp_Special_Ceiling_Step_Id := Null;
Pp_People_Group_Id := Null;
Pp_Soft_Coding_Keyflex_Id := Null;
V_Group_Name := Null;
Pp_Effective_Start_Date := Null;
Pp_Effective_End_Date := Null;
V_Org_Now_No_Manager_Warning := Null;
V_Other_Manager_Warning := Null;
V_Spp_Delete_Warning := Null;
V_Entries_Changed_Warning := Null;
V_Tax_District_Changed_Warning := Null;
Pp_Concatenated_Segments := Null;
Pp_No_Managers_Warning := Null;
Pp_Other_Manager_Warning := Null;
Pp_Comment_Id := Null;
l_code_comb_id := NULL;
l_concat_seg := NULL;

Begin

-- SELECT t.job_group_id
-- into v_job_group_Id
-- from per_job_groups t
-- where t.business_group_id = p_business_group_id;
/*
If (Rec.Effective_Start_Date = P_DATE) Then
V_Mode := 'CORRECTION';
Else
V_Mode := 'UPDATE';
End If;
*/
hr_general.g_data_migrator_mode := 'Y';
commit;

V_Mode := 'CORRECTION';
l_concat_seg := rec.COMPANY_CODE || '-' || rec.DEPARTMENT_CODE || '-' ||
rec.NATURAL_ACCOUNT || '-' || rec.EXPENSE_CATEGORY || '-'
|| rec.
ACTIVITY || '-' || rec.VIRTUAL_LOCATION || '-' ||
rec.PROJECT_NUMBER || '-' || rec.VALUE_STREAM || '-' ||
rec.INTERCOMPANY || '-' || rec.FUTURE_1 || '-' ||
rec.FUTURE_2;

l_code_comb_id := fnd_flex_ext.
get_ccid(application_short_name => 'SQLGL',
key_flex_code => 'GL#',
structure_number => 101,
validation_date => SYSDATE,
concatenated_segments => l_concat_seg);

-- Dbms_Output.Put_Line(Rec.employee_number || '~' || 'Before API' ||


-- '^' || l_concat_seg || '^' ||
-- l_code_comb_id);

hr_general.g_data_migrator_mode := 'Y';
commit;
Hr_Ae_Assignment_Api.Update_Ae_Emp_Asg(P_Validate => False,
P_Effective_Date =>
TRUNC(SYSDATE),
P_Datetrack_Update_Mode => V_Mode,
P_Assignment_Id =>
Rec.Assignment_Id,
P_Object_Version_Number =>
Pp_Object_Version_Number,
p_set_of_books_id => '2021',
p_default_code_comb_id =>
l_code_comb_id,

-- P_Supervisor_Id =>
Rec.Super_Id,
-- P_Date_Probation_End =>
Rec.Prob_End_Date,
-- P_Employer =>
To_Char(Rec.Business_Group_Id),
-- P_Accommodation_Provided =>
Rec.Accomodation_Provided,
-- P_Transportation_Provided =>
Rec.Transportation_Provided,
P_Comment_Id =>
Pp_Comment_Id,
P_Soft_Coding_Keyflex_Id =>
Pp_Soft_Coding_Keyflex_Id,
P_Effective_Start_Date =>
Pp_Effective_Start_Date,
P_Effective_End_Date =>
Pp_Effective_End_Date,
P_Concatenated_Segments =>
Pp_Concatenated_Segments,
P_No_Managers_Warning =>
Pp_No_Managers_Warning,
P_Other_Manager_Warning =>
Pp_Other_Manager_Warning);

/* hr_assignment_api.update_emp_asg_criteria(p_effective_date =>
TO_DATE('01-APR-2012'),
p_datetrack_update_mode => v_mode,
p_assignment_id => rec.assignment_id,
p_validate => FALSE,
p_job_id => rec.job_id,
p_location_id => rec.loc_id,
p_organization_id => rec.org_id,

p_object_version_number => pp_object_version_number,


p_special_ceiling_step_id => pp_special_ceiling_step_id,
p_people_group_id => pp_people_group_id -- bug 2359997
,
p_soft_coding_keyflex_id => pp_soft_coding_keyflex_id -- bug 2622747
,
p_group_name => v_group_name -- out nocopy varchar2
,
p_effective_start_date => v_effective_start_date -- out
nocopy date
,
p_effective_end_date => v_effective_end_date -- out nocopy date
,
p_org_now_no_manager_warning => v_org_now_no_manager_warning -- out
nocopy boolean
,
p_other_manager_warning => v_other_manager_warning,
p_spp_delete_warning => v_spp_delete_warning,
p_entries_changed_warning => v_entries_changed_warning -- out
nocopy varchar2
,
p_tax_district_changed_warning => v_tax_district_changed_warning -- out
nocopy boolean
,
p_concatenated_segments => v_concatenated_segments -- out nocopy
varchar2 -- bug 2622747
,
p_gsp_post_process_warning => v_gsp_post_process_warning -- out
nocopy varchar2
);
*/

Commit;

-- Dbms_Output.Put_Line(Rec.employee_number);

INSERT INTO XXLEL.XXLAM_HR_SYS_ASG_PUR_COST_LOG


VALUES
(REC.ASSIGNMENT_ID,
REC.BUSINESS_GROUP_ID,
REC.ASSIGNMENT_NUMBER,
REC.OBJECT_VERSION_NUMBER,
REC.SPECIAL_CEILING_STEP_ID,
REC.EFFECTIVE_START_DATE,
REC.EMPLOYEE_NUMBER,
REC.COMPANY_CODE,
REC.DEPARTMENT_CODE,
REC.NATURAL_ACCOUNT,
REC.EXPENSE_CATEGORY,
REC.ACTIVITY,
REC.VIRTUAL_LOCATION,
REC.PROJECT_NUMBER,
REC.VALUE_STREAM,
REC.INTERCOMPANY,
REC.FUTURE_1,
REC.FUTURE_2,
REC.DEFAULT_CODE_COMB_ID,
l_code_comb_id,
SYSDATE,
'OK',
NULL);
COMMIT;

L_Cnt := L_Cnt + 1;
Exception
When Others Then
V_Error := Sqlerrm;

INSERT INTO XXLEL.XXLAM_HR_SYS_ASG_PUR_COST_LOG


VALUES
(REC.ASSIGNMENT_ID,
REC.BUSINESS_GROUP_ID,
REC.ASSIGNMENT_NUMBER,
REC.OBJECT_VERSION_NUMBER,
REC.SPECIAL_CEILING_STEP_ID,
REC.EFFECTIVE_START_DATE,
REC.EMPLOYEE_NUMBER,
REC.COMPANY_CODE,
REC.DEPARTMENT_CODE,
REC.NATURAL_ACCOUNT,
REC.EXPENSE_CATEGORY,
REC.ACTIVITY,
REC.VIRTUAL_LOCATION,
REC.PROJECT_NUMBER,
REC.VALUE_STREAM,
REC.INTERCOMPANY,
REC.FUTURE_1,
REC.FUTURE_2,
REC.DEFAULT_CODE_COMB_ID,
l_code_comb_id,
SYSDATE,
'ERROR',
V_ERROR);
COMMIT;

V_Error := Sqlerrm;
Dbms_Output.Put_Line(Rec.employee_number || '~' || V_Error || '^' ||
l_concat_seg || '^' || l_code_comb_id);
fnd_file.put_line(fnd_file.output,
Rec.employee_number || '~' || V_Error || '^' ||
l_concat_seg || '^' || l_code_comb_id);
End;
/* If (V_Error Is Not Null) Then

Rollback;

Update XXLAM_HR_UPL_SUPERVISOR_FINAL9 q
Set Processed = 'N', Error = V_Error
Where Q.employee_number = Rec.employee_number;
Commit;
Else
Update XXLAM_HR_UPL_SUPERVISOR_FINAL9 q
Set Processed = 'Y'
Where Q.employee_number = Rec.employee_number;
Commit;
End If;
*/

End Loop;

Dbms_Output.Put_Line(L_Cnt);
fnd_file.put_line(fnd_file.output,

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
fnd_file.put_line(fnd_file.output,
TO_CHAR(l_cnt) || '/' || TO_CHAR(l_total));

END CORRECT_ASG_PURCHASING_COSTING;

Procedure CORRECT_EMAIL(ERRBUF out nocopy varchar2,


RETCODE out nocopy number,
p_person_Id NUMBER,
p_email_address VARCHAR2,
p_ad_user VARCHAr2,
p_domain_name_id VARCHAR2) Is

V_Error Varchar2(1000);
L_Cnt Number := 0;

Pp_Effective_Start_Date Date;
Pp_Effective_End_Date Date;
Pp_Full_Name Varchar2(1000);
Pp_Comment_Id Number;
Pp_Name_Combination_Warning Boolean;
Pp_Assign_Payroll_Warning Boolean;
Pp_Orig_Hire_Warning Boolean;

Cursor Get_Employee Is
-- select * from xxmb_sshr_user;
Select Pap.Person_Id,
Pap.Object_Version_Number,
Pap.Employee_Number,
pap.full_name,
pap.effective_start_date,
pap.effective_End_Date,
pap.email_Address old_email_Address,
pap.attribute5 old_ad_user,
pap.attribute6 old_domain_name_id

From Per_All_People_f Pap


Where pap.person_id = p_person_id
And Trunc(Sysdate+7) Between Pap.Effective_Start_Date And
Pap.Effective_End_Date
-- and pap.employee_number='0005962'
-- And Pap.Current_Employee_Flag = 'Y'
-- And Pap.Business_Group_Id In (82, 84)
;

Begin
For Emp In Get_Employee Loop
V_Error := Null;

Pp_Effective_Start_Date := Null;
Pp_Effective_End_Date := Null;
Pp_Full_Name := Null;
Pp_Comment_Id := Null;
Pp_Name_Combination_Warning := Null;
Pp_Assign_Payroll_Warning := Null;
Pp_Orig_Hire_Warning := Null;

Begin

-- hr_general.g_data_migrator_mode := 'Y';
-- commit;

Hr_Person_Api.Update_Person(P_Validate => False,


P_Effective_Date =>
Emp.EFFECTIVE_START_DATE,
P_Datetrack_Update_Mode => 'CORRECTION',
P_Person_Id => Emp.Person_Id,
P_Object_Version_Number =>
Emp.Object_Version_Number,
P_Employee_Number =>
Emp.Employee_Number,
p_email_address => p_email_address,
p_attribute_category =>
'LAM_HR_ADDL_PERSON_DETAILS',
p_attribute5 => p_ad_user,
p_attribute6 => p_domain_name_id,
P_Effective_Start_Date =>
Pp_Effective_Start_Date,
P_Effective_End_Date =>
Pp_Effective_End_Date,
P_Full_Name => Pp_Full_Name,
P_Comment_Id => Pp_Comment_Id,
P_Name_Combination_Warning =>
Pp_Name_Combination_Warning,
P_Assign_Payroll_Warning =>
Pp_Assign_Payroll_Warning,
P_Orig_Hire_Warning =>
Pp_Orig_Hire_Warning);

L_Cnt := L_Cnt + 1;
commit;

Exception
When Others Then
V_Error := Sqlerrm;
Dbms_Output.Put_Line(Emp.Employee_number || '~' || V_Error);

End;
If (V_Error Is Not Null) Then

Rollback;

INSERT INTO XXLEL.XXLAM_HR_SYS_EMAIL_CORRECT_T


VALUES

(EMP.PERSON_ID,
EMP.EMPLOYEE_NUMBER,
EMP.FULL_NAME,
EMP.EFFECTIVE_START_DATE,
EMP.OLD_EMAIL_ADDRESS,
P_EMAIL_ADDRESS,
EMP.OLD_AD_USER,
P_AD_USER,
EMP.OLD_DOMAIN_NAME_ID,
p_domain_name_id,
Fnd_Profile.Value('USER_ID'),
SYSDATE,
'ERROR',
V_ERROR);

Commit;
fnd_file.put_line(fnd_file.output,
emp.employee_number || ' - ERROR: ' || V_ERROR);
Else
INSERT INTO XXLEL.XXLAM_HR_SYS_EMAIL_CORRECT_T
VALUES

(EMP.PERSON_ID,
EMP.EMPLOYEE_NUMBER,
EMP.FULL_NAME,
EMP.EFFECTIVE_START_DATE,
EMP.OLD_EMAIL_ADDRESS,
P_EMAIL_ADDRESS,
EMP.OLD_AD_USER,
P_AD_USER,
EMP.OLD_DOMAIN_NAME_ID,
p_domain_name_id,
Fnd_Profile.Value('USER_ID'),
SYSDATE,
'OK',
NULL);
Commit;
fnd_file.put_line(fnd_file.output, emp.employee_number || ' - OK');
End If;

End Loop;

Dbms_Output.Put_Line(L_Cnt);

End CORRECT_EMAIL;

PROCEDURE USER_CREATION_RESP_ASG(ERRBUF out nocopy varchar2,


RETCODE out nocopy number,
p_business_group_id in number) IS

/*Out Variables*/

L_CNT NUMBER := 0;
--v_loc VARCHAR2(100) := NULL;
v_user_Error VARCHAR2(1000) := NULL;
v_user_status VARCHAR2(100) := NULL;
v_resp_Error VARCHAR2(1000) := NULL;
v_resp_Error_ESS VARCHAR2(1000) := NULL;
v_resp_Error_IEX VARCHAR2(1000) := NULL;
v_resp_status VARCHAR2(100) := NULL;
v_object_version_number NUMBER := NULL;
v_PASSWORD VARCHAr2(100) := NULL;

v_user_id number;
l_conc_request_id NUMBER; --:= fnd_global.conc_request_id;

CURSOR crsr_emp IS

select pap.employee_number,
pap.full_name,
pap.email_Address,
hr_general.decode_organization(paa.organization_Id) ORG,
pap.person_id
from per_all_people_f pap,
per_all_assignments_f paa,
pay_people_groups ppg
where pap.person_Id = paa.person_id
and pap.current_employee_flag = 'Y'
and paa.primary_flag = 'Y'
and trunc(sysdate) between pap.effective_start_Date and
pap.effective_end_Date
and trunc(sysdate) between paa.effective_start_Date and
paa.effective_end_Date
and nvl(paa.people_group_id, 61) = ppg.people_group_id
and ppg.segment5 is not null
and paa.supervisor_id is not null
and pap.email_Address is not null
and paa.payroll_id in (62, 67)
and pap.person_id not in
(select fu.employee_id
from fnd_user fu
where employee_id is not null);

BEGIN
l_conc_request_id := fnd_global.conc_request_id;
FOR rec IN crsr_emp LOOP
-- BEGIN
V_user_ERROR := NULL;
v_user_status := NULL;
V_resp_ERROR := NULL;
V_resp_ERROR_ess := NULL;
V_resp_ERROR_iex := NULL;
v_resp_status := NULL;
V_user_id := NULL;
v_PASSWORD := UPPER(dbms_random.string('A', 1) || '9' ||
dbms_random.string('A', 1) || '7' ||
dbms_random.string('A', 1) || '2' ||
dbms_random.string('A', 1) || '6' ||
dbms_random.string('A', 1) || '$');

CREATE_USER(p_user_name => 'LAM' || rec.employee_number,


p_password => v_password,
p_full_name => rec.full_name,
p_email_address => rec.email_address,
p_person_id => rec.person_Id,
p_error => v_user_error);

L_CNT := L_CNT + 1;
IF (v_user_error is null) then
v_user_status := 'OK';

else
v_user_status := 'ERROR';
END IF;

fnd_file.put_line(fnd_file.output,
rec.employee_number || '~ USER CREATION ~' ||
v_user_error);

-- COMMIT;
CREATE_RESP(p_emp_no => rec.employee_number,
p_person_id => rec.person_Id,
p_resp_key => 'XXHR_ESS_LAM',
p_resp_app => 'PER',
p_error => v_resp_error_ess);

fnd_file.put_line(fnd_file.output,
rec.employee_number || '~ ESS RESPONSIBILITY ~' ||
v_resp_error_ess);

CREATE_RESP(p_emp_no => rec.employee_number,


p_person_id => rec.person_Id,
p_resp_key => 'OIE_EXPENSE_REPORT_ENTRY_LEL',
p_resp_app => 'SQLAP',
p_error => v_resp_error_iex);

fnd_file.put_line(fnd_file.output,
rec.employee_number || '~ IEX RESPONSIBILITY ~' ||
v_resp_error_iex);

L_CNT := L_CNT + 1;

-- COMMIT;
v_resp_error := v_resp_error_ess || v_resp_error_iex;

IF (v_resp_error is null) then


v_resp_status := 'OK';
else
v_resp_status := 'ERROR';
END IF;

BEGIN
select user_id
into v_user_id
from fnd_user u
where u.user_name = 'LAM' || rec.employee_number;
EXCEPTION
WHEN OTHERS THEN
v_user_id := NULL;
END;

BEGIN
INSERT INTO XXLEL.XXLAM_HR_SYS_USER_RESP_T T
VALUES
(l_conc_request_id,
'LAM' || rec.employee_number,
rec.full_name,
rec.email_Address,
NULL,
rec.person_id,
v_user_id,
sysdate,
v_user_status,
v_user_Error,
v_resp_status,
v_resp_error);

commit;
EXCEPTION
WHEN OTHERS THEN
fnd_file.put_line(fnd_file.output,
rec.employee_number || '~ TABLE ~' || SQLERRM);
END;

IF (v_user_status = 'OK' and v_resp_status = 'OK') THEN


xxlam_hr_sys_alerts_pkg.new_user_alert('LAM' ||
rec.employee_number,
v_PASSWORD,
rec.email_address);
END IF;

END LOOP;

fnd_file.put_line(fnd_file.output, 'TOTAL: ' || L_CNT);


END USER_CREATION_RESP_ASG;

PROCEDURE CREATE_USER(p_user_name IN VARCHAR2,


p_password IN VARCHAR2,
p_full_name VARCHAR2,
p_email_address VARCHAR2 DEFAULT NULL,
p_person_id IN NUMBER,
p_error OUT VARCHAR2) IS
l_count NUMBER := 0;

BEGIN
SELECT COUNT(1)
INTO l_count
FROM fnd_user
WHERE user_name = p_user_name;
p_error := NULL;

IF l_count < 1 THEN


BEGIN
Fnd_User_Pkg.createuser(x_user_name => p_user_name,
x_owner => 'SEED',
x_unencrypted_password => p_password,
x_description => p_full_name,
x_employee_id => p_person_id,
x_password_lifespan_days => 45,
x_start_date => TRUNC(SYSDATE),
x_end_date => null,
x_email_address => p_email_address);

commit;
-- dbms_output.put_line('Created User for Employee' || p_user_Name);

EXCEPTION
WHEN OTHERS THEN
p_error := SQLERRM;
ROLLBACK;

END;
ELSE
p_error := 'USER EXISTS';
END IF;

RETURN;
--
END CREATE_USER;

PROCEDURE CREATE_RESP(p_emp_no IN VARCHAR2,


p_person_id IN NUMBER,
p_resp_key IN VARCHAR2,
p_resp_app VARCHAR2,
p_error OUT varchar2) IS

l_count NUMBER := 0;

BEGIN
p_error := NULL;
SELECT COUNT(1)
INTO l_count
FROM fnd_user fu,
fnd_user_resp_groups_direct furgd,
fnd_responsibility fr
WHERE fu.user_id = furgd.user_id
AND furgd.responsibility_id = fr.responsibility_id
AND fr.responsibility_key = p_resp_key
AND fu.employee_id = p_person_id;
IF l_count < 1 THEN
Fnd_User_Pkg.addresp(username => 'LAM' || p_emp_no,
resp_app => p_resp_app,
resp_key => p_resp_key,
security_group => 'STANDARD',
description => 'CR-137',
start_date => TRUNC(SYSDATE),
end_date => NULL);

commit;
ELSE
p_error := 'RESPONSIBILITY EXISTS';
END IF;
EXCEPTION
WHEN OTHERS THEN
p_error := SQLERRM;
ROLLBACK;

-- END;

--commit;
return;
END CREATE_RESP;

Procedure DECIMAL_CARRYOVER(ERRBUF out nocopy varchar2,


RETCODE out nocopy number,
p_DATE_CHAR IN VARCHAR2) Is

V_Error Varchar2(1000);
L_Cnt Number := 0;
p_DATE DATE :=FND_DATE.CANONICAL_TO_DATE(p_DATE_CHAR);

V_Object_Version_Number Number;
-- v_job_definition_id NUMBER;
-- v_name VARCHAR2(1000);
Pp_Effective_Start_Date Date := Null;
Pp_Effective_End_Date Date := Null;
Pp_Delete_Warning Boolean := Null;
v_dec NUMBER := 0;
pp_element_entry_id NUMBER := NULL;
pp_object_version_number NUMBER := NULL;
Pp_CREATE_Warning Boolean := Null;
v_element_link_Id NUMBER := NULL;

Cursor DEL_Rec Is
Select Distinct paa.assignment_number,
paa.assignment_id,
paa.person_Id,
petf.element_name,
Pee.Element_Entry_Id,
Pee.Object_Version_Number,
Pee.Effective_Start_Date,
Pee.Effective_End_Date
From Pay_Element_Entries_f Pee,
Pay_Element_Types_f Petf,
Per_All_Assignments_f Paa
Where Paa.Assignment_Id = Pee.Assignment_Id
And P_DATE Between Paa.Effective_Start_Date And
Paa.Effective_End_Date
And P_DATE Between Pee.Effective_Start_Date And
Pee.Effective_End_Date
And Pee.Element_Type_Id = Petf.Element_Type_Id
And Petf.Element_Name =
'Admin Annual Leave Accrual Plan Decimal Carryover'
And Paa.Business_Group_Id = 81

Cursor NEW_Rec Is
select PAA.ASSIGNMENT_ID,
PAA.ASSIGNMENT_NUMBER,
PAA.PAYROLL_ID,
per_Utility_Functions.Get_Net_Accrual(P_Assignment_Id =>
paa.assignment_id,
P_Payroll_Id =>
paa.Payroll_Id,
P_Business_Group_Id => 81,
P_Assignment_Action_Id =>
NULL,
P_Calculation_Date =>
p_DATE - 1,
P_Plan_Id => 61,
P_Accrual_Start_Date =>
Null,
P_Accrual_Latest_Balance =>
Null) PREV_ACCR

from per_all_assignments_F paa,


per_periods_of_Service pps,
pay_element_entries_f pee
where paa.primary_flag = 'Y'
and paa.person_Id = pps.person_Id
and pee.assignment_Id = paa.assignment_Id
AND PEE.ELEMENT_TYPE_ID = 298
and P_DATE BETWEEN PPS.DATE_START AND
NVL(PPS.ACTUAL_TERMINATION_DATE, TO_DATE('31-DEC-4712'))
and P_DATE BETWEEN PAA.EFFECTIVE_START_DATE AND
PAA.EFFECTIVE_END_DATE
and P_DATE BETWEEN PEE.EFFECTIVE_START_DATE AND
PEE.EFFECTIVE_END_DATE
AND PPS.DATE_START < add_months(p_date, -12)
and paa.payroll_Id <>67
AND PAA.ASSIGNMENT_NUMBER not in ('0009659')
;

Begin
For DRec In Del_Rec Loop

V_Error := Null;

Pp_Effective_Start_Date := Null;
Pp_Effective_End_Date := Null;
Pp_Delete_Warning := Null;

If (V_Error Is Null) Then


Begin

Pay_Element_Entry_Api.Delete_Element_Entry(P_Validate =>
False,
P_Datetrack_Delete_Mode =>
'ZAP',
P_Effective_Date =>
DRec.Effective_Start_Date,
P_Element_Entry_Id =>
DRec.Element_Entry_Id,
P_Object_Version_Number =>
DRec.Object_Version_Number,
P_Effective_Start_Date =>
Pp_Effective_Start_Date,
P_Effective_End_Date =>
Pp_Effective_End_Date,
P_Delete_Warning =>
Pp_Delete_Warning);

Commit;

-- DBMS_OUTPUT.PUT_LINE(REC.REC_NO || '~' || PP_DELETE_WARNING);

L_Cnt := L_Cnt + 1;
Exception
When Others Then
V_Error := Sqlerrm;

fnd_file.put_line(fnd_file.output,
drec.assignment_number ||
'- DELETION ERROR - ' || V_ERROR);
DBMS_OUTPUT.put_line(drec.assignment_number ||
'- DELETION ERROR - ' || V_ERROR);

End;
End If;

End Loop;

fnd_file.put_line(fnd_file.output,
'------------- DELETION TOTAL : ' || l_cnt ||
' ------------');

DBMS_OUTPUT.put_line('------------- DELETION TOTAL : ' || l_cnt ||


' ------------');

L_Cnt := 0;
For NRec In New_Rec Loop

IF (NREC.PREV_ACCR > 0 AND


NREC.PREV_ACCR - FLOOR(NREC.PREV_ACCR) <> 0) THEN
v_dec := NREC.PREV_ACCR - FLOOR(NREC.PREV_ACCR);
V_Error := Null;

Pp_Effective_Start_Date := Null;
Pp_Effective_End_Date := Null;
pp_element_entry_id := NULL;
pp_object_version_number := NULL;
Pp_CREATE_Warning := Null;

BEGIN
SELECT pel.element_link_Id
into v_element_link_Id
from pay_Element_links_f pel
where pel.element_type_id = 536
and pel.payroll_id = NREC.PAYROLL_ID;
Exception
When Others Then
V_Error := Sqlerrm;

fnd_file.put_line(fnd_file.output,
nrec.assignment_number || '- LINK ERROR - ' ||
V_ERROR);

DBMS_OUTPUT.put_line(nrec.assignment_number ||
'- LINK ERROR - ' || V_ERROR);

End;
If (V_Error Is Null) Then
Begin

Pay_Element_Entry_Api.create_element_entry(p_validate =>
FALSE,
p_effective_date =>
P_DATE,
p_business_group_id =>
81,
p_assignment_id =>
NREC.ASSIGNMENT_ID,
p_element_link_id =>
v_element_link_Id,
p_entry_type =>
'E',
p_input_value_id1 =>
2124,
p_input_value_id2 =>
2125,
p_entry_value1 =>
TO_CHAR(P_DATE,

'DD-MON-YYYY'),
p_entry_value2 =>
v_dec,
p_effective_start_date =>
pp_effective_Start_date,
p_effective_end_date =>
Pp_Effective_End_Date,
p_element_entry_id =>
pp_element_entry_id,
p_object_version_number =>
pp_object_version_number,
p_create_warning =>
pp_create_warning);

Commit;

-- DBMS_OUTPUT.PUT_LINE(REC.REC_NO || '~' || PP_DELETE_WARNING);

L_Cnt := L_Cnt + 1;
Exception
When Others Then
V_Error := Sqlerrm;
fnd_file.put_line(fnd_file.output,
nrec.assignment_number ||
'- CREATION ERROR - ' || V_ERROR);

DBMS_OUTPUT.put_line(nrec.assignment_number ||
'- CREATION ERROR - ' || V_ERROR);
End;
End If;
END IF;

End Loop;

fnd_file.put_line(fnd_file.output,
'------------- CREATION TOTAL : ' || l_cnt ||
' ------------');

DBMS_OUTPUT.put_line('------------- CREATION TOTAL : ' || l_cnt ||


' ------------');

COMMIT;
End DECIMAL_CARRYOVER;

PROCEDURE XXLEL_UPDATE_IT_TASKS(errbuf OUT varchar2, retcode OUT varchar2)


IS
L_COUNT NUMBER;
LINES_COUNT NUMBER;
l_Approval_Status Varchar2(30);
l_checklist_h_id number;
l_checklist_l_id number;
l_checklist_d_id number;

Cursor c_update_it_tasks
IS
select L.TASK_CATEGORY_CODE LINE_TASK_CATEGORY_CODE,h.person_id,
hr_general.decode_lookup('LAM_HR_SYS_CHECKLIST_TASK_CAT',
l.task_category_code)
LINE_TASK_CATEGORY_NAME,
d.task_due_date,
pps.actual_Termination_Date,

hr_general.DECODE_FND_COMM_LOOKUP('LEAV_REAS',
pps.leaving_reason)
Leaving_Reason,

/*decode( UPPER(hr_general.DECODE_FND_COMM_LOOKUP('LEAV_REAS',

pps.leaving_reason)),'RESIGNATION',greatest(pps.actual_Termination_Date,d.task_due_
Date),d.task_due_Date)*/
d.task_due_Date
NEW_REVOKE_ACCESS_DATE,
L.REMARKS LINE_REMARKS,
L.APPROVAL_STATUS LINE_APPROVAL_STATUS,
L.CREATED_BY LINE_CREATED_BY,
L.CREATION_DATE LINE_CREATION_DATE,
L.LAST_UPDATED_BY LINE_LAST_UPDATED_BY,
L.LAST_UPDATE_DATE LINE_LAST_UPDATE_DATE,
(select t.employee_number from per_all_people_f t
where t.person_Id = d.owner_person_Id and trunc(sysdate) between
t.effective_start_date and t.effective_end_date) owner_employee_number,
l.checklist_l_id,l.checklist_h_id,
d.CHECKLIST_D_ID
from xxlel_per_checklist_d d, xxlel_per_checklist_l l,xxlel_per_checklist_h
h,per_periods_of_service pps
where
d.checklist_h_id = h.checklist_h_id
and
d.checklist_l_id = l.checklist_l_id
and
h.person_Id = pps.person_Id
and pps.date_start = (select max(t.date_Start) from per_periods_of_service t
where t.person_Id = pps.person_Id and t.actual_termination_Date is not null)
and nvl(d.approval_status, 'Pending') = 'Pending'
and h.checklist_type = 'EXIT'
and l.task_category_code = 'IT'
and d.task_due_date <= TRUNC(SYSDATE)
order by d.task_due_date desc, L.TASK_CATEGORY_CODE;
rec_update_it_tasks c_update_it_tasks%ROWTYPE;
BEGIN
OPEN c_update_it_tasks;
LOOP
fetch c_update_it_tasks into rec_update_it_tasks;
exit when c_update_it_tasks%NotFound;

---====== Update Checklist Detail Table

BEGIN
Update XXLEL_PER_CHECKLIST_D
set approval_status = 'Complete',TASK_COMPLETION_DATE = sysdate,COMMENTS_INTERNAL =
'System Timeout, Revoke Access Immediately.',REVOKE_ACCESS_DATE =
rec_update_it_tasks.NEW_REVOKE_ACCESS_DATE
where CHECKLIST_H_ID = rec_update_it_tasks.checklist_h_id
AND CHECKLIST_L_ID = rec_update_it_tasks.checklist_l_id AND CHECKLIST_D_ID =
rec_update_it_tasks.CHECKLIST_D_ID;

commit;
END;

---====== Update Checklist Line Table

BEGIN
Update XXLEL_PER_CHECKLIST_L
set approval_status = 'Complete',TASK_COMPLETION_DATE = sysdate,COMMENTS_INTERNAL =
'System Timeout, Revoke Access Immediately'
where CHECKLIST_H_ID = rec_update_it_tasks.checklist_h_id
AND CHECKLIST_L_ID = rec_update_it_tasks.checklist_l_id;
commit;
END;
---====== Update Checklist Header Table

SELECT COUNT(*) INTO L_COUNT FROM XXLEL_PER_CHECKLIST_L WHERE CHECKLIST_H_ID =


rec_update_it_tasks.checklist_h_id;

SELECT COUNT(*) INTO LINES_COUNT FROM XXLEL_PER_CHECKLIST_L WHERE CHECKLIST_H_ID =


rec_update_it_tasks.checklist_h_id AND APPROVAL_STATUS IN ('Complete','Not
Required');

IF (L_COUNT = LINES_COUNT) THEN

BEGIN
UPDATE XXLEL_PER_CHECKLIST_H
SET APPROVAL_STATUS='Complete'
WHERE CHECKLIST_H_ID = rec_update_it_tasks.checklist_h_id
AND PERSON_ID = rec_update_it_tasks.person_id;
END;
END IF;
COMMIT;
END LOOP;
close c_update_it_tasks;
commit;

--Return 0 for successful completion.

errbuf := '';

retcode := '0';

exception

when others then

errbuf := sqlerrm;

retcode := '2';

END XXLEL_UPDATE_IT_TASKS;

FUNCTION GET_MOBILE_NUMBER(P_EMPLOYEE_NUMBER IN VARCHAR2) RETURN VARCHAR2


IS

V_MOBILE VARCHAR2(100) := NULL;


V_KALLGAUGE_MOBILE VARCHAR2(100) := NULL;
V_HRMS_MOBILE VARCHAR2(100) := NULL;

BEGIN

BEGIN
SELECT (select max(k.mobile_number)
from xxstage.XXSTAGE_EMP_OFFICIAL_MOBILE_T k
where k.employee_number = pap.employee_number
and k.mobile_number like '05%') KALLGAUGE_MOBILE,
(select max(replace(replace(p.phone_number, '-', ''), ' ', ''))
from per_phones p
where p.parent_table = 'PER_ALL_PEOPLE_F'
and p.parent_Id = pap.person_Id
and p.phone_type = 'M'
and trunc(sysdate) between
NVL(p.date_from, TO_DATE('01-JAN-1950')) and
NVL(p.date_to, TO_DATE('31-DEC-4712'))
and (replace(replace(p.phone_number, '-', ''), ' ', '') like
'05%' or
replace(replace(p.phone_number, '-', ''), ' ', '') like
'+9715%' or
replace(replace(p.phone_number, '-', ''), ' ', '') like
'009715%' or
replace(replace(p.phone_number, '-', ''), ' ', '') like
'9715%')) HRMS_MOBILE
INTO V_KALLGAUGE_MOBILE, V_HRMS_MOBILE
from per_all_people_f pap
where trunc(sysdate) between pap.effective_Start_date and
pap.effective_End_Date

and pap.current_employee_flag = 'Y'


and pap.employee_number = p_EMPLOYEE_NUMBER;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;

IF (V_KALLGAUGE_MOBILE IS NOT NULL) THEN


V_MOBILE := V_KALLGAUGE_MOBILE;
ELSIF (V_HRMS_MOBILE IS NOT NULL) THEN
IF (V_HRMS_MOBILE LIKE '05%') THEN
V_HRMS_MOBILE := v_HRMS_MOBILE;
ELSIF (V_HRMS_MOBILE LIKE '+9715%') THEN
V_HRMS_MOBILE := '0' || SUBSTR(V_HRMS_MOBILE, 5, 30);
ELSIF (V_HRMS_MOBILE LIKE '009715%') THEN
V_HRMS_MOBILE := '0' || SUBSTR(V_HRMS_MOBILE, 6, 30);
ELSIF (V_HRMS_MOBILE LIKE '9715%') THEN
V_HRMS_MOBILE := '0' || SUBSTR(V_HRMS_MOBILE, 4, 30);
END IF;

IF(LENGTH(V_HRMS_MOBILE) = 10) THEN


V_MOBILE:= V_HRMS_MOBILE;
END IF;

ELSE
V_MOBILE := NULL;
END IF;

--DBMS_OUTPUT.PUT_LINE(V_MOBILE || '~' || V_KALLGAUGE_MOBILE || '~' ||


-- V_HRMS_MOBILE);
RETURN V_MOBILE;
END GET_MOBILE_NUMBER;

end XXLAM_HR_SYS_SCHED_PROC_PKG;
/

============================================================================