HRMS API: Create Person Address
DECLARE
v_effective_date DATE;
v_person_id NUMBER;
v_primary_flag VARCHAR2 (1);
v_style VARCHAR2 (50);
v_date_from DATE;
v_address_line1 VARCHAR2 (500);
v_town_or_city VARCHAR2 (50);
v_region_1 VARCHAR2 (50);
v_country VARCHAR2 (50);
v_address_id NUMBER;
v_object_version_number NUMBER;
v_api_error VARCHAR2 (500);
v_error_msg VARCHAR2 (500);
BEGIN
v_primary_flag := 'Y';
v_style := 'EG_GLB';
v_country := 'EG';
FOR i IN (SELECT *
FROM xx_upload_addresses xx
WHERE xx.accepted_flag = 'N' AND person_id IS NOT NULL)
LOOP
BEGIN
SELECT per.effective_start_date, per.effective_start_date
INTO v_date_from, v_effective_date
FROM per_all_people_f per
WHERE per.person_id = i.person_id
AND per.effective_end_date = TO_DATE ('31/12/4712', 'DD/MM/YYYY');
hr_person_address_api.create_person_address
(p_effective_date => v_effective_date,
p_person_id => i.person_id,
p_primary_flag => v_primary_flag,
p_style => v_style,
p_date_from => v_date_from,
p_address_line1 => i.building_en,
p_address_line2 => i.street_en,
p_address_line3 => i.sector_en,
p_town_or_city => TRIM (i.town_en),
p_add_information13 => i.building_ar,
p_add_information14 => i.street_ar,
p_add_information15 => i.sector_ar,
p_add_information16 => TRIM (i.town_ar),
p_country => v_country,
p_address_id => v_address_id,
p_object_version_number => v_object_version_number
);
UPDATE xx_upload_addresses
SET person_id = v_person_id,
accepted_flag = 'Y',
err_msg = 'Done',
address_id = v_address_id
WHERE employee_number = i.employee_number
AND business_group_id = i.business_group_id;
EXCEPTION
WHEN OTHERS
THEN
v_date_from := NULL;
v_effective_date := NULL;
v_api_error := NULL;
v_error_msg := NULL;
v_api_error := SQLERRM;
v_error_msg := v_error_msg || ' ' || v_api_error;
UPDATE xx_upload_addresses
SET err_msg = v_error_msg
WHERE employee_number = i.employee_number
AND business_group_id = i.business_group_id
AND accepted_flag = 'N';
END;
END LOOP;
COMMIT;
END;
DECLARE
v_effective_date DATE;
v_person_id NUMBER;
v_primary_flag VARCHAR2 (1);
v_style VARCHAR2 (50);
v_date_from DATE;
v_address_line1 VARCHAR2 (500);
v_town_or_city VARCHAR2 (50);
v_region_1 VARCHAR2 (50);
v_country VARCHAR2 (50);
v_address_id NUMBER;
v_object_version_number NUMBER;
v_api_error VARCHAR2 (500);
v_error_msg VARCHAR2 (500);
BEGIN
v_primary_flag := 'Y';
v_style := 'EG_GLB';
v_country := 'EG';
FOR i IN (SELECT *
FROM xx_upload_addresses xx
WHERE xx.accepted_flag = 'N' AND person_id IS NOT NULL)
LOOP
BEGIN
SELECT per.effective_start_date, per.effective_start_date
INTO v_date_from, v_effective_date
FROM per_all_people_f per
WHERE per.person_id = i.person_id
AND per.effective_end_date = TO_DATE ('31/12/4712', 'DD/MM/YYYY');
hr_person_address_api.create_person_address
(p_effective_date => v_effective_date,
p_person_id => i.person_id,
p_primary_flag => v_primary_flag,
p_style => v_style,
p_date_from => v_date_from,
p_address_line1 => i.building_en,
p_address_line2 => i.street_en,
p_address_line3 => i.sector_en,
p_town_or_city => TRIM (i.town_en),
p_add_information13 => i.building_ar,
p_add_information14 => i.street_ar,
p_add_information15 => i.sector_ar,
p_add_information16 => TRIM (i.town_ar),
p_country => v_country,
p_address_id => v_address_id,
p_object_version_number => v_object_version_number
);
UPDATE xx_upload_addresses
SET person_id = v_person_id,
accepted_flag = 'Y',
err_msg = 'Done',
address_id = v_address_id
WHERE employee_number = i.employee_number
AND business_group_id = i.business_group_id;
EXCEPTION
WHEN OTHERS
THEN
v_date_from := NULL;
v_effective_date := NULL;
v_api_error := NULL;
v_error_msg := NULL;
v_api_error := SQLERRM;
v_error_msg := v_error_msg || ' ' || v_api_error;
UPDATE xx_upload_addresses
SET err_msg = v_error_msg
WHERE employee_number = i.employee_number
AND business_group_id = i.business_group_id
AND accepted_flag = 'N';
END;
END LOOP;
COMMIT;
END;
No comments:
Post a Comment