DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_ENTRY_API

Source


1 package body hr_entry_api as
2 /* $Header: pyentapi.pkb 120.20.12020000.5 2012/11/20 06:42:29 vmaripal ship $ */
3  --
4  -- Record defined to hold information about a entry element that is being
5  -- updated.
6  --
7  g_debug boolean := hr_utility.debug_enabled;
8  g_counter number;
9  --
10  type t_update_entry_rec is record
11    (cost_allocation_keyflex_id number,
12     updating_action_id         number,
13     updating_action_type       varchar2(30),
14     original_entry_id          number,
15     creator_type               varchar2(30),
16     comment_id                 number,
17     creator_id                 number,
18     reason                     varchar2(30),
19     subpriority                number,
20     date_earned                 date,
21     personal_payment_method_id  number,
22     attribute_category         varchar2(60),
23     attribute1                 varchar2(150),
24     attribute2                 varchar2(150),
25     attribute3                 varchar2(150),
26     attribute4                 varchar2(150),
27     attribute5                 varchar2(150),
28     attribute6                 varchar2(150),
29     attribute7                 varchar2(150),
30     attribute8                 varchar2(150),
31     attribute9                 varchar2(150),
32     attribute10                varchar2(150),
33     attribute11                varchar2(150),
34     attribute12                varchar2(150),
35     attribute13                varchar2(150),
36     attribute14                varchar2(150),
37     attribute15                varchar2(150),
38     attribute16                varchar2(150),
39     attribute17                varchar2(150),
40     attribute18                varchar2(150),
41     attribute19                varchar2(150),
42     attribute20                varchar2(150),
43     effective_start_date       date,
44     effective_end_date         date,
45     target_entry_id            number,
46     entry_type                 varchar2(30),
47     element_link_id            number,
48     assignment_id              number,
49     element_type_id            number,
50     processing_type            varchar2(30),
51     input_currency_code        varchar2(30),
52     output_currency_code       varchar2(30),
53     entry_information_category varchar2(30),
54     entry_information1         varchar2(150),
55     entry_information2         varchar2(150),
56     entry_information3         varchar2(150),
57     entry_information4         varchar2(150),
58     entry_information5         varchar2(150),
59     entry_information6         varchar2(150),
60     entry_information7         varchar2(150),
61     entry_information8         varchar2(150),
62     entry_information9         varchar2(150),
63     entry_information10        varchar2(150),
64     entry_information11        varchar2(150),
65     entry_information12        varchar2(150),
66     entry_information13        varchar2(150),
67     entry_information14        varchar2(150),
68     entry_information15        varchar2(150),
69     entry_information16        varchar2(150),
70     entry_information17        varchar2(150),
71     entry_information18        varchar2(150),
72     entry_information19        varchar2(150),
73     entry_information20        varchar2(150),
74     entry_information21        varchar2(150),
75     entry_information22        varchar2(150),
76     entry_information23        varchar2(150),
77     entry_information24        varchar2(150),
78     entry_information25        varchar2(150),
79     entry_information26        varchar2(150),
80     entry_information27        varchar2(150),
81     entry_information28        varchar2(150),
82     entry_information29        varchar2(150),
83     entry_information30        varchar2(150)
84 );
85  --
86  -- Record defined to hold information about a entry element that is being
87  -- removed.
88  --
89  type t_delete_entry_rec is record
90    (original_entry_id    number,
91     effective_start_date date,
92     effective_end_date   date,
93     assignment_id        number,
94     element_link_id      number,
95     entry_type           varchar2(30),
96     creator_type         varchar2(30),
97     creator_id           number,
98     target_entry_id      number,
99     element_type_id      number,
100     processing_type      varchar2(30),
101     non_payments_flag    varchar2(30),
102     personal_payment_method_id  number);
103  --
104  g_package      constant varchar2 (32) := 'hr_entry_api.';
105  g_override_user_ent_chk varchar2(1);
106 
107  -- Hold context variables for formula validation.  (Fix 1123084).
108  -- We do not need to hold the DATE_EARNED context as a variable
109  -- because it is available directly within the appropriate routine.
110  -- Also hold some other useful information.
111  type asg_info_r is record
112  (
113    assignment_id     number,
114    business_group_id number,
115    adj_ee_source     varchar2(30)
116  );
117  g_asg_info asg_info_r;
118  --
119  ------------------------------------------------------------------------------
120  -- Dave Harris, 01-Feb-1994, G590                                           --
121  --                                                                          --
122  -- NAME                                                                     --
123  -- hr_entry_api.element_entry_changed                      PRIVATE FUNCTION --
124  --                                                                          --
125  -- DESCRIPTION                                                              --
126  -- Determines if the entry to be updated will cause a change on either      --
127  -- the PAY_ELEMENT_ENTRIES_F or PAY_ELEMENT_ENTRY_VALUES_F tables.          --
128  -- If the entry is going to cause an update against either the              --
129  -- PAY_ELEMENT_ENTRIES_F or PAY_ELEMENT_ENTRY_VALUES_F attributes then the  --
130  -- return code will be true.                                                --
131  ------------------------------------------------------------------------------
132 --
133  function element_entry_changed
134  (
135   p_driving_date               in date,
136   p_element_entry_id           in number,
137   p_cost_allocation_keyflex_id in number,
138   p_updating_action_id         in number,
139   p_updating_action_type       in varchar2,
140   p_original_entry_id          in number,
141   p_creator_type               in varchar2,
142   p_comment_id                 in number,
143   p_creator_id                 in number,
144   p_reason                     in varchar2,
145   p_subpriority                in number,
146   p_date_earned                in date,
147   p_personal_payment_method_id in number,
148   p_attribute_category         in varchar2,
149   p_attribute1                 in varchar2,
150   p_attribute2                 in varchar2,
151   p_attribute3                 in varchar2,
152   p_attribute4                 in varchar2,
153   p_attribute5                 in varchar2,
154   p_attribute6                 in varchar2,
155   p_attribute7                 in varchar2,
156   p_attribute8                 in varchar2,
157   p_attribute9                 in varchar2,
158   p_attribute10                in varchar2,
159   p_attribute11                in varchar2,
160   p_attribute12                in varchar2,
161   p_attribute13                in varchar2,
162   p_attribute14                in varchar2,
163   p_attribute15                in varchar2,
164   p_attribute16                in varchar2,
165   p_attribute17                in varchar2,
166   p_attribute18                in varchar2,
167   p_attribute19                in varchar2,
168   p_attribute20                in varchar2,
169   p_num_entry_values           in number,
170   p_input_value_id_tbl         in hr_entry.number_table,
171   p_entry_value_tbl            in hr_entry.varchar2_table,
172 -- --
173   p_entry_information_category in varchar2,
174   p_entry_information1         in varchar2,
175   p_entry_information2         in varchar2,
176   p_entry_information3         in varchar2,
177   p_entry_information4         in varchar2,
178   p_entry_information5         in varchar2,
179   p_entry_information6         in varchar2,
180   p_entry_information7         in varchar2,
181   p_entry_information8         in varchar2,
182   p_entry_information9         in varchar2,
183   p_entry_information10        in varchar2,
184   p_entry_information11        in varchar2,
185   p_entry_information12        in varchar2,
186   p_entry_information13        in varchar2,
187   p_entry_information14        in varchar2,
188   p_entry_information15        in varchar2,
189   p_entry_information16        in varchar2,
190   p_entry_information17        in varchar2,
191   p_entry_information18        in varchar2,
192   p_entry_information19        in varchar2,
193   p_entry_information20        in varchar2,
194   p_entry_information21        in varchar2,
195   p_entry_information22        in varchar2,
196   p_entry_information23        in varchar2,
197   p_entry_information24        in varchar2,
198   p_entry_information25        in varchar2,
199   p_entry_information26        in varchar2,
200   p_entry_information27        in varchar2,
201   p_entry_information28        in varchar2,
202   p_entry_information29        in varchar2,
203   p_entry_information30        in varchar2
204  ) return boolean is
205 --
206   Cursor select_entry_value is
207     select  peev.input_value_id,
208             peev.screen_entry_value
209     from    pay_element_entry_values_f peev
210     where   peev.element_entry_id   = p_element_entry_id
211     and     p_driving_date
212     between peev.effective_start_date
213     and     peev.effective_end_date;
214    --
215    -- Local Variables
216    --
217    l_entry_changed      boolean         := false;
218    l_check_entry_values varchar2(10)    := 'N';
219    l_loop_counter       number          := 1;
220    --
221    -- Cursor returning variables
222    --
223    l_input_value_id     pay_element_entry_values_f.input_value_id%TYPE;
224    l_screen_entry_value pay_element_entry_values_f.screen_entry_value%TYPE;
225    --
226    -- Function error variables
227    --
228    l_appid              number          := 801;
229    l_proc_func_name     varchar2(60)    := 'hr_entry_api.element_entry_changed';
230    l_proc_func_error    varchar2(30)    := 'HR_6153_ALL_PROCEDURE_FAIL';
231    --
232  begin
233    --
234    -- Need to determine if the PAY_ELEMENT_ENTRIES_F table is being
235    -- updated with any new values.
236    -- If No change is being made against PAY_ELEMENT_ENTRIES_F we
237    -- then need to determine if any PAY_ELEMENT_ENTRY_VALUES_F are
238    -- being updated.
239    -- However, if a change is going to place against the PAY_ELEMENT_ENTRIES_F
240    -- table then we don't need to check against a change to the
241    -- PAY_ELEMENT_ENTRY_VALUES_F table.
242    --
243    if g_debug then
244       hr_utility.set_location(l_proc_func_name, 5);
245    end if;
246    begin
247      select  'Y'
248      into    l_check_entry_values
249      from    sys.dual
250      where   exists
251       (select  1
252        from    pay_element_entries_f pee
253        where   pee.element_entry_id     = p_element_entry_id
254        and     p_driving_date
255        between pee.effective_start_date
256        and     pee.effective_end_date
257        and     nvl(pee.cost_allocation_keyflex_id,hr_api.g_number) =
258                decode(p_cost_allocation_keyflex_id,
259                       hr_api.g_number, nvl(pee.cost_allocation_keyflex_id,hr_api.g_number),
260                          p_cost_allocation_keyflex_id)
261        and     nvl(pee.updating_action_id,hr_api.g_number) =
262                decode(p_updating_action_id,
263                       hr_api.g_number, nvl(pee.updating_action_id,hr_api.g_number), p_updating_action_id)
264        and     nvl(pee.updating_action_type,hr_api.g_varchar2) =
265                decode(p_updating_action_type,
266                       hr_api.g_varchar2, nvl(pee.updating_action_type,hr_api.g_varchar2), p_updating_action_type)
267        and     nvl(pee.original_entry_id,hr_api.g_number) =
268                decode(p_original_entry_id, hr_api.g_number, nvl(pee.original_entry_id,hr_api.g_number),
269                       p_original_entry_id)
270        and     pee.creator_type =
271                decode(p_creator_type, hr_api.g_varchar2, pee.creator_type, p_creator_type)
272        and     nvl(pee.comment_id,hr_api.g_number) =
273                decode(p_comment_id, hr_api.g_number, nvl(pee.comment_id,hr_api.g_number), p_comment_id)
274        and     nvl(pee.creator_id,hr_api.g_number) =
275                decode(p_creator_id, hr_api.g_number, nvl(pee.creator_id,hr_api.g_number), p_creator_id)
276        and     nvl(pee.reason,hr_api.g_varchar2) =
277                decode(p_reason, hr_api.g_varchar2, nvl(pee.reason,hr_api.g_varchar2), p_reason)
278        and     nvl(pee.subpriority,hr_api.g_number) =
279                decode(p_subpriority,
280                       hr_api.g_number, nvl(pee.subpriority,hr_api.g_number), p_subpriority)
281        and     nvl(pee.date_earned,hr_api.g_date) =
282                decode(p_date_earned,
283                       hr_api.g_date, nvl(pee.date_earned,hr_api.g_date), p_date_earned)
284        and     nvl(pee.personal_payment_method_id,hr_api.g_number) =
285                decode(p_personal_payment_method_id,
286                       hr_api.g_number, nvl(pee.personal_payment_method_id,hr_api.g_number), p_personal_payment_method_id)
287        and     nvl(pee.attribute_category, hr_api.g_varchar2) =
288                decode(p_attribute_category, hr_api.g_varchar2,
289                       nvl(pee.attribute_category,hr_api.g_varchar2),
290                       p_attribute_category)
291        and     nvl(pee.attribute1,hr_api.g_varchar2) =
292                decode(p_attribute1, hr_api.g_varchar2, nvl(pee.attribute1,hr_api.g_varchar2),
293                       p_attribute1)
294        and     nvl(pee.attribute2,hr_api.g_varchar2) =
295                decode(p_attribute2, hr_api.g_varchar2, nvl(pee.attribute2,hr_api.g_varchar2),
296                       p_attribute2)
297        and     nvl(pee.attribute3,hr_api.g_varchar2) =
298                decode(p_attribute3, hr_api.g_varchar2, nvl(pee.attribute3,hr_api.g_varchar2),
299                       p_attribute3)
300        and     nvl(pee.attribute4,hr_api.g_varchar2) =
301                decode(p_attribute4, hr_api.g_varchar2, nvl(pee.attribute4,hr_api.g_varchar2),
302                       p_attribute4)
303        and     nvl(pee.attribute5,hr_api.g_varchar2) =
304                decode(p_attribute5, hr_api.g_varchar2, nvl(pee.attribute5,hr_api.g_varchar2),
305                       p_attribute5)
306        and     nvl(pee.attribute6,hr_api.g_varchar2) =
307                decode(p_attribute6, hr_api.g_varchar2, nvl(pee.attribute6,hr_api.g_varchar2),
308                       p_attribute6)
309        and     nvl(pee.attribute7,hr_api.g_varchar2) =
310                decode(p_attribute7, hr_api.g_varchar2, nvl(pee.attribute7,hr_api.g_varchar2),
311                       p_attribute7)
312        and     nvl(pee.attribute8,hr_api.g_varchar2) =
313                decode(p_attribute8, hr_api.g_varchar2, nvl(pee.attribute8,hr_api.g_varchar2),
314                       p_attribute8)
315        and     nvl(pee.attribute9,hr_api.g_varchar2) =
316                decode(p_attribute9, hr_api.g_varchar2, nvl(pee.attribute9,hr_api.g_varchar2),
317                       p_attribute9)
318        and     nvl(pee.attribute10,hr_api.g_varchar2) =
319                decode(p_attribute10, hr_api.g_varchar2, nvl(pee.attribute10,hr_api.g_varchar2),
320                       p_attribute10)
321        and     nvl(pee.attribute11,hr_api.g_varchar2) =
322                decode(p_attribute11, hr_api.g_varchar2, nvl(pee.attribute11,hr_api.g_varchar2),
323                       p_attribute11)
324        and     nvl(pee.attribute12,hr_api.g_varchar2) =
325                decode(p_attribute12, hr_api.g_varchar2, nvl(pee.attribute12,hr_api.g_varchar2),
326                       p_attribute12)
327        and     nvl(pee.attribute13,hr_api.g_varchar2) =
328                decode(p_attribute13, hr_api.g_varchar2, nvl(pee.attribute13,hr_api.g_varchar2),
329                       p_attribute13)
330        and     nvl(pee.attribute14,hr_api.g_varchar2) =
331                decode(p_attribute14, hr_api.g_varchar2, nvl(pee.attribute14,hr_api.g_varchar2),
332                       p_attribute14)
333        and     nvl(pee.attribute15,hr_api.g_varchar2) =
334                decode(p_attribute15, hr_api.g_varchar2, nvl(pee.attribute15,hr_api.g_varchar2),
335                       p_attribute15)
336        and     nvl(pee.attribute16,hr_api.g_varchar2) =
337                decode(p_attribute16, hr_api.g_varchar2, nvl(pee.attribute16,hr_api.g_varchar2),
338                       p_attribute16)
339        and     nvl(pee.attribute17,hr_api.g_varchar2) =
340                decode(p_attribute17, hr_api.g_varchar2, nvl(pee.attribute17,hr_api.g_varchar2),
341                       p_attribute17)
342        and     nvl(pee.attribute18,hr_api.g_varchar2) =
343                decode(p_attribute18, hr_api.g_varchar2, nvl(pee.attribute18,hr_api.g_varchar2),
344                       p_attribute18)
345        and     nvl(pee.attribute19,hr_api.g_varchar2) =
346                decode(p_attribute19, hr_api.g_varchar2, nvl(pee.attribute19,hr_api.g_varchar2),
347                       p_attribute19)
348        and     nvl(pee.attribute20,hr_api.g_varchar2) =
349                decode(p_attribute20, hr_api.g_varchar2, nvl(pee.attribute20,hr_api.g_varchar2),
350                       p_attribute20)
351 -- --
352        and     nvl(pee.entry_information_category, hr_api.g_varchar2) =
353                decode(p_entry_information_category, hr_api.g_varchar2,
354                       nvl(pee.entry_information_category,hr_api.g_varchar2),
355                       p_entry_information_category)
356        and     nvl(pee.entry_information1,hr_api.g_varchar2) =
357                decode(p_entry_information1, hr_api.g_varchar2, nvl(pee.entry_information1,hr_api.g_varchar2),
358                       p_entry_information1)
359        and     nvl(pee.entry_information2,hr_api.g_varchar2) =
360                decode(p_entry_information2, hr_api.g_varchar2, nvl(pee.entry_information2,hr_api.g_varchar2),
361                       p_entry_information2)
362        and     nvl(pee.entry_information3,hr_api.g_varchar2) =
363                decode(p_entry_information3, hr_api.g_varchar2, nvl(pee.entry_information3,hr_api.g_varchar2),
364                       p_entry_information3)
365        and     nvl(pee.entry_information4,hr_api.g_varchar2) =
366                decode(p_entry_information4, hr_api.g_varchar2, nvl(pee.entry_information4,hr_api.g_varchar2),
367                       p_entry_information4)
368        and     nvl(pee.entry_information5,hr_api.g_varchar2) =
369                decode(p_entry_information5, hr_api.g_varchar2, nvl(pee.entry_information5,hr_api.g_varchar2),
370                       p_entry_information5)
371        and     nvl(pee.entry_information6,hr_api.g_varchar2) =
372                decode(p_entry_information6, hr_api.g_varchar2, nvl(pee.entry_information6,hr_api.g_varchar2),
373                       p_entry_information6)
374        and     nvl(pee.entry_information7,hr_api.g_varchar2) =
375                decode(p_entry_information7, hr_api.g_varchar2, nvl(pee.entry_information7,hr_api.g_varchar2),
376                       p_entry_information7)
377        and     nvl(pee.entry_information8,hr_api.g_varchar2) =
378                decode(p_entry_information8, hr_api.g_varchar2, nvl(pee.entry_information8,hr_api.g_varchar2),
379                       p_entry_information8)
380        and     nvl(pee.entry_information9,hr_api.g_varchar2) =
381                decode(p_entry_information9, hr_api.g_varchar2, nvl(pee.entry_information9,hr_api.g_varchar2),
382                       p_entry_information9)
383        and     nvl(pee.entry_information10,hr_api.g_varchar2) =
384                decode(p_entry_information10, hr_api.g_varchar2, nvl(pee.entry_information10,hr_api.g_varchar2),
385                       p_entry_information10)
386        and     nvl(pee.entry_information11,hr_api.g_varchar2) =
387                decode(p_entry_information11, hr_api.g_varchar2, nvl(pee.entry_information11,hr_api.g_varchar2),
388                       p_entry_information11)
389        and     nvl(pee.entry_information12,hr_api.g_varchar2) =
390                decode(p_entry_information12, hr_api.g_varchar2, nvl(pee.entry_information12,hr_api.g_varchar2),
391                       p_entry_information12)
392        and     nvl(pee.entry_information13,hr_api.g_varchar2) =
393                decode(p_entry_information13, hr_api.g_varchar2, nvl(pee.entry_information13,hr_api.g_varchar2),
394                       p_entry_information13)
395        and     nvl(pee.entry_information14,hr_api.g_varchar2) =
396                decode(p_entry_information14, hr_api.g_varchar2, nvl(pee.entry_information14,hr_api.g_varchar2),
397                       p_entry_information14)
398        and     nvl(pee.entry_information15,hr_api.g_varchar2) =
399                decode(p_entry_information15, hr_api.g_varchar2, nvl(pee.entry_information15,hr_api.g_varchar2),
400                       p_entry_information15)
401        and     nvl(pee.entry_information16,hr_api.g_varchar2) =
402                decode(p_entry_information16, hr_api.g_varchar2, nvl(pee.entry_information16,hr_api.g_varchar2),
403                       p_entry_information16)
404        and     nvl(pee.entry_information17,hr_api.g_varchar2) =
405                decode(p_entry_information17, hr_api.g_varchar2, nvl(pee.entry_information17,hr_api.g_varchar2),
406                       p_entry_information17)
407        and     nvl(pee.entry_information18,hr_api.g_varchar2) =
408                decode(p_entry_information18, hr_api.g_varchar2, nvl(pee.entry_information18,hr_api.g_varchar2),
409                       p_entry_information18)
410        and     nvl(pee.entry_information19,hr_api.g_varchar2) =
411                decode(p_entry_information19, hr_api.g_varchar2, nvl(pee.entry_information19,hr_api.g_varchar2),
412                       p_entry_information19)
413        and     nvl(pee.entry_information20,hr_api.g_varchar2) =
414                decode(p_entry_information20, hr_api.g_varchar2, nvl(pee.entry_information20,hr_api.g_varchar2),
415                       p_entry_information20)
416        and     nvl(pee.entry_information21,hr_api.g_varchar2) =
417                decode(p_entry_information21, hr_api.g_varchar2, nvl(pee.entry_information21,hr_api.g_varchar2),
418                       p_entry_information21)
419        and     nvl(pee.entry_information22,hr_api.g_varchar2) =
420                decode(p_entry_information22, hr_api.g_varchar2, nvl(pee.entry_information22,hr_api.g_varchar2),
421                       p_entry_information22)
422        and     nvl(pee.entry_information23,hr_api.g_varchar2) =
423                decode(p_entry_information23, hr_api.g_varchar2, nvl(pee.entry_information23,hr_api.g_varchar2),
424                       p_entry_information23)
425        and     nvl(pee.entry_information24,hr_api.g_varchar2) =
426                decode(p_entry_information24, hr_api.g_varchar2, nvl(pee.entry_information24,hr_api.g_varchar2),
427                       p_entry_information24)
428        and     nvl(pee.entry_information25,hr_api.g_varchar2) =
429                decode(p_entry_information25, hr_api.g_varchar2, nvl(pee.entry_information25,hr_api.g_varchar2),
430                       p_entry_information25)
431        and     nvl(pee.entry_information26,hr_api.g_varchar2) =
432                decode(p_entry_information26, hr_api.g_varchar2, nvl(pee.entry_information26,hr_api.g_varchar2),
433                       p_entry_information26)
434        and     nvl(pee.entry_information27,hr_api.g_varchar2) =
435                decode(p_entry_information27, hr_api.g_varchar2, nvl(pee.entry_information27,hr_api.g_varchar2),
436                       p_entry_information27)
437        and     nvl(pee.entry_information28,hr_api.g_varchar2) =
438                decode(p_entry_information28, hr_api.g_varchar2, nvl(pee.entry_information28,hr_api.g_varchar2),
439                       p_entry_information28)
440        and     nvl(pee.entry_information29,hr_api.g_varchar2) =
441                decode(p_entry_information29, hr_api.g_varchar2, nvl(pee.entry_information29,hr_api.g_varchar2),
442                       p_entry_information29)
443        and     nvl(pee.entry_information30,hr_api.g_varchar2) =
444                decode(p_entry_information30, hr_api.g_varchar2, nvl(pee.entry_information30,hr_api.g_varchar2),
445                       p_entry_information30)
446 );
447    exception
448      When NO_DATA_FOUND then
449        null;
450    end;
451    --
452    -- If the entry record to be updated is not updating any of
453    -- the PAY_ELEMENT_ENTRIES_F attributes then we must check to
454    -- see if any of the PAY_ELEMENT_ENTRY_VALUES_F are to be
455    -- updated.
456    --
457    if (l_check_entry_values = 'Y') then
458      --
459      -- for each entry value ensure that the input_value_id and
460      -- screen_entry_value from the respective pl/sql tables
461      -- match the PAY_ELEMENT_ENTRY_VALUES_F.
462      --
463      open select_entry_value;
464      while (NOT l_entry_changed) loop
465        --
466        if g_debug then
467           hr_utility.set_location(l_proc_func_name, 10);
468        end if;
469        --
470        -- fetch a row from the select_entry_value cursor returning the
471        -- input_value_id and screen_entry_value
472        --
473        fetch select_entry_value into l_input_value_id, l_screen_entry_value;
474        exit when select_entry_value%NOTFOUND;
475        --
476        -- Having returned the l_input_value_id and l_screen_entry_value
477        -- from the select_entry_value cursor we must iterate through the
478        -- p_input_value_id_tbl until a match has occurred with the
479        -- l_input_value_id. Having the match, we must ensure that the
480        -- p_entry_value_tbl screen_entry_value matches the l_screen_entry_value.
481        -- If the match does NOT occur then an update must be taking place and
482        -- the loop must be terminated.
483        -- NOTE: The use if the nvl() function is used to ensure that the
484        --       entry_value match does not fail if either the pl/sql table
485        --       entry_value or l_screen_entry_value is null.
486        --       The nvl() function is NOT used on the input_value_id as this
487        --       is always mandatory.
488        --
489        <<inner_loop>>
490        for l_loop_counter in 1..p_num_entry_values loop
491          if ((p_input_value_id_tbl(l_loop_counter) = l_input_value_id)    and
492              (nvl(p_entry_value_tbl(l_loop_counter),hr_api.g_varchar2) <>
493               nvl(l_screen_entry_value,hr_api.g_varchar2))) then
494            --
495            -- As the screen_entry_value attribute of PAY_ELEMENT_ENTRY_VALUES_F
496            -- is going to be updated set the returning function code to true.
497            --
498            l_entry_changed := true;
499            exit inner_loop;
500          end if;
501        end loop;
502      end loop;
503      close select_entry_value;
504    else
505      --
506      -- The entry is being updated on the PAY_ELEMENT_ENTRIES_F table
507      -- therefore set the returning function code to true.
508      --
509      l_entry_changed := true;
510    end if;
511    --
512    return(l_entry_changed);
513    --
514  end element_entry_changed;
515  --
516  ------------------------------------------------------------------------------
517  -- NAME                                                                     --
518  -- hr_entry_api.set_formula_contexts                       PRIVATE FUNCTION --
519  --                                                                          --
520  -- DESCRIPTION                                                              --
521  --
522  -- Called to cache some (global) information about the assignment passed.   --
523  -- Originally meant to support input value validation formula, it is now    --
524  -- used more widely.  Search for uses of g_asg_info to see more.            --
525  -- The now somewhat misleading name name has been retained because          --
526  -- this procedure is called from hr_dynsql and changing this would          --
527  -- require C chain dependencies that we would rather avoid.                 --
528  ------------------------------------------------------------------------------
529 --
530  procedure set_formula_contexts
531  (
532   p_assignment_id  number,
533   p_effective_date date
534  ) is
535    begin
536    g_debug := hr_utility.debug_enabled;
537    -- Check whether the business_group_id has been set and
538    -- re-fetch if necessary.
539    if(g_asg_info.business_group_id is null or
540       g_asg_info.assignment_id is null or
541       p_assignment_id <> g_asg_info.assignment_id)
542    then
543       if g_debug then
544          hr_utility.trace('Cache assignment info');
545       end if;
546 
547       g_asg_info.assignment_id := p_assignment_id;
548 
549       select ASG.business_group_id
550       into   g_asg_info.business_group_id
551       from   per_all_assignments_f ASG
552       where  ASG.assignment_id = p_assignment_id
553         and  p_effective_date between
554              ASG.effective_start_date and ASG.effective_end_date;
555 
556       if(g_asg_info.adj_ee_source is null) then
557          -- Obtain ADJUSTMENT_EE_SOURCE legislation rule.  This
558          -- needed in a couple of places.
559          -- Realise that this is not strictly an assignment
560          -- level value, but convenient to get it here.
561          begin
562          select plr.rule_mode
563          into   g_asg_info.adj_ee_source
564          from   pay_legislation_rules plr,
565                 per_business_groups   pbg
566          where pbg.business_group_id = g_asg_info.business_group_id
567          and   pbg.legislation_code  = plr.legislation_code
568          and   plr.rule_type         = 'ADJUSTMENT_EE_SOURCE';
569          exception
570             when no_data_found then g_asg_info.adj_ee_source := 'A';
571          end;
572 
573          if g_debug then
574             hr_utility.trace('ADJUSTMENT_EE_SOURCE ' || g_asg_info.adj_ee_source);
575          end if;
576       end if;
577 
578    end if;
579  end set_formula_contexts;
580 --
581  ------------------------------------------------------------------------------
582  -- NAME                                                                     --
583  -- hr_entry_api.run_validation_formula                     PRIVATE FUNCTION --
584  --                                                                          --
585  -- DESCRIPTION                                                              --
586  --
587  -- Calls input validation formula to check entry value.
588  ------------------------------------------------------------------------------
589 --
590  procedure run_validation_formula
591  (
592   p_formula_id       number,
593   p_session_date     date,
594   p_entry_value      varchar2,
595   p_warning_or_error varchar2
596  ) is
597    v_inputs           ff_exec.inputs_t;
598    v_outputs          ff_exec.outputs_t;
599    v_formula_message  varchar2(2000);
600    v_formula_status   varchar2(10);
601  begin
602    -- We need to call a formula to validate the entry value.
603    ff_exec.init_formula(p_formula_id, p_session_date, v_inputs, v_outputs);
604    --
605    -- Bug 2142799 : although it would not be very useful,
606    -- it's possible that someone might write a validation
607    -- formula without inputs or needing contexts.
608    -- Rather than fail, we check the input count before
609    -- attempting to set the input and context values.
610    if(v_inputs.count >= 1) then
611       if g_debug then
612          hr_utility.trace('Inputs / contexts : ' || v_inputs.count);
613       end if;
614       --
615       -- Set up the inputs and contexts to formula.
616       for i in v_inputs.first..v_inputs.last loop
617          if v_inputs(i).name = 'ASSIGNMENT_ID' then
618             -- Set the assignment_id context.
619             v_inputs(i).value := to_char(g_asg_info.assignment_id);
620          elsif v_inputs(i).name = 'BUSINESS_GROUP_ID' then
621             -- Set the business_group_id context.
622             v_inputs(i).value := to_char(g_asg_info.business_group_id);
623          elsif v_inputs(i).name = 'DATE_EARNED' then
624             -- Set the business_group_id context.
625             v_inputs(i).value := fnd_date.date_to_canonical(p_session_date);
626          elsif v_inputs(i).name = 'ENTRY_VALUE' then
627             -- Set the input to the entry value to be validated.
628             -- Note - need to pass database format to formula.
629             v_inputs(i).value := p_entry_value;
630          else
631             -- No context recognised.
632             hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
633             hr_utility.set_message_token('PROCEDURE',
634                                          'hr_entry_api.run_validation_formula');
635             hr_utility.set_message_token('STEP','10');
636             hr_utility.raise_error;
637          end if;
638       end loop;
639    end if;
640    --
641    ff_exec.run_formula(v_inputs, v_outputs);
642    --
643    -- Now obtain the return values.  There should be
644    -- exactly two outputs.
645    if v_outputs.count <> 2 then
646       hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
647       hr_utility.set_message_token('PROCEDURE',
648                                    'hr_entry_api.run_validation_formula');
649       hr_utility.set_message_token('STEP','20');
650       hr_utility.raise_error;
651    end if;
652    --
653    for i in v_outputs.first..v_outputs.last loop
654       if v_outputs(i).name = 'FORMULA_MESSAGE' then
655          --
656          v_formula_message := v_outputs(i).value;
657       elsif v_outputs(i).name = 'FORMULA_STATUS' then
658          --
659          v_formula_status := upper(v_outputs(i).value);
660       else
661          hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
662          hr_utility.set_message_token('PROCEDURE',
663                                       'hr_entry_api.run_validation_formula');
664          hr_utility.set_message_token('STEP','30');
665          hr_utility.raise_error;
666       end if;
667    end loop;
668    --
669    -- Check whether we have raised an error and act appropriately.
670    if v_formula_status <> 'S' and p_warning_or_error = 'E' then
671       -- I.e. the formula validation failed and we need to raise an error.
672       if v_formula_message is null then
673          -- User not defined an error message.
674          fnd_message.set_name ('PAY', 'HR_6648_ELE_ENTRY_FORMULA_ERR');
675          hr_utility.raise_error;
676       else
677          -- User has defined message and so we can raise it.
678          fnd_message.set_name ('PAY','HR_ELE_ENTRY_FORMULA_HINT');
679          fnd_message.set_token ('FORMULA_TEXT', v_formula_message, false);
680          hr_utility.raise_error;
681       end if;
682    elsif v_formula_status <> 'S' and p_warning_or_error = 'W' then
683       -- We have failed validation, but only want to warn.
684       if v_formula_message is null then
685          -- User not defined an error message.
686          fnd_message.set_name ('PAY', 'HR_6648_ELE_ENTRY_FORMULA_ERR');
687          hr_utility.set_warning;
688       else
689          -- User has defined message and so we can raise it.
690          fnd_message.set_name ('PAY','HR_ELE_ENTRY_FORMULA_HINT');
691          fnd_message.set_token ('FORMULA_TEXT', v_formula_message, false);
692          hr_utility.set_warning;
693       end if;
694    end if;
695  end run_validation_formula;
696 --
697  ------------------------------------------------------------------------------
698  -- NAME                                                                     --
699  -- hr_entry.validate_entry_value                                            --
700  --                                                                          --
701  -- DESCRIPTION                                                              --
702  -- Validates and converts an entry value to DB format.                      --
703  --                                                                          --
704  -- Note: for benefit entries p_session_date needs to be passed to this      --
705  --       procedure or row has to exists in fnd_sessions.                    --
706  --       Otherwise sysdate will be used for coverage level validation.      --
707  ------------------------------------------------------------------------------
708 --
709  procedure validate_entry_value
710  (
711   p_element_link_id     number,
712   p_input_value_id      number,
713   p_session_date        date,
714   p_screen_format       in out nocopy varchar2,
715   p_db_format           in out nocopy varchar2,
716   p_lookup_type         varchar2,
717   p_uom                 varchar2,
718   p_input_currency_code varchar2,
719   p_value_set_id        number default null
720  ) is
721    --
722    -- Make sure that the value is valid for the lookup type.
723    --
724    cursor csr_valid_lookup
725           (
726            p_lookup_type varchar2,
727            p_meaning     varchar2
728           ) is
729        select HL.lookup_code
730        from   hr_lookups HL
731        where  HL.lookup_type = p_lookup_type
732          and  HL.meaning     = p_meaning;
733    --
734    -- Cursor that checks to make sure that the coverage level for a benefit
735    -- element entry is valid for the benefit type.
736    --
737    cursor csr_valid_coverage_level
738           (
739            p_input_value_id number,
740            p_lookup_code    varchar2,
741            v_session_date   date
742           ) is
743      select IV.input_value_id
744      from   pay_element_types_f         ET,
745             pay_input_values_f          IV,
746             ben_benefit_classifications BCL
747      where  IV.input_value_id             = p_input_value_id
748        and  IV.name                       = 'Coverage'
749        and  ET.element_type_id            = IV.element_type_id
750        and  BCL.benefit_classification_id = ET.benefit_classification_id
751        and  BCL.contributions_used        = 'Y'
752        and  not exists (select null
753                         from   ben_benefit_contributions_f BCO
754                         where  BCO.element_type_id = ET.element_type_id
755                           and  BCO.coverage_type   = p_lookup_code
756                           and  v_session_date between BCO.effective_start_date
757                                                   and BCO.effective_end_date);
758    --
759    -- bug 372339, 604543 and 651458 mlisieck/09.01.1998/07.04.1998
760    --
761    cursor csr_benefit_entry is
762      select input_value_id
763      from pay_input_values_f
764      where input_value_id = p_input_value_id and
765            name = 'Coverage';
766    --
767    cursor csr_session_date is
768      select effective_date
769      from fnd_sessions
770      where session_id = userenv('sessionid');
771    --
772    cursor csr_val_fmla is
773      select piv.formula_id
774      from pay_input_values_f piv
775      where piv.input_value_id = p_input_value_id
776        and p_session_date between piv.effective_start_date
777                               and piv.effective_end_date;
778    --
779    -- Local Variables
780    --
781    v_lookup_code      varchar2(30);
782    v_value_set_value  varchar2(60);
783    v_min_max_failure  varchar2(1);
784    v_warning_or_error varchar2(30);
785    v_minimum_value    varchar2(60);
786    v_maximum_value    varchar2(60);
787    --v_db_format      varchar2(60);
788    v_db_format        varchar2(80);
789    -- v_screen_format varchar2(60);
790    -- Enhancement 2793978
791    -- size of v_screen_format increased to deal with screen format of
792    -- value set validated entry values.
793    v_screen_format    varchar2(240);
794    v_hot_defaulted    boolean := false;
795    v_dummy            number;
796    -- bug 604543
797    v_session_date     date;
798    --
799    v_formula_id       number;
800    v_formula_profile  varchar2(30);   -- User profile value.
801    --
802  begin
803    g_debug := hr_utility.debug_enabled;
804    --
805    -- Need to determine the defaulted value of the entry value.
806    --
807    hr_entry.derive_default_value
808      (p_element_link_id,
809       p_input_value_id,
810       p_session_date,
811       p_input_currency_code,
812       'DEF',
813       v_screen_format,
814       v_db_format);
815    --
816    -- If the screen format value is defaulted then set the p_db_format
817    -- value to the return v_db_format value.
818    --
819    if ((p_screen_format = v_screen_format) and
820        (v_db_format is null)) then
821      p_db_format := v_db_format;
822      v_hot_defaulted := true;
823    end if;
824    --
825    -- Value is not validated using lookups so make sure that the value is in a
826    -- correct format for its data type ie. 'ABCDE' would not be valid for an
827    -- integer entry value, etc...
828    --
829    if (p_lookup_type is null and
830        p_value_set_id is null and
831        NOT v_hot_defaulted) then
832      --
833      hr_entry.check_format
834        (p_element_link_id,
835         p_input_value_id,
836         p_session_date,
837         p_screen_format,
838         p_db_format,
839         'Y',
840         v_min_max_failure,
841         v_warning_or_error,
842         v_minimum_value,
843         v_maximum_value);
844      --
845      -- if the warning_or_error flag has been set to 'Error' then Error
846      -- and stop procesing
847      --
848      if v_min_max_failure = 'F' and v_warning_or_error = 'E' then
849        hr_utility.set_message(801, 'PAY_6303_INPUT_VALUE_OUT_RANGE');
850        hr_utility.raise_error;
851      end if;
852      --
853      -- ******* Added this to fix bug 421842 **********
854      -- if the warning_or_error flag has been set to 'Error' then only Warn
855      -- but let the processing continue
856      --
857       if v_min_max_failure = 'F' and v_warning_or_error = 'W' then
858         hr_utility.set_message(801, 'PAY_6303_INPUT_VALUE_OUT_RANGE');
859         hr_utility.set_warning;
860       end if;
861      --
862      -- Check whether we need to perform formula validation.
863      open csr_val_fmla;
864      fetch csr_val_fmla into v_formula_id;
865      close csr_val_fmla;
866      --
867      -- Allow a user to switch off in emergency.
868      fnd_profile.get('PAY_NO_IV_FMLA_VALIDATION', v_formula_profile);
869      if (v_formula_profile is null and p_db_format is not null and
870          v_formula_id is not null) then
871         run_validation_formula (v_formula_id, p_session_date,
872                                 p_db_format, v_warning_or_error);
873      end if;
874    --
875    --
876    -- Value is validated using lookups.
877    --
878    elsif (p_lookup_type   is not null and
879           p_screen_format is not null and
880           NOT v_hot_defaulted) then
881      --
882      -- Make sure value is valid according to the lookup type NB. the meaning
883      -- is being checked.
884      --
885      open csr_valid_lookup(p_lookup_type,p_screen_format);
886      fetch csr_valid_lookup into v_lookup_code;
887      if csr_valid_lookup%notfound then
888        close csr_valid_lookup;
889        hr_utility.set_message(801, 'HR_7033_ELE_ENTRY_LKUP_INVLD');
890        hr_utility.set_message_token('LOOKUP_TYPE',p_lookup_type);
891        hr_utility.raise_error;
892      end if;
893      close csr_valid_lookup;
894      --
895      -- If the element entry is used for benefit processing and the input
896      -- value being checked is 'Coverage' then the value must be one of the
897      -- valid coverage types for the particular benefit type ie. each benefit
898      -- type uses a subset of all the valid coverage types.
899      --
900      -- added if statement below to limit number of checks, especialy after the bug fix below.
901      --
902      open csr_benefit_entry;
903      fetch csr_benefit_entry into v_dummy;
904      --
905      if csr_benefit_entry%found then
906        --
907        -- bug 372339, 604543 and 651458
908        --
909        if g_debug then
910           hr_utility.trace('p_lookup_code: ' || v_lookup_code);
911        end if;
912 
913        v_session_date := p_session_date;
914 
915        -- bugfix 1273798
916        --if v_session_date = null then
917        if v_session_date is null then
918          open csr_session_date;
919          fetch csr_session_date into v_session_date;
920          close csr_session_date;
921        end if;
922 
923        if g_debug then
924           hr_utility.trace('v_session_date: ' || fnd_date.date_to_canonical(v_session_date));
925        end if;
926 
927        -- bugfix 1273798
928        --if v_session_date = null then
929        if v_session_date is null then
930 
931          close csr_benefit_entry;
932          hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
933          hr_utility.set_message_token('PROCEDURE','hr_entry_api.validate_entry_value');
934          hr_utility.set_message_token('STEP','10');
935          hr_utility.raise_error;
936 
937        end if;
938 
939        open csr_valid_coverage_level(p_input_value_id,v_lookup_code,TRUNC(v_session_date));
940        fetch csr_valid_coverage_level into v_dummy;
941        if csr_valid_coverage_level%found then
942          close csr_valid_coverage_level;
943          hr_utility.set_message(801, 'HR_7437_BEN_COVERAGE_INVLD');
944          hr_utility.raise_error;
945        end if;
946        if g_debug then
947           hr_utility.trace('valid_coverage_level_found ' || v_dummy);
948        end if;
949        close csr_valid_coverage_level;
950 
951      end if;
952      --
953      close csr_benefit_entry;
954      --
955      p_db_format := v_lookup_code;
956      --
957    elsif (p_value_set_id is not null and p_screen_format is not null and
958      not v_hot_defaulted) then
959      --
960      -- Enhancement 2793978
961      -- Value is validated using value sets.
962      -- Derive the database format.
963      --
964      v_value_set_value := pay_input_values_pkg.decode_vset_meaning(
965        p_value_set_id, p_screen_format);
966      --
967      if v_value_set_value is null then
968        --
969        -- The screen format was invalid, raise an error
970        --
971        hr_utility.set_message(800, 'HR_34927_ELE_ENTRY_VSET_INVLD');
972        hr_utility.raise_error;
973        --
974      end if;
975      --
976      p_db_format := v_value_set_value;
977      --
978    end if;
979    --
980  end validate_entry_value;
981 --
982  ------------------------------------------------------------------------------
983  -- NAME
984  --   hr_entry_api.chk_user_enterable
985  --
986  -- DESCRIPTION
987  --   additional validation on User Enterable IV_IDs and associated EVs,
988  --   preconditions, only called if creator type in forms or MIX and the
989  --   IV_ID being processed is User Enterable and its associated EV is
990  --   not null
991  ------------------------------------------------------------------------------
992 --
993 PROCEDURE chk_user_enterable(
994   p_el_id               IN NUMBER,
995   p_lookup_type         IN VARCHAR2,
996   p_value_set_id        IN NUMBER,
997   p_uom                 IN VARCHAR2,
998   p_default_value       IN VARCHAR2,
999   p_input_currency_code IN VARCHAR2,
1000   p_session_date        IN DATE,
1001   p_iv_id               IN NUMBER,
1002   p_ev                  IN OUT NOCOPY VARCHAR2,
1003   p_creator_type        IN VARCHAR2,
1004   p_mode                IN VARCHAR2 default 'I',
1005   p_hot_flag            IN VARCHAR2)
1006   IS
1007   --
1008   --
1009   l_default             VARCHAR2(80);
1010   l_screen_fmt_value    VARCHAR2(80);
1011   l_db_fmt_value        VARCHAR2(80);
1012   --
1013   --
1014 BEGIN
1015   if g_debug then
1016      hr_utility.trace('> hr_entry_api.chk_user_enterable');
1017      hr_utility.trace('| p_el_id>'               || p_el_id || '<');
1018      hr_utility.trace('| p_lookup_type>'         || p_lookup_type || '<');
1019      hr_utility.trace('| p_value_set_id>'        || p_value_set_id || '<');
1020      hr_utility.trace('| p_default_value>'       || p_default_value || '<');
1021      hr_utility.trace('| p_input_currency_code>' || p_input_currency_code || '<');
1022      hr_utility.trace('| p_session_date>'        || p_session_date || '<');
1023      hr_utility.trace('| p_iv_id>'               || p_iv_id || '<');
1024      hr_utility.trace('| p_ev>'                  || p_ev || '<');
1025   end if;
1026   --
1027   -- Only convert the format if it is an Insert call.
1028   --
1029   IF p_mode = 'I' THEN
1030     --
1031     -- if IV_ID has an associated lookup then find the
1032     -- associated meaning,
1033     -- else just return the default from the PLIV
1034     --
1035     -- Bugfix 2288865:
1036     -- Ensure both p_lookup_type AND p_default_value are not null
1037     -- before attempting to retrieve the corresponding meaning
1038     --
1039     IF p_lookup_type IS NOT NULL AND p_default_value IS NOT NULL THEN
1040       BEGIN
1041       SELECT h.meaning
1042         INTO   l_default
1043         FROM   HR_LOOKUPS h
1044         WHERE  h.lookup_type = p_lookup_type
1045         and    h.lookup_code = p_default_value
1046         ;
1047       EXCEPTION
1048       WHEN NO_DATA_FOUND THEN
1049         hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
1050         hr_utility.set_message_token('PROCEDURE',
1051                                       'hr_entry_api.chk_user_enterable');
1052         hr_utility.set_message_token('STEP','1');
1053         hr_utility.raise_error;
1054       END;
1055       --
1056     ELSE
1057       --
1058       -- need to convert the default stored on the db into
1059       -- screen format,
1060       -- return default screen and database formatted values in either a cold
1061       -- or hot format for the specified EL and IV
1062       --
1063       hr_entry.derive_default_value(
1064         p_element_link_id       => p_el_id,
1065         p_input_value_id        => p_iv_id,
1066         p_session_date          => p_session_date,
1067         p_input_currency_code   => p_input_currency_code,
1068         v_screen_format_value   => l_screen_fmt_value,
1069         v_database_format_value => l_db_fmt_value);
1070       --
1071       --
1072       if g_debug then
1073          hr_utility.trace('| l_screen_fmt_value>' || l_screen_fmt_value || '<');
1074          hr_utility.trace('| l_db_fmt_value>' || l_db_fmt_value || '<');
1075       end if;
1076       --
1077       l_default := l_screen_fmt_value;
1078     END IF;
1079     --
1080     IF p_hot_flag = 'Y' AND p_ev is null THEN
1081        l_default := NULL;
1082     END IF;
1083     --
1084     --
1085   ELSE
1086     -- The passed value is in the db format.
1087     -- Now format the required valued to the display value required.
1088     -- If the value is a lookup then we must select the meaning from the
1089     -- lookup table.
1090     --
1091        if (p_lookup_type is not null      and
1092            p_default_value is not null) then
1093          begin
1094            select h.meaning
1095            into   l_default
1096            from   hr_lookups h
1097            where  h.lookup_type = p_lookup_type
1098            and    h.lookup_code = p_default_value;
1099          exception
1100            when NO_DATA_FOUND then
1101              hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
1102              hr_utility.set_message_token('PROCEDURE',
1103                                            'hr_entry_api.chk_user_enterable');
1104              hr_utility.set_message_token('STEP','2');
1105              hr_utility.raise_error;
1106          end;
1107     --
1108     -- Bugfix 5555289
1109     -- If the input value uses a value set for validation then derive the
1110     -- default value accordingly...
1111     --
1112        elsif (p_value_set_id is not null and
1113               p_default_value is not null) then
1114          --
1115          l_default := pay_input_values_pkg.decode_vset_value ( p_value_set_id, p_default_value );
1116          --
1117          if l_default is null then
1118            --
1119            -- The p_default_value was invalid, raise an error
1120            --
1121            hr_utility.set_message(800, 'HR_34927_ELE_ENTRY_VSET_INVLD');
1122            hr_utility.raise_error;
1123            --
1124          end if;
1125          --
1126        else
1127          l_default := hr_chkfmt.changeformat(p_default_value, p_uom, p_input_currency_code);
1128        end if;
1129     --
1130     --
1131   END IF;
1132 
1133   if g_debug then
1134      hr_utility.trace('| l_default>' || l_default || '<');
1135   end if;
1136   --
1137 
1138   IF g_override_user_ent_chk = 'Y' THEN
1139      -- p_ev:=l_default;
1140      NULL;
1141   ELSE
1142      --
1143      -- Check non-user enterable will no longer raise error, instead it will
1144      -- use the default value (for insert) or existing value (for update).
1145      --
1146 
1147      IF (l_default IS NOT NULL AND p_ev IS NOT NULL AND p_ev = l_default) OR (l_default IS NULL AND p_ev IS NULL) THEN
1148 
1149        if g_debug then
1150           hr_utility.trace('| EV specified matches value on EL, ok');
1151        end if;
1152 
1153      ELSIF l_default IS NOT NULL AND p_ev IS NOT NULL AND p_ev <> l_default THEN
1154        --
1155        -- API can 'update' a default as specified on EL,
1156        -- therefore default is not null, forms cannot do this
1157        --
1158        if g_debug then
1159           hr_utility.trace('| EV does not match the default value stored on PLIV');
1160        end if;
1161        -- hr_utility.set_message (800, 'PAY_50380_INPVAL_NOT_UPDATABLE');
1162        -- hr_utility.raise_error;
1163 
1164      ELSE
1165        --
1166        -- if there is no default value to compare against (an EV
1167        -- value has been specified), then raise error as it is invalid
1168        -- for the API to 'set' a value for a non User Enterable IV,
1169        -- forms cannot do this
1170        --
1171        if g_debug then
1172           hr_utility.trace('| EV specified');
1173        end if;
1174        -- hr_utility.set_message (800, 'PAY_50381_INPVAL_NOT_ENTERABLE');
1175        -- hr_utility.raise_error;
1176      END IF;
1177 
1178 	p_ev := l_default;
1179      --
1180      --
1181   END IF;
1182   --
1183   if g_debug then
1184      hr_utility.trace('< hr_entry_api.chk_user_enterable');
1185   end if;
1186 END chk_user_enterable;
1187 --
1188  ------------------------------------------------------------------------------
1189  -- NAME                                                                     --
1190  -- hr_entry_api.conv_entry_values_to_table                                  --
1191  --                                                                          --
1192  -- DESCRIPTION                                                              --
1193  -- Converts a set of predefined parameters containing the INPUT_VALUE_IDs   --
1194  -- and SCREEN_ENTRY_VALUEs for an element entry to a pair of PLSQL tables   --
1195  -- containing the same information. It also returns the number of entry     --
1196  -- values.                                                                  --
1197  ------------------------------------------------------------------------------
1198 --
1199  procedure conv_entry_values_to_table
1200  (
1201   p_iv_format          varchar2,
1202   p_element_entry_id   number,
1203   p_element_link_id    number,
1204   p_session_date       date,
1205   p_creator_type       varchar2,
1206   p_entry_type         varchar2,
1207   p_input_value_id1    number,
1208   p_input_value_id2    number,
1209   p_input_value_id3    number,
1210   p_input_value_id4    number,
1211   p_input_value_id5    number,
1212   p_input_value_id6    number,
1213   p_input_value_id7    number,
1214   p_input_value_id8    number,
1215   p_input_value_id9    number,
1216   p_input_value_id10   number,
1217   p_input_value_id11   number,
1218   p_input_value_id12   number,
1219   p_input_value_id13   number,
1220   p_input_value_id14   number,
1221   p_input_value_id15   number,
1222   p_entry_value1       varchar2,
1223   p_entry_value2       varchar2,
1224   p_entry_value3       varchar2,
1225   p_entry_value4       varchar2,
1226   p_entry_value5       varchar2,
1227   p_entry_value6       varchar2,
1228   p_entry_value7       varchar2,
1229   p_entry_value8       varchar2,
1230   p_entry_value9       varchar2,
1231   p_entry_value10      varchar2,
1232   p_entry_value11      varchar2,
1233   p_entry_value12      varchar2,
1234   p_entry_value13      varchar2,
1235   p_entry_value14      varchar2,
1236   p_entry_value15      varchar2,
1237   p_num_entry_values   out nocopy number,
1238   p_input_value_id_tbl out nocopy hr_entry.number_table,
1239   p_entry_value_tbl    out nocopy hr_entry.varchar2_table
1240  ) is
1241    --
1242    -- Local variables
1243    --
1244    --v_screen_format     varchar2(60);
1245    v_screen_format       varchar2(240);
1246    --v_db_format         varchar2(60);
1247    v_db_format           varchar2(240);
1248    v_range_flag          varchar2(1);
1249    v_count               number := 0;
1250    v_input_value_id      number;
1251    v_input_currency_code varchar2(30);
1252    v_entry_value         varchar2(30);
1253    v_input_value_id_tbl  hr_entry.number_table;
1254    v_entry_value_tbl     hr_entry.varchar2_table;
1255    --
1256    -- Selects all the link input values for a specified element link. Each one
1257    -- retrieved is compared with the entry values specified by the user. If it
1258    -- has been specified by the user then the value for the entry value is
1259    -- set to the users value and a flag is set to indicate this has happened.
1260    -- If the user has not set a value for it then the entry value is set to
1261    -- null.
1262    --
1263    cursor csr_link_input_value
1264           (
1265            p_element_link_id number,
1266            p_session_date    date
1267           ) is
1268      select /*+ ORDERED
1269                 INDEX(pliv PAY_LINK_INPUT_VALUES_F_N1)
1270                 INDEX(piv PAY_INPUT_VALUES_F_PK)
1271                 INDEX(et PAY_ELEMENT_TYPES_F_PK)
1272                 USE_NL(PLIV ET PIV) */
1273             pliv.input_value_id,
1274             pliv.default_value      pliv_default_value,
1275             piv.hot_default_flag,
1276             piv.lookup_type,
1277             piv.value_set_id,
1278             piv.uom,
1279             piv.mandatory_flag,
1280             piv.default_value       piv_default_value,
1281             et.input_currency_code,
1282             decode(pliv.input_value_id,
1283                      p_input_value_id1,p_entry_value1,
1284                      p_input_value_id2,p_entry_value2,
1285                      p_input_value_id3,p_entry_value3,
1286                      p_input_value_id4,p_entry_value4,
1287                      p_input_value_id5,p_entry_value5,
1288                      p_input_value_id6,p_entry_value6,
1289                      p_input_value_id7,p_entry_value7,
1290                      p_input_value_id8,p_entry_value8,
1291                      p_input_value_id9,p_entry_value9,
1292                      p_input_value_id10,p_entry_value10,
1293                      p_input_value_id11,p_entry_value11,
1294                      p_input_value_id12,p_entry_value12,
1295                      p_input_value_id13,p_entry_value13,
1296                      p_input_value_id14,p_entry_value14,
1297                      p_input_value_id15,p_entry_value15,
1298                      null) entry_value,
1299             decode(pliv.input_value_id,
1300                      p_input_value_id1,'SET',
1301                      p_input_value_id2,'SET',
1302                      p_input_value_id3,'SET',
1303                      p_input_value_id4,'SET',
1304                      p_input_value_id5,'SET',
1305                      p_input_value_id6,'SET',
1306                      p_input_value_id7,'SET',
1307                      p_input_value_id8,'SET',
1308                      p_input_value_id9,'SET',
1309                      p_input_value_id10,'SET',
1310                      p_input_value_id11,'SET',
1311                      p_input_value_id12,'SET',
1312                      p_input_value_id13,'SET',
1313                      p_input_value_id14,'SET',
1314                      p_input_value_id15,'SET',
1315                      'NOT_SET') entry_specified
1316      from  pay_link_input_values_f pliv,
1317            pay_input_values_f piv,
1318            pay_element_types_f et
1319      where pliv.element_link_id = p_element_link_id
1320        and piv.input_value_id = pliv.input_value_id
1321        and et.element_type_id = piv.element_type_id
1322        and p_session_date between pliv.effective_start_date
1323                               and pliv.effective_end_date
1324        and p_session_date between piv.effective_start_date
1325                               and piv.effective_end_date
1326        and p_session_date between et.effective_start_date
1327                               and et.effective_end_date;
1328    --
1329    -- Selects all the element entry values for a specified entry. Each one
1330    -- retrieved is compared with the entry values specified by the user. If it
1331    -- has been specified by the user then the value for the entry value is
1332    -- set to the users value and a flag is set to indicate this has happened.
1333    -- If the user has not set a value for it then the value is set to the
1334    -- existing value of the entry value.
1335    --
1336    cursor csr_entry_input_value
1337           (
1338            p_element_entry_id number,
1339            p_session_date     date
1340           ) is
1341      select /*+ LEADING(ee) */ ee.element_link_id,
1342             eev.input_value_id,
1343             piv.lookup_type,
1344             piv.value_set_id,
1345             piv.uom,
1346             piv.hot_default_flag,
1347             et.input_currency_code,
1348             piv.mandatory_flag,
1349             eev.screen_entry_value       peev_default_value,
1350             decode(eev.input_value_id,
1351                      p_input_value_id1,p_entry_value1,
1352                      p_input_value_id2,p_entry_value2,
1353                      p_input_value_id3,p_entry_value3,
1354                      p_input_value_id4,p_entry_value4,
1355                      p_input_value_id5,p_entry_value5,
1356                      p_input_value_id6,p_entry_value6,
1357                      p_input_value_id7,p_entry_value7,
1358                      p_input_value_id8,p_entry_value8,
1359                      p_input_value_id9,p_entry_value9,
1360                      p_input_value_id10,p_entry_value10,
1361                      p_input_value_id11,p_entry_value11,
1362                      p_input_value_id12,p_entry_value12,
1363                      p_input_value_id13,p_entry_value13,
1364                      p_input_value_id14,p_entry_value14,
1365                      p_input_value_id15,p_entry_value15,
1366                      eev.screen_entry_value) entry_value,
1367             decode(eev.input_value_id,
1368                      p_input_value_id1,'SET',
1369                      p_input_value_id2,'SET',
1370                      p_input_value_id3,'SET',
1371                      p_input_value_id4,'SET',
1372                      p_input_value_id5,'SET',
1373                      p_input_value_id6,'SET',
1374                      p_input_value_id7,'SET',
1375                      p_input_value_id8,'SET',
1376                      p_input_value_id9,'SET',
1377                      p_input_value_id10,'SET',
1378                      p_input_value_id11,'SET',
1379                      p_input_value_id12,'SET',
1380                      p_input_value_id13,'SET',
1381                      p_input_value_id14,'SET',
1382                      p_input_value_id15,'SET',
1383                      'NOT_SET') entry_specified
1384      from  pay_element_entry_values_f eev,
1385            pay_element_entries_f ee,
1386            pay_input_values_f piv,
1387            pay_element_types_f et
1388      where ee.element_entry_id = p_element_entry_id
1389        and eev.element_entry_id = ee.element_entry_id
1390        and piv.input_value_id = eev.input_value_id
1391        and et.element_type_id = piv.element_type_id
1392        and p_session_date between ee.effective_start_date
1393                               and ee.effective_end_date
1394        and p_session_date between eev.effective_start_date
1395                               and eev.effective_end_date
1396        and p_session_date between piv.effective_start_date
1397                               and piv.effective_end_date
1398        and p_session_date between et.effective_start_date
1399                               and et.effective_end_date;
1400    --
1401 --
1402    cursor csr_creator_type
1403        (
1404         l_element_entry_id number,
1405         l_session_date     date
1406        ) is
1407        select ee.creator_type
1408          from pay_element_entries_f ee
1409         where ee.element_entry_id = l_element_entry_id
1410           and l_session_date between ee.effective_start_date and ee.effective_end_date;
1411    --
1412    v_creator_type varchar2(30);
1413    --
1414  begin
1415    g_debug := hr_utility.debug_enabled;
1416    --
1417    if g_debug then
1418       hr_utility.set_location('hr_entry.conv_entry_values_to_table',5);
1419    end if;
1420    --
1421    if p_creator_type = hr_api.g_varchar2 then
1422       open csr_creator_type(p_element_entry_id,p_session_date);
1423       fetch csr_creator_type into v_creator_type;
1424       close csr_creator_type;
1425    else
1426       v_creator_type := p_creator_type;
1427    end if;
1428    --
1429    if g_debug then
1430       hr_utility.trace('p_entry_value1: ' || p_entry_value1);
1431    end if;
1432    --
1433    -- User is inserting a new element entry.
1434    --
1435    if p_element_link_id is not null then
1436      --
1437      if g_debug then
1438         hr_utility.set_location('hr_entry.conv_entry_values_to_table',10);
1439      end if;
1440      --
1441      -- Find all the entry values for the specified element entry NB. it is a
1442      -- new element entry so have to get the details of the entry values from
1443      -- the element link.
1444      --
1445      for v_link_value in csr_link_input_value(p_element_link_id,
1446                                               p_session_date) loop
1447        --
1448        if g_debug then
1449           hr_utility.set_location('hr_entry.conv_entry_values_to_table',15);
1450        end if;
1451        --
1452        -- Keep a count of the number of entry values and put input_value_id of
1453        -- entry value into table.
1454        --
1455        v_count := v_count + 1;
1456        v_input_value_id_tbl(v_count) := v_link_value.input_value_id;
1457        --
1458        -- User has set a value and it is is in screen format so need to
1459        -- cobert it to DB format.
1460        --
1461        if p_iv_format = 'SCREEN' and v_link_value.entry_specified = 'SET' then
1462          if g_debug then
1463             hr_utility.trace('| Begin conv_entry_values_to_table()');
1464          end if;
1465          --
1466          -- v_link_value.entry_specified really indicates that the IV_ID
1467          -- has been specified
1468          --
1469          -- nb. all IV_IDs for an ET are passed in through forms,
1470          --     via the API, the user can explicitly specify IV_IDs
1471          --
1472          -- bug 546670, extra validation
1473          --
1474          -- this does not apply to adjustment EEs,
1475          -- chk type of EE
1476          --
1477          -- D Additional Entry
1478          -- A Additive Adjustment
1479          -- B Balance Adjustment
1480          -- E Element Entry
1481          -- S Override
1482          -- R Replacement Adjustment
1483          --
1484          if g_debug then
1485             hr_utility.trace('| p_entry_type>' || p_entry_type || '<');
1486          end if;
1487          --
1488          -- Bugfix 3187829
1489          -- Do not call chk_user_enterable for entry type 'R' (replacement
1490          -- adjustment), i.e. we allow a replacement adjustment to be created
1491          -- for non-user enterable Pay Values. This is consistent with entry
1492          -- type 'A' (additive adjustment) behaviour.
1493          --
1494          IF v_creator_type IN ('F','H') AND p_entry_type NOT IN ('A','R') THEN
1495            if g_debug then
1496               hr_utility.trace('| creator type in F or H and not A EE');
1497            end if;
1498            --
1499            IF v_link_value.mandatory_flag = 'X'
1500              -- Following commented out because user can entre null value too.
1501              -- AND v_link_value.entry_value IS NOT NULL
1502              THEN
1503              if g_debug then
1504                 hr_utility.trace('| flag set to X and EV specified');
1505              end if;
1506              --
1507              -- only raise the error if the EV does not match the
1508              -- default value stored on PLIV
1509              --
1510              hr_entry_api.chk_user_enterable(
1511                p_el_id               => p_element_link_id,
1512                p_lookup_type         => v_link_value.lookup_type,
1513                p_value_set_id        => v_link_value.value_set_id,
1514                p_uom                 => v_link_value.uom,
1515                p_default_value       => v_link_value.pliv_default_value,
1516                p_input_currency_code => v_link_value.input_currency_code,
1517                p_session_date        => p_session_date,
1518                p_iv_id               => v_link_value.input_value_id,
1519                p_ev                  => v_link_value.entry_value,
1520                p_creator_type        => v_creator_type,
1521                p_hot_flag            => v_link_value.hot_default_flag);
1522            END IF;
1523            --
1524          END IF;
1525          --
1526          if g_debug then
1527             hr_utility.trace('| End conv_entry_values_to_table()');
1528          end if;
1529          --
1530          --
1531          v_screen_format := v_link_value.entry_value;
1532          v_db_format := v_screen_format;
1533          --
1534          hr_entry_api.validate_entry_value
1535            (p_element_link_id,
1536             v_link_value.input_value_id,
1537             p_session_date,
1538             v_screen_format,
1539             v_db_format,
1540             v_link_value.lookup_type,
1541             v_link_value.uom,
1542             v_link_value.input_currency_code,
1543             v_link_value.value_set_id);
1544          --
1545          -- Put entry value into table.
1546          --
1547          v_entry_value_tbl(v_count) := v_db_format;
1548        --
1549        -- User has not set a value and entry value is not hot defaulted.
1550        --
1551        elsif v_link_value.entry_specified = 'NOT_SET' and
1552              v_link_value.hot_default_flag = 'N' then
1553          --
1554          -- Get any default if it has been set up.
1555          --
1556          hr_entry.derive_default_value
1557            (p_element_link_id,
1558             v_input_value_id_tbl(v_count),
1559             p_session_date,
1560             v_link_value.input_currency_code,
1561             'DEF',
1562             v_screen_format,
1563             v_db_format);
1564          --
1565          -- Put entry value into table.
1566          --
1567          v_entry_value_tbl(v_count) := v_db_format;
1568          if g_debug then
1569             hr_utility.trace('v_db_format: ' || v_db_format);
1570          end if;
1571          --
1572        else
1573          --
1574          -- Put entry value into table.
1575          --
1576          v_entry_value_tbl(v_count) := v_link_value.entry_value;
1577          if g_debug then
1578             hr_utility.trace('v_link_value.entry_value: ' ||
1579                               v_link_value.entry_value);
1580          end if;
1581          --
1582        end if;
1583        --
1584      end loop;
1585    --
1586    -- User is updating an existing element entry.
1587    --
1588    elsif p_element_entry_id is not null then
1589      --
1590      if g_debug then
1591         hr_utility.set_location('hr_entry.conv_entry_values_to_table',20);
1592      end if;
1593      --
1594      -- Find all the entry values for the specified element entry.
1595      --
1596      for v_entry_value in csr_entry_input_value(p_element_entry_id,
1597                                                 p_session_date) loop
1598        --
1599        if g_debug then
1600           hr_utility.set_location('hr_entry.conv_entry_values_to_table',25);
1601           hr_utility.trace('v_entry_value.element_link_id: '||to_char(v_entry_value.element_link_id) );
1602           hr_utility.trace('v_entry_value.input_value_id: '||to_char(v_entry_value.input_value_id) );
1603           hr_utility.trace('v_entry_value.lookup_type: '||v_entry_value.lookup_type) ;
1604           hr_utility.trace('v_entry_value.value_set_id: '||to_char(v_entry_value.value_set_id) );
1605           hr_utility.trace('v_entry_value.uom: '||v_entry_value.uom) ;
1606           hr_utility.trace('v_entry_value.hot_default_flag: '||v_entry_value.hot_default_flag) ;
1607           hr_utility.trace('v_entry_value.input_currency_code: '||v_entry_value.input_currency_code) ;
1608           hr_utility.trace('v_entry_value.mandatory_flag: '||v_entry_value.mandatory_flag) ;
1609           hr_utility.trace('v_entry_value.peev_default_value: '||v_entry_value.peev_default_value) ;
1610           hr_utility.trace('v_entry_value.entry_value: '|| v_entry_value.entry_value) ;
1611           hr_utility.trace('v_entry_value.entry_specified: '||v_entry_value.entry_specified) ;
1612        end if;
1613        --
1614        -- Keep a count of the number of entry values and put input_value_id of
1615        -- entry value into table.
1616        --
1617        v_count := v_count + 1;
1618        v_input_value_id_tbl(v_count) := v_entry_value.input_value_id;
1619        --
1620        -- User has set a value and it is is in screen format so need to
1621        -- cobert it to DB format.
1622        --
1623        if p_iv_format = 'SCREEN' and v_entry_value.entry_specified = 'SET' then
1624          --
1625          --IF v_creator_type IN ('F', 'H') AND p_entry_type <> 'A' THEN -- Commented for bug 8307482
1626 	   IF v_creator_type IN ('F', 'H') AND p_entry_type NOT IN ('A','R') THEN
1627            if g_debug then
1628               hr_utility.trace('| creator type in F or H and not A EE');
1629            end if;
1630            --
1631            IF v_entry_value.mandatory_flag = 'X'
1632              -- Following commented out because user can entre null value too.
1633              -- AND v_entry_value.entry_value IS NOT NULL
1634              THEN
1635              if g_debug then
1636                 hr_utility.trace('| flag set to X and EV specified');
1637              end if;
1638              --
1639              -- only raise the error if the EV does not match the
1640              -- existing value.
1641              --
1642              hr_entry_api.chk_user_enterable(
1643                p_el_id               => v_entry_value.element_link_id,
1644                p_lookup_type         => v_entry_value.lookup_type,
1645                p_value_set_id        => v_entry_value.value_set_id,
1646                p_uom                 => v_entry_value.uom,
1647                p_default_value       => v_entry_value.peev_default_value,
1648                p_input_currency_code => v_entry_value.input_currency_code,
1649                p_session_date        => p_session_date,
1650                p_iv_id               => v_entry_value.input_value_id,
1651                p_ev                  => v_entry_value.entry_value,
1652                p_mode                => 'U',
1653                p_creator_type        => v_creator_type,
1654                p_hot_flag            => v_entry_value.hot_default_flag);
1655            END IF;
1656            --
1657          END IF;
1658          --
1659          --
1660          v_screen_format := v_entry_value.entry_value;
1661          v_db_format := v_screen_format;
1662          --
1663          if g_debug then
1664            hr_utility.set_location('hr_entry.conv_entry_values_to_table',27);
1665          end if;
1666          --
1667          hr_entry_api.validate_entry_value
1668            (v_entry_value.element_link_id,
1669             v_entry_value.input_value_id,
1670             p_session_date,
1671             v_screen_format,
1672             v_db_format,
1673             v_entry_value.lookup_type,
1674             v_entry_value.uom,
1675             v_entry_value.input_currency_code,
1676             v_entry_value.value_set_id);
1677          --
1678          -- Put entry value into table.
1679          --
1680          v_entry_value_tbl(v_count) := v_db_format;
1681          --
1682        else
1683          --
1684          -- Put entry value into table.
1685          --
1686          v_entry_value_tbl(v_count) := v_entry_value.entry_value;
1687          --
1688        end if;
1689        --
1690      end loop;
1691      --
1692    end if;
1693    --
1694    if g_debug then
1695       hr_utility.set_location('hr_entry.conv_entry_values_to_table',30);
1696    end if;
1697    --
1698    -- Return tables containing the entry values in DB format.
1699    --
1700    p_num_entry_values   := v_count;
1701    p_input_value_id_tbl := v_input_value_id_tbl;
1702    p_entry_value_tbl    := v_entry_value_tbl;
1703    --
1704  end conv_entry_values_to_table;
1705 --
1706  ------------------------------------------------------------------------------
1707  -- NAME                                                                     --
1708  -- hr_entry.conv_table_to_table                                             --
1709  --                                                                          --
1710  -- DESCRIPTION                                                              --
1711  -- Given a table of entry values it converts to DB format if required. Any  --
1712  -- entry values that are not specified are derived NB. when inserting the   --
1713  -- values are defaulted, when updating the existing entry values are used.  --
1714  ------------------------------------------------------------------------------
1715 --
1716  procedure conv_table_to_table
1717  (
1718   p_iv_format          varchar2,
1719   p_session_date       date,
1720   p_element_entry_id   number,
1721   p_element_link_id    number,
1722   p_num_entry_values   in out nocopy number,
1723   p_creator_type       varchar2,
1724   p_entry_type         varchar2,
1725   p_input_value_id_tbl in out nocopy hr_entry.number_table,
1726   p_entry_value_tbl    in out nocopy hr_entry.varchar2_table
1727  ) is
1728    --
1729    -- Selects all the link input values for a specified element link.
1730    --
1731    cursor csr_link_input_value
1732           (
1733            p_element_link_id number,
1734            p_session_date    date
1735           ) is
1736      select /*+ ORDERED
1737                 INDEX(pliv PAY_LINK_INPUT_VALUES_F_N1)
1738                 INDEX(piv PAY_INPUT_VALUES_F_PK)
1739                 INDEX(et PAY_ELEMENT_TYPES_F_PK)
1740                 USE_NL(PLIV ET PIV) */
1741             pliv.input_value_id,
1742             pliv.default_value      pliv_default_value,
1743             piv.hot_default_flag,
1744             piv.lookup_type,
1745             piv.value_set_id,
1746             piv.uom,
1747             piv.mandatory_flag,
1748             piv.default_value       piv_default_value,
1749             et.input_currency_code
1750      from   pay_link_input_values_f pliv,
1751             pay_input_values_f piv,
1752             pay_element_types_f et
1753      where  pliv.element_link_id = p_element_link_id
1754        and  piv.input_value_id   = pliv.input_value_id
1755        and  et.element_type_id  = piv.element_type_id
1756        and  p_session_date between pliv.effective_start_date
1757                                and pliv.effective_end_date
1758        and  p_session_date between piv.effective_start_date
1759                                and piv.effective_end_date
1760        and  p_session_date between et.effective_start_date
1761                                and et.effective_end_date;
1762    --
1763    -- Selects all the entry values for a specified element entry.
1764    --
1765    cursor csr_entry_input_value
1766           (
1767            p_element_entry_id number,
1768            p_session_date     date
1769           ) is
1770      select ee.element_link_id,
1771             eev.input_value_id,
1772             piv.lookup_type,
1773             piv.value_set_id,
1774             piv.uom,
1775             piv.hot_default_flag,
1776             et.input_currency_code,
1777             piv.mandatory_flag,
1778             eev.screen_entry_value       peev_default_value,
1779             eev.screen_entry_value
1780      from   pay_element_entry_values_f eev,
1781             pay_element_entries_f ee,
1782             pay_input_values_f piv,
1783             pay_element_types_f et
1784      where  ee.element_entry_id = p_element_entry_id
1785        and  eev.element_entry_id = ee.element_entry_id
1786        and  piv.input_value_id = eev.input_value_id
1787        and  et.element_type_id = piv.element_type_id
1788        and  p_session_date between ee.effective_start_date
1789                                and ee.effective_end_date
1790        and  p_session_date between eev.effective_start_date
1791                                and eev.effective_end_date
1792        and  p_session_date between piv.effective_start_date
1793                                and piv.effective_end_date
1794        and  p_session_date between et.effective_start_date
1795                                and et.effective_end_date;
1796    --
1797 --
1798    cursor csr_creator_type
1799        (
1800         l_element_entry_id number,
1801         l_session_date     date
1802        ) is
1803        select ee.creator_type
1804          from pay_element_entries_f ee
1805         where ee.element_entry_id = l_element_entry_id
1806           and l_session_date between ee.effective_start_date and ee.effective_end_date;
1807    --
1808    -- Local Variables
1809    --
1810    v_creator_type        varchar2(30);
1811    v_num_entry_values    number := 0;
1812    v_input_value_id_tbl  hr_entry.number_table;
1813    v_entry_value_tbl     hr_entry.varchar2_table;
1814    --v_screen_format       varchar2(60);
1815    v_screen_format       varchar2(240);
1816    --v_db_format           varchar2(60);
1817    v_db_format           varchar2(240);
1818    v_element_link_id     number;
1819    v_entry_value_found   boolean := false;
1820    --
1821  begin
1822    g_debug := hr_utility.debug_enabled;
1823    --
1824    if g_debug then
1825       hr_utility.set_location('hr_entry.conv_to_table',5);
1826    end if;
1827    --
1828    --
1829    if p_creator_type = hr_api.g_varchar2 then
1830       open csr_creator_type(p_element_entry_id,p_session_date);
1831       fetch csr_creator_type into v_creator_type;
1832       close csr_creator_type;
1833    else
1834       v_creator_type := p_creator_type;
1835    end if;
1836    --
1837    -- User is inserting a new element entry.
1838    --
1839    if p_element_link_id is not null then
1840      --
1841      -- Find all the entry values for the specified element entry NB. it is a
1842      -- new element entry so have to get the details of the entry values from
1843      -- the element link.
1844      --
1845      for v_link_value in csr_link_input_value(p_element_link_id,
1846                                               p_session_date) loop
1847        --
1848        -- Keep a count of the number of entry values and put input_value_id of
1849        -- entry value into table.
1850        --
1851        v_entry_value_found                      := false;
1852        v_num_entry_values                       := v_num_entry_values + 1;
1853        v_input_value_id_tbl(v_num_entry_values) := v_link_value.input_value_id;
1854        --
1855        -- Has the user specified any entry values.
1856        --
1857        if p_num_entry_values > 0 then
1858          --
1859          -- Loop around the list of entry values set up by the user.
1860          --
1861          for v_loop in 1..p_num_entry_values loop
1862            --
1863            -- See if user has set a value for the entry value.
1864            --
1865            if p_input_value_id_tbl(v_loop) = v_link_value.input_value_id then
1866              --
1867              -- The entry value set by the user is in screen format so need to
1868              -- convert it to DB format.
1869              --
1870              if p_iv_format = 'SCREEN' then
1871                if g_debug then
1872                   hr_utility.trace('| Begin conv_table_to_table()');
1873                end if;
1874                --
1875                -- match found,
1876                -- one of the IV_IDs passed in matches the current IV_ID
1877                -- selected by the cursor
1878                --
1879                -- nb. all IV_IDs for an ET are passed in through forms,
1880                --     via the API, the user can explicitly specify IV_IDs
1881                --
1882                -- bug 546670, repeat validation as exists in
1883                -- conv_entry_values_to_table(),
1884                --
1885                if g_debug then
1886                   hr_utility.trace('| p_entry_type>' || p_entry_type || '<');
1887                end if;
1888                --
1889                IF v_creator_type IN ('F', 'H') AND p_entry_type <> 'A' THEN
1890                  if g_debug then
1891                     hr_utility.trace('| creator type in F or H and not A EE');
1892                  end if;
1893 
1894                  IF v_link_value.mandatory_flag = 'X'
1895                    -- Following commented out because user can entre null value too.
1896                    -- AND p_entry_value_tbl(v_loop) IS NOT NULL
1897                    THEN
1898                    if g_debug then
1899                       hr_utility.trace('| flag set to X and EV specified');
1900                    end if;
1901                    --
1902                    -- only raise the error if the EV does not match the
1903                    -- default value stored on PLIV
1904                    --
1905                    hr_entry_api.chk_user_enterable(
1906                      p_el_id               => p_element_link_id,
1907                      p_lookup_type         => v_link_value.lookup_type,
1908                      p_value_set_id        => v_link_value.value_set_id,
1909                      p_uom                 => v_link_value.uom,
1910                      p_default_value       => v_link_value.pliv_default_value,
1911                      p_input_currency_code => v_link_value.input_currency_code,
1912                      p_session_date        => p_session_date,
1913                      p_iv_id               => v_link_value.input_value_id,
1914                      p_ev                  => p_entry_value_tbl(v_loop),
1915                      p_creator_type        => v_creator_type,
1916                      p_hot_flag            => v_link_value.hot_default_flag);
1917                  END IF;
1918 
1919                END IF;
1920                --
1921                if g_debug then
1922                   hr_utility.trace('| End conv_table_to_table()');
1923                end if;
1924                --
1925                --
1926                v_screen_format := p_entry_value_tbl(v_loop);
1927                --
1928                -- bug 900288. Set v_db_format for each entry value.
1929                -- This is needed in cases where v_db_format is not set
1930                -- in validate_entry_value (such as lookups with a null
1931                -- screen_format) as otherwise v_db_format will be set to
1932                -- the value of the PREVIOUS input value
1933                v_db_format := v_screen_format;
1934                -- end bug 900288
1935                --
1936                hr_entry_api.validate_entry_value
1937                  (p_element_link_id,
1938                   v_link_value.input_value_id,
1939                   p_session_date,
1940                   v_screen_format,
1941                   v_db_format,
1942                   v_link_value.lookup_type,
1943                   v_link_value.uom,
1944                   v_link_value.input_currency_code,
1945                   v_link_value.value_set_id);
1946                --
1947                -- Put entry value into table.
1948                --
1949                v_entry_value_tbl(v_num_entry_values) := v_db_format;
1950                --
1951              else
1952                --
1953                -- Put entry value into table.
1954                --
1955                v_entry_value_tbl(v_num_entry_values) :=
1956                                              p_entry_value_tbl(v_loop);
1957                --
1958              end if;
1959              --
1960              -- Entry value has been found so stop searching through list of
1961              -- entry values set up by the user.
1962              --
1963              v_entry_value_found := true;
1964              exit;
1965              --
1966            end if;
1967            --
1968          end loop;
1969          --
1970        end if;
1971        --
1972        -- User has not set a value and entry value is not hot defaulted.
1973        --
1974        if not v_entry_value_found then
1975          --
1976          if v_link_value.hot_default_flag = 'N' then
1977            --
1978            -- Get any default if it has been set up.
1979            --
1980            hr_entry.derive_default_value
1981              (p_element_link_id,
1982               v_input_value_id_tbl(v_num_entry_values),
1983               p_session_date,
1984               v_link_value.input_currency_code,
1985               'DEF',
1986               v_screen_format,
1987               v_db_format);
1988            --
1989            -- Put entry value into table.
1990            --
1991            v_entry_value_tbl(v_num_entry_values) := v_db_format;
1992            --
1993          else
1994            --
1995            -- Put entry value into table.
1996            --
1997            v_entry_value_tbl(v_num_entry_values) := null;
1998            --
1999          end if;
2000        --
2001        end if;
2002        --
2003      end loop;
2004    --
2005    -- User is updating an existing element entry.
2006    --
2007    elsif p_element_entry_id is not null then
2008      --
2009      -- Find all the entry values for the specified element entry.
2010      --
2011      for v_entry_value in csr_entry_input_value(p_element_entry_id,
2012                                                 p_session_date) loop
2013        --
2014        -- Keep a count of the number of entry values and put input_value_id of
2015        -- entry value into table.
2016        --
2017        v_entry_value_found := false;
2018        v_num_entry_values := v_num_entry_values + 1;
2019        v_input_value_id_tbl(v_num_entry_values) := v_entry_value.input_value_id;
2020        --
2021        -- Has the user specified any entry values.
2022        --
2023        if p_num_entry_values > 0 then
2024          --
2025          -- Loop around the list of entry values set up by the user.
2026          --
2027          for v_loop in 1..p_num_entry_values loop
2028            --
2029            -- See if user has set a value for the entry value.
2030            --
2031            if p_input_value_id_tbl(v_loop) = v_entry_value.input_value_id then
2032              --
2033              -- The entry value set by the user is in screen format so need to
2034              -- convert it to DB format.
2035              --
2036              if p_iv_format = 'SCREEN' then
2037                --
2038                IF v_creator_type IN ('F', 'H') AND p_entry_type <> 'A' THEN
2039                  if g_debug then
2040                     hr_utility.trace('| creator type in F or H and not A EE');
2041                  end if;
2042                  --
2043                  IF v_entry_value.mandatory_flag = 'X'
2044                    -- Following commented out because user can entre null value too.
2045                    -- AND p_entry_value_tbl(v_loop) IS NOT NULL
2046                    THEN
2047                    if g_debug then
2048                       hr_utility.trace('| flag set to X and EV specified');
2049                    end if;
2050                    --
2051                    -- only raise the error if the EV does not match the
2052                    -- existing value.
2053                    --
2054                    hr_entry_api.chk_user_enterable(
2055                      p_el_id               => v_entry_value.element_link_id,
2056                      p_lookup_type         => v_entry_value.lookup_type,
2057                      p_value_set_id        => v_entry_value.value_set_id,
2058                      p_uom                 => v_entry_value.uom,
2059                      p_default_value       => v_entry_value.peev_default_value,
2060                      p_input_currency_code => v_entry_value.input_currency_code,
2061                      p_session_date        => p_session_date,
2062                      p_iv_id               => v_entry_value.input_value_id,
2063                      p_ev                  => p_entry_value_tbl(v_loop),
2064                      p_mode                => 'U',
2065                      p_creator_type        => v_creator_type,
2066                      p_hot_flag            => v_entry_value.hot_default_flag);
2067                  END IF;
2068 
2069                END IF;
2070                --
2071                --
2072                v_screen_format := p_entry_value_tbl(v_loop);
2073                -- bug 900288
2074                v_db_format := v_screen_format;
2075                -- end bug 900288
2076                hr_entry_api.validate_entry_value
2077                  (v_entry_value.element_link_id,
2078                   v_entry_value.input_value_id,
2079                   p_session_date,
2080                   v_screen_format,
2081                   v_db_format,
2082                   v_entry_value.lookup_type,
2083                   v_entry_value.uom,
2084                   v_entry_value.input_currency_code,
2085                   v_entry_value.value_set_id);
2086                --
2087                -- Put entry value into table.
2088                --
2089                v_entry_value_tbl(v_num_entry_values) := v_db_format;
2090                --
2091              else
2092                --
2093                -- Put entry value into table.
2094                --
2095                v_entry_value_tbl(v_num_entry_values) :=
2096                                                   p_entry_value_tbl(v_loop);
2097                --
2098              end if;
2099              --
2100              -- Entry value has been found so stop searching through list of
2101              -- entry values set up by the user.
2102              --
2103              v_entry_value_found := true;
2104              exit;
2105            --
2106            end if;
2107          --
2108          end loop;
2109          --
2110        end if;
2111        --
2112        -- User has not set a value.
2113        --
2114        if not v_entry_value_found then
2115          --
2116          -- Use the existing value of the element entry.
2117          --
2118          v_entry_value_tbl(v_num_entry_values) :=
2119                                             v_entry_value.screen_entry_value;
2120        --
2121        end if;
2122      --
2123      end loop;
2124      --
2125    end if;
2126    --
2127    if g_debug then
2128       hr_utility.set_location('hr_entry.conv_table_to_table',10);
2129    end if;
2130    --
2131    -- Return tables containing the entry values in DB format.
2132    --
2133    p_num_entry_values   := v_num_entry_values;
2134    p_input_value_id_tbl := v_input_value_id_tbl;
2135    p_entry_value_tbl    := v_entry_value_tbl;
2136    --
2137  end conv_table_to_table;
2138 --
2139  ------------------------------------------------------------------------------
2140  -- NAME                                                                     --
2141  -- hr_entry_api.get_link                                                    --
2142  --                                                                          --
2143  -- DESCRIPTION                                                              --
2144  -- Returns for the element link that represents the assignments eligibility --
2145  -- for a particular element type on a given date.                           --
2146  ------------------------------------------------------------------------------
2147 --
2148  function get_link
2149  (
2150   p_assignment_id     number,
2151   p_element_type_id   number,
2152   p_session_date      date
2153  ) return number is
2154    --
2155    -- Local Variables
2156    --
2157    v_element_link_id number;
2158    --
2159  begin
2160    g_debug := hr_utility.debug_enabled;
2161    --
2162    begin
2163      select el.element_link_id
2164      into   v_element_link_id
2165      from   per_assignments_f asg,
2166             pay_element_links_f el
2167      where  asg.assignment_id = p_assignment_id
2168        and  el.business_group_id + 0 = asg.business_group_id + 0
2169        and  el.element_type_id = p_element_type_id
2170        and  p_session_date between asg.effective_start_date
2171                                and asg.effective_end_date
2172        and  p_session_date between el.effective_start_date
2173                                and el.effective_end_date
2174        and  ((el.payroll_id is not null and
2175               el.payroll_id = asg.payroll_id)
2176         or   (el.link_to_all_payrolls_flag = 'Y' and
2177               asg.payroll_id is not null)
2178         or   (el.payroll_id is null and
2179               el.link_to_all_payrolls_flag = 'N'))
2180        and  (el.job_id is null or
2181              el.job_id = asg.job_id)
2182        and  (el.grade_id is null or
2183              el.grade_id = asg.grade_id)
2184        and  (el.position_id is null or
2185              el.position_id = asg.position_id)
2186        and  (el.organization_id is null or
2187              el.organization_id = asg.organization_id)
2188        and  (el.location_id is null or
2189              el.location_id = asg.location_id)
2190        and  (el.pay_basis_id is null or
2191              el.pay_basis_id = asg.pay_basis_id)
2192        and  (el.employment_category is null or
2193              el.employment_category = asg.employment_category)
2194        and  (el.people_group_id is null or exists
2195                (select null
2196                 from   pay_assignment_link_usages_f alu
2197                 where  alu.assignment_id = asg.assignment_id
2198                   and  alu.element_link_id = el.element_link_id
2199                   and  p_session_date between alu.effective_start_date
2200                                           and alu.effective_end_date));
2201    exception
2202      when no_data_found then null;
2203    end;
2204    --
2205    return v_element_link_id;
2206    --
2207  end get_link;
2208 --
2209  ------------------------------------------------------------------------------
2210  -- NAME
2211  -- hr_entry_api.validate_ppm_id
2212  --
2213  -- DESCRIPTION
2214  -- Make sure personal_payment_method_id exists
2215  ------------------------------------------------------------------------------
2216  --
2217  procedure validate_ppm_id (
2218  --
2219  p_personal_payment_method_id   number,
2220  p_assignment_id                number,
2221  p_element_link_id              number,
2222  p_effective_start_date         date,
2223  p_effective_end_date           date,
2224  p_entry_type                   varchar2) is
2225  --
2226  cursor personal_payment_method is
2227         select  min (ppm1.effective_start_date),
2228                 max (ppm2.effective_end_date)
2229         from    pay_personal_payment_methods_f  PPM1,
2230                 pay_personal_payment_methods_f  PPM2
2231         where   ppm1.personal_payment_method_id = p_personal_payment_method_id
2232         and     ppm2.personal_payment_method_id = p_personal_payment_method_id
2233         and     ppm1.assignment_id = p_assignment_id;
2234         --
2235  cursor third_party_element is
2236         select  1
2237         from    pay_element_types_f elt,
2238                 pay_element_links_f eli
2239         where   eli.element_link_id = p_element_link_id
2240         and     eli.element_type_id = elt.element_type_id
2241         and     p_effective_start_date <= eli.effective_end_date
2242         and     p_effective_end_date >= eli.effective_start_date
2243         and     p_effective_start_date <= elt.effective_end_date
2244         and     p_effective_end_date >= elt.effective_start_date
2245         and     elt.third_party_pay_only_flag = 'Y';
2246         --
2247  l_ppm_start    date := null;
2248  l_ppm_end      date := null;
2249  l_dummy        integer (1);
2250  --
2251  begin
2252  --
2253  if p_personal_payment_method_id is null then
2254    --
2255    open third_party_element;
2256    fetch third_party_element into l_dummy;
2257    if third_party_element%found then
2258      --
2259      close third_party_element;
2260      --
2261      -- Special case exclusion for the Balance Adjustment entries.
2262      --
2263      if (p_entry_type <> 'B') then
2264        hr_utility.set_message (801, 'HR_7796_ENTRY_INVALID_PPM');
2265        hr_utility.raise_error;
2266      end if;
2267      --
2268      --
2269    else
2270      close third_party_element;
2271      return; -- Abort check.
2272    end if;
2273    --
2274  else
2275    --
2276    open third_party_element;
2277    fetch third_party_element into l_dummy;
2278    if third_party_element%notfound then
2279      --
2280      close third_party_element;
2281      hr_utility.set_message (801, 'HR_7795_ENTRY_NOT_3RD_PARTY');
2282      hr_utility.raise_error;
2283      --
2284    end if;
2285    --
2286    close third_party_element;
2287    open personal_payment_method;
2288    fetch personal_payment_method into l_ppm_start, l_ppm_end;
2289    --
2290    if personal_payment_method%notfound then
2291      --
2292      -- There was no personal_payment_method for the ID passed in
2293      --
2294      close personal_payment_method;
2295      hr_utility.set_message (801, 'HR_7796_ENTRY_INVALID_PPM');
2296      hr_utility.raise_error;
2297      --
2298    else
2299      --
2300      close personal_payment_method;
2301      --
2302      -- Check the dates of the entry and payment method
2303      --
2304      if (p_effective_start_date < l_ppm_start)
2305         or (p_effective_end_date > l_ppm_end) then
2306        --
2307        -- The payment method does not exist for the whole life of the entry
2308        --
2309        hr_utility.set_message (801, 'HR_7797_ENTRY_PPM_DATES');
2310        hr_utility.raise_error;
2311        --
2312      end if;
2313      --
2314    end if;
2315    --
2316  end if;
2317  --
2318  end validate_ppm_id;
2319  ------------------------------------------------------------------------------
2320  -- NAME
2321  -- hr_entry_api.validate_date_earned
2322  --
2323  -- DESCRIPTION
2324  -- Validate the date_earned column
2325  ------------------------------------------------------------------------------
2326  --
2327  procedure validate_date_earned (
2328  --
2329  p_date_earned          date,
2330  p_effective_start_date date,
2331  p_effective_end_date   date,
2332  p_element_link_id      number,
2333  p_entry_type           varchar2) is
2334  --
2335  cursor processing_type is
2336         select  1
2337         from    pay_element_types_f     ELT,
2338                 pay_element_links_f     ELI
2339         where   eli.element_link_id = p_element_link_id
2340         and     eli.element_type_id = elt.element_type_id
2341         and     p_effective_start_date <= eli.effective_end_date
2342         and     p_effective_end_date >= eli.effective_start_date
2343         and     p_effective_start_date <= elt.effective_end_date
2344         and     p_effective_end_date >= elt.effective_start_date
2345         and     elt.processing_type = 'N';
2346         --
2347  l_dummy        integer (1);
2348  --
2349  begin
2350  --
2351  if g_debug then
2352     hr_utility.trace ('p_date_earned = '||p_date_earned);
2353     hr_utility.trace ('p_effective_start_date = '||p_effective_start_date);
2354     hr_utility.trace ('p_effective_end_date = '||p_effective_end_date);
2355     hr_utility.trace ('p_element_link_id = '||p_element_link_id);
2356     hr_utility.trace ('p_entry_type = '||p_entry_type);
2357  end if;
2358  --
2359  if p_date_earned is null then
2360    return; -- Abort check.
2361  else
2362    --
2363    if p_date_earned not between p_effective_start_date
2364                                 and p_effective_end_date then
2365      --
2366      -- The date_earned must lie within the effective dates
2367      --
2368      hr_utility.set_message (801,'HR_7793_ENTRY_DATE_EARNED');
2369      hr_utility.raise_error;
2370      --
2371    else
2372      --
2373      -- Only nonrecurring entries may have date earned
2374      --
2375      if p_entry_type not in ('A','D','S','R') then
2376        --
2377        open processing_type;
2378        fetch processing_type into l_dummy;
2379        --
2380        if processing_type%notfound then
2381          --
2382          close processing_type;
2383          hr_utility.set_message (801, 'HR_7794_ENTRY_DATE_EARNED_NULL');
2384          hr_utility.raise_error;
2385          --
2386        end if;
2387        --
2388        close processing_type;
2389        --
2390      end if;
2391    end if;
2392  end if;
2393  --
2394  end validate_date_earned;
2395  ------------------------------------------------------------------------------
2396  -- NAME                                                                     --
2397  -- hr_entry_api.val_assignment                                              ==
2398  --                                                                          --
2399  -- DESCRIPTION                                                              --
2400  -- Make sure assignment exists.                                             --
2401  ------------------------------------------------------------------------------
2402 --
2403  procedure val_assignment
2404  (
2405   p_assignment_id         number,
2406   p_validation_start_date date
2407  ) is
2408 --
2409    -- Local Variables
2410    v_number_variable number;
2411 --
2412  begin
2413 --
2414    -- Check assignment exists.
2415    begin
2416 --
2417      select asg.assignment_id
2418      into   v_number_variable
2419      from   per_assignments_f asg
2420      where  asg.assignment_id = p_assignment_id
2421        and  p_validation_start_date between asg.effective_start_date
2422                                         and asg.effective_end_date;
2423 --
2424    exception
2425      when no_data_found then
2426        hr_utility.set_message(801, 'HR_7026_ELE_ENTRY_ASS_NOT_EXST');
2427        hr_utility.set_message_token('DATE',fnd_date.date_to_canonical(p_validation_start_date));
2428        hr_utility.raise_error;
2429    end;
2430 --
2431  end val_assignment;
2432 --
2433  ------------------------------------------------------------------------------
2434  -- NAME                                                                     --
2435  -- hr_entry_api.val_element_link                                            --
2436  --                                                                          --
2437  -- DESCRIPTION                                                              --
2438  -- Make sure element link exists.                                           --
2439  ------------------------------------------------------------------------------
2440 --
2441  procedure val_element_link
2442  (
2443   p_element_link_id       number,
2444   p_validation_start_date date
2445  ) is
2446 --
2447    -- Local Variables
2448    v_number_variable number;
2449 --
2450  begin
2451 --
2452    -- Check element link exists.
2453    begin
2454 --
2455      select el.element_link_id
2456      into   v_number_variable
2457      from   pay_element_links_f el
2458      where  el.element_link_id = p_element_link_id
2459        and  p_validation_start_date between el.effective_start_date
2460                                         and el.effective_end_date;
2461 --
2462    exception
2463      when no_data_found then
2464        hr_utility.set_message(801, 'HR_7027_ELE_ENTRY_EL_NOT_EXST');
2465        hr_utility.set_message_token('DATE',fnd_date.date_to_canonical(p_validation_start_date));
2466        hr_utility.raise_error;
2467    end;
2468 --
2469  end val_element_link;
2470 --
2471  ------------------------------------------------------------------------------
2472  -- NAME                                                                     --
2473  -- hr_entry_api.val_cost_allocation                                         --
2474  --                                                                          --
2475  -- DESCRIPTION                                                              --
2476  -- Make sure cost allocation exists.                                        --
2477  ------------------------------------------------------------------------------
2478 --
2479  procedure val_cost_allocation
2480  (
2481   p_cost_allocation_keyflex_id number
2482  ) is
2483 --
2484    -- Local Variables
2485    v_number_variable number;
2486    v_exists varchar2(1);
2487    --
2488    -- Bugfix 2667184
2489    -- Ensure p_cost_allocation_keyflex_id belongs to cost_allocation_structure
2490    -- used by business group
2491    --
2492    cursor csr_valid_id_flex_num
2493    ( p_cost_allocation_keyflex_id number
2494    , p_business_group_id number) is
2495    select null
2496    from   per_business_groups_perf bg
2497         , pay_cost_allocation_keyflex cak
2498    where  cak.cost_allocation_keyflex_id = p_cost_allocation_keyflex_id
2499    and    bg.business_group_id = p_business_group_id
2500    and    to_char(cak.id_flex_num) = bg.cost_allocation_structure;
2501    --
2502 --
2503  begin
2504 --
2505    begin
2506 --
2507      select cst.cost_allocation_keyflex_id
2508      into   v_number_variable
2509      from   pay_cost_allocation_keyflex cst
2510      where  cst.cost_allocation_keyflex_id = p_cost_allocation_keyflex_id;
2511 --
2512    exception
2513      when no_data_found then
2514        hr_utility.set_message(801, 'HR_7028_ELE_ENTRY_CA_NOT_EXST');
2515        hr_utility.raise_error;
2516    end;
2517 --
2518 -- Bugfix 2667184
2519 -- Ensure p_cost_allocation_keyflex_id belongs to cost_allocation_structure
2520 -- used by business group
2521 --
2522    open csr_valid_id_flex_num( p_cost_allocation_keyflex_id
2523                              , g_asg_info.business_group_id);
2524    fetch csr_valid_id_flex_num into v_exists;
2525    if csr_valid_id_flex_num%notfound then
2526       close csr_valid_id_flex_num;
2527       hr_utility.set_message(801,'HR_33130_INV_COST_ALLOC_KF');
2528       hr_utility.raise_error;
2529    else
2530       close csr_valid_id_flex_num;
2531    end if;
2532 --
2533  end val_cost_allocation;
2534 --
2535  ------------------------------------------------------------------------------
2536  -- NAME                                                                     --
2537  -- hr_entry_api.val_comment                                                 --
2538  --                                                                          --
2539  -- DESCRIPTION                                                              --
2540  -- Make sure comment exists.                                                --
2541  ------------------------------------------------------------------------------
2542 --
2543  procedure val_comment
2544  (
2545   p_comment_id number
2546  ) is
2547 --
2548    -- Local Variables
2549    v_number_variable number;
2550 --
2551  begin
2552 --
2553    begin
2554 --
2555      select com.comment_id
2556      into   v_number_variable
2557      from   hr_comments com
2558      where  com.comment_id = p_comment_id;
2559 --
2560    exception
2561      when no_data_found then
2562        hr_utility.set_message(801, 'HR_7029_ELE_ENTRY_CMT_NOT_EXST');
2563        hr_utility.raise_error;
2564    end;
2565 --
2566  end val_comment;
2567 --
2568  ------------------------------------------------------------------------------
2569  -- NAME                                                                     --
2570  -- hr_entry_api.val_adjustment                                              --
2571  --                                                                          --
2572  -- DESCRIPTION                                                              --
2573  -- Make sure adjustment is valid.                                           --
2574  ------------------------------------------------------------------------------
2575 --
2576  procedure val_adjustment
2577  (
2578   p_assignment_id         number,
2579   p_element_link_id       number,
2580   p_target_entry_id       number,
2581   p_entry_type            varchar2,
2582   p_validation_start_date date
2583  ) is
2584 --
2585    -- Local Variables
2586    v_number_variable number;
2587 --
2588  begin
2589 --
2590    begin
2591 --
2592      select ee.element_entry_id
2593      into   v_number_variable
2594      from   pay_element_entries_f ee
2595      where  p_entry_type in ('R','A')
2596        and  ee.element_entry_id = p_target_entry_id
2597        and  ee.assignment_id = p_assignment_id
2598        and  ee.element_link_id = p_element_link_id
2599        and  ee.entry_type = 'E'
2600        and  exists
2601               (select null
2602                from   pay_element_links_f el,
2603                       pay_element_types_f et
2604                where  el.element_link_id = p_element_link_id
2605                  and  et.element_type_id = el.element_type_id
2606                  and  et.processing_type = 'R')
2607        and  p_validation_start_date between ee.effective_start_date
2608                                         and ee.effective_end_date;
2609 --
2610    exception
2611      when no_data_found then
2612        hr_utility.set_message(801, 'HR_7030_ELE_ENTRY_INV_ADJ');
2613        hr_utility.raise_error;
2614    end;
2615 --
2616  end val_adjustment;
2617 --
2618  ------------------------------------------------------------------------------
2619  -- NAME                                                                     --
2620  -- hr_entry_api.val_original_entry                                          --
2621  --                                                                          --
2622  -- DESCRIPTION                                                              --
2623  -- Make sure original entry is valid.                                       --
2624  ------------------------------------------------------------------------------
2625 --
2626  procedure val_original_entry
2627  (
2628   p_original_entry_id number,
2629   p_assignment_id     number,
2630   p_element_link_id   number,
2631   p_entry_type        varchar2,
2632   p_effective_date    date
2633  ) is
2634 --
2635    -- Local Variables
2636    v_number_variable number;
2637 --
2638    --
2639    -- Support for original entry adjustment. #3482270
2640    --
2641    -- When original_entry_id is specified on the adjustment entry,
2642    -- the original entry must exist with the following conditions.
2643    --
2644    -- 1. The entry is for the same assignment.
2645    -- 2. The entry is a recurring entry.
2646    -- 3. The entry type is 'E'.
2647    -- 4. The parent/original entry exists on the effective date.
2648    -- 5. The entry is not a retro entry.
2649    --
2650    -- Note: The link can be different between the original entry and
2651    --       the adjustment entry, hence p_element_link_id should not
2652    --       be used in this cursor.
2653    --
2654    cursor csr_adj_orig_entry
2655    is
2656      select 1
2657      from   pay_element_entries_f ee
2658            ,pay_element_links_f   el
2659            ,pay_element_types_f   et
2660      where  ee.assignment_id    = p_assignment_id
2661        and  nvl(ee.original_entry_id, ee.element_entry_id)
2662                                 = p_original_entry_id
2663        and  ee.entry_type       = 'E'
2664        and  ee.creator_type not in ('R','EE','RR','PR','NR')
2665        and  p_effective_date between ee.effective_start_date
2666                                  and ee.effective_end_date
2667        and  el.element_link_id  = ee.element_link_id
2668        and  p_effective_date between el.effective_start_date
2669                                  and el.effective_end_date
2670        and  et.element_type_id  = el.element_type_id
2671        and  et.processing_type  = 'R'
2672        and  p_effective_date between et.effective_start_date
2673                                  and et.effective_end_date
2674        ;
2675    --
2676    l_proc     varchar2(80):= 'hr_entry_api.val_original_entry';
2677    --
2678  begin
2679 --
2680    if g_debug then
2681       hr_utility.set_location('Entering: '||l_proc, 5);
2682    end if;
2683 
2684    begin
2685 --
2686      if p_original_entry_id is null then
2687        --
2688        -- do nothing.
2689        --
2690        null;
2691 
2692      elsif p_entry_type = 'E' then
2693 
2694        if g_debug then
2695           hr_utility.set_location(l_proc, 20);
2696        end if;
2697 
2698        select 1
2699        into   v_number_variable
2700        from   sys.dual
2701        where  exists
2702               (select null
2703                from   pay_element_entries_f ee
2704                      ,pay_element_links_f el
2705                      ,pay_element_types_f et
2706                where  ee.assignment_id = p_assignment_id
2707                  /*Bug fix 12364433 */
2708                  /*and  ee.element_link_id = p_element_link_id*/
2709                  and  ee.element_entry_id = p_original_entry_id
2710                  and  ee.entry_type = 'E'
2711                  and  el.element_link_id = ee.element_link_id
2712                  and  ee.effective_start_date between el.effective_start_date
2713                                                   and el.effective_end_date
2714                  and  et.element_type_id = el.element_type_id
2715                  and  ee.effective_start_date between et.effective_start_date
2716                                                   and et.effective_end_date
2717                  and  et.processing_type = 'R');
2718 
2719      elsif p_entry_type = 'B' then
2720 
2721        if g_debug then
2722           hr_utility.set_location(l_proc, 30);
2723        end if;
2724 
2725        open csr_adj_orig_entry;
2726        fetch csr_adj_orig_entry into v_number_variable;
2727        if csr_adj_orig_entry%notfound then
2728          close csr_adj_orig_entry;
2729          raise no_data_found;
2730        end if;
2731        close csr_adj_orig_entry;
2732 
2733      else
2734        if g_debug then
2735           hr_utility.set_location(l_proc, 40);
2736        end if;
2737 
2738        raise no_data_found;
2739      end if;
2740 
2741 --
2742    exception
2743      when no_data_found then
2744        hr_utility.set_message(801, 'HR_7031_ELE_ENTRY_OE_INVLD');
2745        hr_utility.raise_error;
2746    end;
2747 
2748    if g_debug then
2749       hr_utility.set_location('Leaving: '||l_proc, 80);
2750    end if;
2751 --
2752  end val_original_entry;
2753 --
2754  ------------------------------------------------------------------------------
2755  -- NAME                                                                     --
2756  -- hr_entry_api.val_reason                                                  --
2757  --                                                                          --
2758  -- DESCRIPTION                                                              --
2759  -- Make sure reason is valid.                                               --
2760  ------------------------------------------------------------------------------
2761 --
2762  procedure val_reason
2763  (
2764   p_reason varchar2,
2765   p_effective_date date
2766  ) is
2767 --
2768    -- Local Variables
2769    v_varchar_variable varchar2(30);
2770 --
2771  begin
2772 --
2773    begin
2774 --
2775      select hl.lookup_code
2776      into   v_varchar_variable
2777      from   hr_lookups hl
2778      where  hl.lookup_type = 'ELE_ENTRY_REASON'
2779        and  hl.lookup_code = p_reason
2780        and  hl.enabled_flag = 'Y'
2781        and  p_effective_date between
2782             nvl(hl.start_date_active,p_effective_date) and nvl(hl.end_date_active,p_effective_date);
2783 --
2784    exception
2785      when no_data_found then
2786        hr_utility.set_message(801, 'HR_7032_ELE_ENTRY_INV_REASON');
2787        hr_utility.raise_error;
2788    end;
2789 --
2790  end val_reason;
2791 --
2792 -------------------------------------------------------------------------------
2793 -- NAME                                                                      --
2794 -- hr_entry_api.derive_element_type_id                                       --
2795 --                                                                           --
2796 -- DESCRIPTION                                                               --
2797 -- Derives the element_type_id from the previously validated element_link_id --
2798 -- The resulting element_type_id will populate the denormalised column,      --
2799 -- element_type_id on pay_element_entries_f.                                 --
2800 --                                                                           --
2801 -------------------------------------------------------------------------------
2802 FUNCTION derive_element_type_id (p_element_link_id in number
2803                                 ,p_effective_date  in date)
2804 RETURN number IS
2805 --
2806 l_ele_type_id pay_element_types_f.element_type_id%type;
2807 --
2808 BEGIN
2809   select element_type_id
2810   into   l_ele_type_id
2811   from   pay_element_links_f
2812   where  element_link_id = p_element_link_id
2813   and    p_effective_date between effective_start_date
2814                               and effective_end_date;
2815 --
2816 return l_ele_type_id;
2817 --
2818 END derive_element_type_id;
2819 --
2820 -------------------------------------------------------------------------------
2821 -- NAME                                                                      --
2822 -- hr_entry_api.derive_all_entry_values_null                                 --
2823 --                                                                           --
2824 -- DESCRIPTION                                                               --
2825 -- If one or more Element Entry Values exist for the current Element Entry   --
2826 -- and the SCREEN_ENTRY_VALUE for all those Entry Values is NULL, this       --
2827 -- function returns 'Y', otherwise it returns NULL.                          --
2828 --                                                                           --
2829 -------------------------------------------------------------------------------
2830 FUNCTION derive_all_entry_values_null (
2831   p_entry_value_tbl in hr_entry.varchar2_table
2832   ) RETURN varchar2
2833 IS
2834   --
2835   l_all_entry_values_null varchar2(30);
2836   l_counter               number;
2837   --
2838 BEGIN
2839   --
2840   g_debug := hr_utility.debug_enabled;
2841   --
2842   if g_debug then
2843       hr_utility.set_location(
2844         'Entering hr_entry_api.derive_all_entry_values_null', 5
2845         );
2846   end if;
2847   --
2848   -- First, check to see if there are any entry values...
2849   --
2850   if p_entry_value_tbl.COUNT > 0 then
2851     --
2852     if g_debug then
2853         hr_utility.set_location('derive_all_entry_values_null', 10);
2854     end if;
2855     --
2856     l_counter := 1;
2857     --
2858     -- Now, loop through and examine each entry value until either
2859     -- a non-null entry value is found or the last entry value is
2860     -- reached...
2861     --
2862     while l_counter <= p_entry_value_tbl.COUNT loop
2863       --
2864       -- We are not interested in further entry values if this one is not
2865       -- null...
2866       --
2867       exit when p_entry_value_tbl(l_counter) is not null;
2868       --
2869       if g_debug then
2870           hr_utility.set_location('derive_all_entry_values_null', 15);
2871           hr_utility.trace('| Entry value '||to_char(l_counter)||' is null.');
2872       end if;
2873       --
2874       if l_counter = p_entry_value_tbl.COUNT then
2875         --
2876         -- This is the last entry value, and it is null.
2877         -- Therefore all the previous entry values must be
2878         -- null too (otherwise we would have exited the loop).
2879         --
2880         if g_debug then
2881             hr_utility.set_location('derive_all_entry_values_null', 20);
2882             hr_utility.trace('| All entry values are null');
2883         end if;
2884         --
2885         l_all_entry_values_null := 'Y';
2886         --
2887       end if;
2888       --
2889       l_counter := l_counter + 1;
2890       --
2891     end loop;
2892     --
2893   else
2894     --
2895     -- There are no entry values for this element entry.
2896     --
2897     if g_debug then
2898         hr_utility.set_location('derive_all_entry_values_null', 25);
2899         hr_utility.trace('| No entry values exist');
2900     end if;
2901     --
2902     l_all_entry_values_null := null;
2903     --
2904   end if;
2905   --
2906   if g_debug then
2907       hr_utility.set_location('Leaving: derive_all_entry_values_null', 900);
2908       hr_utility.trace('| Returning l_all_entry_values_null: '||nvl(l_all_entry_values_null,'NULL'));
2909   end if;
2910   --
2911   return l_all_entry_values_null;
2912   --
2913 END derive_all_entry_values_null;
2914 --
2915  ------------------------------------------------------------------------------
2916  -- NAME                                                                     --
2917  -- hr_entry_api.ins_ele_entry_param_val                                     --
2918  --                                                                          --
2919  -- DESCRIPTION                                                              --
2920  -- Validates the parameters passed to hr_entry.insert_element_entry. See    --
2921  -- below for a list of the validation steps :                               --
2922  --                                                                          --
2923  -- 1. Check assignment exists.                                              --
2924  -- 2. Check element link exists.                                            --
2925  -- 3. Check costing exists if applicable.                                   --
2926  -- 4. Check comment exists if applicable.                                   --
2927  -- 5. Updating action cannot be set when creating an entry.                 --
2928  -- 6. For an adjustment a target entry should be set and the target entry   --
2929  --    should be recurring.                                                  --
2930  --                                                                          --
2931  -- NB. p_creator_type is validated by constraint                            --
2932  --     PAY_EL_ENTRY_CREATOR_TYPE_CHK                                        --
2933  --     p_entry_type is validated by constraint PAY_EL_ENTRY_ENTRY_TYPE_CHK. --
2934  ------------------------------------------------------------------------------
2935  procedure ins_ele_entry_param_val
2936  (
2937   p_effective_start_date       date,
2938   p_assignment_id              number,
2939   p_element_link_id            number,
2940   p_creator_type               varchar2,
2941   p_entry_type                 varchar2,
2942   p_cost_allocation_keyflex_id number,
2943   p_updating_action_id         number,
2944   p_updating_action_type       varchar2,
2945   p_comment_id                 number,
2946   p_original_entry_id          number,
2947   p_reason                     varchar2,
2948   p_target_entry_id            number
2949  ) is
2950    --
2951    -- Local variables
2952    --
2953    v_number_variable number;
2954    --
2955  begin
2956    --
2957    -- Make sure assignment exists
2958    --
2959    hr_entry_api.val_assignment
2960      (p_assignment_id,
2961       p_effective_start_date);
2962    --
2963    -- Make sure element link exists
2964    --
2965    hr_entry_api.val_element_link
2966      (p_element_link_id,
2967       p_effective_start_date);
2968    --
2969    -- If specified make sure cost allocation exists
2970    --
2971    if p_cost_allocation_keyflex_id is not null then
2972      --
2973      hr_entry_api.val_cost_allocation
2974        (p_cost_allocation_keyflex_id);
2975      --
2976    end if;
2977    --
2978    -- If specified make sure reason is a valid lookup
2979    --
2980    if p_reason is not null then
2981      --
2982      hr_entry_api.val_reason
2983        (p_reason,
2984         p_effective_start_date);
2985      --
2986    end if;
2987    --
2988    -- If specified make sure comment exists
2989    --
2990    if p_comment_id is not null then
2991      --
2992      hr_entry_api.val_comment
2993        (p_comment_id);
2994      --
2995    end if;
2996    --
2997    -- If specified make sure original entry is for the same assignment and
2998    -- element link as the element entry being created
2999    --
3000    if p_original_entry_id is not null then
3001      --
3002      hr_entry_api.val_original_entry
3003        (p_original_entry_id,
3004         p_assignment_id,
3005         p_element_link_id,
3006         p_entry_type,
3007         p_effective_start_date);
3008      --
3009    end if;
3010    --
3011    -- If element entry is an adjustment make sure that the target entry exists
3012    -- and that it is a normal entry for a recurring element
3013    --
3014    if p_entry_type in ('R','A') then
3015      --
3016      hr_entry_api.val_adjustment
3017        (p_assignment_id,
3018         p_element_link_id,
3019         p_target_entry_id,
3020         p_entry_type,
3021         p_effective_start_date);
3022      --
3023    end if;
3024    --
3025  end ins_ele_entry_param_val;
3026 --
3027 -- --
3028 --
3029 -- -----------------------------------------------------------------------
3030 -- |-----------------------< ddf_insert_validate >-----------------------|
3031 -- -----------------------------------------------------------------------
3032 --
3033 -- Description:
3034 --   Validates the all Developer Descriptive Flexfield values prior
3035 --   to insert.
3036 --
3037 -- Pre-conditions:
3038 --   All other columns have been validated. Must be called as the
3039 --   last step before ins_element_entry.
3040 --
3041 -- Post Success:
3042 --   If the Developer Descriptive Flexfield structure column and data
3043 --   values are all valid this procedure will end normally and processing
3044 --   will continue.
3045 --
3046 -- Post Failure:
3047 --   If the DDF structure column value or any of
3048 --   the data values are invalid then an application error is raised as
3049 --   a PL/SQL exception.
3050 --
3051 procedure ddf_insert_validate
3052   (
3053   p_entry_information_category varchar2  default null,
3054   p_entry_information1         varchar2  default null,
3055   p_entry_information2         varchar2  default null,
3056   p_entry_information3         varchar2  default null,
3057   p_entry_information4         varchar2  default null,
3058   p_entry_information5         varchar2  default null,
3059   p_entry_information6         varchar2  default null,
3060   p_entry_information7         varchar2  default null,
3061   p_entry_information8         varchar2  default null,
3062   p_entry_information9         varchar2  default null,
3063   p_entry_information10        varchar2  default null,
3064   p_entry_information11        varchar2  default null,
3065   p_entry_information12        varchar2  default null,
3066   p_entry_information13        varchar2  default null,
3067   p_entry_information14        varchar2  default null,
3068   p_entry_information15        varchar2  default null,
3069   p_entry_information16        varchar2  default null,
3070   p_entry_information17        varchar2  default null,
3071   p_entry_information18        varchar2  default null,
3072   p_entry_information19        varchar2  default null,
3073   p_entry_information20        varchar2  default null,
3074   p_entry_information21        varchar2  default null,
3075   p_entry_information22        varchar2  default null,
3076   p_entry_information23        varchar2  default null,
3077   p_entry_information24        varchar2  default null,
3078   p_entry_information25        varchar2  default null,
3079   p_entry_information26        varchar2  default null,
3080   p_entry_information27        varchar2  default null,
3081   p_entry_information28        varchar2  default null,
3082   p_entry_information29        varchar2  default null,
3083   p_entry_information30        varchar2  default null
3084   ) is
3085 --
3086   l_proc    varchar2(72) := g_package||'ddf_insert_validate';
3087 --
3088 begin
3089   --
3090     hr_dflex_utility.ins_or_upd_descflex_attribs
3091       (p_appl_short_name    => 'PAY'
3092       ,p_descflex_name      => 'Element Entry Developer DF'
3093       ,p_attribute_category => p_entry_information_category
3094       ,p_attribute1_name    => 'ENTRY_INFORMATION1'
3095       ,p_attribute1_value   => p_entry_information1
3096       ,p_attribute2_name    => 'ENTRY_INFORMATION2'
3097       ,p_attribute2_value   => p_entry_information2
3098       ,p_attribute3_name    => 'ENTRY_INFORMATION3'
3099       ,p_attribute3_value   => p_entry_information3
3100       ,p_attribute4_name    => 'ENTRY_INFORMATION4'
3101       ,p_attribute4_value   => p_entry_information4
3102       ,p_attribute5_name    => 'ENTRY_INFORMATION5'
3103       ,p_attribute5_value   => p_entry_information5
3104       ,p_attribute6_name    => 'ENTRY_INFORMATION6'
3105       ,p_attribute6_value   => p_entry_information6
3106       ,p_attribute7_name    => 'ENTRY_INFORMATION7'
3107       ,p_attribute7_value   => p_entry_information7
3108       ,p_attribute8_name    => 'ENTRY_INFORMATION8'
3109       ,p_attribute8_value   => p_entry_information8
3110       ,p_attribute9_name    => 'ENTRY_INFORMATION9'
3111       ,p_attribute9_value   => p_entry_information9
3112       ,p_attribute10_name    => 'ENTRY_INFORMATION10'
3113       ,p_attribute10_value   => p_entry_information10
3114       ,p_attribute11_name    => 'ENTRY_INFORMATION11'
3115       ,p_attribute11_value   => p_entry_information11
3116       ,p_attribute12_name    => 'ENTRY_INFORMATION12'
3117       ,p_attribute12_value   => p_entry_information12
3118       ,p_attribute13_name    => 'ENTRY_INFORMATION13'
3119       ,p_attribute13_value   => p_entry_information13
3120       ,p_attribute14_name    => 'ENTRY_INFORMATION14'
3121       ,p_attribute14_value   => p_entry_information14
3122       ,p_attribute15_name    => 'ENTRY_INFORMATION15'
3123       ,p_attribute15_value   => p_entry_information15
3124       ,p_attribute16_name    => 'ENTRY_INFORMATION16'
3125       ,p_attribute16_value   => p_entry_information16
3126       ,p_attribute17_name    => 'ENTRY_INFORMATION17'
3127       ,p_attribute17_value   => p_entry_information17
3128       ,p_attribute18_name    => 'ENTRY_INFORMATION18'
3129       ,p_attribute18_value   => p_entry_information18
3130       ,p_attribute19_name    => 'ENTRY_INFORMATION19'
3131       ,p_attribute19_value   => p_entry_information19
3132       ,p_attribute20_name    => 'ENTRY_INFORMATION20'
3133       ,p_attribute20_value   => p_entry_information20
3134       ,p_attribute21_name    => 'ENTRY_INFORMATION21'
3135       ,p_attribute21_value   => p_entry_information21
3136       ,p_attribute22_name    => 'ENTRY_INFORMATION22'
3137       ,p_attribute22_value   => p_entry_information22
3138       ,p_attribute23_name    => 'ENTRY_INFORMATION23'
3139       ,p_attribute23_value   => p_entry_information23
3140       ,p_attribute24_name    => 'ENTRY_INFORMATION24'
3141       ,p_attribute24_value   => p_entry_information24
3142       ,p_attribute25_name    => 'ENTRY_INFORMATION25'
3143       ,p_attribute25_value   => p_entry_information25
3144       ,p_attribute26_name    => 'ENTRY_INFORMATION26'
3145       ,p_attribute26_value   => p_entry_information26
3146       ,p_attribute27_name    => 'ENTRY_INFORMATION27'
3147       ,p_attribute27_value   => p_entry_information27
3148       ,p_attribute28_name    => 'ENTRY_INFORMATION28'
3149       ,p_attribute28_value   => p_entry_information28
3150       ,p_attribute29_name    => 'ENTRY_INFORMATION29'
3151       ,p_attribute29_value   => p_entry_information29
3152       ,p_attribute30_name    => 'ENTRY_INFORMATION30'
3153       ,p_attribute30_value   => p_entry_information30
3154       );
3155 end ddf_insert_validate;
3156 --
3157 -- --
3158 --
3159 -- -----------------------------------------------------------------------
3160 -- |----------------------< ddf_update_validate >------------------------|
3161 -- -----------------------------------------------------------------------
3162 --
3163 -- Description:
3164 --   Validates the all Developer Descriptive Flexfield values prior
3165 --   to update.
3166 --
3167 -- Pre-conditions:
3168 --   All other columns have been validated. Must be called as the
3169 --   last step before upd_element_entry.
3170 --
3171 -- Post Success:
3172 --   If the Developer Descriptive Flexfield structure column and data
3173 --   values are all valid this procedure will end normally and processing
3174 --   will continue.
3175 --
3176 -- Post Failure:
3177 --   If the DDF structure column value or any of
3178 --   the data values are invalid then an application error is raised as
3179 --   a PL/SQL exception.
3180 --
3181 procedure ddf_update_validate
3182   (
3183   p_entry_information_category varchar2  default null,
3184   p_entry_information1         varchar2  default null,
3185   p_entry_information2         varchar2  default null,
3186   p_entry_information3         varchar2  default null,
3187   p_entry_information4         varchar2  default null,
3188   p_entry_information5         varchar2  default null,
3189   p_entry_information6         varchar2  default null,
3190   p_entry_information7         varchar2  default null,
3191   p_entry_information8         varchar2  default null,
3192   p_entry_information9         varchar2  default null,
3193   p_entry_information10        varchar2  default null,
3194   p_entry_information11        varchar2  default null,
3195   p_entry_information12        varchar2  default null,
3196   p_entry_information13        varchar2  default null,
3197   p_entry_information14        varchar2  default null,
3198   p_entry_information15        varchar2  default null,
3199   p_entry_information16        varchar2  default null,
3200   p_entry_information17        varchar2  default null,
3201   p_entry_information18        varchar2  default null,
3202   p_entry_information19        varchar2  default null,
3203   p_entry_information20        varchar2  default null,
3204   p_entry_information21        varchar2  default null,
3205   p_entry_information22        varchar2  default null,
3206   p_entry_information23        varchar2  default null,
3207   p_entry_information24        varchar2  default null,
3208   p_entry_information25        varchar2  default null,
3209   p_entry_information26        varchar2  default null,
3210   p_entry_information27        varchar2  default null,
3211   p_entry_information28        varchar2  default null,
3212   p_entry_information29        varchar2  default null,
3213   p_entry_information30        varchar2  default null,
3214   p_entry_information_category_o varchar2  default null,
3215   p_entry_information1_o         varchar2  default null,
3216   p_entry_information2_o         varchar2  default null,
3217   p_entry_information3_o         varchar2  default null,
3218   p_entry_information4_o         varchar2  default null,
3219   p_entry_information5_o         varchar2  default null,
3220   p_entry_information6_o         varchar2  default null,
3221   p_entry_information7_o         varchar2  default null,
3222   p_entry_information8_o         varchar2  default null,
3223   p_entry_information9_o         varchar2  default null,
3224   p_entry_information10_o        varchar2  default null,
3225   p_entry_information11_o        varchar2  default null,
3226   p_entry_information12_o        varchar2  default null,
3227   p_entry_information13_o        varchar2  default null,
3228   p_entry_information14_o        varchar2  default null,
3229   p_entry_information15_o        varchar2  default null,
3230   p_entry_information16_o        varchar2  default null,
3231   p_entry_information17_o        varchar2  default null,
3232   p_entry_information18_o        varchar2  default null,
3233   p_entry_information19_o        varchar2  default null,
3234   p_entry_information20_o        varchar2  default null,
3235   p_entry_information21_o        varchar2  default null,
3236   p_entry_information22_o        varchar2  default null,
3237   p_entry_information23_o        varchar2  default null,
3238   p_entry_information24_o        varchar2  default null,
3239   p_entry_information25_o        varchar2  default null,
3240   p_entry_information26_o        varchar2  default null,
3241   p_entry_information27_o        varchar2  default null,
3242   p_entry_information28_o        varchar2  default null,
3243   p_entry_information29_o        varchar2  default null,
3244   p_entry_information30_o        varchar2  default null
3245   ) is
3246 --
3247   l_proc    varchar2(72) := g_package||'ddf_update_validate';
3248   -- local attribute values
3249   l_attribute1_value    varchar2(150);
3250   l_attribute2_value    varchar2(150);
3251   l_attribute3_value    varchar2(150);
3252   l_attribute4_value    varchar2(150);
3253   l_attribute5_value    varchar2(150);
3254   l_attribute6_value    varchar2(150);
3255   l_attribute7_value    varchar2(150);
3256   l_attribute8_value    varchar2(150);
3257   l_attribute9_value    varchar2(150);
3258   l_attribute10_value   varchar2(150);
3259   l_attribute11_value   varchar2(150);
3260   l_attribute12_value   varchar2(150);
3261   l_attribute13_value   varchar2(150);
3262   l_attribute14_value   varchar2(150);
3263   l_attribute15_value   varchar2(150);
3264   l_attribute16_value   varchar2(150);
3265   l_attribute17_value   varchar2(150);
3266   l_attribute18_value   varchar2(150);
3267   l_attribute19_value   varchar2(150);
3268   l_attribute20_value   varchar2(150);
3269   l_attribute21_value   varchar2(150);
3270   l_attribute22_value   varchar2(150);
3271   l_attribute23_value   varchar2(150);
3272   l_attribute24_value   varchar2(150);
3273   l_attribute25_value   varchar2(150);
3274   l_attribute26_value   varchar2(150);
3275   l_attribute27_value   varchar2(150);
3276   l_attribute28_value   varchar2(150);
3277   l_attribute29_value   varchar2(150);
3278   l_attribute30_value   varchar2(150);
3279 --
3280 begin
3281   --
3282   if nvl(p_entry_information_category,hr_api.g_varchar2) <>
3283      nvl(p_entry_information_category_o,hr_api.g_varchar2) or
3284      nvl(p_entry_information1,hr_api.g_varchar2) <>
3285      nvl(p_entry_information1_o,hr_api.g_varchar2) or
3286      nvl(p_entry_information2,hr_api.g_varchar2) <>
3287      nvl(p_entry_information2_o,hr_api.g_varchar2) or
3288      nvl(p_entry_information3,hr_api.g_varchar2) <>
3289      nvl(p_entry_information3_o,hr_api.g_varchar2) or
3290      nvl(p_entry_information4,hr_api.g_varchar2) <>
3291      nvl(p_entry_information4_o,hr_api.g_varchar2) or
3292      nvl(p_entry_information5,hr_api.g_varchar2) <>
3293      nvl(p_entry_information5_o,hr_api.g_varchar2) or
3294      nvl(p_entry_information6,hr_api.g_varchar2) <>
3295      nvl(p_entry_information6_o,hr_api.g_varchar2) or
3296      nvl(p_entry_information7,hr_api.g_varchar2) <>
3297      nvl(p_entry_information7_o,hr_api.g_varchar2) or
3298      nvl(p_entry_information8,hr_api.g_varchar2) <>
3299      nvl(p_entry_information8_o,hr_api.g_varchar2) or
3300      nvl(p_entry_information9,hr_api.g_varchar2) <>
3301      nvl(p_entry_information9_o,hr_api.g_varchar2) or
3302      nvl(p_entry_information10,hr_api.g_varchar2) <>
3303      nvl(p_entry_information10_o,hr_api.g_varchar2) or
3304      nvl(p_entry_information11,hr_api.g_varchar2) <>
3305      nvl(p_entry_information11_o,hr_api.g_varchar2) or
3306      nvl(p_entry_information12,hr_api.g_varchar2) <>
3307      nvl(p_entry_information12_o,hr_api.g_varchar2) or
3308      nvl(p_entry_information13,hr_api.g_varchar2) <>
3309      nvl(p_entry_information13_o,hr_api.g_varchar2) or
3310      nvl(p_entry_information14,hr_api.g_varchar2) <>
3311      nvl(p_entry_information14_o,hr_api.g_varchar2) or
3312      nvl(p_entry_information15,hr_api.g_varchar2) <>
3313      nvl(p_entry_information15_o,hr_api.g_varchar2) or
3314      nvl(p_entry_information16,hr_api.g_varchar2) <>
3315      nvl(p_entry_information16_o,hr_api.g_varchar2) or
3316      nvl(p_entry_information17,hr_api.g_varchar2) <>
3317      nvl(p_entry_information17_o,hr_api.g_varchar2) or
3318      nvl(p_entry_information18,hr_api.g_varchar2) <>
3319      nvl(p_entry_information18_o,hr_api.g_varchar2) or
3320      nvl(p_entry_information19,hr_api.g_varchar2) <>
3321      nvl(p_entry_information19_o,hr_api.g_varchar2) or
3322      nvl(p_entry_information20,hr_api.g_varchar2) <>
3323      nvl(p_entry_information20_o,hr_api.g_varchar2) or
3324      nvl(p_entry_information21,hr_api.g_varchar2) <>
3325      nvl(p_entry_information21_o,hr_api.g_varchar2) or
3326      nvl(p_entry_information22,hr_api.g_varchar2) <>
3327      nvl(p_entry_information22_o,hr_api.g_varchar2) or
3328      nvl(p_entry_information23,hr_api.g_varchar2) <>
3329      nvl(p_entry_information23_o,hr_api.g_varchar2) or
3330      nvl(p_entry_information24,hr_api.g_varchar2) <>
3331      nvl(p_entry_information24_o,hr_api.g_varchar2) or
3332      nvl(p_entry_information25,hr_api.g_varchar2) <>
3333      nvl(p_entry_information25_o,hr_api.g_varchar2) or
3334      nvl(p_entry_information26,hr_api.g_varchar2) <>
3335      nvl(p_entry_information26_o,hr_api.g_varchar2) or
3336      nvl(p_entry_information27,hr_api.g_varchar2) <>
3337      nvl(p_entry_information27_o,hr_api.g_varchar2) or
3338      nvl(p_entry_information28,hr_api.g_varchar2) <>
3339      nvl(p_entry_information28_o,hr_api.g_varchar2) or
3340      nvl(p_entry_information29,hr_api.g_varchar2) <>
3341      nvl(p_entry_information29_o,hr_api.g_varchar2) or
3342      nvl(p_entry_information30,hr_api.g_varchar2) <>
3343      nvl(p_entry_information30_o,hr_api.g_varchar2)
3344   then
3345     --
3346     -- For validation purposes only, we use null instead of
3347     -- hr_api.g_varchar2
3348     --
3349     if p_entry_information1 = hr_api.g_varchar2 then
3350       l_attribute1_value := null;
3351     else
3352       l_attribute1_value := p_entry_information1;
3353     end if;
3354     --
3355     if p_entry_information2 = hr_api.g_varchar2 then
3356       l_attribute2_value := null;
3357     else
3358       l_attribute2_value := p_entry_information2;
3359     end if;
3360     --
3361     if p_entry_information3 = hr_api.g_varchar2 then
3362       l_attribute3_value := null;
3363     else
3364       l_attribute3_value := p_entry_information3;
3365     end if;
3366     --
3367     if p_entry_information4 = hr_api.g_varchar2 then
3368       l_attribute4_value := null;
3369     else
3370       l_attribute4_value := p_entry_information4;
3371     end if;
3372     --
3373     if p_entry_information5 = hr_api.g_varchar2 then
3374       l_attribute5_value := null;
3375     else
3376       l_attribute5_value := p_entry_information5;
3377     end if;
3378     --
3379     if p_entry_information6 = hr_api.g_varchar2 then
3380       l_attribute6_value := null;
3381     else
3382       l_attribute6_value := p_entry_information6;
3383     end if;
3384     --
3385     if p_entry_information7 = hr_api.g_varchar2 then
3386       l_attribute7_value := null;
3387     else
3388       l_attribute7_value := p_entry_information7;
3389     end if;
3390     --
3391     if p_entry_information8 = hr_api.g_varchar2 then
3392       l_attribute8_value := null;
3393     else
3394       l_attribute8_value := p_entry_information8;
3395     end if;
3396     --
3397     if p_entry_information9 = hr_api.g_varchar2 then
3398       l_attribute9_value := null;
3399     else
3400       l_attribute9_value := p_entry_information9;
3401     end if;
3402     --
3403     if p_entry_information10 = hr_api.g_varchar2 then
3404       l_attribute10_value := null;
3405     else
3406       l_attribute10_value := p_entry_information10;
3407     end if;
3408     --
3409     if p_entry_information11 = hr_api.g_varchar2 then
3410       l_attribute11_value := null;
3411     else
3412       l_attribute11_value := p_entry_information11;
3413     end if;
3414     --
3415     if p_entry_information12 = hr_api.g_varchar2 then
3416       l_attribute12_value := null;
3417     else
3418       l_attribute12_value := p_entry_information12;
3419     end if;
3420     --
3421     if p_entry_information13 = hr_api.g_varchar2 then
3422       l_attribute13_value := null;
3423     else
3424       l_attribute13_value := p_entry_information13;
3425     end if;
3426     --
3427     if p_entry_information14 = hr_api.g_varchar2 then
3428       l_attribute14_value := null;
3429     else
3430       l_attribute14_value := p_entry_information14;
3431     end if;
3432     --
3433     if p_entry_information15 = hr_api.g_varchar2 then
3434       l_attribute15_value := null;
3435     else
3436       l_attribute15_value := p_entry_information15;
3437     end if;
3438     --
3439     if p_entry_information16 = hr_api.g_varchar2 then
3440       l_attribute16_value := null;
3441     else
3442       l_attribute16_value := p_entry_information16;
3443     end if;
3444     --
3445     if p_entry_information17 = hr_api.g_varchar2 then
3446       l_attribute17_value := null;
3447     else
3448       l_attribute17_value := p_entry_information17;
3449     end if;
3450     --
3451     if p_entry_information18 = hr_api.g_varchar2 then
3452       l_attribute18_value := null;
3453     else
3454       l_attribute18_value := p_entry_information18;
3455     end if;
3456     --
3457     if p_entry_information19 = hr_api.g_varchar2 then
3458       l_attribute19_value := null;
3459     else
3460       l_attribute19_value := p_entry_information19;
3461     end if;
3462     --
3463     if p_entry_information20 = hr_api.g_varchar2 then
3464       l_attribute20_value := null;
3465     else
3466       l_attribute20_value := p_entry_information20;
3467     end if;
3468     --
3469     if p_entry_information21 = hr_api.g_varchar2 then
3470       l_attribute21_value := null;
3471     else
3472       l_attribute21_value := p_entry_information21;
3473     end if;
3474     --
3475     if p_entry_information22 = hr_api.g_varchar2 then
3476       l_attribute22_value := null;
3477     else
3478       l_attribute22_value := p_entry_information22;
3479    end if;
3480     --
3481     if p_entry_information23 = hr_api.g_varchar2 then
3482       l_attribute23_value := null;
3483     else
3484       l_attribute23_value := p_entry_information23;
3485     end if;
3486     --
3487     if p_entry_information24 = hr_api.g_varchar2 then
3488       l_attribute24_value := null;
3489     else
3490       l_attribute24_value := p_entry_information24;
3491     end if;
3492     --
3493     if p_entry_information25 = hr_api.g_varchar2 then
3494       l_attribute25_value := null;
3495     else
3496       l_attribute25_value := p_entry_information25;
3497     end if;
3498     --
3499     if p_entry_information26 = hr_api.g_varchar2 then
3500       l_attribute26_value := null;
3501     else
3502       l_attribute26_value := p_entry_information26;
3503     end if;
3504     --
3505     if p_entry_information27 = hr_api.g_varchar2 then
3506       l_attribute27_value := null;
3507     else
3508       l_attribute27_value := p_entry_information27;
3509     end if;
3510     --
3511     if p_entry_information28 = hr_api.g_varchar2 then
3512       l_attribute28_value := null;
3513     else
3514       l_attribute28_value := p_entry_information28;
3515     end if;
3516     --
3517     if p_entry_information29 = hr_api.g_varchar2 then
3518       l_attribute29_value := null;
3519     else
3520       l_attribute29_value := p_entry_information29;
3521     end if;
3522     --
3523     if p_entry_information30 = hr_api.g_varchar2 then
3524       l_attribute30_value := null;
3525     else
3526       l_attribute30_value := p_entry_information30;
3527     end if;
3528     --
3529     hr_dflex_utility.ins_or_upd_descflex_attribs
3530       (p_appl_short_name    => 'PAY'
3531       ,p_descflex_name      => 'Element Entry Developer DF'
3532       ,p_attribute_category => p_entry_information_category
3533       ,p_attribute1_name    => 'ENTRY_INFORMATION1'
3534       ,p_attribute1_value   => l_attribute1_value
3535       ,p_attribute2_name    => 'ENTRY_INFORMATION2'
3536       ,p_attribute2_value   => l_attribute2_value
3537       ,p_attribute3_name    => 'ENTRY_INFORMATION3'
3538       ,p_attribute3_value   => l_attribute3_value
3539       ,p_attribute4_name    => 'ENTRY_INFORMATION4'
3540       ,p_attribute4_value   => l_attribute4_value
3541       ,p_attribute5_name    => 'ENTRY_INFORMATION5'
3542       ,p_attribute5_value   => l_attribute5_value
3543       ,p_attribute6_name    => 'ENTRY_INFORMATION6'
3544       ,p_attribute6_value   => l_attribute6_value
3545       ,p_attribute7_name    => 'ENTRY_INFORMATION7'
3546       ,p_attribute7_value   => l_attribute7_value
3547       ,p_attribute8_name    => 'ENTRY_INFORMATION8'
3548       ,p_attribute8_value   => l_attribute8_value
3549       ,p_attribute9_name    => 'ENTRY_INFORMATION9'
3550       ,p_attribute9_value   => l_attribute9_value
3551       ,p_attribute10_name    => 'ENTRY_INFORMATION10'
3552       ,p_attribute10_value   => l_attribute10_value
3553       ,p_attribute11_name    => 'ENTRY_INFORMATION11'
3554       ,p_attribute11_value   => l_attribute11_value
3555       ,p_attribute12_name    => 'ENTRY_INFORMATION12'
3556       ,p_attribute12_value   => l_attribute12_value
3557       ,p_attribute13_name    => 'ENTRY_INFORMATION13'
3558       ,p_attribute13_value   => l_attribute13_value
3559       ,p_attribute14_name    => 'ENTRY_INFORMATION14'
3560       ,p_attribute14_value   => l_attribute14_value
3561       ,p_attribute15_name    => 'ENTRY_INFORMATION15'
3562       ,p_attribute15_value   => l_attribute15_value
3563       ,p_attribute16_name    => 'ENTRY_INFORMATION16'
3564       ,p_attribute16_value   => l_attribute16_value
3565       ,p_attribute17_name    => 'ENTRY_INFORMATION17'
3566       ,p_attribute17_value   => l_attribute17_value
3567       ,p_attribute18_name    => 'ENTRY_INFORMATION18'
3568       ,p_attribute18_value   => l_attribute18_value
3569       ,p_attribute19_name    => 'ENTRY_INFORMATION19'
3570       ,p_attribute19_value   => l_attribute19_value
3571       ,p_attribute20_name    => 'ENTRY_INFORMATION20'
3572       ,p_attribute20_value   => l_attribute20_value
3573       ,p_attribute21_name    => 'ENTRY_INFORMATION21'
3574       ,p_attribute21_value   => l_attribute21_value
3575       ,p_attribute22_name    => 'ENTRY_INFORMATION22'
3576       ,p_attribute22_value   => l_attribute22_value
3577       ,p_attribute23_name    => 'ENTRY_INFORMATION23'
3578       ,p_attribute23_value   => l_attribute23_value
3579       ,p_attribute24_name    => 'ENTRY_INFORMATION24'
3580       ,p_attribute24_value   => l_attribute24_value
3581       ,p_attribute25_name    => 'ENTRY_INFORMATION25'
3582       ,p_attribute25_value   => l_attribute25_value
3583       ,p_attribute26_name    => 'ENTRY_INFORMATION26'
3584       ,p_attribute26_value   => l_attribute26_value
3585       ,p_attribute27_name    => 'ENTRY_INFORMATION27'
3586       ,p_attribute27_value   => l_attribute27_value
3587       ,p_attribute28_name    => 'ENTRY_INFORMATION28'
3588       ,p_attribute28_value   => l_attribute28_value
3589       ,p_attribute29_name    => 'ENTRY_INFORMATION29'
3590       ,p_attribute29_value   => l_attribute29_value
3591       ,p_attribute30_name    => 'ENTRY_INFORMATION30'
3592       ,p_attribute30_value   => l_attribute30_value
3593       );
3594   --
3595   end if;
3596   --
3597 end ddf_update_validate;
3598 --
3599 -- --
3600 --
3601  ------------------------------------------------------------------------------
3602  -- NAME                                                                     --
3603  -- hr_entry_api.ins_element_entry                                           --
3604  --                                                                          --
3605  -- DESCRIPTION                                                              --
3606  -- Inserts an element entry providing full validation and also making sure  --
3607  -- the end date is set correctly ie. taking into account future entries,    --
3608  -- chnages in eligibility etc ...                                           --
3609  ------------------------------------------------------------------------------
3610 --
3611  procedure ins_element_entry
3612  (
3613   --
3614   -- Common Parameters
3615   --
3616   p_effective_start_date       in out nocopy date,
3617   p_effective_end_date         in out nocopy date,
3618   --
3619   -- Element Entry Table
3620   --
3621   p_element_entry_id           in out nocopy number,
3622   p_original_entry_id          number,
3623   p_assignment_id              number,
3624   p_element_link_id            number,
3625   p_creator_type               varchar2,
3626   p_entry_type                 varchar2,
3627   p_cost_allocation_keyflex_id number,
3628   p_updating_action_id         number,
3629   p_updating_action_type       varchar2,
3630   p_comment_id                 number,
3631   p_creator_id                 number,
3632   p_reason                     varchar2,
3633   p_target_entry_id            number,
3634   p_subpriority                number,
3635   p_date_earned                 date,
3636   p_personal_payment_method_id  number,
3637   p_attribute_category         varchar2,
3638   p_attribute1                 varchar2,
3639   p_attribute2                 varchar2,
3640   p_attribute3                 varchar2,
3641   p_attribute4                 varchar2,
3642   p_attribute5                 varchar2,
3643   p_attribute6                 varchar2,
3644   p_attribute7                 varchar2,
3645   p_attribute8                 varchar2,
3646   p_attribute9                 varchar2,
3647   p_attribute10                varchar2,
3648   p_attribute11                varchar2,
3649   p_attribute12                varchar2,
3650   p_attribute13                varchar2,
3651   p_attribute14                varchar2,
3652   p_attribute15                varchar2,
3653   p_attribute16                varchar2,
3654   p_attribute17                varchar2,
3655   p_attribute18                varchar2,
3656   p_attribute19                varchar2,
3657   p_attribute20                varchar2,
3658   --
3659   -- Element Entry Values Table
3660   --
3661   p_num_entry_values           number,
3662   p_input_value_id_tbl         hr_entry.number_table,
3663   p_entry_value_tbl            hr_entry.varchar2_table,
3664   --
3665   -- J.Bailie Element Entries DDF
3666   --
3667   p_entry_information_category varchar2,
3668   p_entry_information1         varchar2,
3669   p_entry_information2         varchar2,
3670   p_entry_information3         varchar2,
3671   p_entry_information4         varchar2,
3672   p_entry_information5         varchar2,
3673   p_entry_information6         varchar2,
3674   p_entry_information7         varchar2,
3675   p_entry_information8         varchar2,
3676   p_entry_information9         varchar2,
3677   p_entry_information10        varchar2,
3678   p_entry_information11        varchar2,
3679   p_entry_information12        varchar2,
3680   p_entry_information13        varchar2,
3681   p_entry_information14        varchar2,
3682   p_entry_information15        varchar2,
3683   p_entry_information16        varchar2,
3684   p_entry_information17        varchar2,
3685   p_entry_information18        varchar2,
3686   p_entry_information19        varchar2,
3687   p_entry_information20        varchar2,
3688   p_entry_information21        varchar2,
3689   p_entry_information22        varchar2,
3690   p_entry_information23        varchar2,
3691   p_entry_information24        varchar2,
3692   p_entry_information25        varchar2,
3693   p_entry_information26        varchar2,
3694   p_entry_information27        varchar2,
3695   p_entry_information28        varchar2,
3696   p_entry_information29        varchar2,
3697   p_entry_information30        varchar2,
3698   p_label_identifier           varchar2
3699   ) is
3700    -- bug 666197
3701    cursor csr_object_version_number
3702      (p_element_entry_id number, p_effective_date date) is
3703       select object_version_number
3704         from pay_element_entries_f
3705         where element_entry_id = p_element_entry_id
3706           and p_effective_date between effective_start_date
3707                                    and effective_end_date;
3708    --
3709    -- Local Variables
3710    --
3711    v_element_entry_id   number;
3712    v_dummy_varchar      varchar2(30);
3713    l_object_version_number number;
3714    -- bug 666197
3715    l_effective_date date;
3716    --
3717    v_validation_start_date date;
3718    v_validation_end_date   date;
3719    --
3720    l_element_type_id       pay_element_types_f.element_type_id%type;
3721    --
3722    l_all_entry_values_null varchar2(30);
3723    --
3724  begin
3725    --
3726    -- bug 666197
3727    l_effective_date := p_effective_start_date;
3728    --
3729    -- Validate the parameters
3730    --
3731    hr_entry_api.ins_ele_entry_param_val
3732      (p_effective_start_date,
3733       p_assignment_id,
3734       p_element_link_id,
3735       p_creator_type,
3736       p_entry_type,
3737       p_cost_allocation_keyflex_id,
3738       p_updating_action_id,
3739       p_updating_action_type,
3740       p_comment_id,
3741       p_original_entry_id,
3742       p_reason,
3743       p_target_entry_id);
3744    --
3745    -- Validate the entry that is about to be created and also returns the
3746    -- valid start and end dates.
3747    --
3748    hr_entry.chk_element_entry_main
3749      (null,
3750       null,
3751       p_effective_start_date,
3752       p_element_link_id,
3753       p_assignment_id,
3754       p_entry_type,
3755       p_effective_start_date,
3756       p_effective_end_date,
3757       l_effective_date,
3758       hr_general.end_of_time,
3759       null,
3760       null,
3761       'INSERT',
3762       p_target_entry_id,
3763       p_creator_type);
3764    --
3765    -- Validate the date earned and personal_payment_method_id.
3766    -- NB These must be validated AFTER the effective dates have been
3767    -- determined.
3768    --
3769    validate_ppm_id (p_personal_payment_method_id,
3770                 p_assignment_id,
3771                 p_element_link_id,
3772                 p_effective_start_date,
3773                 p_effective_end_date,
3774                 p_entry_type);
3775                 --
3776    validate_date_earned (p_date_earned,
3777                         p_effective_start_date,
3778                         p_effective_end_date,
3779                         p_element_link_id,
3780                         p_entry_type);
3781                         --
3782    -- Trigger workload shifting if creation of element entry overlaps with the
3783    -- latest payroll run for the assignment and workload shifting is enabled.
3784    --
3785    hr_entry.trigger_workload_shifting
3786      ('ELEMENT_ENTRY',
3787       p_assignment_id,
3788       p_effective_start_date,
3789       p_effective_end_date);
3790    --
3791    -- J.Bailie 08-NOV-99 ddf_insert_validate needs to go in here
3792    --
3793   --
3794   -- check whether flexfield exists
3795   --
3796   if fnd_flex_dsc_api.flexfield_exists(
3797             appl_short_name => 'PAY',
3798             flexfield_name  => 'Element Entry Developer DF') then
3799 
3800     if g_debug then
3801        hr_utility.trace('| element entry DDFF defined');
3802        hr_utility.trace('| p_entry_information_category' ||
3803                            p_entry_information_category || '<');
3804     end if;
3805 
3806     --
3807     -- check whether the context value in ENTRY.entry_information_category
3808     -- has been defined/registered,
3809     -- only do FF validation if the context value has been defined/registered
3810     --
3811    if fnd_flex_dsc_api.context_exists(
3812          p_appl_short_name => 'PAY',
3813          p_flexfield_name  => 'Element Entry Developer DF',
3814          p_context_code    => p_entry_information_category) then
3815 
3816       if g_debug then
3817          hr_utility.trace('| element entry context in use, do validation');
3818       end if;
3819 
3820       hr_entry_api.ddf_insert_validate(
3821       p_entry_information_category,
3822          p_entry_information1,
3823          p_entry_information2,
3824          p_entry_information3,
3825          p_entry_information4,
3826          p_entry_information5,
3827          p_entry_information6,
3828          p_entry_information7,
3829          p_entry_information8,
3830          p_entry_information9,
3831          p_entry_information10,
3832          p_entry_information11,
3833          p_entry_information12,
3834          p_entry_information13,
3835          p_entry_information14,
3836          p_entry_information15,
3837          p_entry_information16,
3838          p_entry_information17,
3839          p_entry_information18,
3840          p_entry_information19,
3841          p_entry_information20,
3842          p_entry_information21,
3843          p_entry_information22,
3844          p_entry_information23,
3845          p_entry_information24,
3846          p_entry_information25,
3847          p_entry_information26,
3848          p_entry_information27,
3849          p_entry_information28,
3850          p_entry_information29,
3851          p_entry_information30);
3852 
3853      end if;
3854 
3855    end if;
3856    --
3857    -- Element_type_id denormalisation - the element_type_id will be derived
3858    -- from the element_link_id which has already been validated.
3859    --
3860      l_element_type_id := derive_element_type_id
3861                           (p_element_link_id => p_element_link_id
3862                           ,p_effective_date  => l_effective_date);
3863    --
3864    --
3865    --
3866    v_element_entry_id := hr_entry.generate_entry_id;
3867    --
3868    -- Bugfix 3110853
3869    -- Derive the OVN here instead of in the database trigger in order to
3870    -- avoid the ORA-04091 error
3871    --
3872    l_object_version_number := dt_api.get_object_version_number
3873                               ('PAY_ELEMENT_ENTRIES_F'
3874                               ,'ELEMENT_ENTRY_ID'
3875                               ,v_element_entry_id);
3876    --
3877    -- Enhancement 3478848
3878    -- Derive the all_entry_values_null value
3879    --
3880    l_all_entry_values_null := derive_all_entry_values_null(p_entry_value_tbl);
3881    --
3882    -- Create element entry
3883    --
3884    insert into pay_element_entries_f
3885    (effective_start_date,
3886     effective_end_date,
3887     element_entry_id,
3888     original_entry_id,
3889     assignment_id,
3890     element_link_id,
3891     creator_type,
3892     entry_type,
3893     cost_allocation_keyflex_id,
3894     updating_action_id,
3895     updating_action_type,
3896     comment_id,
3897     creator_id,
3898     reason,
3899     target_entry_id,
3900     subpriority,
3901     date_earned,
3902     personal_payment_method_id,
3903     attribute_category,
3904     attribute1,
3905     attribute2,
3906     attribute3,
3907     attribute4,
3908     attribute5,
3909     attribute6,
3910     attribute7,
3911     attribute8,
3912     attribute9,
3913     attribute10,
3914     attribute11,
3915     attribute12,
3916     attribute13,
3917     attribute14,
3918     attribute15,
3919     attribute16,
3920     attribute17,
3921     attribute18,
3922     attribute19,
3923     attribute20,
3924     last_update_date,
3925     last_updated_by,
3926     last_update_login,
3927     created_by,
3928     creation_date,
3929   --
3930   -- J.Bailie 08-NOV-99 Element Entries DDF
3931   --
3932     entry_information_category,
3933     entry_information1,
3934     entry_information2,
3935     entry_information3,
3936     entry_information4,
3937     entry_information5,
3938     entry_information6,
3939     entry_information7,
3940     entry_information8,
3941     entry_information9,
3942     entry_information10,
3943     entry_information11,
3944     entry_information12,
3945     entry_information13,
3946     entry_information14,
3947     entry_information15,
3948     entry_information16,
3949     entry_information17,
3950     entry_information18,
3951     entry_information19,
3952     entry_information20,
3953     entry_information21,
3954     entry_information22,
3955     entry_information23,
3956     entry_information24,
3957     entry_information25,
3958     entry_information26,
3959     entry_information27,
3960     entry_information28,
3961     entry_information29,
3962     entry_information30,
3963     element_type_id,
3964     all_entry_values_null,
3965     object_version_number,
3966     label_identifier
3967    )
3968    values
3969    (p_effective_start_date,
3970     p_effective_end_date,
3971     v_element_entry_id,
3972     p_original_entry_id,
3973     p_assignment_id,
3974     p_element_link_id,
3975     p_creator_type,
3976     p_entry_type,
3977     p_cost_allocation_keyflex_id,
3978     p_updating_action_id,
3979     p_updating_action_type,
3980     p_comment_id,
3981     p_creator_id,
3982     p_reason,
3983     p_target_entry_id,
3984     p_subpriority,
3985     p_date_earned,
3986     p_personal_payment_method_id,
3987     p_attribute_category,
3988     p_attribute1,
3989     p_attribute2,
3990     p_attribute3,
3991     p_attribute4,
3992     p_attribute5,
3993     p_attribute6,
3994     p_attribute7,
3995     p_attribute8,
3996     p_attribute9,
3997     p_attribute10,
3998     p_attribute11,
3999     p_attribute12,
4000     p_attribute13,
4001     p_attribute14,
4002     p_attribute15,
4003     p_attribute16,
4004     p_attribute17,
4005     p_attribute18,
4006     p_attribute19,
4007     p_attribute20,
4008     trunc(sysdate),
4009     0,
4010     0,
4011     -- Bug 570156 changed to null so the PAY_ELEMENT_ENTRIES_F_WHO trigger
4012     -- can set it. These parameters are not needed here at all, as the form
4013     -- is not passing them and api should not set them. It's always done via
4014     -- the database trigger.
4015     null,
4016     null,
4017   --
4018   -- J.Bailie 08-NOV-99 Element Entries DDF
4019   --
4020     p_entry_information_category,
4021     p_entry_information1,
4022     p_entry_information2,
4023     p_entry_information3,
4024     p_entry_information4,
4025     p_entry_information5,
4026     p_entry_information6,
4027     p_entry_information7,
4028     p_entry_information8,
4029     p_entry_information9,
4030     p_entry_information10,
4031     p_entry_information11,
4032     p_entry_information12,
4033     p_entry_information13,
4034     p_entry_information14,
4035     p_entry_information15,
4036     p_entry_information16,
4037     p_entry_information17,
4038     p_entry_information18,
4039     p_entry_information19,
4040     p_entry_information20,
4041     p_entry_information21,
4042     p_entry_information22,
4043     p_entry_information23,
4044     p_entry_information24,
4045     p_entry_information25,
4046     p_entry_information26,
4047     p_entry_information27,
4048     p_entry_information28,
4049     p_entry_information29,
4050     p_entry_information30,
4051     l_element_type_id,
4052     l_all_entry_values_null,
4053     l_object_version_number,
4054     p_label_identifier
4055    );
4056    --
4057    -- Create the entry values
4058    --
4059    hr_entry.ins_3p_entry_values
4060      (p_element_link_id,
4061       v_element_entry_id,
4062       p_effective_start_date,
4063       p_num_entry_values,
4064       p_input_value_id_tbl,
4065       p_entry_value_tbl);
4066    --
4067    -- Return the element entry id of the entry being created
4068    --
4069    p_element_entry_id := v_element_entry_id;
4070    --
4071    -- bug 666197, retrieve object version number; call to the user hook procedure
4072    --
4073    -- Bugfix 3110853
4074    -- No longer need to fetch the OVN as it has been derived already
4075    /*
4076    open csr_object_version_number(p_element_entry_id, p_effective_start_date);
4077    fetch csr_object_version_number into l_object_version_number;
4078    close csr_object_version_number;
4079    */
4080    --
4081    begin
4082    --
4083    pay_ele_rki.after_insert
4084    -- p_validation_start/end_date are not supported until the proper API implementation
4085      ( p_effective_date                 => l_effective_date
4086       ,p_validation_start_date          => v_validation_start_date
4087       ,p_validation_end_date            => v_validation_end_date
4088       ,p_effective_start_date           => p_effective_start_date
4089       ,p_effective_end_date             => p_effective_end_date
4090       ,p_element_entry_id               => p_element_entry_id
4091       ,p_original_entry_id              => p_original_entry_id
4092       ,p_assignment_id                  => p_assignment_id
4093       ,p_element_link_id                => p_element_link_id
4094       ,p_creator_type                   => p_creator_type
4095       ,p_entry_type                     => p_entry_type
4096       ,p_cost_allocation_keyflex_id     => p_cost_allocation_keyflex_id
4097       ,p_updating_action_id             => p_updating_action_id
4098       ,p_updating_action_type           => p_updating_action_type
4099       ,p_comment_id                     => p_comment_id
4100       ,p_creator_id                     => p_creator_id
4101       ,p_reason                         => p_reason
4102       ,p_target_entry_id                => p_target_entry_id
4103       ,p_source_id                      => null
4104       ,p_subpriority                    => p_subpriority
4105       ,p_date_earned                    => p_date_earned
4106       ,p_personal_payment_method_id     => p_personal_payment_method_id
4107       ,p_attribute_category             => p_attribute_category
4108       ,p_attribute1                     => p_attribute1
4109       ,p_attribute2                     => p_attribute2
4110       ,p_attribute3                     => p_attribute3
4111       ,p_attribute4                     => p_attribute4
4112       ,p_attribute5                     => p_attribute5
4113       ,p_attribute6                     => p_attribute6
4114       ,p_attribute7                     => p_attribute7
4115       ,p_attribute8                     => p_attribute8
4116       ,p_attribute9                     => p_attribute9
4117       ,p_attribute10                    => p_attribute10
4118       ,p_attribute11                    => p_attribute11
4119       ,p_attribute12                    => p_attribute12
4120       ,p_attribute13                    => p_attribute13
4121       ,p_attribute14                    => p_attribute14
4122       ,p_attribute15                    => p_attribute15
4123       ,p_attribute16                    => p_attribute16
4124       ,p_attribute17                    => p_attribute17
4125       ,p_attribute18                    => p_attribute18
4126       ,p_attribute19                    => p_attribute19
4127       ,p_attribute20                    => p_attribute20
4128       ,p_entry_information_category     => p_entry_information_category
4129       ,p_entry_information1             => p_entry_information1
4130       ,p_entry_information2             => p_entry_information2
4131       ,p_entry_information3             => p_entry_information3
4132       ,p_entry_information4             => p_entry_information4
4133       ,p_entry_information5             => p_entry_information5
4134       ,p_entry_information6             => p_entry_information6
4135       ,p_entry_information7             => p_entry_information7
4136       ,p_entry_information8             => p_entry_information8
4137       ,p_entry_information9             => p_entry_information9
4138       ,p_entry_information10            => p_entry_information10
4139       ,p_entry_information11            => p_entry_information11
4140       ,p_entry_information12            => p_entry_information12
4141       ,p_entry_information13            => p_entry_information13
4142       ,p_entry_information14            => p_entry_information14
4143       ,p_entry_information15            => p_entry_information15
4144       ,p_entry_information16            => p_entry_information16
4145       ,p_entry_information17            => p_entry_information17
4146       ,p_entry_information18            => p_entry_information18
4147       ,p_entry_information19            => p_entry_information19
4148       ,p_entry_information20            => p_entry_information20
4149       ,p_entry_information21            => p_entry_information21
4150       ,p_entry_information22            => p_entry_information22
4151       ,p_entry_information23            => p_entry_information23
4152       ,p_entry_information24            => p_entry_information24
4153       ,p_entry_information25            => p_entry_information25
4154       ,p_entry_information26            => p_entry_information26
4155       ,p_entry_information27            => p_entry_information27
4156       ,p_entry_information28            => p_entry_information28
4157       ,p_entry_information29            => p_entry_information29
4158       ,p_entry_information30            => p_entry_information30
4159       ,p_object_version_number          => l_object_version_number
4160       ,p_balance_adj_cost_flag          => null
4161       ,p_comments                       => null
4162       ,p_element_type_id                => l_element_type_id
4163       ,p_all_entry_values_null          => l_all_entry_values_null
4164      );
4165      exception
4166        when hr_api.cannot_find_prog_unit then
4167          hr_api.cannot_find_prog_unit_error
4168                (p_module_name => 'PAY_ELEMENT_ENTRIES_F'
4169                ,p_hook_type   => 'AI'
4170                );
4171      end;
4172     --
4173   -- jford 20-FEB-03
4174   -- -----------------
4175   -- As entry values has no hook, call the CC DYnamic Trigger PacKaGe directly
4176   -- I.e. instead of   pseudoAPI -> HOOK -> DYT_PKG -> CC_PKG
4177   -- we do             pseudoAPI ---------> DYT_PKG -> CC_PKG
4178   -- -----------------
4179   --loop through all element entry vals for this element entry id
4180   --
4181   for new_vals in pay_ele_shd.csr_get_eevals(p_element_entry_id,l_effective_date)  loop
4182     begin
4183       --
4184     if g_debug then
4185       hr_utility.trace(' Hard call PAY_DYT_ELEMENT_ENTRY_VAL_PKG.after_insert');
4186       hr_utility.trace(' Ele ent Val ID: '||new_vals.element_entry_value_id);
4187       hr_utility.trace(' New Screen Val: '||new_vals.screen_entry_value);
4188     end if;
4189 
4190 -- Reason Insert has seemingly irregular parameters is that as
4191 -- element entry values has no hook packages, the generator util of the called
4192 -- pkg, will use an alternate param gen method and defaults lots eg _o
4193       PAY_DYT_ELEMENT_ENTRY_VAL_PKG.after_insert
4194       (
4195         P_EFFECTIVE_END_DATE          => new_vals.effective_end_date
4196        ,P_EFFECTIVE_START_DATE        => new_vals.effective_start_date
4197        ,P_ELEMENT_ENTRY_ID            => new_vals.element_entry_id
4198        ,P_ELEMENT_ENTRY_VALUE_ID      => new_vals.element_entry_value_id
4199        ,P_INPUT_VALUE_ID              => new_vals.input_value_id
4200        ,P_SCREEN_ENTRY_VALUE          => new_vals.screen_entry_value
4201        ,P_EFFECTIVE_END_DATE_O        => new_vals.effective_end_date
4202        ,P_EFFECTIVE_START_DATE_O      => new_vals.effective_start_date
4203        ,P_ELEMENT_ENTRY_ID_O          => new_vals.element_entry_id
4204        ,P_ELEMENT_ENTRY_VALUE_ID_O    => new_vals.element_entry_value_id
4205        ,P_INPUT_VALUE_ID_O            => new_vals.input_value_id
4206        ,P_SCREEN_ENTRY_VALUE_O        => new_vals.screen_entry_value
4207      );
4208     end;
4209     --
4210   end loop;
4211  end ins_element_entry;
4212 --
4213 
4214 
4215 
4216 
4217 
4218 
4219 
4220 
4221 
4222 
4223 
4224 
4225 
4226 
4227 
4228 
4229 
4230 
4231 
4232 
4233 
4234 
4235 
4236 
4237 --
4238  ------------------------------------------------------------------------------
4239  -- NAME                                                                     --
4240  -- hr_entry_api.insert_element_entry                                        --
4241  --                                                                          --
4242  -- DESCRIPTION                                                              --
4243  -- Cover routine for call to hr_entry_api.ins_element_entry that accepts    --
4244  -- entry values passed as a table. It converts the entry values to DB       --
4245  -- format and also defaults any entry values that were not specified.       --
4246  -- NB. all entry values specified are validated !                           --
4247  ------------------------------------------------------------------------------
4248 --
4249  procedure insert_element_entry
4250  (
4251   --
4252   -- Common Parameters
4253   --
4254   p_effective_start_date       in out nocopy date,
4255   p_effective_end_date         in out nocopy date,
4256   --
4257   -- Element Entry Table
4258   --
4259   p_element_entry_id           in out nocopy number,
4260   p_original_entry_id          number    default null,
4261   p_assignment_id              number,
4262   p_element_link_id            number,
4263   p_creator_type               varchar2,
4264   p_entry_type                 varchar2,
4265   p_cost_allocation_keyflex_id number    default null,
4266   p_updating_action_id         number    default null,
4267   p_updating_action_type       varchar2  default null,
4268   p_comment_id                 number    default null,
4269   p_creator_id                 number    default null,
4270   p_reason                     varchar2  default null,
4271   p_target_entry_id            number    default null,
4272   p_subpriority                number    default null,
4273   p_date_earned                 date    default null,
4274   p_personal_payment_method_id  number  default null,
4275   p_attribute_category         varchar2  default null,
4276   p_attribute1                 varchar2  default null,
4277   p_attribute2                 varchar2  default null,
4278   p_attribute3                 varchar2  default null,
4279   p_attribute4                 varchar2  default null,
4280   p_attribute5                 varchar2  default null,
4281   p_attribute6                 varchar2  default null,
4282   p_attribute7                 varchar2  default null,
4283   p_attribute8                 varchar2  default null,
4284   p_attribute9                 varchar2  default null,
4285   p_attribute10                varchar2  default null,
4286   p_attribute11                varchar2  default null,
4287   p_attribute12                varchar2  default null,
4288   p_attribute13                varchar2  default null,
4289   p_attribute14                varchar2  default null,
4290   p_attribute15                varchar2  default null,
4291   p_attribute16                varchar2  default null,
4292   p_attribute17                varchar2  default null,
4293   p_attribute18                varchar2  default null,
4294   p_attribute19                varchar2  default null,
4295   p_attribute20                varchar2  default null,
4296   p_override_user_ent_chk      varchar2  default 'N',
4297   p_label_identifier           varchar2  default null,
4298   --
4299   -- Element Entry Values Table
4300   --
4301   p_num_entry_values           number,
4302   p_input_value_id_tbl         hr_entry.number_table,
4303   p_entry_value_tbl            hr_entry.varchar2_table
4304   ) is
4305    --
4306    -- Local Variables
4307    --
4308    v_num_entry_values   number;
4309    v_input_value_id_tbl hr_entry.number_table;
4310    v_entry_value_tbl    hr_entry.varchar2_table;
4311    --
4312  begin
4313    g_debug := hr_utility.debug_enabled;
4314 
4315    --
4316    -- Initialise variables
4317    --
4318    g_override_user_ent_chk := p_override_user_ent_chk;
4319    v_num_entry_values   := p_num_entry_values;
4320    v_input_value_id_tbl := p_input_value_id_tbl;
4321    v_entry_value_tbl    := p_entry_value_tbl;
4322    --
4323    -- Call code to set up values that may be used in
4324    -- Formula validation of Input Values.
4325    --
4326    set_formula_contexts (p_assignment_id, p_effective_start_date);
4327    --
4328    -- Make sure PLSQL table contains all the entry values ie. fill in missing
4329    -- entry values not specified by the user.
4330    --
4331    hr_entry_api.conv_table_to_table
4332      ('SCREEN',
4333       p_effective_start_date,
4334       null,
4335       p_element_link_id,
4336       v_num_entry_values,
4337       p_creator_type,
4338       p_entry_type,
4339       v_input_value_id_tbl,
4340       v_entry_value_tbl);
4341    --
4342    -- Do real insertion of element entry.
4343    --
4344    hr_entry_api.ins_element_entry
4345      (p_effective_start_date,
4346       p_effective_end_date,
4347       p_element_entry_id,
4348       p_original_entry_id,
4349       p_assignment_id,
4350       p_element_link_id,
4351       p_creator_type,
4352       p_entry_type,
4353       p_cost_allocation_keyflex_id,
4354       p_updating_action_id,
4355       p_updating_action_type,
4356       p_comment_id,
4357       p_creator_id,
4358       p_reason,
4359       p_target_entry_id,
4360       p_subpriority,
4361       p_date_earned,
4362       p_personal_payment_method_id,
4363       p_attribute_category,
4364       p_attribute1,
4365       p_attribute2,
4366       p_attribute3,
4367       p_attribute4,
4368       p_attribute5,
4369       p_attribute6,
4370       p_attribute7,
4371       p_attribute8,
4372       p_attribute9,
4373       p_attribute10,
4374       p_attribute11,
4375       p_attribute12,
4376       p_attribute13,
4377       p_attribute14,
4378       p_attribute15,
4379       p_attribute16,
4380       p_attribute17,
4381       p_attribute18,
4382       p_attribute19,
4383       p_attribute20,
4384       v_num_entry_values,
4385       v_input_value_id_tbl,
4386       v_entry_value_tbl,
4387 -- --
4388     --
4389     -- J.Bailie 08-NOV-99 31 nulls passed to ins_element_entry
4390     --
4391       null,
4392       null,
4393       null,
4394       null,
4395       null,
4396       null,
4397       null,
4398       null,
4399       null,
4400       null,
4401       null,
4402       null,
4403       null,
4404       null,
4405       null,
4406       null,
4407       null,
4408       null,
4409       null,
4410       null,
4411       null,
4412       null,
4413       null,
4414       null,
4415       null,
4416       null,
4417       null,
4418       null,
4419       null,
4420       null,
4421       null,
4422       p_label_identifier
4423 );
4424    --
4425  end insert_element_entry;
4426 --
4427  ------------------------------------------------------------------------------
4428  -- NAME                                                                     --
4429  -- hr_entry_api.insert_element_entry                                        --
4430  --                                                                          --
4431  -- DESCRIPTION                                                              --
4432  -- Cover routine for call to hr_entry_api.ins_element_entry that accepts    --
4433  -- entry values passed as parameters. It converts the entry values to DB    --
4434  -- format and also defaults any entry values that were not specified.       --
4435  -- NB. all entry values specified are validated !                           --
4436  ------------------------------------------------------------------------------
4437 --
4438  procedure insert_element_entry
4439  (
4440   --
4441   -- Common Parameters
4442   --
4443   p_effective_start_date       in out nocopy date,
4444   p_effective_end_date         in out nocopy date,
4445   --
4446   -- Element Entry Table
4447   --
4448   p_element_entry_id           in out nocopy number,
4449   p_original_entry_id          number    default null,
4450   p_assignment_id              number,
4451   p_element_link_id            number,
4452   p_creator_type               varchar2,
4453   p_entry_type                 varchar2,
4454   p_cost_allocation_keyflex_id number    default null,
4455   p_updating_action_id         number    default null,
4456   p_updating_action_type       varchar2  default null,
4457   p_comment_id                 number    default null,
4458   p_creator_id                 number    default null,
4459   p_reason                     varchar2  default null,
4460   p_target_entry_id            number    default null,
4461   p_subpriority                number    default null,
4462   p_date_earned                 date    default null,
4463   p_personal_payment_method_id  number  default null,
4464   p_attribute_category         varchar2  default null,
4465   p_attribute1                 varchar2  default null,
4466   p_attribute2                 varchar2  default null,
4467   p_attribute3                 varchar2  default null,
4468   p_attribute4                 varchar2  default null,
4469   p_attribute5                 varchar2  default null,
4470   p_attribute6                 varchar2  default null,
4471   p_attribute7                 varchar2  default null,
4472   p_attribute8                 varchar2  default null,
4473   p_attribute9                 varchar2  default null,
4474   p_attribute10                varchar2  default null,
4475   p_attribute11                varchar2  default null,
4476   p_attribute12                varchar2  default null,
4477   p_attribute13                varchar2  default null,
4478   p_attribute14                varchar2  default null,
4479   p_attribute15                varchar2  default null,
4480   p_attribute16                varchar2  default null,
4481   p_attribute17                varchar2  default null,
4482   p_attribute18                varchar2  default null,
4483   p_attribute19                varchar2  default null,
4484   p_attribute20                varchar2  default null,
4485   --
4486   -- Element Entry Values Table
4487   --
4488   p_input_value_id1            number    default null,
4489   p_input_value_id2            number    default null,
4490   p_input_value_id3            number    default null,
4491   p_input_value_id4            number    default null,
4492   p_input_value_id5            number    default null,
4493   p_input_value_id6            number    default null,
4494   p_input_value_id7            number    default null,
4495   p_input_value_id8            number    default null,
4496   p_input_value_id9            number    default null,
4497   p_input_value_id10           number    default null,
4498   p_input_value_id11           number    default null,
4499   p_input_value_id12           number    default null,
4500   p_input_value_id13           number    default null,
4501   p_input_value_id14           number    default null,
4502   p_input_value_id15           number    default null,
4503   p_entry_value1               varchar2  default null,
4504   p_entry_value2               varchar2  default null,
4505   p_entry_value3               varchar2  default null,
4506   p_entry_value4               varchar2  default null,
4507   p_entry_value5               varchar2  default null,
4508   p_entry_value6               varchar2  default null,
4509   p_entry_value7               varchar2  default null,
4510   p_entry_value8               varchar2  default null,
4511   p_entry_value9               varchar2  default null,
4512   p_entry_value10              varchar2  default null,
4513   p_entry_value11              varchar2  default null,
4514   p_entry_value12              varchar2  default null,
4515   p_entry_value13              varchar2  default null,
4516   p_entry_value14              varchar2  default null,
4517   p_entry_value15              varchar2  default null,
4518   p_override_user_ent_chk      varchar2  default 'N',
4519   p_label_identifier           varchar2  default null
4520  ) is
4521    --
4522    -- Local Variables
4523    --
4524    v_num_entry_values   number;
4525    v_input_value_id_tbl hr_entry.number_table;
4526    v_entry_value_tbl    hr_entry.varchar2_table;
4527    --
4528  begin
4529    g_debug := hr_utility.debug_enabled;
4530    --
4531    -- Call code to set up values that may be used in
4532    -- Formula validation of Input Values.
4533    --
4534    set_formula_contexts (p_assignment_id, p_effective_start_date);
4535    g_override_user_ent_chk := p_override_user_ent_chk;
4536    --
4537    -- Copy entry values into PLSQL table and make sure PLSQL table contains
4538    -- all the entry values ie. fill in missing entry values not specified by
4539    -- the user.
4540    --
4541    hr_entry_api.conv_entry_values_to_table
4542      ('SCREEN',
4543       null,
4544       p_element_link_id,
4545       p_effective_start_date,
4546       p_creator_type,
4547       p_entry_type,
4548       p_input_value_id1,
4549       p_input_value_id2,
4550       p_input_value_id3,
4551       p_input_value_id4,
4552       p_input_value_id5,
4553       p_input_value_id6,
4554       p_input_value_id7,
4555       p_input_value_id8,
4556       p_input_value_id9,
4557       p_input_value_id10,
4558       p_input_value_id11,
4559       p_input_value_id12,
4560       p_input_value_id13,
4561       p_input_value_id14,
4562       p_input_value_id15,
4563       p_entry_value1,
4564       p_entry_value2,
4565       p_entry_value3,
4566       p_entry_value4,
4567       p_entry_value5,
4568       p_entry_value6,
4569       p_entry_value7,
4570       p_entry_value8,
4571       p_entry_value9,
4572       p_entry_value10,
4573       p_entry_value11,
4574       p_entry_value12,
4575       p_entry_value13,
4576       p_entry_value14,
4577       p_entry_value15,
4578       v_num_entry_values,
4579       v_input_value_id_tbl,
4580       v_entry_value_tbl);
4581    --
4582    -- Do real insertion of element entry.
4583    --
4584    hr_entry_api.ins_element_entry
4585      (p_effective_start_date,
4586       p_effective_end_date,
4587       p_element_entry_id,
4588       p_original_entry_id,
4589       p_assignment_id,
4590       p_element_link_id,
4591       p_creator_type,
4592       p_entry_type,
4593       p_cost_allocation_keyflex_id,
4594       p_updating_action_id,
4595       p_updating_action_type,
4596       p_comment_id,
4597       p_creator_id,
4598       p_reason,
4599       p_target_entry_id,
4600       p_subpriority,
4601       p_date_earned,
4602       p_personal_payment_method_id,
4603       p_attribute_category,
4604       p_attribute1,
4605       p_attribute2,
4606       p_attribute3,
4607       p_attribute4,
4608       p_attribute5,
4609       p_attribute6,
4610       p_attribute7,
4611       p_attribute8,
4612       p_attribute9,
4613       p_attribute10,
4614       p_attribute11,
4615       p_attribute12,
4616       p_attribute13,
4617       p_attribute14,
4618       p_attribute15,
4619       p_attribute16,
4620       p_attribute17,
4621       p_attribute18,
4622       p_attribute19,
4623       p_attribute20,
4624       v_num_entry_values,
4625       v_input_value_id_tbl,
4626       v_entry_value_tbl,
4627 -- --
4628     --
4629     -- J.Bailie 08-NOV-99 31 nulls passed to ins_element_entry
4630     --
4631       null,
4632       null,
4633       null,
4634       null,
4635       null,
4636       null,
4637       null,
4638       null,
4639       null,
4640       null,
4641       null,
4642       null,
4643       null,
4644       null,
4645       null,
4646       null,
4647       null,
4648       null,
4649       null,
4650       null,
4651       null,
4652       null,
4653       null,
4654       null,
4655       null,
4656       null,
4657       null,
4658       null,
4659       null,
4660       null,
4661       null,
4662       p_label_identifier
4663 );
4664    --
4665  end insert_element_entry;
4666 --
4667 -- --
4668 --
4669  ------------------------------------------------------------------------------
4670  -- NAME                                                                     --
4671  -- hr_entry_api.insert_element_entry                                        --
4672  --                                                                          --
4673  -- DESCRIPTION                                                              --
4674  -- Cover routine for call to hr_entry_api.ins_element_entry that accepts    --
4675  -- entry values passed as a table. It converts the entry values to DB       --
4676  -- format and also defaults any entry values that were not specified.       --
4677  -- NB. all entry values specified are validated !                           --
4678  ------------------------------------------------------------------------------
4679 --
4680  procedure insert_element_entry
4681  (
4682   --
4683   -- Common Parameters
4684   --
4685   p_effective_start_date       in out nocopy date,
4686   p_effective_end_date         in out nocopy date,
4687   --
4688   -- Element Entry Table
4689   --
4690   p_element_entry_id           in out nocopy number,
4691   p_original_entry_id          number    default null,
4692   p_assignment_id              number,
4693   p_element_link_id            number,
4694   p_creator_type               varchar2,
4695   p_entry_type                 varchar2,
4696   p_cost_allocation_keyflex_id number    default null,
4697   p_updating_action_id         number    default null,
4698   p_updating_action_type       varchar2  default null,
4699   p_comment_id                 number    default null,
4700   p_creator_id                 number    default null,
4701   p_reason                     varchar2  default null,
4702   p_target_entry_id            number    default null,
4703   p_subpriority                number    default null,
4704   p_date_earned                 date    default null,
4705   p_personal_payment_method_id  number  default null,
4706   p_attribute_category         varchar2  default null,
4707   p_attribute1                 varchar2  default null,
4708   p_attribute2                 varchar2  default null,
4709   p_attribute3                 varchar2  default null,
4710   p_attribute4                 varchar2  default null,
4711   p_attribute5                 varchar2  default null,
4712   p_attribute6                 varchar2  default null,
4713   p_attribute7                 varchar2  default null,
4714   p_attribute8                 varchar2  default null,
4715   p_attribute9                 varchar2  default null,
4716   p_attribute10                varchar2  default null,
4717   p_attribute11                varchar2  default null,
4718   p_attribute12                varchar2  default null,
4719   p_attribute13                varchar2  default null,
4720   p_attribute14                varchar2  default null,
4721   p_attribute15                varchar2  default null,
4722   p_attribute16                varchar2  default null,
4723   p_attribute17                varchar2  default null,
4724   p_attribute18                varchar2  default null,
4725   p_attribute19                varchar2  default null,
4726   p_attribute20                varchar2  default null,
4727   --
4728   -- Element Entry Values Table
4729   --
4730   p_num_entry_values           number,
4731   p_input_value_id_tbl         hr_entry.number_table,
4732   p_entry_value_tbl            hr_entry.varchar2_table,
4733   --
4734   -- J.Bailie Element Entries DDF
4735   --
4736   p_entry_information_category varchar2  ,
4737   p_entry_information1         varchar2  default null,
4738   p_entry_information2         varchar2  default null,
4739   p_entry_information3         varchar2  default null,
4740   p_entry_information4         varchar2  default null,
4741   p_entry_information5         varchar2  default null,
4742   p_entry_information6         varchar2  default null,
4743   p_entry_information7         varchar2  default null,
4744   p_entry_information8         varchar2  default null,
4745   p_entry_information9         varchar2  default null,
4746   p_entry_information10        varchar2  default null,
4747   p_entry_information11        varchar2  default null,
4748   p_entry_information12        varchar2  default null,
4749   p_entry_information13        varchar2  default null,
4750   p_entry_information14        varchar2  default null,
4751   p_entry_information15        varchar2  default null,
4752   p_entry_information16        varchar2  default null,
4753   p_entry_information17        varchar2  default null,
4754   p_entry_information18        varchar2  default null,
4755   p_entry_information19        varchar2  default null,
4756   p_entry_information20        varchar2  default null,
4757   p_entry_information21        varchar2  default null,
4758   p_entry_information22        varchar2  default null,
4759   p_entry_information23        varchar2  default null,
4760   p_entry_information24        varchar2  default null,
4761   p_entry_information25        varchar2  default null,
4762   p_entry_information26        varchar2  default null,
4763   p_entry_information27        varchar2  default null,
4764   p_entry_information28        varchar2  default null,
4765   p_entry_information29        varchar2  default null,
4766   p_entry_information30        varchar2  default null,
4767   p_override_user_ent_chk      varchar2  default 'N',
4768   p_label_identifier           varchar2  default null
4769   ) is
4770    --
4771    -- Local Variables
4772    --
4773    v_num_entry_values   number;
4774    v_input_value_id_tbl hr_entry.number_table;
4775    v_entry_value_tbl    hr_entry.varchar2_table;
4776    --
4777  begin
4778    g_debug := hr_utility.debug_enabled;
4779    --
4780    -- Initialise variables
4781    --
4782    g_override_user_ent_chk := p_override_user_ent_chk;
4783    v_num_entry_values   := p_num_entry_values;
4784    v_input_value_id_tbl := p_input_value_id_tbl;
4785    v_entry_value_tbl    := p_entry_value_tbl;
4786    --
4787    -- Call code to set up values that may be used in
4788    -- Formula validation of Input Values.
4789    --
4790    set_formula_contexts (p_assignment_id, p_effective_start_date);
4791    --
4792    -- Make sure PLSQL table contains all the entry values ie. fill in missing
4793    -- entry values not specified by the user.
4794    --
4795    hr_entry_api.conv_table_to_table
4796      ('SCREEN',
4797       p_effective_start_date,
4798       null,
4799       p_element_link_id,
4800       v_num_entry_values,
4801       p_creator_type,
4802       p_entry_type,
4803       v_input_value_id_tbl,
4804       v_entry_value_tbl);
4805    --
4806    -- Do real insertion of element entry.
4807    --
4808    hr_entry_api.ins_element_entry
4809      (p_effective_start_date,
4810       p_effective_end_date,
4811       p_element_entry_id,
4812       p_original_entry_id,
4813       p_assignment_id,
4814       p_element_link_id,
4815       p_creator_type,
4816       p_entry_type,
4817       p_cost_allocation_keyflex_id,
4818       p_updating_action_id,
4819       p_updating_action_type,
4820       p_comment_id,
4821       p_creator_id,
4822       p_reason,
4823       p_target_entry_id,
4824       p_subpriority,
4825       p_date_earned,
4826       p_personal_payment_method_id,
4827       p_attribute_category,
4828       p_attribute1,
4829       p_attribute2,
4830       p_attribute3,
4831       p_attribute4,
4832       p_attribute5,
4833       p_attribute6,
4834       p_attribute7,
4835       p_attribute8,
4836       p_attribute9,
4837       p_attribute10,
4838       p_attribute11,
4839       p_attribute12,
4840       p_attribute13,
4841       p_attribute14,
4842       p_attribute15,
4843       p_attribute16,
4844       p_attribute17,
4845       p_attribute18,
4846       p_attribute19,
4847       p_attribute20,
4848       v_num_entry_values,
4849       v_input_value_id_tbl,
4850       v_entry_value_tbl,
4851   --
4852   -- J.Bailie 08-NOV-99 Element Entries DDF
4853   --
4854     p_entry_information_category,
4855     p_entry_information1,
4856     p_entry_information2,
4857     p_entry_information3,
4858     p_entry_information4,
4859     p_entry_information5,
4860     p_entry_information6,
4861     p_entry_information7,
4862     p_entry_information8,
4863     p_entry_information9,
4864     p_entry_information10,
4865     p_entry_information11,
4866     p_entry_information12,
4867     p_entry_information13,
4868     p_entry_information14,
4869     p_entry_information15,
4870     p_entry_information16,
4871     p_entry_information17,
4872     p_entry_information18,
4873     p_entry_information19,
4874     p_entry_information20,
4875     p_entry_information21,
4876     p_entry_information22,
4877     p_entry_information23,
4878     p_entry_information24,
4879     p_entry_information25,
4880     p_entry_information26,
4881     p_entry_information27,
4882     p_entry_information28,
4883     p_entry_information29,
4884     p_entry_information30,
4885     p_label_identifier
4886    );
4887    --
4888  end insert_element_entry;
4889 --
4890 -- --
4891 --
4892  ------------------------------------------------------------------------------
4893  -- NAME                                                                     --
4894  -- hr_entry_api.insert_element_entry                                        --
4895  --                                                                          --
4896  -- DESCRIPTION                                                              --
4897  -- Cover routine for call to hr_entry_api.ins_element_entry that accepts    --
4898  -- entry values passed as parameters. It converts the entry values to DB    --
4899  -- format and also defaults any entry values that were not specified.       --
4900  -- NB. all entry values specified are validated !                           --
4901  ------------------------------------------------------------------------------
4902 --
4903  procedure insert_element_entry
4904  (
4905   --
4906   -- Common Parameters
4907   --
4908   p_effective_start_date       in out nocopy date,
4909   p_effective_end_date         in out nocopy date,
4910   --
4911   -- Element Entry Table
4912   --
4913   p_element_entry_id           in out nocopy number,
4914   p_original_entry_id          number    default null,
4915   p_assignment_id              number,
4916   p_element_link_id            number,
4917   p_creator_type               varchar2,
4918   p_entry_type                 varchar2,
4919   p_cost_allocation_keyflex_id number    default null,
4920   p_updating_action_id         number    default null,
4921   p_updating_action_type       varchar2  default null,
4922   p_comment_id                 number    default null,
4923   p_creator_id                 number    default null,
4924   p_reason                     varchar2  default null,
4925   p_target_entry_id            number    default null,
4926   p_subpriority                number    default null,
4927   p_date_earned                 date    default null,
4928   p_personal_payment_method_id  number  default null,
4929   p_attribute_category         varchar2  default null,
4930   p_attribute1                 varchar2  default null,
4931   p_attribute2                 varchar2  default null,
4932   p_attribute3                 varchar2  default null,
4933   p_attribute4                 varchar2  default null,
4934   p_attribute5                 varchar2  default null,
4935   p_attribute6                 varchar2  default null,
4936   p_attribute7                 varchar2  default null,
4937   p_attribute8                 varchar2  default null,
4938   p_attribute9                 varchar2  default null,
4939   p_attribute10                varchar2  default null,
4940   p_attribute11                varchar2  default null,
4941   p_attribute12                varchar2  default null,
4942   p_attribute13                varchar2  default null,
4943   p_attribute14                varchar2  default null,
4944   p_attribute15                varchar2  default null,
4945   p_attribute16                varchar2  default null,
4946   p_attribute17                varchar2  default null,
4947   p_attribute18                varchar2  default null,
4948   p_attribute19                varchar2  default null,
4949   p_attribute20                varchar2  default null,
4950   --
4951   -- Element Entry Values Table
4952   --
4953   p_input_value_id1            number    default null,
4954   p_input_value_id2            number    default null,
4955   p_input_value_id3            number    default null,
4956   p_input_value_id4            number    default null,
4957   p_input_value_id5            number    default null,
4958   p_input_value_id6            number    default null,
4959   p_input_value_id7            number    default null,
4960   p_input_value_id8            number    default null,
4961   p_input_value_id9            number    default null,
4962   p_input_value_id10           number    default null,
4963   p_input_value_id11           number    default null,
4964   p_input_value_id12           number    default null,
4965   p_input_value_id13           number    default null,
4966   p_input_value_id14           number    default null,
4967   p_input_value_id15           number    default null,
4968   p_entry_value1               varchar2  default null,
4969   p_entry_value2               varchar2  default null,
4970   p_entry_value3               varchar2  default null,
4971   p_entry_value4               varchar2  default null,
4972   p_entry_value5               varchar2  default null,
4973   p_entry_value6               varchar2  default null,
4974   p_entry_value7               varchar2  default null,
4975   p_entry_value8               varchar2  default null,
4976   p_entry_value9               varchar2  default null,
4977   p_entry_value10              varchar2  default null,
4978   p_entry_value11              varchar2  default null,
4979   p_entry_value12              varchar2  default null,
4980   p_entry_value13              varchar2  default null,
4981   p_entry_value14              varchar2  default null,
4982   p_entry_value15              varchar2  default null,
4983   --
4984   -- J.Bailie Element Entries DDF
4985   --
4986   p_entry_information_category varchar2  ,
4987   p_entry_information1         varchar2  default null,
4988   p_entry_information2         varchar2  default null,
4989   p_entry_information3         varchar2  default null,
4990   p_entry_information4         varchar2  default null,
4991   p_entry_information5         varchar2  default null,
4992   p_entry_information6         varchar2  default null,
4993   p_entry_information7         varchar2  default null,
4994   p_entry_information8         varchar2  default null,
4995   p_entry_information9         varchar2  default null,
4996   p_entry_information10        varchar2  default null,
4997   p_entry_information11        varchar2  default null,
4998   p_entry_information12        varchar2  default null,
4999   p_entry_information13        varchar2  default null,
5000   p_entry_information14        varchar2  default null,
5001   p_entry_information15        varchar2  default null,
5002   p_entry_information16        varchar2  default null,
5003   p_entry_information17        varchar2  default null,
5004   p_entry_information18        varchar2  default null,
5005   p_entry_information19        varchar2  default null,
5006   p_entry_information20        varchar2  default null,
5007   p_entry_information21        varchar2  default null,
5008   p_entry_information22        varchar2  default null,
5009   p_entry_information23        varchar2  default null,
5010   p_entry_information24        varchar2  default null,
5011   p_entry_information25        varchar2  default null,
5012   p_entry_information26        varchar2  default null,
5013   p_entry_information27        varchar2  default null,
5014   p_entry_information28        varchar2  default null,
5015   p_entry_information29        varchar2  default null,
5016   p_entry_information30        varchar2  default null,
5017   p_override_user_ent_chk      varchar2  default 'N',
5018   p_label_identifier           varchar2  default null
5019  ) is
5020    --
5021    -- Local Variables
5022    --
5023    v_num_entry_values   number;
5024    v_input_value_id_tbl hr_entry.number_table;
5025    v_entry_value_tbl    hr_entry.varchar2_table;
5026    --
5027  begin
5028    g_debug := hr_utility.debug_enabled;
5029    --
5030    -- Call code to set up values that may be used in
5031    -- Formula validation of Input Values.
5032    --
5033    set_formula_contexts (p_assignment_id, p_effective_start_date);
5034    g_override_user_ent_chk := p_override_user_ent_chk;
5035    --
5036    -- Copy entry values into PLSQL table and make sure PLSQL table contains
5037    -- all the entry values ie. fill in missing entry values not specified by
5038    -- the user.
5039    --
5040    hr_entry_api.conv_entry_values_to_table
5041      ('SCREEN',
5042       null,
5043       p_element_link_id,
5044       p_effective_start_date,
5045       p_creator_type,
5046       p_entry_type,
5047       p_input_value_id1,
5048       p_input_value_id2,
5049       p_input_value_id3,
5050       p_input_value_id4,
5051       p_input_value_id5,
5052       p_input_value_id6,
5053       p_input_value_id7,
5054       p_input_value_id8,
5055       p_input_value_id9,
5056       p_input_value_id10,
5057       p_input_value_id11,
5058       p_input_value_id12,
5059       p_input_value_id13,
5060       p_input_value_id14,
5061       p_input_value_id15,
5062       p_entry_value1,
5063       p_entry_value2,
5064       p_entry_value3,
5065       p_entry_value4,
5066       p_entry_value5,
5067       p_entry_value6,
5068       p_entry_value7,
5069       p_entry_value8,
5070       p_entry_value9,
5071       p_entry_value10,
5072       p_entry_value11,
5073       p_entry_value12,
5074       p_entry_value13,
5075       p_entry_value14,
5076       p_entry_value15,
5077       v_num_entry_values,
5078       v_input_value_id_tbl,
5079       v_entry_value_tbl);
5080    --
5081    -- Do real insertion of element entry.
5082    --
5083    hr_entry_api.ins_element_entry
5084      (p_effective_start_date,
5085       p_effective_end_date,
5086       p_element_entry_id,
5087       p_original_entry_id,
5088       p_assignment_id,
5089       p_element_link_id,
5090       p_creator_type,
5091       p_entry_type,
5092       p_cost_allocation_keyflex_id,
5093       p_updating_action_id,
5094       p_updating_action_type,
5095       p_comment_id,
5096       p_creator_id,
5097       p_reason,
5098       p_target_entry_id,
5099       p_subpriority,
5100       p_date_earned,
5101       p_personal_payment_method_id,
5102       p_attribute_category,
5103       p_attribute1,
5104       p_attribute2,
5105       p_attribute3,
5106       p_attribute4,
5107       p_attribute5,
5108       p_attribute6,
5109       p_attribute7,
5110       p_attribute8,
5111       p_attribute9,
5112       p_attribute10,
5113       p_attribute11,
5114       p_attribute12,
5115       p_attribute13,
5116       p_attribute14,
5117       p_attribute15,
5118       p_attribute16,
5119       p_attribute17,
5120       p_attribute18,
5121       p_attribute19,
5122       p_attribute20,
5123       v_num_entry_values,
5124       v_input_value_id_tbl,
5125       v_entry_value_tbl,
5126   --
5127   -- J.Bailie 08-NOV-99 Element Entries DDF
5128   --
5129     p_entry_information_category,
5130     p_entry_information1,
5131     p_entry_information2,
5132     p_entry_information3,
5133     p_entry_information4,
5134     p_entry_information5,
5135     p_entry_information6,
5136     p_entry_information7,
5137     p_entry_information8,
5138     p_entry_information9,
5139     p_entry_information10,
5140     p_entry_information11,
5141     p_entry_information12,
5142     p_entry_information13,
5143     p_entry_information14,
5144     p_entry_information15,
5145     p_entry_information16,
5146     p_entry_information17,
5147     p_entry_information18,
5148     p_entry_information19,
5149     p_entry_information20,
5150     p_entry_information21,
5151     p_entry_information22,
5152     p_entry_information23,
5153     p_entry_information24,
5154     p_entry_information25,
5155     p_entry_information26,
5156     p_entry_information27,
5157     p_entry_information28,
5158     p_entry_information29,
5159     p_entry_information30,
5160     p_label_identifier
5161     );
5162    --
5163  end insert_element_entry;
5164 --
5165  ------------------------------------------------------------------------------
5166  -- NAME
5167  -- hr_entry_api.check_salary_admin_updates
5168  --
5169  -- DESCRIPTION
5170  -- Validates the rules for updating Salary Admin entries
5171  ------------------------------------------------------------------------------
5172  procedure check_salary_admin_updates
5173  (
5174  p_element_entry_id     number,
5175  p_new_entry            hr_entry_api.t_update_entry_rec,
5176  p_effective_date       date,
5177  p_dt_update_mode       varchar2
5178  ) is
5179  --
5180  cursor csr_old_entry_details is
5181         --
5182         -- Get the old values of the entry for comparison with the updated
5183         -- values
5184         --
5185         select  *
5186         from    pay_element_entries_f
5187         where   element_entry_id = p_element_entry_id
5188         and     p_effective_date between effective_start_date
5189                                 and effective_end_date;
5190         --
5191  l_proc varchar2 (72);
5192  old_entry      pay_element_entries_f%rowtype;
5193  invalid_element_entry_id               exception;
5194  invalid_dt_update_mode exception;
5195  --
5196         procedure check_parameters is
5197                 --
5198                 begin
5199                 --
5200                 hr_utility.trace('check_salary_admin_updates');
5201                 hr_api.mandatory_arg_error (
5202                         p_api_name      => l_proc,
5203                         p_argument      => 'p_dt_update_mode',
5204                         p_argument_value=> p_dt_update_mode);
5205                         --
5206                 hr_api.mandatory_arg_error (
5207                         p_api_name      => l_proc,
5208                         p_argument      => 'p_effective_date',
5209                         p_argument_value=> p_effective_date);
5210                         --
5211                 hr_api.mandatory_arg_error (
5212                         p_api_name      => l_proc,
5213                         p_argument      => 'p_element_entry_id',
5214                         p_argument_value=> p_element_entry_id);
5215                         --
5216                 hr_api.mandatory_arg_error (
5217                         p_api_name      => l_proc,
5218                         p_argument      => 'p_new_entry.creator_type',
5219                         p_argument_value=> p_new_entry.creator_type);
5220                         --
5221                 end check_parameters;
5222                 --
5223  begin
5224  --
5225  if g_debug then
5226     l_proc := 'hr_entry_api.check_salary_admin_updates';
5227     check_parameters;
5228  end if;
5229  --
5230  if
5231     -- a salary admin entry
5232     p_new_entry.creator_type = 'SP'
5233  then
5234    --
5235    -- Get the old entry row
5236    --
5237    open csr_old_entry_details;
5238    fetch csr_old_entry_details into old_entry;
5239    if csr_old_entry_details%notfound then
5240      close csr_old_entry_details;
5241      raise invalid_element_entry_id;
5242    else
5243      close csr_old_entry_details;
5244    end if;
5245    --
5246    if
5247        -- if in a datetrack mode which could affect other rows
5248        p_dt_update_mode not in (        'CORRECTION',
5249                                         'UPDATE_CHANGE_INSERT'  )
5250       and
5251       (
5252       -- and costing keyflex was updated
5253       nvl (old_entry.cost_allocation_keyflex_id, 0)
5254                 <> nvl (p_new_entry.cost_allocation_keyflex_id, 0)
5255       --
5256       -- or reason was updated
5257       or nvl (old_entry.reason,'x') <> nvl (p_new_entry.reason,'x')
5258       --
5259       -- or date_earned was updated
5260       or nvl (old_entry.date_earned, hr_general.end_of_time)
5261         <> nvl (p_new_entry.date_earned, hr_general.end_of_time)
5262       --
5263       -- or third party payee details were updated
5264       or nvl (old_entry.personal_payment_method_id, 0)
5265         <> nvl (p_new_entry.personal_payment_method_id, 0)
5266       --
5267       -- or subpriority was updated
5268       or nvl (old_entry.subpriority, 0) <> nvl (p_new_entry.subpriority, 0)
5269       --
5270       -- or descriptive flex was updated
5271       or (nvl (old_entry.attribute_category,'x')
5272                                 <> nvl (p_new_entry.attribute_category,'x')
5273          or nvl (old_entry.attribute1,'x') <> nvl (p_new_entry.attribute1, 'x')
5274          or nvl (old_entry.attribute2,'x') <> nvl (p_new_entry.attribute2, 'x')
5275          or nvl (old_entry.attribute3,'x') <> nvl (p_new_entry.attribute3, 'x')
5276          or nvl (old_entry.attribute4,'x') <> nvl (p_new_entry.attribute4, 'x')
5277          or nvl (old_entry.attribute5,'x') <> nvl (p_new_entry.attribute5, 'x')
5278          or nvl (old_entry.attribute6,'x') <> nvl (p_new_entry.attribute6, 'x')
5279          or nvl (old_entry.attribute7,'x') <> nvl (p_new_entry.attribute7, 'x')
5280          or nvl (old_entry.attribute8,'x') <> nvl (p_new_entry.attribute8, 'x')
5281          or nvl (old_entry.attribute9,'x') <> nvl (p_new_entry.attribute9, 'x')
5282          or nvl(old_entry.attribute10,'x') <> nvl(p_new_entry.attribute10, 'x')
5283          or nvl(old_entry.attribute11,'x') <> nvl(p_new_entry.attribute11, 'x')
5284          or nvl(old_entry.attribute12,'x') <> nvl(p_new_entry.attribute12, 'x')
5285          or nvl(old_entry.attribute13,'x') <> nvl(p_new_entry.attribute13, 'x')
5286          or nvl(old_entry.attribute14,'x') <> nvl(p_new_entry.attribute14, 'x')
5287          or nvl(old_entry.attribute15,'x') <> nvl(p_new_entry.attribute15, 'x')
5288          or nvl(old_entry.attribute16,'x') <> nvl(p_new_entry.attribute16, 'x')
5289          or nvl(old_entry.attribute17,'x') <> nvl(p_new_entry.attribute17, 'x')
5290          or nvl(old_entry.attribute18,'x') <> nvl(p_new_entry.attribute18, 'x')
5291          or nvl(old_entry.attribute19,'x') <> nvl(p_new_entry.attribute19, 'x')
5292          or nvl(old_entry.attribute20,'x') <> nvl(p_new_entry.attribute20, 'x'))
5293       )
5294    then
5295      --
5296      raise invalid_dt_update_mode;
5297      --
5298    end if;
5299    --
5300  end if;
5301  --
5302  exception
5303  --
5304  when invalid_dt_update_mode then
5305    --
5306    -- The entry attributes for salary admin entries may be updated only
5307    -- in UPDATE_CHANGE_INSERT and CORRECTION datetrack modes.
5308    --
5309    hr_utility.set_message (801,'HR_51182_SAL_DT_MODE');
5310    hr_utility.raise_error;
5311    --
5312  when invalid_element_entry_id then
5313    --
5314    -- The update is for a non-existent element entry
5315    --
5316    hr_utility.set_message (801,'HR_6153_ALL_PROCEDURE_FAIL');
5317    hr_utility.set_message_token ('PROCEDURE', l_proc);
5318    hr_utility.set_message_token ('STEP','1');
5319    hr_utility.raise_error;
5320    --
5321  end check_salary_admin_updates;
5322  ------------------------------------------------------------------------------
5323  -- NAME                                                                     --
5324  -- hr_entry_api.upd_ele_entry_param_val                                     --
5325  --                                                                          --
5326  -- DESCRIPTION                                                              --
5327  -- Validates the parameters passed to hr_entry_api.update_element_entry.    --
5328  ------------------------------------------------------------------------------
5329  procedure upd_ele_entry_param_val
5330  (
5331   --
5332   -- Update Mode
5333   --
5334   p_dt_update_mode             in out nocopy varchar2,
5335   --
5336   -- Date on which change is taking place
5337   --
5338   p_session_date               date,
5339   --
5340   -- Element Entry Table
5341   --
5342   p_element_entry_id           number,
5343   p_cost_allocation_keyflex_id number,
5344   p_updating_action_id         number,
5345   p_updating_action_type       varchar2,
5346   p_original_entry_id          number,
5347   p_creator_type               varchar2,
5348   p_comment_id                 number,
5349   p_creator_id                 number,
5350   p_reason                     varchar2,
5351   p_subpriority                number,
5352   p_date_earned                 date,
5353   p_personal_payment_method_id  number,
5354   p_attribute_category         varchar2,
5355   p_attribute1                 varchar2,
5356   p_attribute2                 varchar2,
5357   p_attribute3                 varchar2,
5358   p_attribute4                 varchar2,
5359   p_attribute5                 varchar2,
5360   p_attribute6                 varchar2,
5361   p_attribute7                 varchar2,
5362   p_attribute8                 varchar2,
5363   p_attribute9                 varchar2,
5364   p_attribute10                varchar2,
5365   p_attribute11                varchar2,
5366   p_attribute12                varchar2,
5367   p_attribute13                varchar2,
5368   p_attribute14                varchar2,
5369   p_attribute15                varchar2,
5370   p_attribute16                varchar2,
5371   p_attribute17                varchar2,
5372   p_attribute18                varchar2,
5373   p_attribute19                varchar2,
5374   p_attribute20                varchar2,
5375 -- --
5376   --
5377   -- J.Bailie Element Entries DDF
5378   --
5379   p_entry_information_category varchar2,
5380   p_entry_information1         varchar2,
5381   p_entry_information2         varchar2,
5382   p_entry_information3         varchar2,
5383   p_entry_information4         varchar2,
5384   p_entry_information5         varchar2,
5385   p_entry_information6         varchar2,
5386   p_entry_information7         varchar2,
5387   p_entry_information8         varchar2,
5388   p_entry_information9         varchar2,
5389   p_entry_information10        varchar2,
5390   p_entry_information11        varchar2,
5391   p_entry_information12        varchar2,
5392   p_entry_information13        varchar2,
5393   p_entry_information14        varchar2,
5394   p_entry_information15        varchar2,
5395   p_entry_information16        varchar2,
5396   p_entry_information17        varchar2,
5397   p_entry_information18        varchar2,
5398   p_entry_information19        varchar2,
5399   p_entry_information20        varchar2,
5400   p_entry_information21        varchar2,
5401   p_entry_information22        varchar2,
5402   p_entry_information23        varchar2,
5403   p_entry_information24        varchar2,
5404   p_entry_information25        varchar2,
5405   p_entry_information26        varchar2,
5406   p_entry_information27        varchar2,
5407   p_entry_information28        varchar2,
5408   p_entry_information29        varchar2,
5409   p_entry_information30        varchar2,
5410   p_entry_rec                  out nocopy hr_entry_api.t_update_entry_rec
5411  ) is
5412    --
5413    -- Local Variables
5414    --
5415    v_entry_rec hr_entry_api.t_update_entry_rec;
5416    --
5417  begin
5418    --
5419    -- Cache entry details taking into account if the user has specifed a
5420    -- change. If no change has been supplied then the old value is used when
5421    -- updating.
5422    --
5423    begin
5424      select decode(p_cost_allocation_keyflex_id,hr_api.g_number,
5425                    ee.cost_allocation_keyflex_id,p_cost_allocation_keyflex_id),
5426             decode(p_updating_action_id,hr_api.g_number,
5427                    ee.updating_action_id,p_updating_action_id),
5428             decode(p_updating_action_type,hr_api.g_varchar2,
5429                    ee.updating_action_type,p_updating_action_type),
5430             decode(p_original_entry_id,hr_api.g_number,
5431                    ee.original_entry_id,p_original_entry_id),
5432             decode(p_creator_type,hr_api.g_varchar2,ee.creator_type,p_creator_type),
5433             decode(p_comment_id,hr_api.g_number,ee.comment_id,p_comment_id),
5434             decode(p_creator_id,hr_api.g_number,ee.creator_id,p_creator_id),
5435             decode(p_reason,hr_api.g_varchar2,ee.reason,p_reason),
5436             decode(p_subpriority,hr_api.g_number,ee.subpriority,p_subpriority),
5437             decode(p_date_earned ,hr_api.g_date,ee.date_earned ,p_date_earned),
5438             decode(p_personal_payment_method_id,hr_api.g_number,ee.personal_payment_method_id ,p_personal_payment_method_id),
5439             decode(p_attribute_category,hr_api.g_varchar2,
5440                    ee.attribute_category,p_attribute_category),
5441             decode(p_attribute1,hr_api.g_varchar2,ee.attribute1,p_attribute1),
5442             decode(p_attribute2,hr_api.g_varchar2,ee.attribute2,p_attribute2),
5443             decode(p_attribute3,hr_api.g_varchar2,ee.attribute3,p_attribute3),
5444             decode(p_attribute4,hr_api.g_varchar2,ee.attribute4,p_attribute4),
5445             decode(p_attribute5,hr_api.g_varchar2,ee.attribute5,p_attribute5),
5446             decode(p_attribute6,hr_api.g_varchar2,ee.attribute6,p_attribute6),
5447             decode(p_attribute7,hr_api.g_varchar2,ee.attribute7,p_attribute7),
5448             decode(p_attribute8,hr_api.g_varchar2,ee.attribute8,p_attribute8),
5449             decode(p_attribute9,hr_api.g_varchar2,ee.attribute9,p_attribute9),
5450             decode(p_attribute10,hr_api.g_varchar2,ee.attribute10,p_attribute10),
5451             decode(p_attribute11,hr_api.g_varchar2,ee.attribute11,p_attribute11),
5452             decode(p_attribute12,hr_api.g_varchar2,ee.attribute12,p_attribute12),
5453             decode(p_attribute13,hr_api.g_varchar2,ee.attribute13,p_attribute13),
5454             decode(p_attribute14,hr_api.g_varchar2,ee.attribute14,p_attribute14),
5455             decode(p_attribute15,hr_api.g_varchar2,ee.attribute15,p_attribute15),
5456             decode(p_attribute16,hr_api.g_varchar2,ee.attribute16,p_attribute16),
5457             decode(p_attribute17,hr_api.g_varchar2,ee.attribute17,p_attribute17),
5458             decode(p_attribute18,hr_api.g_varchar2,ee.attribute18,p_attribute18),
5459             decode(p_attribute19,hr_api.g_varchar2,ee.attribute19,p_attribute19),
5460             decode(p_attribute20,hr_api.g_varchar2,ee.attribute20,p_attribute20),
5461             ee.effective_start_date,
5462             ee.effective_end_date,
5463             ee.target_entry_id,
5464             ee.entry_type,
5465             ee.element_link_id,
5466             ee.assignment_id,
5467             et.element_type_id,
5468             et.processing_type,
5469             et.input_currency_code,
5470             et.output_currency_code,
5471 -- --
5472             decode(p_entry_information_category,hr_api.g_varchar2,
5473                    ee.entry_information_category,p_entry_information_category),
5474             decode(p_entry_information1,hr_api.g_varchar2,ee.entry_information1,p_entry_information1),
5475             decode(p_entry_information2,hr_api.g_varchar2,ee.entry_information2,p_entry_information2),
5476             decode(p_entry_information3,hr_api.g_varchar2,ee.entry_information3,p_entry_information3),
5477             decode(p_entry_information4,hr_api.g_varchar2,ee.entry_information4,p_entry_information4),
5478             decode(p_entry_information5,hr_api.g_varchar2,ee.entry_information5,p_entry_information5),
5479             decode(p_entry_information6,hr_api.g_varchar2,ee.entry_information6,p_entry_information6),
5480             decode(p_entry_information7,hr_api.g_varchar2,ee.entry_information7,p_entry_information7),
5481             decode(p_entry_information8,hr_api.g_varchar2,ee.entry_information8,p_entry_information8),
5482             decode(p_entry_information9,hr_api.g_varchar2,ee.entry_information9,p_entry_information9),
5483             decode(p_entry_information10,hr_api.g_varchar2,ee.entry_information10,p_entry_information10),
5484             decode(p_entry_information11,hr_api.g_varchar2,ee.entry_information11,p_entry_information11),
5485             decode(p_entry_information12,hr_api.g_varchar2,ee.entry_information12,p_entry_information12),
5486             decode(p_entry_information13,hr_api.g_varchar2,ee.entry_information13,p_entry_information13),
5487             decode(p_entry_information14,hr_api.g_varchar2,ee.entry_information14,p_entry_information14),
5488             decode(p_entry_information15,hr_api.g_varchar2,ee.entry_information15,p_entry_information15),
5489             decode(p_entry_information16,hr_api.g_varchar2,ee.entry_information16,p_entry_information16),
5490             decode(p_entry_information17,hr_api.g_varchar2,ee.entry_information17,p_entry_information17),
5491             decode(p_entry_information18,hr_api.g_varchar2,ee.entry_information18,p_entry_information18),
5492             decode(p_entry_information19,hr_api.g_varchar2,ee.entry_information19,p_entry_information19),
5493             decode(p_entry_information20,hr_api.g_varchar2,ee.entry_information20,p_entry_information20),
5494             decode(p_entry_information21,hr_api.g_varchar2,ee.entry_information21,p_entry_information21),
5495             decode(p_entry_information22,hr_api.g_varchar2,ee.entry_information22,p_entry_information22),
5496             decode(p_entry_information23,hr_api.g_varchar2,ee.entry_information23,p_entry_information23),
5497             decode(p_entry_information24,hr_api.g_varchar2,ee.entry_information24,p_entry_information24),
5498             decode(p_entry_information25,hr_api.g_varchar2,ee.entry_information25,p_entry_information25),
5499             decode(p_entry_information26,hr_api.g_varchar2,ee.entry_information26,p_entry_information26),
5500             decode(p_entry_information27,hr_api.g_varchar2,ee.entry_information27,p_entry_information27),
5501             decode(p_entry_information28,hr_api.g_varchar2,ee.entry_information28,p_entry_information28),
5502             decode(p_entry_information29,hr_api.g_varchar2,ee.entry_information29,p_entry_information29),
5503             decode(p_entry_information30,hr_api.g_varchar2,ee.entry_information30,p_entry_information30)
5504      into   v_entry_rec
5505      from   pay_element_entries_f ee,
5506             pay_element_links_f el,
5507             pay_element_types_f et
5508      where  ee.element_entry_id = p_element_entry_id
5509        and  el.element_link_id = ee.element_link_id
5510        and  et.element_type_id = el.element_type_id
5511        and  p_session_date between ee.effective_start_date
5512                                and ee.effective_end_date
5513        and  p_session_date between el.effective_start_date
5514                                and el.effective_end_date
5515        and  p_session_date between et.effective_start_date
5516                                and et.effective_end_date;
5517    exception
5518      when no_data_found then
5519        hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
5520        hr_utility.set_message_token('PROCEDURE',
5521                                     'hr_entry_api.upd_ele_entry_param_val');
5522        hr_utility.set_message_token('STEP','1');
5523        hr_utility.raise_error;
5524    end;
5525    --
5526    -- If specified make sure cost allocation exists
5527    --
5528    if p_cost_allocation_keyflex_id <> hr_api.g_number then
5529      hr_entry_api.val_cost_allocation
5530        (p_cost_allocation_keyflex_id);
5531    end if;
5532    --
5533    -- If specified make sure reason is a valid lookup
5534    --
5535    if p_reason <> hr_api.g_varchar2 then
5536      hr_entry_api.val_reason
5537        (p_reason,
5538         p_session_date);
5539    end if;
5540    --
5541    -- If specified make sure comment exists
5542    --
5543    if p_comment_id <> hr_api.g_number then
5544      hr_entry_api.val_comment
5545        (p_comment_id);
5546    end if;
5547    --
5548    -- If specified make sure original entry is for the same assignment and
5549    -- element link as the element entry being created
5550    --
5551    if p_original_entry_id <> hr_api.g_number then
5552      hr_entry_api.val_original_entry
5553        (p_original_entry_id,
5554         v_entry_rec.assignment_id,
5555         v_entry_rec.element_link_id,
5556         v_entry_rec.entry_type,
5557         p_session_date);
5558    end if;
5559    --
5560    -- Nonrecurring entries can only be corrected ie. a nonrecurring entry is
5561    -- always represented by one row.
5562    --
5563    if (v_entry_rec.processing_type = 'N' and v_entry_rec.entry_type = 'E') or
5564        v_entry_rec.entry_type <> 'E' then
5565      --
5566      p_dt_update_mode := 'CORRECTION';
5567      --
5568    else
5569      --
5570      -- If the p_dt_update_mode is null, then we default to UPDATE mode.
5571      --
5572      p_dt_update_mode := nvl(p_dt_update_mode, 'UPDATE');
5573      --
5574      -- When an update is being carried out at the start date of an entry then
5575      -- a CORRECTION is made.
5576      --
5577      if v_entry_rec.effective_start_date = p_session_date then
5578        --
5579        p_dt_update_mode := 'CORRECTION';
5580      --
5581      -- UPDATE mode has been selected but there are future changes. Do a
5582      -- UPDATE_CHANGE_INSERT instead NB. this is the least destructive option.
5583      --
5584      elsif p_dt_update_mode = 'UPDATE' and
5585            v_entry_rec.effective_end_date <> hr_general.end_of_time then
5586        --
5587        p_dt_update_mode := 'UPDATE_CHANGE_INSERT';
5588      --
5589      -- UPDATE_CHANGE_INSERT or UPDATE_OVERRIDE mode has been selected but
5590      -- there are no changes in the future. Do an UPDATE instead.
5591      --
5592      elsif p_dt_update_mode in ('UPDATE_CHANGE_INSERT','UPDATE_OVERRIDE') and
5593            v_entry_rec.effective_end_date = hr_general.end_of_time then
5594      --
5595        p_dt_update_mode := 'UPDATE';
5596      --
5597      end if;
5598    --
5599    end if;
5600    --
5601    -- Return entry details for use when updating the element entry.
5602    --
5603    p_entry_rec := v_entry_rec;
5604    --
5605  end upd_ele_entry_param_val;
5606 --
5607 -- --
5608 --
5609  ------------------------------------------------------------------------------
5610  -- NAME                                                                     --
5611  -- hr_entry_api.upd_element_entry                                           --
5612  --                                                                          --
5613  -- DESCRIPTION                                                              --
5614  -- Updates an element entry providing full validation.                      --
5615  ------------------------------------------------------------------------------
5616 --
5617  procedure upd_element_entry
5618  (
5619   --
5620   -- Update Mode
5621   --
5622   p_dt_update_mode             varchar2,
5623   --
5624   -- Date on which change is taking place
5625   --
5626   p_session_date               date,
5627   --
5628   -- Check to see if the entry is being updated
5629   --
5630   p_check_for_update           varchar2,
5631   --
5632   -- Element Entry Table
5633   --
5634   p_element_entry_id           number,
5635   p_cost_allocation_keyflex_id number,
5636   p_updating_action_id         number,
5637   p_updating_action_type       varchar2,
5638   p_original_entry_id          number,
5639   p_creator_type               varchar2,
5640   p_comment_id                 number,
5641   p_creator_id                 number,
5642   p_reason                     varchar2,
5643   p_subpriority                number,
5644   p_date_earned                 date,
5645   p_personal_payment_method_id  number,
5646   p_attribute_category         varchar2,
5647   p_attribute1                 varchar2,
5648   p_attribute2                 varchar2,
5649   p_attribute3                 varchar2,
5650   p_attribute4                 varchar2,
5651   p_attribute5                 varchar2,
5652   p_attribute6                 varchar2,
5653   p_attribute7                 varchar2,
5654   p_attribute8                 varchar2,
5655   p_attribute9                 varchar2,
5656   p_attribute10                varchar2,
5657   p_attribute11                varchar2,
5658   p_attribute12                varchar2,
5659   p_attribute13                varchar2,
5660   p_attribute14                varchar2,
5661   p_attribute15                varchar2,
5662   p_attribute16                varchar2,
5663   p_attribute17                varchar2,
5664   p_attribute18                varchar2,
5665   p_attribute19                varchar2,
5666   p_attribute20                varchar2,
5667   --
5668   -- Element Entry Values Table
5669   --
5670   p_num_entry_values           number,
5671   p_input_value_id_tbl         hr_entry.number_table,
5672   p_entry_value_tbl            hr_entry.varchar2_table,
5673   --
5674   -- J.Bailie Element Entries DDF
5675   --
5676   p_entry_information_category varchar2,
5677   p_entry_information1         varchar2,
5678   p_entry_information2         varchar2,
5679   p_entry_information3         varchar2,
5680   p_entry_information4         varchar2,
5681   p_entry_information5         varchar2,
5682   p_entry_information6         varchar2,
5683   p_entry_information7         varchar2,
5684   p_entry_information8         varchar2,
5685   p_entry_information9         varchar2,
5686   p_entry_information10        varchar2,
5687   p_entry_information11        varchar2,
5688   p_entry_information12        varchar2,
5689   p_entry_information13        varchar2,
5690   p_entry_information14        varchar2,
5691   p_entry_information15        varchar2,
5692   p_entry_information16        varchar2,
5693   p_entry_information17        varchar2,
5694   p_entry_information18        varchar2,
5695   p_entry_information19        varchar2,
5696   p_entry_information20        varchar2,
5697   p_entry_information21        varchar2,
5698   p_entry_information22        varchar2,
5699   p_entry_information23        varchar2,
5700   p_entry_information24        varchar2,
5701   p_entry_information25        varchar2,
5702   p_entry_information26        varchar2,
5703   p_entry_information27        varchar2,
5704   p_entry_information28        varchar2,
5705   p_entry_information29        varchar2,
5706   p_entry_information30        varchar2
5707  ) is
5708 --
5709    -- Find all accepted pay proposals that use the element entry.
5710    cursor csr_accepted_pay_proposals
5711           (
5712            p_element_entry_id number,
5713            p_assignment_id    number
5714           ) is
5715      select pp.pay_proposal_id
5716      from   per_pay_proposals pp
5717      where  pp.assignment_id = p_assignment_id
5718        and  exists
5719             (select null
5720              from   pay_element_entries_f ee
5721              where  ee.element_entry_id = p_element_entry_id
5722                and  ee.creator_type = 'SP'
5723                and  ee.creator_id = pp.pay_proposal_id
5724                and  ee.effective_start_date = pp.change_date);
5725    --
5726    -- bug 666197
5727    --
5728    -- OVN of the dml record
5729    cursor csr_object_version_number
5730      (p_element_entry_id number, p_effective_date date) is
5731       select object_version_number, effective_start_date, effective_end_date
5732         from pay_element_entries_f
5733         where element_entry_id = p_element_entry_id
5734           and p_effective_date between effective_start_date
5735                                    and effective_end_date;
5736 
5737    --
5738    -- old values of the dml record
5739    cursor csr_old_entry_values is
5740      select
5741        effective_start_date
5742       ,effective_end_date
5743       ,cost_allocation_keyflex_id
5744       ,assignment_id
5745       ,updating_action_id
5746       ,updating_action_type
5747       ,element_link_id
5748       ,original_entry_id
5749       ,creator_type
5750       ,entry_type
5751       ,comment_id
5752       ,creator_id
5753       ,reason
5754       ,target_entry_id
5755       ,source_id
5756       ,attribute_category
5757       ,attribute1
5758       ,attribute2
5759       ,attribute3
5760       ,attribute4
5761       ,attribute5
5762       ,attribute6
5763       ,attribute7
5764       ,attribute8
5765       ,attribute9
5766       ,attribute10
5767       ,attribute11
5768       ,attribute12
5769       ,attribute13
5770       ,attribute14
5771       ,attribute15
5772       ,attribute16
5773       ,attribute17
5774       ,attribute18
5775       ,attribute19
5776       ,attribute20
5777       ,subpriority
5778       ,personal_payment_method_id
5779       ,date_earned
5780       ,object_version_number
5781       ,balance_adj_cost_flag
5782   --
5783   -- J.Bailie 08-NOV-99 Element Entries DDF
5784   --
5785       ,entry_information_category
5786       ,entry_information1
5787       ,entry_information2
5788       ,entry_information3
5789       ,entry_information4
5790       ,entry_information5
5791       ,entry_information6
5792       ,entry_information7
5793       ,entry_information8
5794       ,entry_information9
5795       ,entry_information10
5796       ,entry_information11
5797       ,entry_information12
5798       ,entry_information13
5799       ,entry_information14
5800       ,entry_information15
5801       ,entry_information16
5802       ,entry_information17
5803       ,entry_information18
5804       ,entry_information19
5805       ,entry_information20
5806       ,entry_information21
5807       ,entry_information22
5808       ,entry_information23
5809       ,entry_information24
5810       ,entry_information25
5811       ,entry_information26
5812       ,entry_information27
5813       ,entry_information28
5814       ,entry_information29
5815       ,entry_information30
5816       ,element_type_id
5817       ,all_entry_values_null
5818     from pay_element_entries_f
5819     where element_entry_id = p_element_entry_id
5820       and p_session_date between effective_start_date
5821                              and effective_end_date;
5822     --
5823    -- Local Variables
5824    v_validation_start_date  date;
5825    v_validation_end_date    date;
5826    v_max_effective_end_date date;
5827    v_dt_update_mode         varchar2(30) := p_dt_update_mode;
5828    v_entry_rec              hr_entry_api.t_update_entry_rec;
5829    v_entry_being_changed    boolean      := true;
5830    v_pay_proposal_id        number;
5831    l_all_entry_values_null           varchar2(30);
5832    -- bug 666197
5833    l_object_version_number           number;
5834    l_effective_start_date            date;
5835    l_effective_end_date              date;
5836    l_effective_start_date_o          date;
5837    l_effective_end_date_o            date;
5838    l_cost_allocation_keyflex_id_o    number;
5839    l_assignment_id_o                 number;
5840    l_updating_action_id_o            number;
5841    l_updating_action_type_o          varchar2(30);
5842    l_element_link_id_o               number;
5843    l_original_entry_id_o             number;
5844    l_creator_type_o                  varchar2(10);
5845    l_entry_type_o                    varchar2(1);
5846    l_comment_id_o                    number;
5847    l_creator_id_o                    number;
5848    l_reason_o                        varchar2(30);
5849    l_target_entry_id_o               number;
5850    l_source_id_o                     number;
5851    l_attribute_category_o            varchar2(30);
5852    l_attribute1_o                    varchar2(150);
5853    l_attribute2_o                    varchar2(150);
5854    l_attribute3_o                    varchar2(150);
5855    l_attribute4_o                    varchar2(150);
5856    l_attribute5_o                    varchar2(150);
5857    l_attribute6_o                    varchar2(150);
5858    l_attribute7_o                    varchar2(150);
5859    l_attribute8_o                    varchar2(150);
5860    l_attribute9_o                    varchar2(150);
5861    l_attribute10_o                   varchar2(150);
5862    l_attribute11_o                   varchar2(150);
5863    l_attribute12_o                   varchar2(150);
5864    l_attribute13_o                   varchar2(150);
5865    l_attribute14_o                   varchar2(150);
5866    l_attribute15_o                   varchar2(150);
5867    l_attribute16_o                   varchar2(150);
5868    l_attribute17_o                   varchar2(150);
5869    l_attribute18_o                   varchar2(150);
5870    l_attribute19_o                   varchar2(150);
5871    l_attribute20_o                   varchar2(150);
5872    l_subpriority_o                   number;
5873    l_entry_information_category_o    varchar2(30);
5874    l_entry_information1_o            varchar2(150);
5875    l_entry_information2_o            varchar2(150);
5876    l_entry_information3_o            varchar2(150);
5877    l_entry_information4_o            varchar2(150);
5878    l_entry_information5_o            varchar2(150);
5879    l_entry_information6_o            varchar2(150);
5880    l_entry_information7_o            varchar2(150);
5881    l_entry_information8_o            varchar2(150);
5882    l_entry_information9_o            varchar2(150);
5883    l_entry_information10_o           varchar2(150);
5884    l_entry_information11_o           varchar2(150);
5885    l_entry_information12_o           varchar2(150);
5886    l_entry_information13_o           varchar2(150);
5887    l_entry_information14_o           varchar2(150);
5888    l_entry_information15_o           varchar2(150);
5889    l_entry_information16_o           varchar2(150);
5890    l_entry_information17_o           varchar2(150);
5891    l_entry_information18_o           varchar2(150);
5892    l_entry_information19_o           varchar2(150);
5893    l_entry_information20_o           varchar2(150);
5894    l_entry_information21_o           varchar2(150);
5895    l_entry_information22_o           varchar2(150);
5896    l_entry_information23_o           varchar2(150);
5897    l_entry_information24_o           varchar2(150);
5898    l_entry_information25_o           varchar2(150);
5899    l_entry_information26_o           varchar2(150);
5900    l_entry_information27_o           varchar2(150);
5901    l_entry_information28_o           varchar2(150);
5902    l_entry_information29_o           varchar2(150);
5903    l_entry_information30_o           varchar2(150);
5904    l_personal_payment_method_id_o    number;
5905    l_date_earned_o                   date;
5906    l_object_version_number_o         number;
5907    l_balance_adj_cost_flag_o         varchar2(1);
5908    l_element_type_id_o               number;
5909    l_all_entry_values_null_o         varchar2(30);
5910 --
5911 
5912    l_old_val_tab                     pay_ele_shd.g_old_val_tab_type; --Local store of eev_old details
5913 --
5914 
5915  begin
5916    --
5917    g_debug := hr_utility.debug_enabled;
5918    --
5919    -- bug 666197, retrieve and store old values for the entry row
5920    --
5921    begin
5922    --
5923    open csr_old_entry_values;
5924    fetch csr_old_entry_values into
5925        l_effective_start_date_o
5926       ,l_effective_end_date_o
5927       ,l_cost_allocation_keyflex_id_o
5928       ,l_assignment_id_o
5929       ,l_updating_action_id_o
5930       ,l_updating_action_type_o
5931       ,l_element_link_id_o
5932       ,l_original_entry_id_o
5933       ,l_creator_type_o
5934       ,l_entry_type_o
5935       ,l_comment_id_o
5936       ,l_creator_id_o
5937       ,l_reason_o
5938       ,l_target_entry_id_o
5939       ,l_source_id_o
5940       ,l_attribute_category_o
5941       ,l_attribute1_o
5942       ,l_attribute2_o
5943       ,l_attribute3_o
5944       ,l_attribute4_o
5945       ,l_attribute5_o
5946       ,l_attribute6_o
5947       ,l_attribute7_o
5948       ,l_attribute8_o
5949       ,l_attribute9_o
5950       ,l_attribute10_o
5951       ,l_attribute11_o
5952       ,l_attribute12_o
5953       ,l_attribute13_o
5954       ,l_attribute14_o
5955       ,l_attribute15_o
5956       ,l_attribute16_o
5957       ,l_attribute17_o
5958       ,l_attribute18_o
5959       ,l_attribute19_o
5960       ,l_attribute20_o
5961       ,l_subpriority_o
5962       ,l_personal_payment_method_id_o
5963       ,l_date_earned_o
5964       ,l_object_version_number_o
5965       ,l_balance_adj_cost_flag_o
5966       ,l_entry_information_category_o
5967       ,l_entry_information1_o
5968       ,l_entry_information2_o
5969       ,l_entry_information3_o
5970       ,l_entry_information4_o
5971       ,l_entry_information5_o
5972       ,l_entry_information6_o
5973       ,l_entry_information7_o
5974       ,l_entry_information8_o
5975       ,l_entry_information9_o
5976       ,l_entry_information10_o
5977       ,l_entry_information11_o
5978       ,l_entry_information12_o
5979       ,l_entry_information13_o
5980       ,l_entry_information14_o
5981       ,l_entry_information15_o
5982       ,l_entry_information16_o
5983       ,l_entry_information17_o
5984       ,l_entry_information18_o
5985       ,l_entry_information19_o
5986       ,l_entry_information20_o
5987       ,l_entry_information21_o
5988       ,l_entry_information22_o
5989       ,l_entry_information23_o
5990       ,l_entry_information24_o
5991       ,l_entry_information25_o
5992       ,l_entry_information26_o
5993       ,l_entry_information27_o
5994       ,l_entry_information28_o
5995       ,l_entry_information29_o
5996       ,l_entry_information30_o
5997       ,l_element_type_id_o
5998       ,l_all_entry_values_null_o;
5999    close csr_old_entry_values;
6000    exception
6001    when no_data_found then
6002      hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
6003      hr_utility.set_message_token('PROCEDURE','hr_entry_api.upd_element_entry');
6004      hr_utility.set_message_token('STEP','10');
6005      hr_utility.raise_error;
6006    end;
6007    -- If the entry row is to be checked for a changed attribute then
6008    -- check to see if the entry row is being changed.
6009    --
6010    if (p_check_for_update = 'Y') then
6011      v_entry_being_changed :=
6012        hr_entry_api.element_entry_changed
6013        (p_session_date,
6014         p_element_entry_id,
6015         p_cost_allocation_keyflex_id,
6016         p_updating_action_id,
6017         p_updating_action_type,
6018         p_original_entry_id,
6019         p_creator_type,
6020         p_comment_id,
6021         p_creator_id,
6022         p_reason,
6023         p_subpriority,
6024         p_date_earned,
6025         p_personal_payment_method_id,
6026         p_attribute_category,
6027         p_attribute1,
6028         p_attribute2,
6029         p_attribute3,
6030         p_attribute4,
6031         p_attribute5,
6032         p_attribute6,
6033         p_attribute7,
6034         p_attribute8,
6035         p_attribute9,
6036         p_attribute10,
6037         p_attribute11,
6038         p_attribute12,
6039         p_attribute13,
6040         p_attribute14,
6041         p_attribute15,
6042         p_attribute16,
6043         p_attribute17,
6044         p_attribute18,
6045         p_attribute19,
6046         p_attribute20,
6047         p_num_entry_values,
6048         p_input_value_id_tbl,
6049         p_entry_value_tbl,
6050         p_entry_information_category,
6051         p_entry_information1,
6052         p_entry_information2,
6053         p_entry_information3,
6054         p_entry_information4,
6055         p_entry_information5,
6056         p_entry_information6,
6057         p_entry_information7,
6058         p_entry_information8,
6059         p_entry_information9,
6060         p_entry_information10,
6061         p_entry_information11,
6062         p_entry_information12,
6063         p_entry_information13,
6064         p_entry_information14,
6065         p_entry_information15,
6066         p_entry_information16,
6067         p_entry_information17,
6068         p_entry_information18,
6069         p_entry_information19,
6070         p_entry_information20,
6071         p_entry_information21,
6072         p_entry_information22,
6073         p_entry_information23,
6074         p_entry_information24,
6075         p_entry_information25,
6076         p_entry_information26,
6077         p_entry_information27,
6078         p_entry_information28,
6079         p_entry_information29,
6080         p_entry_information30
6081        );
6082    end if;
6083 --
6084    if v_entry_being_changed then
6085      -- Validate the parameters and return details of the current element entry.
6086      hr_entry_api.upd_ele_entry_param_val
6087        (v_dt_update_mode,
6088         p_session_date,
6089         p_element_entry_id,
6090         p_cost_allocation_keyflex_id,
6091         p_updating_action_id,
6092         p_updating_action_type,
6093         p_original_entry_id,
6094         p_creator_type,
6095         p_comment_id,
6096         p_creator_id,
6097         p_reason,
6098         p_subpriority,
6099         p_date_earned,
6100         p_personal_payment_method_id,
6101         p_attribute_category,
6102         p_attribute1,
6103         p_attribute2,
6104         p_attribute3,
6105         p_attribute4,
6106         p_attribute5,
6107         p_attribute6,
6108         p_attribute7,
6109         p_attribute8,
6110         p_attribute9,
6111         p_attribute10,
6112         p_attribute11,
6113         p_attribute12,
6114         p_attribute13,
6115         p_attribute14,
6116         p_attribute15,
6117         p_attribute16,
6118         p_attribute17,
6119         p_attribute18,
6120         p_attribute19,
6121         p_attribute20,
6122         p_entry_information_category,
6123         p_entry_information1,
6124         p_entry_information2,
6125         p_entry_information3,
6126         p_entry_information4,
6127         p_entry_information5,
6128         p_entry_information6,
6129         p_entry_information7,
6130         p_entry_information8,
6131         p_entry_information9,
6132         p_entry_information10,
6133         p_entry_information11,
6134         p_entry_information12,
6135         p_entry_information13,
6136         p_entry_information14,
6137         p_entry_information15,
6138         p_entry_information16,
6139         p_entry_information17,
6140         p_entry_information18,
6141         p_entry_information19,
6142         p_entry_information20,
6143         p_entry_information21,
6144         p_entry_information22,
6145         p_entry_information23,
6146         p_entry_information24,
6147         p_entry_information25,
6148         p_entry_information26,
6149         p_entry_information27,
6150         p_entry_information28,
6151         p_entry_information29,
6152         p_entry_information30,
6153         v_entry_rec
6154      );
6155 --
6156      -- Set the validation start and end dates according to the update mode
6157      -- selected.
6158      if v_dt_update_mode = 'UPDATE' or
6159         v_dt_update_mode = 'UPDATE_CHANGE_INSERT' then
6160 --
6161        v_validation_start_date := p_session_date;
6162        v_validation_end_date   := v_entry_rec.effective_end_date;
6163 --
6164      elsif v_dt_update_mode = 'UPDATE_OVERRIDE' then
6165 --
6166        begin
6167          select max(ee.effective_end_date)
6168          into   v_max_effective_end_date
6169          from   pay_element_entries_f ee
6170          where  ee.element_entry_id = p_element_entry_id;
6171        exception
6172          when no_data_found then null;
6173        end;
6174 --
6175        v_validation_start_date := p_session_date;
6176        v_validation_end_date   := v_max_effective_end_date;
6177 --
6178      elsif v_dt_update_mode = 'CORRECTION' then
6179 --
6180        v_validation_start_date := v_entry_rec.effective_start_date;
6181        v_validation_end_date   := v_entry_rec.effective_end_date;
6182 --
6183      end if;
6184 --
6185 --
6186      validate_ppm_id (v_entry_rec.personal_payment_method_id,
6187                       v_entry_rec.assignment_id,
6188                       v_entry_rec.element_link_id,
6189                       v_validation_start_date,
6190                       v_validation_end_date,
6191                       l_entry_type_o);
6192                       --
6193 --
6194      -- Make sure the update is valid.
6195      hr_entry.chk_element_entry_main
6196        (p_element_entry_id,
6197         v_entry_rec.original_entry_id,
6198         p_session_date,
6199         v_entry_rec.element_link_id,
6200         v_entry_rec.assignment_id,
6201         v_entry_rec.entry_type,
6202         v_entry_rec.effective_start_date,
6203         v_entry_rec.effective_end_date,
6204         v_validation_start_date,
6205         v_validation_end_date,
6206         v_dt_update_mode,
6207         null,
6208         'UPDATE',  -- p_usage
6209         v_entry_rec.target_entry_id,
6210         p_creator_type);
6211 --
6212      -- Validate salary admin updates to user-enterable fields
6213      --
6214      hr_entry_api.check_salary_admin_updates (
6215         --
6216         p_element_entry_id      => p_element_entry_id,
6217         p_new_entry             => v_entry_rec,
6218         p_effective_date        => p_session_date,
6219         p_dt_update_mode        => p_dt_update_mode);
6220         --
6221      -- Make a copy of all pay proposals for the assignment which have been
6222      -- accepted. This is used later to see if any have had the element entry
6223      -- changed ie. creator type changed, removed etc... If so the pay proposal
6224      -- has to be removed.
6225      open csr_accepted_pay_proposals(p_element_entry_id,
6226                                      v_entry_rec.assignment_id);
6227 --
6228      -- Trigger workload shifting if change to element entry overlaps with the
6229      -- latest payroll run for the assignment and workload shifting is enabled.
6230      hr_entry.trigger_workload_shifting
6231        ('ELEMENT_ENTRY',
6232         v_entry_rec.assignment_id,
6233         v_validation_start_date,
6234         v_validation_end_date);
6235 --
6236      -- Bugfix 2768375
6237      -- Perform validation of Element Entry Developer DF segments
6238      if fnd_flex_dsc_api.flexfield_exists(
6239             appl_short_name => 'PAY',
6240             flexfield_name  => 'Element Entry Developer DF') then
6241 
6242        if g_debug then
6243           hr_utility.trace('| element entry DDFF defined');
6244           hr_utility.trace('| p_entry_information_category' ||
6245                               p_entry_information_category || '<');
6246        end if;
6247 
6248        --
6249        -- only do FF validation if the context exists
6250        --
6251        if fnd_flex_dsc_api.context_exists(
6252             p_appl_short_name => 'PAY',
6253             p_flexfield_name  => 'Element Entry Developer DF',
6254             p_context_code    => p_entry_information_category) then
6255 
6256          if g_debug then
6257            hr_utility.trace('| element entry context in use, do validation');
6258          end if;
6259 
6260          hr_entry_api.ddf_update_validate(
6261            p_entry_information_category   => p_entry_information_category
6262          , p_entry_information1           => p_entry_information1
6263          , p_entry_information2           => p_entry_information2
6264          , p_entry_information3           => p_entry_information3
6265          , p_entry_information4           => p_entry_information4
6266          , p_entry_information5           => p_entry_information5
6267          , p_entry_information6           => p_entry_information6
6268          , p_entry_information7           => p_entry_information7
6269          , p_entry_information8           => p_entry_information8
6270          , p_entry_information9           => p_entry_information9
6271          , p_entry_information10          => p_entry_information10
6272          , p_entry_information11          => p_entry_information11
6273          , p_entry_information12          => p_entry_information12
6274          , p_entry_information13          => p_entry_information13
6275          , p_entry_information14          => p_entry_information14
6276          , p_entry_information15          => p_entry_information15
6277          , p_entry_information16          => p_entry_information16
6278          , p_entry_information17          => p_entry_information17
6279          , p_entry_information18          => p_entry_information18
6280          , p_entry_information19          => p_entry_information19
6281          , p_entry_information20          => p_entry_information20
6282          , p_entry_information21          => p_entry_information21
6283          , p_entry_information22          => p_entry_information22
6284          , p_entry_information23          => p_entry_information23
6285          , p_entry_information24          => p_entry_information24
6286          , p_entry_information25          => p_entry_information25
6287          , p_entry_information26          => p_entry_information26
6288          , p_entry_information27          => p_entry_information27
6289          , p_entry_information28          => p_entry_information28
6290          , p_entry_information29          => p_entry_information29
6291          , p_entry_information30          => p_entry_information30
6292          , p_entry_information_category_o => l_entry_information_category_o
6293          , p_entry_information1_o         => l_entry_information1_o
6294          , p_entry_information2_o         => l_entry_information2_o
6295          , p_entry_information3_o         => l_entry_information3_o
6296          , p_entry_information4_o         => l_entry_information4_o
6297          , p_entry_information5_o         => l_entry_information5_o
6298          , p_entry_information6_o         => l_entry_information6_o
6299          , p_entry_information7_o         => l_entry_information7_o
6300          , p_entry_information8_o         => l_entry_information8_o
6301          , p_entry_information9_o         => l_entry_information9_o
6302          , p_entry_information10_o        => l_entry_information10_o
6303          , p_entry_information11_o        => l_entry_information11_o
6304          , p_entry_information12_o        => l_entry_information12_o
6305          , p_entry_information13_o        => l_entry_information13_o
6306          , p_entry_information14_o        => l_entry_information14_o
6307          , p_entry_information15_o        => l_entry_information15_o
6308          , p_entry_information16_o        => l_entry_information16_o
6309          , p_entry_information17_o        => l_entry_information17_o
6310          , p_entry_information18_o        => l_entry_information18_o
6311          , p_entry_information19_o        => l_entry_information19_o
6312          , p_entry_information20_o        => l_entry_information20_o
6313          , p_entry_information21_o        => l_entry_information21_o
6314          , p_entry_information22_o        => l_entry_information22_o
6315          , p_entry_information23_o        => l_entry_information23_o
6316          , p_entry_information24_o        => l_entry_information24_o
6317          , p_entry_information25_o        => l_entry_information25_o
6318          , p_entry_information26_o        => l_entry_information26_o
6319          , p_entry_information27_o        => l_entry_information27_o
6320          , p_entry_information28_o        => l_entry_information28_o
6321          , p_entry_information29_o        => l_entry_information29_o
6322          , p_entry_information30_o        => l_entry_information30_o);
6323 
6324        end if;
6325 
6326      end if;
6327      -- End Bugfix 2768375
6328 --
6329      --
6330      -- Enhancement 3478848
6331      -- Derive all_entry_values_null
6332      --
6333      l_all_entry_values_null := derive_all_entry_values_null(p_entry_value_tbl);
6334 --
6335      -- Do date effective operation on element entry.
6336      if v_dt_update_mode in ('UPDATE','UPDATE_CHANGE_INSERT',
6337                              'UPDATE_OVERRIDE')  then
6338 --
6339        -- Clear out future records (if any).
6340        if v_dt_update_mode = 'UPDATE_OVERRIDE' then
6341 --
6342          delete from pay_element_entries_f ee
6343          where  ee.element_entry_id = p_element_entry_id
6344            and  ee.effective_start_date > v_entry_rec.effective_start_date;
6345 --
6346        end if;
6347 --
6348 
6349        --
6350        -- Bug 3674811 : updating_action_id
6351        --      null on first half for Stop
6352        --      null on second half for Update Recurring
6353        --
6354 
6355        update pay_element_entries_f ee
6356        set    ee.effective_end_date = p_session_date - 1,
6357               ee.updating_action_id = decode(ee.updating_action_type, 'U', ee.updating_action_id,
6358                                                                       null),
6359               ee.updating_action_type = decode(ee.updating_action_type, 'U', 'U', null)
6360        where  ee.element_entry_id = p_element_entry_id
6361          and  ee.effective_start_date = v_entry_rec.effective_start_date;
6362 
6363        --
6364        -- Bugfix 3110853
6365        -- Derive the OVN here instead of in the database trigger in order to
6366        -- avoid the ORA-04091 error
6367        --
6368        l_object_version_number := dt_api.get_object_version_number
6369                                   ('PAY_ELEMENT_ENTRIES_F'
6370                                   ,'ELEMENT_ENTRY_ID'
6371                                   ,p_element_entry_id);
6372 
6373        insert into pay_element_entries_f
6374        (element_entry_id,
6375         effective_start_date,
6376         effective_end_date,
6377         cost_allocation_keyflex_id,
6378         assignment_id,
6379         updating_action_id,
6380         updating_action_type,
6381         element_link_id,
6382         original_entry_id,
6383         creator_type,
6384         entry_type,
6385         comment_id,
6386         creator_id,
6387         reason,
6388         target_entry_id,
6389         subpriority,
6390         date_earned,
6391         personal_payment_method_id,
6392         attribute_category,
6393         attribute1,
6394         attribute2,
6395         attribute3,
6396         attribute4,
6397         attribute5,
6398         attribute6,
6399         attribute7,
6400         attribute8,
6401         attribute9,
6402         attribute10,
6403         attribute11,
6404         attribute12,
6405         attribute13,
6406         attribute14,
6407         attribute15,
6408         attribute16,
6409         attribute17,
6410         attribute18,
6411         attribute19,
6412         attribute20,
6413         --
6414         -- J.Bailie 08-NOV-99 Element Entries DDF
6415         --
6416         entry_information_category,
6417         entry_information1,
6418         entry_information2,
6419         entry_information3,
6420         entry_information4,
6421         entry_information5,
6422         entry_information6,
6423         entry_information7,
6424         entry_information8,
6425         entry_information9,
6426         entry_information10,
6427         entry_information11,
6428         entry_information12,
6429         entry_information13,
6430         entry_information14,
6431         entry_information15,
6432         entry_information16,
6433         entry_information17,
6434         entry_information18,
6435         entry_information19,
6436         entry_information20,
6437         entry_information21,
6438         entry_information22,
6439         entry_information23,
6440         entry_information24,
6441         entry_information25,
6442         entry_information26,
6443         entry_information27,
6444         entry_information28,
6445         entry_information29,
6446         entry_information30,
6447         element_type_id,
6448         all_entry_values_null,
6449         object_version_number,
6450         last_update_date,
6451         last_updated_by,
6452         last_update_login,
6453         created_by,
6454         creation_date)
6455        select
6456         ee.element_entry_id,
6457         v_validation_start_date,
6458         v_validation_end_date,
6459         v_entry_rec.cost_allocation_keyflex_id,
6460         ee.assignment_id,
6461         decode(ee.updating_action_type, 'S', ee.updating_action_id, null),
6462         decode(ee.updating_action_type, 'S', 'S', null),
6463         ee.element_link_id,
6464         v_entry_rec.original_entry_id,
6465         v_entry_rec.creator_type,
6466         ee.entry_type,
6467         v_entry_rec.comment_id,
6468         v_entry_rec.creator_id,
6469         v_entry_rec.reason,
6470         ee.target_entry_id,
6471         v_entry_rec.subpriority,
6472         v_entry_rec.date_earned,
6473         v_entry_rec.personal_payment_method_id,
6474         v_entry_rec.attribute_category,
6475         v_entry_rec.attribute1,
6476         v_entry_rec.attribute2,
6477         v_entry_rec.attribute3,
6478         v_entry_rec.attribute4,
6479         v_entry_rec.attribute5,
6480         v_entry_rec.attribute6,
6481         v_entry_rec.attribute7,
6482         v_entry_rec.attribute8,
6483         v_entry_rec.attribute9,
6484         v_entry_rec.attribute10,
6485         v_entry_rec.attribute11,
6486         v_entry_rec.attribute12,
6487         v_entry_rec.attribute13,
6488         v_entry_rec.attribute14,
6489         v_entry_rec.attribute15,
6490         v_entry_rec.attribute16,
6491         v_entry_rec.attribute17,
6492         v_entry_rec.attribute18,
6493         v_entry_rec.attribute19,
6494         v_entry_rec.attribute20,
6495         --
6496         -- J.Bailie 08-NOV-99 Element Entries DDF
6497         --
6498         v_entry_rec.entry_information_category,
6499         v_entry_rec.entry_information1,
6500         v_entry_rec.entry_information2,
6501         v_entry_rec.entry_information3,
6502         v_entry_rec.entry_information4,
6503         v_entry_rec.entry_information5,
6504         v_entry_rec.entry_information6,
6505         v_entry_rec.entry_information7,
6506         v_entry_rec.entry_information8,
6507         v_entry_rec.entry_information9,
6508         v_entry_rec.entry_information10,
6509         v_entry_rec.entry_information11,
6510         v_entry_rec.entry_information12,
6511         v_entry_rec.entry_information13,
6512         v_entry_rec.entry_information14,
6513         v_entry_rec.entry_information15,
6514         v_entry_rec.entry_information16,
6515         v_entry_rec.entry_information17,
6516         v_entry_rec.entry_information18,
6517         v_entry_rec.entry_information19,
6518         v_entry_rec.entry_information20,
6519         v_entry_rec.entry_information21,
6520         v_entry_rec.entry_information22,
6521         v_entry_rec.entry_information23,
6522         v_entry_rec.entry_information24,
6523         v_entry_rec.entry_information25,
6524         v_entry_rec.entry_information26,
6525         v_entry_rec.entry_information27,
6526         v_entry_rec.entry_information28,
6527         v_entry_rec.entry_information29,
6528         v_entry_rec.entry_information30,
6529         v_entry_rec.element_type_id,
6530         l_all_entry_values_null,
6531         l_object_version_number,
6532         trunc(sysdate),
6533         0,
6534         0,
6535         ee.created_by,
6536         ee.creation_date
6537        from  pay_element_entries_f ee
6538        where ee.element_entry_id = p_element_entry_id
6539          and ee.effective_start_date = v_entry_rec.effective_start_date;
6540 --
6541      elsif v_dt_update_mode = 'CORRECTION' then
6542        update pay_element_entries_f ee
6543        set    ee.cost_allocation_keyflex_id =
6544               v_entry_rec.cost_allocation_keyflex_id,
6545               ee.updating_action_id = v_entry_rec.updating_action_id,
6546               ee.updating_action_type = v_entry_rec.updating_action_type,
6547               ee.original_entry_id = v_entry_rec.original_entry_id,
6548               ee.creator_type = v_entry_rec.creator_type,
6549               ee.comment_id = v_entry_rec.comment_id,
6550               ee.creator_id = v_entry_rec.creator_id,
6551               ee.reason = v_entry_rec.reason,
6552               ee.subpriority = v_entry_rec.subpriority,
6553               ee.date_earned = v_entry_rec.date_earned,
6554               ee.personal_payment_method_id = v_entry_rec.personal_payment_method_id,
6555               ee.all_entry_values_null = l_all_entry_values_null,
6556               ee.attribute_category = v_entry_rec.attribute_category,
6557               ee.attribute1  = v_entry_rec.attribute1,
6558               ee.attribute2  = v_entry_rec.attribute2,
6559               ee.attribute3  = v_entry_rec.attribute3,
6560               ee.attribute4  = v_entry_rec.attribute4,
6561               ee.attribute5  = v_entry_rec.attribute5,
6562               ee.attribute6  = v_entry_rec.attribute6,
6563               ee.attribute7  = v_entry_rec.attribute7,
6564               ee.attribute8  = v_entry_rec.attribute8,
6565               ee.attribute9  = v_entry_rec.attribute9,
6566               ee.attribute10 = v_entry_rec.attribute10,
6567               ee.attribute11 = v_entry_rec.attribute11,
6568               ee.attribute12 = v_entry_rec.attribute12,
6569               ee.attribute13 = v_entry_rec.attribute13,
6570               ee.attribute14 = v_entry_rec.attribute14,
6571               ee.attribute15 = v_entry_rec.attribute15,
6572               ee.attribute16 = v_entry_rec.attribute16,
6573               ee.attribute17 = v_entry_rec.attribute17,
6574               ee.attribute18 = v_entry_rec.attribute18,
6575               ee.attribute19 = v_entry_rec.attribute19,
6576               ee.attribute20 = v_entry_rec.attribute20,
6577               ee.entry_information_category = v_entry_rec.entry_information_category,
6578               ee.entry_information1  = v_entry_rec.entry_information1,
6579               ee.entry_information2  = v_entry_rec.entry_information2,
6580               ee.entry_information3  = v_entry_rec.entry_information3,
6581               ee.entry_information4  = v_entry_rec.entry_information4,
6582               ee.entry_information5  = v_entry_rec.entry_information5,
6583               ee.entry_information6  = v_entry_rec.entry_information6,
6584               ee.entry_information7  = v_entry_rec.entry_information7,
6585               ee.entry_information8  = v_entry_rec.entry_information8,
6586               ee.entry_information9  = v_entry_rec.entry_information9,
6587               ee.entry_information10  = v_entry_rec.entry_information10,
6588               ee.entry_information11  = v_entry_rec.entry_information11,
6589               ee.entry_information12  = v_entry_rec.entry_information12,
6590               ee.entry_information13  = v_entry_rec.entry_information13,
6591               ee.entry_information14  = v_entry_rec.entry_information14,
6592               ee.entry_information15  = v_entry_rec.entry_information15,
6593               ee.entry_information16  = v_entry_rec.entry_information16,
6594               ee.entry_information17  = v_entry_rec.entry_information17,
6595               ee.entry_information18  = v_entry_rec.entry_information18,
6596               ee.entry_information19  = v_entry_rec.entry_information19,
6597               ee.entry_information20  = v_entry_rec.entry_information20,
6598               ee.entry_information21  = v_entry_rec.entry_information21,
6599               ee.entry_information22  = v_entry_rec.entry_information22,
6600               ee.entry_information23  = v_entry_rec.entry_information23,
6601               ee.entry_information24  = v_entry_rec.entry_information24,
6602               ee.entry_information25  = v_entry_rec.entry_information25,
6603               ee.entry_information26  = v_entry_rec.entry_information26,
6604               ee.entry_information27  = v_entry_rec.entry_information27,
6605               ee.entry_information28  = v_entry_rec.entry_information28,
6606               ee.entry_information29  = v_entry_rec.entry_information29,
6607               ee.entry_information30  = v_entry_rec.entry_information30,
6608               ee.last_update_date  = trunc(sysdate),
6609               ee.last_updated_by   = 0,
6610               ee.last_update_login = 0
6611        where  ee.element_entry_id = p_element_entry_id
6612          and  ee.effective_start_date = v_validation_start_date;
6613 
6614      end if;
6615 --
6616     -- 21-FEB-03
6617     -- Before we change the element entry values for this entry, we need to store
6618     -- the old element_entry_values for our hardcoded call to the CC DYT_PKG
6619     l_old_val_tab.delete;
6620     g_counter := 0;
6621 
6622     For vals_rec in pay_ele_shd.csr_get_eevals(p_element_entry_id,p_session_date) loop
6623       g_counter := g_counter + 1;
6624         l_old_val_tab(g_counter).element_entry_value_id
6625               := vals_rec.element_entry_value_id;
6626         l_old_val_tab(g_counter).effective_start_date
6627               := vals_rec.effective_start_date;
6628         l_old_val_tab(g_counter).effective_end_date
6629               := vals_rec.effective_end_date;
6630         l_old_val_tab(g_counter).input_value_id
6631              := vals_rec.input_value_id;
6632         l_old_val_tab(g_counter).element_entry_id
6633               := vals_rec.element_entry_id;
6634         l_old_val_tab(g_counter).screen_entry_value
6635               := vals_rec.screen_entry_value;
6636 
6637     End Loop;
6638 
6639 --
6640      -- Update element entry values.
6641      hr_entry.upd_3p_entry_values
6642        (p_element_entry_id,
6643         v_entry_rec.element_type_id,
6644         v_entry_rec.element_link_id,
6645         v_entry_rec.cost_allocation_keyflex_id,
6646         v_entry_rec.entry_type,
6647         v_entry_rec.processing_type,
6648         v_entry_rec.creator_type,
6649         v_entry_rec.creator_id,
6650         v_entry_rec.assignment_id,
6651         v_entry_rec.input_currency_code,
6652         v_entry_rec.output_currency_code,
6653         v_validation_start_date,
6654         v_validation_end_date,
6655         p_session_date,
6656         v_dt_update_mode,
6657         p_num_entry_values,
6658         p_input_value_id_tbl,
6659         p_entry_value_tbl);
6660 --
6661      -- Go through list of accepted pay proposals for the assignment /
6662      -- element entry to see if any of the pay proosals have lost the element
6663      -- entry they had (the existence of an element entry signifies an accepted
6664      -- pay proposal) ie. crerator type changed, removed etc... Any accepted
6665      -- pay proposals that have lost their element entry should be removed.
6666      loop
6667 --
6668        fetch csr_accepted_pay_proposals into v_pay_proposal_id;
6669        exit when csr_accepted_pay_proposals%notfound;
6670 
6671 --- bug 9648525 remove proposal components as well as proposal
6672        delete from per_pay_proposal_components ppc
6673               where  ppc.pay_proposal_id in
6674        ( select pp.pay_proposal_id from per_pay_proposals pp
6675        where  pp.pay_proposal_id = v_pay_proposal_id
6676          and  not exists
6677               (select null
6678                from   pay_element_entries_f ee
6679                where  ee.element_entry_id = p_element_entry_id
6680                  and  ee.creator_type = 'SP'
6681                  and  ee.creator_id = pp.pay_proposal_id
6682                  and  ee.effective_start_date = pp.change_date));
6683 --
6684        delete from per_pay_proposals pp
6685        where  pp.pay_proposal_id = v_pay_proposal_id
6686          and  not exists
6687               (select null
6688                from   pay_element_entries_f ee
6689                where  ee.element_entry_id = p_element_entry_id
6690                  and  ee.creator_type = 'SP'
6691                  and  ee.creator_id = pp.pay_proposal_id
6692                  and  ee.effective_start_date = pp.change_date);
6693 --
6694      end loop;
6695 --
6696    end if;
6697    --
6698    -- bug 666197, retrieve object version number; call to the user hook procedure
6699    --
6700    open csr_object_version_number(p_element_entry_id, p_session_date);
6701    fetch csr_object_version_number into l_object_version_number, l_effective_start_date,
6702                                                                  l_effective_end_date;
6703    close csr_object_version_number;
6704    --
6705    begin
6706    --
6707    -- Bugfix 2993625
6708    -- Pass actual values to the after update hook instead of the defaulted
6709    -- values, i.e. pass null instead of hr_api.g_number, etc.
6710    -- This is to avoid unnecessary rows being created in PAY_PROCESS_EVENTS
6711    -- during the continuous calc process.
6712    --
6713    pay_ele_rku.after_update
6714    -- p_validation_start/end_date are not supported until the proper API implementation
6715      (
6716        p_effective_date                 => p_session_date
6717       ,p_validation_start_date          => v_validation_start_date
6718       ,p_validation_end_date            => v_validation_end_date
6719       ,p_datetrack_mode                 => v_dt_update_mode             --6144913
6720       -- new values set
6721       ,p_element_entry_id               => p_element_entry_id
6722       ,p_effective_start_date           => l_effective_start_date
6723       ,p_effective_end_date             => l_effective_end_date
6724       ,p_original_entry_id              => v_entry_rec.original_entry_id
6725       ,p_creator_type                   => v_entry_rec.creator_type
6726       ,p_cost_allocation_keyflex_id   => v_entry_rec.cost_allocation_keyflex_id
6727       -- Needed for row handler
6728       ,p_target_entry_id                => null
6729       ,p_source_id                      => null
6730       ,p_balance_adj_cost_flag          => null
6731       ,p_entry_type                     => null
6732       --
6733       ,p_updating_action_id             => v_entry_rec.updating_action_id
6734       ,p_updating_action_type           => v_entry_rec.updating_action_type
6735       ,p_comment_id                     => v_entry_rec.comment_id
6736       ,p_creator_id                     => v_entry_rec.creator_id
6737       ,p_reason                         => v_entry_rec.reason
6738       ,p_subpriority                    => v_entry_rec.subpriority
6739       ,p_date_earned                    => v_entry_rec.date_earned
6740       ,p_personal_payment_method_id   => v_entry_rec.personal_payment_method_id
6741       ,p_attribute_category             => v_entry_rec.attribute_category
6742       ,p_attribute1                     => v_entry_rec.attribute1
6743       ,p_attribute2                     => v_entry_rec.attribute2
6744       ,p_attribute3                     => v_entry_rec.attribute3
6745       ,p_attribute4                     => v_entry_rec.attribute4
6746       ,p_attribute5                     => v_entry_rec.attribute5
6747       ,p_attribute6                     => v_entry_rec.attribute6
6748       ,p_attribute7                     => v_entry_rec.attribute7
6749       ,p_attribute8                     => v_entry_rec.attribute8
6750       ,p_attribute9                     => v_entry_rec.attribute9
6751       ,p_attribute10                    => v_entry_rec.attribute10
6752       ,p_attribute11                    => v_entry_rec.attribute11
6753       ,p_attribute12                    => v_entry_rec.attribute12
6754       ,p_attribute13                    => v_entry_rec.attribute13
6755       ,p_attribute14                    => v_entry_rec.attribute14
6756       ,p_attribute15                    => v_entry_rec.attribute15
6757       ,p_attribute16                    => v_entry_rec.attribute16
6758       ,p_attribute17                    => v_entry_rec.attribute17
6759       ,p_attribute18                    => v_entry_rec.attribute18
6760       ,p_attribute19                    => v_entry_rec.attribute19
6761       ,p_attribute20                    => v_entry_rec.attribute20
6762       ,p_entry_information_category   => v_entry_rec.entry_information_category
6763       ,p_entry_information1             => v_entry_rec.entry_information1
6764       ,p_entry_information2             => v_entry_rec.entry_information2
6765       ,p_entry_information3             => v_entry_rec.entry_information3
6766       ,p_entry_information4             => v_entry_rec.entry_information4
6767       ,p_entry_information5             => v_entry_rec.entry_information5
6768       ,p_entry_information6             => v_entry_rec.entry_information6
6769       ,p_entry_information7             => v_entry_rec.entry_information7
6770       ,p_entry_information8             => v_entry_rec.entry_information8
6771       ,p_entry_information9             => v_entry_rec.entry_information9
6772       ,p_entry_information10            => v_entry_rec.entry_information10
6773       ,p_entry_information11            => v_entry_rec.entry_information11
6774       ,p_entry_information12            => v_entry_rec.entry_information12
6775       ,p_entry_information13            => v_entry_rec.entry_information13
6776       ,p_entry_information14            => v_entry_rec.entry_information14
6777       ,p_entry_information15            => v_entry_rec.entry_information15
6778       ,p_entry_information16            => v_entry_rec.entry_information16
6779       ,p_entry_information17            => v_entry_rec.entry_information17
6780       ,p_entry_information18            => v_entry_rec.entry_information18
6781       ,p_entry_information19            => v_entry_rec.entry_information19
6782       ,p_entry_information20            => v_entry_rec.entry_information20
6783       ,p_entry_information21            => v_entry_rec.entry_information21
6784       ,p_entry_information22            => v_entry_rec.entry_information22
6785       ,p_entry_information23            => v_entry_rec.entry_information23
6786       ,p_entry_information24            => v_entry_rec.entry_information24
6787       ,p_entry_information25            => v_entry_rec.entry_information25
6788       ,p_entry_information26            => v_entry_rec.entry_information26
6789       ,p_entry_information27            => v_entry_rec.entry_information27
6790       ,p_entry_information28            => v_entry_rec.entry_information28
6791       ,p_entry_information29            => v_entry_rec.entry_information29
6792       ,p_entry_information30            => v_entry_rec.entry_information30
6793       ,p_object_version_number          => l_object_version_number
6794       ,p_comments                       => null
6795       ,p_all_entry_values_null          => l_all_entry_values_null
6796       -- old values set
6797       ,p_effective_start_date_o         => l_effective_start_date_o
6798       ,p_effective_end_date_o           => l_effective_end_date_o
6799       ,p_cost_allocation_keyflex_id_o   => l_cost_allocation_keyflex_id_o
6800       ,p_assignment_id_o                => l_assignment_id_o
6801       ,p_updating_action_id_o         => l_updating_action_id_o
6802       ,p_updating_action_type_o         => l_updating_action_type_o
6803       ,p_element_link_id_o              => l_element_link_id_o
6804       ,p_original_entry_id_o            => l_original_entry_id_o
6805       ,p_creator_type_o                 => l_creator_type_o
6806       ,p_entry_type_o                   => l_entry_type_o
6807       ,p_comment_id_o                   => l_comment_id_o
6808       ,p_creator_id_o                   => l_creator_id_o
6809       ,p_reason_o                       => l_reason_o
6810       ,p_target_entry_id_o              => l_target_entry_id_o
6811       ,p_source_id_o                    => l_source_id_o
6812       ,p_attribute_category_o           => l_attribute_category_o
6813       ,p_attribute1_o                   => l_attribute1_o
6814       ,p_attribute2_o                   => l_attribute2_o
6815       ,p_attribute3_o                   => l_attribute3_o
6816       ,p_attribute4_o                   => l_attribute4_o
6817       ,p_attribute5_o                   => l_attribute5_o
6818       ,p_attribute6_o                   => l_attribute6_o
6819       ,p_attribute7_o                   => l_attribute7_o
6820       ,p_attribute8_o                   => l_attribute8_o
6821       ,p_attribute9_o                   => l_attribute9_o
6822       ,p_attribute10_o                  => l_attribute10_o
6823       ,p_attribute11_o                  => l_attribute11_o
6824       ,p_attribute12_o                  => l_attribute12_o
6825       ,p_attribute13_o                  => l_attribute13_o
6826       ,p_attribute14_o                  => l_attribute14_o
6827       ,p_attribute15_o                  => l_attribute15_o
6828       ,p_attribute16_o                  => l_attribute16_o
6829       ,p_attribute17_o                  => l_attribute17_o
6830       ,p_attribute18_o                  => l_attribute18_o
6831       ,p_attribute19_o                  => l_attribute19_o
6832       ,p_attribute20_o                  => l_attribute20_o
6833       ,p_entry_information_category_o   => l_entry_information_category_o
6834       ,p_entry_information1_o           => l_entry_information1_o
6835       ,p_entry_information2_o           => l_entry_information2_o
6836       ,p_entry_information3_o           => l_entry_information3_o
6837       ,p_entry_information4_o           => l_entry_information4_o
6838       ,p_entry_information5_o           => l_entry_information5_o
6839       ,p_entry_information6_o           => l_entry_information6_o
6840       ,p_entry_information7_o           => l_entry_information7_o
6841       ,p_entry_information8_o           => l_entry_information8_o
6842       ,p_entry_information9_o           => l_entry_information9_o
6843       ,p_entry_information10_o          => l_entry_information10_o
6844       ,p_entry_information11_o          => l_entry_information11_o
6845       ,p_entry_information12_o          => l_entry_information12_o
6846       ,p_entry_information13_o          => l_entry_information13_o
6847       ,p_entry_information14_o          => l_entry_information14_o
6848       ,p_entry_information15_o          => l_entry_information15_o
6849       ,p_entry_information16_o          => l_entry_information16_o
6850       ,p_entry_information17_o          => l_entry_information17_o
6851       ,p_entry_information18_o          => l_entry_information18_o
6852       ,p_entry_information19_o          => l_entry_information19_o
6853       ,p_entry_information20_o          => l_entry_information20_o
6854       ,p_entry_information21_o          => l_entry_information21_o
6855       ,p_entry_information22_o          => l_entry_information22_o
6856       ,p_entry_information23_o          => l_entry_information23_o
6857       ,p_entry_information24_o          => l_entry_information24_o
6858       ,p_entry_information25_o          => l_entry_information25_o
6859       ,p_entry_information26_o          => l_entry_information26_o
6860       ,p_entry_information27_o          => l_entry_information27_o
6861       ,p_entry_information28_o          => l_entry_information28_o
6862       ,p_entry_information29_o          => l_entry_information29_o
6863       ,p_entry_information30_o          => l_entry_information30_o
6864       ,p_subpriority_o                  => l_subpriority_o
6865       ,p_personal_payment_method_id_o   => l_personal_payment_method_id_o
6866       ,p_date_earned_o                  => l_date_earned_o
6867       ,p_object_version_number_o        => l_object_version_number_o
6868       ,p_balance_adj_cost_flag_o        => l_balance_adj_cost_flag_o
6869       ,p_comments_o                     => null
6870       ,p_element_type_id_o              => l_element_type_id_o
6871       ,p_all_entry_values_null_o        => l_all_entry_values_null_o
6872      );
6873      exception
6874        when hr_api.cannot_find_prog_unit then
6875          hr_api.cannot_find_prog_unit_error
6876                (p_module_name => 'PAY_ELEMENT_ENTRIES_F'
6877                ,p_hook_type   => 'AU'
6878                );
6879      end;
6880     --
6881 
6882   --
6883   -- 21-FEB-03
6884   -- -----------------
6885   -- As entry values has no hook, call the CC DYnamic Trigger PacKaGe directly
6886   -- I.e. instead of         API -> HOOK -> DYT_PKG -> CC_PKG
6887   -- we do             pseudoAPI ---------> DYT_PKG -> CC_PKG
6888   -- -----------------
6889   --loop through all new element entry vals for this element entry id
6890   --(usually just the one val)
6891   --
6892   -- Only make call if data has possibly changed, and => old vals are cached
6893   --
6894   if v_entry_being_changed then
6895 
6896     g_counter := 0;
6897 
6898     for new_vals in pay_ele_shd.csr_get_eevals(p_element_entry_id,p_session_date)  loop
6899       begin
6900         g_counter := g_counter + 1;
6901         --
6902       if g_debug then
6903         hr_utility.trace(' Hard call PAY_DYT_ELEMENT_ENTRY_VAL_PKG.after_update');
6904         hr_utility.trace(' Ele ent Val ID: '||new_vals.element_entry_value_id);
6905         hr_utility.trace(' New Screen Val: '||new_vals.screen_entry_value);
6906         hr_utility.trace(' Old Screen Val: '||l_old_val_tab(g_counter).screen_entry_value);
6907       end if;
6908 
6909         PAY_DYT_ELEMENT_ENTRY_VAL_PKG.after_update
6910         (
6911           P_EFFECTIVE_END_DATE          => new_vals.effective_end_date
6912          ,P_EFFECTIVE_START_DATE        => new_vals.effective_start_date
6913          ,P_ELEMENT_ENTRY_ID            => new_vals.element_entry_id
6914          ,P_ELEMENT_ENTRY_VALUE_ID      => new_vals.element_entry_value_id
6915          ,P_INPUT_VALUE_ID              => new_vals.input_value_id
6916          ,P_SCREEN_ENTRY_VALUE          => new_vals.screen_entry_value
6917          ,P_EFFECTIVE_END_DATE_O
6918            => l_old_val_tab(g_counter).effective_end_date
6919          ,P_EFFECTIVE_START_DATE_O
6920            => l_old_val_tab(g_counter).effective_start_date
6921          ,P_ELEMENT_ENTRY_ID_O
6922            => l_old_val_tab(g_counter).element_entry_id
6923          ,P_ELEMENT_ENTRY_VALUE_ID_O
6924            => l_old_val_tab(g_counter).element_entry_value_id
6925          ,P_INPUT_VALUE_ID_O
6926            => l_old_val_tab(g_counter).input_value_id
6927          ,P_SCREEN_ENTRY_VALUE_O
6928            => l_old_val_tab(g_counter).screen_entry_value
6929          ,p_datetrack_mode              => v_dt_update_mode       --6144913
6930        );
6931 
6932       end;
6933       --
6934     end loop;
6935   end if;
6936   hr_utility.set_location('Leaving: upd_element_entry', 900);
6937 
6938  end upd_element_entry;
6939 --
6940 
6941 
6942 
6943 
6944 
6945 
6946 
6947  ------------------------------------------------------------------------------
6948  -- NAME                                                                     --
6949  -- hr_entry_api.update_element_entry                                        --
6950  --                                                                          --
6951  -- DESCRIPTION                                                              --
6952  -- Cover routine for call to hr_entry_api.upd_element_entry that accepts    --
6953  -- entry values passed as a table. It converts the entry values to DB       --
6954  -- format. Any entry values that were not specified are copied from the     --
6955  -- element entry being updated.                                             --
6956  -- NB. all entry values specified are validated !                           --
6957  ------------------------------------------------------------------------------
6958 --
6959  procedure update_element_entry
6960  (
6961   --
6962   -- Update Mode
6963   --
6964   p_dt_update_mode             varchar2 default null,
6965   --
6966   -- Date on which change is taking place
6967   --
6968   p_session_date               date,
6969   --
6970   -- Check to see if the entry is being updated
6971   --
6972   p_check_for_update           varchar2  default 'N',
6973   --
6974   -- Element Entry Table
6975   --
6976   p_element_entry_id           number,
6977   p_cost_allocation_keyflex_id number    default hr_api.g_number,
6978   p_updating_action_id         number    default hr_api.g_number,
6979   p_updating_action_type       varchar2  default hr_api.g_varchar2,
6980   p_original_entry_id          number    default hr_api.g_number,
6981   p_creator_type               varchar2  default hr_api.g_varchar2,
6982   p_comment_id                 number    default hr_api.g_number,
6983   p_creator_id                 number    default hr_api.g_number,
6984   p_reason                     varchar2  default hr_api.g_varchar2,
6985   p_subpriority                number    default hr_api.g_number,
6986   p_date_earned                 date    default hr_api.g_date,
6987   p_personal_payment_method_id  number  default hr_api.g_number,
6988   p_attribute_category         varchar2  default hr_api.g_varchar2,
6989   p_attribute1                 varchar2  default hr_api.g_varchar2,
6990   p_attribute2                 varchar2  default hr_api.g_varchar2,
6991   p_attribute3                 varchar2  default hr_api.g_varchar2,
6992   p_attribute4                 varchar2  default hr_api.g_varchar2,
6993   p_attribute5                 varchar2  default hr_api.g_varchar2,
6994   p_attribute6                 varchar2  default hr_api.g_varchar2,
6995   p_attribute7                 varchar2  default hr_api.g_varchar2,
6996   p_attribute8                 varchar2  default hr_api.g_varchar2,
6997   p_attribute9                 varchar2  default hr_api.g_varchar2,
6998   p_attribute10                varchar2  default hr_api.g_varchar2,
6999   p_attribute11                varchar2  default hr_api.g_varchar2,
7000   p_attribute12                varchar2  default hr_api.g_varchar2,
7001   p_attribute13                varchar2  default hr_api.g_varchar2,
7002   p_attribute14                varchar2  default hr_api.g_varchar2,
7003   p_attribute15                varchar2  default hr_api.g_varchar2,
7004   p_attribute16                varchar2  default hr_api.g_varchar2,
7005   p_attribute17                varchar2  default hr_api.g_varchar2,
7006   p_attribute18                varchar2  default hr_api.g_varchar2,
7007   p_attribute19                varchar2  default hr_api.g_varchar2,
7008   p_attribute20                varchar2  default hr_api.g_varchar2,
7009   p_override_user_ent_chk      varchar2  default 'N',
7010   --
7011   -- Element Entry Values Table
7012   --
7013   p_num_entry_values           number,
7014   p_input_value_id_tbl         hr_entry.number_table,
7015   p_entry_value_tbl            hr_entry.varchar2_table
7016  ) is
7017 --
7018    -- Local Variables
7019    v_num_entry_values   number;
7020    v_input_value_id_tbl hr_entry.number_table;
7021    v_entry_value_tbl    hr_entry.varchar2_table;
7022    l_entry_type         VARCHAR2(1);
7023    v_assignment_id      number;
7024    --
7025    -- Local Cursors
7026    --
7027    --
7028    -- bug 546670
7029    --
7030    CURSOR csr_entry_type(p_element_entry_id NUMBER,
7031                          p_effective_date   DATE)
7032    IS
7033      SELECT pee.entry_type,
7034             pee.assignment_id
7035      FROM   PAY_ELEMENT_ENTRIES_F pee
7036      WHERE  pee.element_entry_id = p_element_entry_id
7037      and    p_effective_date BETWEEN
7038                 pee.effective_start_date and pee.effective_end_date
7039      ;
7040 --
7041  begin
7042    g_debug := hr_utility.debug_enabled;
7043 --
7044    g_override_user_ent_chk := p_override_user_ent_chk;
7045    v_num_entry_values   := p_num_entry_values;
7046    v_input_value_id_tbl := p_input_value_id_tbl;
7047    v_entry_value_tbl    := p_entry_value_tbl;
7048 --
7049    OPEN  csr_entry_type(p_element_entry_id, p_session_date);
7050    FETCH csr_entry_type INTO l_entry_type, v_assignment_id;
7051    CLOSE csr_entry_type;
7052    --
7053    -- Call code to set up values that may be used in
7054    -- Formula validation of Input Values.
7055    --
7056    set_formula_contexts (v_assignment_id, p_session_date);
7057 --
7058    hr_entry_api.conv_table_to_table
7059      ('SCREEN',
7060       p_session_date,
7061       p_element_entry_id,
7062       null,
7063       v_num_entry_values,
7064       p_creator_type,
7065       l_entry_type,
7066       v_input_value_id_tbl,
7067       v_entry_value_tbl);
7068 --
7069    hr_entry_api.upd_element_entry
7070      (p_dt_update_mode,
7071       p_session_date,
7072       p_check_for_update,
7073       p_element_entry_id,
7074       p_cost_allocation_keyflex_id,
7075       p_updating_action_id,
7076       p_updating_action_type,
7077       p_original_entry_id,
7078       p_creator_type,
7079       p_comment_id,
7080       p_creator_id,
7081       p_reason,
7082       p_subpriority,
7083       p_date_earned,
7084       p_personal_payment_method_id,
7085       p_attribute_category,
7086       p_attribute1,
7087       p_attribute2,
7088       p_attribute3,
7089       p_attribute4,
7090       p_attribute5,
7091       p_attribute6,
7092       p_attribute7,
7093       p_attribute8,
7094       p_attribute9,
7095       p_attribute10,
7096       p_attribute11,
7097       p_attribute12,
7098       p_attribute13,
7099       p_attribute14,
7100       p_attribute15,
7101       p_attribute16,
7102       p_attribute17,
7103       p_attribute18,
7104       p_attribute19,
7105       p_attribute20,
7106       v_num_entry_values,
7107       v_input_value_id_tbl,
7108       v_entry_value_tbl,
7109 -- --
7110     --
7111     -- J.Bailie 08-NOV-99 31 nulls passed to ins_element_entry
7112     --
7113       null,
7114       null,
7115       null,
7116       null,
7117       null,
7118       null,
7119       null,
7120       null,
7121       null,
7122       null,
7123       null,
7124       null,
7125       null,
7126       null,
7127       null,
7128       null,
7129       null,
7130       null,
7131       null,
7132       null,
7133       null,
7134       null,
7135       null,
7136       null,
7137       null,
7138       null,
7139       null,
7140       null,
7141       null,
7142       null,
7143       null
7144 );
7145 --
7146  end update_element_entry;
7147 --
7148  ------------------------------------------------------------------------------
7149  -- NAME                                                                     --
7150  -- hr_entry_api.update_element_entry                                        --
7151  --                                                                          --
7152  -- DESCRIPTION                                                              --
7153  -- Cover routine for call to hr_entry_api.upd_element_entry that accepts    --
7154  -- entry values passed as parameters. It converts the entry values to DB    --
7155  -- format. Any entry values that were not specified are copied from the     --
7156  -- element entry being updated.                                             --
7157  -- NB. all entry values specified are validated !                           --
7158  ------------------------------------------------------------------------------
7159 --
7160  procedure update_element_entry
7161  (
7162   --
7163   -- Update Mode
7164   --
7165   p_dt_update_mode             varchar2 default null,
7166   --
7167   -- Date on which change is taking place
7168   --
7169   p_session_date               date,
7170   --
7171   -- Check to see if the entry is being updated
7172   --
7173   p_check_for_update           varchar2  default 'N',
7174   --
7175   -- Element Entry Table
7176   --
7177   p_element_entry_id           number,
7178   p_cost_allocation_keyflex_id number    default hr_api.g_number,
7179   p_updating_action_id         number    default hr_api.g_number,
7180   p_updating_action_type       varchar2  default hr_api.g_varchar2,
7181   p_original_entry_id          number    default hr_api.g_number,
7182   p_creator_type               varchar2  default hr_api.g_varchar2,
7183   p_comment_id                 number    default hr_api.g_number,
7184   p_creator_id                 number    default hr_api.g_number,
7185   p_reason                     varchar2  default hr_api.g_varchar2,
7186   p_subpriority                number    default hr_api.g_number,
7187   p_date_earned                date      default hr_api.g_date,
7188   p_personal_payment_method_id number    default hr_api.g_number,
7189   p_attribute_category         varchar2  default hr_api.g_varchar2,
7190   p_attribute1                 varchar2  default hr_api.g_varchar2,
7191   p_attribute2                 varchar2  default hr_api.g_varchar2,
7192   p_attribute3                 varchar2  default hr_api.g_varchar2,
7193   p_attribute4                 varchar2  default hr_api.g_varchar2,
7194   p_attribute5                 varchar2  default hr_api.g_varchar2,
7195   p_attribute6                 varchar2  default hr_api.g_varchar2,
7196   p_attribute7                 varchar2  default hr_api.g_varchar2,
7197   p_attribute8                 varchar2  default hr_api.g_varchar2,
7198   p_attribute9                 varchar2  default hr_api.g_varchar2,
7199   p_attribute10                varchar2  default hr_api.g_varchar2,
7200   p_attribute11                varchar2  default hr_api.g_varchar2,
7201   p_attribute12                varchar2  default hr_api.g_varchar2,
7202   p_attribute13                varchar2  default hr_api.g_varchar2,
7203   p_attribute14                varchar2  default hr_api.g_varchar2,
7204   p_attribute15                varchar2  default hr_api.g_varchar2,
7205   p_attribute16                varchar2  default hr_api.g_varchar2,
7206   p_attribute17                varchar2  default hr_api.g_varchar2,
7207   p_attribute18                varchar2  default hr_api.g_varchar2,
7208   p_attribute19                varchar2  default hr_api.g_varchar2,
7209   p_attribute20                varchar2  default hr_api.g_varchar2,
7210   --
7211   -- Element Entry Values Table
7212   --
7213   p_input_value_id1            number   default null,
7214   p_input_value_id2            number   default null,
7215   p_input_value_id3            number   default null,
7216   p_input_value_id4            number   default null,
7217   p_input_value_id5            number   default null,
7218   p_input_value_id6            number   default null,
7219   p_input_value_id7            number   default null,
7220   p_input_value_id8            number   default null,
7221   p_input_value_id9            number   default null,
7222   p_input_value_id10           number   default null,
7223   p_input_value_id11           number   default null,
7224   p_input_value_id12           number   default null,
7225   p_input_value_id13           number   default null,
7226   p_input_value_id14           number   default null,
7227   p_input_value_id15           number   default null,
7228   p_entry_value1               varchar2 default null,
7229   p_entry_value2               varchar2 default null,
7230   p_entry_value3               varchar2 default null,
7231   p_entry_value4               varchar2 default null,
7232   p_entry_value5               varchar2 default null,
7233   p_entry_value6               varchar2 default null,
7234   p_entry_value7               varchar2 default null,
7235   p_entry_value8               varchar2 default null,
7236   p_entry_value9               varchar2 default null,
7237   p_entry_value10              varchar2 default null,
7238   p_entry_value11              varchar2 default null,
7239   p_entry_value12              varchar2 default null,
7240   p_entry_value13              varchar2 default null,
7241   p_entry_value14              varchar2 default null,
7242   p_entry_value15              varchar2 default null,
7243   p_override_user_ent_chk      varchar2  default 'N'
7244  ) is
7245 --
7246    -- Local Variables
7247    v_num_entry_values   number;
7248    v_input_value_id_tbl hr_entry.number_table;
7249    v_entry_value_tbl    hr_entry.varchar2_table;
7250    l_entry_type         VARCHAR2(1);
7251    v_assignment_id      number;
7252    --
7253    -- Local Cursors
7254    --
7255    --
7256    -- bug 546670
7257    --
7258    CURSOR csr_entry_type(p_element_entry_id NUMBER,
7259                          p_effective_date   DATE)
7260    IS
7261      SELECT pee.entry_type,
7262             pee.assignment_id
7263      FROM   PAY_ELEMENT_ENTRIES_F pee
7264      WHERE  pee.element_entry_id = p_element_entry_id
7265      and    p_effective_date BETWEEN
7266                 pee.effective_start_date and pee.effective_end_date
7267      ;
7268 --
7269  begin
7270    g_debug := hr_utility.debug_enabled;
7271 --
7272    OPEN  csr_entry_type(p_element_entry_id, p_session_date);
7273    FETCH csr_entry_type INTO l_entry_type, v_assignment_id;
7274    CLOSE csr_entry_type;
7275    g_override_user_ent_chk := p_override_user_ent_chk;
7276    --
7277    -- Call code to set up values that may be used in
7278    -- Formula validation of Input Values.
7279    --
7280    set_formula_contexts (v_assignment_id, p_session_date);
7281    --
7282    -- Convert entry value details ie. INPUT_VALUE_ID and SCREEN_ENTRY_VALUE
7283    -- into two tables to be passed into the overloaded version of
7284    -- update_element_entry. The overloaded version is capable of handling
7285    -- unlimited numbers of entry values.
7286    hr_entry_api.conv_entry_values_to_table
7287      ('SCREEN',
7288       p_element_entry_id,
7289       null,
7290       p_session_date,
7291       p_creator_type,
7292       l_entry_type,
7293       p_input_value_id1,
7294       p_input_value_id2,
7295       p_input_value_id3,
7296       p_input_value_id4,
7297       p_input_value_id5,
7298       p_input_value_id6,
7299       p_input_value_id7,
7300       p_input_value_id8,
7301       p_input_value_id9,
7302       p_input_value_id10,
7303       p_input_value_id11,
7304       p_input_value_id12,
7305       p_input_value_id13,
7306       p_input_value_id14,
7307       p_input_value_id15,
7308       p_entry_value1,
7309       p_entry_value2,
7310       p_entry_value3,
7311       p_entry_value4,
7312       p_entry_value5,
7313       p_entry_value6,
7314       p_entry_value7,
7315       p_entry_value8,
7316       p_entry_value9,
7317       p_entry_value10,
7318       p_entry_value11,
7319       p_entry_value12,
7320       p_entry_value13,
7321       p_entry_value14,
7322       p_entry_value15,
7323       v_num_entry_values,
7324       v_input_value_id_tbl,
7325       v_entry_value_tbl);
7326 --
7327    hr_entry_api.upd_element_entry
7328      (p_dt_update_mode,
7329       p_session_date,
7330       p_check_for_update,
7331       p_element_entry_id,
7332       p_cost_allocation_keyflex_id,
7333       p_updating_action_id,
7334       p_updating_action_type,
7335       p_original_entry_id,
7336       p_creator_type,
7337       p_comment_id,
7338       p_creator_id,
7339       p_reason,
7340       p_subpriority,
7341       p_date_earned,
7342       p_personal_payment_method_id,
7343       p_attribute_category,
7344       p_attribute1,
7345       p_attribute2,
7346       p_attribute3,
7347       p_attribute4,
7348       p_attribute5,
7349       p_attribute6,
7350       p_attribute7,
7351       p_attribute8,
7352       p_attribute9,
7353       p_attribute10,
7354       p_attribute11,
7355       p_attribute12,
7356       p_attribute13,
7357       p_attribute14,
7358       p_attribute15,
7359       p_attribute16,
7360       p_attribute17,
7361       p_attribute18,
7362       p_attribute19,
7363       p_attribute20,
7364       v_num_entry_values,
7365       v_input_value_id_tbl,
7366       v_entry_value_tbl,
7367 -- --
7368     --
7369     -- J.Bailie 08-NOV-99 31 nulls passed to ins_element_entry
7370     --
7371       null,
7372       null,
7373       null,
7374       null,
7375       null,
7376       null,
7377       null,
7378       null,
7379       null,
7380       null,
7381       null,
7382       null,
7383       null,
7384       null,
7385       null,
7386       null,
7387       null,
7388       null,
7389       null,
7390       null,
7391       null,
7392       null,
7393       null,
7394       null,
7395       null,
7396       null,
7397       null,
7398       null,
7399       null,
7400       null,
7401       null
7402 );
7403 --
7404  end update_element_entry;
7405 --
7406 -- --
7407 --
7408  ------------------------------------------------------------------------------
7409  -- NAME                                                                     --
7410  -- hr_entry_api.update_element_entry                                        --
7411  --                                                                          --
7412  -- DESCRIPTION                                                              --
7413  -- Cover routine for call to hr_entry_api.upd_element_entry that accepts    --
7414  -- entry values passed as a table. It converts the entry values to DB       --
7415  -- format. Any entry values that were not specified are copied from the     --
7416  -- element entry being updated.                                             --
7417  -- NB. all entry values specified are validated !                           --
7418  ------------------------------------------------------------------------------
7419 --
7420  procedure update_element_entry
7421  (
7422   --
7423   -- Update Mode
7424   --
7425   p_dt_update_mode             varchar2 default null,
7426   --
7427   -- Date on which change is taking place
7428   --
7429   p_session_date               date,
7430   --
7431   -- Check to see if the entry is being updated
7432   --
7433   p_check_for_update           varchar2  default 'N',
7434   --
7435   -- Element Entry Table
7436   --
7437   p_element_entry_id           number,
7438   p_cost_allocation_keyflex_id number    default hr_api.g_number,
7439   p_updating_action_id         number    default hr_api.g_number,
7440   p_updating_action_type       varchar2  default hr_api.g_varchar2,
7441   p_original_entry_id          number    default hr_api.g_number,
7442   p_creator_type               varchar2  default hr_api.g_varchar2,
7443   p_comment_id                 number    default hr_api.g_number,
7444   p_creator_id                 number    default hr_api.g_number,
7445   p_reason                     varchar2  default hr_api.g_varchar2,
7446   p_subpriority                number    default hr_api.g_number,
7447   p_date_earned                 date    default hr_api.g_date,
7448   p_personal_payment_method_id  number  default hr_api.g_number,
7449   p_attribute_category         varchar2  default hr_api.g_varchar2,
7450   p_attribute1                 varchar2  default hr_api.g_varchar2,
7451   p_attribute2                 varchar2  default hr_api.g_varchar2,
7452   p_attribute3                 varchar2  default hr_api.g_varchar2,
7453   p_attribute4                 varchar2  default hr_api.g_varchar2,
7454   p_attribute5                 varchar2  default hr_api.g_varchar2,
7455   p_attribute6                 varchar2  default hr_api.g_varchar2,
7456   p_attribute7                 varchar2  default hr_api.g_varchar2,
7457   p_attribute8                 varchar2  default hr_api.g_varchar2,
7458   p_attribute9                 varchar2  default hr_api.g_varchar2,
7459   p_attribute10                varchar2  default hr_api.g_varchar2,
7460   p_attribute11                varchar2  default hr_api.g_varchar2,
7461   p_attribute12                varchar2  default hr_api.g_varchar2,
7462   p_attribute13                varchar2  default hr_api.g_varchar2,
7463   p_attribute14                varchar2  default hr_api.g_varchar2,
7464   p_attribute15                varchar2  default hr_api.g_varchar2,
7465   p_attribute16                varchar2  default hr_api.g_varchar2,
7466   p_attribute17                varchar2  default hr_api.g_varchar2,
7467   p_attribute18                varchar2  default hr_api.g_varchar2,
7468   p_attribute19                varchar2  default hr_api.g_varchar2,
7469   p_attribute20                varchar2  default hr_api.g_varchar2,
7470   --
7471   -- Element Entry Values Table
7472   --
7473   p_num_entry_values           number,
7474   p_input_value_id_tbl         hr_entry.number_table,
7475   p_entry_value_tbl            hr_entry.varchar2_table,
7476   p_entry_information_category varchar2  ,
7477   p_entry_information1         varchar2  default hr_api.g_varchar2,
7478   p_entry_information2         varchar2  default hr_api.g_varchar2,
7479   p_entry_information3         varchar2  default hr_api.g_varchar2,
7480   p_entry_information4         varchar2  default hr_api.g_varchar2,
7481   p_entry_information5         varchar2  default hr_api.g_varchar2,
7482   p_entry_information6         varchar2  default hr_api.g_varchar2,
7483   p_entry_information7         varchar2  default hr_api.g_varchar2,
7484   p_entry_information8         varchar2  default hr_api.g_varchar2,
7485   p_entry_information9         varchar2  default hr_api.g_varchar2,
7486   p_entry_information10        varchar2  default hr_api.g_varchar2,
7487   p_entry_information11        varchar2  default hr_api.g_varchar2,
7488   p_entry_information12        varchar2  default hr_api.g_varchar2,
7489   p_entry_information13        varchar2  default hr_api.g_varchar2,
7490   p_entry_information14        varchar2  default hr_api.g_varchar2,
7491   p_entry_information15        varchar2  default hr_api.g_varchar2,
7492   p_entry_information16        varchar2  default hr_api.g_varchar2,
7493   p_entry_information17        varchar2  default hr_api.g_varchar2,
7494   p_entry_information18        varchar2  default hr_api.g_varchar2,
7495   p_entry_information19        varchar2  default hr_api.g_varchar2,
7496   p_entry_information20        varchar2  default hr_api.g_varchar2,
7497   p_entry_information21        varchar2  default hr_api.g_varchar2,
7498   p_entry_information22        varchar2  default hr_api.g_varchar2,
7499   p_entry_information23        varchar2  default hr_api.g_varchar2,
7500   p_entry_information24        varchar2  default hr_api.g_varchar2,
7501   p_entry_information25        varchar2  default hr_api.g_varchar2,
7502   p_entry_information26        varchar2  default hr_api.g_varchar2,
7503   p_entry_information27        varchar2  default hr_api.g_varchar2,
7504   p_entry_information28        varchar2  default hr_api.g_varchar2,
7505   p_entry_information29        varchar2  default hr_api.g_varchar2,
7506   p_entry_information30        varchar2  default hr_api.g_varchar2,
7507   p_override_user_ent_chk      varchar2  default 'N'
7508  ) is
7509 --
7510    -- Local Variables
7511    v_num_entry_values   number;
7512    v_input_value_id_tbl hr_entry.number_table;
7513    v_entry_value_tbl    hr_entry.varchar2_table;
7514    l_entry_type         VARCHAR2(1);
7515    v_assignment_id      number;
7516    --
7517    -- Local Cursors
7518    --
7519    --
7520    -- bug 546670
7521    --
7522    CURSOR csr_entry_type(p_element_entry_id NUMBER,
7523                          p_effective_date   DATE)
7524    IS
7525      SELECT pee.entry_type,
7526             pee.assignment_id
7527      FROM   PAY_ELEMENT_ENTRIES_F pee
7528      WHERE  pee.element_entry_id = p_element_entry_id
7529      and    p_effective_date BETWEEN
7530                 pee.effective_start_date and pee.effective_end_date
7531      ;
7532 --
7533  begin
7534    g_debug := hr_utility.debug_enabled;
7535 --
7536    g_override_user_ent_chk := p_override_user_ent_chk;
7537    v_num_entry_values   := p_num_entry_values;
7538    v_input_value_id_tbl := p_input_value_id_tbl;
7539    v_entry_value_tbl    := p_entry_value_tbl;
7540 --
7541    OPEN  csr_entry_type(p_element_entry_id, p_session_date);
7542    FETCH csr_entry_type INTO l_entry_type, v_assignment_id;
7543    CLOSE csr_entry_type;
7544    --
7545    -- Call code to set up values that may be used in
7546    -- Formula validation of Input Values.
7547    --
7548    set_formula_contexts (v_assignment_id, p_session_date);
7549 --
7550    hr_entry_api.conv_table_to_table
7551      ('SCREEN',
7552       p_session_date,
7553       p_element_entry_id,
7554       null,
7555       v_num_entry_values,
7556       p_creator_type,
7557       l_entry_type,
7558       v_input_value_id_tbl,
7559       v_entry_value_tbl);
7560 --
7561    hr_entry_api.upd_element_entry
7562      (p_dt_update_mode,
7563       p_session_date,
7564       p_check_for_update,
7565       p_element_entry_id,
7566       p_cost_allocation_keyflex_id,
7567       p_updating_action_id,
7568       p_updating_action_type,
7569       p_original_entry_id,
7570       p_creator_type,
7571       p_comment_id,
7572       p_creator_id,
7573       p_reason,
7574       p_subpriority,
7575       p_date_earned,
7576       p_personal_payment_method_id,
7577       p_attribute_category,
7578       p_attribute1,
7579       p_attribute2,
7580       p_attribute3,
7581       p_attribute4,
7582       p_attribute5,
7583       p_attribute6,
7584       p_attribute7,
7585       p_attribute8,
7586       p_attribute9,
7587       p_attribute10,
7588       p_attribute11,
7589       p_attribute12,
7590       p_attribute13,
7591       p_attribute14,
7592       p_attribute15,
7593       p_attribute16,
7594       p_attribute17,
7595       p_attribute18,
7596       p_attribute19,
7597       p_attribute20,
7598       v_num_entry_values,
7599       v_input_value_id_tbl,
7600       v_entry_value_tbl,
7601   --
7602   -- J.Bailie 08-NOV-99 Element Entries DDF
7603   --
7604     p_entry_information_category,
7605     p_entry_information1,
7606     p_entry_information2,
7607     p_entry_information3,
7608     p_entry_information4,
7609     p_entry_information5,
7610     p_entry_information6,
7611     p_entry_information7,
7612     p_entry_information8,
7613     p_entry_information9,
7614     p_entry_information10,
7615     p_entry_information11,
7616     p_entry_information12,
7617     p_entry_information13,
7618     p_entry_information14,
7619     p_entry_information15,
7620     p_entry_information16,
7621     p_entry_information17,
7622     p_entry_information18,
7623     p_entry_information19,
7624     p_entry_information20,
7625     p_entry_information21,
7626     p_entry_information22,
7627     p_entry_information23,
7628     p_entry_information24,
7629     p_entry_information25,
7630     p_entry_information26,
7631     p_entry_information27,
7632     p_entry_information28,
7633     p_entry_information29,
7634     p_entry_information30
7635    );
7636 --
7637  end update_element_entry;
7638 --
7639 -- --
7640 --
7641  ------------------------------------------------------------------------------
7642  -- NAME                                                                     --
7643  -- hr_entry_api.update_element_entry                                        --
7644  --                                                                          --
7645  -- DESCRIPTION                                                              --
7646  -- Cover routine for call to hr_entry_api.upd_element_entry that accepts    --
7647  -- entry values passed as parameters. It converts the entry values to DB    --
7648  -- format. Any entry values that were not specified are copied from the     --
7649  -- element entry being updated.                                             --
7650  -- NB. all entry values specified are validated !                           --
7651  ------------------------------------------------------------------------------
7652 --
7653  procedure update_element_entry
7654  (
7655   --
7656   -- Update Mode
7657   --
7658   p_dt_update_mode             varchar2 default null,
7659   --
7660   -- Date on which change is taking place
7661   --
7662   p_session_date               date,
7663   --
7664   -- Check to see if the entry is being updated
7665   --
7666   p_check_for_update           varchar2  default 'N',
7667   --
7668   -- Element Entry Table
7669   --
7670   p_element_entry_id           number,
7671   p_cost_allocation_keyflex_id number    default hr_api.g_number,
7672   p_updating_action_id         number    default hr_api.g_number,
7673   p_updating_action_type       varchar2  default hr_api.g_varchar2,
7674   p_original_entry_id          number    default hr_api.g_number,
7675   p_creator_type               varchar2  default hr_api.g_varchar2,
7676   p_comment_id                 number    default hr_api.g_number,
7677   p_creator_id                 number    default hr_api.g_number,
7678   p_reason                     varchar2  default hr_api.g_varchar2,
7679   p_subpriority                number    default hr_api.g_number,
7680   p_date_earned                date      default hr_api.g_date,
7681   p_personal_payment_method_id number    default hr_api.g_number,
7682   p_attribute_category         varchar2  default hr_api.g_varchar2,
7683   p_attribute1                 varchar2  default hr_api.g_varchar2,
7684   p_attribute2                 varchar2  default hr_api.g_varchar2,
7685   p_attribute3                 varchar2  default hr_api.g_varchar2,
7686   p_attribute4                 varchar2  default hr_api.g_varchar2,
7687   p_attribute5                 varchar2  default hr_api.g_varchar2,
7688   p_attribute6                 varchar2  default hr_api.g_varchar2,
7689   p_attribute7                 varchar2  default hr_api.g_varchar2,
7690   p_attribute8                 varchar2  default hr_api.g_varchar2,
7691   p_attribute9                 varchar2  default hr_api.g_varchar2,
7692   p_attribute10                varchar2  default hr_api.g_varchar2,
7693   p_attribute11                varchar2  default hr_api.g_varchar2,
7694   p_attribute12                varchar2  default hr_api.g_varchar2,
7695   p_attribute13                varchar2  default hr_api.g_varchar2,
7696   p_attribute14                varchar2  default hr_api.g_varchar2,
7697   p_attribute15                varchar2  default hr_api.g_varchar2,
7698   p_attribute16                varchar2  default hr_api.g_varchar2,
7699   p_attribute17                varchar2  default hr_api.g_varchar2,
7700   p_attribute18                varchar2  default hr_api.g_varchar2,
7701   p_attribute19                varchar2  default hr_api.g_varchar2,
7702   p_attribute20                varchar2  default hr_api.g_varchar2,
7703   --
7704   -- Element Entry Values Table
7705   --
7706   p_input_value_id1            number   default null,
7707   p_input_value_id2            number   default null,
7708   p_input_value_id3            number   default null,
7709   p_input_value_id4            number   default null,
7710   p_input_value_id5            number   default null,
7711   p_input_value_id6            number   default null,
7712   p_input_value_id7            number   default null,
7713   p_input_value_id8            number   default null,
7714   p_input_value_id9            number   default null,
7715   p_input_value_id10           number   default null,
7716   p_input_value_id11           number   default null,
7717   p_input_value_id12           number   default null,
7718   p_input_value_id13           number   default null,
7719   p_input_value_id14           number   default null,
7720   p_input_value_id15           number   default null,
7721   p_entry_value1               varchar2 default null,
7722   p_entry_value2               varchar2 default null,
7723   p_entry_value3               varchar2 default null,
7724   p_entry_value4               varchar2 default null,
7725   p_entry_value5               varchar2 default null,
7726   p_entry_value6               varchar2 default null,
7727   p_entry_value7               varchar2 default null,
7728   p_entry_value8               varchar2 default null,
7729   p_entry_value9               varchar2 default null,
7730   p_entry_value10              varchar2 default null,
7731   p_entry_value11              varchar2 default null,
7732   p_entry_value12              varchar2 default null,
7733   p_entry_value13              varchar2 default null,
7734   p_entry_value14              varchar2 default null,
7735   p_entry_value15              varchar2 default null,
7736   p_entry_information_category varchar2  ,
7737   p_entry_information1         varchar2  default hr_api.g_varchar2,
7738   p_entry_information2         varchar2  default hr_api.g_varchar2,
7739   p_entry_information3         varchar2  default hr_api.g_varchar2,
7740   p_entry_information4         varchar2  default hr_api.g_varchar2,
7741   p_entry_information5         varchar2  default hr_api.g_varchar2,
7742   p_entry_information6         varchar2  default hr_api.g_varchar2,
7743   p_entry_information7         varchar2  default hr_api.g_varchar2,
7744   p_entry_information8         varchar2  default hr_api.g_varchar2,
7745   p_entry_information9         varchar2  default hr_api.g_varchar2,
7746   p_entry_information10        varchar2  default hr_api.g_varchar2,
7747   p_entry_information11        varchar2  default hr_api.g_varchar2,
7748   p_entry_information12        varchar2  default hr_api.g_varchar2,
7749   p_entry_information13        varchar2  default hr_api.g_varchar2,
7750   p_entry_information14        varchar2  default hr_api.g_varchar2,
7751   p_entry_information15        varchar2  default hr_api.g_varchar2,
7752   p_entry_information16        varchar2  default hr_api.g_varchar2,
7753   p_entry_information17        varchar2  default hr_api.g_varchar2,
7754   p_entry_information18        varchar2  default hr_api.g_varchar2,
7755   p_entry_information19        varchar2  default hr_api.g_varchar2,
7756   p_entry_information20        varchar2  default hr_api.g_varchar2,
7757   p_entry_information21        varchar2  default hr_api.g_varchar2,
7758   p_entry_information22        varchar2  default hr_api.g_varchar2,
7759   p_entry_information23        varchar2  default hr_api.g_varchar2,
7760   p_entry_information24        varchar2  default hr_api.g_varchar2,
7761   p_entry_information25        varchar2  default hr_api.g_varchar2,
7762   p_entry_information26        varchar2  default hr_api.g_varchar2,
7763   p_entry_information27        varchar2  default hr_api.g_varchar2,
7764   p_entry_information28        varchar2  default hr_api.g_varchar2,
7765   p_entry_information29        varchar2  default hr_api.g_varchar2,
7766   p_entry_information30        varchar2  default hr_api.g_varchar2,
7767   p_override_user_ent_chk      varchar2  default 'N'
7768  ) is
7769 --
7770    -- Local Variables
7771    v_num_entry_values   number;
7772    v_input_value_id_tbl hr_entry.number_table;
7773    v_entry_value_tbl    hr_entry.varchar2_table;
7774    l_entry_type         VARCHAR2(1);
7775    v_assignment_id      number;
7776    --
7777    -- Local Cursors
7778    --
7779    --
7780    -- bug 546670
7781    --
7782    CURSOR csr_entry_type(p_element_entry_id NUMBER,
7783                          p_effective_date   DATE)
7784    IS
7785      SELECT pee.entry_type,
7786             pee.assignment_id
7787      FROM   PAY_ELEMENT_ENTRIES_F pee
7788      WHERE  pee.element_entry_id = p_element_entry_id
7789      and    p_effective_date BETWEEN
7790                 pee.effective_start_date and pee.effective_end_date
7791      ;
7792 --
7793  begin
7794    g_debug := hr_utility.debug_enabled;
7795 --
7796    OPEN  csr_entry_type(p_element_entry_id, p_session_date);
7797    FETCH csr_entry_type INTO l_entry_type, v_assignment_id;
7798    CLOSE csr_entry_type;
7799    g_override_user_ent_chk := p_override_user_ent_chk;
7800    --
7801    -- Call code to set up values that may be used in
7802    -- Formula validation of Input Values.
7803    --
7804    set_formula_contexts (v_assignment_id, p_session_date);
7805    --
7806    -- Convert entry value details ie. INPUT_VALUE_ID and SCREEN_ENTRY_VALUE
7807    -- into two tables to be passed into the overloaded version of
7808    -- update_element_entry. The overloaded version is capable of handling
7809    -- unlimited numbers of entry values.
7810    hr_entry_api.conv_entry_values_to_table
7811      ('SCREEN',
7812       p_element_entry_id,
7813       null,
7814       p_session_date,
7815       p_creator_type,
7816       l_entry_type,
7817       p_input_value_id1,
7818       p_input_value_id2,
7819       p_input_value_id3,
7820       p_input_value_id4,
7821       p_input_value_id5,
7822       p_input_value_id6,
7823       p_input_value_id7,
7824       p_input_value_id8,
7825       p_input_value_id9,
7826       p_input_value_id10,
7827       p_input_value_id11,
7828       p_input_value_id12,
7829       p_input_value_id13,
7830       p_input_value_id14,
7831       p_input_value_id15,
7832       p_entry_value1,
7833       p_entry_value2,
7834       p_entry_value3,
7835       p_entry_value4,
7836       p_entry_value5,
7837       p_entry_value6,
7838       p_entry_value7,
7839       p_entry_value8,
7840       p_entry_value9,
7841       p_entry_value10,
7842       p_entry_value11,
7843       p_entry_value12,
7844       p_entry_value13,
7845       p_entry_value14,
7846       p_entry_value15,
7847       v_num_entry_values,
7848       v_input_value_id_tbl,
7849       v_entry_value_tbl);
7850 --
7851    hr_entry_api.upd_element_entry
7852      (p_dt_update_mode,
7853       p_session_date,
7854       p_check_for_update,
7855       p_element_entry_id,
7856       p_cost_allocation_keyflex_id,
7857       p_updating_action_id,
7858       p_updating_action_type,
7859       p_original_entry_id,
7860       p_creator_type,
7861       p_comment_id,
7862       p_creator_id,
7863       p_reason,
7864       p_subpriority,
7865       p_date_earned,
7866       p_personal_payment_method_id,
7867       p_attribute_category,
7868       p_attribute1,
7869       p_attribute2,
7870       p_attribute3,
7871       p_attribute4,
7872       p_attribute5,
7873       p_attribute6,
7874       p_attribute7,
7875       p_attribute8,
7876       p_attribute9,
7877       p_attribute10,
7878       p_attribute11,
7879       p_attribute12,
7880       p_attribute13,
7881       p_attribute14,
7882       p_attribute15,
7883       p_attribute16,
7884       p_attribute17,
7885       p_attribute18,
7886       p_attribute19,
7887       p_attribute20,
7888       v_num_entry_values,
7889       v_input_value_id_tbl,
7890       v_entry_value_tbl,
7891   --
7892   -- J.Bailie 08-NOV-99 Element Entries DDF
7893   --
7894     p_entry_information_category,
7895     p_entry_information1,
7896     p_entry_information2,
7897     p_entry_information3,
7898     p_entry_information4,
7899     p_entry_information5,
7900     p_entry_information6,
7901     p_entry_information7,
7902     p_entry_information8,
7903     p_entry_information9,
7904     p_entry_information10,
7905     p_entry_information11,
7906     p_entry_information12,
7907     p_entry_information13,
7908     p_entry_information14,
7909     p_entry_information15,
7910     p_entry_information16,
7911     p_entry_information17,
7912     p_entry_information18,
7913     p_entry_information19,
7914     p_entry_information20,
7915     p_entry_information21,
7916     p_entry_information22,
7917     p_entry_information23,
7918     p_entry_information24,
7919     p_entry_information25,
7920     p_entry_information26,
7921     p_entry_information27,
7922     p_entry_information28,
7923     p_entry_information29,
7924     p_entry_information30
7925    );
7926 --
7927  end update_element_entry;
7928 --
7929  ------------------------------------------------------------------------------
7930  -- NAME                                                                     --
7931  -- hr_entry_api.del_ele_entry_param_val                                     --
7932  --                                                                          --
7933  -- DESCRIPTION                                                              --
7934  -- Validates the parameters passed to hr_entry_api.delete_element_entry.    --
7935  ------------------------------------------------------------------------------
7936  function del_ele_entry_param_val
7937  (
7938   p_dt_delete_mode   in out nocopy varchar2,
7939   p_session_date     date,
7940   p_element_entry_id number,
7941   p_assignment_id    number,
7942   p_entry_rec        out nocopy hr_entry_api.t_delete_entry_rec
7943  ) return boolean is
7944    --
7945    -- Local Variables
7946    --
7947    l_processed   varchar2(1) := 'N';
7948    v_entry_rec hr_entry_api.t_delete_entry_rec;
7949 
7950    --Added for bug:6809717
7951    l_assign_exist number:=0;
7952    l_before_ovm number;
7953    l_after_ovm number;
7954    --
7955    -- Bugfix 4308892
7956    -- Function to return the final process date for an assignment
7957    function final_process_date
7958    (
7959     p_assignment_id number,
7960     p_session_date date
7961    ) return date
7962    is
7963      --
7964      cursor csr_final_process_date (p_assignment_id number, p_session_date date) is
7965      select pos.final_process_date
7966      from per_periods_of_service pos,
7967           per_all_assignments_f asg
7968      where asg.assignment_id = p_assignment_id
7969      /* Added one more condition(PERIOD_OF_SERVICE_ID) for bug no: 6739960*/
7970      and   pos.PERIOD_OF_SERVICE_ID=asg.PERIOD_OF_SERVICE_ID
7971      and   asg.person_id = pos.person_id
7972      and   p_session_date between asg.effective_start_date
7973                           and asg.effective_end_date;
7974      --
7975      l_final_process_date date;
7976      --
7977    begin
7978      --
7979      open csr_final_process_date (p_assignment_id, p_session_date);
7980      fetch csr_final_process_date into l_final_process_date;
7981      close csr_final_process_date;
7982      --
7983      return l_final_process_date;
7984      --
7985    end final_process_date;
7986    --
7987  begin
7988    --
7989    -- Retrieve details about element entry being deleted.
7990    --
7991    begin
7992      select ee.original_entry_id,
7993             ee.effective_start_date,
7994             ee.effective_end_date,
7995             ee.assignment_id,
7996             ee.element_link_id,
7997             ee.entry_type,
7998             ee.creator_type,
7999             ee.creator_id,
8000             ee.target_entry_id,
8001             et.element_type_id,
8002             et.processing_type,
8003             nvl(ec.non_payments_flag, 'N'),
8004             ee.personal_payment_method_id
8005      into   v_entry_rec
8006      from   pay_element_entries_f ee,
8007             pay_element_links_f el,
8008             pay_element_types_f et,
8009             pay_element_classifications ec
8010      where  ee.element_entry_id = p_element_entry_id
8011        and  el.element_link_id = ee.element_link_id
8012        and  et.element_type_id = el.element_type_id
8013        and  ec.classification_id = et.classification_id
8014        and  p_session_date between ee.effective_start_date
8015                                and ee.effective_end_date
8016        and  p_session_date between el.effective_start_date
8017                                and el.effective_end_date
8018        and  p_session_date between et.effective_start_date
8019                                and et.effective_end_date;
8020    exception
8021      when no_data_found then
8022        hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
8023        hr_utility.set_message_token('PROCEDURE',
8024                                     'hr_entry_api.delete_element_entry');
8025        hr_utility.set_message_token('STEP','1');
8026        hr_utility.raise_error;
8027      when too_many_rows then
8028        hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
8029        hr_utility.set_message_token('PROCEDURE',
8030                                     'hr_entry_api.delete_element_entry');
8031        hr_utility.set_message_token('STEP','2');
8032        hr_utility.raise_error;
8033    end;
8034    --
8035    p_entry_rec := v_entry_rec;
8036    --
8037    -- Nonrecurring entries can only be deleted ie. a nonrecurring entry is
8038    -- always represented by one row.
8039    --
8040    if (v_entry_rec.processing_type = 'N' and v_entry_rec.entry_type = 'E') or
8041        v_entry_rec.entry_type <> 'E' then
8042      --
8043 --
8044      declare
8045         adjust_ee_source varchar2(1);
8046      begin
8047        -- Set the value for ADJUSTMENT_EE_SOURCE.
8048        -- NOTE: this assumes that the set_formula_contexts procedure has
8049        -- been called previously.
8050        adjust_ee_source := g_asg_info.adj_ee_source;
8051 --
8052        begin
8053 /*
8054          select  'Y'
8055          into l_processed
8056          from    pay_run_results
8057          where   source_id       = p_element_entry_id
8058          and     source_type    in ('E', 'I')
8059          and     status          <> 'U';
8060 */
8061 -- start of change 115.21 --
8062         SELECT  'Y'
8063         INTO    l_processed
8064         FROM    DUAL
8065         WHERE EXISTS
8066             (SELECT null
8067              FROM   PAY_RUN_RESULTS
8068              WHERE  source_id =  decode(v_entry_rec.entry_type,
8069                                           'A', decode (adjust_ee_source,
8070                                                        'T', v_entry_rec.target_entry_id,
8071                                                        p_element_entry_id),
8072                                           'R', decode (adjust_ee_source,
8073                                                        'T', v_entry_rec.target_entry_id,
8074                                                        p_element_entry_id),
8075                                           p_element_entry_id)
8076              and    entry_type = v_entry_rec.entry_type
8077              and    source_type in ('E', 'I')
8078              and    status <> 'U'
8079             )
8080         ;
8081   -- end of change 115.21 --
8082        exception
8083         when no_data_found then
8084             null;
8085        end;
8086      end;
8087 --Bug 6809717
8088 --Added to stop deletion of non recurring element entries in case of assignment status change.
8089  select nvl(count(*),0) into l_assign_exist
8090  from per_all_assignments_f paaf,per_assignment_status_types past
8091  where paaf.ASSIGNMENT_ID=p_assignment_id
8092  and p_session_date+1 between paaf.EFFECTIVE_START_DATE and paaf.EFFECTIVE_END_DATE
8093  and paaf.ASSIGNMENT_STATUS_TYPE_ID=past.ASSIGNMENT_STATUS_TYPE_ID
8094  and past.per_system_status='ACTIVE_ASSIGN';
8095 
8096 if l_assign_exist>0 then
8097 	select nvl(count(*),0) into l_before_ovm
8098 	from per_all_assignments_f
8099 	where ASSIGNMENT_ID=p_assignment_id and
8100 	p_session_date between EFFECTIVE_START_DATE and EFFECTIVE_END_DATE;
8101 
8102 	select nvl(count(*),0) into l_after_ovm
8103 	from per_all_assignments_f
8104 	where ASSIGNMENT_ID=p_assignment_id and
8105 	p_session_date+1 between EFFECTIVE_START_DATE and EFFECTIVE_END_DATE;
8106 
8107 	if l_before_ovm<>l_after_ovm then
8108 	l_assign_exist:=0;
8109 	end if;
8110 end if;
8111 
8112 
8113      if l_processed <> 'Y' then
8114         --
8115         if p_dt_delete_mode in ('DELETE_NEXT_CHANGE','FUTURE_CHANGE') then
8116            --
8117            -- Bugfix 2085631
8118            -- return false as we do not wish to remove these entries
8119            --
8120            return (false);
8121            --
8122         elsif p_dt_delete_mode = 'DELETE'
8123           and p_session_date = v_entry_rec.effective_end_date then
8124           --
8125           -- Bugfix 4015749
8126           -- return false, the non-recurring entry need not be zapped if it
8127           -- currently ends on the same day that the link being deleted will
8128           -- end, i.e.:
8129           --
8130           -- Before:
8131           -- EL  |----------------------------->
8132           -- PAY |-----|-----|-----|-----|----->
8133           -- EE        |-----|
8134           --                 ^
8135           --              p_session_date
8136           -- After:
8137           -- EL  |-----------|
8138           -- PAY |-----|-----|-----|-----|----->
8139           -- EE        |-----|
8140           --
8141           return (false);
8142           --
8143         -- Bugfix 4308892
8144         -- Need a new check here for employee termination code
8145         elsif p_dt_delete_mode = 'DELETE'
8146           and final_process_date(p_assignment_id, p_session_date) = p_session_date then
8147           --
8148           -- We do not wish to Zap this entry, it should be end-dated on
8149           -- the final process date so proceed with the Delete...
8150           return (true);
8151           --Added for Bug 6809717
8152 	elsif l_assign_exist=0 then
8153         -- We do not required to zap if its just assignment status change to end.
8154         return (true);
8155 
8156         ELSIF p_dt_delete_mode <> 'ZAP' THEN   -- bug 8225278
8157            --
8158             p_dt_delete_mode := 'DELETE';
8159            --
8160         end if;
8161         --
8162      end if;
8163      return (true);
8164      --
8165    elsif p_dt_delete_mode in ('DELETE_NEXT_CHANGE','FUTURE_CHANGE') and
8166          v_entry_rec.effective_end_date = hr_general.end_of_time then
8167      --
8168      return (false);
8169      --
8170    else
8171      --
8172      return (true);
8173      --
8174    end if;
8175    --
8176  end del_ele_entry_param_val;
8177 --
8178  ------------------------------------------------------------------------------
8179  -- NAME                                                                     --
8180  -- hr_entry_api.delete_element_entry                                        --
8181  --                                                                          --
8182  -- DESCRIPTION                                                              --
8183  -- Deletes an element entry providing full validation.                      --
8184  ------------------------------------------------------------------------------
8185 --
8186  procedure delete_element_entry
8187  (
8188   --
8189   -- Delete Mode
8190   --
8191   p_dt_delete_mode             varchar2,
8192   --
8193   -- Date on which change is taking place
8194   --
8195   p_session_date               date,
8196   --
8197   -- Element Entry Table
8198   --
8199   p_element_entry_id           number
8200  ) is
8201    --
8202    -- Find all accepted pay proposals that use the element entry.
8203    --
8204    cursor csr_accepted_pay_proposals
8205           (
8206            p_element_entry_id number,
8207            p_assignment_id    number
8208           ) is
8209      select pp.pay_proposal_id
8210      from   per_pay_proposals pp
8211      where  pp.assignment_id = p_assignment_id
8212        and  exists
8213             (select null
8214              from   pay_element_entries_f ee
8215              where  ee.element_entry_id = p_element_entry_id
8216                and  ee.creator_type = 'SP'
8217                and  ee.creator_id = pp.pay_proposal_id
8218                and  ee.effective_start_date = pp.change_date);
8219 
8220    -- bug 666197
8221    cursor csr_ovn_and_dates
8222      (p_element_entry_id number, p_effective_date date) is
8223       select object_version_number, effective_start_date, effective_end_date
8224         from pay_element_entries_f
8225         where element_entry_id = p_element_entry_id
8226           and p_effective_date between effective_start_date
8227                                    and effective_end_date;
8228    --
8229    -- old values of the dml record
8230    cursor csr_old_entry_values is
8231      select
8232        effective_start_date
8233       ,effective_end_date
8234       ,cost_allocation_keyflex_id
8235       ,assignment_id
8236       ,updating_action_id
8237       ,updating_action_type
8238       ,element_link_id
8239       ,original_entry_id
8240       ,creator_type
8241       ,entry_type
8242       ,comment_id
8243       ,creator_id
8244       ,reason
8245       ,target_entry_id
8246       ,source_id
8247       ,attribute_category
8248       ,attribute1
8249       ,attribute2
8250       ,attribute3
8251       ,attribute4
8252       ,attribute5
8253       ,attribute6
8254       ,attribute7
8255       ,attribute8
8256       ,attribute9
8257       ,attribute10
8258       ,attribute11
8259       ,attribute12
8260       ,attribute13
8261       ,attribute14
8262       ,attribute15
8263       ,attribute16
8264       ,attribute17
8265       ,attribute18
8266       ,attribute19
8267       ,attribute20
8268       ,subpriority
8269       ,personal_payment_method_id
8270       ,date_earned
8271       ,object_version_number
8272       ,balance_adj_cost_flag
8273       ,element_type_id
8274       ,all_entry_values_null
8275     from pay_element_entries_f
8276     where element_entry_id = p_element_entry_id
8277       and p_session_date between effective_start_date
8278                              and effective_end_date;
8279    --
8280    --
8281    -- Local Variables
8282    --
8283    l_prof_value              varchar2(30);
8284    v_validation_start_date   date;
8285    v_validation_end_date     date;
8286    v_next_effective_end_date date;
8287    v_dt_delete_mode          varchar2(30) := p_dt_delete_mode;
8288    v_entry_rec               hr_entry_api.t_delete_entry_rec;
8289    v_pay_proposal_id         number;
8290    -- bug 666197
8291    l_effective_start_date            date;
8292    l_effective_end_date              date;
8293    l_object_version_number           number;
8294    l_effective_start_date_o          date;
8295    l_effective_end_date_o            date;
8296    l_cost_allocation_keyflex_id_o    number;
8297    l_assignment_id_o                 number;
8298    l_updating_action_id_o            number;
8299    l_updating_action_type_o          varchar2(30);
8300    l_element_link_id_o               number;
8301    l_original_entry_id_o             number;
8302    l_creator_type_o                  varchar2(10);
8303    l_entry_type_o                    varchar2(1);
8304    l_comment_id_o                    number;
8305    l_creator_id_o                    number;
8306    l_reason_o                        varchar2(30);
8307    l_target_entry_id_o               number;
8308    l_source_id_o                     number;
8309    l_attribute_category_o            varchar2(30);
8310    l_attribute1_o                    varchar2(150);
8311    l_attribute2_o                    varchar2(150);
8312    l_attribute3_o                    varchar2(150);
8313    l_attribute4_o                    varchar2(150);
8314    l_attribute5_o                    varchar2(150);
8315    l_attribute6_o                    varchar2(150);
8316    l_attribute7_o                    varchar2(150);
8317    l_attribute8_o                    varchar2(150);
8318    l_attribute9_o                    varchar2(150);
8319    l_attribute10_o                   varchar2(150);
8320    l_attribute11_o                   varchar2(150);
8321    l_attribute12_o                   varchar2(150);
8322    l_attribute13_o                   varchar2(150);
8323    l_attribute14_o                   varchar2(150);
8324    l_attribute15_o                   varchar2(150);
8325    l_attribute16_o                   varchar2(150);
8326    l_attribute17_o                   varchar2(150);
8327    l_attribute18_o                   varchar2(150);
8328    l_attribute19_o                   varchar2(150);
8329    l_attribute20_o                   varchar2(150);
8330 -- --
8331    l_entry_information_category_o    varchar2(30);
8332    l_entry_information1_o            varchar2(150);
8333    l_entry_information2_o            varchar2(150);
8334    l_entry_information3_o            varchar2(150);
8335    l_entry_information4_o            varchar2(150);
8336    l_entry_information5_o            varchar2(150);
8337    l_entry_information6_o            varchar2(150);
8338    l_entry_information7_o            varchar2(150);
8339    l_entry_information8_o            varchar2(150);
8340    l_entry_information9_o            varchar2(150);
8341    l_entry_information10_o           varchar2(150);
8342    l_entry_information11_o           varchar2(150);
8343    l_entry_information12_o           varchar2(150);
8344    l_entry_information13_o           varchar2(150);
8345    l_entry_information14_o           varchar2(150);
8346    l_entry_information15_o           varchar2(150);
8347    l_entry_information16_o           varchar2(150);
8348    l_entry_information17_o           varchar2(150);
8349    l_entry_information18_o           varchar2(150);
8350    l_entry_information19_o           varchar2(150);
8351    l_entry_information20_o           varchar2(150);
8352    l_entry_information21_o           varchar2(150);
8353    l_entry_information22_o           varchar2(150);
8354    l_entry_information23_o           varchar2(150);
8355    l_entry_information24_o           varchar2(150);
8356    l_entry_information25_o           varchar2(150);
8357    l_entry_information26_o           varchar2(150);
8358    l_entry_information27_o           varchar2(150);
8359    l_entry_information28_o           varchar2(150);
8360    l_entry_information29_o           varchar2(150);
8361    l_entry_information30_o           varchar2(150);
8362 -- --
8363    l_subpriority_o                   number;
8364    l_personal_payment_method_id_o    number;
8365    l_date_earned_o                   date;
8366    l_object_version_number_o         number;
8367    l_balance_adj_cost_flag_o         varchar2(1);
8368    l_element_type_id_o               number;
8369    l_all_entry_values_null_o         varchar2(30);
8370    --
8371    l_eev_need_null_call              boolean;
8372    i                                 number;
8373    l_session_date_cur                date;
8374    --
8375    --
8376         function PROCESSED (
8377         --
8378         -- Returns true if the element entry has already been processed in a run
8379         --
8380         p_element_entry_id      number,
8381         p_original_entry_id     number,
8382         p_processing_type       varchar2,
8383         p_entry_type            varchar2,
8384         p_validation_start_date date,
8385         p_assignment_id         number) return boolean is
8386         --
8387         processed       varchar2(1) := 'N';
8388         --
8389         -- Define how to determine if the entry is processed
8390         --
8391         cursor nonrecurring_entries (adjust_ee_source in varchar2) is
8392         select  'Y'
8393         from    pay_run_results       prr,
8394                 pay_element_entries_f pee
8395         where   pee.element_entry_id = p_element_entry_id
8396 	/* Added the following condition for bug: 7344563 */
8397 	and     pee.element_entry_id = prr.element_entry_id
8398         and     p_validation_start_date between pee.effective_start_date
8399                                      and pee.effective_end_date
8400         and     prr.source_id   = decode(pee.entry_type,
8401                                           'A', decode (adjust_ee_source,
8402                                                        'T', pee.target_entry_id,
8403                                                        pee.element_entry_id),
8404                                           'R', decode (adjust_ee_source,
8405                                                        'T', pee.target_entry_id,
8406                                                        pee.element_entry_id),
8407                                           pee.element_entry_id)
8408         and     prr.entry_type  = pee.entry_type
8409         and     prr.source_type    in ('E', 'I')
8410         and     prr.status          <> 'U';
8411                 --
8412         cursor recurring_entries is
8413                 --
8414                 select  'Y'
8415                 from    pay_run_results         RESULT,
8416                         pay_assignment_actions  ASGT_ACTION,
8417                         pay_payroll_actions     PAY_ACTION,
8418                         per_time_periods        PERIOD
8419                 where   result.source_id        = nvl (p_original_entry_id,
8420                                                         p_element_entry_id)
8421                 and result.source_type    in ('E', 'I')
8422                 and result.status               <> 'U'
8423                 and result.assignment_action_id=asgt_action.assignment_action_id
8424                 and asgt_action.payroll_action_id=pay_action.payroll_action_id
8425                 and pay_action.time_period_id   = period.time_period_id
8426                 and p_validation_start_date <= period.start_date;
8427         --
8428         adjust_ee_source varchar2(1);
8429         begin
8430         --
8431         if (p_entry_type in ('S','D','A','R') or p_processing_type = 'N') then
8432           --
8433           -- Ensure that we have loaded relevant informaion
8434           -- that includes value for leg rule 'ADJUSTMENT_EE_SOURCE'
8435           set_formula_contexts(p_assignment_id, p_validation_start_date);
8436 --
8437           adjust_ee_source := g_asg_info.adj_ee_source;
8438 --
8439           open nonrecurring_entries(adjust_ee_source);
8440           fetch nonrecurring_entries into processed;
8441           close nonrecurring_entries;
8442           --
8443         else
8444           --
8445           open recurring_entries;
8446           fetch recurring_entries into processed;
8447           close recurring_entries;
8448           --
8449         end if;
8450         --
8451         return (processed='Y');
8452         --
8453         end processed;
8454         --
8455  begin
8456    g_debug := hr_utility.debug_enabled;
8457    --
8458    if g_debug then
8459       hr_utility.set_location('hr_entry_api.delete_element_entry', 5);
8460    end if;
8461    --
8462    -- bug 666197, retrieve and store old values for the entry row
8463    --
8464    begin
8465    --
8466    open csr_old_entry_values;
8467    fetch csr_old_entry_values into
8468           l_effective_start_date_o
8469          ,l_effective_end_date_o
8470          ,l_cost_allocation_keyflex_id_o
8471          ,l_assignment_id_o
8472          ,l_updating_action_id_o
8473          ,l_updating_action_type_o
8474          ,l_element_link_id_o
8475          ,l_original_entry_id_o
8476          ,l_creator_type_o
8477          ,l_entry_type_o
8478          ,l_comment_id_o
8479          ,l_creator_id_o
8480          ,l_reason_o
8481          ,l_target_entry_id_o
8482          ,l_source_id_o
8483          ,l_attribute_category_o
8484          ,l_attribute1_o
8485          ,l_attribute2_o
8486          ,l_attribute3_o
8487          ,l_attribute4_o
8488          ,l_attribute5_o
8489          ,l_attribute6_o
8490          ,l_attribute7_o
8491          ,l_attribute8_o
8492          ,l_attribute9_o
8493          ,l_attribute10_o
8494          ,l_attribute11_o
8495          ,l_attribute12_o
8496          ,l_attribute13_o
8497          ,l_attribute14_o
8498          ,l_attribute15_o
8499          ,l_attribute16_o
8500          ,l_attribute17_o
8501          ,l_attribute18_o
8502          ,l_attribute19_o
8503          ,l_attribute20_o
8504          ,l_subpriority_o
8505          ,l_personal_payment_method_id_o
8506          ,l_date_earned_o
8507          ,l_object_version_number_o
8508          ,l_balance_adj_cost_flag_o
8509          ,l_element_type_id_o
8510          ,l_all_entry_values_null_o;
8511       close csr_old_entry_values;
8512       exception
8513       when no_data_found then
8514         hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
8515         hr_utility.set_message_token('PROCEDURE','hr_entry_api.upd_element_entry');
8516         hr_utility.set_message_token('STEP','10');
8517         hr_utility.raise_error;
8518      end;
8519       --
8520       --
8521       -- Validate the parameter and return element entry details.
8522       --
8523       -- Bug 9013257, gets minimum assignment effective_start_date
8524       select min(ASG.effective_start_date)
8525       into l_session_date_cur
8526       from per_all_assignments_f ASG
8527       where ASG.assignment_id = l_assignment_id_o;
8528       --
8529       -- Bug 9013257, use min(effective_start_date) as the session_date
8530       -- if it is later than session_date and ZAP mode
8531       --
8532       if v_dt_delete_mode='ZAP' and l_session_date_cur > p_session_date then
8533         set_formula_contexts(l_assignment_id_o, l_session_date_cur);
8534       else
8535         set_formula_contexts(l_assignment_id_o, p_session_date);
8536       end if;
8537       --
8538       if hr_entry_api.del_ele_entry_param_val
8539         (v_dt_delete_mode,
8540          p_session_date,
8541          p_element_entry_id,
8542          l_assignment_id_o,
8543          v_entry_rec) then
8544      --
8545      -- Set the validation start and end dates according to the delete mode
8546      -- selected.
8547      --
8548      if v_dt_delete_mode = 'DELETE_NEXT_CHANGE' then
8549        --
8550        if g_debug then
8551           hr_utility.set_location('hr_entry_api.delete_element_entry', 15);
8552        end if;
8553        --
8554        begin
8555          select min(ee.effective_end_date)
8556          into   v_next_effective_end_date
8557          from   pay_element_entries_f ee
8558          where  ee.element_entry_id = p_element_entry_id
8559            and  ee.effective_start_date > v_entry_rec.effective_end_date;
8560        exception
8561          when no_data_found then null;
8562        end;
8563        --
8564        v_validation_start_date := v_entry_rec.effective_end_date + 1;
8565        --
8566        if v_next_effective_end_date is null then
8567          v_validation_end_date := hr_general.end_of_time;
8568        else
8569          v_validation_end_date := v_next_effective_end_date;
8570        end if;
8571        --
8572      elsif v_dt_delete_mode = 'FUTURE_CHANGE' then
8573        --
8574        v_validation_start_date := v_entry_rec.effective_end_date + 1;
8575        v_validation_end_date   := hr_general.end_of_time;
8576        --
8577      elsif v_dt_delete_mode = 'DELETE' then
8578        --
8579        v_validation_start_date := p_session_date + 1;
8580        v_validation_end_date   := hr_general.end_of_time;
8581        --
8582      elsif v_dt_delete_mode = 'ZAP' then
8583        --
8584        -- It may be illegal for users to purge entries, depending on
8585        -- the setting of a profile and what sort of entry is specified
8586        -- for purge.  We check this here because the v_dt_delete_mode
8587        -- can be changed by the previous call.
8588        --
8589        if g_debug then
8590           hr_utility.set_location('hr_entry_api.delete_element_entry', 18);
8591        end if;
8592        -- Start by reading the value.
8593        fnd_profile.get('HR_ELE_ENTRY_PURGE_CONTROL', l_prof_value);
8594        --
8595        -- Check if the profile is set appropriately and we are
8596        -- restricted.
8597        if l_prof_value is not null and
8598          (l_prof_value = 'N' or
8599           (l_prof_value = 'I' and v_entry_rec.non_payments_flag = 'N'))
8600        then
8601          -- We need to raise error that are attempting to purge.
8602          hr_utility.set_message (800,'HR_33000_ENTRY_CANT_PURGE');
8603          hr_utility.raise_error;
8604        end if;
8605        --
8606        -- Choose the extend of the entry to supply
8607        -- the validation start and end dates.
8608        -- This was added as a fix for bug 1862422
8609        -- to bring the validation into line with the
8610        -- usual api standards.
8611        select min(pee.effective_start_date),
8612               max(pee.effective_end_date)
8613        into   v_validation_start_date,
8614               v_validation_end_date
8615        from   pay_element_entries_f pee
8616        where  pee.element_entry_id = p_element_entry_id;
8617        --
8618      end if;
8619      --
8620      if g_debug then
8621         hr_utility.set_location('hr_entry_api.delete_element_entry', 20);
8622      end if;
8623      --
8624      -- Make sure the delete is valid.
8625      --
8626 	 /* Bug 14237599 : Commenting the below condition as we should be able to
8627 	    end date the third party element entry just like other element entries.
8628 
8629      if v_entry_rec.personal_payment_method_id is not null
8630      and processed (
8631                 --
8632                 p_element_entry_id,
8633                 v_entry_rec.original_entry_id,
8634                 v_entry_rec.processing_type,
8635                 v_entry_rec.entry_type,
8636                 v_validation_start_date,
8637                 v_entry_rec.assignment_id)
8638                 --
8639      then
8640        hr_utility.set_message (801,'HR_7798_ENTRY_PPM_RUN_RESULT');
8641        hr_utility.raise_error;
8642        --
8643      end if;
8644      --
8645      */
8646      -- Bug 9013257, use min(effective_start_date) as the session_date
8647      -- if it is later than session_date and ZAP mode
8648      --
8649      if v_dt_delete_mode='ZAP' and l_session_date_cur > p_session_date then
8650        hr_entry.chk_element_entry_main
8651        (p_element_entry_id,
8652         v_entry_rec.original_entry_id,
8653         l_session_date_cur,
8654         v_entry_rec.element_link_id,
8655         v_entry_rec.assignment_id,
8656         v_entry_rec.entry_type,
8657         v_entry_rec.effective_start_date,
8658         v_entry_rec.effective_end_date,
8659         v_validation_start_date,
8660         v_validation_end_date,
8661         null,
8662         v_dt_delete_mode,
8663         'DELETE',  -- p_usage
8664         v_entry_rec.target_entry_id,
8665         v_entry_rec.creator_type);
8666      else
8667        hr_entry.chk_element_entry_main
8668        (p_element_entry_id,
8669         v_entry_rec.original_entry_id,
8670         p_session_date,
8671         v_entry_rec.element_link_id,
8672         v_entry_rec.assignment_id,
8673         v_entry_rec.entry_type,
8674         v_entry_rec.effective_start_date,
8675         v_entry_rec.effective_end_date,
8676         v_validation_start_date,
8677         v_validation_end_date,
8678         null,
8679         v_dt_delete_mode,
8680         'DELETE',  -- p_usage
8681         v_entry_rec.target_entry_id,
8682         v_entry_rec.creator_type);
8683      end if;
8684      --
8685      -- Make a copy of all pay proposals for the assignment which have been
8686      -- accepted. This is used later to see if any have had the element entry
8687      -- changed ie. creator type changed, removed etc... If so the pay proposal
8688      -- has to be removed.
8689      --
8690      open csr_accepted_pay_proposals(p_element_entry_id,
8691                                      v_entry_rec.assignment_id);
8692      --
8693      if g_debug then
8694         hr_utility.set_location('hr_entry_api.delete_element_entry', 25);
8695      end if;
8696      --
8697      -- Trigger workload shifting if change to element entry overlaps with the
8698      -- latest payroll run for the assignment and workload shifting is enabled.
8699      --
8700      hr_entry.trigger_workload_shifting
8701        ('ELEMENT_ENTRY',
8702         v_entry_rec.assignment_id,
8703         v_validation_start_date,
8704         v_validation_end_date);
8705      --
8706      -- If entry is being removed then
8707      --
8708      --   remove any explict quickpay inclusions for the element entry
8709      --   where the inclusion overlaps with the removed part of the element
8710      --   entry.
8711      --
8712      if v_dt_delete_mode = 'DELETE' or p_dt_delete_mode = 'ZAP' then
8713        --
8714        if g_debug then
8715           hr_utility.set_location('hr_entry_api.delete_element_entry', 30);
8716        end if;
8717        --
8718        -- Enhancement 3368211
8719        --
8720        -- Delete from both PAY_QUICKPAY_INCLUSIONS and PAY_QUICKPAY_EXCLUSIONS.
8721        --
8722        -- There is a chance the element entry id exists in both tables if
8723        -- any QuickPay assignment actions were created before the QuickPay
8724        -- Exclusions data model was in use.
8725        --
8726        delete from pay_quickpay_exclusions pqe
8727        where  pqe.element_entry_id = p_element_entry_id
8728          and  exists
8729                 (select null
8730                  from   pay_assignment_actions paa,
8731                         pay_payroll_actions    ppa
8732                  where  paa.assignment_action_id = pqe.assignment_action_id
8733                    and  ppa.payroll_action_id    = paa.payroll_action_id
8734                    and  ppa.date_earned between v_validation_start_date
8735                                             and v_validation_end_date);
8736        --
8737        delete from pay_quickpay_inclusions pqi
8738        where  pqi.element_entry_id = p_element_entry_id
8739          and  exists
8740                 (select null
8741                  from   pay_assignment_actions paa,
8742                         pay_payroll_actions    ppa
8743                  where  paa.assignment_action_id = pqi.assignment_action_id
8744                    and  ppa.payroll_action_id    = paa.payroll_action_id
8745                    and  ppa.date_earned between v_validation_start_date
8746                                             and v_validation_end_date);
8747 
8748      end if;
8749      --
8750      -- Do date effective operation on element entry.
8751      --
8752      if v_dt_delete_mode = 'DELETE_NEXT_CHANGE' then
8753        --
8754        if g_debug then
8755           hr_utility.set_location('hr_entry_api.delete_element_entry', 40);
8756        end if;
8757        --
8758        delete from pay_element_entries_f ee
8759        where  ee.element_entry_id = p_element_entry_id
8760          and  ee.effective_start_date = v_validation_start_date;
8761        --
8762        update pay_element_entries_f ee
8763        set    ee.effective_end_date = decode(v_validation_end_date,
8764                                              hr_general.end_of_time,
8765                                              v_entry_rec.effective_end_date,
8766                                              v_validation_end_date),
8767               ee.updating_action_id = decode(ee.updating_action_type, 'U', ee.updating_action_id,
8768                                                                       null),
8769               ee.updating_action_type = decode(ee.updating_action_type, 'U', 'U', null)
8770        where  ee.element_entry_id = p_element_entry_id
8771          and  ee.effective_start_date = v_entry_rec.effective_start_date;
8772        --
8773      elsif v_dt_delete_mode = 'FUTURE_CHANGE' then
8774        --
8775        if g_debug then
8776           hr_utility.set_location('hr_entry_api.delete_element_entry', 45);
8777        end if;
8778        --
8779        delete from pay_element_entries_f ee
8780        where  ee.element_entry_id = p_element_entry_id
8781          and  ee.effective_start_date > v_entry_rec.effective_start_date;
8782        --
8783        update pay_element_entries_f ee
8784        set    ee.effective_end_date = v_entry_rec.effective_end_date,
8785               ee.updating_action_id = decode(ee.updating_action_type, 'U', ee.updating_action_id,
8786                                                                       null),
8787               ee.updating_action_type = decode(ee.updating_action_type, 'U', 'U', null)
8788        where  ee.element_entry_id = p_element_entry_id
8789          and  ee.effective_start_date = v_entry_rec.effective_start_date;
8790        --
8791      elsif v_dt_delete_mode = 'DELETE' then
8792        --
8793        if g_debug then
8794           hr_utility.set_location('hr_entry_api.delete_element_entry', 50);
8795        end if;
8796        --
8797        delete from pay_element_entries_f ee
8798        where  ee.element_entry_id = p_element_entry_id
8799          and  ee.effective_start_date > p_session_date;
8800        --
8801        update pay_element_entries_f ee
8802        set    ee.effective_end_date = p_session_date,
8803               ee.updating_action_id = decode(ee.updating_action_type, 'U', ee.updating_action_id,
8804                                                                       null),
8805               ee.updating_action_type = decode(ee.updating_action_type, 'U', 'U', null)
8806        where  ee.element_entry_id = p_element_entry_id
8807          and  ee.effective_start_date = v_entry_rec.effective_start_date;
8808        --
8809      elsif v_dt_delete_mode = 'ZAP' then
8810        --
8811        if g_debug then
8812           hr_utility.set_location('hr_entry_api.delete_element_entry', 55);
8813        end if;
8814        --
8815        -- For Zap mode, delete any balance exclusions rows for the entry
8816        --
8817        delete from pay_grossup_bal_exclusions excl
8818        where  excl.source_id =  p_element_entry_id
8819        and    excl.source_type = 'EE';
8820        --
8821        delete from pay_element_entries_f ee
8822        where  ee.element_entry_id = p_element_entry_id;
8823        --
8824        -- Bug 11843573
8825 	l_effective_start_date_o := v_validation_start_date;
8826      end if;
8827      --
8828      if g_debug then
8829         hr_utility.set_location('hr_entry_api.delete_element_entry', 60);
8830      end if;
8831      --
8832      -- Delete element entry values
8833      --
8834      hr_entry.del_3p_entry_values
8835        (v_entry_rec.assignment_id,
8836         p_element_entry_id,
8837         v_entry_rec.element_type_id,
8838         v_entry_rec.element_link_id,
8839         v_entry_rec.entry_type,
8840         v_entry_rec.processing_type,
8841         v_entry_rec.creator_type,
8842         v_entry_rec.creator_id,
8843         v_dt_delete_mode,
8844         p_session_date,
8845         v_validation_start_date,
8846         v_validation_end_date);
8847      --
8848      if g_debug then
8849         hr_utility.set_location('hr_entry_api.delete_element_entry', 65);
8850      end if;
8851      --
8852      -- Go through list of accepted pay proposals for the assignment /
8853      -- element entry to see if any of the pay proosals have lost the element
8854      -- entry they had (the existence of an element entry signifies an accepted
8855      -- pay proposal) ie. creator type changed, removed etc... Any accepted
8856      -- pay proposals that have lost their element entry should be removed.
8857      --
8858      loop
8859        --
8860        fetch csr_accepted_pay_proposals into v_pay_proposal_id;
8861        exit when csr_accepted_pay_proposals%notfound;
8862        --
8863        -- bug 9648525 remove proposal components as well as proposal
8864        delete from per_pay_proposal_components ppc
8865               where  ppc.pay_proposal_id in
8866        ( select pp.pay_proposal_id from per_pay_proposals pp
8867        where  pp.pay_proposal_id = v_pay_proposal_id
8868          and  not exists
8869               (select null
8870                from   pay_element_entries_f ee
8871                where  ee.element_entry_id = p_element_entry_id
8872                  and  ee.creator_type = 'SP'
8873                  and  ee.creator_id = pp.pay_proposal_id
8874                  and  ee.effective_start_date = pp.change_date));
8875        --
8876        delete from per_pay_proposals pp
8877        where  pp.pay_proposal_id = v_pay_proposal_id
8878          and  not exists
8879               (select null
8880                from   pay_element_entries_f ee
8881                where  ee.element_entry_id = p_element_entry_id
8882                  and  ee.creator_type = 'SP'
8883                  and  ee.creator_id = pp.pay_proposal_id
8884                  and  ee.effective_start_date = pp.change_date);
8885        --
8886      end loop;
8887      --
8888    else -- hr_entry_api.del_ele_entry_param_val returned 'FALSE'
8889    --
8890       if v_entry_rec.processing_type = 'N' and
8891        --v_dt_delete_mode in ('DELETE_NEXT_CHANGE','FUTURE_CHANGE') then
8892          v_dt_delete_mode in ('DELETE_NEXT_CHANGE','FUTURE_CHANGE','DELETE') then
8893          --
8894          if g_debug then
8895             hr_utility.set_location('hr_entry_api.delete_element_entry', 67);
8896          end if;
8897          --
8898          -- We do not wish to continue processing
8899          --
8900          return;
8901          --
8902       end if;
8903    --
8904    end if;
8905    --
8906    -- bug 666197, retrieve object version number; effective start/end dates;
8907    -- call to the user hook procedure
8908    --
8909    open csr_ovn_and_dates(p_element_entry_id, p_session_date);
8910    fetch csr_ovn_and_dates into l_object_version_number, l_effective_start_date,
8911                                         l_effective_end_date;
8912    close csr_ovn_and_dates;
8913 
8914 
8915    --
8916    begin
8917    --
8918    -- NB bug 3057670 has highlighted the fact that the orig delete_mode can be altered
8919    -- in the earlier call to hr_entry_api.del_ele_entry_param_val
8920    -- Therefore the passed value can be p_dt_delete_mode or v_dt_delete_mode.
8921    -- From JUL FP 03 this has been made the latter, ie if we handle a DELETE as a ZAP
8922    -- as in the bug above, then tell the hook (and DYT's etc) that we have just
8923    -- performed a ZAP
8924    --
8925    pay_ele_rkd.after_delete
8926      ( p_effective_date                 => p_session_date
8927       ,p_validation_start_date          => v_validation_start_date
8928       ,p_validation_end_date            => v_validation_end_date
8929       ,p_datetrack_mode                 => v_dt_delete_mode
8930       ,p_element_entry_id               => p_element_entry_id
8931       ,p_effective_start_date           => l_effective_start_date
8932       ,p_effective_end_date             => l_effective_end_date
8933       --,p_object_version_number          => l_object_version_number
8934       -- old values set
8935       ,p_effective_start_date_o         => l_effective_start_date_o
8936       ,p_effective_end_date_o           => l_effective_end_date_o
8937       ,p_cost_allocation_keyflex_id_o   => l_cost_allocation_keyflex_id_o
8938       ,p_assignment_id_o                => l_assignment_id_o
8939       ,p_updating_action_id_o           => l_updating_action_id_o
8940       ,p_updating_action_type_o         => l_updating_action_type_o
8941       ,p_element_link_id_o              => l_element_link_id_o
8942       ,p_original_entry_id_o            => l_original_entry_id_o
8943       ,p_creator_type_o                 => l_creator_type_o
8944       ,p_entry_type_o                   => l_entry_type_o
8945       ,p_comment_id_o                   => l_comment_id_o
8946       ,p_creator_id_o                   => l_creator_id_o
8947       ,p_reason_o                       => l_reason_o
8948       ,p_target_entry_id_o              => l_target_entry_id_o
8949       ,p_source_id_o                    => l_source_id_o
8950       ,p_attribute_category_o           => l_attribute_category_o
8951       ,p_attribute1_o                   => l_attribute1_o
8952       ,p_attribute2_o                   => l_attribute2_o
8953       ,p_attribute3_o                   => l_attribute3_o
8954       ,p_attribute4_o                   => l_attribute4_o
8955       ,p_attribute5_o                   => l_attribute5_o
8956       ,p_attribute6_o                   => l_attribute6_o
8957       ,p_attribute7_o                   => l_attribute7_o
8958       ,p_attribute8_o                   => l_attribute8_o
8959       ,p_attribute9_o                   => l_attribute9_o
8960       ,p_attribute10_o                  => l_attribute10_o
8961       ,p_attribute11_o                  => l_attribute11_o
8962       ,p_attribute12_o                  => l_attribute12_o
8963       ,p_attribute13_o                  => l_attribute13_o
8964       ,p_attribute14_o                  => l_attribute14_o
8965       ,p_attribute15_o                  => l_attribute15_o
8966       ,p_attribute16_o                  => l_attribute16_o
8967       ,p_attribute17_o                  => l_attribute17_o
8968       ,p_attribute18_o                  => l_attribute18_o
8969       ,p_attribute19_o                  => l_attribute19_o
8970       ,p_attribute20_o                  => l_attribute20_o
8971 -- --
8972       ,p_entry_information_category_o   => l_entry_information_category_o
8973       ,p_entry_information1_o           => l_entry_information1_o
8974       ,p_entry_information2_o           => l_entry_information2_o
8975       ,p_entry_information3_o           => l_entry_information3_o
8976       ,p_entry_information4_o           => l_entry_information4_o
8977       ,p_entry_information5_o           => l_entry_information5_o
8978       ,p_entry_information6_o           => l_entry_information6_o
8979       ,p_entry_information7_o           => l_entry_information7_o
8980       ,p_entry_information8_o           => l_entry_information8_o
8981       ,p_entry_information9_o           => l_entry_information9_o
8982       ,p_entry_information10_o          => l_entry_information10_o
8983       ,p_entry_information11_o          => l_entry_information11_o
8984       ,p_entry_information12_o          => l_entry_information12_o
8985       ,p_entry_information13_o          => l_entry_information13_o
8986       ,p_entry_information14_o          => l_entry_information14_o
8987       ,p_entry_information15_o          => l_entry_information15_o
8988       ,p_entry_information16_o          => l_entry_information16_o
8989       ,p_entry_information17_o          => l_entry_information17_o
8990       ,p_entry_information18_o          => l_entry_information18_o
8991       ,p_entry_information19_o          => l_entry_information19_o
8992       ,p_entry_information20_o          => l_entry_information20_o
8993       ,p_entry_information21_o          => l_entry_information21_o
8994       ,p_entry_information22_o          => l_entry_information22_o
8995       ,p_entry_information23_o          => l_entry_information23_o
8996       ,p_entry_information24_o          => l_entry_information24_o
8997       ,p_entry_information25_o          => l_entry_information25_o
8998       ,p_entry_information26_o          => l_entry_information26_o
8999       ,p_entry_information27_o          => l_entry_information27_o
9000       ,p_entry_information28_o          => l_entry_information28_o
9001       ,p_entry_information29_o          => l_entry_information29_o
9002       ,p_entry_information30_o          => l_entry_information30_o
9003       ,p_subpriority_o                  => l_subpriority_o
9004       ,p_personal_payment_method_id_o   => l_personal_payment_method_id_o
9005       ,p_date_earned_o                  => l_date_earned_o
9006       ,p_object_version_number_o        => l_object_version_number_o
9007       ,p_balance_adj_cost_flag_o        => l_balance_adj_cost_flag_o
9008       ,p_comments_o                     => null
9009       ,p_element_type_id_o              => l_element_type_id_o
9010       ,p_all_entry_values_null_o        => l_all_entry_values_null_o
9011      );
9012      --
9013      exception
9014        when hr_api.cannot_find_prog_unit then
9015          hr_api.cannot_find_prog_unit_error
9016                (p_module_name => 'PAY_ELEMENT_ENTRIES_F'
9017                ,p_hook_type   => 'AD'
9018                );
9019      end;
9020     --
9021    --
9022    if g_debug then
9023       hr_utility.set_location('hr_entry_api.delete_element_entry', 70);
9024    end if;
9025    --
9026 
9027   --
9028   -- 21-FEB-03
9029   -- -----------------
9030   -- Currently the hard-coded calls to the after_delete dynamic trigger package
9031   -- for element entries vals have been made for after insert and after update.  At this
9032   -- time after delete will not be made as CC does not require it.  At a future
9033   -- juncture this can be added, methodology....
9034   -- 1) Before delete of eev above, create cache of values
9035   -- 2) Now make a call to PAY_DYT_ELEMENT_ENTRY_VAL_PKG.after_delete
9036   --    -use current values if end dated or nulls if row has been blown away
9037   --
9038   if g_debug then
9039      hr_utility.trace(' NO Hard call PAY_DYT_ELEMENT_ENTRY_VAL_PKG.after_delete');
9040      hr_utility.set_location('Leaving: delete_element_entry', 900);
9041   end if;
9042 
9043  end delete_element_entry;
9044  --
9045 end hr_entry_api;