DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_ENTRY_API

Source


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