Create Contact(Depandant) API Script
DECLARE
l_validate_mode BOOLEAN := FALSE;
l_datetrack_update_mode VARCHAR2 (30);
l_row_id ROWID;
l_business_group_id NUMBER;
l_contact_type VARCHAR2 (30);
l_contact_title VARCHAR2 (30);
l_primary_flag VARCHAR2 (30);
l_attribute16 VARCHAR2 (150);
l_contact_full_name VARCHAR2 (240);
l_person_type_id NUMBER;
l_sex VARCHAR2 (30);
l_per_start_date DATE;
l_per_end_date DATE;
l_per_comment_id NUMBER;
l_name_comb_warning BOOLEAN;
l_contact_relationship_id NUMBER;
l_contact_rel_ovn NUMBER;
l_contact_person_id NUMBER;
l_contact_person_ovn NUMBER;
l_errors VARCHAR2 (100);
l_orig_hire_warning BOOLEAN;
l_person_id NUMBER;
l_start_date DATE;
l_martial_status VARCHAR2 (10);
l_nationality VARCHAR2 (25);
l_error VARCHAR2 (2500);
CURSOR cur_ee
IS
SELECT *
FROM xxbtm_contact_stg_v1
WHERE record_status IS NULL AND sno <= 40;
BEGIN
FOR c1_ee_rec IN cur_ee
LOOP
l_person_id := NULL;
l_start_date := NULL;
l_martial_status := NULL;
l_nationality := NULL;
l_business_group_id := NULL;
l_contact_rel_ovn:=null;
l_contact_person_id:=null;
l_contact_person_ovn:=null;
l_per_start_date:=null;
l_per_end_date:=null;
l_contact_full_name:=null;
l_per_comment_id:=null;
l_name_comb_warning:=null;
l_orig_hire_warning:=null;
BEGIN
SELECT person_id, effective_start_date, business_group_id
INTO l_person_id, l_start_date, l_business_group_id
FROM per_all_people_f
WHERE attribute6 = c1_ee_rec.legacy_emp_num
AND TRUNC (SYSDATE) BETWEEN effective_start_date
AND effective_end_date;
EXCEPTION
WHEN OTHERS
THEN
l_error := 'Invalid Emp Details' || SQLERRM;
END;
IF l_start_date < c1_ee_rec.date_of_birth
THEN
l_start_date := c1_ee_rec.date_of_birth;
ELSE
l_start_date := l_start_date;
END IF;
BEGIN
SELECT TRIM (lookup_code)
INTO l_martial_status
FROM hr_lookups
WHERE lookup_type = 'MAR_STATUS'
AND UPPER (meaning) = UPPER (c1_ee_rec.martial_status);
EXCEPTION
WHEN OTHERS
THEN
l_error := 'Invalid MARTIAL_STATUS' || SQLERRM;
END;
BEGIN
SELECT TRIM (lookup_code)
INTO l_nationality
FROM hr_lookups
WHERE lookup_type = 'NATIONALITY'
AND UPPER (meaning) = UPPER (c1_ee_rec.nationality);
EXCEPTION
WHEN OTHERS
THEN
l_error := 'Invalid NATIONALITY' || SQLERRM;
END;
IF TRIM (l_error) IS NULL
THEN
BEGIN
hr_contact_rel_api.create_contact
(p_validate => FALSE,
p_date_start => l_start_date,
p_start_date => l_start_date,
p_personal_flag => 'Y',
p_business_group_id => l_business_group_id,
p_person_id => l_person_id,
p_contact_type => 'C',
p_last_name => c1_ee_rec.last_name,
p_sex => SUBSTR
(c1_ee_rec.gender,
1,
1
),
p_person_type_id => 1122,
p_date_of_birth => c1_ee_rec.date_of_birth,
p_first_name => c1_ee_rec.first_name,
p_marital_status => l_martial_status,
p_nationality => l_nationality,
p_title => UPPER
(c1_ee_rec.title),
p_contact_relationship_id => l_contact_relationship_id,
p_ctr_object_version_number => l_contact_rel_ovn,
p_per_person_id => l_contact_person_id,
p_per_object_version_number => l_contact_person_ovn,
p_per_effective_start_date => l_per_start_date,
p_per_effective_end_date => l_per_end_date,
p_full_name => l_contact_full_name,
p_per_comment_id => l_per_comment_id,
p_name_combination_warning => l_name_comb_warning,
p_orig_hire_warning => l_orig_hire_warning
);
UPDATE xxbtm_contact_stg_v1
SET record_status = 'S'
WHERE sno = c1_ee_rec.sno;
EXCEPTION
WHEN OTHERS
THEN
l_error := SQLERRM;
UPDATE xxbtm_contact_stg_v1
SET record_status = 'E',
error_message = l_error
WHERE sno = c1_ee_rec.sno;
END;
ELSE
UPDATE xxbtm_contact_stg_v1
SET record_status = 'E',
error_message = l_error
WHERE sno = c1_ee_rec.sno;
END IF;
END LOOP;
COMMIT;
END;
/
No comments:
Post a Comment