1 package body PER_ES_CREATE_EMPLOYEE as
2 /* $Header: peesempp.pkb 120.3 2006/09/14 14:20:13 mgettins noship $ */
3 g_package VARCHAR2(30) := 'PER_ES_CREATE_EMPLOYEE.';
4 -- p_first_last_name p_last_name
5 -- p_identifier_type p_per_information2
6 -- p_identifier_value p_per_information3
7
8 PROCEDURE create_es_employee (p_last_name VARCHAR2
9 ,p_first_name VARCHAR2
10 ,p_national_identifier VARCHAR2
11 ,p_per_information1 VARCHAR2
12 ,p_per_information2 VARCHAR2
13 ,p_per_information3 VARCHAR2
14 ) is
15
16 CURSOR get_lookup_type(p_per_information2 varchar2) is
17 select lookup_code from hr_lookups where
18 lookup_type='ES_IDENTIFIER_TYPE'
19 and lookup_code=p_per_information2;
20
21 l_identifier_type hr_lookups.lookup_code%TYPE;
22 l_identifier_value VARCHAR2(10);
23 l_validate_profile VARCHAR2(20);
24 l_proc VARCHAR2(72) := g_package||'CREATE_ES_EMPLOYEE';
25 l_national_identifier per_all_people_f.national_identifier%TYPE;
26 BEGIN
27 --
28 -- Added for GSI Bug 5472781
29 --
30 IF hr_utility.chk_product_install('Oracle Human Resources', 'ES') THEN
31 --
32 hr_api.mandatory_arg_error
33 (p_api_name => l_proc,
34 p_argument => hr_general.decode_lookup('ES_FORM_LABELS','LAST_NAME_1'),
35 p_argument_value => p_last_name
36 );
37
38 l_validate_profile := FND_PROFILE.VALUE('PER_NATIONAL_IDENTIFIER_VALIDATION');
39
40 IF p_per_information3 IS NOT NULL AND
41 p_per_information2 IS NULL THEN
42 hr_utility.set_message(800,'HR_ES_INVALID_VALUE');
43 hr_utility.set_message_token(800,'FIELD',hr_general.decode_lookup('ES_FORM_LABELS','IDENTIFIER_TYPE'));
44 hr_utility.raise_error;
45 ELSIF p_per_information2 IS NOT NULL AND
46 p_per_information3 IS NULL THEN
47 OPEN get_lookup_type(p_per_information2);
48 FETCH get_lookup_type into l_identifier_type;
49 IF get_lookup_type%NOTFOUND THEN
50 hr_utility.set_message(800,'HR_ES_INVALID_VALUE');
51 hr_utility.set_message_token(800,'FIELD',hr_general.decode_lookup('ES_FORM_LABELS','IDENTIFIER_TYPE'));
52 hr_utility.raise_error;
53 END IF;
54 CLOSE get_lookup_type;
55 hr_utility.set_message(800,'HR_ES_INVALID_VALUE');
56 hr_utility.set_message_token(800,'FIELD',hr_general.decode_lookup('ES_IDENTIFIER_TYPE',p_per_information2));
57 hr_utility.raise_error;
58 END IF;
59 --
60 IF l_validate_profile <> 'NONE' THEN --No Validation
61 IF p_national_identifier IS NULL THEN
62 IF p_per_information3 IS NULL THEN
63 hr_utility.set_message(800, 'HR_ES_REQ_NIF_IDT_MISSING');
64 hr_utility.raise_error;
65 END IF;
66 ELSE
67 l_national_identifier := hr_es_utility.check_NIF(p_national_identifier);
68 IF l_national_identifier = 'N' THEN
69 hr_utility.set_message(800, 'HR_ES_INVALID_NIF');
70 hr_utility.raise_error;
71 END IF;
72 END IF;
73 END IF;
74
75 IF p_per_information2 IS NOT NULL THEN
76 OPEN get_lookup_type(p_per_information2);
77 FETCH get_lookup_type into l_identifier_type;
78 IF get_lookup_type%NOTFOUND THEN
79 hr_utility.set_message(800,'HR_ES_INVALID_VALUE');
80 hr_utility.set_message_token(800,'FIELD',hr_general.decode_lookup('ES_FORM_LABELS','IDENTIFIER_TYPE'));
81 hr_utility.raise_error;
82 ELSIF l_validate_profile <> 'NONE' THEN
83 l_identifier_value := hr_es_utility.validate_identifier(p_per_information2,p_per_information3);
84 END IF;
85 CLOSE get_lookup_type;
86 END IF;
87
88 IF l_validate_profile <> 'NONE' and p_per_information2 IS NOT NULL and p_per_information3 IS NOT NULL and p_national_identifier is not null THEN
89 OPEN get_lookup_type(p_per_information2);
90 FETCH get_lookup_type into l_identifier_type;
91 if l_identifier_type='DNI' then
92 If substr(p_national_identifier,1,8) <> p_per_information3 then
93 hr_utility.set_message(800,'HR_ES_INVALID_DNI_NIF');
94 hr_utility.raise_error;
95 end if;
96 end if;
97 CLOSE get_lookup_type;
98 end if;
99
100 IF length(p_last_name)>40 THEN
101 hr_utility.set_message(800, 'HR_289712_UTF8_LENGTH_EXCEEDED');
102 hr_utility.set_message_token('COLUMN_NAME',hr_general.decode_lookup('ES_FORM_LABELS','LAST_NAME_1'));
103 hr_utility.set_message_token('COLUMN_VALUE',p_last_name);
104 hr_utility.set_message_token('MAX_LENGTH','40');
105 hr_utility.raise_error;
106 END IF;
107
108 IF length(p_first_name)>40 THEN
109 hr_utility.set_message(800, 'HR_289712_UTF8_LENGTH_EXCEEDED');
110 hr_utility.set_message_token('COLUMN_NAME',hr_general.decode_lookup('ES_FORM_LABELS','NAME'));
111 hr_utility.set_message_token('COLUMN_VALUE',p_first_name);
112 hr_utility.set_message_token('MAX_LENGTH','40');
113 hr_utility.raise_error;
114 END IF;
115
116 IF length(p_per_information1)>40 THEN
117 hr_utility.set_message(800, 'HR_289712_UTF8_LENGTH_EXCEEDED');
118 hr_utility.set_message_token('COLUMN_NAME',hr_general.decode_lookup('ES_FORM_LABELS','LAST_NAME_2'));
119 hr_utility.set_message_token('COLUMN_VALUE',p_per_information1);
120 hr_utility.set_message_token('MAX_LENGTH','40');
121 hr_utility.raise_error;
122 END IF;
123 --
124 END IF;
125 --
126 END create_es_employee;
127
128 END PER_ES_CREATE_EMPLOYEE;