0% found this document useful (0 votes)
312 views

API Code For FA

This script uses HRMS APIs to end date or delete an element entry. It retrieves the element entry ID, object version number, and assignment ID for a given employee number and element name. It then calls the hr_element_entry_api to end date or delete the element entry. Any errors are caught and rolled back.

Uploaded by

krishna
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
312 views

API Code For FA

This script uses HRMS APIs to end date or delete an element entry. It retrieves the element entry ID, object version number, and assignment ID for a given employee number and element name. It then calls the hr_element_entry_api to end date or delete the element entry. Any errors are caught and rolled back.

Uploaded by

krishna
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 21

Grade Rate API(s)

Use hr_grade_rate_value_api API to create/update/delete grade rate values


Ex: Update grade rate
-DECLARE
CURSOR get_details
IS
select pgr.effective_start_date
,pgr.effective_end_date
,pgr.object_version_number
,pgr.value
,pgr.maximum
,pgr.mid_value
,pgr.minimum
,pgr.sequence
,pgr.grade_rule_id
,pgr.currency_code
from per_grades pg,
pay_grade_rules_f pgr
where pg.name = 'AK General|12|Standard XX'
and pgr.grade_or_spinal_point_id = pg.grade_id
and trunc(sysdate) between pgr.effective_start_date and pgr.effective_end_date
;
l_effective_start_date DATE := NULL;
l_effective_end_date
DATE := NULL;
l_grade_rule_id
NUMBER := NULL;
l_object_version_number NUMBER := NULL;
l_err_msg
VARCHAR2 (500) := NULL;
l_value
NUMBER;
l_mid_value
NUMBER;
l_max_vlaue
NUMBER;
l_mim_value
NUMBER;
BEGIN
FOR i IN get_details LOOP
-l_object_version_number := i.object_version_number;
l_max_vlaue
:= 40000;
l_mim_value
:= 30000;
l_mid_value
:= 35000;
l_value
:= 35000;
-BEGIN
hr_grade_rate_value_api.update_grade_rate_value (
p_validate
=> FALSE,
p_grade_rule_id
=> i.grade_rule_id,
p_effective_date
=> TO_DATE ('10-MAY-2014', 'DD-MON-YYYY'),
p_datetrack_update_mode => 'UPDATE',--'CORRECTION',
p_currency_code
=> i.currency_code,
p_maximum
=> l_max_vlaue,
p_mid_value
=> l_mid_value,
p_minimum
=> l_mim_value,

p_value
=> l_value,
p_sequence
=> i.sequence,
p_object_version_number => l_object_version_number,
p_effective_start_date => l_effective_start_date,
p_effective_end_date
=> l_effective_end_date
);
COMMIT;
DBMS_OUTPUT.put_line ('Grate Rate has been Updated: ' || i.grade_rule_id );
EXCEPTION
WHEN OTHERS THEN
l_err_msg := SQLERRM;
DBMS_OUTPUT.put_line ('Inner Exception: ' || l_err_msg);
END;
END LOOP;
-EXCEPTION
WHEN OTHERS THEN
l_err_msg := SQLERRM;
DBMS_OUTPUT.put_line ('Main Exception: ' || l_err_msg);
END;
-Posted by Abhay Kumar at 3:41 AM No comments:
Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest
Labels: API Scripts, Handy Scripts, HRMS

Tuesday, January 5, 2016

Configuration Values - APIs


-- Global and localized configuration settings provide the appropriate defaults for business groups
-- Business Rules are held in pqp_configuration_values table
-- HRMS > Other Definitions > Configuration Values
-- Here I am updating a configuration value
declare
-ln_con_val_id number;
ln_bg
number;
ln_ovn
number;
lc_cat
varchar2(200);
lc_info
varchar2(200);
-begin
-select pcv.PCV_INFORMATION_CATEGORY
,pcv.PCV_INFORMATION2
,pcv.business_group_id
,pcv.configuration_value_id
,pcv.object_version_number
into lc_cat
,lc_info
,ln_bg
,ln_con_val_id
,ln_ovn
from pqp_configuration_types pct
,pqp_configuration_modules pcm
,pqp_configuration_values pcv
where 1=1

and pct.module_id = pcm.module_id


and pcm.module_name = 'Assignment Budget Value Maintenance'
and pct.description = 'Maintenance Configuration'
and pcv.pcv_information_category = pct.configuration_type
;
dbms_output.put_line('Before: lc_cat: '||lc_cat||' lc_info: '||lc_info||' in_ovn: '|| ln_ovn);
-pqp_pcv_api.update_configuration_value(p_validate
=> false
,p_effective_date
=> sysdate
,p_business_group_id
=> ln_bg
,p_configuration_value_id
=> ln_con_val_id
,p_pcv_information_category
=> lc_cat
,p_pcv_information2
=> 'Y'
,p_object_version_number
=> ln_ovn);
dbms_output.put_line('Configuration Value Updated');
commit;
-exception
when others then
dbms_output.put_line('Error : '||sqlerrm);
rollback;
end;
-Posted by Abhay Kumar at 6:00 AM No comments:
Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest
Labels: API Scripts, Handy Scripts, HRMS

Tuesday, November 3, 2015

Create Payment Method - HRMS APIs


---Possible Error: ORA-20001: HR_7348_ASSIGNMENT_INVALID
--Check the date format of effective_date
-declare
ln_method_id
pay_personal_payment_methods_f.personal_payment_method_id%type;
ln_ext_acc_id
pay_external_accounts.external_account_id%type;
ln_obj_ver_num
pay_personal_payment_methods_f.object_version_number%type;
lc_org_pay_method pay_org_payment_methods_f_tl.org_payment_method_name%type;
ld_eff_date
date := to_date('01-OCT-2011','DD-MON-YYYY');
ld_eff_start_date date;
ld_eff_end_date
date;
ln_comment_id
number;
ln_assignment_id number;
ln_org_pay_method_id number;
lc_employee_num
varchar2(20) := '223344';
lc_territory_code varchar2(60) := 'GB';
lc_bank_name
varchar2(60) := 'XX';
lc_bank_branch
varchar2(60) ;
lc_sort_code
varchar2(60) := '900011';
lc_account_num
varchar2(60) := '91889999';

lc_account_name
varchar2(60) := 'Mr A Kumar' ;
lc_account_type
varchar2(60) := '0' ;
lc_bld_s_account_num varchar2(60) := null;
lc_branch_loc
varchar2(60) ;
begin
-select assignment_id
,pay.payroll_name
into ln_assignment_id
,lc_org_pay_method
from per_all_assignments_f ass
,per_all_people_f
per
,pay_all_payrolls_f pay
where ass.person_id = per.person_id
and per.employee_number = lc_employee_num
and trunc(sysdate) between ass.effective_start_date and ass.effective_end_date
and trunc(sysdate) between per.effective_start_date and per.effective_end_date
and pay.payroll_id = ass.payroll_id;
select org_payment_method_id
into ln_org_pay_method_id
from pay_org_payment_methods_f_tl
where org_payment_method_name = lc_org_pay_method
and language = 'US';
-- Create Employee Payment Method
-- -------------------------------------------------hr_personal_pay_method_api.create_personal_pay_method
(-- Input Parameters
p_effective_date
=> ld_eff_date,
p_assignment_id
=> ln_assignment_id,
p_org_payment_method_id
=> ln_org_pay_method_id,
p_priority
=> 1,
p_percentage
=> 100,
p_territory_code
=> lc_territory_code,
p_segment1
=> lc_bank_name,
p_segment2
=> lc_bank_branch,
p_segment3
=> lc_sort_code,
p_segment4
=> lc_account_num,
p_segment5
=> lc_account_name,
p_segment6
=> lc_account_type,
p_segment7
=> lc_bld_s_account_num,
p_segment8
=> lc_branch_loc,
-- Output parameters
p_personal_payment_method_id
=> ln_method_id,
p_external_account_id
=> ln_ext_acc_id,
p_object_version_number
=> ln_obj_ver_num,
p_effective_start_date
=> ld_eff_start_date,
p_effective_end_date
=> ld_eff_end_date,
p_comment_id
=> ln_comment_id
);
commit;
dbms_output.put_line('Done');
--

exception
when others then
dbms_output.put_line('Error: '||sqlerrm);
rollback;
end;
-Posted by Abhay Kumar at 3:17 AM No comments:
Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest
Labels: API Scripts, HRMS

Create/Update Person extra info - HRMS APIs


-declare
-cursor cur_eit_details
is
select per.person_id
,'EIT_VALUE' eit_val
,to_char(sysdate,'YYYY/MM/DD HH24:MI:SS') begin_date
,null end_date
from per_all_people_f per
where per.employee_number = '123456'
and trunc(sysdate) between per.effective_start_date and per.effective_end_date
;
lc_information_type varchar2(20) := 'XXAK_TEST_EIT';
lc_information_cat varchar2(20) := 'XXAK_TEST_EIT';
ln_per_extra_info_id number;
ln_ovn_pei
number;
-begin
--- Please use your own business logic, this is a basic case
for rec_eit_details in cur_eit_details loop
-begin
-select ppei.person_extra_info_id
,ppei.object_version_number
into ln_per_extra_info_id
,ln_ovn_pei
from per_people_extra_info
ppei
where ppei.person_id
= rec_eit_details.person_id
and ppei.information_type
= lc_information_type
and ppei.pei_information_category = lc_information_cat
;
-begin
-- UPDATE
hr_person_extra_info_api.update_person_extra_info
( p_validate
=> false
, p_person_extra_info_id
=> ln_per_extra_info_id
-- In / Out
, p_object_version_number
=> ln_ovn_pei
-- In
, p_pei_information_category => lc_information_cat
, p_pei_information1
=> rec_eit_details.eit_val

, p_pei_information2
=> rec_eit_details.begin_date
, p_pei_information3
=> rec_eit_details.end_date
);
dbms_output.put_line('EIT Updated ');
commit;
-exception
when others then
dbms_output.put_line('Update Failed '||sqlerrm);
rollback;
end;
-exception
when no_data_found then
-begin
-- CREATE
ln_per_extra_info_id := null;
ln_ovn_pei
:= null;
-hr_person_extra_info_api.create_person_extra_info
( p_validate
=> false
, p_person_id
=> rec_eit_details.person_id
, p_information_type
=> lc_information_type
, p_pei_information_category => lc_information_cat
, p_pei_information1
=> rec_eit_details.eit_val
, p_pei_information2
=> rec_eit_details.begin_date
, p_pei_information3
=> rec_eit_details.end_date
-- Out
, p_person_extra_info_id
=> ln_per_extra_info_id
, p_object_version_number => ln_ovn_pei
);
-dbms_output.put_line('EIT Created '||ln_per_extra_info_id);
commit;
-exception
when others then
dbms_output.put_line('Creation Failed '||sqlerrm);
rollback;
-end;
-when others then
dbms_output.put_line('Error: Selecting Person Extra Info '||sqlerrm);
end;
-end loop;
-dbms_output.put_line('Done!');
-exception
when others then
dbms_output.put_line('Error: '||sqlerrm);
rollback;

end;
-Posted by Abhay Kumar at 3:15 AM No comments:
Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest
Labels: API Scripts, HRMS

Wednesday, July 29, 2015

Delete/End Date Element Entry - HRMS APIs


-declare
-ld_effective_start_date
date;
ld_effective_end_date
date;
lb_delete_warning
boolean;
ln_element_entry_id
number;
ln_object_version_number number;
ln_assin_id
number;
-lc_element_name
pay_element_types_f.element_name%type := 'AK Element';
lc_emp_num
per_all_people_f.employee_number := '123425';
begin
-select pee.element_entry_id
,pee.object_version_number
,paf.assignment_id
into ln_element_entry_id
,ln_object_version_number
,ln_assin_id
from per_all_people_f
per
,per_all_assignments_f paf
,pay_element_entries_f pee
,pay_element_types_f_tl petl
,pay_element_types_f pet
where per.employee_number = lc_emp_num
and trunc(sysdate) between per.effective_start_date and per.effective_end_date
and paf.person_id
= per.person_id
and trunc(sysdate) between paf.effective_start_date and paf.effective_end_date
and pee.assignment_id = paf.assignment_id
and pee.element_type_id = pet.element_type_id
and trunc(sysdate) between pee.effective_start_date and pee.effective_end_date
and petl.element_name = lc_element_name
and petl.language
= 'US'
and pet.element_type_id = petl.element_type_id;
/* Date Track modes
DELETE
>> end date element entry
DELETE_NEXT_CHANGE >> delete next changes
FUTURE_CHANGE
>> delete future changes
ZAP
>> completely remove element entry from the database
*/
pay_element_entry_api.delete_element_entry
(p_validate
=> false
,p_datetrack_delete_mode
=> 'DELETE'

,p_effective_date
=> trunc(sysdate)
,p_element_entry_id
=> ln_element_entry_id
,p_object_version_number
=> ln_object_version_number
,p_effective_start_date
=> ld_effective_start_date
,p_effective_end_date
=> ld_effective_end_date
,p_delete_warning
=> lb_delete_warning
);
-commit;
-exception
when others then
dbms_output.put_line('Error: '||sqlerrm);
rollback;
end;
Posted by Abhay Kumar at 6:42 AM No comments:
Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest
Labels: API Scripts, Handy Scripts, HRMS

Update Element Entry - HRMS APIs


-declare
-cursor cur_input_name(c_ele_name varchar2)
is
select piv.display_sequence
,piv.name
,piv.element_type_id
from pay_element_types_f_tl petl
,pay_element_types_f pet
,pay_input_values_f piv
where petl.element_name = c_ele_name
and petl.language
= 'US'
and pet.element_type_id = petl.element_type_id
and piv.element_type_id = pet.element_type_id
order by piv.display_sequence;
-ld_effective_start_date date;
ld_effective_end_date date;
ln_object_version_number pay_element_entries_f.object_version_number %type;
lb_update_warning
boolean;
ln_screen_entry_value pay_element_entry_values_f.screen_entry_value%type;
ln_element_type_id
pay_element_types_f.element_type_id%type;
ln_input_value_id1
pay_input_values_f.input_value_id%type;
ln_input_value_id2
pay_input_values_f.input_value_id%type;
ln_input_value_id
pay_input_values_f.input_value_id%type;
-- DT API Out Variables
lb_correction
boolean;
lb_update
boolean;
lb_upover
boolean;
lb_upchin
boolean;
-lc_element_name
pay_element_types_f.element_name%type := 'AK Element';
lc_emp_num
per_all_people_f.employee_number := '123425';

lc_dt_mode

varchar2(20);

begin
-savepoint sv_update;
-select pee.element_entry_id
,pee.object_version_number
into ln_element_entry_id
,ln_object_version_number
from per_all_people_f
per
,per_all_assignments_f paf
,pay_element_entries_f pee
,pay_element_types_f_tl petl
,pay_element_types_f pet
where per.employee_number = lc_emp_num
and trunc(sysdate) between per.effective_start_date and per.effective_end_date
and paf.person_id
= per.person_id
and trunc(sysdate) between paf.effective_start_date and paf.effective_end_date
and pee.assignment_id = paf.assignment_id
and pee.element_type_id = pet.element_type_id
and trunc(sysdate) between pee.effective_start_date and pee.effective_end_date
and petl.element_name = lc_element_name
and petl.language
= 'US'
and pet.element_type_id = petl.element_type_id;
--Determine the Date Track Mode for Update..
dt_api.find_dt_upd_modes
( p_effective_date
=> trunc(sysdate)
, p_base_table_name
=> 'PAY_ELEMENT_ENTRIES_F'
, p_base_key_column
=> 'ELEMENT_ENTRY_ID'
, p_base_key_value
=> ln_element_entry_id
, p_correction
=> lb_correction
, p_update
=> lb_update
, p_update_override
=> lb_upover
, p_update_change_insert => lb_upchin
);
if lb_upover or lb_upchin then
lc_dt_mode := 'UPDATE_OVERRIDE';
--elsif lb_upchin then
-- p_dt_mode := 'UPDATE_CHANGE_INSERT';
elsif lb_update then
lc_dt_mode := 'UPDATE';
elsif lb_correction then
lc_dt_mode := 'CORRECTION';
end if;
-- Get input value ids
for rec_input_name in cur_input_name(lc_element_name) loop
select piv.input_value_id
into ln_input_value_id

from pay_input_values_f piv


where piv.element_type_id = rec_input_name.element_type_id
and piv.name
= rec_input_name.name
;
if rec_input_name.display_sequence = 1 then -- AK Value
p_input_value_id1 := ln_input_value_id;
elsif rec_input_name.display_sequence = 2 then -- Employee Rate
p_input_value_id2 := ln_input_value_id;
end if;
end loop;
-- Update Element Entry
-- -----------------------------pay_element_entry_api.update_element_entry
( -- Input data elements
-- ----------------------------p_validate
=> false, --true
p_datetrack_update_mode
=> lc_dt_mode,
p_effective_date => to_date('25-JUN-2012','DD-MON-YYYY'),
p_business_group_id => fnd_profile.value('PER_BUSINESS_GROUP_ID'),
p_element_entry_id
=> ln_element_entry_id,
p_object_version_number
=> ln_object_version_number,
p_input_value_id1
=> ln_input_value_id1,
p_entry_value1
=> null,
p_input_value_id2
=> ln_input_value_id2,
p_entry_value2
=> 10,
-- Output data elements
-- -------------------------------p_effective_start_date
=> ld_effective_start_date,
p_effective_end_date
=> ld_effective_end_date,
p_update_warning
=> lb_update_warning
);
dbms_output.put_line( ' API: pay_element_entry_api.update_element_entry successfull - Element Entry
Id: ' );
-commit;
-exception
when others then
dbms_output.put_line('Error: '||sqlerrm);
rollback to sv_update;
end;
-Posted by Abhay Kumar at 6:40 AM No comments:
Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest
Labels: API Scripts, Handy Scripts, HRMS

Thursday, July 23, 2015

Create Element Entry - HRMS APIs


-declare
-cursor cur_input_name (p_ele_name varchar2)
is
select piv.display_sequence
,piv.name
,piv.element_type_id
from pay_element_types_f_tl petl
,pay_element_types_f pet
,pay_input_values_f piv
where petl.element_name = p_ele_name
and petl.language
= 'US'
and pet.element_type_id = petl.element_type_id
and piv.element_type_id = pet.element_type_id
order by piv.display_sequence;
-ln_element_link_id
pay_element_links_f.element_link_id%type;
ld_effective_start_date
date;
ld_effective_end_date
date;
ln_element_entry_id
pay_element_entries_f.element_entry_id%type;
ln_object_version_number pay_element_entries_f.object_version_number%type;
lb_create_warning
boolean;
ln_screen_entry_value
pay_element_entry_values_f.screen_entry_value%type;
ln_element_type_id
pay_element_types_f.element_type_id%type;
ln_input_value_id1
pay_input_values_f.input_value_id%type;
ln_input_value_id2
pay_input_values_f.input_value_id%type;
ln_input_value_id
pay_input_values_f.input_value_id%type;
ln_element_type_id
-ln_assignment_id
lc_element_name

pay_element_types_f.element_type_id%type;
NUMBER := 12346;
pay_element_types_f.element_name%type := 'AK Test Element';

-BEGIN
--savepoint sv_create_element;
--- Get the element type id
select tl.element_type_id
into ln_element_type_id
from pay_element_types_f_tl tl
,pay_element_types_f t
where tl.element_name = lc_element_name
and language = 'US'
and t.element_type_id = tl.element_type_id
and trunc(sysdate) between t.effective_start_date and t.effective_end_date;
-- You can have upto many more input values depending on the element setup, modify the script
accordingly
for rec_input_name in cur_input_name (lc_element_name ) loop

select piv.input_value_id
into ln_input_value_id
from pay_input_values_f piv
where piv.element_type_id = rec_input_name.element_type_id
and piv.name
= rec_input_name.name
;
if rec_input_name.display_sequence = 1 then -- AK Value
ln_input_value_id1 := ln_input_value_id;
elsif rec_input_name.display_sequence = 2 then -- Employee Rate
ln_input_value_id2 := ln_input_value_id;
end if;
-end loop;
-- Get Element Link Id
-- -----------------------------ln_element_link_id := hr_entry_api.get_link
(p_assignment_id => ln_assignment_id,
p_element_type_id => ln_element_type_id,
p_session_date => TRUNC(SYSDATE)
);
dbms_output.put_line( ' API: Element Link Id: ' || ln_element_link_id );
-- Create Element Entry
-- -----------------------------pay_element_entry_api.create_element_entry
( -- Input data elements
-- ----------------------------p_validate
=> false,
p_effective_date
=> TO_DATE('22-JUN-2012','DD-MON-YYYY'),
p_business_group_id => fnd_profile.value('PER_BUSINESS_GROUP_ID'),
p_assignment_id
=> ln_assignment_id,
p_element_link_id
=> ln_element_link_id,
p_entry_type
=> 'E',
p_input_value_id1
=> ln_input_value_id1,
p_entry_value1
=> null,
p_input_value_id2
=> ln_input_value_id2,
p_entry_value2
=> 4,
-- Output data elements
-- -------------------------------p_effective_start_date => ld_effective_start_date,
p_effective_end_date => ld_effective_end_date,
p_element_entry_id
=> ln_element_entry_id,
p_object_version_number => ln_object_version_number,
p_create_warning
=> lb_create_warning
);
dbms_output.put_line( ' API: pay_element_entry_api.create_element_entry successfull - Element
Entry Id: ' || ln_element_entry_id );
--rollback;
commit;
exception

when others then


dbms_output.put_line('Error: '||sqlerrm);
rollback to sv_create_element;
end;
/
Posted by Abhay Kumar at 6:37 AM No comments:
Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest
Labels: API Scripts, HRMS

Monday, September 8, 2014

FND User/Responsibility Create/Update/Delete


-declare
-l_mode
varchar2(10) := 'CreateUser';
-l_user_name
fnd_user.user_name%type := 'AKTEST';
l_employee_id
per_all_people_f.person_id%type := 12348;
l_email
varchar2(40) := 'aktest@ak.com';
l_begin_date
date := trunc(sysdate);
l_resp_app
fnd_application.application_short_name%type := 'XXCUST';
l_resp_key
fnd_responsibility.responsibility_key%type := 'XXAK_TEST_RESP';
l_security_group fnd_security_groups.security_group_key%type := 'STANDARD';
l_responsibility_id fnd_responsibility.responsibility_id%type := 12345;
l_app_id
fnd_application.application_id%type := 67891;
l_security_group_id fnd_security_groups.security_group_id%type := 23456;
-begin
-if l_action = 'CreateUser' then
---Insert new user record into FND_USER table
fnd_user_pkg.createuser ( x_user_name
=> l_user_name
, x_employee_id
=> l_employee_id
, x_email_address
=> l_email
, x_start_date
=> l_begin_date
, x_unencrypted_password => 'Welcome1'
, x_owner
=> 'CUST'
, x_password_lifespan_days => 90 );
-- For a given user, attach a valid responsibility
fnd_user_pkg.addresp ( start_date
=> l_begin_date
, end_date
=> null
, username
=> l_user_name
, resp_app
=> l_resp_app
, resp_key
=> l_resp_key
, security_group
=> l_security_group
, description
=> null);
elsif l_action = 'UpdateUser' then
--Update any column for a particular user record.here I am just updating the Email Address
fnd_user_pkg.updateuser (x_user_name
,x_owner
=> 'CUST'

=> l_user_name

,x_email_address => l_email


);
--Update an existing user/resp/group assignment
fnd_user_resp_groups_api.Update_Assignment( user_id
=> l_user_id
,responsibility_id
=> l_responsibility_id
,responsibility_application_id => l_app_id
,security_group_id
=> l_security_group_id
,start_date
=> l_begin_date
,end_date
=> hr_general.end_of_time
,description
=> NULL);
elsif l_action = 'Delresp' then
-- Detach a responsibility which is currently attached to this given user
fnd_user_pkg.delresp(username
=> l_user_name
,resp_app
=> l_resp_app
,resp_key
=> l_resp_key
,security_group => l_security_group);
end if;
-commit;
--exception
when others then
dbms_output.put_line('Error :'||sqlerrm);
rollback;
end;
-Posted by Abhay Kumar at 7:55 AM No comments:
Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest
Labels: API Scripts, HRMS

Thursday, September 4, 2014

Reverse Termination Employee/Contingent Worker - HRMS


APIs
-declare
---Common Variables
l_sys_person_type
l_person_id

varchar2(40);
number := 123456;

--- Declare variables for reverse termination API


l_act_term_date
per_periods_of_service.actual_termination_date%type;
l_clear_details
varchar2(1) := 'Y';
l_fut_actns_exist_warning boolean;
-begin
-select ppt.system_person_type
into l_sys_person_type
from per_all_people_f
papf

,per_person_types
ppt
where papf.person_id = l_person_id
and papf.person_type_id = ppt.person_type_id;
-if l_sys_person_type like 'EX_EMP%' then
select pos.actual_termination_date
into l_act_term_date
from per_all_people_f
papf
,per_periods_of_service pos
where papf.person_id = l_person_id
--AND papf.effective_start_date =
and pos.person_id = papf.person_id ;
/*
* This API is not published, hence not meant for public calls.
*/
hr_ex_employee_api.reverse_terminate_employee
( p_validate
=> false
, p_person_id
=> l_person_id
, p_actual_termination_date => l_act_term_date
, p_clear_details
=> l_clear_details
);
dbms_output.put_line('Employee Reverse Terminated ');
-commit;
-else --CWK
select pos.actual_termination_date
into l_act_term_date
from per_all_people_f
papf
,per_periods_of_placement pos
where papf.person_id = l_person_id
-- AND papf.effective_start_date =
and pos.person_id = papf.person_id ;
/* This API reverses a contingent worker termination.
* This API removes the end date from the period of placement and the
* contingent worker assignments, and reverts the person type to Contingent Worker
*/
hr_contingent_worker_api.reverse_terminate_placement
( p_validate
=> false
, p_person_id
=> l_person_id
, p_actual_termination_date => l_act_term_date
, p_clear_details
=> l_clear_details
, p_fut_actns_exist_warning => l_fut_actns_exist_warning
);
if l_fut_actns_exist_warning then
dbms_output.put_line('Reverse Termination failed for CWK '||sqlerrm);
rollback;
else
dbms_output.put_line('CWK Reverse Terminated ');

commit;
end if;
end if;
-exception
when others then
dbms_output.put_line('Reverse Termination failed. Error Others: '||sqlerrm);
rollback;
end;
-Posted by Abhay Kumar at 3:49 AM No comments:
Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest
Labels: API Scripts, HRMS

Wednesday, September 3, 2014

Update Employment/Placement Details - HRMS APIs


-declare
---Common Variables
l_type
varchar2(10) := 'CWK';--'EMP'
l_person_id
number := 123456;
--- DECLARE variables for hr_periods_of_placement_api.update_pdp_details
l_effective_date
date := trunc(sysdate);
l_termination_reason
per_periods_of_placement.leaving_reason%type := 'AGE_REACHED';
l_object_version_number
per_periods_of_placement.object_version_number%type;
l_start_date
per_periods_of_placement.date_start%type;
-cursor cur_emp_res is
select rowid row_id
--HR_GENERAL.DECODE_LOOKUP ('LEAV_REAS',a.leaving_REASON)
ter_reason
,pos.*
from per_periods_of_service pos
where person_id = 123456;
-begin
-if l_type = 'CWK' then --Contingent Worker
-- HR_GENERAL.DECODE_LOOKUP
('HR_CWK_TERMINATION_REASONS',a.TERMINATION_REASON) termination_reason
select pos.object_version_number, date_start
into l_object_version_number, l_start_date
from per_periods_of_placement pos
where pos.person_id = l_person_id;
/*
* This API updates period of placement information for a contingent worker.
* Typically, this API is used to update the flexfields associated with periods
* of placement.
*/
hr_periods_of_placement_api.update_pdp_details(
p_validate
=> false

,p_effective_date
=> l_effective_date
,p_object_version_number => l_object_version_number
,p_person_id
=> l_person_id
,p_date_start
=> l_start_date
,p_termination_reason => l_termination_reason
--,p_attribute_category =>
--,p_attribute1
=>
--,p_attribute2
=>
--,p_attribute3
=>
);
else --Employee
for rec_per IN cur_emp_res loop
per_periods_of_service_pkg.update_row(
p_row_id
=> rec_per.row_id
,p_period_of_service_id
=> rec_per.period_of_service_id
,p_business_group_id
=> rec_per.business_group_id
,p_person_id
=> rec_per.person_id
,p_date_start
=> rec_per.date_start
,p_termination_accepted_per_id => rec_per.termination_accepted_person_id
,p_accepted_termination_date
=> rec_per.accepted_termination_date
,p_actual_termination_date
=> rec_per.actual_termination_date
,p_comments
=> rec_per.comments
,p_final_process_date
=> rec_per.final_process_date
,p_last_standard_process_date => rec_per.last_standard_process_date
,p_leaving_reason
=> l_termination_reason
,p_notified_termination_date
=> rec_per.notified_termination_date
,p_projected_termination_date => rec_per.projected_termination_date
,p_request_id
=> rec_per.request_id
,p_program_application_id
=> rec_per.program_application_id
,p_program_id
=> rec_per.program_id
,p_program_update_date
=> rec_per.program_update_date
,p_attribute_category
=> rec_per.attribute_category
,p_attribute1
=> rec_per.attribute1
,p_attribute2
=> rec_per.attribute2
,p_attribute3
=> rec_per.attribute3
,p_attribute4
=> rec_per.attribute4
,p_attribute5
=> rec_per.attribute5
,p_attribute6
=> rec_per.attribute6
,p_attribute7
=> rec_per.attribute7
,p_attribute8
=> rec_per.attribute8
,p_attribute9
=> rec_per.attribute9
,p_attribute10
=> rec_per.attribute10
,p_attribute11
=> rec_per.attribute11
,p_attribute12
=> rec_per.attribute12
,p_attribute13
=> rec_per.attribute13
,p_attribute14
=> rec_per.attribute14
,p_attribute15
=> rec_per.attribute15
,p_attribute16
=> rec_per.attribute16
,p_attribute17
=> rec_per.attribute17
,p_attribute18
=> rec_per.attribute18
,p_attribute19
=> rec_per.attribute19
,p_attribute20
=> rec_per.attribute20
,p_pds_information_category
=> rec_per.pds_information_category
,p_pds_information1
=> rec_per.pds_information1

,p_pds_information2
,p_pds_information3
,p_pds_information4
,p_pds_information5
,p_pds_information6
,p_pds_information7
,p_pds_information8
,p_pds_information9
,p_pds_information10
,p_pds_information11
,p_pds_information12
,p_pds_information13
,p_pds_information14
,p_pds_information15
,p_pds_information16
,p_pds_information17
,p_pds_information18
,p_pds_information19
,p_pds_information20
,p_pds_information21
,p_pds_information22
,p_pds_information23
,p_pds_information24
,p_pds_information25
,p_pds_information26
,p_pds_information27
,p_pds_information28
,p_pds_information29
,p_pds_information30
,p_adjusted_svc_date
);

=> rec_per.pds_information2
=> rec_per.pds_information3
=> rec_per.pds_information4
=> rec_per.pds_information5
=> rec_per.pds_information6
=> rec_per.pds_information7
=> rec_per.pds_information8
=> rec_per.pds_information9
=> rec_per.pds_information10
=> rec_per.pds_information11
=> rec_per.pds_information12
=> rec_per.pds_information13
=> rec_per.pds_information14
=> rec_per.pds_information15
=> rec_per.pds_information16
=> rec_per.pds_information17
=> rec_per.pds_information18
=> rec_per.pds_information19
=> rec_per.pds_information20
=> rec_per.pds_information21
=> rec_per.pds_information22
=> rec_per.pds_information23
=> rec_per.pds_information24
=> rec_per.pds_information25
=> rec_per.pds_information26
=> rec_per.pds_information27
=> rec_per.pds_information28
=> rec_per.pds_information29
=> rec_per.pds_information30
=> rec_per.adjusted_svc_date

end loop;
end if;
-commit;
-exception
when others then
dbms_output.put_line('Update Placement/Employement Details. Error OTHERS while validating: '||
sqlerrm);
rollback;
end;
-Posted by Abhay Kumar at 2:49 AM 2 comments:
Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest
Labels: API Scripts, HRMS

Terminate Contingent Worker - HRMS APIs


-declare
---Common Variables
l_terminate_cwk_flag
l_terminate_msg

varchar2(1) := 'N';
varchar2(600);

l_person_id
number := 123456;
l_le_terminate_cwk_exception exception;
--- DECLARE variables for hr_contingent_worker_api.actual_termination_placement
--- IN variables
l_effective_date
date := trunc(sysdate);
l_termination_reason
per_periods_of_placement.leaving_reason%type := 'AGE_REACHED';
l_person_type_id
per_person_types.person_type_id%type := 1120;
l_period_of_service_id
per_periods_of_placement.period_of_service_id%type;
l_actual_termination_date per_periods_of_placement.actual_termination_date%type
:=trunc(sysdate);
l_last_standard_process_date per_periods_of_placement.last_standard_process_date%type :=
trunc(sysdate+10);
l_object_version_number
per_periods_of_placement.object_version_number%type;
l_start_date
per_periods_of_placement.date_start%type;
l_notif_term_date
date;
--- OUT variables
l_supervisor_warning
boolean := false;
l_event_warning
boolean := false;
l_interview_warning
boolean := false;
l_review_warning
boolean := false;
l_recruiter_warning
boolean := false;
l_asg_future_changes_warning boolean := false;
l_entries_changed_warning varchar2(300);
l_pay_proposal_warning
boolean := false;
l_dod_warning
boolean := false;
--- DECLARE variables for hr_contingent_worker_api.final_process_placement
--- IN variables
l_final_process_date
per_periods_of_service.final_process_date%type;
--- OUT variables
l_org_now_no_manager_warning boolean := false;
-begin
-begin
select pos.period_of_placement_id, pos.object_version_number, date_start
into l_period_of_service_id, l_object_version_number, l_start_date
from per_periods_of_placement pos
where pos.person_id = l_person_id;
exception
when others then
l_terminate_msg := 'Error while selecting cwk details : '||substr(sqlerrm,1,150);
raise l_le_terminate_cwk_exception;
end;
-savepoint terminate_cwk_s1;
-begin
/*
This API covers the first step in terminating a period of placement and
all current assignments for a cwk, identified by person_id and date_start.
You can use the API to set the actual termination date, the last standard

process date, the new assignment status and the new person type
*/
hr_contingent_worker_api.actual_termination_placement
(p_validate
=> false
,p_effective_date
=> l_effective_date
,p_person_id
=> l_person_id
,p_date_start
=> l_start_date
,p_person_type_id
=> l_person_type_id
,p_actual_termination_date
=> l_actual_termination_date
,p_termination_reason
=> l_termination_reason
--In/Out
,p_object_version_number
=> l_object_version_number
,p_last_standard_process_date => l_last_standard_process_date
--Out
,p_supervisor_warning
=> l_supervisor_warning
,p_event_warning
=> l_event_warning
,p_interview_warning
=> l_interview_warning
,p_review_warning
=> l_review_warning
,p_recruiter_warning
=> l_recruiter_warning
,p_asg_future_changes_warning
=> l_asg_future_changes_warning
,p_entries_changed_warning
=> l_entries_changed_warning
,p_pay_proposal_warning
=> l_pay_proposal_warning
,p_dod_warning
=> l_dod_warning
);
if l_object_version_number is null then
l_terminate_cwk_flag := 'N';
l_terminate_msg
:= 'Warning validating API:
hr_contingent_worker_api.actual_termination_placement';
raise l_le_terminate_cwk_exception;
end if;
l_terminate_cwk_flag := 'Y';
exception
when others then
l_terminate_msg := 'Error validating API: hr_contingent_worker_api.actual_termination_placement :
'||substr(sqlerrm,1,150);
raise l_le_terminate_cwk_exception;
end; --hr_contingent_worker_api.actual_termination_placement
if l_terminate_cwk_flag = 'Y' then
begin
/*
This API covers the second step in terminating a period of placement and
all current assignments for an cwk. It updates the period of placement
details and date-effectively deletes all the contingent worker assignments
as of the final process date.
*/
hr_contingent_worker_api.final_process_placement (
p_validate
=> false
,p_person_id
=> l_person_id
,p_date_start
=> l_start_date
--In/Out
,p_object_version_number
=> l_object_version_number
,p_final_process_date
=> l_final_process_date
--Out

,p_org_now_no_manager_warning => l_org_now_no_manager_warning


,p_asg_future_changes_warning => l_asg_future_changes_warning
,p_entries_changed_warning
=> l_entries_changed_warning );
exception
when others then
l_terminate_msg := 'Error validating API: hr_contingent_worker_api.final_process_placement : '||
substr(sqlerrm,1,150);
raise l_le_terminate_cwk_exception;
end; --hr_contingent_worker_api.final_process_placement
end if;
-commit;
-exception
when l_le_terminate_cwk_exception then
dbms_output.put_line(l_terminate_msg);
rollback to terminate_cwk_s1;
when others then
dbms_output.put_line('Terminate CWK. Error OTHERS while validating: '||sqlerrm);
rollback to terminate_cwk_s1;
end;
--

You might also like