--------------------------------------------------------------------------
--Create/Update/Delete Hierarchy Element
--------------------------------------------------------------------------
--
declare
--
l_action varchar2(10) := 'CREATE'; --'UPDATE'--'DELETE'
l_validate_mode boolean := true;
l_child_effective_date date := sysdate;
l_parent_org_id hr_all_organization_units.organization_id%type;
l_child_org_id hr_all_organization_units.organization_id%type;
l_org_structure_ver_id per_org_structure_versions.org_structure_version_id%type;
l_business_group_id NUMBER := 101;
l_inactive_org_warning BOOLEAN;
l_object_version_number per_org_structure_elements.object_version_number%TYPE;
l_org_hierarchy per_organization_structures.name%TYPE;
l_org_structure_element_id per_org_structure_elements.org_structure_element_id%TYPE;
--
begin
--
l_parent_org_id := 8719;
l_child_org_id := 4536;
l_org_structure_ver_id := 30061;
/*select posv.org_structure_version_id,pos.*
from per_org_structure_versions posv
,per_organization_structures pos
where pos.name = :l_org_hierarchy
and posv.organization_structure_id = pos.organization_structure_id; */
--
l_org_structure_element_id := null;
l_object_version_number := null;
l_inactive_org_warning := false;
--
if l_action = 'CREATE' then
begin
--
hr_hierarchy_element_api.create_hierarchy_element
(
p_validate => l_validate_mode
,p_effective_date => l_child_effective_date
,p_organization_id_parent => l_parent_org_id
,p_org_structure_version_id => l_org_structure_ver_id
,p_organization_id_child => l_child_org_id
,p_business_group_id => l_business_group_id
,p_pos_control_enabled_flag => 'N'
,p_inactive_org_warning => l_inactive_org_warning
,p_org_structure_element_id => l_org_structure_element_id
,p_object_version_number => l_object_version_number
);
if l_object_version_number is null or l_org_structure_element_id is null then
dbms_output.put_line('create_hierarchy_element API Error: '||sqlerrm);
rollback;
elsif l_inactive_org_warning then
dbms_output.put_line('Warning: Inactive Organization');
rollback;
else
dbms_output.put_line('hierarchy created Successfully ');
commit;
end if;
exception
when others then
dbms_output.put_line('create_hierarchy_element API failed with error :'||sqlerrm);
rollback;
end;
elsif l_action = 'UPDATE' then
l_org_structure_element_id := 180;
l_object_version_number := 3;
begin
--
hr_hierarchy_element_api.update_hierarchy_element
(
p_validate => l_validate_mode
,p_effective_date => l_child_effective_date
,p_org_structure_element_id => l_org_structure_element_id
,p_organization_id_parent => l_parent_org_id
,p_organization_id_child => l_child_org_id
,p_pos_control_enabled_flag => 'N'
,p_object_version_number => l_object_version_number
);
if l_object_version_number is null then
dbms_output.put_line('update_hierarchy_element API Error: '||sqlerrm);
rollback;
else
dbms_output.put_line('hierarchy updated Successfully ');
commit;
end if;
exception
when others then
dbms_output.put_line('update_hierarchy_element API failed with error :'||sqlerrm);
rollback;
end;
elsif l_action = 'DELETE' then
l_org_structure_element_id := 180;
l_object_version_number := 4;
begin
--
hr_hierarchy_element_api.delete_hierarchy_element
(
p_validate => l_validate_mode
,p_org_structure_element_id => l_org_structure_element_id
,p_object_version_number => l_object_version_number
);
--
dbms_output.put_line('hierarchy deleted Successfully ');
commit;
--
exception
when others then
dbms_output.put_line('delete_hierarchy_element API failed with error :'||sqlerrm);
rollback;
end;
end if;
--
exception
when others then
dbms_output.put_line('hr_hierarchy_element_api API failed with error :'||sqlerrm);
rollback;
end;
--
--Create/Update/Delete Hierarchy Element
--------------------------------------------------------------------------
--
declare
--
l_action varchar2(10) := 'CREATE'; --'UPDATE'--'DELETE'
l_validate_mode boolean := true;
l_child_effective_date date := sysdate;
l_parent_org_id hr_all_organization_units.organization_id%type;
l_child_org_id hr_all_organization_units.organization_id%type;
l_org_structure_ver_id per_org_structure_versions.org_structure_version_id%type;
l_business_group_id NUMBER := 101;
l_inactive_org_warning BOOLEAN;
l_object_version_number per_org_structure_elements.object_version_number%TYPE;
l_org_hierarchy per_organization_structures.name%TYPE;
l_org_structure_element_id per_org_structure_elements.org_structure_element_id%TYPE;
--
begin
--
l_parent_org_id := 8719;
l_child_org_id := 4536;
l_org_structure_ver_id := 30061;
/*select posv.org_structure_version_id,pos.*
from per_org_structure_versions posv
,per_organization_structures pos
where pos.name = :l_org_hierarchy
and posv.organization_structure_id = pos.organization_structure_id; */
--
l_org_structure_element_id := null;
l_object_version_number := null;
l_inactive_org_warning := false;
--
if l_action = 'CREATE' then
begin
--
hr_hierarchy_element_api.create_hierarchy_element
(
p_validate => l_validate_mode
,p_effective_date => l_child_effective_date
,p_organization_id_parent => l_parent_org_id
,p_org_structure_version_id => l_org_structure_ver_id
,p_organization_id_child => l_child_org_id
,p_business_group_id => l_business_group_id
,p_pos_control_enabled_flag => 'N'
,p_inactive_org_warning => l_inactive_org_warning
,p_org_structure_element_id => l_org_structure_element_id
,p_object_version_number => l_object_version_number
);
if l_object_version_number is null or l_org_structure_element_id is null then
dbms_output.put_line('create_hierarchy_element API Error: '||sqlerrm);
rollback;
elsif l_inactive_org_warning then
dbms_output.put_line('Warning: Inactive Organization');
rollback;
else
dbms_output.put_line('hierarchy created Successfully ');
commit;
end if;
exception
when others then
dbms_output.put_line('create_hierarchy_element API failed with error :'||sqlerrm);
rollback;
end;
elsif l_action = 'UPDATE' then
l_org_structure_element_id := 180;
l_object_version_number := 3;
begin
--
hr_hierarchy_element_api.update_hierarchy_element
(
p_validate => l_validate_mode
,p_effective_date => l_child_effective_date
,p_org_structure_element_id => l_org_structure_element_id
,p_organization_id_parent => l_parent_org_id
,p_organization_id_child => l_child_org_id
,p_pos_control_enabled_flag => 'N'
,p_object_version_number => l_object_version_number
);
if l_object_version_number is null then
dbms_output.put_line('update_hierarchy_element API Error: '||sqlerrm);
rollback;
else
dbms_output.put_line('hierarchy updated Successfully ');
commit;
end if;
exception
when others then
dbms_output.put_line('update_hierarchy_element API failed with error :'||sqlerrm);
rollback;
end;
elsif l_action = 'DELETE' then
l_org_structure_element_id := 180;
l_object_version_number := 4;
begin
--
hr_hierarchy_element_api.delete_hierarchy_element
(
p_validate => l_validate_mode
,p_org_structure_element_id => l_org_structure_element_id
,p_object_version_number => l_object_version_number
);
--
dbms_output.put_line('hierarchy deleted Successfully ');
commit;
--
exception
when others then
dbms_output.put_line('delete_hierarchy_element API failed with error :'||sqlerrm);
rollback;
end;
end if;
--
exception
when others then
dbms_output.put_line('hr_hierarchy_element_api API failed with error :'||sqlerrm);
rollback;
end;
--
No comments:
Post a Comment