DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_ZA_USER_HOOK_PKG

Source


1 PACKAGE BODY per_za_user_hook_pkg AS
2 /* $Header: pezauhkp.pkb 120.0.12000000.1 2007/03/26 15:44:53 rajesrin noship $ */
3    --------------------
4    -- Package variables
5    --------------------
6    g_package  varchar2(21) := 'per_za_user_hook_pkg.';
7    --------------------------------------------------------------------------
8    -- validate_race                                                        --
9    --------------------------------------------------------------------------
10    -- Description:
11    --    Checks that a valid race has been entered for
12    --    applicants, employees and contingent workers.
13    -- Called from:
14    --    validate_applicant
15    --    validate_employee
16    --    validate_cwk
17    --    validate_person
18    -- Person DDF segments used :
19    --    SEGMENT            NAME
20    --    -------            ----
21    --    PER_INFORMATION4   Race
22    --
23    ---------------------------------------------------------------------------
24    --                                                                       --
25    ---------------------------------------------------------------------------
26    PROCEDURE validate_race
27    ( p_effective_date in date
28    , p_person_type_id in number   default null
29    , p_race_code      in varchar2 default null
30    ) IS
31       -- Cursors
32       --
33       CURSOR c_system_person_type
34       IS
35          SELECT typ.system_person_type
36            FROM per_person_types typ
37           WHERE typ.person_type_id     = p_person_type_id;
38       -- Local Variables
39       --
40       l_proc               varchar2(40) := g_package||'validate_race';
41       l_system_person_type per_person_types.system_person_type%TYPE;
42    BEGIN
43 
44       -- The Race segment is mandatory for employees, applicants and
45       -- contingent workers
46       --
47          -- Find the system person type
48          --
49          OPEN  c_system_person_type;
50          FETCH c_system_person_type INTO l_system_person_type;
51          CLOSE c_system_person_type;
52 
53          -- RACE is required for system person types
54          -- of APL, EMP and CWK
55          --
56          IF l_system_person_type IN ('APL','EMP','CWK') THEN
57             IF hr_multi_message.no_exclusive_error
58                ( p_check_column1 => 'PER_ALL_PEOPLE_F.PER_INFORMATION4'
59                )
60             THEN
61               IF p_race_code IS NULL OR
62                  p_race_code = 'N'   OR
63                  hr_api.not_exists_in_hr_lookups
64                     (p_effective_date => p_effective_date
65                     ,p_lookup_type    => 'ZA_RACE'
66                     ,p_lookup_code    => p_race_code
67                     )
68               THEN
69                  fnd_message.set_name('PER', 'HR_ZA_MAND_SEG_RACE');
70                  hr_multi_message.add
71                    (p_associated_column1 => 'PER_ALL_PEOPLE_F.PER_INFORMATION4'
72                    );
73               END IF;
74             END IF;
75          END IF;
76    END validate_race;
77 -------------------------------------------------------------------------------
78 -- validate_applicant
79 -------------------------------------------------------------------------------
80 PROCEDURE validate_applicant
81    ( p_business_group_id
82         in per_all_people_f.business_group_id%type        default null
83    , p_date_received
84         in date
85    , p_person_type_id
86         in per_all_people_f.person_type_id%type           default null
87    , p_per_information_category
88         in per_all_people_f.per_information_category%type default null
89    , p_per_information4
90         in per_all_people_f.per_information4%type         default null
91    )
92 AS
93    ------------
94    -- Variables
95    ------------
96    l_proc            varchar2(40) := g_package||'validate_applicant';
97    l_person_type_id  per_all_people_f.person_type_id%type;
98 
99 BEGIN
100    IF hr_utility.chk_product_install('Oracle Human Resources', 'ZA') THEN
101       hr_utility.set_location(l_proc,1);
102 
103       -- Check/Find person type id
104       --
105       per_per_bus.chk_person_type
106          ( p_person_type_id    => l_person_type_id
107          , p_business_group_id => p_business_group_id
108          , p_expected_sys_type => 'APL'
109          );
110 
111       hr_utility.set_location(l_proc,2);
112 
113       -- Validate the person's race
114       --
115       validate_race
116          ( p_effective_date => p_date_received
117          , p_person_type_id => l_person_type_id
118          , p_race_code      => p_per_information4
119          );
120 
121       hr_utility.set_location(l_proc,3);
122    END IF;
123 END validate_applicant;
124 -------------------------------------------------------------------------------
125 -- validate_employee
126 -------------------------------------------------------------------------------
127 PROCEDURE validate_employee
128    ( p_business_group_id
129         in per_all_people_f.business_group_id%type        default null
130    , p_hire_date
131         in date
132    , p_person_type_id
133         in per_all_people_f.person_type_id%type           default null
134    , p_per_information_category
135         in per_all_people_f.per_information_category%type default null
136    , p_per_information4
137         in per_all_people_f.per_information4%type         default null
138    )
139 AS
140    ------------
141    -- Variables
142    ------------
143    l_proc            varchar2(40) := g_package||'validate_employee';
144    l_person_type_id  per_all_people_f.person_type_id%type;
145 
146 BEGIN
147    IF hr_utility.chk_product_install('Oracle Human Resources', 'ZA') THEN
148       hr_utility.set_location(l_proc,1);
149 
150       -- Check/Find person type id
151       --
152       per_per_bus.chk_person_type
153          ( p_person_type_id    => l_person_type_id
154          , p_business_group_id => p_business_group_id
155          , p_expected_sys_type => 'EMP'
156          );
157 
158       hr_utility.set_location(l_proc,2);
159 
160       -- Validate the person's race
161       --
162       validate_race
163          ( p_effective_date => p_hire_date
164          , p_person_type_id => l_person_type_id
165          , p_race_code      => p_per_information4
166          );
167 
168       hr_utility.set_location(l_proc,3);
169    END IF;
170 END validate_employee;
171 -------------------------------------------------------------------------------
172 -- validate_cwk
173 -------------------------------------------------------------------------------
174 PROCEDURE validate_cwk
175    ( p_business_group_id
176         in per_all_people_f.business_group_id%type        default null
177    , p_start_date
178         in date
179    , p_person_type_id
180         in per_all_people_f.person_type_id%type           default null
181    , p_per_information_category
182         in per_all_people_f.per_information_category%type default null
183    , p_per_information4
184         in per_all_people_f.per_information4%type         default null
185    )
186 AS
187    ------------
188    -- Variables
189    ------------
190    l_proc            varchar2(40) := g_package||'validate_cwk';
191    l_person_type_id  per_all_people_f.person_type_id%type;
192 
193 BEGIN
194    IF hr_utility.chk_product_install('Oracle Human Resources', 'ZA') THEN
195       hr_utility.set_location(l_proc,1);
196 
197       -- Check/Find person type id
198       --
199       per_per_bus.chk_person_type
200          ( p_person_type_id    => l_person_type_id
201          , p_business_group_id => p_business_group_id
202          , p_expected_sys_type => 'CWK'
203          );
204 
205       hr_utility.set_location(l_proc,2);
206 
207       -- Validate the person's race
208       --
209       validate_race
210          ( p_effective_date => p_start_date
211          , p_person_type_id => l_person_type_id
212          , p_race_code      => p_per_information4
213          );
214 
215       hr_utility.set_location(l_proc,3);
216    END IF;
217 END validate_cwk;
218 -------------------------------------------------------------------------------
219 -- validate_person
220 -------------------------------------------------------------------------------
221 PROCEDURE validate_person
222    ( p_person_id
223         in per_all_people_f.person_id%type
224    , p_effective_date
225         in date
226    , p_person_type_id
227         in per_all_people_f.person_type_id%type
228    , p_per_information_category
229         in per_all_people_f.per_information_category%type
230    , p_per_information4
231         in per_all_people_f.per_information4%type
232    )
233 AS
234    ---------
235    -- Cursor
236    ---------
237    CURSOR c_person_person_type
238    IS
239       SELECT person_type_id
240         FROM per_all_people_f
241        WHERE person_id = p_person_id
242          AND p_effective_date BETWEEN effective_start_date
243                                   AND effective_end_date;
244    CURSOR c_person_race
245    IS
246       SELECT per_information4
247         FROM per_all_people_f
248        WHERE person_id = p_person_id
249          AND p_effective_date BETWEEN effective_start_date
250                                   AND effective_end_date;
251    ------------
252    -- Variables
253    ------------
254    l_proc            varchar2(40) := g_package||'validate_person';
255    l_person_type_id  per_all_people_f.person_type_id%type;
256    l_person_race     per_all_people_f.per_information4%type;
257 
258 BEGIN
259    IF hr_utility.chk_product_install('Oracle Human Resources', 'ZA') THEN
260       hr_utility.set_location(l_proc,1);
261 
262       -- If the person type id was not passed
263       --
264       IF p_person_type_id = hr_api.g_number THEN
265          hr_utility.set_location(l_proc,2);
266          -- Find the person's person type
267          --
268          OPEN  c_person_person_type;
269          FETCH c_person_person_type INTO l_person_type_id;
270          CLOSE c_person_person_type;
271       ELSE
272          hr_utility.set_location(l_proc,3);
273          l_person_type_id := p_person_type_id;
274       END IF;
275 
276       -- if the race field was not updated
277       --
278       IF p_per_information4 = hr_api.g_varchar2 THEN
279          hr_utility.set_location(l_proc,4);
280          -- find the person's race
281          --
282          OPEN  c_person_race;
283          FETCH c_person_race INTO l_person_race;
284          CLOSE c_person_race;
285       ELSE
286          hr_utility.set_location(l_proc,5);
287          l_person_race := p_per_information4;
288       END IF;
289 
290       -- Validate the person's race
291       --
292       validate_race
293          ( p_effective_date => p_effective_date
294          , p_person_type_id => l_person_type_id
295          , p_race_code      => l_person_race
296          );
297 
298       hr_utility.set_location(l_proc,6);
299    END IF;
300 
301 END validate_person;
302 
303 END per_za_user_hook_pkg;