1 package body hrdyndbi as
2 /* $Header: pydyndbi.pkb 120.27.12010000.4 2009/08/22 07:13:16 pgongada ship $ */
3 --
4 /*
5 --
6 -- Copyright (c) Oracle Corporation 1991,1992,1993. All rights reserved
7 /*
8 PRODUCT
9 Oracle*Payroll
10 --
11 NAME
12 pydyndbi.pkb - procedures for creating/ deleting DYNamic DataBase Items.
13 --
14 DESCRIPTION
15 This package contains a collection of routines for generating and
16 deleting dynamic database item. The routes must already be in the
17 database for these routines to work.
18 The following database items are created/ deleted using procedures in
19 this file:
20 balances
21 element types
22 input values
23 grade rates
24 descriptive flexs
25 key flexs
26 absence types
27 NOTES
28 User Defined Data:
29 -----------------
30 User defined data may either be owned by a ---------------------
31 business group OR by a legislation. Since | User Defined Data |
32 a business group belongs to a legislation, ---------------------
33 the legislation code for data that has a Y Y
34 business group id may always be derived. | |
35 \ | | /
36 \ | | /
37 The effect on the entity horizon is that \------------/
38 either the legislation code OR the | |
39 business group id may be specified. The ------------ |
40 columns on the table ff_user_entities should | Business | |
41 not BOTH be populated. | group | |
42 ------------ |
43 The allowed combinations for these 2 columns Y |
44 are shown in the table below. This is now the | |
45 same model for Payroll and Formula. | |
46 | |
47 ---------------
48 | Legislation |
49 ---------------
50 --
51 --------------------------------------------------------------------
52 | Legislation Business |
53 | Code Group id |
54 | |
55 | Generic Startup Data : null null |
56 | |
57 | Legislation Specific : not null null |
58 | Startup Data |
59 | |
60 | User Defined Data : null not null |
61 | |
62 --------------------------------------------------------------------
63 --
64 (Previously Formula used the same model, EXCEPT that User Defined Data had
65 both columns as not null).
66 --
67 --
68 Creating DB Items:
69 -----------------
70 The main procedures that create/ delete database items are named xxx_dict.
71 These procedures share some general purpose routines to simplify the
72 process of creating DB items. These procedures are called:
73 --
74 insert_user_entity
75 insert_parameter_value
76 insert_database_item
77 --
78 Since they are declared in the package header, other routines that may
79 be written in the future to generate DB items may also reference them.
80 Each of the database creation procedures follow a similar layout:
81 --
82 The procedure (xxx_dict) is called with the relevent parameters (for
83 example the procedure to generate Element DB items is passed an element
84 type id and an effective date). The procedure may then retrieve further
85 information from the database. Then the entity is created with a call
86 to: 'insert_user_entity'. This defines what route the database items will
87 be attached to. If the route uses any where clause fillers (written as
88 (Ux in the route) then the procedure 'insert_parameter_value' is called
89 next. (If the route does not use any where clause fillers, this call is
90 omitted). Finally the procedure calls 'insert_database_item' for every
91 datbase item that is to be attached to the entity (and hence the route).
92 When several database items are to be created each with a different route,
93 then the main procedure (xxx_dict) calls the 3 routines in order, ie:
94 --
95 procedure xxx_dict (..) -- create some DB items
96 begin
97 -- get some information from the database
98 insert_user_entity (..);
99 insert_parameter_value (..); -- if the route uses where clause fillers
100 --
101 -- now create all the DB items for the above entity (and hence route)
102 --
103 insert_database_item (..);
104 insert_database_item (..);
105 insert_database_item (..);
106 --
107 -- another route is required, so declare a new user entity:
108 --
109 insert_user_entity (..);
110 insert_parameter_value (..);
111 --
112 -- now create all the DB items for the above entity (and hence route)
113 --
114 insert_database_item (..);
115 insert_database_item (..);
116 insert_database_item (..);
117 end;
118 --
119 Refer to the procedure headers for more information on each procedure.
120 --
121 Name Ver DD-MON-YYYY BugNo. and text
122 -----------------------------------------
123 pgongada 115.150 22-Aug-2009 Bug#8717589.Creating database items for
124 'Further Personal Payment Method Info' DFF.
125 priupadh 115.149 15-May-2009 Bug 8512762 Added commit in process_pay_dyndbi_changes.
126 ckesanap 115.148 25-Apr-2008 Bug 6955080. In delete_keyflex_dict, chaged the
127 where condition clause for deleting the
128 existing user_entity from ff_user_entities.
129 ckesanap 115.147 07-Aug-2007 Bug 5930272. Added fnd_message.retrieve() in
130 insert_user_entity_main() to clear the message
131 in the FND message queue as the error raised
132 in checkformat() is being handled.
133 ckesanap 115.146 18-Jul-2007 Bug 6215173. Passed null for l_legislation_code
134 parameter to create_key_flex() in
135 create_keyflex_dict() procedure.
136 divicker 115.145 22-MAY-2007 Merge exists for check_for_(tl)_dbi_clash
137 divicker 115.144 16-MAY-2007 Optimizer hints added for procedures
138 check_for_(tl)_dbi_clash
139 arashid 115.143 24-NOV-2006 Make dbi2ueid error message give out
140 more information. Also, catch
141 exceptions from update_xxx calls
142 in pay_process_dyndbi_changes and
143 log the errors.
144 Set the g_security_group_id for the
145 NAME_TRANSLATIONS lookup in
146 pay_process_dyndbi_changes, otherwise
147 the meaning is not translated.
148 Only delete PAY_DYNDBI_CHANGES row if
149 no errors occurred.
150 arashid 115.142 10-NOV-2006 Bug5464970 fix for changed
151 pay_dbitl_update_errors_pkg.fetch_all_rows
152 interface. Also, use dbms_sql.varchar_table
153 in process_leg_translations.
154 arashid 115.141 22-SEP-2006 Bug 5556728: in the MLS dbi case,
155 'Pay Value' was passed into
156 replace_code_name so the replacement was
157 not taking place.
158 divicker 115.140 01-JUN-2006 11511 branch merge
159 arashid 115.139 11-MAY-2006 Add code for running legislation-specific
160 database item translation from
161 process_pay_dyndbi_changes.
162 arashid 115.138 09-MAY-2006 Don't disable ff_user_entities delete
163 triggers as thay are required to delete
164 ff_database_items_tl rows (other child
165 rows are cascade deleted).
166 arashid 115.137 05-MAY-2006 Use substr to restrict names to 80
167 characters in routines that generate base
168 dbi names - this is to match the main
169 dynamic dbi name generation code. The
170 changes are in:
171 GEN_ET_BASE_DBI_NAME
172 GEN_DB_BASE_DBI_NAME
173 GEN_EIV_BASE_DBI_NAME
174 arashid 115.136 04-MAY-2006 Fixed infinitely looping code for
175 translating DATE_PAID and non-DATE_PAID
176 ELEMENT TYPE / INPUT VALUE database items.
177 Put debug into PROCESS_PAY_DYNDBI_CHANGES,
178 and tidied up the update error logging
179 code therein.
180 arashid 115.135 27-APR-2006 The following changes were made:
181 - process date-paid and non-date-paid
182 database items when updating _TL names.
183 - process_pay_dyndbi_changes code now calls
184 FF_DATABASE_ITEMS_PKG.UPDATE_SEEDED_TL_ROWS
185 and writes messages to the concurrent
186 processing log file.
187 arashid 115.134 31-MAR-2006 Changed process_pay_dyndbi_changes to not
188 raise assertions when entities are missing.
189 Instead, the condition is traced and the
190 PAY_DYNDBI_CHANGES row deleted.
191 arashid 115.133 27-JAN-2006 Changed process_pay_dyndbi_changes to a
192 concurrent processing interface with VARCHAR2
193 parameters.
194 arashid 115.132 11-NOV-2005 Fixed bug in new_defined_balance whereby
195 p_defined_balance_id was being passed
196 as p_balance_type_id in GEN_DB_TL_DBI_NAME.
197 arashid 115.131 01-NOV-2005 Made process_pay_dyndbi_changes multi-threaded.
198 arashid 115.130 31-OCT-2005 Changed PROCESS_PAY_DYNDBI_CHANGES to COMMIT
199 every 50 rows.
200 arashid 115.129 19-OCT-2005 Added support for fully translated dynamic
201 database items.
202 1. Added internal insert_database_item
203 interface with extra parameters to
204 help with fully translated database
205 items.
206 2. Tightened up validation for 'SEED'
207 condition to check against business
208 groups with the same legislation code.
209 3. Extracted code into functions for reuse:
210 check_for_dbi_clash
211 replace_code_name
212 uom_requires_dbis
213 4. Changed insert_database_item to handle
214 full MLS and pseudo-MLS as separate
215 cases. For full MLS, only a single
216 base DBI in ff_database_items is
217 generated.
218 5. Changed code for generating element,
219 input, and defined balance DBIs to
220 handle full MLS where it is supported.
221 6. Added update_xxx calls for MLS updates
222 to FF_DATABASE_ITEMS_TL.
223 Updates to FP.K and earlier should be
224 branched on 115.28.
225 alogue 115.128 07-OCT-2005 Performance fix to sel_ffci in
226 create_alternative_dbis. Bug 4658377.
227 nbristow 115.126 01-AUG-2005 Added support for OTL balances.
228 divicker 115.125 27-JUL-2005 add sleep for all workers bar first when
229 altering trigger states to prevent ora 4061
230 divicker 115.124 27-JUN-2005 add delimiting quotes to a text type
231 route parameter value 4431372
232 divicker 115.123 23-JUN-2005 hint update
233 divicker 115.122 22-JUN-2005 Add ordered hints for 2 stmts that speed up
234 fresh installs of hrglobal
235 divicker 115.121 09-JUN-2005 4363933 Add sleep to prevent too many
236 executions of worker complete loop
237 arashid 115.120 25-MAY-2005 4387272
238 Fixed FF_COMPILED_INFO_F delete code so
239 that all the affected FF_COMPILED_INFO_F
240 rows are deleted. The changes are made
241 for the partial delete cases:
242 delete_compiled_formula
243 delete_compiled_formula_priv
244 legislative rebuild_ele_input_bal
245 divicker 115.119 17-MAY-2005 Pre delete formula usages compiled info
246 by legislation or all if core
247 divicker 115.118 13-MAY-2005 Add commit points per 100 rows
248 Trace the worker for each main loop
249 divicker 115.117 12-MAY-2005 Regress back to fail and quit mode
250 divicker 115.116 11-MAY-2005 Fix duplicate RB user entity creation
251 divicker 115.115 05-MAY-2005 Add name delete for RB ue as well
252 divicker 115.114 21-APR-2005 add hint to del_comp_form_priv cursor
253 divicker 115.113 21-APR-2005 make internal calls to del_comp_form
254 call a more performant del_comp_form_priv
255 version instead when we can guarantee internal
256 calls will have a non-null creator id so we
257 can exploit the index by removing the nvl
258 divicker 115.112 20-APR-2005 fix issue with RB only def bal creation
259 divicker 115.111 31-MAR-2005 refresh def bal cursor addition and
260 and get_alt_route addition for 4273939
261 divicker 115.110 29-MAR-2005 fix to delete_compiled_formula when passed
262 leg_code is null even though formulae
263 may not be null 4262658
264 divicker 115.109 10-MAR-2005 fix an incorrect trace stmt
265 divicker 115.108 10-MAR-2005 dont eenable triggers in exception blk of
266 reib in order to avoid red herring mutation
267 erros in other drivers. instead do it in
268 hrrbdeib caller. Do it at beginning so both
269 are initially enabled if calling reib
270 manually
271 divicker 115.107 24-FEB-2005 comment change
272 divicker 115.106 23-FEB-2005 trace each main ID being processed
273 allows for much faster tracing
274 format is:
275 RDB:B,RB:leg_code.bg.defbalid,baldimid,baltype,srunbal
276 RELE:element_type_id.date
277 RELI:input_value_id.date
278 To rerun hrrbdeib for just one piece of data call the following
279 call disable trigger procs
280 set boolean hrdyndbi.g_triggers_altered true
281 for RDB: hrdyndbi.refresh_defined_balances(defbalid, 1);
282 for RELE: hrdyndbi.create_element_type_dict(element_type_id,dt);
283 for RELI: hrdyndbi.create_input_value_dict(input_value_id,dt);
284 <dt is to_date(<date>,'DD-MM-YYYY')> or null
285 divicker 115.105 23-FEB-2005 deliver better restricted tracing data
286 divicker 115.104 17-FEB-2005 mod to dcf
287 divicker 115.103 15-FEB-2005 decompile formula on leg code
288 divicker 115.102 10-FEB-2005 Add applied date to see when each worker is
289 started
290 divicker 115.101 09-FEB-2005 mthread fix
291 divicker 115.100 01-FEB-2005 Add proc reib_all
292 divicker 115.99 28-JAN-2005 form id pick fix and perf improvements
293 divicker 115.98 26-JAN-2005 del_comp_form E takes null leg_code not %
294 use l_entity_name in del_c_f KF
295 divicker 115.97 24-JAN-2005 Put back mod for refresh_element_types
296 divicker 115.96 21-JAN-2005 Be more selective on the formulae to
297 uncompile so FFXBPC can run faster
298 divicker 115.95 21-JAN-2005 Remove sho err
299 divicker 115.94 19-JAN-2005 Performance improvements
300 divicker 115.93 18-NOV-2004 Multithread
301 alogue 115.92 28-JUL-2004 Ensure quoted dbitems front last change
302 do not exceed 80 characters. Bug 3797888.
303 alogue 115.88 06-JUL-2004 Quote dbitem names that would have failed
304 with illegal characters. Bug 3723715.
305 divicker 115.87 24-JUN-2004 More mods to debug for insert route param
306 divicker 115.86 12-MAY-2004 Fix for 8i
307 divicker 115.84 06-MAY-2004 More debug info for input value
308 divicker 115.83 Add a load of additional debug info.
309 PYUPIP apps/apps HRDYNDBI
310 divicker 115.81 09-DEC-2003 No multi-thread
311 Merge changes in 115.79
312 Merge changes in 115.80
313 divicker 115.76 24-SEP-2003 Same as 115.74 (back out mthread routines)
314 alogue 115.74 31-JUL-2003 Bug 3073514. Replace hyphens with underscores
315 from flex segment names before creating
316 their dbitems. Change to dflex_c2.
317 alogue 115.73 28-MAY-2003 Bug 2977644. Fix delete_compiled_formula
318 to correctlt delete formula.
319 alogue 115.72 02-MAY-2003 Bug 2936561. Remove full stops from input
320 value names before ue and dbi creation.
321 GUI should have avoided full stops being in
322 input value names, but transpires accrual
323 code creates elements and input values
324 without running checkformat check. This is
325 really a workaround to that issue.
326 alogue 115.71 02-MAY-2003 Bug 2936750. Remove full stops from flex
327 segment names before creating their dbitems.
328 Change to dflex_c2;
329 scchakra 115.70 30-APR-2003 Created procedure recreate_defined_balance.
330 Bug - 2450195.
331 alogue 115.69 28-MAR-2003 Bug 2865665. Change behaviour for
332 so always set to Y if on db less than 9i.
333 divicker 115.68 17-MAR-2003 Modify leg code specific version of
334 refresh_element_types to only pick up
335 IVs that are deemed for dbi generation
336 alogue 115.67 10-MAR-2003 Bug 2836076. Change LOW_VOLUME behaviour
337 so defaults to TRUE for dbs earlier
338 than 9i.
339 alogue 115.66 06-MAR-2003 Bug 2835806. Fix to legislative
340 rebuild_ele_input_bal to ensure only
341 Balance user entities get deleted.
342 scchakra 115.65 20-FEB-2003 Bug 2813405. Removed code to raise error
343 PAY_34166_DF_DBI_MULTI_OCCUR from procedures
344 create_dev_desc_flex_dict and
345 get_legislation_code.
346 scchakra 115.64 11-FEB-2003 Bug 2637573. Modified
347 create_dev_desc_flex_dict to create DB items
348 for routes defined in table
349 pay_route_to_descr_flexs. Created a new
350 function get_legislation_code.
351 divicker 115.63 03-FEB-2003 bugfix 2782128
352 divicker 115.62 31-JAN-2003 Ensure BG items related to legcode are also picked
353 up for processing in legislative striping mode
354 alogue 115.61 18-DEC-2002 NOCOPY changes. Bug 2692195.
355 Support of Competencies dbitem creation in
356 create_keyflex_dict.
357 alogue 115.60 15-NOV-2002 Changed balance dbitem definition strategy so
358 now only use RULE hint when LOW_VOLUME
359 pay_action_parameter is set to Y. Thus default
360 behaviour is now that balances won't have this hint.
361 RThirlby 115.59 15-OCT-2002 Changed new_defined_balance to default the
362 save_run_balance flag is it is not alreaady
363 set, and if a default is available.
364 nbristow 115.58 03-OCT-2002 Changed new_defined_balance to allow calls to
365 get_value.
366 mkandasa 115.57 03-OCT-2002 Removed the error which is raised if p_record_inserted
367 returns false in insert_user_entity.
368 mkandasa 115.56 01-OCT-2002 Substr'd user entity name to 80 chars.Raised
369 Error in case of duplication of user entity name.
370 Bug no 2073022.
371 divicker 115.55 24-SEP-2002 H_ instead of H_DEC
372 divicker 115.54 20-SEP-2002 Slight fix to change in 115.53
373 divicker 115.53 19-SEP-2002 Change UOM H_ support to use H_DEC%. Tidy up of string
374 alogue 115.51 11-SEP-2002 Remove full stops from potential dbitems. Bug 2557062.
375 alogue 115.50 22-AUG-2002 Remove brackets from potential dbitems. Bug 2377726.
376 divicker 115.49 29-JUL-2002 Leg code striping for formula
377 mreid 115.48 18-JUL-2002 Modify creation of rpv for Entry DDF
378 alogue 115.47 16-JUL-2002 Handle user entities owned by old
379 values of SCL legislation rule
380 in create_scl_flex_dict.
381 divicker 115.46 26-JUN-2002 Added call in create_desc_flex_main to
382 insert rpv for ENTRY_DESC_FLEX_ROUTE
383 divicker 115.45 17-JUN-2002 Added back H_% UOM support
384 Added route parameter for ENTRY_DESC_FLEX
385 route
386 mreid 115.44 11-JUN-2002 Added support for Entry DDF
387 divicker 115.43 22-MAY-2002 Back out 115.41 change until July MP
388 rthirlby 115.42 13-MAY-2002 Corrected delete of SRB user entities to
389 delete of RB user entities.
390 divicker 115.41 01-MAY-2002 Added H_% UOM to generate fffunc.cn calls
391 rthirlby 115.40 01-MAR-2002 Added procedure create_alternative_dbis, to
392 create user entites for run balances. NB, no
393 dbi is created, to avoid the possibility of
394 people using the wrong dbi in formulas.
395 Added delete of SRB balances to rebuild_ele_
396 input_bal procedure.
397 alogue 08-MAR-2001 Fix insert_database_item when passed in
398 user_entity_id.
399 alogue 12-DEC-2000 Suport of creation of dbitems in
400 create_dev_desc_flex_dict for Extra Location Info
401 DDF, Extra Position Info DDF and Extra Person Info
402 DDF.
403 alogue 23-NOV-2000 Always RULE hint for balace dbitems. Bug 1513266.
404 divicker 115.35 30-OCT-2000 trigger enabled check for new_defined_balance
405 procedure added.
406 divicker 115.34 30-OCT-2000 Exception handler for reenabling triggers.
407 Check on derived codename value and whether triggers
408 are disabled or not, keeping original logic if
409 insert_database_item, insert_user_entity not called
410 via rebuild_ele_input_bal.
411 jarthurt 115.33 28-OCT-2000 Remove enabling and disabling of triggers in
412 rebuild_ele_input_bal. These are being transfered
413 to hrrbdeib.sql.
414 divicker 04-OCT-2000 Perf. enhancements to rebuild_ele_input_bal
415 alogue 07-AUG-2000 Fix to bug fix 1271588.
416 alogue 28-JUN-2000 Support of BALANCE_DBITEM_TYPE for flexible
417 balance dbitem definition text approach.
418 Includes Rule Hint.
419 alogue 20-APR-2000 Fix issue in descriptive flex dflex_c1 cursor
420 to handle titles that have been passed that
421 contain full-stops. Bug 1271588.
422 alogue 16-MAR-2000 Fix issue in insert_database_item to handle
423 NAME_TRANSLATIONS lokkup meanings that
424 contain apostrophes. Bug 1210117.
425 tbattoo 24-FEB-2000 Bug 1207273, if a user entity alredy exists when
426 you insert the db item use the id for the
427 existing entity and not the currval in the seq
428 alogue 22-FEB-2000 Translated Pay Value Database Item issue.
429 Bug 1110849.
430 alogue 14-FEB-2000 Utf8 support.
431 alogue 28-JAN-2000 Performance fix to create_element_type.
432 alogue 10-NOV-1999 Fix issue in descriptive flex dflex_c1 cursor
433 to handle titles that have been passed that
434 contain apostrophes. Bug 1061472.
435 jmoyano 03-NOV-1999 generator for Payroll DDF added to procedure
436 create_dev_desc_flex_dict.
437 alogue 02-NOV-1999 Fix issue in delete_flexfield_dict to handle
438 titles that have been passed that contain
439 apostrophes. Bug 1058676.
440 alogue 05-OCT-1999 Fix issue in create_input_value to handle
441 scenario where some user entities already exist,
442 but others don't. Bug 1018544.
443 alogue 23-SEP-1999 Support application_ids for SSP (804),
444 OAD (805), HXT (808), Federal HR (8301).
445 alogue 22-SEP-1999 Change to reflect desc flex titles now being
446 stripped of apostrophes prior to being passed
447 in.
448 kkawol 14-SEP-1999 Changed create_input_value, now checking date
449 UOM is set to 'D' instead of 'D_%'.
450 alogue 04-AUG-1999 Canoncial Number fix for absence dbitems.
451 alogue 01-JUL-1999 Fix to exc_acc and scl dbitem creations so
452 that now process several legislations using
453 the same passed in flexfield.
454 alogue 09-JUN-1999 Now handles descriptive flexfields titles
455 that contain apostrophes ie Add'l Org Unit Details.
456 Bug 874129.
457 alogue 24-MAY-1999 Support for Cananda in creation of Org
458 dev flex dbis.
459 alogue 27-APR-1999 Change in create_input_value support
460 of canonical numbers.
461 alogue 26-APR-1999 Fixes in create_input_value to support
462 canonical dates and canonical numbers.
463 alogue 09-APR-1999 Change in new_defined_balance to support
464 canonical numbers in balances database items.
465 cborrett 04-DEC-1998 Added generation of context sensitive
466 dbitems in procedure CREATE_FLEXFIELD_DICT().
467 Replaced hardcoded routes in CREATE_FLEXFIELD_DICT()
468 with cursor against new table pay_route_to_descr_flexs.
469 alogue 08-JAN-1999 Change in create_desc_flex to create
470 CURRENCY_CODE dbitem for Org Pay Method
471 descriptive flex.
472 arundell 06-JAN-1999 Changes in insert_database_item to support
473 MLS.
474 alogue 02-DEC-1998 Removed application_id check on hr_lookups
475 within insert_database_item.
476 alogue 05-OCT-1998 Fix insert_user_entity check of whether entity
477 exists to also check it is in current bus grp
478 or legislation.
479 alogue 09-MAR-1998 Creation of overloading of insert_user_entity
480 so 'old' style call is supported ie called
481 without p_record_inserted out parameter
482 added by 13-JAN-1998 change.
483 mfender 10-FEB-1998 Bug 610203 - removed count(*) from
484 insert_database_item.
485 amills 110.11 23-JAN-1998 Bug 523343. Changed insert_database_item procedure.
486 Added cursor get_codename which takes the
487 parameter item name and splits into constituent
488 items where necessary for matching onto hr_lookups,
489 so that translation of each part can be effective.
490 After retrieving the translatable 'meaning',
491 the constituent parts are then concatenated back
492 to form a fully translated db item.
493 amyers 13-JAN-1998 Amended procedure insert_user_entitiy to:
494 i. only insert data if it doesn't exist,
495 ii. return a value in a new parameter indicating
496 whether the insert has happened to determine
497 the creation of underlying parameter values
498 and database items.
499 This change comes from bug 602851, where in an
500 R11 upgrade database items and entities were not
501 created and formulae would then not compile, so
502 in driver hr11gn.drv we need to run procedure
503 refresh_grade_spine_rates to ensure this doesn't
504 happen.
505 New version is 110.10.
506 amills 24-DEC-1997 Added rtrim to same select to remove full stop,
507 a temporary workaround for bug 603256 to
508 ensure no reserved words or characters are in desc
509 flex creation.
510 amills 09-DEC-1997 changed l_title to select from fnd_descriptive_
511 flexs_vl rather than take a hardcoded value
512 in create_org_pay_flex_dict
513 alogue 28-OCT-1997 legislation_code used in delete from ff_user_entities
514 in delete_keyflex_dict. Fix to bug 513364.
515 mreid 24-SEP-1997 Changed table_names for release 11 security.
516 dsaxby 15-SEP-1997 Changed substr to substrb to avoid problems with
517 generating NLS database items.
518 alogue 13-AUG-1997 Business_group_id passed to delete_keyflex_dict
519 to fix bug 513364.
520 nbristow 25-JUL-1997 Changed all references of fn_descriptive_flexs
521 to fnd_descriptive_flexs_vl.
522 mwcallag 26-APR-1995 Entity name passed to delete_keyflex_dict to
523 fix bug 278064.
524 rfine 24-NOV-1994 Suppressed index on business_group_id
525 mwcallag 13-OCT-1994 Route PAYROLL_ACTION_FLEXFIELD_ROUTE deleted.
526 rfine 05-OCT-1994 Changed call to renamed package: was us_contr_dbi,
527 now pay_us_contr_dbi.
528 mwcallag 28-JUL-1994 Optional commit points added to procedure
529 rebuild_ele_input_bal.
530 mwcallag 20-JUL-1994 It has been decided to convert the formula model
531 to the payroll model for User Defined Data,
532 thereby being consistent for Payroll and Formula.
533 This means that for User Defined Data only the
534 business group id should be populated on
535 ff_user_entities, not legislation code as well.
536 (previously both columns were populated). Refer
537 to the Notes above for more information. The
538 change dated 15-JUL-1994 is undone.
539 mwcallag 15-JUL-1994 procedure 'new_defined_balance' altered to
540 populate leg_code in ff_user_entity if the
541 business group id is null. (ie. payroll to
542 Formula startup data interface). <- temp. change.
543 mwcallag 13-JUN-1994 G916 Procedure 'rebuild_ele_input_bal' added.
544 mwcallag 07-JUN-1994 G890 Entity name for DF Element Type corrected.
545 mwcallag 06-JUN-1994 G867 The user entity id is no longer appended to
546 the user entity name when the entity is created.
547 This eases the startup delivery for DB items.
548 mwcallag 25-MAY-1994 G795 The new where clause filler of element type
549 id was missing from the input value route
550 'INPUT_VALUE_ENTRY_LEVEL' for multiple
551 entries allowed input values.
552 mwcallag 29-APR-1994 Element type id context added for the route:
553 INPUT_VALUE_ENTRY_LEVEL to improve performance.
554 mwcallag 28-FEB-1994 Database names changed from '%ASS_%' to '%ASG_%'.
555 mwcallag 20-JAN-1994 Legislation code passed to delete_keyflex_dict,
556 procedure delete_compiled_formula added (G516).
557 mwcallag 11-JAN-1994 The title of the Element DF changed from 'Element
558 Developer DF' to 'Further Element Information'.
559 mwcallag 09-DEC-1993 G334 For element or input values DB items, if the
560 legislation code is null on the base table it
561 is derived from per_business_groups.
562 mwcallag 08-DEC-1993 G323 Context name is now used in the entity name
563 (together with the title) for all descriptive
564 flex DB items.
565 mwcallag 07-DEC-1993 G291 Change to Legal Company DB items.
566 mwcallag 30-NOV-1993 G259 procedure insert_parameter_value corrected to
567 properly handle multiple where clause fillers.
568 mwcallag 29-NOV-1993 G221 Improved handling for long database item
569 names.
570 mwcallag 23-NOV-1993 G161 Simplified the calls to generate DB items for
571 external use. Element DDF DB item now gets the
572 legislation code from per_business_groups if the
573 legislation code is null and business_group_id
574 is present on the element type table. (The
575 legislation code concatenated with the element
576 classification is used as the context code in the
577 AOL descriptive flex tables).
578 mwcallag 03-NOV-1993 Assignment Developer Descriptive flex DB items
579 added.
580 mwcallag 02-NOV-1993 ********************************
581 * DIVERGENCE FROM FROZEN CODE *
582 ********************************
583 Input Value DB item creation now tests the
584 multiple entries allowed flag, rather than the
585 recurring flag. Developer descriptive flex
586 DB items for elements and jobs added.
587 Benefit classification DB items added.
588 mwcallag 26-OCT-1993 Sum function in definition text for non-recurring
589 input values moved to outer parenthesis to stop
590 sql retrival error.
591 mwcallag 28-SEP-1993 pay_name_translations reference replaced with
592 hr_lookups in insert_database_item procedure,
593 also passed parameter of legislation code removed
594 since it is no longer used.
595 abraae 09-SEP-1993 strip blanks from DB Item defn text to fit into
596 ff_database_items.definition_text (char(240))
597 mwcallag 08-SEP-1993 Input value definition text modified to include a
598 decode on the UOM to avoid problem in formula when
599 several DB items of different user definable
600 data types are retrieved in 1 formula cursor.
601 mwcallag 01-SEP-1993 Procedure for converting element DB items from the
602 context of date earned to date paid added. Enable
603 checks added to cursors in SCL and descriptive
604 flex routines.
605 mwcallag 23-AUG-1993 More DB items for Descriptive flexfields added,
606 plus Organization payment methods, external
607 accounts and legal company SCL DB items.
608 mwcallag 03-AUG-1993 Developer Descriptive flexfield and SCL flexfield
609 procedures added.
610 mwcallag 27-JUL-1993 Passed parameter name to Key flexfield DB items
611 now use the short names of GRP, GRD, POS JOB.
612 mwcallag 20-JUL-1993 Not found flags set to yes, this stops quickpaint
613 error on an assignment with minimal information.
614 Dummy group function added to recurring input
615 values to stop formula error (see input value
616 code below for more information).
617 mwcallag 18-JUN-1993 Descriptive and key flex deletion routines now
618 delete compilied DB items from ff_fdi_usages_f
619 mwcallag 14-JUN-1993 Application id removed from both
620 delete_flexfield_dict and create_flexfield_dict
621 mwcallag 03-JUN-1993 Create descriptive and key flexfield routines
622 delete old flexfields before creation attempted.
623 mwcallag 26-MAY-1993 Creator types changed to reflect database change.
624 mwcallag 24-MAY-1993 'rate_type' DB item removed from grade rate
625 creation. (Bug 160305 rejected for rel. 10).
626 mwcallag 07-MAY-1993 Spine DB creation added to grade procedure.
627 DB creation procedure for key flexfield.
628 mwcallag 30-APR-1993 Grade rates extended, descriptive flexs and
629 absence types added.
630 mwcallag 26-APR-1993 Procedures for input values, element types
631 and grade rate database items added.
632 Abraae 06-APR-1993 Created.
633 */
634 --
635 -- Translations Data Structures
636 --
637 type r_dbi_prefix is record
638 (language varchar2(30)
639 ,found boolean
640 ,prefix varchar2(240)
641 );
642
643 type t_dbi_prefixes is table of r_dbi_prefix index by binary_integer;
644 --
645 -- Flags for PROCESS_PAY_DYNDBI_CHANGES procedure.
646 --
647 g_dyndbi_changes boolean := false;
648 g_dyndbi_changes_ok boolean;
649 --
650 -- Cursors for descriptive flexs, used by more than one procedure:
651 --
652 -- declare cursor 1 for retrieving the context level of the descriptive flex:
653 --
654 cursor dflex_c1 (p_table_name varchar2,
655 p_title varchar2,
656 p_global_flag varchar2,
657 p_context varchar2) is
658 SELECT DFC.descriptive_flexfield_name c_flex_name,
659 replace (replace (replace (ltrim(rtrim(upper(DF.title))),
660 ' ','_'),'''',''),'.','_') c_title,
661 DFC.created_by c_created_by,
662 DFC.last_update_login c_last_login
663 FROM fnd_descriptive_flexs_vl DF,
664 fnd_descr_flex_contexts DFC
665 WHERE DF.application_table_name = p_table_name
666 AND replace (ltrim (rtrim(DF.title)), '''','') = replace(p_title,'''','')
667 AND DF.application_id IN (800, 801, 804, 805, 808, 8301)
668 AND DF.descriptive_flexfield_name = DFC.descriptive_flexfield_name
669 AND DFC.enabled_flag = 'Y'
670 AND DFC.global_flag = p_global_flag
671 AND DFC.application_id IN (800, 801, 804, 805, 808, 8301)
672 AND DFC.descriptive_flex_context_code = p_context;
673 --
674 -- declare cursor 2 for retrieving the actual column names:
675 --
676 cursor dflex_c2 (p_descr_flex varchar2,
677 p_context varchar2) is
678 SELECT DFCU.application_column_name c_def_text,
679 replace(replace(replace (ltrim(rtrim(upper(DFCU.end_user_column_name))),
680 ' ','_'),'.',''),'-','_') c_db_name
681 FROM fnd_descr_flex_column_usages DFCU
682 WHERE DFCU.descriptive_flexfield_name = p_descr_flex
683 AND DFCU.application_id IN (800, 801, 804, 805, 808, 8301)
684 AND DFCU.descriptive_flex_context_code = p_context
685 AND DFCU.enabled_flag = 'Y';
686 --
687 -- Cache parameters for new_defined_balance
688 --
689 cached boolean := FALSE;
690 g_low_volume pay_action_parameters.parameter_value%type := 'N';
691 --
692 -- Cache value for security group ID
693 --
694 g_security_group_id number;
695 g_sess_date date;
696 --
697 -- Multithread support procedure
698 --
699 PROCEDURE insert_mthread_pps (p_stage number,
700 p_worker_id number,
701 p_leg_code varchar2 default 'ZZ')
702 IS
703 PRAGMA AUTONOMOUS_TRANSACTION;
704 BEGIN
705
706 insert into PAY_PATCH_STATUS(id,
707 patch_number,
708 patch_name,
709 process_type,
710 applied_date)
711 values (
712 pay_patch_status_s.nextval,
713 to_char(p_worker_id),
714 'HRRBDEIB INTERNAL PROC S' || to_char(p_stage),
715 p_leg_code,
716 sysdate);
717 commit;
718 END insert_mthread_pps;
719 --
720 PROCEDURE insert_mthread_pps_err (p_worker_id number,
721 p_leg_code varchar2 default 'ZZ')
722 IS
723 PRAGMA AUTONOMOUS_TRANSACTION;
724 BEGIN
725
726 insert into PAY_PATCH_STATUS(id,
727 patch_number,
728 patch_name,
729 process_type,
730 applied_date)
731 values (
732 pay_patch_status_s.nextval,
733 to_char(p_worker_id),
734 'HRRBDEIB INTERNAL PROC ERR' || to_char(p_worker_id),
735 p_leg_code,
736 sysdate);
737 commit;
738 END insert_mthread_pps_err;
739 --
740 PROCEDURE hrrbdeib_trace_on IS
741 BEGIN
742 if g_debug_cnt > 0 then
743 hr_utility.trace_on(null, 'HRRBDEIB');
744 end if;
745 END;
746
747 PROCEDURE hrrbdeib_trace_off is
748 BEGIN
749 if g_debug_cnt > 0 then
750 hr_utility.trace_off;
751 end if;
752 END;
753 --
754 -- Function/Procedure declarations.
755 --
756 procedure check_for_dbi_clash
757 (p_user_name in varchar2
758 ,p_ue_id in number
759 ,p_leg_code in varchar2
760 ,p_bg_id in number
761 ,p_startup_mode in varchar2
762 ,p_clash out nocopy boolean
763 );
764 --
765 procedure replace_code_name
766 (p_language_code in varchar2
767 ,p_item_name in out nocopy varchar2
768 );
769 --
770 -- Assert a condition in the code.
771 --
772 procedure assert
773 (p_condition in boolean
774 ,p_location in varchar2
775 ,p_extra_info in varchar2
776 );
777 --
778 procedure gen_db_tl_dbi_name
779 (p_balance_type_id in number
780 ,p_balance_dimension_id in number
781 ,p_language in varchar2
782 ,p_tl_name out nocopy varchar2
783 ,p_found out nocopy boolean
784 );
785 --
786 procedure gen_et_dbi_prefixes
787 (p_element_type_id in number
788 ,p_languages in dbms_sql.varchar2s
789 ,p_prefixes in out nocopy t_dbi_prefixes
790 );
791 --
792 procedure gen_eiv_dbi_prefixes
793 (p_input_value_id in number
794 ,p_effective_date in date
795 ,p_languages in dbms_sql.varchar2s
796 ,p_prefixes in out nocopy t_dbi_prefixes
797 );
798 --
799 procedure update_tl_dbi_name
800 (p_user_name in varchar2
801 ,p_user_entity_id in number
802 ,p_leg_code in varchar2
803 ,p_bg_id in number
804 ,p_startup_mode in varchar2
805 ,p_language in varchar2
806 ,p_tl_user_name in varchar2
807 );
808 --
809 procedure update_et_tl_dbi_names
810 (p_leg_code in varchar2
811 ,p_bg_id in number
812 ,p_startup_mode in varchar2
813 ,p_user_name in varchar2
814 ,p_user_entity_id in number
815 ,p_prefixes in t_dbi_prefixes
816 ,p_suffix in varchar2
817 ,p_date_p in varchar2
818 );
819 --
820 function uom_requires_dbis
821 (p_uom in varchar2
822 ) return boolean;
823 --
824 -- New private procedure called by overloaded create_desc_flex()
825 --
826 procedure create_desc_flex_main
827 (
828 p_title in varchar2,
829 p_table_name in varchar2,
830 p_route_name in varchar2,
831 p_entity_name in varchar2,
832 p_context in varchar2,
833 p_global_flag in varchar2,
834 p_param_value in varchar2,
835 p_leg_code in varchar2,
836 p_business_group_id in varchar2
837 );
838 --
839 procedure delete_compiled_formula_priv
840 (
841 p_creator_id in number,
842 p_creator_type in varchar2,
843 p_user_entity_name in varchar2,
844 p_leg_code in varchar2
845 );
846 --
847 procedure ff_compiled_info_del
848 (p_formula_ids in dbms_sql.number_table
849 ,p_start_dates in dbms_sql.date_table
850 );
851 --
852 procedure create_user_entity
853 (p_db_item_name in out nocopy varchar2,
854 p_business_group_id in number,
855 p_legislation_code in varchar2,
856 p_route_id in number,
857 p_notfound_flag in varchar2,
858 p_defined_balance_id in number,
859 p_creator_type in varchar2,
860 p_description in varchar2,
861 p_startup_mode in varchar2,
862 p_user_entity_id in out nocopy number
863 )
864 is
865 rgeflg varchar2(1);
866 begin
867 IF (g_triggers_altered) THEN
868 -- validate the name is OK. This was originally called as part of
869 -- the FF_USER_ENTITIES_BRI trigger so we add it here.
870 begin
871 -- Check if name legal format eg no spaces, or special characters
872 hr_chkfmt.checkformat (p_db_item_name, 'DB_ITEM_NAME', p_db_item_name,
873 null,null,'Y',rgeflg,null);
874 exception
875 when hr_utility.hr_error then
876 hr_utility.set_message (802, 'FFHR_6016_ALL_RES_WORDS');
877 hr_utility.set_message_token(802,'VALUE_NAME','FF94_USER_ENTITY');
878 hrrbdeib_trace_on;
879 hr_utility.trace('checkformat create_user_entity');
880 hr_utility.trace('ue name:' || p_db_item_name);
881 hrrbdeib_trace_off;
882 hr_utility.raise_error;
883 end;
884 --
885 -- create user entity
886 select ff_user_entities_s.nextval
887 into p_user_entity_id
888 from sys.dual;
889
890 BEGIN
891 insert into ff_user_entities
892 (user_entity_id,
893 business_group_id,
894 legislation_code,
895 route_id,
896 notfound_allowed_flag,
897 user_entity_name,
898 creator_id,
899 creator_type,
900 entity_description)
901 select
902 p_user_entity_id,
903 p_business_group_id,
904 p_legislation_code,
905 p_route_id,
906 p_notfound_flag,
907 p_db_item_name,
908 p_defined_balance_id,
909 p_creator_type,
910 p_description
911 from dual
912 where not exists (
913 select null
914 from ff_user_entities a
915 where a.user_entity_name = p_db_item_name
916 and
917 ( p_startup_mode = 'MASTER'
918 or
919 ( p_startup_mode = 'SEED'
920 and
921 ( a.legislation_code = p_legislation_code
922 or
923 (a.legislation_code is null and a.business_group_id is null)
924 or
925 p_legislation_code =
926 (
927 select b.legislation_code
928 from per_business_groups_perf b
929 where b.business_group_id = a.business_group_id
930 )
931 )
932 )
933 or
934 ( p_startup_mode = 'NON-SEED'
935 and
936 ( a.business_group_id = p_business_group_id
937 or
938 (a.legislation_code is null and a.business_group_id is null)
939 or
940 (a.business_group_id is null and a.legislation_code = p_legislation_code)
941 )
942 )
943 ));
944 EXCEPTION WHEN OTHERS THEN
945 hrrbdeib_trace_on;
946 hr_utility.trace('hrrbdeib ins user entity: ');
947 hr_utility.trace(p_db_item_name || ' :routeid:');
948 hr_utility.trace(to_char(p_route_id) || ' :legcode:');
949 hr_utility.trace(p_legislation_code || ' :bgid:');
950 hr_utility.trace(to_char(p_business_group_id));
951 hrrbdeib_trace_off;
952 raise;
953 END;
954 ELSE -- g_triggers_altered is FALSE so use existing trigger validation
955 --
956 select ff_user_entities_s.nextval
957 into p_user_entity_id
958 from sys.dual;
959 --
960 insert into ff_user_entities
961 (user_entity_id,
962 business_group_id,
963 legislation_code,
964 route_id,
965 notfound_allowed_flag,
966 user_entity_name,
967 creator_id,
968 creator_type,
969 entity_description)
970 values (
971 p_user_entity_id,
972 p_business_group_id,
973 p_legislation_code,
974 p_route_id,
975 p_notfound_flag,
976 p_db_item_name,
977 p_defined_balance_id,
978 p_creator_type,
979 p_description
980 );
981 END IF; -- g_triggers_altered
982 --
983 --
984 end create_user_entity;
985 --
986 procedure create_dbi
987 (
988 p_db_item_name in varchar2,
989 p_user_entity_id in number,
990 p_datatype in varchar2,
991 p_definition in varchar2,
992 p_null_allowed in varchar2,
993 p_description in varchar2,
994 p_startup_mode in varchar2,
995 p_legislation_code in varchar2,
996 p_business_group_id in number
997 )
998 is
999 l_exists varchar2(2);
1000 l_clash boolean;
1001 begin
1002 -- Insert a Database Item to hold balance value.
1003 check_for_dbi_clash
1004 (p_user_name => p_db_item_name
1005 ,p_ue_id => p_user_entity_id
1006 ,p_leg_code => p_legislation_code
1007 ,p_bg_id => p_business_group_id
1008 ,p_startup_mode => p_startup_mode
1009 ,p_clash => l_clash
1010 );
1011 if not l_clash then
1012 insert into ff_database_items
1013 (user_name
1014 ,user_entity_id
1015 ,data_type
1016 ,definition_text
1017 ,null_allowed_flag
1018 ,description
1019 )
1020 values
1021 (p_db_item_name
1022 ,p_user_entity_id
1023 ,p_datatype
1024 ,p_definition
1025 ,p_null_allowed
1026 ,p_description
1027 );
1028 end if;
1029 exception
1030 when others then
1031 hrrbdeib_trace_on;
1032 hr_utility.trace('hrrbdeib ins dbi: ');
1033 hr_utility.trace(p_db_item_name || ' :ue id:');
1034 hr_utility.trace(to_char(p_user_entity_id) || ' :legcode:');
1035 hr_utility.trace(p_legislation_code || ' :bgid:');
1036 hr_utility.trace(to_char(p_business_group_id));
1037 hrrbdeib_trace_off;
1038 raise;
1039 end;
1040 ---------------------------------------------------------------------------
1041 -- procedure create_alternative_dbis
1042 ---------------------------------------------------------------------------
1043 procedure create_alternative_dbis(p_defined_balance_id in number,
1044 p_balance_dimension_id in number,
1045 p_balance_type_id in number,
1046 p_business_group_id in number,
1047 p_legislation_code in varchar2,
1048 p_db_item_name in varchar2,
1049 p_startup_mode in varchar2
1050 )
1051 is
1052 cursor get_alt_routes (p_bal_dim in number)
1053 is
1054 select pdr.route_id,
1055 pdr.route_type,
1056 pdr.run_dimension_id,
1057 pdr.priority
1058 from pay_dimension_routes pdr
1059 where pdr.balance_dimension_id = p_bal_dim
1060 and not exists (select null
1061 from ff_user_entities u
1062 where u.creator_id = p_defined_balance_id
1063 and u.creator_type = 'RB'
1064 and u.route_id = pdr.route_id)
1065 order by pdr.balance_dimension_id, pdr.priority;
1066 --
1067 cursor sel_ffci(p_dbi_item_name in varchar2,
1068 p_legislation_code in varchar2,
1069 p_business_group_id in number,
1070 p_startup_mode in varchar2)
1071 is
1072 select /*+ ORDERED
1073 INDEX(a FF_USER_ENTITIES_N50)
1074 INDEX(fdbi FF_DATABASE_ITEMS_FK1)
1075 INDEX(fdi FF_USER_ENTITIES_N50)
1076 USE_NL(a fdbi fdi) */
1077 formula_id
1078 from
1079 ff_user_entities a,
1080 ff_database_items fdbi,
1081 ff_fdi_usages_f fdi
1082 where fdi.usage = 'D'
1083 and fdi.item_name = fdbi.user_name
1084 and fdbi.user_entity_id = a.user_entity_id
1085 and a.user_entity_name = p_dbi_item_name
1086 and
1087 ( p_startup_mode = 'MASTER'
1088 or
1089 ( p_startup_mode = 'SEED'
1090 and
1091 ( a.legislation_code = p_legislation_code
1092 or
1093 (a.legislation_code is null and a.business_group_id is null)
1094 or
1095 p_legislation_code =
1096 (
1097 select b.legislation_code
1098 from per_business_groups_perf b
1099 where b.business_group_id = a.business_group_id
1100 )
1101 )
1102 )
1103 or
1104 ( p_startup_mode = 'NON-SEED'
1105 and
1106 ( a.business_group_id = p_business_group_id
1107 or
1108 (a.legislation_code is null and a.business_group_id is null)
1109 or
1110 (a.business_group_id is null and a.legislation_code = p_legislation_code)
1111 )
1112 )
1113 );
1114
1115 l_db_item_name ff_database_items.user_name%type;
1116 usr_ent_id number;
1117 l_dbitem_def_text ff_database_items.definition_text%type;
1118 --
1119 begin
1120 --
1121 for rrrec in get_alt_routes(p_balance_dimension_id) loop
1122 --
1123 l_db_item_name := p_db_item_name||'_'||to_char(rrrec.priority);
1124 --
1125 -- delete the UE so we ensure that we recreate it
1126 for r_sel_ffci in sel_ffci(l_db_item_name,
1127 p_legislation_code,
1128 p_business_group_id,
1129 p_startup_mode) loop
1130
1131 delete ff_fdi_usages_f where formula_id = r_sel_ffci.formula_id;
1132 delete ff_compiled_info_f where formula_id = r_sel_ffci.formula_id;
1133
1134 end loop;
1135
1136 delete ff_user_entities a
1137 where a.user_entity_name = l_db_item_name
1138 and
1139 ( p_startup_mode = 'MASTER'
1140 or
1141 ( p_startup_mode = 'SEED'
1142 and
1143 ( a.legislation_code = p_legislation_code
1144 or
1145 (a.legislation_code is null and a.business_group_id is null)
1146 or
1147 p_legislation_code =
1148 (
1149 select b.legislation_code
1150 from per_business_groups_perf b
1151 where b.business_group_id = a.business_group_id
1152 )
1153 )
1154 )
1155 or
1156 ( p_startup_mode = 'NON-SEED'
1157 and
1158 ( a.business_group_id = p_business_group_id
1159 or
1160 (a.legislation_code is null and a.business_group_id is null)
1161 or
1162 (a.business_group_id is null and a.legislation_code = p_legislation_code)
1163 )
1164 )
1165 );
1166
1167 create_user_entity
1168 (l_db_item_name,
1169 p_business_group_id,
1170 p_legislation_code,
1171 rrrec.route_id,
1172 'N',
1173 p_defined_balance_id,
1174 'RB',
1175 'To hold database items for the Balance '
1176 || l_db_item_name || ' (automatically generated)',
1177 p_startup_mode,
1178 usr_ent_id
1179 );
1180 --
1181 -- add Route Parameter values which contains the
1182 -- balance type ID and balance Dimension id to make
1183 -- the route work (we know sequence is 1 and 2)
1184
1185 insert into ff_route_parameter_values
1186 (route_parameter_id,
1187 user_entity_id,
1188 value)
1189 select RP.route_parameter_id,
1190 usr_ent_id,
1191 to_char(p_balance_type_id)
1192 from ff_route_parameters RP
1193 where RP.route_id = rrrec.route_id
1194 and RP.sequence_no = 1;
1195 if sql%rowcount <> 1 then
1196 hr_utility.set_message(801, 'HR_ERROR');
1197 hrrbdeib_trace_on;
1198 hr_utility.trace('missing seq 1 route param for route : ' || to_char(rrrec.route_id) || ' :user ent id:' || to_char(usr_ent_id));
1199 hrrbdeib_trace_off;
1200 hr_utility.raise_error;
1201 end if;
1202 --
1203 if rrrec.route_type = 'SRB' then
1204 --
1205 -- RR routes will only have route parameters for Balance type_id
1206 --
1207
1208 insert into ff_route_parameter_values
1209 (route_parameter_id,
1210 user_entity_id,
1211 value)
1212 select RP.route_parameter_id,
1213 usr_ent_id,
1214 to_char(rrrec.run_dimension_id)
1215 from ff_route_parameters RP
1216 where RP.route_id = rrrec.route_id
1217 and RP.sequence_no = 2;
1218 if sql%rowcount <> 1 then
1219 hr_utility.set_message(801, 'HR_ERROR');
1220 hrrbdeib_trace_on;
1221 hr_utility.trace('missing seq 2 route param for route : ' || to_char(rrrec.route_id) || ' :user ent id:' || to_char(usr_ent_id));
1222 hrrbdeib_trace_off;
1223 hr_utility.raise_error;
1224 end if;
1225 end if;
1226 --
1227
1228 -- For run balances we are not creating database items, just user entities,
1229 -- in order to avoid the incorrect use of dbis in formulas, so call to
1230 -- create_dbi has been removed.
1231 --
1232 --
1233 end loop;
1234 --
1235 end create_alternative_dbis;
1236 --
1237 /*------------------- new_defined_balance -----------------------------*/
1238 --
1239 /*
1240 * This routine creates the database item and supporting information
1241 * for a single defined balance. It is normally called from the
1242 * trigger on insert of defined balance, or from the refresh routine.
1243 */
1244 procedure new_defined_balance (p_defined_balance_id in number,
1245 p_balance_dimension_id in number,
1246 p_balance_type_id in number,
1247 p_business_group_id in number,
1248 p_legislation_code in varchar2) is
1249 --
1250 cursor c_language is
1251 select language_code
1252 from fnd_languages
1253 where installed_flag in ('I','B');
1254 --
1255 cursor chk_flag_set(p_def_bal number)
1256 is
1257 select count(*)
1258 from pay_defined_balances
1259 where defined_balance_id = p_def_bal
1260 and save_run_balance is null;
1261 --
1262 cursor get_cat_id(p_bal_type number)
1263 is
1264 select balance_category_id
1265 from pay_balance_types
1266 where balance_type_id = p_bal_type;
1267 --
1268 cursor get_sess_date
1269 is
1270 select effective_date
1271 from fnd_sessions
1272 where session_id = userenv('sessionid');
1273 --
1274 l_route_id ff_routes.route_id%type;
1275 l_db_item_name ff_database_items.user_name%type;
1276 l_dbitem_def_text ff_database_items.definition_text%type;
1277 l_dbi_function pay_balance_dimensions.database_item_function%type;
1278
1279 startup_mode varchar2(10);
1280 rgeflg varchar2(1);
1281 usr_ent_id number;
1282 route_param_value number;
1283 l_flag_set number;
1284 l_bal_cat_id pay_balance_types.balance_category_id%type;
1285 l_run_bal_flag pay_defined_balances.save_run_balance%type;
1286 l_sess_date date;
1287 l_ora_db_vers number; -- db version number for LOW_VOLUME
1288
1289 l_legislation_code varchar2(30);
1290 l_full_mls boolean;
1291 l_found boolean;
1292 l_tl_name ff_database_items_tl.translated_user_name%type;
1293 --
1294 begin
1295 --
1296 IF (g_triggers_altered) THEN
1297 -- Get the startup mode
1298 startup_mode := ffstup.get_mode (p_business_group_id,
1299 p_legislation_code);
1300 END IF;
1301 --
1302 l_legislation_code := p_legislation_code;
1303 if l_legislation_code is null then
1304 select bg.legislation_code
1305 into l_legislation_code
1306 from per_business_groups_perf bg
1307 where bg.business_group_id = p_business_group_id
1308 ;
1309 end if;
1310 l_full_mls := ff_dbi_utils_pkg.translations_supported(l_legislation_code);
1311
1312 --
1313 -- First check if the save_run_balance flag has been set on the defined
1314 -- balance. If not update the column if required.
1315 --
1316 -- if this procedure has been called from the trigger pay_defined_bal_ari,
1317 -- then the save run balance flag will have been set if it can be set, so
1318 -- don't do the following check as it will cause a mutating table error.
1319 --
1320 if not g_trigger_dfb_ari then
1321 open chk_flag_set(p_defined_balance_id);
1322 fetch chk_flag_set into l_flag_set;
1323 close chk_flag_set;
1324 --
1325 if l_flag_set <> 0 then -- flag not set, attempt to set it
1326 open get_cat_id(p_balance_type_id);
1327 fetch get_cat_id into l_bal_cat_id;
1328 close get_cat_id;
1329 --
1330 -- get the session date or default sysdate
1331 --
1332 open get_sess_date;
1333 fetch get_sess_date into l_sess_date;
1334 if get_sess_date%notfound then
1335 close get_sess_date;
1336 l_sess_date := trunc(sysdate);
1337 end if;
1338 --
1339 l_run_bal_flag := pay_defined_balances_pkg.set_save_run_bals_flag
1340 (p_balance_category_id => l_bal_cat_id
1341 ,p_effective_date => l_sess_date
1342 ,p_balance_dimension_id => p_balance_dimension_id); --
1343 if l_run_bal_flag is not null then
1344 --
1345 -- update the defined balance
1346 --
1347 begin
1348 update pay_defined_balances
1349 set save_run_balance = l_run_bal_flag
1350 where defined_balance_id = p_defined_balance_id;
1351 exception
1352 when others then
1353 hrrbdeib_trace_on;
1354 hr_utility.trace('update pay_def_bal.save_run_balance:def_bal_id:' || to_char(p_defined_balance_id) ||
1355 'to save_run_balance:' || nvl(l_run_bal_flag, 'NULL') || ':');
1356 hrrbdeib_trace_off;
1357 raise;
1358 end;
1359 --
1360 end if; -- flag is null, so dont both to update
1361 --
1362 end if; -- flag is set so dont do anything
1363 end if; -- global is true, so code skipped.
1364 --
1365 -- get details from balance dimension and type
1366 BEGIN
1367 select BALDIM.route_id,
1368 nvl(database_item_function, 'N'),
1369 upper(replace(BALTYPE.balance_name || BALDIM.database_item_suffix,
1370 ' ','_'))
1371 into l_route_id,
1372 l_dbi_function,
1373 l_db_item_name
1374 from pay_balance_dimensions BALDIM,
1375 pay_balance_types BALTYPE
1376 where BALDIM.balance_dimension_id = p_balance_dimension_id
1377 and BALTYPE.balance_type_id = p_balance_type_id;
1378 EXCEPTION WHEN OTHERS THEN
1379 hrrbdeib_trace_on;
1380 hr_utility.trace('missing baldim type info : baldim: ' || to_char(p_balance_dimension_id) ||
1381 ' bal type: ' || to_char(p_balance_type_id));
1382 hrrbdeib_trace_off;
1383 END;
1384 --
1385 create_user_entity
1386 (l_db_item_name,
1387 p_business_group_id,
1388 p_legislation_code,
1389 l_route_id,
1390 'N',
1391 p_defined_balance_id,
1392 'B',
1393 'To hold database items for the Balance '
1394 || l_db_item_name || ' (automatically generated)',
1395 startup_mode,
1396 usr_ent_id
1397 );
1398 --
1399 -- add a Route Parameter value which contains the balance type ID
1400 -- to make the route work (we know sequence is 1)
1401 if (l_dbi_function = 'N') then
1402 route_param_value := p_balance_type_id;
1403 else
1404 route_param_value := p_defined_balance_id;
1405 end if;
1406 insert into ff_route_parameter_values
1407 (route_parameter_id,
1408 user_entity_id,
1409 value)
1410 select RP.route_parameter_id,
1411 usr_ent_id,
1412 to_char(route_param_value)
1413 from ff_route_parameters RP
1414 where RP.route_id = l_route_id
1415 and RP.sequence_no = 1;
1416 if sql%rowcount <> 1 then
1417 hr_utility.set_message(801, 'HR_ERROR');
1418 hrrbdeib_trace_on;
1419 hr_utility.trace('missing seq 1 route param for route : ' || to_char(l_route_id));
1420 hrrbdeib_trace_off;
1421 hr_utility.raise_error;
1422 end if;
1423 --
1424 --
1425 -- Use Rule hint on balances if LOW_VOLUME pay_action_paremeter set
1426 --
1427 -- use caching to avoid repeated finding parameter_value
1428 --
1429 if (cached = FALSE) then
1430 cached := TRUE;
1431 l_ora_db_vers := hr_general2.get_oracle_db_version;
1432 if (nvl(l_ora_db_vers, 0) < 9.0) then
1433 g_low_volume := 'Y';
1434 else
1435 begin
1436 select parameter_value
1437 into g_low_volume
1438 from pay_action_parameters
1439 where parameter_name = 'LOW_VOLUME';
1440 exception
1441 when others then
1442 g_low_volume := 'N';
1443 end;
1444 end if;
1445 end if;
1446
1447 if (l_dbi_function = 'N') then
1448 if (g_low_volume = 'Y') then
1449 l_dbitem_def_text := '/*+'||' RULE*/ nvl(sum(fnd_number.canonical_to_number(TARGET.result_value) * FEED.scale),0) ';
1450 else
1451 l_dbitem_def_text := 'nvl(sum(fnd_number.canonical_to_number(TARGET.result_value) * FEED.scale),0) ';
1452 end if;
1453 --
1454 elsif (l_dbi_function = 'Y') then
1455 l_dbitem_def_text := '1';
1456 else
1457 l_dbitem_def_text := l_dbi_function;
1458 end if;
1459
1460 -- insert a Database Item to hold balance value
1461 create_dbi
1462 (
1463 l_db_item_name,
1464 usr_ent_id,
1465 'N',
1466 l_dbitem_def_text,
1467 'N',
1468 'Current value for balance ' || l_db_item_name || ' (automatically generated)',
1469 startup_mode,
1470 p_legislation_code,
1471 p_business_group_id
1472 );
1473 --
1474 if l_full_mls then
1475 for l in c_language loop
1476 gen_db_tl_dbi_name
1477 (p_balance_type_id => p_balance_type_id
1478 ,p_balance_dimension_id => p_balance_dimension_id
1479 ,p_language => l.language_code
1480 ,p_tl_name => l_tl_name
1481 ,p_found => l_found
1482 );
1483 --
1484 -- Update the translated database item.
1485 --
1486 if l_found then
1487 update_tl_dbi_name
1488 (p_user_name => l_db_item_name
1489 ,p_user_entity_id => usr_ent_id
1490 ,p_leg_code => p_legislation_code
1491 ,p_bg_id => p_business_group_id
1492 ,p_startup_mode => startup_mode
1493 ,p_language => l.language_code
1494 ,p_tl_user_name => l_tl_name
1495 );
1496 end if;
1497 end loop;
1498 end if;
1499 --
1500 --
1501 create_alternative_dbis(p_defined_balance_id,
1502 p_balance_dimension_id,
1503 p_balance_type_id,
1504 p_business_group_id,
1505 p_legislation_code,
1506 l_db_item_name,
1507 startup_mode
1508 );
1509 --
1510 end new_defined_balance;
1511 --
1512 /*------------------- refresh_defined_balances ---------------------------*/
1513 /*
1514 * This routine creates all database items based on defined balances
1515 * in the system. The routine assumes that no such database items currently
1516 * exist.
1517 */
1518 procedure refresh_defined_balances(p_worker_id in number default 0,
1519 p_maxworkers in number default 1) is
1520 cursor c1 is select defined_balance_id,
1521 balance_dimension_id,
1522 balance_type_id,
1523 business_group_id,
1524 legislation_code,
1525 save_run_balance
1526 from pay_defined_balances b
1527 where not exists (
1528 select null from ff_user_entities u
1529 where b.defined_balance_id = u.creator_id
1530 and u.creator_type = 'B')
1531 and mod(defined_balance_id, p_maxworkers) = p_worker_id
1532 order by b.defined_balance_id;
1533
1534 cursor c2 is select defined_balance_id,
1535 balance_dimension_id,
1536 balance_type_id,
1537 business_group_id,
1538 legislation_code,
1539 save_run_balance
1540 from pay_defined_balances b
1541 where /* def bal ue simply doesn't exist but has an associated pdr */
1542 ((
1543 not exists (
1544 select null from ff_user_entities u
1545 where b.defined_balance_id = u.creator_id
1546 and u.creator_type = 'RB')
1547 and exists
1548 (select null
1549 from pay_dimension_routes pdr
1550 where pdr.balance_dimension_id = b.balance_dimension_id)
1551 )
1552 OR /* def bal ue does exists but has a missing ue pdr */
1553 (
1554 exists (
1555 select pdr.balance_dimension_id
1556 from pay_dimension_routes pdr
1557 where pdr.balance_dimension_id = b.balance_dimension_id
1558 and not exists (select null
1559 from ff_user_entities ue
1560 where ue.creator_id = b.defined_balance_id
1561 and ue.route_id = pdr.route_id
1562 and ue.creator_type = 'RB'))
1563 ))
1564 and mod(defined_balance_id, p_maxworkers) = p_worker_id
1565 order by b.defined_balance_id;
1566
1567 l_db_item_name ff_database_items.user_name%type;
1568 startup_mode varchar2(10);
1569 l_loop_cnt number;
1570
1571 begin
1572
1573 hrrbdeib_trace_on;
1574 hr_utility.trace('entering refresh_defined_balances all' ||
1575 ' worker: ' || to_char(p_worker_id + 1) || '/' ||
1576 to_char(p_maxworkers));
1577 hrrbdeib_trace_off;
1578
1579 l_loop_cnt := 0;
1580
1581 -- create missing B and RB data
1582
1583 for c1rec in c1 loop
1584 hrrbdeib_trace_on;
1585 hr_utility.trace('RDB:B :' || to_char(p_worker_id + 1) || ':' ||
1586 c1rec.legislation_code || '.' ||
1587 to_char(c1rec.business_group_id) || '.' ||
1588 to_char(c1rec.defined_balance_id) || '.' ||
1589 to_char(c1rec.balance_dimension_id) || '.' ||
1590 to_char(c1rec.balance_type_id) || '.' ||
1591 c1rec.save_run_balance);
1592 hrrbdeib_trace_off;
1593
1594 recreate_defined_balance
1595 (p_defined_balance_id => c1rec.defined_balance_id,
1596 p_balance_dimension_id => c1rec.balance_dimension_id,
1597 p_balance_type_id => c1rec.balance_type_id,
1598 p_business_group_id => c1rec.business_group_id,
1599 p_legislation_code => c1rec.legislation_code);
1600
1601 l_loop_cnt := l_loop_cnt + 1;
1602 if l_loop_cnt > 100 then
1603 l_loop_cnt := 0;
1604 commit;
1605 end if;
1606
1607 end loop;
1608
1609 -- create missing RB data which can happen if we had some or all B entities
1610 -- before running the c1 loop
1611 -- already created but no associated RB row as in this case the c1 cursor would -- not note it needs to create the missing RB row for an already existing B row
1612 -- however, as we only want to recreate the RB row we will create a new proc
1613
1614 for c2rec in c2 loop
1615
1616 hrrbdeib_trace_on;
1617 hr_utility.trace('RDB:RB:' || to_char(p_worker_id + 1) || ':' ||
1618 c2rec.legislation_code || '.' ||
1619 to_char(c2rec.business_group_id) || '.' ||
1620 to_char(c2rec.defined_balance_id) || '.' ||
1621 to_char(c2rec.balance_dimension_id) || '.' ||
1622 to_char(c2rec.balance_type_id) || '.' ||
1623 c2rec.save_run_balance);
1624 hrrbdeib_trace_off;
1625
1626 BEGIN
1627 select upper(replace(BALTYPE.balance_name ||
1628 BALDIM.database_item_suffix,
1629 ' ','_'))
1630 into l_db_item_name
1631 from pay_balance_dimensions BALDIM,
1632 pay_balance_types BALTYPE
1633 where BALDIM.balance_dimension_id = c2rec.balance_dimension_id
1634 and BALTYPE.balance_type_id = c2rec.balance_type_id;
1635 EXCEPTION WHEN OTHERS THEN
1636 hrrbdeib_trace_on;
1637 hr_utility.trace('missing baldim type2 info : baldim: ' ||
1638 to_char(c2rec.balance_dimension_id) ||
1639 ' bal type: ' || to_char(c2rec.balance_type_id));
1640 hrrbdeib_trace_off;
1641 END;
1642
1643 IF (g_triggers_altered) THEN
1644 -- Get the startup mode
1645 startup_mode := ffstup.get_mode (c2rec.business_group_id,
1646 c2rec.legislation_code);
1647 END IF;
1648
1649 -- delete_compiled_formula_priv(c2rec.defined_balance_id , 'RB', '%',
1650 -- c2rec.legislation_code);
1651
1652 delete ff_user_entities
1653 where creator_id = c2rec.defined_balance_id
1654 and creator_type = 'RB';
1655
1656 create_alternative_dbis(c2rec.defined_balance_id,
1657 c2rec.balance_dimension_id,
1658 c2rec.balance_type_id,
1659 c2rec.business_group_id,
1660 c2rec.legislation_code,
1661 l_db_item_name,
1662 startup_mode
1663 );
1664
1665 l_loop_cnt := l_loop_cnt + 1;
1666 if l_loop_cnt > 100 then
1667 l_loop_cnt := 0;
1668 commit;
1669 end if;
1670
1671 end loop;
1672
1673 hrrbdeib_trace_on;
1674 hr_utility.trace('leaving refresh_defined_balances all' ||
1675 ' worker: ' || to_char(p_worker_id + 1) || '/' ||
1676 to_char(p_maxworkers));
1677 hrrbdeib_trace_off;
1678
1679 end refresh_defined_balances;
1680 --
1681 /*------------------- refresh_defined_balances ---------------------------*/
1682 /*
1683 * This routine creates all database items based on defined balances
1684 * in the system. The routine assumes that no such database items currently
1685 * exist.
1686 */
1687 procedure refresh_defined_balances(p_leg_code in varchar2,
1688 p_worker_id in number default 0,
1689 p_maxworkers in number default 1) is
1690
1691 cursor c1 is select defined_balance_id,
1692 balance_dimension_id,
1693 balance_type_id,
1694 business_group_id,
1695 legislation_code,
1696 save_run_balance
1697 from pay_defined_balances a
1698 where not exists (
1699 select null from ff_user_entities u
1700 where a.defined_balance_id = u.creator_id
1701 and u.creator_type = 'B')
1702 and mod(defined_balance_id, p_maxworkers) = p_worker_id
1703 and (a.legislation_code = p_leg_code
1704 or exists (select null
1705 from per_business_groups_perf b
1706 where a.business_group_id = b.business_group_id
1707 and nvl(b.legislation_code, p_leg_code) = p_leg_code))
1708 order by a.defined_balance_id;
1709
1710 cursor c2 is select defined_balance_id,
1711 balance_dimension_id,
1712 balance_type_id,
1713 business_group_id,
1714 legislation_code,
1715 save_run_balance
1716 from pay_defined_balances a
1717 where /* def bal ue simply doesn't exist but has an associated pdr */
1718 ((
1719 not exists (
1720 select null from ff_user_entities u
1721 where a.defined_balance_id = u.creator_id
1722 and u.creator_type = 'RB')
1723 and exists
1724 (select null
1725 from pay_dimension_routes pdr
1726 where pdr.balance_dimension_id = a.balance_dimension_id)
1727 )
1728 OR /* def bal ue does exists but has a missing ue pdr */
1729 (
1730 exists (
1731 select pdr.balance_dimension_id
1732 from pay_dimension_routes pdr
1733 where pdr.balance_dimension_id = a.balance_dimension_id
1734 and not exists (select null
1735 from ff_user_entities ue
1736 where ue.creator_id = a.defined_balance_id
1737 and ue.route_id = pdr.route_id
1738 and ue.creator_type = 'RB'))
1739 ))
1740 and mod(defined_balance_id, p_maxworkers) = p_worker_id
1741 and (a.legislation_code = p_leg_code
1742 or exists (select null
1743 from per_business_groups_perf b
1744 where a.business_group_id = b.business_group_id
1745 and nvl(b.legislation_code, p_leg_code) = p_leg_code))
1746 order by a.defined_balance_id;
1747
1748 l_db_item_name ff_database_items.user_name%type;
1749 startup_mode varchar2(10);
1750 l_loop_cnt number;
1751
1752 begin
1753
1754 hrrbdeib_trace_on;
1755 hr_utility.trace('entering refresh_defined_balances ' || p_leg_code ||
1756 ' worker: ' || to_char(p_worker_id + 1) || '/' ||
1757 to_char(p_maxworkers));
1758 hrrbdeib_trace_off;
1759
1760 l_loop_cnt := 0;
1761
1762 -- create missing B and RB data
1763
1764 for c1rec in c1 loop
1765
1766 hrrbdeib_trace_on;
1767 hr_utility.trace('RDB:B :' || to_char(p_worker_id + 1) || ':' ||
1768 c1rec.legislation_code || '.' ||
1769 to_char(c1rec.business_group_id) || '.' ||
1770 to_char(c1rec.defined_balance_id) || '.' ||
1771 to_char(c1rec.balance_dimension_id) || '.' ||
1772 to_char(c1rec.balance_type_id) || '.' ||
1773 c1rec.save_run_balance);
1774 hrrbdeib_trace_off;
1775
1776 recreate_defined_balance
1777 (p_defined_balance_id => c1rec.defined_balance_id,
1778 p_balance_dimension_id => c1rec.balance_dimension_id,
1779 p_balance_type_id => c1rec.balance_type_id,
1780 p_business_group_id => c1rec.business_group_id,
1781 p_legislation_code => c1rec.legislation_code);
1782
1783 l_loop_cnt := l_loop_cnt + 1;
1784 if l_loop_cnt > 100 then
1785 l_loop_cnt := 0;
1786 commit;
1787 end if;
1788
1789 end loop;
1790
1791 -- create missing RB data which can happen if we had some or all B entities
1792 -- before running the c1 loop
1793 -- already created but no associated RB row as in this case the c1 cursor would -- not note it needs to create the missing RB row for an already existing B row
1794 -- however, as we only want to recreate the RB row we will create a new proc
1795
1796 for c2rec in c2 loop
1797
1798 hrrbdeib_trace_on;
1799 hr_utility.trace('RDB:RB:' || to_char(p_worker_id + 1) || ':' ||
1800 c2rec.legislation_code || '.' ||
1801 to_char(c2rec.business_group_id) || '.' ||
1802 to_char(c2rec.defined_balance_id) || '.' ||
1803 to_char(c2rec.balance_dimension_id) || '.' ||
1804 to_char(c2rec.balance_type_id) || '.' ||
1805 c2rec.save_run_balance);
1806 hrrbdeib_trace_off;
1807
1808 BEGIN
1809 select upper(replace(BALTYPE.balance_name ||
1810 BALDIM.database_item_suffix,
1811 ' ','_'))
1812 into l_db_item_name
1813 from pay_balance_dimensions BALDIM,
1814 pay_balance_types BALTYPE
1815 where BALDIM.balance_dimension_id = c2rec.balance_dimension_id
1816 and BALTYPE.balance_type_id = c2rec.balance_type_id;
1817 EXCEPTION WHEN OTHERS THEN
1818 hrrbdeib_trace_on;
1819 hr_utility.trace('missing baldim type2 info : baldim: ' ||
1820 to_char(c2rec.balance_dimension_id) ||
1821 ' bal type: ' || to_char(c2rec.balance_type_id));
1822 hrrbdeib_trace_off;
1823 END;
1824
1825 IF (g_triggers_altered) THEN
1826 -- Get the startup mode
1827 startup_mode := ffstup.get_mode (c2rec.business_group_id,
1828 c2rec.legislation_code);
1829 END IF;
1830
1831 -- delete_compiled_formula_priv(c2rec.defined_balance_id , 'RB', '%',
1832 -- c2rec.legislation_code);
1833
1834 delete ff_user_entities
1835 where creator_id = c2rec.defined_balance_id
1836 and creator_type = 'RB';
1837
1838 create_alternative_dbis(c2rec.defined_balance_id,
1839 c2rec.balance_dimension_id,
1840 c2rec.balance_type_id,
1841 c2rec.business_group_id,
1842 c2rec.legislation_code,
1843 l_db_item_name,
1844 startup_mode
1845 );
1846
1847 l_loop_cnt := l_loop_cnt + 1;
1848 if l_loop_cnt > 100 then
1849 l_loop_cnt := 0;
1850 commit;
1851 end if;
1852
1853 end loop;
1854
1855 hrrbdeib_trace_on;
1856 hr_utility.trace('leaving refresh_defined_balances ' || p_leg_code ||
1857 ' worker: ' || to_char(p_worker_id + 1) || '/' ||
1858 to_char(p_maxworkers));
1859 hrrbdeib_trace_off;
1860
1861 end refresh_defined_balances;
1862 --
1863 /*------------------- recreate_defined_balance ---------------------------*/
1864 /*
1865 * This routine deletes and creates database items based on a given
1866 * defined balance in the system.
1867 */
1868 procedure recreate_defined_balance(p_defined_balance_id in number,
1869 p_balance_dimension_id in number,
1870 p_balance_type_id in number,
1871 p_business_group_id in number,
1872 p_legislation_code in varchar2)
1873 is
1874 begin
1875 --
1876 -- delete_compiled_formula_priv(p_defined_balance_id, 'B', '%', p_legislation_code);
1877 -- delete_compiled_formula_priv(p_defined_balance_id, 'RB', '%', p_legislation_code);
1878
1879 delete from ff_user_entities
1880 where creator_id = p_defined_balance_id
1881 and creator_type = 'B';
1882 --
1883 delete from ff_user_entities
1884 where creator_id = p_defined_balance_id
1885 and creator_type = 'RB';
1886 --
1887 hrdyndbi.new_defined_balance
1888 (p_defined_balance_id => p_defined_balance_id,
1889 p_balance_dimension_id => p_balance_dimension_id,
1890 p_balance_type_id => p_balance_type_id,
1891 p_business_group_id => p_business_group_id,
1892 p_legislation_code => p_legislation_code);
1893 --
1894 end;
1895 --
1896 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1897 -- +
1898 -- insert_parameter_value +
1899 -- +
1900 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1901 /*
1902 NAME
1903 insert_parameter_value - insert the entity value into the route parameter
1904 table
1905 DESCRIPTION
1906 This routine is called if the routes contains where clause fillers (Ux).
1907 Get the route parameter id from the ff_route_parameters table and insert
1908 the actual entity value into the ff_route_parameter_values table. For
1909 example, when an element type is created, the value inserted into the
1910 ff_route_parameter_values table is the element type id.
1911 The parameters passed are:
1912 p_value - the actual where clause filler value
1913 p_sequence_no - the number of the where clause filler, eg. 1 for U1.
1914 */
1915 procedure insert_parameter_value
1916 (
1917 p_value in varchar2,
1918 p_sequence_no in number
1919 ) is
1920 l_route_parameter_id number;
1921 l_route_id number;
1922 l_user_entity_id number;
1923 l_created_by ff_user_entities.created_by%type;
1924 l_last_login ff_user_entities.last_update_login%type;
1925 l_user_entity_name ff_user_entities.user_entity_name%type;
1926 l_ent_bg_id ff_user_entities.BUSINESS_GROUP_ID%type;
1927 l_ent_lc ff_user_entities.LEGISLATION_CODE%type;
1928 l_route_name ff_routes.route_name%type;
1929 l_route_cd varchar2(60);
1930 l_route_lud varchar2(60);
1931 l_route_lub number;
1932 BEGIN
1933 --
1934 -- get the user entity id to be used:
1935 --
1936 select ff_user_entities_s.currval
1937 into l_user_entity_id
1938 from dual;
1939 --
1940 -- get the relevant information for the user entity we are using
1941 --
1942 BEGIN
1943 select RPARAM.route_parameter_id,
1944 ENTITY.created_by,
1945 ENTITY.last_update_login,
1946 ENTITY.user_entity_name
1947 into l_route_parameter_id,
1948 l_created_by,
1949 l_last_login,
1950 l_user_entity_name
1951 from ff_user_entities ENTITY
1952 , ff_route_parameters RPARAM
1953 where ENTITY.user_entity_id = l_user_entity_id
1954 and RPARAM.route_id = ENTITY.route_id
1955 and RPARAM.sequence_no = p_sequence_no;
1956 EXCEPTION WHEN OTHERS THEN
1957 hrrbdeib_trace_on;
1958 hr_utility.trace(SQLCODE || '-' || SQLERRM);
1959 hr_utility.trace('insert param val');
1960 hr_utility.trace(' seqno: ' || to_char(p_sequence_no));
1961 hr_utility.trace('Checking for user entity ' || to_char(l_user_entity_id)
1962 || ' details');
1963 BEGIN
1964 select ENTITY.user_entity_name,
1965 ENTITY.route_id,
1966 ENTITY.BUSINESS_GROUP_ID,
1967 ENTITY. LEGISLATION_CODE
1968 into l_user_entity_name,
1969 l_route_id,
1970 l_ent_bg_id,
1971 l_ent_lc
1972 from ff_user_entities ENTITY
1973 where ENTITY.user_entity_id = l_user_entity_id;
1974
1975 hr_utility.trace('entity_name: ' || l_user_entity_name);
1976 hr_utility.trace('entity route id: ' || to_char(l_route_id));
1977 hr_utility.trace('entity BG id: ' || to_char(l_ent_bg_id));
1978 hr_utility.trace('entity LC: ' || l_ent_lc);
1979
1980 IF l_route_id is not null THEN
1981 select route_name,
1982 to_char(CREATION_DATE, 'DD-MM-YYYY'),
1983 to_char(LAST_UPDATE_DATE, 'DD-MM-YYYY'),
1984 LAST_UPDATED_BY
1985 into l_route_name,
1986 l_route_cd,
1987 l_route_lud,
1988 l_route_lub
1989 from ff_routes
1990 where route_id = l_route_id;
1991
1992 hr_utility.trace('route_name: ' || l_route_name);
1993 hr_utility.trace('route creation date: ' || l_route_cd);
1994 hr_utility.trace('route LUD: ' || l_route_lud);
1995 hr_utility.trace('route LUB: ' || to_char(l_route_lub));
1996 hrrbdeib_trace_off;
1997
1998 END IF;
1999 EXCEPTION WHEN OTHERS THEN NULL;
2000 END;
2001
2002 raise;
2003
2004 END;
2005 --
2006 -- populate the route parameter value table with the entity value
2007 --
2008 insert into ff_route_parameter_values (
2009 user_entity_id,
2010 route_parameter_id,
2011 value,
2012 last_update_date,
2013 last_updated_by,
2014 last_update_login,
2015 created_by,
2016 creation_date)
2017 --
2018 values (l_user_entity_id,
2019 l_route_parameter_id,
2020 p_value,
2021 sysdate,
2022 l_created_by,
2023 l_last_login,
2024 l_created_by,
2025 sysdate);
2026 --
2027 END insert_parameter_value;
2028 --
2029 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2030 -- +
2031 -- insert_database_item +
2032 -- +
2033 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2034 /*
2035 NAME
2036 insert_database_item - load the database item.
2037 --
2038 DESCRIPTION
2039 Internal interface for insert_database_item.
2040
2041 This is the external insert_database_item but with extra parameters
2042 extra parameters so that only a single base database item is
2043 created.
2044
2045 If P_FULL_MLS is true then this call just creates a single base
2046 database item whose name is returned in P_BASE_DBI_NAME. If
2047 P_FULL_MLS is false then this call performs the old pseudo-MLS
2048 generation of multiple database items in FF_DATABASE_ITEMS, and
2049 P_BASE_DBI_NAME is ignored.
2050 */
2051 procedure insert_database_item
2052 (
2053 p_entity_name in varchar2,
2054 p_item_name in varchar2,
2055 p_data_type in varchar2,
2056 p_definition_text in varchar2,
2057 p_null_allowed_flag in varchar2,
2058 p_description in varchar2,
2059 p_user_entity_id in number,
2060 p_full_mls in boolean,
2061 p_base_dbi_name out nocopy varchar2
2062 ) is
2063 l_item_name ff_database_items.user_name%type;
2064 l_user_name ff_database_items.user_name%type;
2065 l_user_entity_id number;
2066 l_created_by ff_user_entities.created_by%type;
2067 l_last_login ff_user_entities.last_update_login%type;
2068 l_db number;
2069 l_exists VARCHAR2(2);
2070 l_clash boolean;
2071 --
2072 startup_mode varchar2(10);
2073 rgeflg varchar2(1);
2074 bg_id number;
2075 leg_code varchar2(30);
2076 --
2077 cursor c_language is
2078 select language_code
2079 from fnd_languages
2080 where installed_flag in ('I','B');
2081 --
2082 cursor c_dbi_exists(c_user_name IN VARCHAR2,
2083 c_user_entity_id IN VARCHAR2) IS
2084 SELECT 'Y'
2085 FROM ff_database_items
2086 WHERE user_name = c_user_name
2087 AND user_entity_id = c_user_entity_id;
2088 --
2089 BEGIN
2090 --
2091 --
2092 -- get the user entity id to be used:
2093 --
2094 if (p_user_entity_id is not NULL) then
2095 l_user_entity_id:=p_user_entity_id;
2096 else
2097 select ff_user_entities_s.currval
2098 into l_user_entity_id
2099 from dual;
2100 end if;
2101
2102 --
2103 -- get the relevant information for the user entity we are using
2104 --
2105 select created_by,
2106 last_update_login,
2107 business_group_id,
2108 legislation_code
2109 into l_created_by,
2110 l_last_login,
2111 bg_id,
2112 leg_code
2113 from ff_user_entities
2114 where user_entity_id = l_user_entity_id;
2115 --
2116 IF (g_triggers_altered) THEN
2117 -- Get the startup mode
2118 startup_mode := ffstup.get_mode (bg_id, leg_code);
2119 ELSE
2120 -- get the security group id which won't have been populated yet.
2121 g_security_group_id := fnd_global.lookup_security_group('NAME_TRANSLATIONS', 3);
2122 END IF;
2123
2124 if not p_full_mls then
2125 --
2126 -- This is the pseudo-MLS process where the base table values are
2127 -- appended with lookup meanings for all languages.
2128 --
2129 for c_lang_rec in c_language loop
2130 --
2131 -- This used to be a cursor for-loop.
2132 --
2133 l_item_name := p_item_name;
2134 replace_code_name
2135 (p_language_code => c_lang_rec.language_code
2136 ,p_item_name => l_item_name
2137 );
2138
2139 --
2140 -- If the Database item name is greater than 80, then we have no choice
2141 -- but to truncate the trailing characters. This may lead to the insert
2142 -- failing due to duplicate DB item names.
2143 -- Note the use of substrb.
2144 --
2145 -- For utf8 support we now substr 80 so :
2146 -- (a). for singlebyte environments get same sa previous versions of
2147 -- this package and thus data integrity.
2148 -- (b). for multibyte environments get 80 multibyte characters ... using
2149 -- upto 240 bytes.
2150
2151
2152 l_user_name := substr ((p_entity_name || '_' || l_item_name), 1, 80);
2153
2154 --
2155 -- str2dbiname does all the checks performed here before including
2156 -- checkformat and, if necessary, quoting (see bug 3723715).
2157 --
2158 l_user_name := ff_dbi_utils_pkg.str2dbiname(p_str => l_user_name);
2159
2160 --
2161 -- load the database name into the database item table
2162 -- As this is now done for each installed language, we should
2163 -- check that the user_name, user_entitiy_id doesn't already
2164 -- exist.
2165 --
2166 OPEN c_dbi_exists(l_user_name, l_user_entity_id);
2167 FETCH c_dbi_exists INTO l_exists;
2168 IF c_dbi_exists%NOTFOUND then
2169 BEGIN
2170 --
2171 -- Make sure that the name does not clash with FF_DATABASE_ITEMS,
2172 -- FF_DATABASE_ITEMS_TL, or FF_CONTEXT rows.
2173 --
2174 check_for_dbi_clash
2175 (p_user_name => l_user_name
2176 ,p_ue_id => l_user_entity_id
2177 ,p_leg_code => leg_code
2178 ,p_bg_id => bg_id
2179 ,p_startup_mode => startup_mode
2180 ,p_clash => l_clash
2181 );
2182 if not l_clash then
2183 insert into ff_database_items
2184 (user_name
2185 ,user_entity_id
2186 ,data_type
2187 ,definition_text
2188 ,null_allowed_flag
2189 ,description
2190 ,last_update_date
2191 ,last_updated_by
2192 ,last_update_login
2193 ,created_by
2194 ,creation_date
2195 )
2196 values
2197 (l_user_name
2198 ,l_user_entity_id
2199 ,p_data_type
2200 ,p_definition_text
2201 ,p_null_allowed_flag
2202 ,p_description
2203 ,sysdate
2204 ,l_created_by
2205 ,l_last_login
2206 ,l_created_by
2207 ,sysdate
2208 );
2209 else
2210 --
2211 -- For the pseudo-MLS process it is possible to get name
2212 -- clashes because translation patches may not have been
2213 -- applied.
2214 --
2215 null;
2216 end if;
2217 EXCEPTION
2218 WHEN OTHERS THEN
2219 hrrbdeib_trace_on;
2220 IF (g_triggers_altered) THEN
2221 hr_utility.trace('ins dbi: g_trigger TRUE');
2222 ELSE
2223 hr_utility.trace('ins dbi: g_trigger FALSE');
2224 END IF;
2225 hr_utility.trace('ins dbi: dbi: ' || l_user_name);
2226 hr_utility.trace('ins dbi: ue: ' || p_entity_name);
2227 hr_utility.trace('ins dbi: item: ' || l_item_name);
2228 hr_utility.trace('ins dbi: ueid: ' || to_char(l_user_entity_id));
2229 hr_utility.trace('ins dbi: lang: ' || c_lang_rec.language_code);
2230 hrrbdeib_trace_off;
2231
2232 if c_dbi_exists%isopen then
2233 close c_dbi_exists;
2234 end if;
2235 raise;
2236 END;
2237 END IF;
2238 CLOSE c_dbi_exists;
2239 --
2240 -- Repeat the process for the next language
2241 --
2242 end loop;
2243 --
2244 -- For the full MLS process, this code only generates a single base
2245 -- table database item based upon the supplied item name.
2246 --
2247 else
2248 --
2249 -- The translations will be done in other code to be reused elsewhere.
2250 --
2251 l_user_name := substr ((p_entity_name || '_' || p_item_name), 1, 80);
2252
2253 --
2254 -- str2dbiname does all the checks performed here before including
2255 -- checkformat and, if necessary, quoting (see bug 3723715).
2256 --
2257 l_user_name := ff_dbi_utils_pkg.str2dbiname(p_str => l_user_name);
2258
2259 OPEN c_dbi_exists(l_user_name, l_user_entity_id);
2260 FETCH c_dbi_exists INTO l_exists;
2261 IF c_dbi_exists%NOTFOUND then
2262 BEGIN
2263 --
2264 -- Make sure that the name does not clash with FF_DATABASE_ITEMS,
2265 -- FF_DATABASE_ITEMS_TL, or FF_CONTEXT rows.
2266 --
2267 check_for_dbi_clash
2268 (p_user_name => l_user_name
2269 ,p_ue_id => l_user_entity_id
2270 ,p_leg_code => leg_code
2271 ,p_bg_id => bg_id
2272 ,p_startup_mode => startup_mode
2273 ,p_clash => l_clash
2274 );
2275 if not l_clash then
2276 insert into ff_database_items
2277 (user_name
2278 ,user_entity_id
2279 ,data_type
2280 ,definition_text
2281 ,null_allowed_flag
2282 ,description
2283 ,last_update_date
2284 ,last_updated_by
2285 ,last_update_login
2286 ,created_by
2287 ,creation_date
2288 )
2289 values
2290 (l_user_name
2291 ,l_user_entity_id
2292 ,p_data_type
2293 ,p_definition_text
2294 ,p_null_allowed_flag
2295 ,p_description
2296 ,sysdate
2297 ,l_created_by
2298 ,l_last_login
2299 ,l_created_by
2300 ,sysdate
2301 );
2302 else
2303 --
2304 -- For the full MLS process, a name clash is a fatal error.
2305 --
2306 hr_utility.set_message (801, 'PAY_33916_DYN_DBI_NAME_CLASH');
2307 hr_utility.set_message_token('1', l_user_name);
2308 hr_utility.raise_error;
2309 end if;
2310 EXCEPTION
2311 WHEN OTHERS THEN
2312 hrrbdeib_trace_on;
2313 IF (g_triggers_altered) THEN
2314 hr_utility.trace('ins dbi: g_trigger TRUE');
2315 ELSE
2316 hr_utility.trace('ins dbi: g_trigger FALSE');
2317 END IF;
2318 hr_utility.trace('ins dbi: dbi: ' || l_user_name);
2319 hr_utility.trace('ins dbi: ue: ' || p_entity_name);
2320 hr_utility.trace('ins dbi: item: ' || l_item_name);
2321 hr_utility.trace('ins dbi: ueid: ' || to_char(l_user_entity_id));
2322 hr_utility.trace('ins dbi: base name' );
2323 hrrbdeib_trace_off;
2324
2325 if c_dbi_exists%isopen then
2326 close c_dbi_exists;
2327 end if;
2328 raise;
2329 END;
2330 END IF;
2331 CLOSE c_dbi_exists;
2332
2333 p_base_dbi_name := l_user_name;
2334 end if;
2335 END insert_database_item;
2336 --
2337 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2338 -- +
2339 -- insert_database_item +
2340 -- +
2341 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2342 /*
2343 NAME
2344 insert_database_item - load the database item.
2345 --
2346 DESCRIPTION
2347 Insert a new row into the database_items table. The actual database
2348 name is a concatenation of the supplied entity name and the database
2349 name as:
2350 --
2351 <ENTITY_NAME>_<ITEM_NAME>
2352 --
2353 The <ITEM_NAME> parameter is checked to see if its name translation is
2354 to be used. This is now done for each installed language (the c_language
2355 cursor loop), to maintain the current Japanese functionality of using
2356 the name translations lookup to translation JP-specific elements into
2357 Japanese. This functionality leads to pseudo-translated multilingual
2358 DEH DBIs, and currently does nothing with the translation table. For
2359 this multilanguage translation to
2360 work, we can not access the data through the single language views,
2361 either HR_LOOKUPS or FND_LOOKUPS, but instead have to access the base table
2362 directly, filtering by the required language.
2363
2364 The parameters passed are:
2365 p_entity_name - The first half of the database name
2366 p_item_name - The second half of the database name
2367 p_data_type - Data type T = text, N = number, D = date.
2368 p_definition_text - The text after the 'select' statment and before
2369 the 'from' that is used to retrieve the data.
2370 p_null_allowed_flag - Y or N, can the database item be null.
2371 p_description - The description of the database item
2372 */
2373 procedure insert_database_item
2374 (
2375 p_entity_name in varchar2,
2376 p_item_name in varchar2,
2377 p_data_type in varchar2,
2378 p_definition_text in varchar2,
2379 p_null_allowed_flag in varchar2,
2380 p_description in varchar2,
2381 p_user_entity_id in number
2382 ) is
2383 l_base_dbi_name varchar2(2000);
2384 begin
2385 --
2386 -- This call must generate the old-style pseudo-MLS database items
2387 -- so P_FULL_MLS is FALSE.
2388 --
2389 insert_database_item
2390 (
2391 p_entity_name => p_entity_name,
2392 p_item_name => p_item_name,
2393 p_data_type => p_data_type,
2394 p_definition_text => p_definition_text,
2395 p_null_allowed_flag => p_null_allowed_flag,
2396 p_description => p_description,
2397 p_user_entity_id => p_user_entity_id,
2398 p_full_mls => false,
2399 p_base_dbi_name => l_base_dbi_name
2400 );
2401 end insert_database_item;
2402 --
2403 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2404 -- +
2405 -- insert_user_entity +
2406 -- +
2407 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2408 /*
2409 NAME
2410 insert_user_entity - load the element type information into user
2411 entity and route parameter value tables
2412 --
2413 DESCRIPTION
2414 This is the first general purpose routine that should be called by the
2415 main procedures (xxx_dict). It defines an entity, that the other
2416 procedures ('insert_parameter_value' and 'insert_database_item')
2417 reference.
2418 NB insert_user_entity_main is overloaded by 2 insert_user_entity
2419 procedures: one that is passed the out parameter p_record_inserted
2420 and one that uses its own local p_record_inserted paramter (whose
2421 values is subsequently ignored).
2422 The parameters passed are:
2423 p_route_name - the route name to be used, this must already be
2424 seeded in the table ff_routes.
2425 p_user_entity_name - The name of the user entity.
2426 p_entity_description- The description of the entity.
2427 p_not_found_flag - Y/ N, Y= the database item may not be found in
2428 some cases, N= it will ALWAYS return a value.
2429 p_creator_type - Indicates which type of DB items are to be
2430 created, eg. E = element type.
2431 p_creator_id - Further defines who created the DB items, for
2432 example, element type id.
2433 p_business_group_id - If this is null, the item may be seen by all
2434 business groups.
2435 p_legislation_code - The legisaltion code, null = generic.
2436 p_created_by - Used in the AOL columns of the database.
2437 p_last_login - Used in the AOL columns of the database.
2438 p_record_inserted - Boolean indicating whether insertion happened
2439 */
2440 --
2441 -- insert_user_entity called with p_record_inserted
2442 --
2443 procedure insert_user_entity
2444 (
2445 p_route_name in varchar2,
2446 p_user_entity_name in varchar2,
2447 p_entity_description in varchar2,
2448 p_not_found_flag in varchar2,
2449 p_creator_type in varchar2,
2450 p_creator_id in number,
2451 p_business_group_id in number,
2452 p_legislation_code in varchar2,
2453 p_created_by in number,
2454 p_last_login in number,
2455 p_record_inserted out nocopy boolean
2456 ) is
2457 l_user_entity_name ff_user_entities.user_entity_name%type;
2458 BEGIN
2459 --
2460 -- simply call insert_user_entity_main
2461 --
2462 -- mkandasa substr'd user entity name to 80. Bug fix 2073022.
2463 l_user_entity_name := substr(p_user_entity_name,1,80);
2464
2465 insert_user_entity_main( p_route_name,
2466 l_user_entity_name,
2467 p_entity_description,
2468 p_not_found_flag,
2469 p_creator_type,
2470 p_creator_id,
2471 p_business_group_id,
2472 p_legislation_code,
2473 p_created_by,
2474 p_last_login,
2475 p_record_inserted);
2476 END insert_user_entity;
2477 --
2478 -- insert_user_entity called without p_record_inserted
2479 --
2480 procedure insert_user_entity
2481 (
2482 p_route_name in varchar2,
2483 p_user_entity_name in varchar2,
2484 p_entity_description in varchar2,
2485 p_not_found_flag in varchar2,
2486 p_creator_type in varchar2,
2487 p_creator_id in number,
2488 p_business_group_id in number,
2489 p_legislation_code in varchar2,
2490 p_created_by in number,
2491 p_last_login in number
2492 ) is
2493 l_record_inserted boolean;
2494 BEGIN
2495 --
2496 -- call insert_user_entity_main with l_record_inserted
2497 --
2498 insert_user_entity_main( p_route_name,
2499 p_user_entity_name,
2500 p_entity_description,
2501 p_not_found_flag,
2502 p_creator_type,
2503 p_creator_id,
2504 p_business_group_id,
2505 p_legislation_code,
2506 p_created_by,
2507 p_last_login,
2508 l_record_inserted);
2509 END insert_user_entity;
2510 --
2511 -- main insert user entity procedure
2512 --
2513 procedure insert_user_entity_main
2514 (
2515 p_route_name in varchar2,
2516 p_user_entity_name in varchar2,
2517 p_entity_description in varchar2,
2518 p_not_found_flag in varchar2,
2519 p_creator_type in varchar2,
2520 p_creator_id in number,
2521 p_business_group_id in number,
2522 p_legislation_code in varchar2,
2523 p_created_by in number,
2524 p_last_login in number,
2525 p_record_inserted out nocopy boolean
2526 ) is
2527 l_route_id number;
2528 l_user_entities_seq number;
2529 l_dummy_fetch_var number;
2530 l_user_entity_name ff_database_items.user_name%type;
2531 startup_mode varchar2(10);
2532 rgeflg varchar2(1);
2533 l_message varchar2(255);
2534
2535 BEGIN
2536 --
2537 -- get the user entity id from its sequence
2538 --
2539 begin
2540 SELECT ff_user_entities_s.nextval
2541 INTO l_user_entities_seq
2542 FROM dual;
2543 end;
2544 --
2545 l_user_entity_name := p_user_entity_name;
2546 --
2547 --
2548 -- Check if name legal format eg no spaces, or special characters
2549 -- If not add quotes : Bug 3723715
2550 --
2551 begin
2552 hr_chkfmt.checkformat (l_user_entity_name, 'DB_ITEM_NAME', l_user_entity_name,
2553 null,null,'Y',rgeflg,null);
2554 exception
2555 when hr_utility.hr_error then
2556 -- FFHR_6016_ALL_RES_WORDS error condition
2557 -- so add quotes
2558 --Bug 5930272
2559 fnd_message.retrieve(l_message);
2560 l_user_entity_name := '"' || substr(l_user_entity_name, 1, 78) || '"';
2561 end;
2562 --
2563 -- If we are running this via rebuild_ele_input_bal
2564 IF (g_triggers_altered) THEN
2565 -- Get the startup mode
2566 startup_mode := ffstup.get_mode (p_business_group_id,
2567 p_legislation_code);
2568 --
2569 -- Check the name is OK
2570 --
2571 -- validate the name is OK. This was originally called as part of
2572 -- the FF_USER_ENTITIES_BRI trigger so we add it here.
2573
2574 begin
2575 -- Check if name legal format eg no spaces, or special characters
2576 hr_chkfmt.checkformat (l_user_entity_name, 'DB_ITEM_NAME', l_user_entity_name,
2577 null,null,'Y',rgeflg,null);
2578 exception
2579 when hr_utility.hr_error then
2580 hr_utility.set_message (802, 'FFHR_6016_ALL_RES_WORDS');
2581 hr_utility.set_message_token(802,'VALUE_NAME','FF94_USER_ENTITY');
2582 hrrbdeib_trace_on;
2583 hr_utility.trace('chkfmt DB_ITEM_NAME');
2584 hr_utility.trace('ue: ' || l_user_entity_name);
2585 hr_utility.trace('route_name: ' || p_route_name);
2586 hr_utility.trace('creator_id: ' || to_char(p_creator_id));
2587 hr_utility.trace('creator_type: ' || p_creator_type);
2588 hr_utility.trace('rgeflg: ' || rgeflg);
2589 hrrbdeib_trace_off;
2590 raise;
2591 end;
2592 END IF; -- g_triggers_altered
2593 --
2594 -- Check if entity already exists before inserting it
2595
2596 select count(*)
2597 into l_dummy_fetch_var
2598 from ff_user_entities
2599 where user_entity_name = l_user_entity_name
2600 and nvl (legislation_code, ' ') = nvl (p_legislation_code, ' ')
2601 and nvl (business_group_id, -1) = nvl (p_business_group_id, -1);
2602
2603 IF l_dummy_fetch_var = 0
2604 THEN
2605 --
2606 -- get the route id
2607 --
2608 BEGIN
2609
2610 SELECT route_id
2611 INTO l_route_id
2612 FROM ff_routes
2613 WHERE route_name = p_route_name;
2614
2615 EXCEPTION WHEN OTHERS THEN
2616 hrrbdeib_trace_on;
2617 hr_utility.trace('insert_user_entity_main : missing route : ' ||
2618 p_route_name);
2619 hrrbdeib_trace_off;
2620 raise;
2621 END;
2622 --
2623 -- populate the ff_user_entities table :
2624 --
2625 BEGIN
2626
2627 IF (g_triggers_altered) THEN
2628 insert into ff_user_entities (
2629 user_entity_id,
2630 business_group_id,
2631 legislation_code,
2632 route_id,
2633 notfound_allowed_flag,
2634 user_entity_name,
2635 creator_id,
2636 creator_type,
2637 entity_description,
2638 last_update_date,
2639 last_updated_by,
2640 last_update_login,
2641 created_by,
2642 creation_date)
2643 select l_user_entities_seq,
2644 p_business_group_id,
2645 p_legislation_code,
2646 l_route_id,
2647 p_not_found_flag,
2648 l_user_entity_name,
2649 p_creator_id,
2650 p_creator_type,
2651 p_entity_description,
2652 sysdate,
2653 p_created_by,
2654 p_last_login,
2655 p_created_by,
2656 sysdate
2657 from dual
2658 where not exists (
2659 select null
2660 from ff_user_entities a
2661 where a.user_entity_name = l_user_entity_name
2662 and
2663 ( startup_mode = 'MASTER'
2664 or
2665 ( startup_mode = 'SEED'
2666 and
2667 ( a.legislation_code = p_legislation_code
2668 or
2669 (a.legislation_code is null and a.business_group_id is null)
2670 or
2671 p_legislation_code =
2672 (
2673 select b.legislation_code
2674 from per_business_groups_perf b
2675 where b.business_group_id = a.business_group_id
2676 )
2677 )
2678 )
2679 or
2680 ( startup_mode = 'NON-SEED'
2681 and
2682 ( a.business_group_id = p_business_group_id
2683 or
2684 (a.legislation_code is null and a.business_group_id is null)
2685 or
2686 (a.business_group_id is null and a.legislation_code = p_legislation_code)
2687 )
2688 )
2689 ));
2690 ELSE
2691 insert into ff_user_entities (
2692 user_entity_id,
2693 business_group_id,
2694 legislation_code,
2695 route_id,
2696 notfound_allowed_flag,
2697 user_entity_name,
2698 creator_id,
2699 creator_type,
2700 entity_description,
2701 last_update_date,
2702 last_updated_by,
2703 last_update_login,
2704 created_by,
2705 creation_date)
2706 values (l_user_entities_seq,
2707 p_business_group_id,
2708 p_legislation_code,
2709 l_route_id,
2710 p_not_found_flag,
2711 l_user_entity_name,
2712 p_creator_id,
2713 p_creator_type,
2714 p_entity_description,
2715 sysdate,
2716 p_created_by,
2717 p_last_login,
2718 p_created_by,
2719 sysdate);
2720 END IF;
2721 p_record_inserted := TRUE;
2722 EXCEPTION WHEN OTHERS THEN
2723 hrrbdeib_trace_on;
2724 hr_utility.trace('insert ff_user_entities: ue: ' || l_user_entity_name);
2725 hr_utility.trace('insert ff_user_entities: route_name: ' || p_route_name);
2726 hrrbdeib_trace_off;
2727 raise;
2728 END;
2729
2730 ELSE
2731 p_record_inserted := FALSE;
2732 END IF;
2733 END insert_user_entity_main;
2734 --
2735 --
2736 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2737 -- +
2738 -- delete_compiled_formula +
2739 -- +
2740 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2741 /*
2742 NAME
2743 delete_compiled_formula - Delete any compiled formula references
2744 based on a user entity.
2745 -- this version is for when we can't guarantee that the creator id passed
2746 -- in is not null and as such will use a less efficient index. It also
2747 -- ensures that we don't destabailise outside APIs calling into this proc
2748 -- with a potentially null creator_id
2749 -- For internal calls from this package where we know the creator id is
2750 -- not null we will call into a _priv version of this routine.
2751
2752 DESCRIPTION
2753 This routine is called before certain database items are deleted to
2754 remove all compiled references to them (eg. Descriptive flexs). Since
2755 the user creates Descriptive flex database items from a concurrent
2756 program which could be run several times, it is necessary to delete them
2757 before the re-creation.
2758 */
2759 procedure delete_compiled_formula
2760 (
2761 p_creator_id in number,
2762 p_creator_type in varchar2,
2763 p_user_entity_name in varchar2,
2764 p_leg_code in varchar2
2765 ) is
2766 --
2767 cursor get_formula_ids
2768 is
2769 select /* INDEX(fdi FF_FDI_USAGES_F_N50)*/
2770 distinct fdi.formula_id,
2771 fdi.effective_start_date
2772 from
2773 ff_user_entities ent,
2774 ff_database_items dbi,
2775 ff_fdi_usages_f fdi
2776 where fdi.item_name = dbi.user_name
2777 and fdi.usage = 'D'
2778 and ent.user_entity_id = dbi.user_entity_id
2779 and ent.creator_type = p_creator_type
2780 and ent.user_entity_name like p_user_entity_name
2781 and (nvl (ent.legislation_code, ' ') = nvl (p_leg_code, ' ')
2782 or exists (select null from per_business_groups_perf b
2783 where ent.business_group_id = b.business_group_id
2784 and nvl(b.legislation_code, p_leg_code) = p_leg_code))
2785 and nvl(ent.creator_id, -1) = nvl(nvl(p_creator_id, ent.creator_id), -1);
2786 --
2787 num number;
2788 begin
2789
2790 for form in get_formula_ids loop
2791
2792 select count(*)
2793 into num
2794 from ff_formulas_f f
2795 where form.formula_id = f.formula_id
2796 and form.effective_start_date = f.effective_start_date
2797 and (nvl (f.legislation_code, ' ') = nvl (p_leg_code, nvl (f.legislation_code, ' '))
2798 or exists (select null from per_business_groups_perf b
2799 where f.business_group_id = b.business_group_id
2800 and nvl(b.legislation_code, p_leg_code) = p_leg_code));
2801
2802 if num > 0 then
2803
2804 delete from ff_fdi_usages_f fdi
2805 where fdi.formula_id = form.formula_id
2806 and form.effective_start_date = fdi.effective_start_date;
2807
2808 delete from ff_compiled_info_f fci
2809 where fci.formula_id = form.formula_id
2810 and form.effective_start_date = fci.effective_start_date;
2811
2812 end if;
2813
2814 end loop;
2815
2816 END delete_compiled_formula;
2817 --
2818 -- Private version
2819 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2820 -- +
2821 -- delete_compiled_formula_priv +
2822 -- +
2823 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2824 /*
2825 NAME
2826 delete_compiled_formula_priv - Delete any compiled formula references
2827 based on a user entity. Performant version
2828 --
2829 DESCRIPTION
2830 This routine is called before certain database items are deleted to
2831 remove all compiled references to them (eg. Descriptive flexs). Since
2832 the user creates Descriptive flex database items from a concurrent
2833 program which could be run several times, it is necessary to delete them
2834 before the re-creation.
2835 Private version for performance. See note on del_comp_form for more info
2836 */
2837 procedure delete_compiled_formula_priv
2838 (
2839 p_creator_id in number,
2840 p_creator_type in varchar2,
2841 p_user_entity_name in varchar2,
2842 p_leg_code in varchar2
2843 ) is
2844 --
2845 l_formula_ids dbms_sql.number_table;
2846 l_start_dates dbms_sql.date_table;
2847 begin
2848
2849 delete ff_fdi_usages_f fdi
2850 where FDI.usage = 'D'
2851 and exists (select null
2852 from ff_formulas_f f
2853 where fdi.formula_id = f.formula_id
2854 and (nvl (f.legislation_code, ' ') = nvl (p_leg_code, nvl (f.legislation_code, ' '))
2855 or exists (select null from per_business_groups_perf b
2856 where f.business_group_id = b.business_group_id
2857 and nvl(b.legislation_code, p_leg_code) = p_leg_code)))
2858 and exists (select null from
2859 ff_database_items dbi
2860 where fdi.item_name = dbi.user_name
2861 and exists (select /*+ INDEX(ent FF_USER_ENTITIES_N51)*/ null from
2862 ff_user_entities ent
2863 where ent.user_entity_id = dbi.user_entity_id
2864 and ent.creator_id = p_creator_id
2865 and ent.creator_type = p_creator_type
2866 and ent.user_entity_name like p_user_entity_name
2867 and (nvl (ent.legislation_code, ' ') = nvl (p_leg_code, ' ')
2868 or exists (select null from per_business_groups_perf b
2869 where ent.business_group_id = b.business_group_id
2870 and nvl(b.legislation_code, p_leg_code) = p_leg_code))
2871 ))
2872 returning fdi.formula_id, fdi.effective_start_date
2873 bulk collect into l_formula_ids, l_start_dates
2874 ;
2875
2876 ff_compiled_info_del
2877 (p_formula_ids => l_formula_ids
2878 ,p_start_dates => l_start_dates
2879 );
2880
2881 END delete_compiled_formula_priv;
2882 --
2883 --
2884 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2885 -- +
2886 -- ff_compiled_info_del +
2887 -- +
2888 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2889 /*
2890 NAME
2891 ff_compiled_info_del
2892
2893 DESCRIPTION
2894 Bulk delete FF_COMPILED_INFO_F using FORMULA_ID and
2895 EFFECTIVE_START_DATE from FF_FDI_USAGES_F.
2896 */
2897 procedure ff_compiled_info_del
2898 (p_formula_ids dbms_sql.number_table
2899 ,p_start_dates dbms_sql.date_table
2900 ) is
2901 l_iterations number;
2902 l_chunksize binary_integer := 250;
2903 l_upper_limit binary_integer;
2904 l_lower_limit binary_integer;
2905 begin
2906 --
2907 -- Code will delete l_chunksize rows at most per iteration.
2908 --
2909 l_iterations := trunc(p_formula_ids.count / l_chunksize);
2910 if l_iterations * l_chunksize < p_formula_ids.count then
2911 l_iterations := 1 + l_iterations;
2912 end if;
2913
2914 l_lower_limit := 1;
2915 l_upper_limit := l_chunksize;
2916 for i in 1 .. l_iterations loop
2917
2918 if l_upper_limit > p_formula_ids.count then
2919 l_upper_limit := p_formula_ids.count;
2920 end if;
2921
2922 forall j in l_lower_limit .. l_upper_limit
2923 delete
2924 from ff_compiled_info_f
2925 where formula_id = p_formula_ids(j)
2926 and effective_start_date = p_start_dates(j)
2927 ;
2928
2929 l_lower_limit := l_upper_limit + 1;
2930 l_upper_limit := l_upper_limit + l_chunksize;
2931 end loop;
2932 end ff_compiled_info_del;
2933 --
2934 --
2935 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2936 -- +
2937 -- delete_element_type_dict +
2938 -- +
2939 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2940 /*
2941 NAME
2942 delete_element_type_dict - delete an element type from the data
2943 dictionary
2944 --
2945 DESCRIPTION
2946 */
2947 procedure delete_element_type_dict
2948 (
2949 p_element_type_id in number
2950 ) is
2951 --
2952 BEGIN
2953
2954 -- delete_compiled_formula_priv(p_element_type_id, 'E', '%', null);
2955
2956 DELETE FROM ff_user_entities
2957 WHERE creator_id = p_element_type_id
2958 AND creator_type = 'E';
2959 END delete_element_type_dict;
2960 --
2961 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2962 -- +
2963 -- create_element_type +
2964 -- +
2965 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2966 /*
2967 NAME
2968 create_element_type - create an element type in the data
2969 dictionary, with a context of either date
2970 earned or date paid.
2971 --
2972 DESCRIPTION
2973 This procedure creates element type database items for a given element
2974 type id, with a context of either date earned or date paid. Date paid
2975 database items have '_DP' appended to the database name. To create date
2976 earned DB items, set the paramater 'p_date_p' to null. To create date
2977 paid DB items, set it to '_DP'.
2978 The routes must have already been defined in the
2979 database (in table ff_routes). The procedure will search for the
2980 routes in this table by using the route name, which is hard coded below.
2981 The procedure processes each route in turn, creating a user entity and
2982 route parameter values, and then inserting each database items for that
2983 particular route.
2984 The database items created use the element type name. This routine
2985 generates the following database items:
2986 --
2987 <NAME>_REPORTING_NAME
2988 <NAME>_PRIMARY_CLASSIFICATION
2989 <NAME>_INPUT_CURRENCY_CODE
2990 <NAME>_OUTPUT_CURRENCY_CODE
2991 <NAME>_PROCESSING_PRIORITY
2992 <NAME>_CLOSED_FOR_ENTRY
2993 <NAME>_CLOSED_FOR_ENTRY_CODE
2994 <NAME>_END_DATE
2995 <NAME>_QUALIFYING_LENGTH_OF_SERVICE
2996 <NAME>_QUALIFYING_UNITS
2997 <NAME>_QUALIFYING_UNITS_CODE
2998 <NAME>_QUALIFYING_AGE
2999 <NAME>_STANDARD_LINK
3000 <NAME>_STANDARD_LINK_CODE
3001 <NAME>_COSTABLE_TYPE
3002 <NAME>_COSTABLE_TYPE_CODE
3003 <NAME>_COUNT
3004 */
3005 procedure create_element_type
3006 (
3007 p_element_type_id in number,
3008 p_effective_date in date,
3009 p_date_p in varchar2
3010 ) is
3011 cursor get_title is
3012 select title from fnd_descriptive_flexs_vl
3013 where descriptive_flexfield_name = 'Element Developer DF'
3014 and application_id = 801;
3015 --
3016 cursor c_language is
3017 select language_code
3018 from fnd_languages
3019 where installed_flag in ('I','B');
3020 --
3021 l_title varchar2(80);
3022 l_route1_name varchar2(50):= 'ELEMENT_TYPE_AT_TYPE_LEVEL' || p_date_p;
3023 l_route2_name varchar2(50):= 'ELEMENT_TYPE_AT_ASSIGNMENT_LEVEL' || p_date_p;
3024 l_route3_name varchar2(50):= 'ELEMENT_TYPE_COUNT_OF_ELEMENT_ENTRIES'||p_date_p;
3025 l_created_by number;
3026 l_last_login number;
3027 l_dbitem_found boolean;
3028 l_record_inserted boolean;
3029
3030 l_benefit_class_id number;
3031 l_class_name pay_element_classifications.classification_name%type;
3032 l_business_group_id number;
3033 l_element_name pay_element_types_f.element_name%type;
3034 l_legislation_code pay_element_types_f.legislation_code%type;
3035 l_leg_code_class pay_element_types_f.legislation_code%type;
3036 l_full_mls boolean;
3037 l_base_dbi_name varchar2(2000);
3038 l_user_entity_id number;
3039 l_dbi_prefixes t_dbi_prefixes;
3040 l_languages dbms_sql.varchar2s;
3041 l_startup_mode varchar2(100);
3042 l_legislation_code1 pay_element_types_f.legislation_code%type;
3043 --
3044 ------------------------- create_element_type -------------------------
3045 --
3046 BEGIN
3047 --
3048 -- get the element type information
3049 --
3050 begin
3051 select replace (ltrim (rtrim (upper (ETYPE.element_name))), ' ', '_'),
3052 ETYPE.business_group_id,
3053 ltrim(rtrim(ETYPE.legislation_code)),
3054 ETYPE.benefit_classification_id,
3055 upper (CLASS.classification_name),
3056 ETYPE.created_by,
3057 ETYPE.last_update_login
3058 into l_element_name,
3059 l_business_group_id,
3060 l_legislation_code,
3061 l_benefit_class_id,
3062 l_class_name,
3063 l_created_by,
3064 l_last_login
3065 from pay_element_types_f ETYPE
3066 , pay_element_classifications CLASS
3067 where ETYPE.element_type_id = p_element_type_id
3068 and p_effective_date between ETYPE.effective_start_date
3069 and ETYPE.effective_end_date
3070 and CLASS.classification_id = ETYPE.classification_id;
3071 end;
3072 --
3073 if (g_triggers_altered) then
3074 -- Get the startup mode
3075 l_startup_mode :=
3076 ffstup.get_mode (l_business_group_id, l_legislation_code);
3077 else
3078 -- Get the security group id which won't have been populated yet.
3079 g_security_group_id :=
3080 fnd_global.lookup_security_group('NAME_TRANSLATIONS', 3);
3081 end if;
3082 --
3083 -- Are the database items to be fully translated ?
3084 --
3085 l_legislation_code1 := l_legislation_code;
3086 if l_legislation_code1 is null and l_business_group_id is not null then
3087 select bg.legislation_code
3088 into l_legislation_code1
3089 from per_business_groups_perf bg
3090 where bg.business_group_id = l_business_group_id
3091 ;
3092 end if;
3093 l_full_mls := ff_dbi_utils_pkg.translations_supported(l_legislation_code1);
3094
3095 --
3096 -- Set up the data for the full MLS case.
3097 --
3098 if l_full_mls then
3099 open c_language;
3100 fetch c_language bulk collect
3101 into l_languages;
3102 close c_language;
3103
3104 gen_et_dbi_prefixes
3105 (p_element_type_id => p_element_type_id
3106 ,p_languages => l_languages
3107 ,p_prefixes => l_dbi_prefixes
3108 );
3109 end if;
3110 --
3111 -- create the user entity for the first route
3112 --
3113 insert_user_entity (l_route1_name,
3114 l_element_name || '_E1' || p_date_p,
3115 'entity for '|| l_route1_name,
3116 'Y', -- not found allowed flag
3117 'E',
3118 p_element_type_id,
3119 l_business_group_id,
3120 l_legislation_code,
3121 l_created_by,
3122 l_last_login,
3123 l_record_inserted);
3124 --
3125 -- only insert parameter values/database items if an entity was inserted
3126 --
3127 IF l_record_inserted THEN
3128 --
3129 -- Fetch the user_entity_id.
3130 --
3131 select ff_user_entities_s.currval
3132 into l_user_entity_id
3133 from dual;
3134 --
3135 -- insert the element type id for the where clause filler
3136 --
3137 insert_parameter_value (p_element_type_id, 1);
3138 --
3139 -- load up the database items for the first route:
3140 --
3141 insert_database_item (l_element_name,
3142 'REPORTING_NAME' || p_date_p,
3143 'T', -- data type
3144 'ETYPE.reporting_name',
3145 'Y', -- null allowed
3146 'reporting name for element type',
3147 l_user_entity_id,
3148 l_full_mls,
3149 l_base_dbi_name);
3150 if l_full_mls then
3151 update_et_tl_dbi_names
3152 (p_leg_code => l_legislation_code
3153 ,p_bg_id => l_business_group_id
3154 ,p_startup_mode => l_startup_mode
3155 ,p_user_name => l_base_dbi_name
3156 ,p_user_entity_id => l_user_entity_id
3157 ,p_prefixes => l_dbi_prefixes
3158 ,p_suffix => 'REPORTING_NAME'
3159 ,p_date_p => p_date_p
3160 );
3161 end if;
3162 --
3163 insert_database_item (l_element_name,
3164 'CLASSIFICATION' || p_date_p,
3165 'T', -- data type
3166 'ECLASS.classification_name',
3167 'N', -- null allowed
3168 'primary classification name for element type',
3169 l_user_entity_id,
3170 l_full_mls,
3171 l_base_dbi_name);
3172 if l_full_mls then
3173 update_et_tl_dbi_names
3174 (p_leg_code => l_legislation_code
3175 ,p_bg_id => l_business_group_id
3176 ,p_startup_mode => l_startup_mode
3177 ,p_user_name => l_base_dbi_name
3178 ,p_user_entity_id => l_user_entity_id
3179 ,p_prefixes => l_dbi_prefixes
3180 ,p_suffix => 'CLASSIFICATION'
3181 ,p_date_p => p_date_p
3182 );
3183 end if;
3184 --
3185 insert_database_item (l_element_name,
3186 'INPUT_CURRENCY_CODE' || p_date_p,
3187 'T', -- data type
3188 'ETYPE.input_currency_code',
3189 'Y', -- null allowed
3190 'input currency code for element type',
3191 l_user_entity_id,
3192 l_full_mls,
3193 l_base_dbi_name);
3194 if l_full_mls then
3195 update_et_tl_dbi_names
3196 (p_leg_code => l_legislation_code
3197 ,p_bg_id => l_business_group_id
3198 ,p_startup_mode => l_startup_mode
3199 ,p_user_name => l_base_dbi_name
3200 ,p_user_entity_id => l_user_entity_id
3201 ,p_prefixes => l_dbi_prefixes
3202 ,p_suffix => 'INPUT_CURRENCY_CODE'
3203 ,p_date_p => p_date_p
3204 );
3205 end if;
3206 --
3207 insert_database_item (l_element_name,
3208 'OUTPUT_CURRENCY_CODE' || p_date_p,
3209 'T', -- data type
3210 'ETYPE.output_currency_code',
3211 'Y', -- null allowed
3212 'output currency code for element type',
3213 l_user_entity_id,
3214 l_full_mls,
3215 l_base_dbi_name);
3216 if l_full_mls then
3217 update_et_tl_dbi_names
3218 (p_leg_code => l_legislation_code
3219 ,p_bg_id => l_business_group_id
3220 ,p_startup_mode => l_startup_mode
3221 ,p_user_name => l_base_dbi_name
3222 ,p_user_entity_id => l_user_entity_id
3223 ,p_prefixes => l_dbi_prefixes
3224 ,p_suffix => 'OUTPUT_CURRENCY_CODE'
3225 ,p_date_p => p_date_p
3226 );
3227 end if;
3228 --
3229 insert_database_item (l_element_name,
3230 'PROCESSING_PRIORITY' || p_date_p,
3231 'N', -- data type
3232 'ETYPE.processing_priority',
3233 'N', -- null allowed
3234 'processing priority for element type',
3235 l_user_entity_id,
3236 l_full_mls,
3237 l_base_dbi_name);
3238 if l_full_mls then
3239 update_et_tl_dbi_names
3240 (p_leg_code => l_legislation_code
3241 ,p_bg_id => l_business_group_id
3242 ,p_startup_mode => l_startup_mode
3243 ,p_user_name => l_base_dbi_name
3244 ,p_user_entity_id => l_user_entity_id
3245 ,p_prefixes => l_dbi_prefixes
3246 ,p_suffix => 'PROCESSING_PRIORITY'
3247 ,p_date_p => p_date_p
3248 );
3249 end if;
3250 --
3251 insert_database_item (l_element_name,
3252 'CLOSED_FOR_ENTRY' || p_date_p,
3253 'T', -- data type
3254 'CELOOK.meaning',
3255 'N', -- null allowed
3256 'closed for entry flag meaning from the lookup table for element type',
3257 l_user_entity_id,
3258 l_full_mls,
3259 l_base_dbi_name);
3260 if l_full_mls then
3261 update_et_tl_dbi_names
3262 (p_leg_code => l_legislation_code
3263 ,p_bg_id => l_business_group_id
3264 ,p_startup_mode => l_startup_mode
3265 ,p_user_name => l_base_dbi_name
3266 ,p_user_entity_id => l_user_entity_id
3267 ,p_prefixes => l_dbi_prefixes
3268 ,p_suffix => 'CLOSED_FOR_ENTRY'
3269 ,p_date_p => p_date_p
3270 );
3271 end if;
3272 --
3273 insert_database_item (l_element_name,
3274 'CLOSED_FOR_ENTRY_CODE' || p_date_p,
3275 'T', -- data type
3276 'ETYPE.closed_for_entry_flag',
3277 'N', -- null allowed
3278 'closed for entry flag - Y or N, for element type',
3279 l_user_entity_id,
3280 l_full_mls,
3281 l_base_dbi_name);
3282 if l_full_mls then
3283 update_et_tl_dbi_names
3284 (p_leg_code => l_legislation_code
3285 ,p_bg_id => l_business_group_id
3286 ,p_startup_mode => l_startup_mode
3287 ,p_user_name => l_base_dbi_name
3288 ,p_user_entity_id => l_user_entity_id
3289 ,p_prefixes => l_dbi_prefixes
3290 ,p_suffix => 'CLOSED_FOR_ENTRY_CODE'
3291 ,p_date_p => p_date_p
3292 );
3293 end if;
3294 --
3295 insert_database_item (l_element_name,
3296 'END_DATE' || p_date_p,
3297 'D', -- data type
3298 'ETYPE.effective_end_date',
3299 'N', -- null allowed
3300 'effective end date for element type',
3301 l_user_entity_id,
3302 l_full_mls,
3303 l_base_dbi_name);
3304 if l_full_mls then
3305 update_et_tl_dbi_names
3306 (p_leg_code => l_legislation_code
3307 ,p_bg_id => l_business_group_id
3308 ,p_startup_mode => l_startup_mode
3309 ,p_user_name => l_base_dbi_name
3310 ,p_user_entity_id => l_user_entity_id
3311 ,p_prefixes => l_dbi_prefixes
3312 ,p_suffix => 'END_DATE'
3313 ,p_date_p => p_date_p
3314 );
3315 end if;
3316 --
3317 -- see if there is a benefit classification for this element, and if
3318 -- so generate a DB item for it.
3319 --
3320 if (l_benefit_class_id is not null) then
3321 insert_database_item (l_element_name,
3322 'BEN_CLASS' || p_date_p,
3323 'T', -- data type
3324 'BCLASS.benefit_classification_name',
3325 'N', -- null allowed
3326 'The element''s benefit classification',
3327 l_user_entity_id,
3328 l_full_mls,
3329 l_base_dbi_name);
3330 if l_full_mls then
3331 update_et_tl_dbi_names
3332 (p_leg_code => l_legislation_code
3333 ,p_bg_id => l_business_group_id
3334 ,p_startup_mode => l_startup_mode
3335 ,p_user_name => l_base_dbi_name
3336 ,p_user_entity_id => l_user_entity_id
3337 ,p_prefixes => l_dbi_prefixes
3338 ,p_suffix => 'BEN_CLASS'
3339 ,p_date_p => p_date_p
3340 );
3341 end if;
3342 end if;
3343 END IF;
3344 --
3345 -- create the user entity for the second route
3346 --
3347 insert_user_entity (l_route2_name,
3348 l_element_name || '_E2' || p_date_p,
3349 'entity for '|| l_route2_name,
3350 'Y', -- not found allowed flag
3351 'E',
3352 p_element_type_id,
3353 l_business_group_id,
3354 l_legislation_code,
3355 l_created_by,
3356 l_last_login,
3357 l_record_inserted);
3358 --
3359 -- only insert parameter values/database items if an entity was inserted
3360 --
3361 IF l_record_inserted THEN
3362 --
3363 -- Fetch the user_entity_id.
3364 --
3365 select ff_user_entities_s.currval
3366 into l_user_entity_id
3367 from dual;
3368 --
3369 -- insert the element type id for the where clause filler
3370 --
3371 insert_parameter_value (p_element_type_id, 1);
3372 --
3373 -- load up the database items for the second route:
3374 --
3375 insert_database_item
3376 (l_element_name,
3377 'LENGTH_OF_SERVICE' || p_date_p,
3378 'N', -- data type
3379 'nvl (ELINK.qualifying_length_of_service, ETYPE.qualifying_length_of_service)',
3380 'Y', -- null allowed
3381 'qualifying length of service for element type',
3382 l_user_entity_id,
3383 l_full_mls,
3384 l_base_dbi_name);
3385 if l_full_mls then
3386 update_et_tl_dbi_names
3387 (p_leg_code => l_legislation_code
3388 ,p_bg_id => l_business_group_id
3389 ,p_startup_mode => l_startup_mode
3390 ,p_user_name => l_base_dbi_name
3391 ,p_user_entity_id => l_user_entity_id
3392 ,p_prefixes => l_dbi_prefixes
3393 ,p_suffix => 'LENGTH_OF_SERVICE'
3394 ,p_date_p => p_date_p
3395 );
3396 end if;
3397 --
3398 insert_database_item
3399 (l_element_name,
3400 'QUALIFYING_UNITS' || p_date_p,
3401 'T', -- data type
3402 'nvl(hr_general.decode_lookup(''QUALIFYING_UNITS'',ELINK.QUALIFYING_UNITS),hr_general.decode_lookup(''QUALIFYING_UNITS'',ETYPE.QUALIFYING_UNITS))',
3403 'Y', -- null allowed
3404 'qualifying units from lookup table for element type',
3405 l_user_entity_id,
3406 l_full_mls,
3407 l_base_dbi_name);
3408 if l_full_mls then
3409 update_et_tl_dbi_names
3410 (p_leg_code => l_legislation_code
3411 ,p_bg_id => l_business_group_id
3412 ,p_startup_mode => l_startup_mode
3413 ,p_user_name => l_base_dbi_name
3414 ,p_user_entity_id => l_user_entity_id
3415 ,p_prefixes => l_dbi_prefixes
3416 ,p_suffix => 'QUALIFYING_UNITS'
3417 ,p_date_p => p_date_p
3418 );
3419 end if;
3420 --
3421 insert_database_item (l_element_name,
3422 'QUALIFYING_UNITS_CODE' || p_date_p,
3423 'T', -- data type
3424 'nvl(ELINK.qualifying_units, ETYPE.qualifying_units)',
3425 'Y', -- null allowed
3426 'qualifying units from database for element type',
3427 l_user_entity_id,
3428 l_full_mls,
3429 l_base_dbi_name);
3430 if l_full_mls then
3431 update_et_tl_dbi_names
3432 (p_leg_code => l_legislation_code
3433 ,p_bg_id => l_business_group_id
3434 ,p_startup_mode => l_startup_mode
3435 ,p_user_name => l_base_dbi_name
3436 ,p_user_entity_id => l_user_entity_id
3437 ,p_prefixes => l_dbi_prefixes
3438 ,p_suffix => 'QUALIFYING_UNITS_CODE'
3439 ,p_date_p => p_date_p
3440 );
3441 end if;
3442 --
3443 insert_database_item (l_element_name,
3444 'QUALIFYING_AGE' || p_date_p,
3445 'N', -- data type
3446 'nvl (ELINK.qualifying_age, ETYPE.qualifying_age)',
3447 'Y', -- null allowed
3448 'qualifying age for element type',
3449 l_user_entity_id,
3450 l_full_mls,
3451 l_base_dbi_name);
3452 if l_full_mls then
3453 update_et_tl_dbi_names
3454 (p_leg_code => l_legislation_code
3455 ,p_bg_id => l_business_group_id
3456 ,p_startup_mode => l_startup_mode
3457 ,p_user_name => l_base_dbi_name
3458 ,p_user_entity_id => l_user_entity_id
3459 ,p_prefixes => l_dbi_prefixes
3460 ,p_suffix => 'QUALIFYING_AGE'
3461 ,p_date_p => p_date_p
3462 );
3463 end if;
3464 --
3465 insert_database_item (l_element_name,
3466 'STANDARD_LINK' || p_date_p,
3467 'T', -- data type
3468 'nvl(hr_general.decode_lookup(''YES_NO'',ELINK.STANDARD_LINK_FLAG),hr_general.decode_lookup(''YES_NO'',ETYPE.STANDARD_LINK_FLAG))',
3469 'N', -- null allowed
3470 'standard link meaning from lookup table Yes = standard, No = discretionary',
3471 l_user_entity_id,
3472 l_full_mls,
3473 l_base_dbi_name);
3474 if l_full_mls then
3475 update_et_tl_dbi_names
3476 (p_leg_code => l_legislation_code
3477 ,p_bg_id => l_business_group_id
3478 ,p_startup_mode => l_startup_mode
3479 ,p_user_name => l_base_dbi_name
3480 ,p_user_entity_id => l_user_entity_id
3481 ,p_prefixes => l_dbi_prefixes
3482 ,p_suffix => 'STANDARD_LINK'
3483 ,p_date_p => p_date_p
3484 );
3485 end if;
3486 --
3487 insert_database_item (l_element_name,
3488 'STANDARD_LINK_CODE' || p_date_p,
3489 'T', -- data type
3490 'nvl (ELINK.standard_link_flag, ETYPE.standard_link_flag)',
3491 'N', -- null allowed
3492 'standard link value held on the database Y = standard, N = discretionary',
3493 l_user_entity_id,
3494 l_full_mls,
3495 l_base_dbi_name);
3496 if l_full_mls then
3497 update_et_tl_dbi_names
3498 (p_leg_code => l_legislation_code
3499 ,p_bg_id => l_business_group_id
3500 ,p_startup_mode => l_startup_mode
3501 ,p_user_name => l_base_dbi_name
3502 ,p_user_entity_id => l_user_entity_id
3503 ,p_prefixes => l_dbi_prefixes
3504 ,p_suffix => 'STANDARD_LINK_CODE'
3505 ,p_date_p => p_date_p
3506 );
3507 end if;
3508 --
3509 insert_database_item (l_element_name,
3510 'COSTABLE_TYPE' || p_date_p,
3511 'T', -- data type
3512 'CTLOOK.meaning',
3513 'N', -- null allowed
3514 'costable type meaning from lookup table for element type',
3515 l_user_entity_id,
3516 l_full_mls,
3517 l_base_dbi_name);
3518 if l_full_mls then
3519 update_et_tl_dbi_names
3520 (p_leg_code => l_legislation_code
3521 ,p_bg_id => l_business_group_id
3522 ,p_startup_mode => l_startup_mode
3523 ,p_user_name => l_base_dbi_name
3524 ,p_user_entity_id => l_user_entity_id
3525 ,p_prefixes => l_dbi_prefixes
3526 ,p_suffix => 'COSTABLE_TYPE'
3527 ,p_date_p => p_date_p
3528 );
3529 end if;
3530 --
3531 insert_database_item (l_element_name,
3532 'COSTABLE_TYPE_CODE' || p_date_p,
3533 'T', -- data type
3534 'ELINK.costable_type',
3535 'N', -- null allowed
3536 'costable type value held on the database for element type',
3537 l_user_entity_id,
3538 l_full_mls,
3539 l_base_dbi_name);
3540 if l_full_mls then
3541 update_et_tl_dbi_names
3542 (p_leg_code => l_legislation_code
3543 ,p_bg_id => l_business_group_id
3544 ,p_startup_mode => l_startup_mode
3545 ,p_user_name => l_base_dbi_name
3546 ,p_user_entity_id => l_user_entity_id
3547 ,p_prefixes => l_dbi_prefixes
3548 ,p_suffix => 'COSTABLE_TYPE_CODE'
3549 ,p_date_p => p_date_p
3550 );
3551 end if;
3552 end if;
3553 --
3554 -- create the user entity for the third route
3555 --
3556 insert_user_entity (l_route3_name,
3557 l_element_name || '_E3' || p_date_p,
3558 'entity for '|| l_route3_name,
3559 'Y', -- not found allowed flag
3560 'E',
3561 p_element_type_id,
3562 l_business_group_id,
3563 l_legislation_code,
3564 l_created_by,
3565 l_last_login,
3566 l_record_inserted);
3567 --
3568 -- only insert parameter values/database items if an entity was inserted
3569 --
3570 IF l_record_inserted THEN
3571 --
3572 -- Fetch the user_entity_id.
3573 --
3574 select ff_user_entities_s.currval
3575 into l_user_entity_id
3576 from dual;
3577 --
3578 -- insert the element type id for the where clause filler
3579 --
3580 insert_parameter_value (p_element_type_id, 1);
3581 --
3582 -- load up the database items for the third route:
3583 --
3584 insert_database_item (l_element_name,
3585 'COUNT' || p_date_p,
3586 'N', -- data type
3587 'count(0)',
3588 'Y', -- null allowed
3589 'count of element types for given assignment and element type',
3590 l_user_entity_id,
3591 l_full_mls,
3592 l_base_dbi_name);
3593 if l_full_mls then
3594 update_et_tl_dbi_names
3595 (p_leg_code => l_legislation_code
3596 ,p_bg_id => l_business_group_id
3597 ,p_startup_mode => l_startup_mode
3598 ,p_user_name => l_base_dbi_name
3599 ,p_user_entity_id => l_user_entity_id
3600 ,p_prefixes => l_dbi_prefixes
3601 ,p_suffix => 'COUNT'
3602 ,p_date_p => p_date_p
3603 );
3604 end if;
3605 END IF;
3606
3607 --
3608 -- Now see if any Element Descriptive flexs are to be created:
3609 -- First get a value for the legislation code:
3610 --
3611 select nvl (ltrim(rtrim(ETYPE.legislation_code)),
3612 ltrim(rtrim(BUSGP.legislation_code)))
3613 into l_leg_code_class
3614 from pay_element_types_f ETYPE
3615 , per_business_groups_perf BUSGP
3616 where ETYPE.element_type_id = p_element_type_id
3617 and p_effective_date between ETYPE.effective_start_date
3618 and ETYPE.effective_end_date
3619 and BUSGP.business_group_id (+) = ETYPE.business_group_id;
3620 --
3621 l_class_name := l_leg_code_class ||'_'|| l_class_name;
3622 --
3623 --
3624 open get_title;
3625 fetch get_title into l_title;
3626 close get_title;
3627 --
3628 for c1rec in dflex_c1 ('PAY_ELEMENT_TYPES_F', -- table name
3629 l_title, -- title of desc. flex
3630 'N', -- global flag
3631 l_class_name) loop -- context code
3632 l_dbitem_found := FALSE;
3633 --
3634 -- now create the database items
3635 --
3636
3637 for c2rec in dflex_c2 (c1rec.c_flex_name, l_class_name) loop
3638 --
3639 -- only create a user entity if database items are to be created.
3640 --
3641 if (l_dbitem_found = FALSE) then
3642 l_dbitem_found := TRUE;
3643 --
3644 -- create a user entity.
3645 --
3646 l_created_by := c1rec.c_created_by;
3647 l_last_login := c1rec.c_last_login;
3648 --
3649 insert_user_entity (l_route1_name,
3650 l_element_name || '_DF_E3' || p_date_p,
3651 'Element DDF entity for '|| l_route1_name,
3652 'Y',
3653 'E',
3654 p_element_type_id,
3655 l_business_group_id,
3656 l_legislation_code,
3657 l_created_by,
3658 l_last_login,
3659 l_record_inserted);
3660 --
3661 -- insert the element type id for the where clause filler
3662 --
3663 IF l_record_inserted
3664 THEN
3665 insert_parameter_value (p_element_type_id, 1);
3666 END IF;
3667 --
3668 END IF;
3669 --
3670 IF l_record_inserted
3671 THEN
3672 insert_database_item (l_element_name,
3673 c2rec.c_db_name || p_date_p,
3674 'T', -- data type
3675 'ETYPE.' || c2rec.c_def_text,
3676 'Y', -- null allowed
3677 'Element Descriptive flex DB item for ' || l_element_name);
3678 END IF;
3679 END LOOP; -- dflex_c2 loop
3680 END LOOP; -- dflex_c1 loop
3681 --
3682 END create_element_type;
3683 --
3684 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3685 -- +
3686 -- create_element_type_dict +
3687 -- +
3688 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3689 /*
3690 NAME
3691 create_element_type_dict - create an element type in the data
3692 dictionary
3693 --
3694 DESCRIPTION
3695 This procedure is the main entry point for creating database items for
3696 a given element type, where the context is date earned. It calls the
3697 element type creation procedure : create_element_type.
3698 */
3699 procedure create_element_type_dict
3700 (
3701 p_element_type_id in number,
3702 p_effective_date in date
3703 ) is
3704 --
3705 begin
3706 create_element_type (p_element_type_id,
3707 p_effective_date,
3708 null);
3709 end create_element_type_dict;
3710 --
3711 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3712 -- +
3713 -- create_element_type_dp_dict +
3714 -- +
3715 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3716 /*
3717 NAME
3718 create_element_type_dp_dict - create an element type in the data
3719 dictionary of context date paid,
3720 --
3721 DESCRIPTION
3722 This procedure is the main entry point for creating database items for
3723 a given element type, where the context is date paid. It first
3724 deletes all the old DB items for the given element type id, as these DB
3725 items would have been set up to use the context of date earned. It then
3726 calls the element type creation procedure : create_element_type, with the
3727 parameters to create date paid DB items. This includes deleting and
3728 re-creating input value database items for the given element type.
3729 */
3730 procedure create_element_type_dp_dict
3731 (
3732 p_element_type_id in number
3733 ) is
3734 --
3735 -- cursor c1 : select input values to be deleted:
3736 --
3737 cursor c1 is
3738 select input_value_id
3739 from pay_input_values_f
3740 where element_type_id = p_element_type_id;
3741 --
3742 -- cursor c2 : select input values to be used for database items:
3743 --
3744 cursor c2 is
3745 select input_value_id,
3746 max(effective_end_date) c_date
3747 from pay_input_values_f
3748 where generate_db_items_flag = 'Y'
3749 and element_type_id = p_element_type_id
3750 group by input_value_id;
3751 --
3752 l_date date;
3753 l_element_type number;
3754 begin
3755 --
3756 -- first delete the old element type DB items which use the context of
3757 -- date earned
3758 --
3759 delete_element_type_dict (p_element_type_id);
3760 --
3761 -- create the new DB items with the context of date paid
3762 --
3763 select element_type_id,
3764 max(effective_end_date)
3765 into l_element_type,
3766 l_date
3767 from pay_element_types_f
3768 where element_type_id = p_element_type_id
3769 group by element_type_id;
3770 --
3771 create_element_type (p_element_type_id,
3772 l_date,
3773 '_DP');
3774 --
3775 -- go through and delete any old input values
3776 --
3777 for c1rec in c1 loop
3778 delete_input_value_dict (c1rec.input_value_id);
3779 end loop; -- c1 loop
3780 --
3781 -- create the new input values with the context of date paid
3782 --
3783 for c2rec in c2 loop
3784 create_input_value (c2rec.input_value_id,
3785 c2rec.c_date,
3786 '_DP');
3787 end loop; -- c2 loop
3788 --
3789 end create_element_type_dp_dict;
3790 --
3791 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3792 -- +
3793 -- delete_input_value_dict +
3794 -- +
3795 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3796 /*
3797 NAME
3798 delete_input_value_dict - delete an input value from the data
3799 dictionary
3800 --
3801 DESCRIPTION
3802 */
3803 procedure delete_input_value_dict
3804 (
3805 p_input_value_id in number
3806 ) is
3807 --
3808 BEGIN
3809
3810 -- delete_compiled_formula_priv(p_input_value_id, 'I', '%', null);
3811
3812 DELETE FROM ff_user_entities
3813 WHERE creator_id = p_input_value_id
3814 AND creator_type = 'I';
3815 END delete_input_value_dict;
3816 --
3817 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3818 -- +
3819 -- create_input_value +
3820 -- +
3821 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3822 /*
3823 NAME
3824 create_input_value - create an element type in the data
3825 dictionary, with a context of either date
3826 earned or date paid.
3827 --
3828 DESCRIPTION
3829 This procedure creates input value database items for a given input value
3830 id, with a context of either date earned or date paid. Date paid
3831 database items have '_DP' appended to the database name. To create date
3832 earned DB items, set the paramater 'p_date_p' to null. To create date
3833 paid DB items, set it to '_DP'.
3834 The routes must have already been defined in the
3835 database (in table ff_routes). The procedure will search for the
3836 routes in this table by using the route name, which is hard coded below.
3837 The procedure processes each route in turn, creating a user entity and
3838 route parameter values, and then inserting each database items for that
3839 particular route.
3840 The database items created use the input value name. This routine
3841 generates the following database items:
3842 --
3843 <NAME>_UNIT_OF_MEASURE
3844 <NAME>_UNIT_OF_MEASURE_CODE
3845 <NAME>_DEFAULT
3846 <NAME>_MINIMUM
3847 <NAME>_MAXIMUM
3848 --
3849 The following database items are created if multiple entries are NOT
3850 allowed:
3851 --
3852 <NAME>_ENTRY_VALUE
3853 <NAME>_USER_ENTERED_CODE
3854 <NAME>_START_DATE
3855 <NAME>_END_DATE
3856 --
3857 The following database item is created if the multiple entries are
3858 allowed:
3859 --
3860 <NAME>_ENTRY_VALUE (sum of all non recurring values)
3861 */
3862 procedure create_input_value
3863 (
3864 p_input_value_id in number,
3865 p_effective_date in date,
3866 p_date_p in varchar2
3867 ) is
3868 l_route1_name varchar2(50) := 'INPUT_VALUE_FROM_INPUT_VALUE_TABLE' ||p_date_p;
3869 l_route2_name varchar2(50) := 'INPUT_VALUE_USING_PARTIAL_MATCHING' ||p_date_p;
3870 l_entry_route varchar2(50) := 'INPUT_VALUE_ENTRY_LEVEL' || p_date_p;
3871 l_override_entry_route varchar2(50) := 'INPUT_VALUE_ENTRY_LEVEL_OVERRIDE' || p_date_p;
3872 l_input_name pay_input_values_f.name%type;
3873 l_entity_name ff_user_entities.user_entity_name%type;
3874 l_element_type_id pay_element_types_f.element_type_id%type;
3875 l_element_name pay_element_types_f.element_name%type;
3876 l_multiple_entries pay_element_types_f.multiple_entries_allowed_flag%type;
3877 l_legislation_code pay_element_types_f.legislation_code%type;
3878 l_leg_code_ben pay_element_types_f.legislation_code%type;
3879 l_uom varchar2(30); -- unit of measure
3880 l_business_group_id number;
3881 l_start_string varchar2(240);
3882 l_end_string varchar2(240);
3883 l_data_type varchar2(1);
3884 l_created_by number;
3885 l_last_login number;
3886 l_record_inserted boolean;
3887 l_full_mls boolean;
3888 l_base_dbi_name varchar2(2000);
3889 l_user_entity_id number;
3890 l_legislation_code1 pay_element_types_f.legislation_code%type;
3891 l_startup_mode varchar2(30);
3892 l_languages dbms_sql.varchar2s;
3893 l_dbi_prefixes t_dbi_prefixes;
3894 --
3895 -- debug info
3896 l_iv_eltypeid number;
3897
3898 --
3899 cursor c_language is
3900 select language_code
3901 from fnd_languages
3902 where installed_flag in ('I','B');
3903
3904 cursor c_list_ivs(p_iv_id in number) is
3905 select name,
3906 element_type_id,
3907 to_char(effective_start_date, 'DD-MM-YYYY') esd,
3908 to_char(effective_end_date, 'DD-MM-YYYY') eed,
3909 legislation_code,
3910 business_group_id
3911 from pay_input_values_f
3912 where input_value_id = p_iv_id;
3913
3914 cursor c_list_elements(p_el_id in number) is
3915 select element_name,
3916 to_char(effective_start_date, 'DD-MM-YYYY') esd,
3917 to_char(effective_end_date, 'DD-MM-YYYY') eed,
3918 legislation_code,
3919 business_group_id
3920 from pay_element_types_f
3921 where element_type_id = p_el_id;
3922
3923 -- This procedure is used to translate hardcoded "Pay Value"
3924 -- for each language installed.
3925 --
3926 PROCEDURE local_insert_database_item (
3927 p_item_name in varchar2,
3928 p_data_type in varchar2,
3929 p_definition_text in varchar2,
3930 p_null_allowed_flag in varchar2,
3931 p_description in varchar2,
3932 p_user_entity_id in number,
3933 p_full_mls in boolean,
3934 p_base_dbi_name out nocopy varchar2)
3935 IS
3936 BEGIN
3937 --
3938 -- NB attention spaces ' ' of l_input_name are not replaced with underscore '_'.
3939 --
3940 -- call to insert_database_item to handle Pay_Value issue : Bug 1110849
3941 -- where if the input value found is Pay Value get dbitem created
3942 -- to contain the translated value for Pay Value by passing the input value
3943 -- name within the second parameter which goes through translation
3944 -- lookup in insert_database_item.
3945 --
3946 if l_input_name = 'PAY VALUE' and not p_full_mls then
3947 insert_database_item (l_element_name,
3948 l_input_name || '_' || p_item_name || p_date_p,
3949 p_data_type,
3950 p_definition_text,
3951 p_null_allowed_flag,
3952 p_description,
3953 p_user_entity_id,
3954 p_full_mls,
3955 p_base_dbi_name);
3956 else
3957 insert_database_item (l_entity_name,
3958 p_item_name || p_date_p,
3959 p_data_type,
3960 p_definition_text,
3961 p_null_allowed_flag,
3962 p_description,
3963 p_user_entity_id,
3964 p_full_mls,
3965 p_base_dbi_name);
3966 end if;
3967 END local_insert_database_item;
3968 --
3969 -- NOTE: The variable 'l_entity_name' is used to hold both the element type
3970 -- name concatenated with the input value name. This exceeds the maximum
3971 -- length of the database item name. On attempting to create the associated
3972 -- db item, it is possible that the constructed name will exceed this maximum.
3973 -- We rely on this being trapped by the insert statement failing.
3974 --
3975 ------------------------- create_input_value -----------------------------
3976 --
3977 BEGIN
3978 --
3979 -- get the input and element type information
3980 --
3981 BEGIN
3982 select ltrim (rtrim (upper (INPUTV.name))),
3983 INPUTV.uom,
3984 INPUTV.business_group_id,
3985 ltrim(rtrim(INPUTV.legislation_code)),
3986 INPUTV.created_by,
3987 INPUTV.last_update_login,
3988 ET.element_type_id,
3989 replace (ltrim (rtrim (upper (ET.element_name))), ' ', '_'),
3990 ET.multiple_entries_allowed_flag
3991 into l_input_name,
3992 l_uom,
3993 l_business_group_id,
3994 l_legislation_code,
3995 l_created_by,
3996 l_last_login,
3997 l_element_type_id,
3998 l_element_name,
3999 l_multiple_entries
4000 from pay_input_values_f INPUTV
4001 , pay_element_types_f ET
4002 where INPUTV.input_value_id = p_input_value_id
4003 and p_effective_date between INPUTV.effective_start_date
4004 and INPUTV.effective_end_date
4005 and ET.element_type_id = INPUTV.element_type_id
4006 and p_effective_date between ET.effective_start_date
4007 and ET.effective_end_date;
4008 EXCEPTION WHEN OTHERS THEN
4009 BEGIN
4010 hrrbdeib_trace_on;
4011 hr_utility.trace('create_input_value select');
4012 hr_utility.trace('effective_date: ' ||
4013 to_char(p_effective_date, 'DD-MM-YYYY'));
4014 hr_utility.trace('input_value_id : ' || to_char(p_input_value_id));
4015
4016 FOR iv IN c_list_ivs(p_input_value_id) LOOP
4017 hr_utility.trace('input name: ' || iv.name);
4018 hr_utility.trace('input el_type_id: ' ||
4019 to_char(iv.element_type_id));
4020 hr_utility.trace('input leg_code: ' || iv.legislation_code);
4021 hr_utility.trace('input BG id: ' || to_char(iv.business_group_id));
4022 hr_utility.trace('input ESD: ' || iv.esd);
4023 hr_utility.trace('input EED: ' || iv.eed);
4024 END LOOP;
4025
4026 select distinct element_type_id
4027 into l_iv_eltypeid
4028 from pay_input_values_f
4029 where input_value_id = p_input_value_id
4030 and rownum = 1;
4031
4032 FOR el in c_list_elements(l_iv_eltypeid) LOOP
4033 hr_utility.trace('element name: ' || el.element_name);
4034 hr_utility.trace('element ESD: ' || el.esd);
4035 hr_utility.trace('element EED: ' || el.eed);
4036 hr_utility.trace('element leg_code: ' || el.legislation_code);
4037 hr_utility.trace('element BG id: ' || to_char(el.business_group_id));
4038 END LOOP;
4039 hrrbdeib_trace_off;
4040 raise;
4041 END;
4042 END;
4043 --
4044 if (g_triggers_altered) then
4045 -- Get the startup mode
4046 l_startup_mode :=
4047 ffstup.get_mode (l_business_group_id, l_legislation_code);
4048 else
4049 -- Get the security group id which won't have been populated yet.
4050 g_security_group_id :=
4051 fnd_global.lookup_security_group('NAME_TRANSLATIONS', 3);
4052 end if;
4053 --
4054 -- Are the database items to be fully translated ?
4055 --
4056 l_legislation_code1 := l_legislation_code;
4057 if l_legislation_code1 is null and l_business_group_id is not null then
4058 select bg.legislation_code
4059 into l_legislation_code1
4060 from per_business_groups_perf bg
4061 where bg.business_group_id = l_business_group_id
4062 ;
4063 end if;
4064 l_full_mls := ff_dbi_utils_pkg.translations_supported(l_legislation_code1);
4065
4066 --
4067 -- Set up the data for the full MLS case.
4068 --
4069 if l_full_mls then
4070 open c_language;
4071 fetch c_language bulk collect
4072 into l_languages;
4073 close c_language;
4074
4075 gen_eiv_dbi_prefixes
4076 (p_input_value_id => p_input_value_id
4077 ,p_effective_date => p_effective_date
4078 ,p_languages => l_languages
4079 ,p_prefixes => l_dbi_prefixes
4080 );
4081 end if;
4082 --
4083 -- assemble the entity name:
4084 -- nb spaces ' ' of l_input_name are not replaced with underscore '_'.
4085 -- now pass l_entity_name to insert_user_entity and
4086 -- use local_insert_database_item instead of direct call to
4087 -- insert_database_item to handle Pay_Value issue : Bug 1110849
4088 -- where if the input value found is Pay value get dbitem created
4089 -- to contain the translated value for Pay Value.
4090 --
4091 -- Bug 2936561. Remove full stops from input value nams prior to
4092 -- ue and dbi creation.
4093 --
4094 l_entity_name := l_element_name || '_' || replace(replace(l_input_name,' ','_'),
4095 '.','');
4096 --
4097 -- create the user entity for the first route
4098 --
4099 insert_user_entity (l_route1_name,
4100 l_entity_name || '_I1' || p_date_p,
4101 'entity for '|| l_route1_name,
4102 'Y', -- not found allowed flag
4103 'I',
4104 p_input_value_id,
4105 l_business_group_id,
4106 l_legislation_code,
4107 l_created_by,
4108 l_last_login,
4109 l_record_inserted);
4110 --
4111 -- only insert parameter values/database items if an entity was inserted
4112 --
4113 IF l_record_inserted THEN
4114 --
4115 -- Fetch the user_entity_id.
4116 --
4117 select ff_user_entities_s.currval
4118 into l_user_entity_id
4119 from dual;
4120 --
4121 -- insert the input value id for the where clause filler
4122 --
4123 insert_parameter_value (p_input_value_id, 1);
4124 --
4125 -- load up the database items for the first route:
4126 --
4127 local_insert_database_item (
4128 'UNIT_OF_MEASURE',
4129 'T', -- data type
4130 'UMLOOK.meaning',
4131 'N', -- null allowed
4132 'unit of measure from lookup table for input value',
4133 l_user_entity_id,
4134 l_full_mls,
4135 l_base_dbi_name);
4136 --
4137 if l_full_mls then
4138 update_et_tl_dbi_names
4139 (p_leg_code => l_legislation_code
4140 ,p_bg_id => l_business_group_id
4141 ,p_startup_mode => l_startup_mode
4142 ,p_user_name => l_base_dbi_name
4143 ,p_user_entity_id => l_user_entity_id
4144 ,p_prefixes => l_dbi_prefixes
4145 ,p_suffix => 'UNIT_OF_MEASURE'
4146 ,p_date_p => p_date_p
4147 );
4148 end if;
4149 --
4150 local_insert_database_item (
4151 'UNIT_OF_MEASURE_CODE',
4152 'T', -- data type
4153 'INPUTV.uom',
4154 'N', -- null allowed
4155 'unit of measure held on the database for input value',
4156 l_user_entity_id,
4157 l_full_mls,
4158 l_base_dbi_name);
4159 --
4160 if l_full_mls then
4161 update_et_tl_dbi_names
4162 (p_leg_code => l_legislation_code
4163 ,p_bg_id => l_business_group_id
4164 ,p_startup_mode => l_startup_mode
4165 ,p_user_name => l_base_dbi_name
4166 ,p_user_entity_id => l_user_entity_id
4167 ,p_prefixes => l_dbi_prefixes
4168 ,p_suffix => 'UNIT_OF_MEASURE_CODE'
4169 ,p_date_p => p_date_p
4170 );
4171 end if;
4172 END IF;
4173 --
4174 -- create the user entity for the second route
4175 --
4176 insert_user_entity (l_route2_name,
4177 l_entity_name || '_I2' || p_date_p,
4178 'entity for '|| l_route2_name,
4179 'Y', -- not found allowed flag
4180 'I',
4181 p_input_value_id,
4182 l_business_group_id,
4183 l_legislation_code,
4184 l_created_by,
4185 l_last_login,
4186 l_record_inserted);
4187 --
4188 l_start_string := null;
4189 l_end_string := null;
4190 --
4191 -- note : If several input values that use the same route are created in
4192 -- a formula, then formula will fetch them all at once in one cursor. A
4193 -- problem arises when the database item has a user definable data type,
4194 -- for example input values. If several items are used within the same
4195 -- formula and the data types are different, formula will fetch them all
4196 -- in one cursor and get confused about which data types belong to which
4197 -- items. To avoid this the decode statment is added to the definition
4198 -- text for the DB item.
4199 --
4200 if (l_uom = 'D') then -- a date, all formula dates to be in cannonical format
4201 l_start_string := 'fnd_date.canonical_to_date(decode(substr(INPUTV.uom,1,1),''D'',';
4202 l_end_string := ',null))';
4203 l_data_type := 'D';
4204 elsif (l_uom = 'M') or (l_uom = 'N') or (l_uom = 'I') then
4205 l_start_string := 'fffunc.cn(decode(
4206 decode(INPUTV.uom,''M'',''N'',''N'',''N'',''I'',''N'',null),''N'',';
4207 l_end_string := ',null))';
4208 l_data_type := 'N';
4209 elsif (l_uom like 'H_%') then
4210 l_start_string := 'fffunc.cn(decode(
4211 decode(substr(INPUTV.uom,1,2),''H_'',''N'',null),''N'',';
4212 l_end_string := ',null))';
4213 l_data_type := 'N';
4214 else
4215 l_data_type := 'T';
4216 end if;
4217 --
4218 -- only insert parameter values/database items if an entity was inserted
4219 --
4220 IF l_record_inserted THEN
4221 --
4222 -- Fetch the user_entity_id.
4223 --
4224 select ff_user_entities_s.currval
4225 into l_user_entity_id
4226 from dual;
4227 --
4228 -- insert the input value id for the where clause filler
4229 --
4230 insert_parameter_value (p_input_value_id, 1);
4231 --
4232 -- load up the database items for the second route:
4233 --
4234 -- arrange the values to be displayed in the format specified by the UOM
4235 local_insert_database_item (
4236 'DEFAULT',
4237 l_data_type, -- data type
4238 l_start_string||'nvl(LIV.default_value,INPUTV.default_value)'|| l_end_string,
4239 'Y', -- null allowed
4240 'default value for input value',
4241 l_user_entity_id,
4242 l_full_mls,
4243 l_base_dbi_name);
4244 --
4245 if l_full_mls then
4246 update_et_tl_dbi_names
4247 (p_leg_code => l_legislation_code
4248 ,p_bg_id => l_business_group_id
4249 ,p_startup_mode => l_startup_mode
4250 ,p_user_name => l_base_dbi_name
4251 ,p_user_entity_id => l_user_entity_id
4252 ,p_prefixes => l_dbi_prefixes
4253 ,p_suffix => 'DEFAULT'
4254 ,p_date_p => p_date_p
4255 );
4256 end if;
4257 --
4258 local_insert_database_item (
4259 'MIN',
4260 l_data_type, -- data type
4261 l_start_string || 'nvl(LIV.min_value,INPUTV.min_value)' || l_end_string,
4262 'Y', -- null allowed
4263 'minimum value for input value',
4264 l_user_entity_id,
4265 l_full_mls,
4266 l_base_dbi_name);
4267 --
4268 if l_full_mls then
4269 update_et_tl_dbi_names
4270 (p_leg_code => l_legislation_code
4271 ,p_bg_id => l_business_group_id
4272 ,p_startup_mode => l_startup_mode
4273 ,p_user_name => l_base_dbi_name
4274 ,p_user_entity_id => l_user_entity_id
4275 ,p_prefixes => l_dbi_prefixes
4276 ,p_suffix => 'MIN'
4277 ,p_date_p => p_date_p
4278 );
4279 end if;
4280 --
4281 local_insert_database_item (
4282 'MAX',
4283 l_data_type, -- data type
4284 l_start_string || 'nvl(LIV.max_value,INPUTV.max_value)' || l_end_string,
4285 'Y', -- null allowed
4286 'maximum value for input value',
4287 l_user_entity_id,
4288 l_full_mls,
4289 l_base_dbi_name);
4290 --
4291 if l_full_mls then
4292 update_et_tl_dbi_names
4293 (p_leg_code => l_legislation_code
4294 ,p_bg_id => l_business_group_id
4295 ,p_startup_mode => l_startup_mode
4296 ,p_user_name => l_base_dbi_name
4297 ,p_user_entity_id => l_user_entity_id
4298 ,p_prefixes => l_dbi_prefixes
4299 ,p_suffix => 'MAX'
4300 ,p_date_p => p_date_p
4301 );
4302 end if;
4303 END IF;
4304 --
4305 -- now create database items depending whether the element is recurring
4306 -- or non-recurring
4307 --
4308 if (l_multiple_entries = 'N') then -- multiple entries not allowed
4309 begin
4310 -- note: These non multi entry database items share the same route
4311 -- as the multi entry DB item which has a group function (a 'sum'
4312 -- function) as part of its definition text. Therefore these DB
4313 -- items must also have a dummy group function ('min') as part
4314 -- of their definition text even though they will only return one
4315 -- row.
4316 -- This is to allow for the case when a formula has both
4317 -- types of these DB items, as it will use the same
4318 -- cursor for both sets of DB items. This would result in an
4319 -- illegal SQL statement, where it was missing a 'group by'
4320 -- clause. Since the 'group by' clause cannot be part of the route,
4321 -- all of the following DB items must contain a dummy group
4322 -- function. Also, since null is returned for a group function
4323 -- with no rows, the null allowed flag must be set to 'yes'.
4324 --
4325 -- The only other solution to this problem would be to have 2
4326 -- identical routes, one for multi entry allowed, the other for
4327 -- non multi entry allowed. Since we wanted to minimise the
4328 -- number of routes, this solution was not implemented.
4329 --
4330 --
4331 -- create the user entity for the non multiple entry types
4332 --
4333 insert_user_entity (l_entry_route,
4334 l_entity_name || '_I3' || p_date_p,
4335 'non multiple entry entity for '|| l_entry_route,
4336 'Y', -- not found allowed flag
4337 'I',
4338 p_input_value_id,
4339 l_business_group_id,
4340 l_legislation_code,
4341 l_created_by,
4342 l_last_login,
4343 l_record_inserted);
4344 --
4345 -- only insert parameter values/database items if entity
4346 -- was inserted
4347 --
4348 IF l_record_inserted THEN
4349 --
4350 -- Fetch the user_entity_id.
4351 --
4352 select ff_user_entities_s.currval
4353 into l_user_entity_id
4354 from dual;
4355 --
4356 -- insert the input value id for the where clause filler
4357 --
4358 insert_parameter_value (p_input_value_id, 1);
4359 --
4360 -- insert the element type id for the 2nd where clause filler
4361 --
4362 IF p_date_p IS NULL THEN
4363 insert_parameter_value (l_element_type_id, 2);
4364 END IF;
4365 --
4366 -- load up the database items for the non multiple entry types:
4367 --
4368 local_insert_database_item (
4369 'ENTRY_VALUE',
4370 l_data_type, -- data type
4371 'min (' || l_start_string ||
4372 'decode(INPUTV.hot_default_flag,''Y'',nvl(EEV.screen_entry_value,
4373 nvl(LIV.default_value,INPUTV.default_value)),''N'',EEV.screen_entry_value)'
4374 || l_end_string || ')',
4375 'Y', -- null allowed
4376 'the recurring value',
4377 l_user_entity_id,
4378 l_full_mls,
4379 l_base_dbi_name);
4380 --
4381 if l_full_mls then
4382 update_et_tl_dbi_names
4383 (p_leg_code => l_legislation_code
4384 ,p_bg_id => l_business_group_id
4385 ,p_startup_mode => l_startup_mode
4386 ,p_user_name => l_base_dbi_name
4387 ,p_user_entity_id => l_user_entity_id
4388 ,p_prefixes => l_dbi_prefixes
4389 ,p_suffix => 'ENTRY_VALUE'
4390 ,p_date_p => p_date_p
4391 );
4392 end if;
4393 --
4394 local_insert_database_item (
4395 'USER_ENTERED_CODE',
4396 'T', -- data type
4397 'min(decode(EEV.screen_entry_value,null,''N'',''Y''))',
4398 'Y', -- null allowed
4399 'indicates if a value exists at the element entry level',
4400 l_user_entity_id,
4401 l_full_mls,
4402 l_base_dbi_name);
4403 --
4404 if l_full_mls then
4405 update_et_tl_dbi_names
4406 (p_leg_code => l_legislation_code
4407 ,p_bg_id => l_business_group_id
4408 ,p_startup_mode => l_startup_mode
4409 ,p_user_name => l_base_dbi_name
4410 ,p_user_entity_id => l_user_entity_id
4411 ,p_prefixes => l_dbi_prefixes
4412 ,p_suffix => 'USER_ENTERED_CODE'
4413 ,p_date_p => p_date_p
4414 );
4415 end if;
4416 --
4417 local_insert_database_item (
4418 'START_DATE',
4419 'D', -- data type
4420 'min(EE.effective_start_date)',
4421 'Y', -- null allowed
4422 'start date of element',
4423 l_user_entity_id,
4424 l_full_mls,
4425 l_base_dbi_name);
4426 --
4427 if l_full_mls then
4428 update_et_tl_dbi_names
4429 (p_leg_code => l_legislation_code
4430 ,p_bg_id => l_business_group_id
4431 ,p_startup_mode => l_startup_mode
4432 ,p_user_name => l_base_dbi_name
4433 ,p_user_entity_id => l_user_entity_id
4434 ,p_prefixes => l_dbi_prefixes
4435 ,p_suffix => 'START_DATE'
4436 ,p_date_p => p_date_p
4437 );
4438 end if;
4439 --
4440 local_insert_database_item (
4441 'END_DATE',
4442 'D', -- data type
4443 'min(EE.effective_end_date)',
4444 'Y', -- null allowed
4445 'end date of element',
4446 l_user_entity_id,
4447 l_full_mls,
4448 l_base_dbi_name);
4449 --
4450 if l_full_mls then
4451 update_et_tl_dbi_names
4452 (p_leg_code => l_legislation_code
4453 ,p_bg_id => l_business_group_id
4454 ,p_startup_mode => l_startup_mode
4455 ,p_user_name => l_base_dbi_name
4456 ,p_user_entity_id => l_user_entity_id
4457 ,p_prefixes => l_dbi_prefixes
4458 ,p_suffix => 'END_DATE'
4459 ,p_date_p => p_date_p
4460 );
4461 end if;
4462 END IF;
4463 --
4464 -- Override Entry dbitems
4465 --
4466 insert_user_entity (l_override_entry_route,
4467 l_entity_name || '_I4' || p_date_p,
4468 'non multiple entry entity for '|| l_override_entry_route,
4469 'Y', -- not found allowed flag
4470 'I',
4471 p_input_value_id,
4472 l_business_group_id,
4473 l_legislation_code,
4474 l_created_by,
4475 l_last_login,
4476 l_record_inserted);
4477 --
4478 -- only insert parameter values/database items if entity
4479 -- was inserted
4480 --
4481 IF l_record_inserted THEN
4482 --
4483 -- Fetch the user_entity_id.
4484 --
4485 select ff_user_entities_s.currval
4486 into l_user_entity_id
4487 from dual;
4488 --
4489 -- insert the input value id for the where clause filler
4490 --
4491 insert_parameter_value (p_input_value_id, 1);
4492 --
4493 -- insert the element type id for the 2nd where clause filler
4494 --
4495 IF p_date_p IS NULL THEN
4496 insert_parameter_value (l_element_type_id, 2);
4497 END IF;
4498 --
4499 -- load up the database items for the non multiple entry types:
4500 --
4501 local_insert_database_item (
4502 'OVERRIDE_ENTRY_VALUE',
4503 l_data_type, -- data type
4504 'min (' || l_start_string ||
4505 'decode(INPUTV.hot_default_flag,''Y'',nvl(EEV.screen_entry_value,
4506 nvl(LIV.default_value,INPUTV.default_value)),''N'',EEV.screen_entry_value)'
4507 || l_end_string || ')',
4508 'Y', -- null allowed
4509 'the recurring value',
4510 l_user_entity_id,
4511 l_full_mls,
4512 l_base_dbi_name);
4513 --
4514 if l_full_mls then
4515 update_et_tl_dbi_names
4516 (p_leg_code => l_legislation_code
4517 ,p_bg_id => l_business_group_id
4518 ,p_startup_mode => l_startup_mode
4519 ,p_user_name => l_base_dbi_name
4520 ,p_user_entity_id => l_user_entity_id
4521 ,p_prefixes => l_dbi_prefixes
4522 ,p_suffix => 'OVERRIDE_ENTRY_VALUE'
4523 ,p_date_p => p_date_p
4524 );
4525 end if;
4526 --
4527 local_insert_database_item (
4528 'OVERRIDE_USER_ENTERED_CODE',
4529 'T', -- data type
4530 'min(decode(EEV.screen_entry_value,null,''N'',''Y''))',
4531 'Y', -- null allowed
4532 'indicates if a value exists at the element entry level',
4533 l_user_entity_id,
4534 l_full_mls,
4535 l_base_dbi_name);
4536 --
4537 if l_full_mls then
4538 update_et_tl_dbi_names
4539 (p_leg_code => l_legislation_code
4540 ,p_bg_id => l_business_group_id
4541 ,p_startup_mode => l_startup_mode
4542 ,p_user_name => l_base_dbi_name
4543 ,p_user_entity_id => l_user_entity_id
4544 ,p_prefixes => l_dbi_prefixes
4545 ,p_suffix => 'OVERRIDE_USER_ENTERED_CODE'
4546 ,p_date_p => p_date_p
4547 );
4548 end if;
4549 --
4550 local_insert_database_item (
4551 'OVERRIDE_START_DATE',
4552 'D', -- data type
4553 'min(EE.effective_start_date)',
4554 'Y', -- null allowed
4555 'start date of element',
4556 l_user_entity_id,
4557 l_full_mls,
4558 l_base_dbi_name);
4559 --
4560 if l_full_mls then
4561 update_et_tl_dbi_names
4562 (p_leg_code => l_legislation_code
4563 ,p_bg_id => l_business_group_id
4564 ,p_startup_mode => l_startup_mode
4565 ,p_user_name => l_base_dbi_name
4566 ,p_user_entity_id => l_user_entity_id
4567 ,p_prefixes => l_dbi_prefixes
4568 ,p_suffix => 'OVERRIDE_START_DATE'
4569 ,p_date_p => p_date_p
4570 );
4571 end if;
4572 --
4573 local_insert_database_item (
4574 'OVERRIDE_END_DATE',
4575 'D', -- data type
4576 'min(EE.effective_end_date)',
4577 'Y', -- null allowed
4578 'end date of element',
4579 l_user_entity_id,
4580 l_full_mls,
4581 l_base_dbi_name);
4582 --
4583 if l_full_mls then
4584 update_et_tl_dbi_names
4585 (p_leg_code => l_legislation_code
4586 ,p_bg_id => l_business_group_id
4587 ,p_startup_mode => l_startup_mode
4588 ,p_user_name => l_base_dbi_name
4589 ,p_user_entity_id => l_user_entity_id
4590 ,p_prefixes => l_dbi_prefixes
4591 ,p_suffix => 'OVERRIDE_END_DATE'
4592 ,p_date_p => p_date_p
4593 );
4594 end if;
4595 END IF;
4596 end;
4597 else -- multiple entries allowed
4598 --
4599 -- for multiple entries allowed, UOM must be hours, money or number,
4600 -- as it is summed in the definition text
4601 --
4602 if uom_requires_dbis(p_uom => l_uom) then
4603 begin
4604 --
4605 -- create the user entity for the multiple entries element
4606 --
4607 insert_user_entity (l_entry_route,
4608 l_entity_name || '_I3' || p_date_p,
4609 'multiple entry entity for '|| l_entry_route,
4610 'Y',
4611 'I',
4612 p_input_value_id,
4613 l_business_group_id,
4614 l_legislation_code,
4615 l_created_by,
4616 l_last_login,
4617 l_record_inserted);
4618 --
4619 -- only insert parameter values/database items if entity
4620 -- was inserted
4621 --
4622 IF l_record_inserted THEN
4623 --
4624 -- Fetch the user_entity_id.
4625 --
4626 select ff_user_entities_s.currval
4627 into l_user_entity_id
4628 from dual;
4629 --
4630 -- insert the input value id for the where clause filler
4631 --
4632 insert_parameter_value (p_input_value_id, 1);
4633 --
4634 -- insert the element type id for the 2nd where clause filler
4635 --
4636 IF p_date_p IS NULL THEN
4637 insert_parameter_value (l_element_type_id, 2);
4638 END IF;
4639 --
4640 -- load up the database items for the multiple entry items:
4641 --
4642 local_insert_database_item (
4643 'ENTRY_VALUE',
4644 l_data_type, -- data type
4645 'sum(' || l_start_string || 'decode(INPUTV.hot_default_flag,
4646 ''Y'',nvl(EEV.screen_entry_value,
4647 nvl(LIV.default_value,INPUTV.default_value)),
4648 ''N'',EEV.screen_entry_value)' || l_end_string || ')',
4649 'Y', -- null allowed
4650 'the summed multiple entry element values',
4651 l_user_entity_id,
4652 l_full_mls,
4653 l_base_dbi_name);
4654 --
4655 if l_full_mls then
4656 update_et_tl_dbi_names
4657 (p_leg_code => l_legislation_code
4658 ,p_bg_id => l_business_group_id
4659 ,p_startup_mode => l_startup_mode
4660 ,p_user_name => l_base_dbi_name
4661 ,p_user_entity_id => l_user_entity_id
4662 ,p_prefixes => l_dbi_prefixes
4663 ,p_suffix => 'ENTRY_VALUE'
4664 ,p_date_p => p_date_p
4665 );
4666 end if;
4667 END IF;
4668 --
4669 -- Override Entry dbitems
4670 --
4671 insert_user_entity (l_override_entry_route,
4672 l_entity_name || '_I4' || p_date_p,
4673 'multiple entry entity for '|| l_override_entry_route,
4674 'Y',
4675 'I',
4676 p_input_value_id,
4677 l_business_group_id,
4678 l_legislation_code,
4679 l_created_by,
4680 l_last_login,
4681 l_record_inserted);
4682 --
4683 -- only insert parameter values/database items if entity
4684 -- was inserted
4685 --
4686 IF l_record_inserted THEN
4687 --
4688 -- Fetch the user_entity_id.
4689 --
4690 select ff_user_entities_s.currval
4691 into l_user_entity_id
4692 from dual;
4693 --
4694 -- insert the input value id for the where clause filler
4695 --
4696 insert_parameter_value (p_input_value_id, 1);
4697 --
4698 -- insert the element type id for the 2nd where clause filler
4699 --
4700 IF p_date_p IS NULL THEN
4701 insert_parameter_value (l_element_type_id, 2);
4702 END IF;
4703 --
4704 -- load up the database items for the multiple entry items:
4705 --
4706 local_insert_database_item (
4707 'OVERRIDE_ENTRY_VALUE',
4708 l_data_type, -- data type
4709 'sum(' || l_start_string || 'decode(INPUTV.hot_default_flag,
4710 ''Y'',nvl(EEV.screen_entry_value,
4711 nvl(LIV.default_value,INPUTV.default_value)),
4712 ''N'',EEV.screen_entry_value)' || l_end_string || ')',
4713 'Y', -- null allowed
4714 'the summed multiple entry element values',
4715 l_user_entity_id,
4716 l_full_mls,
4717 l_base_dbi_name);
4718 --
4719 if l_full_mls then
4720 update_et_tl_dbi_names
4721 (p_leg_code => l_legislation_code
4722 ,p_bg_id => l_business_group_id
4723 ,p_startup_mode => l_startup_mode
4724 ,p_user_name => l_base_dbi_name
4725 ,p_user_entity_id => l_user_entity_id
4726 ,p_prefixes => l_dbi_prefixes
4727 ,p_suffix => 'OVERRIDE_ENTRY_VALUE'
4728 ,p_date_p => p_date_p
4729 );
4730 end if;
4731 END IF;
4732 end;
4733 end if;
4734 end if;
4735 --
4736 -- create the benefit input values if legislation = US.
4737 --
4738
4739 select nvl (ltrim(rtrim(INPUTV.legislation_code)),
4740 ltrim(rtrim(BUSGP.legislation_code)))
4741 into l_leg_code_ben
4742 from pay_input_values_f INPUTV
4743 , per_business_groups_perf BUSGP
4744 where INPUTV.input_value_id = p_input_value_id
4745 and p_effective_date between INPUTV.effective_start_date
4746 and INPUTV.effective_end_date
4747 and BUSGP.business_group_id (+) = INPUTV.business_group_id;
4748
4749 --
4750 if (l_leg_code_ben = 'US') then
4751 pay_us_contr_dbi.create_contr_items (p_input_value_id,
4752 p_effective_date,
4753 l_start_string,
4754 l_end_string,
4755 l_data_type);
4756 end if;
4757 END create_input_value;
4758 --
4759 --
4760 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4761 -- +
4762 -- create_input_value_dict +
4763 -- +
4764 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4765 /*
4766 NAME
4767 create_input_value_dict - create an input value in the data
4768 dictionary
4769 --
4770 DESCRIPTION
4771 This procedure is the main entry point for creating database items for
4772 a given input value, where the context is date earned. It calls the
4773 input value creation procedure : create_input_value.
4774 */
4775 procedure create_input_value_dict
4776 (
4777 p_input_value_id in number,
4778 p_effective_date in date
4779 ) is
4780 begin
4781 create_input_value (p_input_value_id,
4782 p_effective_date,
4783 null);
4784 end create_input_value_dict;
4785 --
4786 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4787 -- +
4788 -- refresh_element_types +
4789 -- +
4790 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4791 /*
4792 NAME
4793 refresh_element_types - create all DB items for element type and input
4794 values
4795 --
4796 DESCRIPTION
4797 This routine creates all database items based on element types
4798 in the system. The routine assumes that no such database items currently
4799 exist.
4800 */
4801 procedure refresh_element_types(p_worker_id in number default 0,
4802 p_maxworkers in number default 1) is
4803 cursor c1 is select element_type_id,
4804 max(effective_end_date)
4805 from pay_element_types_f e
4806 where not exists (
4807 select null
4808 from ff_user_entities u
4809 where u.creator_id = e.element_type_id
4810 and u.creator_type = 'E')
4811 and mod(element_type_id, p_maxworkers) = p_worker_id
4812 group by element_type_id
4813 order by element_type_id;
4814 --
4815 cursor c2 is select input_value_id,
4816 max(effective_end_date)
4817 from pay_input_values_f i
4818 where generate_db_items_flag = 'Y'
4819 and not exists (
4820 select null
4821 from ff_user_entities u
4822 where u.creator_id = i.input_value_id
4823 and u.creator_type = 'I')
4824 and mod(input_value_id, p_maxworkers) = p_worker_id
4825 group by input_value_id
4826 order by input_value_id;
4827
4828 l_input_value_id number;
4829 l_element_type_id number;
4830 l_date date;
4831 l_loop_cnt number;
4832
4833 begin
4834 --
4835 -- create element types
4836 --
4837 hrrbdeib_trace_on;
4838 hr_utility.trace('entering refresh_el types elements all' ||
4839 ' worker: ' || to_char(p_worker_id + 1) || '/' ||
4840 to_char(p_maxworkers));
4841 hrrbdeib_trace_off;
4842
4843 l_loop_cnt := 0;
4844
4845 open c1;
4846 loop
4847 fetch c1 into l_element_type_id,
4848 l_date;
4849 EXIT when c1%notfound;
4850 hrrbdeib_trace_on;
4851 hr_utility.trace('RELE:'|| to_char(p_worker_id + 1) || ':' ||
4852 to_char(l_element_type_id) || '.' ||
4853 to_char(l_date,'DD-MM-YYYY'));
4854 hrrbdeib_trace_off;
4855 create_element_type_dict (l_element_type_id, l_date);
4856
4857 l_loop_cnt := l_loop_cnt + 1;
4858 if l_loop_cnt > 100 then
4859 l_loop_cnt := 0;
4860 commit;
4861 end if;
4862
4863 end loop;
4864 close c1;
4865 --
4866 -- create input values
4867 --
4868 hrrbdeib_trace_on;
4869 hr_utility.trace('leaving refresh_el types elements all' ||
4870 ' worker: ' || to_char(p_worker_id + 1) || '/' ||
4871 to_char(p_maxworkers));
4872
4873 hr_utility.trace('entering refresh_el types ivs all' ||
4874 ' worker: ' || to_char(p_worker_id + 1) || '/' ||
4875 to_char(p_maxworkers));
4876 hrrbdeib_trace_off;
4877
4878 l_loop_cnt := 0;
4879
4880 open c2;
4881 loop
4882 fetch c2 into l_input_value_id,
4883 l_date;
4884 EXIT when c2%notfound;
4885 hrrbdeib_trace_on;
4886 hr_utility.trace('RELI:'|| to_char(p_worker_id + 1) || ':' ||
4887 to_char(l_input_value_id) || '.' ||
4888 to_char(l_date,'DD-MM-YYYY'));
4889 hrrbdeib_trace_off;
4890 create_input_value_dict (l_input_value_id, l_date);
4891
4892 l_loop_cnt := l_loop_cnt + 1;
4893 if l_loop_cnt > 100 then
4894 l_loop_cnt := 0;
4895 commit;
4896 end if;
4897
4898 end loop;
4899 close c2;
4900
4901 hrrbdeib_trace_on;
4902 hr_utility.trace('leaving refresh_el types ivs all' ||
4903 ' worker: ' || to_char(p_worker_id + 1) || '/' ||
4904 to_char(p_maxworkers));
4905 hrrbdeib_trace_off;
4906
4907 end refresh_element_types;
4908 --
4909 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4910 -- +
4911 -- refresh_element_types +
4912 -- +
4913 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4914 /*
4915 NAME
4916 refresh_element_types - create all DB items for element type and input
4917 values
4918 --
4919 DESCRIPTION
4920 This routine creates all database items based on element types
4921 in the system. The routine assumes that no such database items currently
4922 exist.
4923 */
4924 procedure refresh_element_types(p_leg_code in varchar2,
4925 p_worker_id in number default 0,
4926 p_maxworkers in number default 1) is
4927 cursor c1 is select element_type_id,
4928 max(effective_end_date)
4929 from pay_element_types_f a
4930 where not exists (
4931 select null
4932 from ff_user_entities u
4933 where u.creator_id = a.element_type_id
4934 and u.creator_type = 'E')
4935 and mod(element_type_id, p_maxworkers) = p_worker_id
4936 and (a.legislation_code = p_leg_code
4937 or exists (select null
4938 from per_business_groups_perf b
4939 where a.business_group_id = b.business_group_id
4940 and nvl(b.legislation_code, p_leg_code) = p_leg_code))
4941 group by element_type_id
4942 order by element_type_id;
4943 --
4944 cursor c2 is select input_value_id,
4945 max(effective_end_date)
4946 from pay_input_values_f a
4947 where generate_db_items_flag = 'Y'
4948 and not exists (
4949 select null
4950 from ff_user_entities u
4951 where u.creator_id = a.input_value_id
4952 and u.creator_type = 'I')
4953 and mod(input_value_id, p_maxworkers) = p_worker_id
4954 and (a.legislation_code = p_leg_code
4955 or exists (select null
4956 from per_business_groups_perf b
4957 where a.business_group_id = b.business_group_id
4958 and nvl(b.legislation_code, p_leg_code) = p_leg_code))
4959 group by input_value_id
4960 order by input_value_id;
4961
4962 l_input_value_id number;
4963 l_element_type_id number;
4964 l_date date;
4965 l_loop_cnt number;
4966
4967 begin
4968 --
4969 -- create element types
4970 --
4971 hrrbdeib_trace_on;
4972 hr_utility.trace('entering refresh_el types elements ' || p_leg_code ||
4973 ' worker: ' || to_char(p_worker_id + 1) || '/' ||
4974 to_char(p_maxworkers));
4975 hrrbdeib_trace_off;
4976
4977 l_loop_cnt := 0;
4978
4979 open c1;
4980 loop
4981 fetch c1 into l_element_type_id,
4982 l_date;
4983 EXIT when c1%notfound;
4984 hrrbdeib_trace_on;
4985 hr_utility.trace('RELE:'|| to_char(p_worker_id + 1) || ':' ||
4986 to_char(l_element_type_id) || '.' ||
4987 to_char(l_date,'DD-MM-YYYY'));
4988 hrrbdeib_trace_off;
4989 create_element_type_dict (l_element_type_id, l_date);
4990
4991 l_loop_cnt := l_loop_cnt + 1;
4992 if l_loop_cnt > 100 then
4993 l_loop_cnt := 0;
4994 commit;
4995 end if;
4996
4997 end loop;
4998 close c1;
4999 --
5000 hrrbdeib_trace_on;
5001 hr_utility.trace('leaving refresh_el types elements ' || p_leg_code ||
5002 ' worker: ' || to_char(p_worker_id + 1) || '/' ||
5003 to_char(p_maxworkers));
5004
5005 -- create input values
5006 --
5007 hr_utility.trace('entering refresh_el types ivs ' || p_leg_code ||
5008 ' worker: ' || to_char(p_worker_id + 1) || '/' ||
5009 to_char(p_maxworkers));
5010 hrrbdeib_trace_off;
5011
5012 l_loop_cnt := 0;
5013
5014 open c2;
5015 loop
5016 fetch c2 into l_input_value_id,
5017 l_date;
5018 EXIT when c2%notfound;
5019 hrrbdeib_trace_on;
5020 hr_utility.trace('RELI:'|| to_char(p_worker_id + 1) || ':' ||
5021 to_char(l_input_value_id) || '.' ||
5022 to_char(l_date,'DD-MM-YYYY'));
5023 hrrbdeib_trace_off;
5024 create_input_value_dict (l_input_value_id, l_date);
5025
5026 l_loop_cnt := l_loop_cnt + 1;
5027 if l_loop_cnt > 100 then
5028 l_loop_cnt := 0;
5029 commit;
5030 end if;
5031
5032 end loop;
5033 close c2;
5034
5035 hrrbdeib_trace_on;
5036 hr_utility.trace('leaving refresh_el types ivs ' || p_leg_code ||
5037 ' worker: ' || to_char(p_worker_id + 1) || '/' ||
5038 to_char(p_maxworkers));
5039 hrrbdeib_trace_off;
5040
5041 end refresh_element_types;
5042 --
5043 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5044 -- +
5045 -- delete_element_types +
5046 -- +
5047 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5048 /*
5049 NAME
5050 delete_element_types - delete all DB itms for element type and input
5051 values
5052 --
5053 DESCRIPTION
5054 This routine deletes all database items based on element types
5055 in the system. The routine assumes that no such database items currently
5056 exist.
5057 */
5058 procedure delete_element_types(p_worker_id in number default 0,
5059 p_maxworkers in number default 1) is
5060 begin
5061 --
5062 delete ff_user_entities u
5063 where u.creator_type = 'I'
5064 and exists (
5065 select null
5066 from pay_input_values_f a
5067 where u.creator_id = a.input_value_id);
5068
5069 delete ff_user_entities u
5070 where u.creator_type = 'E'
5071 and exists (
5072 select null
5073 from pay_element_types_f x
5074 where u.creator_id = x.element_type_id);
5075 end;
5076 --
5077 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5078 -- +
5079 -- delete_element_types +
5080 -- +
5081 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5082 /*
5083 NAME
5084 delete_element_types - delete all DB itms for element type and input
5085 values
5086 --
5087 DESCRIPTION
5088 This routine deletes all database items based on element types
5089 in the system. The routine assumes that no such database items currently
5090 exist.
5091 */
5092 procedure delete_element_types(p_leg_code in varchar2,
5093 p_worker_id in number default 0,
5094 p_maxworkers in number default 1) is
5095 begin
5096 --
5097 -- delete the input values
5098 --
5099 delete ff_user_entities u
5100 where u.creator_type = 'I'
5101 and exists (
5102 select null
5103 from pay_input_values_f a
5104 where u.creator_id = a.input_value_id
5105 and (a.legislation_code = p_leg_code
5106 or exists
5107 (select null
5108 from per_business_groups_perf b
5109 where a.business_group_id = b.business_group_id
5110 and nvl(b.legislation_code, p_leg_code) = p_leg_code)));
5111
5112 delete ff_user_entities u
5113 where u.creator_type = 'E'
5114 and exists (
5115 select null
5116 from pay_element_types_f x
5117 where u.creator_id = x.element_type_id
5118 and (x.legislation_code = p_leg_code
5119 or exists
5120 (select null
5121 from per_business_groups_perf y
5122 where x.business_group_id = y.business_group_id
5123 and nvl(y.legislation_code, p_leg_code) = p_leg_code)));
5124
5125 end delete_element_types;
5126 --
5127 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5128 -- +
5129 -- rebuild_ele_input_bal +
5130 -- +
5131 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5132 --
5133 /*
5134 NAME
5135 rebuild_ele_input_bal - Delete and then re-create Db items for elements,
5136 input values and balances.
5137 --
5138 DESCRIPTION
5139 This routine deletes all database items for element, input values and
5140 balances in the database. It then re-creates them.
5141 This routine would typically be called after a startup delivery.
5142 If the parameter 'p_commit' is set to 'Y' then the routine will commit
5143 after the procedure calls to delete/re-create the DB items. This helps
5144 the installation process when there is many DB items, or if the rollback
5145 segment space is limited.
5146 */
5147 procedure rebuild_ele_input_bal
5148 (
5149 p_commit in varchar2 default 'N',
5150 p_worker_id in number default 0,
5151 p_maxworkers in number default 1
5152 )
5153 is
5154
5155 workers_complete number;
5156 worker_err number;
5157
5158 begin
5159 --
5160 g_debug_cnt := 0;
5161
5162 select count(*)
5163 into g_debug_cnt
5164 from pay_patch_status
5165 where patch_name = 'HRGLOBAL_DEBUG2';
5166
5167 hrrbdeib_trace_on;
5168 hr_utility.trace('entering rebuild_ele_input_bal all' ||
5169 ' worker: ' || to_char(p_worker_id + 1) || '/' ||
5170 to_char(p_maxworkers));
5171 hrrbdeib_trace_off;
5172
5173 -- First set global to say we are disabling triggers.
5174 -- Loop thru each worker
5175 if p_worker_id = 0 then
5176 enable_ffue_cascade_trig;
5177 enable_refbal_trig;
5178
5179 -- Running Core so delete all compiled info and usages
5180 hrrbdeib_trace_on;
5181 hr_utility.trace('entering truncate_fcomp_info');
5182 hrrbdeib_trace_off;
5183
5184 -- truncate_fcomp_info;
5185
5186 hrrbdeib_trace_on;
5187 hr_utility.trace('leaving truncate_fcomp_info');
5188 hrrbdeib_trace_off;
5189
5190 else
5191 dbms_lock.sleep(5);
5192 end if;
5193
5194 g_triggers_altered := TRUE;
5195 --
5196 if (p_commit = 'Y') then
5197 commit;
5198 end if;
5199 --
5200 -- Delete ALL balance DB items:
5201 --
5202 -- disable delete triggers for these entities for performance.
5203 if p_worker_id = 0 then
5204 disable_ffue_cascade_trig;
5205 else
5206 dbms_lock.sleep(5);
5207 end if;
5208
5209 --
5210 if (p_commit = 'Y') then
5211 commit;
5212 end if;
5213 --
5214 -- INSERT A COMPLETION STEP AND
5215 -- LOOP HERE UNTIL ALL WORKERS HAVE COMPLETED INITIAL SET UP
5216 -- SO THAT WORKER 2 WONT BE DELETING WHILST WORKER 1 IS CREATING
5217 -- FOR EXAMPLE
5218 insert_mthread_pps(1, p_worker_id, 'ZZ');
5219 --
5220 if (p_commit = 'Y') then
5221 commit;
5222 end if;
5223 --
5224 loop
5225
5226 select count(*)
5227 into worker_err
5228 from pay_patch_status
5229 where patch_name like 'HRRBDEIB INTERNAL PROC ERR%';
5230
5231 if worker_err > 0 then
5232 raise_application_error(-20106, 'A hrrbdeib worker has failed, terminating all workers.');
5233 end if;
5234
5235 select count(*)
5236 into workers_complete
5237 from pay_patch_status
5238 where patch_name = 'HRRBDEIB INTERNAL PROC S1'
5239 and process_type = 'ZZ';
5240
5241 exit when workers_complete = p_maxworkers;
5242
5243 dbms_lock.sleep(5);
5244
5245 end loop;
5246
5247 if (p_commit = 'Y') then
5248 commit;
5249 end if;
5250
5251 -- re-enable delete triggers
5252 if p_worker_id = 0 then
5253 enable_ffue_cascade_trig;
5254 disable_refbal_trig;
5255 else
5256 dbms_lock.sleep(5);
5257 end if;
5258
5259 --
5260 hrdyndbi.refresh_defined_balances(p_worker_id,
5261 p_maxworkers);
5262
5263 --
5264 -- INSERT A COMPLETION STEP AND
5265 -- LOOP HERE UNTIL ALL WORKERS HAVE COMPLETED INITIAL SET UP
5266 -- SO THAT WORKER 2 WONT BE DELETING WHILST WORKER 1 IS CREATING
5267 -- FOR EXAMPLE
5268 insert_mthread_pps(2, p_worker_id, 'ZZ');
5269
5270 if (p_commit = 'Y') then
5271 commit;
5272 end if;
5273
5274
5275 loop
5276
5277 select count(*)
5278 into worker_err
5279 from pay_patch_status
5280 where patch_name like 'HRRBDEIB INTERNAL PROC ERR%';
5281
5282 if worker_err > 0 then
5283 raise_application_error(-20106, 'A hrrbdeib worker has failed, terminating all workers.');
5284 end if;
5285
5286 select count(*)
5287 into workers_complete
5288 from pay_patch_status
5289 where patch_name = 'HRRBDEIB INTERNAL PROC S2'
5290 and process_type = 'ZZ';
5291
5292 exit when workers_complete = p_maxworkers;
5293
5294 dbms_lock.sleep(5);
5295
5296 end loop;
5297 --
5298 if (p_commit = 'Y') then
5299 commit;
5300 end if;
5301 --
5302 -- re-enable insert triggers
5303 if p_worker_id = 0 then
5304 enable_refbal_trig;
5305 disable_ffue_cascade_trig;
5306 else
5307 dbms_lock.sleep(5);
5308 end if;
5309
5310 --
5311 --
5312 -- INSERT A COMPLETION STEP AND
5313 -- LOOP HERE UNTIL ALL WORKERS HAVE COMPLETED INITIAL SET UP
5314 -- SO THAT WORKER 2 WONT BE DELETING WHILST WORKER 1 IS CREATING
5315 -- FOR EXAMPLE
5316 insert_mthread_pps(3, p_worker_id, 'ZZ');
5317
5318 if (p_commit = 'Y') then
5319 commit;
5320 end if;
5321
5322
5323 loop
5324
5325 select count(*)
5326 into worker_err
5327 from pay_patch_status
5328 where patch_name like 'HRRBDEIB INTERNAL PROC ERR%';
5329
5330 if worker_err > 0 then
5331 raise_application_error(-20106, 'A hrrbdeib worker has failed, terminating all workers.');
5332 end if;
5333
5334 select count(*)
5335 into workers_complete
5336 from pay_patch_status
5337 where patch_name = 'HRRBDEIB INTERNAL PROC S3'
5338 and process_type = 'ZZ';
5339
5340 exit when workers_complete = p_maxworkers;
5341
5342 dbms_lock.sleep(5);
5343
5344 end loop;
5345
5346 if (p_commit = 'Y') then
5347 commit;
5348 end if;
5349 --
5350 -- re-enable delete triggers
5351 if p_worker_id = 0 then
5352 enable_ffue_cascade_trig;
5353 else
5354 dbms_lock.sleep(5);
5355 end if;
5356
5357 --
5358 -- Create all input and element DB items:
5359 --
5360 -- Get the security ID for the codename cursor
5361 g_security_group_id := fnd_global.lookup_security_group('NAME_TRANSLATIONS', 3);
5362 --
5363 --
5364 -- disable insert triggers for these entities for performance.
5365 if p_worker_id = 0 then
5366 disable_refbal_trig;
5367 else
5368 dbms_lock.sleep(5);
5369 end if;
5370
5371 --
5372 hrdyndbi.refresh_element_types(p_worker_id,
5373 p_maxworkers);
5374 -- INSERT A COMPLETION STEP AND
5375 -- LOOP HERE UNTIL ALL WORKERS HAVE COMPLETED INITIAL SET UP
5376 -- SO THAT WORKER 2 WONT BE DELETING WHILST WORKER 1 IS CREATING
5377 -- FOR EXAMPLE
5378 insert_mthread_pps(4, p_worker_id, 'ZZ');
5379
5380 if (p_commit = 'Y') then
5381 commit;
5382 end if;
5383
5384
5385 loop
5386
5387 select count(*)
5388 into worker_err
5389 from pay_patch_status
5390 where patch_name like 'HRRBDEIB INTERNAL PROC ERR%';
5391
5392 if worker_err > 0 then
5393 raise_application_error(-20106, 'A hrrbdeib worker has failed, terminating all workers.');
5394 end if;
5395
5396 select count(*)
5397 into workers_complete
5398 from pay_patch_status
5399 where patch_name = 'HRRBDEIB INTERNAL PROC S4'
5400 and process_type = 'ZZ';
5401
5402 exit when workers_complete = p_maxworkers;
5403
5404 dbms_lock.sleep(5);
5405
5406 end loop;
5407 --
5408 -- Important. In order not to hang when we have selected more than
5409 -- 1 non Core legislation for install, we must of course delete the
5410 -- tracking pay_patch_status rows so that the next leg loop of hrrbdeib
5411 -- starts afresh. We take care of this now by not trashing history and
5412 -- tag a legislation code to the pps rows
5413 --
5414 if (p_commit = 'Y') then
5415 commit;
5416 end if;
5417 --
5418 -- re-enable insert triggers
5419 if p_worker_id = 0 then
5420 enable_refbal_trig;
5421 else
5422 dbms_lock.sleep(5);
5423 end if;
5424
5425 --
5426 -- reset global
5427 g_triggers_altered := FALSE;
5428 --
5429 hrrbdeib_trace_on;
5430 hr_utility.trace('leaving rebuild_ele_input_bal all' ||
5431 ' worker: ' || to_char(p_worker_id + 1) || '/' ||
5432 to_char(p_maxworkers));
5433 hrrbdeib_trace_off;
5434 --
5435 exception
5436 when others then
5437 -- re-enable any disabled triggers
5438 hrrbdeib_trace_on;
5439 hr_utility.trace('exception raised in rebuild_ele_input_bal all' ||
5440 ' worker: ' || to_char(p_worker_id + 1) || '/' ||
5441 to_char(p_maxworkers));
5442 hrrbdeib_trace_off;
5443 insert_mthread_pps_err(p_worker_id, 'ZZ');
5444 enable_ffue_cascade_trig;
5445 enable_refbal_trig;
5446 raise; -- reraise the exception
5447 --
5448 end rebuild_ele_input_bal;
5449 --
5450 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5451 -- +
5452 -- rebuild_ele_input_bal +
5453 -- +
5454 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5455 --
5456 /*
5457 NAME
5458 rebuild_ele_input_bal - Delete and then re-create Db items for elements,
5459 input values and balances.
5460 --
5461 DESCRIPTION
5462 This routine deletes all database items for element, input values and
5463 balances in the database. It then re-creates them.
5464 This routine would typically be called after a startup delivery.
5465 If the parameter 'p_commit' is set to 'Y' then the routine will commit
5466 after the procedure calls to delete/re-create the DB items. This helps
5467 the installation process when there is many DB items, or if the rollback
5468 segment space is limited.
5469 */
5470 procedure rebuild_ele_input_bal
5471 (
5472 p_commit in varchar2 default 'N',
5473 p_leg_code in varchar2,
5474 p_worker_id in number default 0,
5475 p_maxworkers in number default 1
5476 )
5477 is
5478
5479 workers_complete number;
5480 worker_err number;
5481 l_formula_ids dbms_sql.number_table;
5482 l_start_dates dbms_sql.date_table;
5483 l_rowids dbms_sql.varchar2s;
5484 form_name varchar2(80);
5485
5486 --
5487 -- Cursor to fetch FDIU row information for rows affected by the EIB
5488 -- database item recreation.
5489 --
5490 cursor csr_affected_fdiu_rows
5491 (p_leg_code in varchar2
5492 ) is
5493 select fdi.rowid
5494 , fdi.formula_id
5495 , fdi.effective_start_date
5496 from ff_fdi_usages_f fdi
5497 where exists
5498 (select null
5499 from ff_database_items dbi
5500 where fdi.item_name = dbi.user_name
5501 and exists
5502 (select null
5503 from ff_user_entities ent
5504 where ent.user_entity_id = dbi.user_entity_id
5505 and ent.creator_type in ('B','RB','E','I')
5506 -- MERGE B RB E I main cursors
5507 --
5508 -- B
5509 and (
5510 not exists (
5511 select null
5512 from pay_defined_balances b
5513 where b.defined_balance_id = ent.creator_id
5514 and ent.creator_type = 'B'
5515 )
5516 OR
5517 -- RB
5518 (not exists (
5519 select null
5520 from pay_defined_balances b
5521 where b.defined_balance_id = ent.creator_id
5522 and ent.creator_type = 'RB'
5523 and exists
5524 (select null
5525 from pay_dimension_routes pdr
5526 where pdr.balance_dimension_id = b.balance_dimension_id)
5527 )
5528 OR
5529 (exists (
5530 select pdr.balance_dimension_id
5531 from pay_dimension_routes pdr,
5532 pay_defined_balances b
5533 where pdr.balance_dimension_id = b.balance_dimension_id
5534 and not exists (select null
5535 from ff_user_entities ue
5536 where ue.creator_id = b.defined_balance_id
5537 and ue.route_id = pdr.route_id
5538 and ue.creator_type = 'RB'))
5539 )
5540 ) -- end RB
5541 OR
5542 -- E
5543 (not exists (
5544 select null
5545 from pay_element_types_f et
5546 where ent.creator_id = et.element_type_id
5547 and ent.creator_type = 'E'))
5548 OR
5549 -- I
5550 (not exists (
5551 select null
5552 from pay_input_values_f i
5553 where ent.creator_id = i.input_value_id
5554 and i.generate_db_items_flag = 'Y'
5555 and ent.creator_type = 'I'))
5556 ) -- end B RB E I
5557 and
5558 (nvl (ent.legislation_code, ' ') = nvl (p_leg_code, ' ')
5559 or exists
5560 (select null
5561 from per_business_groups_perf b
5562 where ent.business_group_id = b.business_group_id
5563 and nvl(b.legislation_code, p_leg_code) = p_leg_code
5564 )
5565 )
5566 )
5567 )
5568 ;
5569 begin
5570 --
5571 g_debug_cnt := 0;
5572
5573 select count(*)
5574 into g_debug_cnt
5575 from pay_patch_status
5576 where patch_name = 'HRGLOBAL_DEBUG2';
5577
5578 hrrbdeib_trace_on;
5579 hr_utility.trace('entering rebuild_ele_input_bal ' || p_leg_code ||
5580 ' worker: ' || to_char(p_worker_id + 1) || '/' ||
5581 to_char(p_maxworkers));
5582 hrrbdeib_trace_off;
5583 --
5584 -- First set global to say we are disabling triggers.
5585 if p_worker_id = 0 then
5586 enable_ffue_cascade_trig;
5587 enable_refbal_trig;
5588
5589 g_triggers_altered := TRUE;
5590 --
5591 -- delete legislative formulae usages and compiled info
5592 --
5593 hrrbdeib_trace_on;
5594 hr_utility.trace('entering delete fcomp info: LC: ' || p_leg_code);
5595 hrrbdeib_trace_off;
5596
5597 /*
5598 open csr_affected_fdiu_rows(p_leg_code => p_leg_code);
5599
5600 loop
5601 --
5602 -- Delete in chunks to avoid potential memory issues with bulk
5603 -- collecting many thousands of rows.
5604 --
5605 fetch csr_affected_fdiu_rows bulk collect
5606 into l_rowids
5607 , l_formula_ids
5608 , l_start_dates
5609 limit 500;
5610
5611 exit when csr_affected_fdiu_rows%notfound;
5612
5613 forall i in 1 .. l_rowids.count
5614 delete
5615 from ff_fdi_usages_f fdi
5616 where fdi.rowid = l_rowids(i)
5617 ;
5618
5619 forall i in 1 .. l_rowids.count
5620 delete
5621 from ff_compiled_info_f fci
5622 where fci.formula_id = l_formula_ids(i)
5623 and fci.effective_start_date = l_start_dates(i)
5624 ;
5625
5626 end loop;
5627
5628 close csr_affected_fdiu_rows;
5629 */
5630
5631 hrrbdeib_trace_on;
5632 hr_utility.trace('leaving delete fcomp info: LC: ' || p_leg_code);
5633 hrrbdeib_trace_off;
5634
5635 end if;
5636 --
5637 if (p_commit = 'Y') then
5638 commit;
5639 end if;
5640 --
5641 -- INSERT A COMPLETION STEP AND
5642 -- LOOP HERE UNTIL ALL WORKERS HAVE COMPLETED INITIAL SET UP
5643 -- SO THAT WORKER 2 WONT BE DELETING WHILST WORKER 1 IS CREATING
5644 -- FOR EXAMPLE
5645 insert_mthread_pps(1, p_worker_id, p_leg_code);
5646
5647 if (p_commit = 'Y') then
5648 commit;
5649 end if;
5650
5651
5652 loop
5653
5654 select count(*)
5655 into worker_err
5656 from pay_patch_status
5657 where patch_name like 'HRRBDEIB INTERNAL PROC ERR%';
5658
5659 if worker_err > 0 then
5660 raise_application_error(-20106, 'A hrrbdeib worker has failed, terminating all workers.');
5661 end if;
5662
5663 select count(*)
5664 into workers_complete
5665 from pay_patch_status
5666 where patch_name = 'HRRBDEIB INTERNAL PROC S1'
5667 and process_type = p_leg_code;
5668
5669 exit when workers_complete = p_maxworkers;
5670
5671 dbms_lock.sleep(5);
5672
5673 end loop;
5674 --
5675 -- Create ALL DB items for defined balances in the account:
5676 --
5677 -- disable insert triggers for these entities for performance.
5678 if p_worker_id = 0 then
5679 disable_refbal_trig;
5680 else
5681 dbms_lock.sleep(5);
5682 end if;
5683
5684 --
5685 hrdyndbi.refresh_defined_balances(p_leg_code,
5686 p_worker_id,
5687 p_maxworkers);
5688 --
5689 -- INSERT A COMPLETION STEP AND
5690 -- LOOP HERE UNTIL ALL WORKERS HAVE COMPLETED INITIAL SET UP
5691 -- SO THAT WORKER 2 WONT BE DELETING WHILST WORKER 1 IS CREATING
5692 -- FOR EXAMPLE
5693 insert_mthread_pps(2, p_worker_id, p_leg_code);
5694 --
5695 if (p_commit = 'Y') then
5696 commit;
5697 end if;
5698
5699
5700 loop
5701
5702 select count(*)
5703 into worker_err
5704 from pay_patch_status
5705 where patch_name like 'HRRBDEIB INTERNAL PROC ERR%';
5706
5707 if worker_err > 0 then
5708 raise_application_error(-20106, 'A hrrbdeib worker has failed, terminating all workers.');
5709 end if;
5710
5711 select count(*)
5712 into workers_complete
5713 from pay_patch_status
5714 where patch_name = 'HRRBDEIB INTERNAL PROC S2'
5715 and process_type = p_leg_code;
5716
5717 exit when workers_complete = p_maxworkers;
5718
5719 dbms_lock.sleep(5);
5720
5721 end loop;
5722
5723 if (p_commit = 'Y') then
5724 commit;
5725 end if;
5726 --
5727 -- re-enable insert triggers
5728 if p_worker_id = 0 then
5729 enable_refbal_trig;
5730 disable_ffue_cascade_trig;
5731 else
5732 dbms_lock.sleep(5);
5733 end if;
5734
5735 --
5736 --
5737 -- INSERT A COMPLETION STEP AND
5738 -- LOOP HERE UNTIL ALL WORKERS HAVE COMPLETED INITIAL SET UP
5739 -- SO THAT WORKER 2 WONT BE DELETING WHILST WORKER 1 IS CREATING
5740 -- FOR EXAMPLE
5741 insert_mthread_pps(3, p_worker_id, p_leg_code);
5742
5743 if (p_commit = 'Y') then
5744 commit;
5745 end if;
5746
5747
5748 loop
5749
5750 select count(*)
5751 into worker_err
5752 from pay_patch_status
5753 where patch_name like 'HRRBDEIB INTERNAL PROC ERR%';
5754
5755 if worker_err > 0 then
5756 raise_application_error(-20106, 'A hrrbdeib worker has failed, terminating all workers.');
5757 end if;
5758
5759 select count(*)
5760 into workers_complete
5761 from pay_patch_status
5762 where patch_name = 'HRRBDEIB INTERNAL PROC S3'
5763 and process_type = p_leg_code;
5764
5765 exit when workers_complete = p_maxworkers;
5766
5767 dbms_lock.sleep(5);
5768
5769 end loop;
5770
5771 if (p_commit = 'Y') then
5772 commit;
5773 end if;
5774 --
5775 -- re-enable delete triggers
5776 if p_worker_id = 0 then
5777 enable_ffue_cascade_trig;
5778 else
5779 dbms_lock.sleep(5);
5780 end if;
5781
5782 --
5783 -- Create all input and element DB items:
5784 --
5785 -- Get the security ID for the codename cursor
5786 g_security_group_id := fnd_global.lookup_security_group('NAME_TRANSLATIONS',
5787 3);
5788 --
5789 --
5790 -- disable insert triggers for these entities for performance.
5791 if p_worker_id = 0 then
5792 disable_refbal_trig;
5793 else
5794 dbms_lock.sleep(5);
5795 end if;
5796
5797 --
5798 hrdyndbi.refresh_element_types(p_leg_code,
5799 p_worker_id,
5800 p_maxworkers);
5801 --
5802 --
5803 -- INSERT A COMPLETION STEP AND
5804 -- LOOP HERE UNTIL ALL WORKERS HAVE COMPLETED INITIAL SET UP
5805 -- SO THAT WORKER 2 WONT BE DELETING WHILST WORKER 1 IS CREATING
5806 -- FOR EXAMPLE
5807 insert_mthread_pps(4, p_worker_id, p_leg_code);
5808
5809 if (p_commit = 'Y') then
5810 commit;
5811 end if;
5812
5813
5814 loop
5815
5816 select count(*)
5817 into worker_err
5818 from pay_patch_status
5819 where patch_name like 'HRRBDEIB INTERNAL PROC ERR%';
5820
5821 if worker_err > 0 then
5822 raise_application_error(-20106, 'A hrrbdeib worker has failed, terminating all workers.');
5823 end if;
5824
5825 select count(*)
5826 into workers_complete
5827 from pay_patch_status
5828 where patch_name = 'HRRBDEIB INTERNAL PROC S4'
5829 and process_type = p_leg_code;
5830
5831 exit when workers_complete = p_maxworkers;
5832
5833 dbms_lock.sleep(5);
5834
5835 end loop;
5836 --
5837 -- Important. In order not to hang when we have selected more than
5838 -- 1 non Core legislation for install, we must of course delete the
5839 -- tracking pay_patch_status rows so that the next leg loop of hrrbdeib
5840 -- starts afresh. We take care of this now by not trashing history and
5841 -- tag a legislation code to the pps rows
5842 --
5843 if (p_commit = 'Y') then
5844 commit;
5845 end if;
5846 --
5847 -- re-enable insert triggers
5848 if p_worker_id = 0 then
5849 enable_refbal_trig;
5850 else
5851 dbms_lock.sleep(5);
5852 end if;
5853
5854 --
5855 -- reset global
5856 g_triggers_altered := FALSE;
5857 --
5858 hrrbdeib_trace_on;
5859 hr_utility.trace('leaving rebuild_ele_input_bal ' || p_leg_code ||
5860 ' worker: ' || to_char(p_worker_id + 1) || '/' ||
5861 to_char(p_maxworkers));
5862 hrrbdeib_trace_off;
5863 --
5864 exception
5865 when others then
5866 hrrbdeib_trace_on;
5867 hr_utility.trace('exception in rebuild_ele_input_bal ' || p_leg_code ||
5868 ' worker: ' || to_char(p_worker_id + 1) || '/' ||
5869 to_char(p_maxworkers));
5870 hrrbdeib_trace_off;
5871 --
5872 if csr_affected_fdiu_rows%isopen then
5873 close csr_affected_fdiu_rows;
5874 end if;
5875 --
5876 insert_mthread_pps_err(p_worker_id, p_leg_code);
5877 -- re-enable any disabled triggers
5878 enable_ffue_cascade_trig;
5879 enable_refbal_trig;
5880 raise; -- reraise the exception
5881 --
5882 end rebuild_ele_input_bal;
5883 --
5884 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5885 -- +
5886 -- delete_grade_spine_dict +
5887 -- +
5888 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5889 /*
5890 NAME
5891 delete_grade_spine_dict - delete the grade rate items from the data
5892 dictionary
5893 --
5894 DESCRIPTION
5895 */
5896 procedure delete_grade_spine_dict
5897 (
5898 p_rate_id in number
5899 ) is
5900 --
5901 BEGIN
5902 DELETE FROM ff_user_entities
5903 WHERE creator_id = p_rate_id
5904 AND creator_type = 'G';
5905 end delete_grade_spine_dict;
5906 --
5907 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5908 -- +
5909 -- create_grade_spine_dict +
5910 -- +
5911 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5912 --
5913 /*
5914 NAME
5915 create_grade_spine_dict - create grade/ spine rate database items
5916 --
5917 DESCRIPTION
5918 This procedure is the main entry point for creating database items for
5919 either grades or spines. The routes must have already been defined in the
5920 database (in table ff_routes). The procedure will search for the
5921 routes in this table by using the route name, which is hard coded below.
5922 The procedure processes each route in turn, creating a user entity and
5923 route parameter values, and then inserting each database items for that
5924 particular route.
5925 The database items created use the rate name. This routine
5926 generates the following database items for grades:
5927 --
5928 GRADE_<NAME>_VALUE
5929 GRADE_<NAME>_MINIMUM
5930 GRADE_<NAME>_MAXIMUM
5931 --
5932 For spines the following database item is generated:
5933 --
5934 SPINE_<NAME>_VALUE
5935 */
5936 procedure create_grade_spine_dict
5937 (
5938 p_rate_id in number
5939 ) is
5940 l_grade_route_name varchar2(50) := 'GRADE_RATE_ROUTE';
5941 l_spine_route_name varchar2(50) := 'SPINE_RATE_ROUTE';
5942 l_rate_type pay_rates.rate_type%type;
5943 l_name pay_rates.name%type;
5944 l_business_group_id number;
5945 l_created_by number;
5946 l_last_login number;
5947 l_record_inserted boolean;
5948 --
5949 ------------------------- create_grade_spine_dict -------------------------
5950 --
5951 BEGIN
5952 --
5953 -- find out if its a grade or spine that needs to be created:
5954 --
5955 select rate_type,
5956 replace (ltrim (rtrim (upper (name))), ' ', '_'),
5957 business_group_id,
5958 created_by,
5959 last_update_login
5960 into l_rate_type,
5961 l_name,
5962 l_business_group_id,
5963 l_created_by,
5964 l_last_login
5965 from pay_rates
5966 where rate_id = p_rate_id;
5967 --
5968 if (l_rate_type = 'G') then -- grade
5969 --
5970 -- create the user entity for the grade rate route
5971 --
5972 insert_user_entity (l_grade_route_name,
5973 'GRADE_' || l_name,
5974 'entity for '|| l_grade_route_name,
5975 'Y', -- not found allowed flag
5976 'G',
5977 p_rate_id,
5978 l_business_group_id,
5979 null, -- null legislation code
5980 l_created_by,
5981 l_last_login,
5982 l_record_inserted);
5983 --
5984 -- only insert parameter values/database items if entity was inserted
5985 --
5986 IF l_record_inserted THEN
5987 --
5988 -- insert the rate id for the where clause filler
5989 --
5990 insert_parameter_value (p_rate_id, 1);
5991 --
5992 l_name := 'GRADE_' || l_name;
5993 --
5994 -- load up the database items for the grade rate route:
5995 --
5996 insert_database_item (l_name,
5997 'VALUE',
5998 'T', -- data type
5999 'GRULE.value',
6000 'Y', -- null allowed
6001 'value for grade rates');
6002 --
6003 insert_database_item (l_name,
6004 'MINIMUM',
6005 'T', -- data type
6006 'GRULE.minimum',
6007 'Y', -- null allowed
6008 'minimum value for grade rates');
6009 --
6010 insert_database_item (l_name,
6011 'MAXIMUM',
6012 'T', -- data type
6013 'GRULE.maximum',
6014 'Y', -- null allowed
6015 'maximum value for grade rates');
6016 END IF;
6017 else -- a spine rate
6018 --
6019 -- create the user entity for the spine rate route
6020 --
6021 insert_user_entity (l_spine_route_name,
6022 'SPINE_' || l_name,
6023 'entity for '|| l_spine_route_name,
6024 'Y', -- not found allowed flag
6025 'G',
6026 p_rate_id,
6027 l_business_group_id,
6028 null, -- null legislation code
6029 l_created_by,
6030 l_last_login,
6031 l_record_inserted);
6032 --
6033 -- only insert parameter values/database items if entity was inserted
6034 --
6035 IF l_record_inserted THEN
6036 --
6037 -- insert the rate id for the where clause filler
6038 --
6039 insert_parameter_value (p_rate_id, 1);
6040 --
6041 l_name := 'SPINE_' || l_name;
6042 --
6043 -- load up the database items for the grade rate route:
6044 --
6045 insert_database_item (l_name,
6046 'VALUE',
6047 'T', -- data type
6048 'target.value',
6049 'Y', -- null allowed
6050 'value for spine rates');
6051 END IF;
6052 end if;
6053 end create_grade_spine_dict;
6054 --
6055 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6056 -- +
6057 -- refresh_grade_spine_rates +
6058 -- +
6059 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6060 /*
6061 NAME
6062 refresh_grade_spine_rates - create DB items for grade and spine rates
6063 --
6064 DESCRIPTION
6065 This routine creates all database items based on grade and spine rates
6066 in the system. The routine assumes that no such database items currently
6067 exist.
6068 */
6069 procedure refresh_grade_spine_rates is
6070 cursor c1 is select rate_id
6071 from pay_rates r
6072 where not exists (select null from ff_user_entities u
6073 where u.creator_id = r.rate_id
6074 and u.creator_type = 'G');
6075 begin
6076 for c1rec in c1 loop
6077 hrrbdeib_trace_on;
6078 hr_utility.trace ('creating database item grade/ spine rate id: '||
6079 to_char (c1rec.rate_id));
6080 hrrbdeib_trace_off;
6081 create_grade_spine_dict (c1rec.rate_id);
6082 end loop;
6083 end refresh_grade_spine_rates;
6084 --
6085 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6086 -- +
6087 -- delete_grade_spine_rates +
6088 -- +
6089 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6090 /*
6091 NAME
6092 delete_grade_spine_rates - delete DB items for grade and spine rates
6093 --
6094 DESCRIPTION
6095 This routine deletes all database items based on grade or spine rates
6096 in the system. The routine assumes that no such database items currently
6097 exist.
6098 */
6099 procedure delete_grade_spine_rates is
6100 cursor c1 is select rate_id
6101 from pay_rates;
6102 begin
6103 --
6104 -- delete the grade/ spine rates
6105 --
6106 for c1rec in c1 loop
6107 hrrbdeib_trace_on;
6108 hr_utility.trace ('deleting database item grade/ spine rate id: '||
6109 to_char (c1rec.rate_id));
6110 hrrbdeib_trace_off;
6111 delete_grade_spine_dict (c1rec.rate_id);
6112 end loop;
6113 end delete_grade_spine_rates;
6114 --
6115 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6116 -- +
6117 -- delete_flexfield_dict +
6118 -- +
6119 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6120 /*
6121 NAME
6122 delete_flexfield_dict - delete a descriptive flexfield in the
6123 data dictionary
6124 --
6125 DESCRIPTION
6126 This procedure is the main entry point for deleting descriptive
6127 flexfield database items. To delete all the descriptive flexfield
6128 database items for a given legislation code, pass the title parameter
6129 as '%'. To delete an individual descriptive flexfield pass the title
6130 of the flexfield.
6131 NOTES
6132 Since the legislation code for a descriptive flexfield could be null
6133 a nvl function is required as part of the SQL statement.
6134 */
6135 procedure delete_flexfield_dict
6136 (
6137 p_title in varchar2,
6138 p_context in varchar2,
6139 p_leg_code in varchar2
6140 ) is
6141 l_entity_name ff_user_entities.user_entity_name%type;
6142 BEGIN
6143 if (p_title = '%') and
6144 (p_context = '%') then -- delete all descriptive flexfield DB items
6145 --
6146 -- first delete any complied formula references
6147 --
6148 delete_compiled_formula (null,
6149 'DF',
6150 '%',
6151 p_leg_code);
6152 --
6153 -- now delete the actual database items
6154 --
6155 delete from ff_user_entities
6156 where creator_type = 'DF'
6157 and nvl (legislation_code, ' ') = nvl (p_leg_code, ' ');
6158 --
6159 else -- delete selected DB items
6160 --
6161 -- assemble the entity name:
6162 --
6163 l_entity_name := replace (replace (ltrim(rtrim(upper(p_title))),' ','_'),'''','')
6164 ||'_'|| replace (ltrim(rtrim(upper(p_context))),' ','_');
6165 l_entity_name := l_entity_name || '_DF%';
6166 --
6167 -- first delete any complied formula references
6168 --
6169 delete_compiled_formula (null,
6170 'DF',
6171 l_entity_name,
6172 p_leg_code);
6173 --
6174 -- now delete the actual database items
6175 --
6176 delete from ff_user_entities
6177 where creator_type = 'DF'
6178 and user_entity_name like l_entity_name
6179 and nvl (legislation_code, ' ') = nvl (p_leg_code, ' ');
6180 end if;
6181 end delete_flexfield_dict;
6182 --
6183 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6184 -- +
6185 -- create_desc_flex +
6186 -- +
6187 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6188 /*
6189 NAME
6190 create_desc_flex - General routine to create Descriptive flexs. Called
6191 from the main Descriptive flexfield DB item generation
6192 procedures.
6193 --
6194 DESCRIPTION
6195 This procedure creates Descriptive flexfield DB items, and is responsible
6196 for creating the user entities for a particular flexfield. For the
6197 given flexfield there could be several contexts that apply to several
6198 flexfield segment names. Hence two cursor loops are used to generate
6199 the database items, the outer one to select the context
6200 and the inner one to select the column names.
6201 */
6202 --
6203 -- This create_desc_flex() does not accept business_group_id for context
6204 -- sensitive db_item generation.
6205 --
6206 procedure create_desc_flex
6207 (
6208 p_title in varchar2,
6209 p_table_name in varchar2,
6210 p_route_name in varchar2,
6211 p_entity_name in varchar2,
6212 p_context in varchar2,
6213 p_global_flag in varchar2,
6214 p_param_value in varchar2,
6215 p_leg_code in varchar2
6216 ) is
6217 BEGIN
6218 create_desc_flex_main( p_title,
6219 p_table_name,
6220 p_route_name,
6221 p_entity_name,
6222 p_context,
6223 p_global_flag,
6224 p_param_value,
6225 p_leg_code,
6226 p_business_group_id => NULL );
6227 END create_desc_flex;
6228 --
6229 -- This create_desc_flex() accepts business_group_id for context
6230 -- sensitive db_item generation.
6231 --
6232 procedure create_desc_flex
6233 (
6234 p_title in varchar2,
6235 p_table_name in varchar2,
6236 p_route_name in varchar2,
6237 p_entity_name in varchar2,
6238 p_context in varchar2,
6239 p_global_flag in varchar2,
6240 p_param_value in varchar2,
6241 p_leg_code in varchar2,
6242 p_business_group_id in varchar2
6243 ) is
6244 BEGIN
6245 create_desc_flex_main( p_title,
6246 p_table_name,
6247 p_route_name,
6248 p_entity_name,
6249 p_context,
6250 p_global_flag,
6251 p_param_value,
6252 p_leg_code,
6253 p_business_group_id );
6254 END create_desc_flex;
6255 --
6256 -- Main create_desc_flex() procedure
6257 --
6258 procedure create_desc_flex_main
6259 (
6260 p_title in varchar2,
6261 p_table_name in varchar2,
6262 p_route_name in varchar2,
6263 p_entity_name in varchar2,
6264 p_context in varchar2,
6265 p_global_flag in varchar2,
6266 p_param_value in varchar2,
6267 p_leg_code in varchar2,
6268 p_business_group_id in varchar2
6269 ) is
6270 l_param_value ff_route_parameter_values.value%type;
6271 l_dbitem_found boolean;
6272 l_entity_name ff_user_entities.user_entity_name%type;
6273 l_created_by number;
6274 l_last_login number;
6275 l_record_inserted boolean;
6276 l_user_entity_id number;
6277 --
6278 --
6279 begin
6280 for c1rec in dflex_c1 (p_table_name,
6281 p_title,
6282 p_global_flag,
6283 p_context) loop
6284
6285 l_dbitem_found := FALSE;
6286 --
6287 -- now create the database items
6288 --
6289 for c2rec in dflex_c2 (c1rec.c_flex_name,
6290 p_context) loop
6291 --
6292 -- only create a user entity if database items are to be created.
6293 --
6294 if (l_dbitem_found = FALSE) then
6295 l_dbitem_found := TRUE;
6296 --
6297 -- delete any old descriptive flex DB items of the same name:
6298 --
6299 delete_flexfield_dict (p_title,
6300 p_context,
6301 p_leg_code);
6302 --
6303 -- create a user entity, first construct the entity name:
6304 -- (note: the c1 cursor perform the upper functions, etc. for
6305 -- the title name).
6306 --
6307 l_entity_name := c1rec.c_title || '_' ||
6308 replace (ltrim(rtrim(upper(p_context))),' ','_');
6309 --
6310 l_created_by := c1rec.c_created_by;
6311 l_last_login := c1rec.c_last_login;
6312 --
6313 insert_user_entity (p_route_name,
6314 l_entity_name || '_DF',
6315 'entity for '|| p_route_name,
6316 'Y',
6317 'DF',
6318 null, -- null creator id
6319 p_business_group_id,
6320 p_leg_code,
6321 l_created_by,
6322 l_last_login,
6323 l_record_inserted);
6324 --
6325 -- only insert parameter values/database items if entity
6326 -- was inserted
6327 --
6328 IF l_record_inserted THEN
6329 --
6330 -- if we are creating certain Developer DF DB items then we
6331 -- need to insert the type context into the route parameter
6332 -- value table.
6333 --
6334 if (p_route_name = 'DEVELOPER_ORG_DESC_FLEX_ROUTE') OR
6335 (p_route_name = 'LEGAL_CO_DESC_FLEX_ROUTE') OR
6336 (p_route_name = 'DEVELOPER_ASS_DESC_FLEX_ROUTE') OR
6337 (p_route_name = 'DEVELOPER_LOC_DESC_FLEX_ROUTE') OR
6338 (p_route_name = 'DEVELOPER_POS_DESC_FLEX_ROUTE') OR
6339 (p_route_name = 'DEVELOPER_PER_DESC_FLEX_ROUTE') then
6340 --
6341 -- note: fast formula requires the quotes for a text
6342 -- string to be in the parameter value table, as opposed
6343 -- to in the route.
6344 --
6345 l_param_value := '''' ||
6346 replace (ltrim(rtrim(p_param_value)),' ','_') || '''';
6347 insert_parameter_value (l_param_value, 1);
6348 --
6349 elsif (p_route_name = 'ENTRY_DESC_FLEX_ROUTE') then
6350 -- Different insert for the Entry DDF as the
6351 -- space replacement is not required
6352 l_param_value := '''' ||
6353 ltrim(rtrim(p_param_value)) || '''';
6354 insert_parameter_value (l_param_value, 1);
6355
6356 elsif (p_route_name = 'ORG_PAY_METHOD_DESC_FLEX_ROUTE') then
6357 insert_parameter_value (p_param_value, 1);
6358 --
6359 -- We create the CURRENCY_CODE database item here
6360 -- as the above delete_flexfield_dict will have
6361 -- removed it if it had been delivered earlier.
6362 --
6363 insert_database_item (p_entity_name,
6364 'CURRENCY_CODE',
6365 'T', -- data type
6366 'target.currency_code',
6367 'N', -- null allowed
6368 'database item for : ' ||
6369 p_entity_name);
6370 elsif (p_route_name = 'PAY_FURTHER_PPM_DESC_FLEX_ROUTE') then
6371 insert_database_item (p_entity_name,
6372 'CURRENCY_CODE',
6373 'T', -- data type
6374 'target.currency_code',
6375 'N', -- null allowed
6376 'database item for : ' ||
6377 p_entity_name);
6378 elsif (p_route_name is not null
6379 and p_param_value is not null) then
6380 --
6381 -- create a parameter value if a route uses a parameter.
6382 --
6383 insert_parameter_value (p_param_value, 1);
6384 --
6385 end if;
6386 ELSE
6387 select user_entity_id
6388 into l_user_entity_id
6389 from ff_user_entities
6390 where user_entity_name=l_entity_name || '_DF'
6391 and nvl(legislation_code,'X')=nvl(p_leg_code,'X')
6392 and nvl(business_group_id,-1)=nvl(p_business_group_id,-1);
6393 END IF;
6394 end if;
6395 --
6396 insert_database_item (p_entity_name,
6397 c2rec.c_db_name,
6398 'T', -- data type
6399 'target.' || c2rec.c_def_text,
6400 'Y', -- null allowed
6401 'database item for : ' || p_entity_name,
6402 l_user_entity_id);
6403 end loop; -- dflex_c2 loop
6404 end loop; -- dflex_c1 loop
6405 end create_desc_flex_main;
6406 --
6407 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6408 -- +
6409 -- get_legislation_code +
6410 -- +
6411 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6412 --
6413 -- This private function is used to get the legislation code for the Developer
6414 -- Descriptive flex context as specified in the Information type tables.
6415 -- This function returns 'M' if the flex context allows multiple occurrences.
6416 --
6417 function get_legislation_code
6418 (p_flexfield_name in varchar2
6419 ,p_context in varchar2)
6420 return varchar2 is
6421 --
6422 l_legislation_code hr_org_information_types.legislation_code%type;
6423 l_navigation_method hr_org_information_types.navigation_method%type;
6424 l_multi_occur_flag per_assignment_info_types.multiple_occurences_flag%type;
6425 --
6426 begin
6427 --
6428 --
6429 if (p_flexfield_name in ('Person Developer DF',
6430 'Payroll Developer DF',
6431 'Element Entry Developer DF',
6432 'Job Developer DF')) then
6433 --
6434 l_legislation_code := p_context;
6435 --
6436 elsif (p_flexfield_name = 'Org Developer DF') then -- Organization DF
6437 --
6438 -- get the legislation code
6439 --
6440 select legislation_code,
6441 navigation_method
6442 into l_legislation_code,
6443 l_navigation_method
6444 from hr_org_information_types
6445 where org_information_type = p_context;
6446 --
6447 -- The database item generated can only return one row. So if the
6448 -- navigation method is not 'GS' then raise an error.
6449 --
6450 if (l_navigation_method <> 'GS') then
6451 --
6452 return 'M';
6453 --
6454 end if;
6455 --
6456 elsif (p_flexfield_name = 'Assignment Developer DF') then
6457 --
6458 -- get the legislation code
6459 --
6460 select legislation_code,
6461 multiple_occurences_flag
6462 into l_legislation_code,
6463 l_multi_occur_flag
6464 from per_assignment_info_types
6465 where information_type = p_context;
6466 --
6467 -- The database item generated can only return one row. So if the
6468 -- multiple occurrences flag is not 'N' then raise an error.
6469 --
6470 if (l_multi_occur_flag <> 'N') then
6471 --
6472 return 'M';
6473 --
6474 end if;
6475 --
6476 elsif (p_flexfield_name = 'Extra Location Info DDF') then
6477 --
6478 -- get the legislation code:
6479 --
6480 select legislation_code,
6481 multiple_occurences_flag
6482 into l_legislation_code,
6483 l_multi_occur_flag
6484 from hr_location_info_types
6485 where information_type = p_context;
6486 --
6487 -- The database item generated can only return one row. So if the
6488 -- multiple occurrences flag is not 'N' then raise an error.
6489 --
6490 if (l_multi_occur_flag <> 'N') then
6491 --
6492 return 'M';
6493 --
6494 end if;
6495 --
6496 elsif (p_flexfield_name = 'Extra Position Info DDF') then
6497 --
6498 -- get the legislation code:
6499 --
6500 select legislation_code,
6501 multiple_occurences_flag
6502 into l_legislation_code,
6503 l_multi_occur_flag
6504 from per_position_info_types
6505 where information_type = p_context;
6506 --
6507 -- The database item generated can only return one row. So if the
6508 -- multiple occurrences flag is not 'N' then raise an error.
6509 --
6510 if (l_multi_occur_flag <> 'N') then
6511 --
6512 return 'M';
6513 --
6514 end if;
6515 --
6516 elsif (p_flexfield_name = 'Extra Person Info DDF') then
6517 --
6518 -- get the legislation code:
6519 --
6520 select legislation_code,
6521 multiple_occurences_flag
6522 into l_legislation_code,
6523 l_multi_occur_flag
6524 from per_people_info_types
6525 where information_type = p_context;
6526 --
6527 -- The database item generated can only return one row. So if the
6528 -- multiple occurrences flag is not 'N' then raise an error.
6529 --
6530 if (l_multi_occur_flag <> 'N') then
6531 --
6532 return 'M';
6533 --
6534 end if;
6535 --
6536 end if;
6537 --
6538 --
6539 return l_legislation_code;
6540 --
6541 end get_legislation_code;
6542 --
6543 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6544 -- +
6545 -- create_flexfield_dict +
6546 -- +
6547 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6548 /*
6549 NAME
6550 create_flexfield_dict - create descriptive flexfield database items
6551 --
6552 DESCRIPTION
6553 This procedure is the main entry point for creating descriptive
6554 flexfield database items. The title of the descriptive flex is passed to
6555 this routine as a parameter. To create all the descriptive flexfield
6556 database items for a particular application pass the title parameter
6557 as '%'
6558 --
6559 The database items created use the name as defined in the column
6560 'end_user_column_name' from the foundation table
6561 'fnd_descr_flex_column_usages'. For a given descriptive flexfield there
6562 could be several database items.
6563 --
6564 NOTES
6565 Since there is no desciptive flex id to identify an individual row in
6566 the ff_user_entities table, the title of the descriptive flex is used
6567 instead, holding it in the user_entity_name column.
6568 --
6569 It is intended that this flexfield creation procedure be run from the
6570 Standard Report Submission (SRS) form.
6571 */
6572 procedure create_flexfield_dict
6573 (
6574 p_title in varchar2
6575 ) is
6576 -- declare a cursor to determine the routes to a descriptive flexfields'
6577 -- tables and an entity name for each of these tables.
6578 --
6579 cursor routes_c is
6580 select df.application_table_name,
6581 rtd.route_name,
6582 rtd.user_key
6583 from fnd_descriptive_flexs_vl df,
6584 pay_route_to_descr_flexs rtd
6585 where df.application_id = rtd.application_id
6586 and df.descriptive_flexfield_name = rtd.descriptive_flexfield_name
6587 and replace (ltrim (rtrim(df.title)), '''','') = p_title;
6588 --
6589 -- declare a cursor to determine all the business_group_id's that any
6590 -- context descriptive flexfield elements are sensitive to.
6591 --
6592 cursor bgrp_c (p_table_name varchar2) is
6593 select dfc.descriptive_flex_context_code bus_grp_id
6594 from fnd_descr_flex_contexts dfc,
6595 fnd_descriptive_flexs_vl df
6596 where dfc.application_id = df.application_id
6597 and dfc.descriptive_flexfield_name = df.descriptive_flexfield_name
6598 and df.application_table_name = p_table_name
6599 and replace (ltrim (rtrim(df.title)), '''','') = p_title
6600 and df.default_context_field_name = 'BUSINESS_GROUP_ID'
6601 and dfc.enabled_flag = 'Y'
6602 and dfc.global_flag = 'N';
6603 --
6604 BEGIN
6605 for routes_crec in routes_c loop
6606
6607 create_desc_flex (p_title,
6608 routes_crec.application_table_name,
6609 routes_crec.route_name,
6610 routes_crec.user_key,
6611 'Global Data Elements', -- context
6612 'Y', -- global flag
6613 null, -- no route parameters
6614 null); -- legislation code
6615 --
6616 -- Now create business_group_id context dbitems
6617 --
6618 for bgrp_crec in bgrp_c(routes_crec.application_table_name) loop
6619 create_desc_flex (p_title,
6620 routes_crec.application_table_name,
6621 routes_crec.route_name,
6622 routes_crec.user_key,
6623 bgrp_crec.bus_grp_id, -- context
6624 'N', -- global flag
6625 null, -- no route params
6626 null, -- legislation code
6627 bgrp_crec.bus_grp_id); -- business group id
6628 end loop; -- bgrp_c loop
6629
6630 end loop; -- routes_crec
6631 end create_flexfield_dict;
6632 --
6633 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6634 -- +
6635 -- create_dev_desc_flex_dict +
6636 -- +
6637 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6638 /*
6639 NAME
6640 create_dev_desc_flex_dict - create developer descriptive flexfield
6641 database items
6642 --
6643 DESCRIPTION
6644 This procedure is the main entry point for creating developer descriptive
6645 flexfield database items. The parameters passed in are the
6646 title of the descriptive flex and the context.
6647 --
6648 The database items created use the name as defined in the column
6649 'end_user_column_name' from the foundation table
6650 'fnd_descr_flex_column_usages'. For a given descriptive flexfield there
6651 could be several database items.
6652 --
6653 This same procedure is called by different reports:
6654 --
6655 Create Organization Developer Descriptive Flexfield
6656 Create Person Developer Descriptive Flexfield
6657 Create Job Developer Descriptive Flexfield
6658 --
6659 The differences that affect this procedure are outlined below:
6660 --
6661 For the Organization DF report, the passed in context is a valid
6662 organization information type. In order to create a unique name the
6663 database item is named:
6664 --
6665 <CONTEXT>_ORG_<SEGMENT_NAME>
6666 --
6667 where <CONTEXT> is the passed in value, upper cased and spaces removed.
6668 --
6669 For the Person DF and the Job Developer Descriptive Flexfield
6670 report, the passed in context is the legislation code.
6671 In order to create a unique name the database item for the Person
6672 developer DF is:
6673 --
6674 PEOPLE_<LEGISLATION_CODE>_<SEGMENT_NAME>
6675 --
6676 and for the Job developer DF, it is name:
6677 --
6678 JOB_<LEGISLATION_CODE>_<SEGMENT_NAME>
6679 --
6680 where <LEGISLATION_CODE> is the passed in value of 'p_context'.
6681 --
6682 Code added to create dbitems for Extra Location Info DDF,
6683 Extra Position Info DDF and Extra Person Info DDF. The
6684 context passed for these 3 flexfields is the appropriate
6685 information type.
6686 NOTES
6687 Since there is no desciptive flex id to identify an individual row in
6688 the ff_user_entities table, the title of the descriptive flex is used
6689 instead, holding it in the user_entity_name column.
6690 --
6691 It is intended that this flexfield creation procedure be run from the
6692 Standard Report Submission (SRS) form.
6693 */
6694 procedure create_dev_desc_flex_dict
6695 (
6696 p_title in varchar2,
6697 p_context in varchar2
6698 ) is
6699 l_flexfield_name fnd_descriptive_flexs_vl.descriptive_flexfield_name%type;
6700 l_legislation_code hr_org_information_types.legislation_code%type;
6701 l_context hr_org_information_types.org_information_type%type;
6702 l_navigation_method hr_org_information_types.navigation_method%type;
6703 l_multi_occur_flag per_assignment_info_types.multiple_occurences_flag%type;
6704 --
6705 -- declare a cursor to determine the routes to a descriptive flexfield's
6706 -- tables and an entity name for each of these tables.
6707 --
6708 cursor c_routes is
6709 select df.application_table_name,
6710 rtd.route_name,
6711 rtd.user_key
6712 from fnd_descriptive_flexs_vl df,
6713 pay_route_to_descr_flexs rtd
6714 where df.application_id = rtd.application_id
6715 and df.descriptive_flexfield_name = rtd.descriptive_flexfield_name
6716 and replace (ltrim (rtrim(df.title)), '''','') = p_title
6717 and rtd.descriptive_flex_context_code = p_context;
6718 --
6719 -- declare a cursor to check whether the route uses a parameter
6720 --
6721 cursor c_chk_route_parameter (p_route_name varchar2) is
6722 select data_type
6723 from ff_route_parameters rpm, ff_routes rt
6724 where rt.route_name = p_route_name
6725 and rpm.route_id = rt.route_id;
6726
6727 l_routes c_routes%rowtype;
6728 l_routes_count number := 0;
6729 l_parameter_type varchar2(1);
6730 l_entity_name varchar2(80);
6731 l_parameter_value ff_route_parameter_values.value%type;
6732 --
6733 ---------------------- create_dev_desc_flex_dict -------------------------
6734 --
6735 BEGIN
6736 --
6737 select descriptive_flexfield_name
6738 into l_flexfield_name
6739 from fnd_descriptive_flexs_vl
6740 where title = p_title
6741 and application_id between 800 and 801;
6742 --
6743 l_legislation_code := get_legislation_code(l_flexfield_name, p_context);
6744 --
6745 -- Create the DB items only if the context allows single occurrence
6746 --
6747 if nvl(l_legislation_code,'N') <> 'M' then
6748 --
6749 -- Bug 2637573 - Code added to check if any Developer DF contexts are
6750 -- seeded. If yes, then the DB items are created using the routes in
6751 -- table pay_route_to_descr_flexs.
6752 --
6753 open c_routes;
6754 loop
6755 --
6756 fetch c_routes into l_routes;
6757 l_routes_count := c_routes%rowcount;
6758 --
6759 exit when c_routes%notfound;
6760 --
6761 open c_chk_route_parameter(l_routes.route_name);
6762 fetch c_chk_route_parameter into l_parameter_type;
6763 --
6764 if c_chk_route_parameter%found then
6765 if (l_parameter_type = 'T') then
6766 l_parameter_value := '''' || p_context || '''';
6767 else
6768 l_parameter_value := p_context;
6769 end if;
6770 end if;
6771 --
6772 close c_chk_route_parameter;
6773 --
6774 l_entity_name := replace (ltrim(rtrim(upper(l_flexfield_name))),' ','_')
6775 ||'_'||l_routes.user_key;
6776 --
6777 create_desc_flex (p_title,
6778 l_routes.application_table_name,
6779 l_routes.route_name,
6780 l_entity_name,
6781 p_context, -- context
6782 'N', -- global flag
6783 l_parameter_value, -- route parameter
6784 l_legislation_code); -- legislation_code
6785 --
6786 end Loop;
6787 close c_routes;
6788 --
6789 end if;
6790 --
6791 -- If no Developer DF contexts are seeded then DB items areccreated using the
6792 -- regular method.
6793 --
6794 If l_routes_count = 0 then
6795 --
6796 -- find out which report called this routine, either the Organization
6797 -- DF, the person developer DF or the job developer DF.
6798 --
6799 if (l_flexfield_name = 'Person Developer DF') then
6800 create_desc_flex (p_title,
6801 'PER_ALL_PEOPLE_F',
6802 'PEOPLE_FLEXFIELD_ROUTE',
6803 'PEOPLE_' || p_context,
6804 p_context, -- the context name
6805 'N', -- global flag
6806 null, -- no route parameters
6807 p_context); -- legislation code
6808 --
6809 elsif (l_flexfield_name = 'Org Developer DF') then -- Organization DF
6810 --
6811 -- get the legislation code
6812 --
6813 select legislation_code,
6814 navigation_method
6815 into l_legislation_code,
6816 l_navigation_method
6817 from hr_org_information_types
6818 where org_information_type = p_context;
6819 --
6820 -- this check to see if the navigation_method is 'GS' is also
6821 -- performed in the concurrent program. It has been added here as
6822 -- well, in case this procedure is called directly, and to ensure that
6823 -- the database item generated can only return one row.
6824 --
6825 if (l_navigation_method = 'GS') then
6826 l_context := replace (ltrim (rtrim (upper (p_context))), ' ', '_');
6827 --
6828 create_desc_flex (p_title,
6829 'HR_ORGANIZATION_INFORMATION',
6830 'DEVELOPER_ORG_DESC_FLEX_ROUTE',
6831 l_context || '_ORG',
6832 p_context, -- the context name
6833 'N', -- global flag
6834 p_context, -- used for route parameter
6835 l_legislation_code); -- legislation code
6836 --
6837 -- see if any Legal Company Descriptive Flexs are to be created:
6838 --
6839 if ((l_legislation_code is null)
6840 or (l_legislation_code ='US')
6841 or (l_legislation_code ='CA')) then
6842 create_desc_flex (p_title,
6843 'HR_ORGANIZATION_INFORMATION',
6844 'LEGAL_CO_DESC_FLEX_ROUTE',
6845 'LC_' || l_context || '_ORG',
6846 p_context, -- the context name
6847 'N', -- global flag
6848 p_context, -- used for route parameter
6849 l_legislation_code); -- legislation code
6850 end if;
6851 --
6852 end if;
6853 --
6854 elsif (l_flexfield_name = 'Assignment Developer DF') then
6855 --
6856 -- get the legislation code:
6857 --
6858 select legislation_code,
6859 multiple_occurences_flag
6860 into l_legislation_code,
6861 l_multi_occur_flag
6862 from per_assignment_info_types
6863 where information_type = p_context;
6864 --
6865 -- this check to see if the multiple_occurences_flag is 'N' is also
6866 -- performed in the concurrent program. It has been added here as
6867 -- well in case this procedure is called directly, and to ensure that
6868 -- the database item generated can only return one row.
6869 --
6870 if (l_multi_occur_flag = 'N') then
6871 l_context := replace (ltrim (rtrim (upper (p_context))), ' ', '_');
6872 --
6873 create_desc_flex (p_title,
6874 'PER_ASSIGNMENT_EXTRA_INFO',
6875 'DEVELOPER_ASS_DESC_FLEX_ROUTE',
6876 l_context || '_ASG',
6877 p_context, -- the context name
6878 'N', -- global flag
6879 p_context, -- used for route parameter
6880 l_legislation_code); -- legislation code
6881 end if;
6882 --
6883 elsif (l_flexfield_name = 'Payroll Developer DF') then -- Payroll DDF
6884 create_desc_flex (p_title,
6885 'PAY_ALL_PAYROLLS_F',
6886 'PAYROLL_FLEXFIELD_ROUTE',
6887 'PAY_' || p_context,
6888 p_context, -- the context name
6889 'N', -- global flag
6890 null, -- no route parameters
6891 p_context); -- legislation code
6892 --
6893 elsif (l_flexfield_name = 'Extra Location Info DDF') then
6894 --
6895 -- get the legislation code:
6896 --
6897 select legislation_code,
6898 multiple_occurences_flag
6899 into l_legislation_code,
6900 l_multi_occur_flag
6901 from hr_location_info_types
6902 where information_type = p_context;
6903 --
6904 -- this check to see if the multiple_occurences_flag is 'N' is also
6905 -- performed in the concurrent program. It has been added here as
6906 -- well in case this procedure is called directly, and to ensure that
6907 -- the database item generated can only return one row.
6908 --
6909 if (l_multi_occur_flag = 'N') then
6910 l_context := replace (ltrim (rtrim (upper (p_context))), ' ', '_');
6911 --
6912 create_desc_flex (p_title,
6913 'HR_LOCATION_EXTRA_INFO',
6914 'DEVELOPER_LOC_DESC_FLEX_ROUTE',
6915 l_context || '_LOC',
6916 p_context, -- the context name
6917 'N', -- global flag
6918 p_context, -- used for route parameter
6919 l_legislation_code); -- legislation code
6920 end if;
6921 --
6922 elsif (l_flexfield_name = 'Extra Position Info DDF') then
6923 --
6924 -- get the legislation code:
6925 --
6926 select legislation_code,
6927 multiple_occurences_flag
6928 into l_legislation_code,
6929 l_multi_occur_flag
6930 from per_position_info_types
6931 where information_type = p_context;
6932 --
6933 -- this check to see if the multiple_occurences_flag is 'N' is also
6934 -- performed in the concurrent program. It has been added here as
6935 -- well in case this procedure is called directly, and to ensure that
6936 -- the database item generated can only return one row.
6937 --
6938 if (l_multi_occur_flag = 'N') then
6939 l_context := replace (ltrim (rtrim (upper (p_context))), ' ', '_');
6940 --
6941 create_desc_flex (p_title,
6942 'PER_POSITION_EXTRA_INFO',
6943 'DEVELOPER_POS_DESC_FLEX_ROUTE',
6944 l_context || '_POS',
6945 p_context, -- the context name
6946 'N', -- global flag
6947 p_context, -- used for route parameter
6948 l_legislation_code); -- legislation code
6949 end if;
6950 --
6951 elsif (l_flexfield_name = 'Extra Person Info DDF') then
6952 --
6953 -- get the legislation code:
6954 --
6955 select legislation_code,
6956 multiple_occurences_flag
6957 into l_legislation_code,
6958 l_multi_occur_flag
6959 from per_people_info_types
6960 where information_type = p_context;
6961 --
6962 -- this check to see if the multiple_occurences_flag is 'N' is also
6963 -- performed in the concurrent program. It has been added here as
6964 -- well in case this procedure is called directly, and to ensure that
6965 -- the database item generated can only return one row.
6966 --
6967 if (l_multi_occur_flag = 'N') then
6968 l_context := replace (ltrim (rtrim (upper (p_context))), ' ', '_');
6969 --
6970 create_desc_flex (p_title,
6971 'PER_PEOPLE_EXTRA_INFO',
6972 'DEVELOPER_PER_DESC_FLEX_ROUTE',
6973 l_context || '_PER',
6974 p_context, -- the context name
6975 'N', -- global flag
6976 p_context, -- used for route parameter
6977 l_legislation_code); -- legislation code
6978 end if;
6979 --
6980 elsif (l_flexfield_name = 'Element Entry Developer DF') then
6981 create_desc_flex (p_title,
6982 'PAY_ELEMENT_ENTRIES_F',
6983 'ENTRY_DESC_FLEX_ROUTE',
6984 'ENTRY_'|| replace(ltrim(rtrim(p_context)),' ','_'),
6985 p_context, -- the context name
6986 'N', -- global flag
6987 p_context, -- used for route parameter
6988 substrb(p_context,1,2)); -- legislation code
6989 else -- a job developer DF
6990 --
6991 -- A Job developer descriptive flex. The 'p_context' parameter is a
6992 -- legislation code, which is used as the context code in the
6993 -- descriptive flex tables, and as part of the DB item name.
6994 --
6995 create_desc_flex (p_title,
6996 'PER_JOBS',
6997 'JOBS_DESC_FLEX_ROUTE',
6998 'JOBS_' || p_context,
6999 p_context,
7000 'N', -- global flag
7001 null, -- no route parameters
7002 p_context); -- legislation code
7003 end if;
7004 --
7005 end if;
7006 --
7007 end create_dev_desc_flex_dict;
7008 --
7009 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7010 -- +
7011 -- create_org_pay_flex_dict +
7012 -- +
7013 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7014 /*
7015 NAME
7016 create_org_pay_flex_dict - Create Organization Payment descriptive
7017 flexfield database items
7018 --
7019 DESCRIPTION
7020 This procedure is the main entry point for creating Organization
7021 Payment descriptive flexfield database items. The parameters passed
7022 in are the payment type id.
7023 --
7024 The database items created use the name as defined in the column
7025 'end_user_column_name' from the foundation table
7026 'fnd_descr_flex_column_usages'. For a given descriptive flexfield there
7027 could be several database items.
7028 NOTES
7029 Since there is no desciptive flex id to identify an individual row in
7030 the ff_user_entities table, the title of the descriptive flex is used
7031 instead, holding it in the user_entity_name column.
7032
7033 Added rtrim to title select below, due to Reserved word problem, ie
7034 the title, in creating descriptive flex cannot contain full stops,
7035 eg 'Further Payment Info.' - this is a temporary measure.
7036 */
7037 procedure create_org_pay_flex_dict
7038 (
7039 p_payment_id in number
7040 ) is
7041 cursor get_title is
7042 select rtrim(title,'.') from fnd_descriptive_flexs_vl
7043 where descriptive_flexfield_name = 'Paymeth Developer DF';
7044 --
7045 l_context pay_payment_types.payment_type_name%type;
7046 l_context_upper pay_payment_types.payment_type_name%type;
7047 l_title varchar2(80);
7048 --
7049 ---------------------- create_org_pay_flex_dict -------------------------
7050 --
7051 BEGIN
7052 --
7053 -- get the context
7054 --
7055 select payment_type_name
7056 into l_context
7057 from pay_payment_types
7058 where payment_type_id = p_payment_id;
7059 --
7060 open get_title;
7061 fetch get_title into l_title;
7062 close get_title;
7063 --
7064 l_context_upper := replace (ltrim (rtrim (upper (l_context))), ' ', '_');
7065 create_desc_flex (l_title,
7066 'PAY_ORG_PAYMENT_METHODS_F',
7067 'ORG_PAY_METHOD_DESC_FLEX_ROUTE',
7068 l_context_upper, -- used for entity name
7069 l_context, -- the context name
7070 'N', -- global flag
7071 p_payment_id, -- the route parameter
7072 null); -- legislation code
7073 end create_org_pay_flex_dict;
7074 --
7075 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7076 -- +
7077 -- create_ppm_devdff_flex_dict +
7078 -- +
7079 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7080 /*
7081 NAME
7082 create_ppm_devdff_flex_dict - Create Further Personal Payment Method
7083 Info DFF database items
7084 --
7085 DESCRIPTION
7086 This procedure is the main entry point for creating Further Personal
7087 Payment Method Info descriptive flexfield database items. The parameters
7088 passed in are the payment type id. Data base items will be created for
7089 the DFF with the payment type name as prefix.
7090 --
7091 The database items created use the name as defined in the column
7092 'end_user_column_name' from the foundation table
7093 'fnd_descr_flex_column_usages'. For a given descriptive flexfield there
7094 could be several database items.
7095 DB Item Format : <Leg Code>_<Payment Type>_<end_user_column_name>
7096 NOTES
7097 Since there is no desciptive flex id to identify an individual row in
7098 the ff_user_entities table, the title of the descriptive flex is used
7099 instead, holding it in the user_entity_name column.
7100
7101 Added rtrim to title select below, due to Reserved word problem, ie
7102 the title, in creating descriptive flex cannot contain full stops,
7103 eg 'Further Payment Info.' - this is a temporary measure.
7104 Added legislation code as well at the starting to figure the database
7105 items properly.
7106 */
7107 --
7108 procedure create_ppm_devdff_flex_dict
7109 (
7110 p_payment_id in number
7111 ) is
7112 cursor get_title is
7113 select rtrim(title,'.') from fnd_descriptive_flexs_vl
7114 where descriptive_flexfield_name = 'Personal PayMeth Developer DF';
7115
7116 l_context pay_payment_types.payment_type_name%type;
7117 l_context_upper pay_payment_types.payment_type_name%type;
7118 l_title varchar2(80);
7119
7120 begin
7121 select nvl(territory_code, 'ZZ')||'_'||payment_type_name
7122 into l_context
7123 from pay_payment_types
7124 where payment_type_id = p_payment_id;
7125 --
7126 open get_title;
7127 fetch get_title into l_title;
7128 close get_title;
7129 --
7130 l_context_upper := replace (ltrim (rtrim (upper (l_context))), ' ', '_');
7131 create_desc_flex (l_title,
7132 'PAY_PERSONAL_PAYMENT_METHODS_F',
7133 'PAY_FURTHER_PPM_DESC_FLEX_ROUTE',
7134 l_context_upper, -- used for entity name
7135 l_context, -- the context name
7136 'N', -- global flag
7137 p_payment_id, -- the route parameter
7138 null); -- legislation code
7139 end create_ppm_devdff_flex_dict;
7140 --
7141 --
7142 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7143 -- +
7144 -- create_absence_dict +
7145 -- +
7146 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7147 /*
7148 NAME
7149 create_absence_dict - create an absence database item in the dictionary
7150 --
7151 DESCRIPTION
7152 This procedure is the main entry point for creating absence type
7153 database items. The routes must have already been defined in the
7154 database (in table ff_routes). The procedure will search for the
7155 routes in this table by using the route name, which is hard coded below.
7156 The database items use the absence type name. The following
7157 database item is created:
7158 --
7159 <NAME>_CUM_BALANCE -- sum of entry values for that absence type
7160 */
7161 procedure create_absence_dict
7162 (
7163 p_absence_type_id in number
7164 ) is
7165 l_route_name varchar2(50) := 'ABSENCE_SUM_OF_ELEMENT_ENTRY_VALUES';
7166 l_absence_name per_absence_attendance_types.name%type;
7167 l_business_group_id number;
7168 l_created_by number;
7169 l_last_login number;
7170 l_record_inserted boolean;
7171 --
7172 ------------------------- create_absence_dict -------------------------
7173 --
7174 BEGIN
7175 --
7176 -- get the absence type information
7177 --
7178 select replace (ltrim (rtrim (upper (name))), ' ', '_'),
7179 business_group_id,
7180 created_by,
7181 last_update_login
7182 into l_absence_name,
7183 l_business_group_id,
7184 l_created_by,
7185 l_last_login
7186 from per_absence_attendance_types
7187 where absence_attendance_type_id = p_absence_type_id;
7188 --
7189 -- create the user entity for the route
7190 --
7191 insert_user_entity (l_route_name,
7192 l_absence_name,
7193 'entity for '|| l_route_name,
7194 'Y', -- not found allowed flag
7195 'A',
7196 p_absence_type_id,
7197 l_business_group_id,
7198 null, -- null legislation code
7199 l_created_by,
7200 l_last_login,
7201 l_record_inserted);
7202 --
7203 -- only insert parameter values/database items if entity was inserted
7204 --
7205 IF l_record_inserted THEN
7206 --
7207 -- insert the absence type id for the where clause filler
7208 --
7209 insert_parameter_value (p_absence_type_id, 1);
7210 --
7211 -- load up the database item for the route:
7212 --
7213 insert_database_item (l_absence_name,
7214 'CUM_BALANCE',
7215 'N', -- data type
7216 'sum (fnd_number.canonical_to_number(target.screen_entry_value))',
7217 'Y', -- null allowed
7218 'cumulative balance of an absence type for a given assignment');
7219 END IF;
7220 end create_absence_dict;
7221 --
7222 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7223 -- +
7224 -- delete_absence_dict +
7225 -- +
7226 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7227 /*
7228 NAME
7229 delete_absence_dict - delete the absence DB items from the data
7230 dictionary
7231 --
7232 DESCRIPTION
7233 */
7234 procedure delete_absence_dict
7235 (
7236 p_absence_type_id in number
7237 ) is
7238 --
7239 BEGIN
7240 DELETE FROM ff_user_entities
7241 WHERE creator_id = p_absence_type_id
7242 AND creator_type = 'A';
7243 end delete_absence_dict;
7244 --
7245 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7246 -- +
7247 -- refresh_absence_types *
7248 -- +
7249 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7250 /*
7251 NAME
7252 refresh_absence_types - create DB items for all absence types
7253 --
7254 DESCRIPTION
7255 This routine creates all database items based on absence types
7256 in the system. The routine assumes that no such database items currently
7257 exist.
7258 */
7259 procedure refresh_absence_types is
7260 cursor c1 is select absence_attendance_type_id type_id
7261 from per_absence_attendance_types;
7262 begin
7263 for c1rec in c1 loop
7264 hrrbdeib_trace_on;
7265 hr_utility.trace ('creating database item absence type id: '||
7266 to_char (c1rec.type_id));
7267 hrrbdeib_trace_off;
7268 create_absence_dict (c1rec.type_id);
7269 end loop;
7270 end refresh_absence_types;
7271 --
7272 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7273 -- +
7274 -- delete_absence_types +
7275 -- +
7276 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7277 /*
7278 NAME
7279 delete_absence_types - delete DB items for absence types
7280 --
7281 DESCRIPTION
7282 This routine deletes all database items based on absence types
7283 in the system. The routine assumes that no such database items currently
7284 exist.
7285 */
7286 procedure delete_absence_types is
7287 cursor c1 is select absence_attendance_type_id type_id
7288 from per_absence_attendance_types;
7289 begin
7290 --
7291 -- delete the absence types
7292 --
7293 for c1rec in c1 loop
7294 hrrbdeib_trace_on;
7295 hr_utility.trace ('deleting database item absence type id: '||
7296 to_char (c1rec.type_id));
7297 hrrbdeib_trace_off;
7298 delete_absence_dict (c1rec.type_id);
7299 end loop;
7300 end delete_absence_types;
7301 --
7302 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7303 -- +
7304 -- delete_keyflex_dict +
7305 -- +
7306 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7307 /*
7308 NAME
7309 delete_keyflex_dict - delete a key flexfield in the data dictionary
7310 --
7311 DESCRIPTION
7312 This procedure is the main entry point for deleting key
7313 flexfield database items. The parameters passed in are the id flex num
7314 and the name of the key flexfield.
7315 --
7316 NOTES
7317 */
7318 procedure delete_keyflex_dict
7319 (
7320 p_creator_id in number,
7321 p_entity_name in varchar2,
7322 p_leg_code in varchar2,
7323 p_business_group_id in number
7324 ) is
7325 l_entity_name ff_user_entities.user_entity_name%type;
7326 BEGIN
7327 l_entity_name := p_entity_name || '%';
7328 --
7329 -- delete any complied formula references
7330 --
7331 delete_compiled_formula (p_creator_id,
7332 'KF',
7333 l_entity_name,
7334 p_leg_code);
7335 --
7336 -- now delete the actual database items
7337 --
7338 delete from ff_user_entities
7339 where creator_type = 'KF'
7340 and creator_id = p_creator_id
7341 and user_entity_name like l_entity_name
7342 and ( nvl (legislation_code, ' ') = nvl (p_leg_code, ' ') -- 6955080
7343 OR nvl (business_group_id, -1) = nvl (p_business_group_id, -1));
7344 end delete_keyflex_dict;
7345 --
7346 --
7347 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7348 -- +
7349 -- create_key_flex +
7350 -- +
7351 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7352 /*
7353 NAME
7354 create_key_flex - General procedure for creating Key flexfield DB items
7355 --
7356 DESCRIPTION
7357 This procedure is responsible for creating the database items for a
7358 particular key flexfield.
7359 --
7360 NOTES
7361 The parameter 'p_table_name' is the name of the table as referred to in
7362 the table alias of the route.
7363 */
7364 procedure create_key_flex
7365 (
7366 p_applic_id in number,
7367 p_business_group in number,
7368 p_id_flex_num in number,
7369 p_id_flex_code in varchar2,
7370 p_entity_name in varchar2,
7371 p_leg_code in varchar2,
7372 p_route_name in varchar2,
7373 p_table_name in varchar2
7374 ) is
7375 --
7376 -- declare cursor for retrieving the actual column names:
7377 --
7378 cursor c1 is
7379 SELECT application_column_name c_def_text,
7380 replace (ltrim(rtrim(upper(segment_name))),' ','_') c_db_name
7381 FROM fnd_id_flex_segments
7382 WHERE application_id = p_applic_id
7383 AND id_flex_num = p_id_flex_num
7384 AND id_flex_code = p_id_flex_code;
7385 --
7386 l_dbitem_found boolean;
7387 l_record_inserted boolean;
7388 l_user_entity_id number;
7389 l_created_by number := 0;
7390 l_last_login number := 0;
7391 --
7392 ------------------------- create_key_flex -------------------------
7393 --
7394 begin
7395 l_dbitem_found := FALSE;
7396 --
7397 for c1rec in c1 loop
7398 if (l_dbitem_found = FALSE) then
7399 l_dbitem_found := TRUE;
7400 --
7401 -- create a user entity only if database items exist.
7402 --
7403 insert_user_entity (p_route_name,
7404 p_entity_name || '_KEY_FLEX_ENTITY',
7405 'route for key flexfield : '|| p_route_name,
7406 'Y',
7407 'KF',
7408 p_id_flex_num,
7409 p_business_group,
7410 p_leg_code,
7411 l_created_by,
7412 l_last_login,
7413 l_record_inserted);
7414 end if;
7415 insert_database_item (p_entity_name,
7416 c1rec.c_db_name,
7417 'T', -- data type
7418 p_table_name || '.' || c1rec.c_def_text,
7419 'Y', -- null allowed
7420 'database item for : ' || p_entity_name);
7421 end loop; -- c1 loop
7422 end create_key_flex;
7423 --
7424 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7425 -- +
7426 -- create_keyflex_dict +
7427 -- +
7428 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7429 /*
7430 NAME
7431 create_keyflex_dict - create a key flexfield in the data dictionary
7432 --
7433 DESCRIPTION
7434 This procedure is the main entry point for creating key
7435 flexfield database items. The routes must have already been defined
7436 in the database (in table ff_routes). The procedure will search for the
7437 routes in this table by using the route name, which is hard coded below.
7438 The parameters passed in are the business group id and the name of the
7439 key flexfield. To create all the key flexfield database items for a
7440 particular business group pass the name parameter as '%'. To create an
7441 individual key flexfield the following key flexfields are supported:
7442 --
7443 JOB for 'p_keyflex_name' pass in : 'JOB'
7444 POSITION for 'p_keyflex_name' pass in : 'POS'
7445 GRADE for 'p_keyflex_name' pass in : 'GRD'
7446 GROUP for 'p_keyflex_name' pass in : 'GRP'
7447 --
7448 The database items use the segment name column from the foundation
7449 table 'fnd_id_flex_segments'. For a given key flexfield there
7450 could be several database items.
7451 The following database items are created:
7452 --
7453 GRADE_KF_<NAME>
7454 JOB_KF_<NAME>
7455 POS_KF_<NAME>
7456 GROUP_KF_<NAME>
7457 --
7458 It is intended that this flexfield creation procedure be run from the
7459 Standard Report Submission (SRS) form.
7460 */
7461 procedure create_keyflex_dict
7462 (
7463 p_business_group_id in number,
7464 p_keyflex_name in varchar2
7465 ) is
7466 l_legislation_code varchar2(30);
7467 l_grade_flex_num number;
7468 l_group_flex_num number;
7469 l_job_flex_num number;
7470 l_position_flex_num number;
7471 l_competence_flex_num number;
7472 l_route_name varchar2(50) := 'KEY_FLEXFIELD_ROUTE';
7473 --
7474 ------------------------- create_keyflex_dict -------------------------
7475 --
7476 BEGIN
7477 --
7478 -- select the id flex numbers for each of the key flexfields
7479 --
7480 select grade_structure,
7481 people_group_structure,
7482 job_structure,
7483 position_structure,
7484 competence_structure,
7485 legislation_code
7486 into l_grade_flex_num,
7487 l_group_flex_num,
7488 l_job_flex_num,
7489 l_position_flex_num,
7490 l_competence_flex_num,
7491 l_legislation_code
7492 from per_business_groups_perf
7493 where business_group_id = p_business_group_id;
7494 --
7495 -- create each of the flexfields
7496 --
7497 if ('GRD' like p_keyflex_name) then -- create grade keyflex
7498 --
7499 -- first delete key flexfields that were previously created
7500 --
7501 delete_keyflex_dict (l_grade_flex_num,
7502 'GRADE_KF',
7503 l_legislation_code,
7504 p_business_group_id);
7505 --
7506 create_key_flex (800,
7507 p_business_group_id,
7508 l_grade_flex_num,
7509 'GRD',
7510 'GRADE_KF',
7511 null,
7512 l_route_name,
7513 'GRADEF'); -- target table name
7514 end if;
7515 --
7516 if ('JOB' like p_keyflex_name) then -- create job keyflex
7517 --
7518 -- first delete key flexfields that were previously created
7519 --
7520 delete_keyflex_dict (l_job_flex_num,
7521 'JOB_KF',
7522 l_legislation_code,
7523 p_business_group_id);
7524 --
7525 create_key_flex (800,
7526 p_business_group_id,
7527 l_job_flex_num,
7528 'JOB',
7529 'JOB_KF',
7530 null,
7531 l_route_name,
7532 'JOBDEF'); -- target table name
7533 end if;
7534 --
7535 if ('POS' like p_keyflex_name) then -- create position keyflex
7536 --
7537 -- first delete key flexfields that were previously created
7538 --
7539 delete_keyflex_dict (l_position_flex_num,
7540 'POS_KF',
7541 l_legislation_code,
7542 p_business_group_id);
7543 --
7544 create_key_flex (800,
7545 p_business_group_id,
7546 l_position_flex_num,
7547 'POS',
7548 'POS_KF',
7549 null,
7550 l_route_name,
7551 'POSDEF'); -- target table name
7552 end if;
7553 --
7554 if ('GRP' like p_keyflex_name) then -- create group keyflex
7555 --
7556 -- first delete key flexfields that were previously created
7557 --
7558 delete_keyflex_dict (l_group_flex_num,
7559 'GROUP_KF',
7560 l_legislation_code,
7561 p_business_group_id);
7562 --
7563 create_key_flex (801,
7564 p_business_group_id,
7565 l_group_flex_num,
7566 'GRP',
7567 'GROUP_KF',
7568 null,
7569 l_route_name,
7570 'PGROUP'); -- target table name
7571 end if;
7572 --
7573 if ('CMP' like p_keyflex_name) then -- create group keyflex
7574 --
7575 -- first delete key flexfields that were previously created
7576 --
7577 delete_keyflex_dict (l_competence_flex_num,
7578 'COMP_KF',
7579 l_legislation_code,
7580 p_business_group_id);
7581 --
7582 create_key_flex (800,
7583 p_business_group_id,
7584 l_competence_flex_num,
7585 'CMP',
7586 'COMP_KF',
7587 null,
7588 l_route_name,
7589 'COMP'); -- target table name
7590 end if;
7591 end create_keyflex_dict;
7592 --
7593 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7594 -- +
7595 -- create_ext_acc_keyflex_dict +
7596 -- +
7597 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7598 /*
7599 NAME
7600 create_ext_acc_keyflex_dict - create a key flexfield for an External
7601 Account in the data dictionary
7602 --
7603 DESCRIPTION
7604 This procedure is the main entry point for creating External Account Key
7605 flexfield database items. The routes must have already been defined
7606 in the database (in table ff_routes). The procedure will search for the
7607 routes in this table by using the route name, which is hard coded below.
7608 The parameter passed in is the id_flex_num of the keyflex.
7609 --
7610 The database items use the segment name column from the foundation
7611 table 'fnd_id_flex_segments'. For a given key flexfield there
7612 could be several database items.
7613 --
7614 The routine has been enhanced to loop around to create dbitems
7615 for each of the legislations which use the flex_num passed in.
7616 */
7617 procedure create_ext_acc_keyflex_dict
7618 (
7619 p_id_flex_num in number
7620 ) is
7621 --
7622 -- declare cursor 1 for retrieving each legislation using this flex num
7623 --
7624 cursor c1 is
7625 select legislation_code
7626 from pay_legislation_rules
7627 where rule_type = 'E'
7628 and rule_mode = to_char (p_id_flex_num);
7629 --
7630 l_legislation_code pay_legislation_rules.legislation_code%type;
7631 l_route_name varchar2(50) := 'EXT_ACCOUNT_ORG_KEYFLEX_ROUTE';
7632 --
7633 ----------------------- create_ext_acc_keyflex_dict -------------------------
7634 --
7635 BEGIN
7636 --
7637 -- get each legislation code
7638 --
7639 --
7640 for c1rec in c1 loop
7641 --
7642 l_legislation_code := c1rec.legislation_code;
7643 --
7644 -- delete key flexfields that were previously created
7645 --
7646 delete_keyflex_dict (p_id_flex_num,
7647 'ORG_' || l_legislation_code,
7648 l_legislation_code,
7649 null);
7650 --
7651 -- create the Organization External Account Keyflex
7652 --
7653 create_key_flex (801,
7654 null, -- business group id
7655 p_id_flex_num,
7656 'BANK',
7657 'ORG_' || l_legislation_code,
7658 l_legislation_code,
7659 l_route_name,
7660 'target'); -- target table name
7661 --
7662 -- delete key flexfields that were previously created
7663 --
7664 delete_keyflex_dict (p_id_flex_num,
7665 'PER_' || l_legislation_code,
7666 l_legislation_code,
7667 null);
7668 --
7669 -- create the Personal External Account Keyflex
7670 --
7671 l_route_name := 'EXT_ACCOUNT_PER_KEYFLEX_ROUTE';
7672 --
7673 create_key_flex (801,
7674 null, -- business group id
7675 p_id_flex_num,
7676 'BANK',
7677 'PER_' || l_legislation_code,
7678 l_legislation_code,
7679 l_route_name,
7680 'target'); -- target table name
7681 --
7682 end loop; -- c1 loop
7683 end create_ext_acc_keyflex_dict;
7684 --
7685 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7686 -- +
7687 -- create_scl_flex_dict +
7688 -- +
7689 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7690 /*
7691 NAME
7692 create_scl_flex_dict - create Soft Coded Legislation Keyflex DB items
7693 --
7694 DESCRIPTION
7695 This procedure is the main entry point for creating Soft Coded
7696 Legislation Keyflex database items. The parameter passed is is the
7697 id flex number.
7698 --
7699 The database items created use the name as defined in the column
7700 'segment_name' from the foundation table 'fnd_id_flex_segments'.
7701 There are 3 levels of SCL keyflex:
7702 --
7703 ASSIGNMENT
7704 PAYROLL
7705 ORGANIZATION
7706 --
7707 The routine loops through and generates DB items for each level.
7708 For a given SCL flexfield there could be several database items.
7709 --
7710 The routine has been enhanced to loop around to create dbitems
7711 for each of the legislations which use the flex_num passed in.
7712 NOTES
7713 It is intended that this creation procedure be run from the
7714 Standard Report Submission (SRS) form.
7715 */
7716 procedure create_scl_flex_dict
7717 (
7718 p_id_flex_num in number
7719 ) is
7720 --
7721 -- declare cursor 0 for retrieving each legislation using this flex num
7722 --
7723 cursor c0 is
7724 select legislation_code
7725 from pay_legislation_rules
7726 where rule_type = 'S'
7727 and rule_mode = to_char (p_id_flex_num);
7728 l_created_by number;
7729 l_last_login number;
7730 l_legislation_code pay_legislation_rules.legislation_code%type;
7731 --
7732 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7733 -- create_scl_flex +
7734 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7735 /*
7736 NAME
7737 create_scl_flex - called from procedure create_scl_flex_dict
7738 --
7739 DESCRIPTION
7740 This procedure is called from create_scl_flex_dict, and is responsible
7741 for creating the user entity and database items for a particular SCL
7742 flexfield.
7743 */
7744 procedure create_scl_flex
7745 (
7746 p_id_flex_num in number,
7747 p_leg_code in varchar2,
7748 p_route_name in varchar2,
7749 p_entity_name in varchar2,
7750 p_attribute_type in varchar2
7751 ) is
7752 --
7753 -- declare cursor 1 for retrieving the segment names and target columns
7754 --
7755 cursor c1 is
7756 select SEG.application_column_name c_def_text,
7757 replace (ltrim(rtrim(upper(SEG.segment_name))),' ','_') c_db_name,
7758 SEG.created_by c_created_by,
7759 SEG.last_update_login c_last_login
7760 from fnd_id_flex_segments SEG
7761 , fnd_segment_attribute_values VALUE
7762 where SEG.application_id = 800
7763 and SEG.id_flex_code = 'SCL'
7764 and SEG.id_flex_num = p_id_flex_num
7765 and SEG.enabled_flag = 'Y'
7766 and VALUE.application_column_name = SEG.application_column_name
7767 and VALUE.id_flex_code = 'SCL'
7768 and VALUE.id_flex_num = p_id_flex_num
7769 and VALUE.segment_attribute_type = p_attribute_type
7770 and VALUE.attribute_value = 'Y';
7771 --
7772 l_user_entity_id number;
7773 l_db_item_exist boolean;
7774 l_record_inserted boolean;
7775 begin
7776 l_db_item_exist := false;
7777 for c1rec in c1 loop
7778 if (l_db_item_exist = false) then -- first time through loop
7779 --
7780 -- create a user entity
7781 --
7782 l_created_by := c1rec.c_created_by;
7783 l_last_login := c1rec.c_last_login;
7784 --
7785 hrrbdeib_trace_on;
7786 hr_utility.trace ('creating SCL flex entity for '|| p_entity_name);
7787 hrrbdeib_trace_off;
7788 insert_user_entity (p_route_name,
7789 p_entity_name,
7790 'route for SCL level : '|| p_attribute_type,
7791 'Y',
7792 'KF',
7793 p_id_flex_num,
7794 null, -- null business group id
7795 p_leg_code,
7796 l_created_by,
7797 l_last_login,
7798 l_record_inserted);
7799 --
7800 -- only insert parameter values/database items if entity
7801 -- was inserted
7802 --
7803 IF l_record_inserted THEN
7804 --
7805 -- insert the id flex num for the where clause filler
7806 --
7807 insert_parameter_value (p_id_flex_num, 1);
7808 l_db_item_exist := true;
7809 END IF;
7810 end if;
7811 --
7812 -- now create the database item
7813 --
7814 insert_database_item (p_entity_name,
7815 c1rec.c_db_name,
7816 'T', -- data type
7817 'target.' || c1rec.c_def_text,
7818 'Y', -- null allowed
7819 'database item for : ' || p_entity_name);
7820 end loop; -- c1 loop
7821 end create_scl_flex;
7822 --
7823 ---------------------- create_scl_flex_dict -------------------------
7824 --
7825 BEGIN
7826 --
7827 -- get each legislation code
7828 --
7829 --
7830 for c0rec in c0 loop
7831 --
7832 l_legislation_code := c0rec.legislation_code;
7833 --
7834 -- delete any old SCL keyflex DB items that were created with the same id
7835 --
7836 delete_keyflex_dict (p_id_flex_num,
7837 'SCL',
7838 l_legislation_code,
7839 null);
7840
7841 --
7842 -- delete user entities (and dbitems) owned by a user entity
7843 -- for an old value of the S leg rule
7844 --
7845 delete from ff_user_entities
7846 where creator_type = 'KF'
7847 and creator_id <> p_id_flex_num
7848 and user_entity_name like 'SCL%'
7849 and nvl (legislation_code, ' ') = nvl (l_legislation_code, ' ')
7850 and business_group_id is null;
7851
7852 --
7853 -- generate DB items for the 3 levels of SCL:
7854 --
7855 create_scl_flex (p_id_flex_num,
7856 l_legislation_code,
7857 'SCL_ASS_FLEX_ROUTE',
7858 'SCL_ASG_' || l_legislation_code,
7859 'ASSIGNMENT');
7860 --
7861 create_scl_flex (p_id_flex_num,
7862 l_legislation_code,
7863 'SCL_PAY_FLEX_ROUTE',
7864 'SCL_PAY_' || l_legislation_code,
7865 'PAYROLL');
7866 --
7867 create_scl_flex (p_id_flex_num,
7868 l_legislation_code,
7869 'SCL_ORG_FLEX_ROUTE',
7870 'SCL_ORG_' || l_legislation_code,
7871 'ORGANIZATION');
7872 --
7873 end loop; -- c0 loop
7874 end create_scl_flex_dict;
7875 --
7876 procedure truncate_fcomp_info is
7877 statem varchar2(256);
7878 sql_cur number;
7879 ignore number;
7880 l_status varchar2(50);
7881 l_industry varchar2(50);
7882 l_per_owner varchar2(30);
7883 l_ret_per boolean;
7884 begin
7885
7886 -- Get FF table owner
7887 l_ret_per := FND_INSTALLATION.GET_APP_INFO ('PER', l_status,
7888 l_industry, l_per_owner);
7889
7890 statem := 'truncate table ' || l_per_owner || '.' || 'ff_fdi_usages_f';
7891 sql_cur := dbms_sql.open_cursor;
7892 dbms_sql.parse(sql_cur,
7893 statem,
7894 dbms_sql.v7);
7895 ignore := dbms_sql.execute(sql_cur);
7896 dbms_sql.close_cursor(sql_cur);
7897 statem := 'truncate table ' || l_per_owner || '.' || 'ff_compiled_info_f';
7898 sql_cur := dbms_sql.open_cursor;
7899 dbms_sql.parse(sql_cur,
7900 statem,
7901 dbms_sql.v7);
7902 ignore := dbms_sql.execute(sql_cur);
7903 dbms_sql.close_cursor(sql_cur);
7904 end truncate_fcomp_info;
7905 --
7906
7907 procedure disable_ffue_cascade_trig is
7908 statem varchar2(256);
7909 sql_cur number;
7910 ignore number;
7911 begin
7912 statem := 'alter trigger ff_database_items_brd disable';
7913 sql_cur := dbms_sql.open_cursor;
7914 dbms_sql.parse(sql_cur,
7915 statem,
7916 dbms_sql.v7);
7917 ignore := dbms_sql.execute(sql_cur);
7918 dbms_sql.close_cursor(sql_cur);
7919 statem := 'alter trigger ff_rpv_brud disable';
7920 sql_cur := dbms_sql.open_cursor;
7921 dbms_sql.parse(sql_cur,
7922 statem,
7923 dbms_sql.v7);
7924 ignore := dbms_sql.execute(sql_cur);
7925 dbms_sql.close_cursor(sql_cur);
7926 end disable_ffue_cascade_trig;
7927 --
7928 procedure enable_ffue_cascade_trig is
7929 statem varchar2(256);
7930 sql_cur number;
7931 ignore number;
7932 begin
7933 statem := 'alter trigger ff_database_items_brd enable';
7934 sql_cur := dbms_sql.open_cursor;
7935 dbms_sql.parse(sql_cur,
7936 statem,
7937 dbms_sql.v7);
7938 ignore := dbms_sql.execute(sql_cur);
7939 dbms_sql.close_cursor(sql_cur);
7940 statem := 'alter trigger ff_rpv_brud enable';
7941 sql_cur := dbms_sql.open_cursor;
7942 dbms_sql.parse(sql_cur,
7943 statem,
7944 dbms_sql.v7);
7945 ignore := dbms_sql.execute(sql_cur);
7946 dbms_sql.close_cursor(sql_cur);
7947 end enable_ffue_cascade_trig;
7948 --
7949 procedure disable_refbal_trig is
7950 statem varchar2(256);
7951 sql_cur number;
7952 ignore number;
7953 begin
7954 statem := 'alter trigger ff_user_entities_bri disable';
7955 sql_cur := dbms_sql.open_cursor;
7956 dbms_sql.parse(sql_cur,
7957 statem,
7958 dbms_sql.v7);
7959 ignore := dbms_sql.execute(sql_cur);
7960 dbms_sql.close_cursor(sql_cur);
7961 statem := 'alter trigger ff_database_items_bri disable';
7962 sql_cur := dbms_sql.open_cursor;
7963 dbms_sql.parse(sql_cur,
7964 statem,
7965 dbms_sql.v7);
7966 ignore := dbms_sql.execute(sql_cur);
7967 dbms_sql.close_cursor(sql_cur);
7968 statem := 'alter trigger ff_rpv_bri disable';
7969 sql_cur := dbms_sql.open_cursor;
7970 dbms_sql.parse(sql_cur,
7971 statem,
7972 dbms_sql.v7);
7973 ignore := dbms_sql.execute(sql_cur);
7974 dbms_sql.close_cursor(sql_cur);
7975 end disable_refbal_trig;
7976 --
7977 procedure enable_refbal_trig is
7978 statem varchar2(256);
7979 sql_cur number;
7980 ignore number;
7981 begin
7982 statem := 'alter trigger ff_user_entities_bri enable';
7983 sql_cur := dbms_sql.open_cursor;
7984 dbms_sql.parse(sql_cur,
7985 statem,
7986 dbms_sql.v7);
7987 ignore := dbms_sql.execute(sql_cur);
7988 dbms_sql.close_cursor(sql_cur);
7989 statem := 'alter trigger ff_database_items_bri enable';
7990 sql_cur := dbms_sql.open_cursor;
7991 dbms_sql.parse(sql_cur,
7992 statem,
7993 dbms_sql.v7);
7994 ignore := dbms_sql.execute(sql_cur);
7995 dbms_sql.close_cursor(sql_cur);
7996 statem := 'alter trigger ff_rpv_bri enable';
7997 sql_cur := dbms_sql.open_cursor;
7998 dbms_sql.parse(sql_cur,
7999 statem,
8000 dbms_sql.v7);
8001 ignore := dbms_sql.execute(sql_cur);
8002 dbms_sql.close_cursor(sql_cur);
8003 end enable_refbal_trig;
8004 --
8005 -- The following procedure recreates ALL dbis and UEs for all
8006 -- existing elements input values and balances. It is not intended to
8007 -- be used outside of Oracle development
8008 --
8009 procedure reib_all is
8010 begin
8011 --
8012 -- First set global to say we are disabling triggers.
8013 g_triggers_altered := TRUE;
8014 --
8015 delete pay_patch_status
8016 where patch_name like 'HRRBDEIB%';
8017 --
8018 commit;
8019 --
8020 disable_ffue_cascade_trig;
8021 --
8022 delete from ff_user_entities
8023 where creator_type in ('B', 'RB');
8024 --
8025 enable_ffue_cascade_trig;
8026 disable_refbal_trig;
8027 --
8028 hrdyndbi.refresh_defined_balances(0, 1);
8029 --
8030 commit;
8031 --
8032 enable_refbal_trig;
8033 disable_ffue_cascade_trig;
8034 --
8035 hrdyndbi.delete_element_types(0,1);
8036 --
8037 enable_ffue_cascade_trig;
8038 disable_refbal_trig;
8039 --
8040 hrdyndbi.refresh_element_types(0, 1);
8041 --
8042 delete pay_patch_status
8043 where patch_name like 'HRRBDEIB%';
8044 --
8045 enable_refbal_trig;
8046 --
8047 g_triggers_altered := FALSE;
8048 --
8049 exception when others then
8050 enable_ffue_cascade_trig;
8051 enable_refbal_trig;
8052 raise; -- reraise the exception
8053 end reib_all;
8054 --
8055 -- check_for_dbi_clash
8056 --
8057 -- This keeps the database item clash checking code in one place.
8058 -- This is for additions to FF_DATABASE_ITEMS.
8059 -- It also checks G_TRIGGERS_ALTERED.
8060 -- The code does not bother with FF_GLOBALS_F as that's the
8061 -- same as checking against database items.
8062 --
8063 procedure check_for_dbi_clash
8064 (p_user_name in varchar2
8065 ,p_ue_id in number
8066 ,p_leg_code in varchar2
8067 ,p_bg_id in number
8068 ,p_startup_mode in varchar2
8069 ,p_clash out nocopy boolean
8070 ) is
8071 l_exists varchar2(1);
8072 begin
8073 p_clash := true;
8074
8075 --
8076 -- For NOT G_TRIGGERS_ALTERED, the code will defer the checking to
8077 -- to database item trigger code.
8078 --
8079 if not g_triggers_altered then
8080 p_clash := false;
8081 return;
8082 end if;
8083
8084 select null
8085 into l_exists
8086 from dual
8087 where exists
8088 (
8089 select /*+ INDEX(a FF_DATABASE_ITEMS_PK)
8090 INDEX(b FF_USER_ENTITIES_PK) */ null
8091 from ff_database_items a,
8092 ff_user_entities b
8093 where a.user_name = p_user_name
8094 and a.user_entity_id = b.user_entity_id
8095 and
8096 (
8097 p_startup_mode = 'MASTER'
8098 or
8099 (
8100 p_startup_mode = 'SEED'
8101 and
8102 (
8103 b.legislation_code = p_leg_code
8104 or
8105 (
8106 b.legislation_code is null and b.business_group_id is null
8107 )
8108 or
8109 p_leg_code =
8110 (
8111 select c.legislation_code
8112 from per_business_groups_perf c
8113 where c.business_group_id = b.business_group_id
8114 )
8115 )
8116 )
8117 or
8118 (
8119 p_startup_mode = 'NON-SEED'
8120 and
8121 (
8122 b.business_group_id = p_bg_id
8123 or
8124 (
8125 b.legislation_code is null and b.business_group_id is null
8126 )
8127 or
8128 (
8129 b.business_group_id is null and b.legislation_code = p_leg_code
8130 )
8131 )
8132 )
8133 )
8134 )
8135 or exists
8136 (
8137 select /*+ ORDERED INDEX(a FF_DATABASE_ITEMS_TL_N2)
8138 INDEX(b FF_USER_ENTITIES_PK) */ null
8139 from ff_database_items_tl a,
8140 ff_user_entities b
8141 where a.translated_user_name = p_user_name
8142 and (a.user_name <> p_user_name or a.user_entity_id <> p_ue_id)
8143 and a.user_entity_id = b.user_entity_id
8144 and
8145 (
8146 p_startup_mode = 'MASTER'
8147 or
8148 (
8149 p_startup_mode = 'SEED'
8150 and
8151 (
8152 b.legislation_code = p_leg_code
8153 or
8154 (
8155 b.legislation_code is null and b.business_group_id is null
8156 )
8157 or
8158 p_leg_code =
8159 (
8160 select c.legislation_code
8161 from per_business_groups_perf c
8162 where c.business_group_id = b.business_group_id
8163 )
8164 )
8165 )
8166 or
8167 (
8168 p_startup_mode = 'NON-SEED'
8169 and
8170 (
8171 b.business_group_id = p_bg_id
8172 or
8173 (
8174 b.legislation_code is null and b.business_group_id is null
8175 )
8176 or
8177 (
8178 b.business_group_id is null and b.legislation_code = p_leg_code
8179 )
8180 )
8181 )
8182 )
8183 )
8184 or exists
8185 (
8186 select null
8187 from ff_contexts
8188 where context_name = p_user_name
8189 );
8190
8191 hrrbdeib_trace_on;
8192 hr_utility.trace('DBI name clash in (' || p_leg_code || ',' || p_bg_id ||
8193 ') for ' || p_user_name);
8194 hrrbdeib_trace_off;
8195
8196 exception
8197 when no_data_found then
8198 p_clash := false;
8199 end check_for_dbi_clash;
8200 --
8201 -- replace_code_name
8202 --
8203 -- This takes the NAME_TRANSLATIONS lookup search-and-replace code from
8204 -- insert_database_item so that it can be used in many places.
8205 --
8206 procedure replace_code_name
8207 (p_language_code in varchar2
8208 ,p_item_name in out nocopy varchar2
8209 ) is
8210 --
8211 -- Get codename cursor now accesses FND table directly, since we
8212 -- need all language values, not just the ones for the current
8213 -- language.
8214 --
8215 -- As bugfix 1210117 we replace apostrophes with underscores.
8216 --
8217 cursor get_codename (c_lookup_code in varchar2,
8218 c_language in varchar2) is
8219 select lookup_code,
8220 replace(replace(replace(replace(replace(ltrim(rtrim(upper(meaning))),' ','_'),'''','_'),'(',''),')',''),'.','') meaning2
8221 from fnd_lookup_values
8222 where instr(c_lookup_code,lookup_code) > 0
8223 and lookup_type = 'NAME_TRANSLATIONS'
8224 and language = c_language
8225 and view_application_id = 3
8226 and security_group_id = g_security_group_id
8227 order by length(lookup_code) desc;
8228 --
8229 l_item_name ff_database_items.user_name%type;
8230 begin
8231 --
8232 -- 523343. if the item name consists of more than one lookup_code,
8233 -- split into its constituent parts and translate separately, then
8234 -- concat back together to form the entirely translated item name.
8235 --
8236 l_item_name := p_item_name;
8237 for c1_rec in get_codename(p_item_name, p_language_code) loop
8238 l_item_name := replace(l_item_name,c1_rec.lookup_code,
8239 lower(c1_rec.meaning2));
8240 end loop;
8241 p_item_name := upper(l_item_name);
8242 end replace_code_name;
8243 --
8244 -- =================================== --
8245 -- DBI Base name generation procedures --
8246 -- =================================== --
8247
8248 -- Defined Balance
8249 procedure gen_db_base_dbi_name
8250 (p_defined_balance_id in number
8251 ,p_leg_code out nocopy varchar2
8252 ,p_bg_id out nocopy number
8253 ,p_base_name out nocopy varchar2
8254 ,p_balance_type_id out nocopy number
8255 ,p_balance_dimension_id out nocopy number
8256 ) is
8257 cursor csr_balance_dbi_name
8258 (p_defined_balance_id in number
8259 ) is
8260 select b.balance_name || d.database_item_suffix
8261 , db.legislation_code
8262 , db.business_group_id
8263 , db.balance_type_id
8264 , db.balance_dimension_id
8265 from pay_defined_balances db
8266 , pay_balance_types b
8267 , pay_balance_dimensions d
8268 where db.defined_balance_id = p_defined_balance_id
8269 and b.balance_type_id = db.balance_type_id
8270 and d.balance_dimension_id = db.balance_dimension_id
8271 ;
8272 --
8273 l_found boolean;
8274 l_base_name ff_database_items.user_name%type;
8275 l_leg_code pay_defined_balances.legislation_code%type;
8276 l_bg_id pay_defined_balances.business_group_id%type;
8277 l_bal_id pay_defined_balances.balance_type_id%type;
8278 l_baldim_id pay_defined_balances.balance_dimension_id%type;
8279 begin
8280 open csr_balance_dbi_name
8281 (p_defined_balance_id => p_defined_balance_id
8282 );
8283 fetch csr_balance_dbi_name
8284 into l_base_name
8285 , l_leg_code
8286 , l_bg_id
8287 , l_bal_id
8288 , l_baldim_id
8289 ;
8290 l_found := csr_balance_dbi_name%found;
8291 close csr_balance_dbi_name;
8292
8293 assert(l_found, 'gen_db_base_dbi_name:1', p_defined_balance_id);
8294
8295 -- Set output values.
8296 p_leg_code := l_leg_code;
8297 p_bg_id := l_bg_id;
8298 p_balance_type_id := l_bal_id;
8299 p_balance_dimension_id := l_baldim_id;
8300
8301 --
8302 -- Convert to a valid database item name.
8303 --
8304 p_base_name := ff_dbi_utils_pkg.str2dbiname(substr(l_base_name, 1, 80));
8305 end gen_db_base_dbi_name;
8306
8307 --
8308 -- gen_et_base_dbi_name
8309 --
8310 -- p_prefix is the element name and is taken from the database
8311 -- if null, otherwise it is reused.
8312 --
8313 procedure gen_et_base_dbi_name
8314 (p_element_type_id in number
8315 ,p_leg_code in out nocopy varchar2
8316 ,p_bg_id in out nocopy number
8317 ,p_prefix in out nocopy varchar2
8318 ,p_suffix in varchar2
8319 ,p_date_p in varchar2
8320 ,p_base_name out nocopy varchar2
8321 ) is
8322 cursor csr_prefix
8323 (p_element_type_id in number
8324 ) is
8325 select et.element_name
8326 , et.legislation_code
8327 , et.business_group_id
8328 from pay_element_types_f et
8329 where et.element_type_id = p_element_type_id
8330 ;
8331 --
8332 l_prefix varchar2(240);
8333 l_ele_name pay_element_types_f.element_name%type;
8334 l_found boolean;
8335 l_leg_code pay_element_types_f.legislation_code%type;
8336 l_bg_id pay_element_types_f.business_group_id%type;
8337 begin
8338 --
8339 -- Fetch the element name if necessary.
8340 --
8341 if p_prefix is null then
8342 open csr_prefix
8343 (p_element_type_id => p_element_type_id
8344 );
8345 fetch csr_prefix
8346 into l_ele_name
8347 , l_leg_code
8348 , l_bg_id
8349 ;
8350 l_found := csr_prefix%found;
8351 close csr_prefix;
8352
8353 assert(l_found, 'gen_et_base_dbi_name:1', p_element_type_id);
8354
8355 p_prefix := l_ele_name;
8356 p_leg_code := l_leg_code;
8357 p_bg_id := l_bg_id;
8358 end if;
8359
8360 --
8361 -- Convert to a valid database item name.
8362 --
8363 p_base_name :=
8364 ff_dbi_utils_pkg.str2dbiname(substr(p_prefix || '_' || p_suffix || p_date_p, 1, 80));
8365 end gen_et_base_dbi_name;
8366
8367 --
8368 -- gen_eiv_base_dbi_name
8369 --
8370 -- p_prefix is the element name and input value name, and is taken from
8371 -- the database if null, otherwise it is reused. There is special
8372 -- processing for PAY VALUE so that the lookup meaning from the
8373 -- NAME_TRANSLATIONS lookup is substituted in.
8374 --
8375 procedure gen_eiv_base_dbi_name
8376 (p_input_value_id in number
8377 ,p_leg_code in out nocopy varchar2
8378 ,p_bg_id in out nocopy number
8379 ,p_prefix in out nocopy varchar2
8380 ,p_suffix in varchar2
8381 ,p_date_p in varchar2
8382 ,p_base_name out nocopy varchar2
8383 ) is
8384 cursor csr_prefix
8385 (p_input_value_id in number
8386 ) is
8387 select et.element_name || '_' || iv.name
8388 , et.legislation_code
8389 , et.business_group_id
8390 from pay_element_types_f et
8391 , pay_input_values_f iv
8392 where iv.input_value_id = p_input_value_id
8393 and et.element_type_id = iv.element_type_id
8394 ;
8395 --
8396 l_prefix ff_database_items.user_name%type;
8397 l_leg_code pay_input_values_f.legislation_code%type;
8398 l_bg_id pay_input_values_f.business_group_id%type;
8399 l_found boolean;
8400 begin
8401 --
8402 -- Fetch the prefix if necessary.
8403 --
8404 if p_prefix is null then
8405 open csr_prefix
8406 (p_input_value_id => p_input_value_id
8407 );
8408 fetch csr_prefix
8409 into l_prefix
8410 , l_leg_code
8411 , l_bg_id
8412 ;
8413 l_found := csr_prefix%found;
8414 close csr_prefix;
8415
8416 assert(l_found, 'gen_eiv_base_dbi_name:1', p_input_value_id);
8417
8418 p_prefix := l_prefix;
8419 p_leg_code := l_leg_code;
8420 p_bg_id := l_bg_id;
8421 end if;
8422
8423 --
8424 -- Convert to a valid database item name.
8425 --
8426 p_base_name :=
8427 ff_dbi_utils_pkg.str2dbiname(substr(p_prefix || '_' || p_suffix || p_date_p, 1, 80));
8428 end gen_eiv_base_dbi_name;
8429
8430 -- ========================================= --
8431 -- DBI translated name generation procedures --
8432 -- ========================================= --
8433
8434 -- =============== --
8435 -- Defined Balance --
8436 -- =============== --
8437 procedure gen_db_tl_dbi_name
8438 (p_balance_type_id in number
8439 ,p_balance_dimension_id in number
8440 ,p_language in varchar2
8441 ,p_tl_name out nocopy varchar2
8442 ,p_found out nocopy boolean
8443 ) is
8444 cursor csr_balance_name
8445 (p_balance_type_id in number
8446 ,p_language in varchar2
8447 ) is
8448 select b.balance_name
8449 from pay_balance_types_tl b
8450 where b.balance_type_id = p_balance_type_id
8451 and b.language = p_language
8452 ;
8453 cursor csr_dbi_suffix
8454 (p_balance_dimension_id in number
8455 ,p_language in varchar2
8456 ) is
8457 select bd.database_item_suffix
8458 from pay_balance_dimensions_tl bd
8459 where bd.balance_dimension_id = p_balance_dimension_id
8460 and bd.language = p_language
8461 ;
8462 --
8463 l_balance_name pay_balance_types_tl.balance_name%type;
8464 l_dbi_suffix pay_balance_dimensions_tl.database_item_suffix%type;
8465 l_debug boolean := hr_utility.debug_enabled;
8466 l_found boolean;
8467 begin
8468 open csr_balance_name
8469 (p_balance_type_id => p_balance_type_id
8470 ,p_language => p_language
8471 );
8472 fetch csr_balance_name
8473 into l_balance_name
8474 ;
8475 l_found := csr_balance_name%found;
8476 close csr_balance_name;
8477
8478 if l_found then
8479 open csr_dbi_suffix
8480 (p_balance_dimension_id => p_balance_dimension_id
8481 ,p_language => p_language
8482 );
8483 fetch csr_dbi_suffix
8484 into l_dbi_suffix
8485 ;
8486 l_found := csr_dbi_suffix%found;
8487 close csr_dbi_suffix;
8488 end if;
8489
8490 if l_found then
8491 --
8492 -- Check name, converting if necessary. STR2DBINAME will be called
8493 -- later in the processing.
8494 --
8495 p_tl_name := l_balance_name || l_dbi_suffix;
8496 elsif l_debug then
8497 hr_utility.trace('Could not generate _TL DBI for defined balance (' ||
8498 p_balance_type_id || ',' || p_balance_dimension_id ||
8499 ')');
8500 end if;
8501
8502 p_found := l_found;
8503 end gen_db_tl_dbi_name;
8504
8505 -- =================== --
8506 -- Element Type Prefix --
8507 -- =================== --
8508 procedure gen_et_tl_dbi_prefix
8509 (p_element_type_id in number
8510 ,p_language in varchar2
8511 ,p_prefix in out nocopy varchar2
8512 ,p_found out nocopy boolean
8513 ) is
8514 cursor csr_prefix
8515 (p_element_type_id in number
8516 ,p_language in varchar2
8517 ) is
8518 select ettl.element_name
8519 from pay_element_types_f_tl ettl
8520 where ettl.element_type_id = p_element_type_id
8521 and ettl.language = p_language
8522 ;
8523 --
8524 l_found boolean := true;
8525 l_debug boolean := hr_utility.debug_enabled;
8526 begin
8527 open csr_prefix
8528 (p_element_type_id => p_element_type_id
8529 ,p_language => p_language
8530 );
8531 fetch csr_prefix
8532 into p_prefix;
8533 l_found := csr_prefix%found;
8534 close csr_prefix;
8535
8536 if not l_found then
8537 if l_debug then
8538 hr_utility.trace('Could not generate _TL DBI for element type ' ||
8539 p_element_type_id);
8540 end if;
8541 end if;
8542
8543 p_found := l_found;
8544 end gen_et_tl_dbi_prefix;
8545
8546 -- ========================== --
8547 -- Element Input Value Prefix --
8548 -- ========================== --
8549 procedure gen_eiv_tl_dbi_prefix
8550 (p_input_value_id in number
8551 ,p_effective_date in date
8552 ,p_language in varchar2
8553 ,p_prefix in out nocopy varchar2
8554 ,p_found out nocopy boolean
8555 ) is
8556 cursor csr_base_name
8557 (p_input_value_id in number
8558 ) is
8559 select iv.name
8560 from pay_input_values_f iv
8561 where iv.input_value_id = p_input_value_id
8562 and p_effective_date between
8563 iv.effective_start_date and iv.effective_end_date
8564 ;
8565 --
8566 cursor csr_prefix
8567 (p_input_value_id in number
8568 ,p_language in varchar2
8569 ) is
8570 select ivtl.name
8571 , ettl.element_name
8572 from pay_input_values_f iv
8573 , pay_element_types_f_tl ettl
8574 , pay_input_values_f_tl ivtl
8575 where iv.input_value_id = p_input_value_id
8576 and p_effective_date between
8577 iv.effective_start_date and iv.effective_end_date
8578 and ettl.element_type_id = iv.element_type_id
8579 and ettl.language = p_language
8580 and ivtl.input_value_id = iv.input_value_id
8581 and ivtl.language = p_language
8582 ;
8583 --
8584 l_pay_value pay_input_values_f.name%type := null;
8585 l_ipv_name pay_input_values_f_tl.name%type;
8586 l_ele_name pay_element_types_f_tl.element_name%type;
8587 l_found boolean := true;
8588 l_debug boolean := hr_utility.debug_enabled;
8589 begin
8590 --
8591 -- Check if the input is PAY VALUE.
8592 --
8593 open csr_base_name
8594 (p_input_value_id => p_input_value_id
8595 );
8596 fetch csr_base_name
8597 into l_pay_value
8598 ;
8599 l_found := csr_base_name%found;
8600 close csr_base_name;
8601
8602 --
8603 -- Whatever happens the base name must exist.
8604 --
8605 assert(l_found, 'gen_eiv_tl_dbi_name:1', p_input_value_id);
8606
8607 if upper(l_pay_value) = 'PAY VALUE' then
8608 l_pay_value := 'PAY VALUE';
8609 replace_code_name
8610 (p_language_code => p_language
8611 ,p_item_name => l_pay_value
8612 );
8613 else
8614 l_pay_value := null;
8615 end if;
8616
8617 open csr_prefix
8618 (p_input_value_id => p_input_value_id
8619 ,p_language => p_language
8620 );
8621 fetch csr_prefix
8622 into l_ipv_name
8623 , l_ele_name
8624 ;
8625 l_found := csr_prefix%found;
8626 close csr_prefix;
8627
8628 if l_found then
8629 p_prefix := l_ele_name || '_' || nvl(l_pay_value, l_ipv_name);
8630 else
8631 if l_debug then
8632 hr_utility.trace('Could not generate _TL DBI for element input value ' ||
8633 p_input_value_id);
8634 end if;
8635 end if;
8636
8637 p_found := l_found;
8638 end gen_eiv_tl_dbi_prefix;
8639
8640 procedure gen_et_dbi_prefixes
8641 (p_element_type_id in number
8642 ,p_languages in dbms_sql.varchar2s
8643 ,p_prefixes in out nocopy t_dbi_prefixes
8644 ) is
8645 l_prefix r_dbi_prefix;
8646 begin
8647 if p_prefixes.count = 0 then
8648 for i in 1 .. p_languages.count loop
8649 gen_et_tl_dbi_prefix
8650 (p_element_type_id => p_element_type_id
8651 ,p_language => p_languages(i)
8652 ,p_prefix => l_prefix.prefix
8653 ,p_found => l_prefix.found
8654 );
8655 p_prefixes(i) := l_prefix;
8656 p_prefixes(i).language := p_languages(i);
8657 end loop;
8658 end if;
8659 end gen_et_dbi_prefixes;
8660
8661 procedure gen_eiv_dbi_prefixes
8662 (p_input_value_id in number
8663 ,p_effective_date in date
8664 ,p_languages in dbms_sql.varchar2s
8665 ,p_prefixes in out nocopy t_dbi_prefixes
8666 ) is
8667 l_prefix r_dbi_prefix;
8668 begin
8669 if p_prefixes.count = 0 then
8670 for i in 1 .. p_languages.count loop
8671 gen_eiv_tl_dbi_prefix
8672 (p_input_value_id => p_input_value_id
8673 ,p_effective_date => p_effective_date
8674 ,p_language => p_languages(i)
8675 ,p_prefix => l_prefix.prefix
8676 ,p_found => l_prefix.found
8677 );
8678 p_prefixes(i) := l_prefix;
8679 p_prefixes(i).language := p_languages(i);
8680 end loop;
8681 end if;
8682 end gen_eiv_dbi_prefixes;
8683
8684 -- =================================== --
8685 -- Element Type / Input Value DBI Name --
8686 -- =================================== --
8687 procedure gen_et_tl_dbi_name
8688 (p_prefix in varchar2
8689 ,p_suffix in varchar2
8690 ,p_date_p in varchar2
8691 ,p_language in varchar2
8692 ,p_tl_name out nocopy varchar2
8693 ) is
8694 l_suffix varchar2(240);
8695 begin
8696 -- Translate the suffix.
8697 l_suffix := p_suffix || p_date_p;
8698 replace_code_name
8699 (p_language_code => p_language
8700 ,p_item_name => l_suffix
8701 );
8702
8703 --
8704 -- Convert to a valid database item name. STR2DBINAME will be
8705 -- called later in the processing.
8706 --
8707 p_tl_name := p_prefix || '_' || l_suffix;
8708 end gen_et_tl_dbi_name;
8709
8710 -- ====================================== --
8711 -- Utility procedures for translated DBIs --
8712 -- ====================================== --
8713
8714 --
8715 -- dbi2ueid
8716 --
8717 -- Takes a database item name and entity information to retrieve the
8718 -- corresponding user_entity_id.
8719 --
8720 function dbi2ueid
8721 (p_creator_id in number
8722 ,p_creator_type in varchar2
8723 ,p_user_name in varchar2
8724 ) return number is
8725 cursor csr_user_entity_id
8726 (p_creator_id in number
8727 ,p_creator_type in varchar2
8728 ,p_user_name in varchar2
8729 ) is
8730 select u.user_entity_id
8731 from ff_database_items d
8732 , ff_user_entities u
8733 where d.user_name = p_user_name
8734 and u.user_entity_id = d.user_entity_id
8735 and u.creator_id = p_creator_id
8736 and u.creator_type = p_creator_type
8737 ;
8738 --
8739 l_found boolean;
8740 l_ueid number;
8741 begin
8742 open csr_user_entity_id
8743 (p_creator_id => p_creator_id
8744 ,p_creator_type => p_creator_type
8745 ,p_user_name => p_user_name
8746 );
8747 fetch csr_user_entity_id
8748 into l_ueid
8749 ;
8750 l_found := csr_user_entity_id%found;
8751 close csr_user_entity_id;
8752
8753 assert(l_found, 'dbi2ueid:1',
8754 p_user_name || ':' || p_creator_type || ':' || p_creator_id);
8755
8756 return l_ueid;
8757 end dbi2ueid;
8758
8759 --
8760 -- check_for_tl_dbi_clash
8761 --
8762 -- This keeps the database item clash checking code in one place.
8763 -- This is for additions to FF_DATABASE_ITEMS_TL.
8764 -- It also checks G_TRIGGERS_ALTERED.
8765 -- The code does not bother with FF_GLOBALS_F as that's the
8766 -- same as checking against database items.
8767 --
8768 procedure check_for_tl_dbi_clash
8769 (p_user_name in varchar2
8770 ,p_user_entity_id in number
8771 ,p_tl_user_name in varchar2
8772 ,p_leg_code in varchar2
8773 ,p_bg_id in number
8774 ,p_startup_mode in varchar2
8775 ,p_clash out nocopy boolean
8776 ) is
8777 l_exists varchar2(1);
8778 begin
8779 p_clash := true;
8780
8781 --
8782 -- For NOT G_TRIGGERS_ALTERED, the code will defer the checking to
8783 -- to database item trigger code.
8784 --
8785 if not g_triggers_altered then
8786 p_clash := false;
8787 return;
8788 end if;
8789
8790 select null
8791 into l_exists
8792 from dual
8793 where exists
8794 (
8795 select /*+ INDEX(a FF_DATABASE_ITEMS_PK)
8796 INDEX(b FF_USER_ENTITIES_PK) */ null
8797 from ff_database_items a,
8798 ff_user_entities b
8799 where a.user_name = p_tl_user_name
8800 and (p_user_name <> p_tl_user_name or a.user_entity_id <> p_user_entity_id)
8801 and a.user_entity_id = b.user_entity_id
8802 and
8803 (
8804 p_startup_mode = 'MASTER'
8805 or
8806 (
8807 p_startup_mode = 'SEED'
8808 and
8809 (
8810 b.legislation_code = p_leg_code
8811 or
8812 (
8813 b.legislation_code is null and b.business_group_id is null
8814 )
8815 or
8816 p_leg_code =
8817 (
8818 select c.legislation_code
8819 from per_business_groups_perf c
8820 where c.business_group_id = b.business_group_id
8821 )
8822 )
8823 )
8824 or
8825 (
8826 p_startup_mode = 'NON-SEED'
8827 and
8828 (
8829 b.business_group_id = p_bg_id
8830 or
8831 (
8832 b.legislation_code is null and b.business_group_id is null
8833 )
8834 or
8835 (
8836 b.business_group_id is null and b.legislation_code = p_leg_code
8837 )
8838 )
8839 )
8840 )
8841 )
8842 or exists
8843 (
8844 select /*+ ORDERED INDEX(a FF_DATABASE_ITEMS_TL_N2)
8845 INDEX(b FF_USER_ENTITIES_PK) */ null
8846 from ff_database_items_tl a,
8847 ff_user_entities b
8848 where a.translated_user_name = p_tl_user_name
8849 and (a.user_name <> p_user_name or a.user_entity_id <> p_user_entity_id)
8850 and a.user_entity_id = b.user_entity_id
8851 and
8852 (
8853 p_startup_mode = 'MASTER'
8854 or
8855 (
8856 p_startup_mode = 'SEED'
8857 and
8858 (
8859 b.legislation_code = p_leg_code
8860 or
8861 (
8862 b.legislation_code is null and b.business_group_id is null
8863 )
8864 or
8865 p_leg_code =
8866 (
8867 select c.legislation_code
8868 from per_business_groups_perf c
8869 where c.business_group_id = b.business_group_id
8870 )
8871 )
8872 )
8873 or
8874 (
8875 p_startup_mode = 'NON-SEED'
8876 and
8877 (
8878 b.business_group_id = p_bg_id
8879 or
8880 (
8881 b.legislation_code is null and b.business_group_id is null
8882 )
8883 or
8884 (
8885 b.business_group_id is null and b.legislation_code = p_leg_code
8886 )
8887 )
8888 )
8889 )
8890 )
8891 or exists
8892 (
8893 select null
8894 from ff_contexts
8895 where context_name = p_tl_user_name
8896 );
8897
8898 hrrbdeib_trace_on;
8899 hr_utility.trace('TL DBI name clash in (' || p_leg_code || ',' || p_bg_id ||
8900 ') for ' || p_user_name);
8901 hrrbdeib_trace_off;
8902
8903 exception
8904 when no_data_found then
8905 p_clash := false;
8906 end check_for_tl_dbi_clash;
8907
8908 -- Assert a condition in the code.
8909 procedure assert
8910 (p_condition in boolean
8911 ,p_location in varchar2
8912 ,p_extra_info in varchar2
8913 ) is
8914 l_debug_cnt number;
8915 begin
8916 if not p_condition then
8917 hr_utility.set_message(801, 'FFPLU01_ASSERTION_FAILED');
8918 hr_utility.set_message_token('1', p_location || ':[' || p_extra_info || ']');
8919 hr_utility.raise_error;
8920 end if;
8921 end assert;
8922
8923 -- Check for DATE_PAID database items.
8924 function has_date_paid_dbis
8925 (p_creator_type in varchar2
8926 ,p_creator_id in number
8927 ) return boolean is
8928 l_count number;
8929 begin
8930 select count(*)
8931 into l_count
8932 from ff_user_entities ue
8933 where ue.creator_id = p_creator_id
8934 and ue.creator_type = p_creator_type
8935 and ue.user_entity_name like '%_DP'
8936 ;
8937
8938 return l_count > 0;
8939 end has_date_paid_dbis;
8940
8941 -- Check for non-DATE_PAID database items.
8942 function has_non_date_paid_dbis
8943 (p_creator_type in varchar2
8944 ,p_creator_id in number
8945 ) return boolean is
8946 l_count number;
8947 begin
8948 select count(*)
8949 into l_count
8950 from ff_user_entities ue
8951 where ue.creator_id = p_creator_id
8952 and ue.creator_type = p_creator_type
8953 and ue.user_entity_name not like '%_DP'
8954 ;
8955
8956 return l_count > 0;
8957 end has_non_date_paid_dbis;
8958
8959 --
8960 -- Update the _TL database item name.
8961 --
8962 procedure update_tl_dbi_name
8963 (p_user_name in varchar2
8964 ,p_user_entity_id in number
8965 ,p_leg_code in varchar2
8966 ,p_bg_id in number
8967 ,p_startup_mode in varchar2
8968 ,p_language in varchar2
8969 ,p_tl_user_name in varchar2
8970 ) is
8971 l_clash boolean;
8972 l_tl_user_name ff_database_items_tl.translated_user_name%type;
8973 l_got_error boolean;
8974 begin
8975 --
8976 -- G_TRIGGERS_ALTERED is true for the bulk generation of balance,
8977 -- element, and input value names in HRDYNDBI. The validation assumes
8978 -- that FF_FDI_USAGES_F rows have been deleted.
8979 --
8980 if g_triggers_altered then
8981 --
8982 -- Format the translated name.
8983 --
8984 l_tl_user_name :=
8985 ff_dbi_utils_pkg.str2dbiname(p_str => p_tl_user_name);
8986
8987 check_for_tl_dbi_clash
8988 (p_user_name => p_user_name
8989 ,p_user_entity_id => p_user_entity_id
8990 ,p_tl_user_name => l_tl_user_name
8991 ,p_leg_code => p_leg_code
8992 ,p_bg_id => p_bg_id
8993 ,p_startup_mode => p_startup_mode
8994 ,p_clash => l_clash
8995 );
8996
8997 if not l_clash then
8998 update ff_database_items_tl dbitl
8999 set dbitl.translated_user_name = l_tl_user_name
9000 , dbitl.source_lang = p_language
9001 where dbitl.language = p_language
9002 and dbitl.user_name = p_user_name
9003 and dbitl.user_entity_id = p_user_entity_id
9004 ;
9005
9006 --
9007 -- Put in an assertion to check for missing database items.
9008 -- However, the US deduction form creates the element type
9009 -- before updating the benefit_classification_id causing this
9010 -- assertion to fail, because the database items are created
9011 -- before the benefit_classification_id is made NOT NULL.
9012 --
9013 if not p_user_name like '%BEN_CLASS' then
9014 assert(SQL%rowcount > 0, 'update_tl_dbi_name:1',
9015 p_user_name || ':' || p_user_entity_id);
9016 end if;
9017 else
9018 --
9019 -- For the MLS process, a name clash is a fatal error.
9020 --
9021 hr_utility.set_message (801, 'PAY_33916_DYN_DBI_NAME_CLASH');
9022 hr_utility.set_message_token('1', l_tl_user_name);
9023 hr_utility.raise_error;
9024 end if;
9025 elsif g_dyndbi_changes then
9026 l_tl_user_name := p_tl_user_name;
9027 ff_database_items_pkg.update_seeded_tl_rows
9028 (x_user_name => p_user_name
9029 ,x_user_entity_id => p_user_entity_id
9030 ,x_language => p_language
9031 ,x_translated_user_name => l_tl_user_name
9032 ,x_description => null
9033 ,x_got_error => l_got_error
9034 );
9035
9036 if l_got_error then
9037 g_dyndbi_changes_ok := false;
9038 end if;
9039
9040 --
9041 -- One-off update for a single element type, input value, or balance.
9042 -- In the FF_DATABASE_ITEMS case, the FF_DATABASE_ITEMS trigger would
9043 -- handle this validation. Unfortunately, an update trigger cannot
9044 -- perform this because of ORA-04091 errors.
9045 --
9046 else
9047 --
9048 -- Note: UPDATE_TL_ROW calls STR2DBINAME so passing p_tl_user_name
9049 -- unmodified to UPDATE_TL_ROW.
9050 --
9051 ff_database_items_pkg.update_tl_row
9052 (x_user_name => p_user_name
9053 ,x_user_entity_id => p_user_entity_id
9054 ,x_language => p_language
9055 ,x_source_lang => p_language
9056 ,x_translated_user_name => p_tl_user_name
9057 ,x_description => null
9058 );
9059 end if;
9060 end update_tl_dbi_name;
9061
9062 -- =================================================== --
9063 -- Element Type/Input Value DBI name update procedure --
9064 -- =================================================== --
9065 procedure update_et_tl_dbi_names
9066 (p_leg_code in varchar2
9067 ,p_bg_id in number
9068 ,p_startup_mode in varchar2
9069 ,p_user_name in varchar2
9070 ,p_user_entity_id in number
9071 ,p_prefixes in t_dbi_prefixes
9072 ,p_suffix in varchar2
9073 ,p_date_p in varchar2
9074 ) is
9075 --
9076 l_tl_name ff_database_items_tl.translated_user_name%type;
9077 begin
9078 for i in 1 .. p_prefixes.count loop
9079 if p_prefixes(i).found then
9080 --
9081 -- Generate the translated DBI name.
9082 --
9083 gen_et_tl_dbi_name
9084 (p_prefix => p_prefixes(i).prefix
9085 ,p_suffix => p_suffix
9086 ,p_date_p => p_date_p
9087 ,p_language => p_prefixes(i).language
9088 ,p_tl_name => l_tl_name
9089 );
9090
9091 --
9092 -- Update the translated database item.
9093 --
9094 update_tl_dbi_name
9095 (p_user_name => p_user_name
9096 ,p_user_entity_id => p_user_entity_id
9097 ,p_leg_code => p_leg_code
9098 ,p_bg_id => p_bg_id
9099 ,p_startup_mode => p_startup_mode
9100 ,p_language => p_prefixes(i).language
9101 ,p_tl_user_name => l_tl_name
9102 );
9103 end if;
9104 end loop;
9105 end update_et_tl_dbi_names;
9106
9107 -- ========================================= --
9108 -- Update all the dbis for a defined balance --
9109 -- ========================================= --
9110 procedure update_defined_balance
9111 (p_defined_balance_id in number
9112 ,p_languages in dbms_sql.varchar2s
9113 ) is
9114 l_leg_code varchar2(30);
9115 l_bg_id number;
9116 l_bal_id pay_defined_balances.balance_type_id%type;
9117 l_baldim_id pay_defined_balances.balance_dimension_id%type;
9118 l_base_name ff_database_items.user_name%type;
9119 l_ueid number;
9120 l_tl_name ff_database_items_tl.translated_user_name%type;
9121 l_found boolean;
9122 l_startup_mode varchar2(30);
9123 begin
9124 --
9125 -- Generate the base database item information.
9126 --
9127 gen_db_base_dbi_name
9128 (p_defined_balance_id => p_defined_balance_id
9129 ,p_leg_code => l_leg_code
9130 ,p_bg_id => l_bg_id
9131 ,p_base_name => l_base_name
9132 ,p_balance_type_id => l_bal_id
9133 ,p_balance_dimension_id => l_baldim_id
9134 );
9135 l_ueid :=
9136 dbi2ueid
9137 (p_creator_id => p_defined_balance_id
9138 ,p_creator_type => 'B'
9139 ,p_user_name => l_base_name
9140 );
9141
9142 --
9143 -- Get the startup mode.
9144 --
9145 if g_triggers_altered then
9146 l_startup_mode := ffstup.get_mode(l_bg_id, l_leg_code);
9147 end if;
9148
9149 --
9150 -- Generate the translated name and create the database item
9151 -- for each language
9152 --
9153 for i in 1 .. p_languages.count loop
9154 gen_db_tl_dbi_name
9155 (p_balance_type_id => l_bal_id
9156 ,p_balance_dimension_id => l_baldim_id
9157 ,p_language => p_languages(i)
9158 ,p_tl_name => l_tl_name
9159 ,p_found => l_found
9160 );
9161
9162 --
9163 -- Update the translated database item.
9164 --
9165 if l_found then
9166 update_tl_dbi_name
9167 (p_user_name => l_base_name
9168 ,p_user_entity_id => l_ueid
9169 ,p_leg_code => l_leg_code
9170 ,p_bg_id => l_bg_id
9171 ,p_startup_mode => l_startup_mode
9172 ,p_language => p_languages(i)
9173 ,p_tl_user_name => l_tl_name
9174 );
9175 end if;
9176 end loop;
9177 end update_defined_balance;
9178
9179 -- =============================== --
9180 -- Update dbis for an element type --
9181 -- =============================== --
9182
9183 --
9184 -- Interface 1: does not reference PAY_ELEMENT_TYPES_F_TL - the core
9185 -- interface.
9186 --
9187 procedure update_element_type
9188 (p_element_type_id in number
9189 ,p_effective_date in date
9190 ,p_languages in dbms_sql.varchar2s
9191 ,p_dbi_prefixes in t_dbi_prefixes
9192 ) is
9193 l_date_p varchar2(16);
9194 l_do_date_p boolean;
9195 l_do_non_date_p boolean;
9196 l_leg_code varchar2(30);
9197 l_bg_id number;
9198 l_ueid number;
9199 l_prefix varchar2(240);
9200 l_found boolean;
9201 l_startup_mode varchar2(30);
9202 l_ben_class_id number;
9203
9204 --
9205 -- Cursor to fetch element type information.
9206 --
9207 cursor csr_element_type_info
9208 (p_element_type_id in number
9209 ,p_effective_date in date
9210 ) is
9211 select et.benefit_classification_id
9212 , et.legislation_code
9213 , et.business_group_id
9214 from pay_element_types_f et
9215 where et.element_type_id = p_element_type_id
9216 and p_effective_date between
9217 et.effective_start_date and et.effective_end_date
9218 ;
9219 --
9220 procedure update_dbis
9221 (p_element_type_id in number
9222 ,p_leg_code in out nocopy varchar2
9223 ,p_bg_id in out nocopy number
9224 ,p_prefix in out nocopy varchar2
9225 ,p_dbi_prefixes in t_dbi_prefixes
9226 ,p_date_p in varchar2
9227 ,p_startup_mode in varchar2
9228 ,p_languages in dbms_sql.varchar2s
9229 ,p_user_entity_id in out nocopy number
9230 ,p_suffix in varchar2
9231 ) is
9232 l_base_name ff_database_items.user_name%type;
9233 begin
9234 gen_et_base_dbi_name
9235 (p_element_type_id => p_element_type_id
9236 ,p_leg_code => p_leg_code
9237 ,p_bg_id => p_bg_id
9238 ,p_prefix => p_prefix
9239 ,p_suffix => p_suffix
9240 ,p_date_p => p_date_p
9241 ,p_base_name => l_base_name
9242 );
9243
9244 if p_user_entity_id is null then
9245 p_user_entity_id :=
9246 dbi2ueid
9247 (p_creator_id => p_element_type_id
9248 ,p_creator_type => 'E'
9249 ,p_user_name => l_base_name
9250 );
9251 end if;
9252
9253 update_et_tl_dbi_names
9254 (p_leg_code => p_leg_code
9255 ,p_bg_id => p_bg_id
9256 ,p_startup_mode => p_startup_mode
9257 ,p_user_name => l_base_name
9258 ,p_user_entity_id => p_user_entity_id
9259 ,p_prefixes => p_dbi_prefixes
9260 ,p_suffix => p_suffix
9261 ,p_date_p => p_date_p
9262 );
9263 end update_dbis;
9264
9265 begin
9266 -- ==================================================== --
9267 -- Are there DATE_PAID / non-DATE_PAID database items ? --
9268 -- ==================================================== --
9269 l_do_date_p :=
9270 has_date_paid_dbis
9271 (p_creator_type => 'E'
9272 ,p_creator_id => p_element_type_id
9273 );
9274
9275 l_do_non_date_p :=
9276 has_non_date_paid_dbis
9277 (p_creator_type => 'E'
9278 ,p_creator_id => p_element_type_id
9279 );
9280
9281 -- ============================= --
9282 -- Get element type information. --
9283 -- ============================= --
9284 open csr_element_type_info
9285 (p_element_type_id => p_element_type_id
9286 ,p_effective_date => p_effective_date
9287 );
9288 fetch csr_element_type_info
9289 into l_ben_class_id
9290 , l_leg_code
9291 , l_bg_id
9292 ;
9293 l_found := csr_element_type_info%found;
9294 close csr_element_type_info;
9295
9296 assert(l_found, 'update_element_type:1', p_element_type_id);
9297
9298 --
9299 -- Get the startup mode. This only needs to be done at this
9300 -- stage as l_bg_id and l_leg_code should not change.
9301 --
9302 if g_triggers_altered then
9303 l_startup_mode := ffstup.get_mode(l_bg_id, l_leg_code);
9304 end if;
9305
9306 -- Force fetch of element type information.
9307 l_prefix := null;
9308
9309 -- ============================== --
9310 -- Database item processing code. --
9311 -- ============================== --
9312 loop
9313
9314 --
9315 -- Loop control based upon processing DATE PAID and non-DATE PAID
9316 -- database items.
9317 --
9318 if l_do_non_date_p then
9319 l_date_p := null;
9320 l_do_non_date_p := false;
9321 elsif l_do_date_p then
9322 l_date_p := '_DP';
9323 l_do_date_p := false;
9324 else
9325 exit;
9326 end if;
9327
9328 -- ========================================= --
9329 -- Process the dbis for the _E1 user entity. --
9330 -- ========================================= --
9331
9332 --
9333 -- This must be done for the first dbi in each user entity.
9334 --
9335 l_ueid := null;
9336
9337 -- REPORTING_NAME --
9338 update_dbis
9339 (p_element_type_id => p_element_type_id
9340 ,p_leg_code => l_leg_code
9341 ,p_bg_id => l_bg_id
9342 ,p_prefix => l_prefix
9343 ,p_dbi_prefixes => p_dbi_prefixes
9344 ,p_date_p => l_date_p
9345 ,p_startup_mode => l_startup_mode
9346 ,p_languages => p_languages
9347 ,p_user_entity_id => l_ueid
9348 ,p_suffix => 'REPORTING_NAME'
9349 );
9350
9351 -- CLASSIFICATION --
9352 update_dbis
9353 (p_element_type_id => p_element_type_id
9354 ,p_leg_code => l_leg_code
9355 ,p_bg_id => l_bg_id
9356 ,p_prefix => l_prefix
9357 ,p_dbi_prefixes => p_dbi_prefixes
9358 ,p_date_p => l_date_p
9359 ,p_startup_mode => l_startup_mode
9360 ,p_languages => p_languages
9361 ,p_user_entity_id => l_ueid
9362 ,p_suffix => 'CLASSIFICATION'
9363 );
9364
9365 -- INPUT_CURRENCY_CODE --
9366 update_dbis
9367 (p_element_type_id => p_element_type_id
9368 ,p_leg_code => l_leg_code
9369 ,p_bg_id => l_bg_id
9370 ,p_prefix => l_prefix
9371 ,p_dbi_prefixes => p_dbi_prefixes
9372 ,p_date_p => l_date_p
9373 ,p_startup_mode => l_startup_mode
9374 ,p_languages => p_languages
9375 ,p_user_entity_id => l_ueid
9376 ,p_suffix => 'INPUT_CURRENCY_CODE'
9377 );
9378
9379 -- OUTPUT_CURRENCY_CODE --
9380 update_dbis
9381 (p_element_type_id => p_element_type_id
9382 ,p_leg_code => l_leg_code
9383 ,p_bg_id => l_bg_id
9384 ,p_prefix => l_prefix
9385 ,p_dbi_prefixes => p_dbi_prefixes
9386 ,p_date_p => l_date_p
9387 ,p_startup_mode => l_startup_mode
9388 ,p_languages => p_languages
9389 ,p_user_entity_id => l_ueid
9390 ,p_suffix => 'OUTPUT_CURRENCY_CODE'
9391 );
9392
9393 -- PROCESSING_PRIORITY --
9394 update_dbis
9395 (p_element_type_id => p_element_type_id
9396 ,p_leg_code => l_leg_code
9397 ,p_bg_id => l_bg_id
9398 ,p_prefix => l_prefix
9399 ,p_dbi_prefixes => p_dbi_prefixes
9400 ,p_date_p => l_date_p
9401 ,p_startup_mode => l_startup_mode
9402 ,p_languages => p_languages
9403 ,p_user_entity_id => l_ueid
9404 ,p_suffix => 'PROCESSING_PRIORITY'
9405 );
9406
9407 -- CLOSED_FOR_ENTRY --
9408 update_dbis
9409 (p_element_type_id => p_element_type_id
9410 ,p_leg_code => l_leg_code
9411 ,p_bg_id => l_bg_id
9412 ,p_prefix => l_prefix
9413 ,p_dbi_prefixes => p_dbi_prefixes
9414 ,p_date_p => l_date_p
9415 ,p_startup_mode => l_startup_mode
9416 ,p_languages => p_languages
9417 ,p_user_entity_id => l_ueid
9418 ,p_suffix => 'CLOSED_FOR_ENTRY'
9419 );
9420
9421 -- CLOSED_FOR_ENTRY_CODE --
9422 update_dbis
9423 (p_element_type_id => p_element_type_id
9424 ,p_leg_code => l_leg_code
9425 ,p_bg_id => l_bg_id
9426 ,p_prefix => l_prefix
9427 ,p_dbi_prefixes => p_dbi_prefixes
9428 ,p_date_p => l_date_p
9429 ,p_startup_mode => l_startup_mode
9430 ,p_languages => p_languages
9431 ,p_user_entity_id => l_ueid
9432 ,p_suffix => 'CLOSED_FOR_ENTRY_CODE'
9433 );
9434
9435 -- END_DATE --
9436 update_dbis
9437 (p_element_type_id => p_element_type_id
9438 ,p_leg_code => l_leg_code
9439 ,p_bg_id => l_bg_id
9440 ,p_prefix => l_prefix
9441 ,p_dbi_prefixes => p_dbi_prefixes
9442 ,p_date_p => l_date_p
9443 ,p_startup_mode => l_startup_mode
9444 ,p_languages => p_languages
9445 ,p_user_entity_id => l_ueid
9446 ,p_suffix => 'END_DATE'
9447 );
9448
9449 --
9450 -- BEN_CLASS
9451 --
9452 -- Database item is only generated when the BENEFIT_CLASSIFICATION_ID
9453 -- is NOT NULL.
9454 --
9455 if l_ben_class_id is not null then
9456 update_dbis
9457 (p_element_type_id => p_element_type_id
9458 ,p_leg_code => l_leg_code
9459 ,p_bg_id => l_bg_id
9460 ,p_prefix => l_prefix
9461 ,p_dbi_prefixes => p_dbi_prefixes
9462 ,p_date_p => l_date_p
9463 ,p_startup_mode => l_startup_mode
9464 ,p_languages => p_languages
9465 ,p_user_entity_id => l_ueid
9466 ,p_suffix => 'BEN_CLASS'
9467 );
9468 end if;
9469
9470 -- ========================================= --
9471 -- Process the dbis for the _E2 user entity. --
9472 -- ========================================= --
9473
9474 --
9475 -- This must be done for the first dbi in each user entity.
9476 --
9477 l_ueid := null;
9478
9479 -- LENGTH_OF_SERVICE --
9480 update_dbis
9481 (p_element_type_id => p_element_type_id
9482 ,p_leg_code => l_leg_code
9483 ,p_bg_id => l_bg_id
9484 ,p_prefix => l_prefix
9485 ,p_dbi_prefixes => p_dbi_prefixes
9486 ,p_date_p => l_date_p
9487 ,p_startup_mode => l_startup_mode
9488 ,p_languages => p_languages
9489 ,p_user_entity_id => l_ueid
9490 ,p_suffix => 'LENGTH_OF_SERVICE'
9491 );
9492
9493 -- QUALIFYING_UNITS --
9494 update_dbis
9495 (p_element_type_id => p_element_type_id
9496 ,p_leg_code => l_leg_code
9497 ,p_bg_id => l_bg_id
9498 ,p_prefix => l_prefix
9499 ,p_dbi_prefixes => p_dbi_prefixes
9500 ,p_date_p => l_date_p
9501 ,p_startup_mode => l_startup_mode
9502 ,p_languages => p_languages
9503 ,p_user_entity_id => l_ueid
9504 ,p_suffix => 'QUALIFYING_UNITS'
9505 );
9506
9507 -- QUALIFYING_UNITS_CODE --
9508 update_dbis
9509 (p_element_type_id => p_element_type_id
9510 ,p_leg_code => l_leg_code
9511 ,p_bg_id => l_bg_id
9512 ,p_prefix => l_prefix
9513 ,p_dbi_prefixes => p_dbi_prefixes
9514 ,p_date_p => l_date_p
9515 ,p_startup_mode => l_startup_mode
9516 ,p_languages => p_languages
9517 ,p_user_entity_id => l_ueid
9518 ,p_suffix => 'QUALIFYING_UNITS_CODE'
9519 );
9520
9521 -- QUALIFYING_AGE --
9522 update_dbis
9523 (p_element_type_id => p_element_type_id
9524 ,p_leg_code => l_leg_code
9525 ,p_bg_id => l_bg_id
9526 ,p_prefix => l_prefix
9527 ,p_dbi_prefixes => p_dbi_prefixes
9528 ,p_date_p => l_date_p
9529 ,p_startup_mode => l_startup_mode
9530 ,p_languages => p_languages
9531 ,p_user_entity_id => l_ueid
9532 ,p_suffix => 'QUALIFYING_AGE'
9533 );
9534
9535 -- STANDARD_LINK --
9536 update_dbis
9537 (p_element_type_id => p_element_type_id
9538 ,p_leg_code => l_leg_code
9539 ,p_bg_id => l_bg_id
9540 ,p_prefix => l_prefix
9541 ,p_dbi_prefixes => p_dbi_prefixes
9542 ,p_date_p => l_date_p
9543 ,p_startup_mode => l_startup_mode
9544 ,p_languages => p_languages
9545 ,p_user_entity_id => l_ueid
9546 ,p_suffix => 'STANDARD_LINK'
9547 );
9548
9549 -- STANDARD_LINK_CODE --
9550 update_dbis
9551 (p_element_type_id => p_element_type_id
9552 ,p_leg_code => l_leg_code
9553 ,p_bg_id => l_bg_id
9554 ,p_prefix => l_prefix
9555 ,p_dbi_prefixes => p_dbi_prefixes
9556 ,p_date_p => l_date_p
9557 ,p_startup_mode => l_startup_mode
9558 ,p_languages => p_languages
9559 ,p_user_entity_id => l_ueid
9560 ,p_suffix => 'STANDARD_LINK_CODE'
9561 );
9562
9563 -- COSTABLE_TYPE --
9564 update_dbis
9565 (p_element_type_id => p_element_type_id
9566 ,p_leg_code => l_leg_code
9567 ,p_bg_id => l_bg_id
9568 ,p_prefix => l_prefix
9569 ,p_dbi_prefixes => p_dbi_prefixes
9570 ,p_date_p => l_date_p
9571 ,p_startup_mode => l_startup_mode
9572 ,p_languages => p_languages
9573 ,p_user_entity_id => l_ueid
9574 ,p_suffix => 'COSTABLE_TYPE'
9575 );
9576
9577 -- COSTABLE_TYPE_CODE --
9578 update_dbis
9579 (p_element_type_id => p_element_type_id
9580 ,p_leg_code => l_leg_code
9581 ,p_bg_id => l_bg_id
9582 ,p_prefix => l_prefix
9583 ,p_dbi_prefixes => p_dbi_prefixes
9584 ,p_date_p => l_date_p
9585 ,p_startup_mode => l_startup_mode
9586 ,p_languages => p_languages
9587 ,p_user_entity_id => l_ueid
9588 ,p_suffix => 'COSTABLE_TYPE_CODE'
9589 );
9590
9591 -- ========================================= --
9592 -- Process the dbis for the _E3 user entity. --
9593 -- ========================================= --
9594
9595 --
9596 -- This must be done for the first dbi in each user entity.
9597 --
9598 l_ueid := null;
9599
9600 -- COUNT --
9601 update_dbis
9602 (p_element_type_id => p_element_type_id
9603 ,p_leg_code => l_leg_code
9604 ,p_bg_id => l_bg_id
9605 ,p_prefix => l_prefix
9606 ,p_dbi_prefixes => p_dbi_prefixes
9607 ,p_date_p => l_date_p
9608 ,p_startup_mode => l_startup_mode
9609 ,p_languages => p_languages
9610 ,p_user_entity_id => l_ueid
9611 ,p_suffix => 'COUNT'
9612 );
9613 end loop;
9614
9615 end update_element_type;
9616
9617 --
9618 -- Interface 2: references PAY_ELEMENT_TYPES_F_TL.
9619 --
9620 procedure update_element_type
9621 (p_element_type_id in number
9622 ,p_effective_date in date
9623 ,p_languages in dbms_sql.varchar2s
9624 ) is
9625 l_prefixes t_dbi_prefixes;
9626 begin
9627 -- ========================== --
9628 -- Generate the _TL prefixes. --
9629 -- ========================== --
9630 gen_et_dbi_prefixes
9631 (p_element_type_id => p_element_type_id
9632 ,p_languages => p_languages
9633 ,p_prefixes => l_prefixes
9634 );
9635
9636 -- ========================================== --
9637 -- Call the overloaded version with prefixes. --
9638 -- ========================================== --
9639 update_element_type
9640 (p_element_type_id => p_element_type_id
9641 ,p_effective_date => p_effective_date
9642 ,p_languages => p_languages
9643 ,p_dbi_prefixes => l_prefixes
9644 );
9645 end update_element_type;
9646
9647 -- ====================================== --
9648 -- Update all the dbis for an input value --
9649 -- ====================================== --
9650
9651 --
9652 -- Interface 1: does not reference PAY_INPUT_VALUES_F_TL - the core
9653 -- interface.
9654 --
9655 procedure update_input_value
9656 (p_input_value_id in number
9657 ,p_effective_date in date
9658 ,p_languages in dbms_sql.varchar2s
9659 ,p_dbi_prefixes in t_dbi_prefixes
9660 ) is
9661 --
9662 -- Cursor to get input value information.
9663 --
9664 cursor csr_input_value_info
9665 (p_input_value_id in number
9666 ,p_effective_date in date
9667 ) is
9668 select et.multiple_entries_allowed_flag
9669 , iv.legislation_code
9670 , iv.business_group_id
9671 , iv.uom
9672 , iv.generate_db_items_flag
9673 from pay_input_values_f iv
9674 , pay_element_types_f et
9675 where iv.input_value_id = p_input_value_id
9676 and p_effective_date between
9677 iv.effective_start_date and iv.effective_end_date
9678 and et.element_type_id = iv.element_type_id
9679 and p_effective_date between
9680 et.effective_start_date and et.effective_end_date
9681 ;
9682 --
9683 l_multi_entries pay_element_types_f.multiple_entries_allowed_flag%type;
9684 l_uom pay_input_values_f.uom%type;
9685 l_generate_dbis pay_input_values_f.generate_db_items_flag%type;
9686 l_do_date_p boolean;
9687 l_do_non_date_p boolean;
9688 l_date_p varchar2(16);
9689 l_leg_code varchar2(30);
9690 l_bg_id number;
9691 l_ueid number;
9692 l_prefix varchar2(240);
9693 l_found boolean;
9694 l_startup_mode varchar2(30);
9695 --
9696 procedure update_dbis
9697 (p_input_value_id in number
9698 ,p_leg_code in out nocopy varchar2
9699 ,p_bg_id in out nocopy number
9700 ,p_prefix in out nocopy varchar2
9701 ,p_dbi_prefixes in t_dbi_prefixes
9702 ,p_date_p in varchar2
9703 ,p_startup_mode in varchar2
9704 ,p_languages in dbms_sql.varchar2s
9705 ,p_user_entity_id in out nocopy number
9706 ,p_suffix in varchar2
9707 ) is
9708 l_base_name ff_database_items.user_name%type;
9709 begin
9710 gen_eiv_base_dbi_name
9711 (p_input_value_id => p_input_value_id
9712 ,p_leg_code => p_leg_code
9713 ,p_bg_id => p_bg_id
9714 ,p_prefix => p_prefix
9715 ,p_suffix => p_suffix
9716 ,p_date_p => p_date_p
9717 ,p_base_name => l_base_name
9718 );
9719
9720 if p_user_entity_id is null then
9721 p_user_entity_id :=
9722 dbi2ueid
9723 (p_creator_id => p_input_value_id
9724 ,p_creator_type => 'I'
9725 ,p_user_name => l_base_name
9726 );
9727 end if;
9728
9729 update_et_tl_dbi_names
9730 (p_leg_code => p_leg_code
9731 ,p_bg_id => p_bg_id
9732 ,p_startup_mode => p_startup_mode
9733 ,p_user_name => l_base_name
9734 ,p_user_entity_id => p_user_entity_id
9735 ,p_prefixes => p_dbi_prefixes
9736 ,p_suffix => p_suffix
9737 ,p_date_p => p_date_p
9738 );
9739
9740 end update_dbis;
9741
9742 begin
9743
9744 -- ============================== --
9745 -- Fetch input value information. --
9746 -- ============================== --
9747 open csr_input_value_info
9748 (p_input_value_id => p_input_value_id
9749 ,p_effective_date => p_effective_date
9750 );
9751 fetch csr_input_value_info
9752 into l_multi_entries
9753 , l_leg_code
9754 , l_bg_id
9755 , l_uom
9756 , l_generate_dbis
9757 ;
9758 l_found := csr_input_value_info%found;
9759 close csr_input_value_info;
9760
9761 assert(l_found, 'update_input_value:1', p_input_value_id);
9762
9763 if l_generate_dbis <> 'Y' then
9764 --
9765 -- No need to do anything.
9766 --
9767 return;
9768 end if;
9769
9770 --
9771 -- Get the startup mode. This only needs to be done at this
9772 -- stage as l_bg_id and l_leg_code should not change.
9773 --
9774 if g_triggers_altered then
9775 l_startup_mode := ffstup.get_mode(l_bg_id, l_leg_code);
9776 end if;
9777
9778 -- Force fetch of element type information.
9779 l_prefix := null;
9780
9781 -- ==================================================== --
9782 -- Are there DATE_PAID / non-DATE_PAID database items ? --
9783 -- ==================================================== --
9784 l_do_date_p :=
9785 has_date_paid_dbis
9786 (p_creator_type => 'I'
9787 ,p_creator_id => p_input_value_id
9788 );
9789
9790 l_do_non_date_p :=
9791 has_non_date_paid_dbis
9792 (p_creator_type => 'I'
9793 ,p_creator_id => p_input_value_id
9794 );
9795
9796 -- ============================== --
9797 -- Database item processing code. --
9798 -- ============================== --
9799 loop
9800
9801 --
9802 -- Loop control based upon processing DATE PAID and non-DATE PAID
9803 -- database items.
9804 --
9805 if l_do_non_date_p then
9806 l_date_p := null;
9807 l_do_non_date_p := false;
9808 elsif l_do_date_p then
9809 l_date_p := '_DP';
9810 l_do_date_p := false;
9811 else
9812 exit;
9813 end if;
9814
9815 -- ========================================= --
9816 -- Process the dbis for the _I1 user entity. --
9817 -- ========================================= --
9818
9819 --
9820 -- This must be done for the first dbi in each user entity.
9821 --
9822 l_ueid := null;
9823
9824 -- UNIT_OF_MEASURE --
9825 update_dbis
9826 (p_input_value_id => p_input_value_id
9827 ,p_leg_code => l_leg_code
9828 ,p_bg_id => l_bg_id
9829 ,p_prefix => l_prefix
9830 ,p_dbi_prefixes => p_dbi_prefixes
9831 ,p_date_p => l_date_p
9832 ,p_startup_mode => l_startup_mode
9833 ,p_languages => p_languages
9834 ,p_user_entity_id => l_ueid
9835 ,p_suffix => 'UNIT_OF_MEASURE'
9836 );
9837
9838 -- UNIT_OF_MEASURE_CODE --
9839 update_dbis
9840 (p_input_value_id => p_input_value_id
9841 ,p_leg_code => l_leg_code
9842 ,p_bg_id => l_bg_id
9843 ,p_prefix => l_prefix
9844 ,p_dbi_prefixes => p_dbi_prefixes
9845 ,p_date_p => l_date_p
9846 ,p_startup_mode => l_startup_mode
9847 ,p_languages => p_languages
9848 ,p_user_entity_id => l_ueid
9849 ,p_suffix => 'UNIT_OF_MEASURE_CODE'
9850 );
9851
9852 -- ========================================= --
9853 -- Process the dbis for the _I2 user entity. --
9854 -- ========================================= --
9855
9856 --
9857 -- This must be done for the first dbi in each user entity.
9858 --
9859 l_ueid := null;
9860
9861 -- DEFAULT --
9862 update_dbis
9863 (p_input_value_id => p_input_value_id
9864 ,p_leg_code => l_leg_code
9865 ,p_bg_id => l_bg_id
9866 ,p_prefix => l_prefix
9867 ,p_dbi_prefixes => p_dbi_prefixes
9868 ,p_date_p => l_date_p
9869 ,p_startup_mode => l_startup_mode
9870 ,p_languages => p_languages
9871 ,p_user_entity_id => l_ueid
9872 ,p_suffix => 'DEFAULT'
9873 );
9874
9875 -- MIN --
9876 update_dbis
9877 (p_input_value_id => p_input_value_id
9878 ,p_leg_code => l_leg_code
9879 ,p_bg_id => l_bg_id
9880 ,p_prefix => l_prefix
9881 ,p_dbi_prefixes => p_dbi_prefixes
9882 ,p_date_p => l_date_p
9883 ,p_startup_mode => l_startup_mode
9884 ,p_languages => p_languages
9885 ,p_user_entity_id => l_ueid
9886 ,p_suffix => 'MIN'
9887 );
9888
9889 -- MAX --
9890 update_dbis
9891 (p_input_value_id => p_input_value_id
9892 ,p_leg_code => l_leg_code
9893 ,p_bg_id => l_bg_id
9894 ,p_prefix => l_prefix
9895 ,p_dbi_prefixes => p_dbi_prefixes
9896 ,p_date_p => l_date_p
9897 ,p_startup_mode => l_startup_mode
9898 ,p_languages => p_languages
9899 ,p_user_entity_id => l_ueid
9900 ,p_suffix => 'MAX'
9901 );
9902
9903 -- ================================= --
9904 -- Multiple Entries are not allowed. --
9905 -- ================================= --
9906 if l_multi_entries = 'N' then
9907 -- ========================================= --
9908 -- Process the dbis for the _I3 user entity. --
9909 -- ========================================= --
9910
9911 --
9912 -- This must be done for the first dbi in each user entity.
9913 --
9914 l_ueid := null;
9915
9916 -- ENTRY_VALUE --
9917 update_dbis
9918 (p_input_value_id => p_input_value_id
9919 ,p_leg_code => l_leg_code
9920 ,p_bg_id => l_bg_id
9921 ,p_prefix => l_prefix
9922 ,p_dbi_prefixes => p_dbi_prefixes
9923 ,p_date_p => l_date_p
9924 ,p_startup_mode => l_startup_mode
9925 ,p_languages => p_languages
9926 ,p_user_entity_id => l_ueid
9927 ,p_suffix => 'ENTRY_VALUE'
9928 );
9929
9930 -- USER_ENTERED_CODE --
9931 update_dbis
9932 (p_input_value_id => p_input_value_id
9933 ,p_leg_code => l_leg_code
9934 ,p_bg_id => l_bg_id
9935 ,p_prefix => l_prefix
9936 ,p_dbi_prefixes => p_dbi_prefixes
9937 ,p_date_p => l_date_p
9938 ,p_startup_mode => l_startup_mode
9939 ,p_languages => p_languages
9940 ,p_user_entity_id => l_ueid
9941 ,p_suffix => 'USER_ENTERED_CODE'
9942 );
9943
9944 -- START_DATE --
9945 update_dbis
9946 (p_input_value_id => p_input_value_id
9947 ,p_leg_code => l_leg_code
9948 ,p_bg_id => l_bg_id
9949 ,p_prefix => l_prefix
9950 ,p_dbi_prefixes => p_dbi_prefixes
9951 ,p_date_p => l_date_p
9952 ,p_startup_mode => l_startup_mode
9953 ,p_languages => p_languages
9954 ,p_user_entity_id => l_ueid
9955 ,p_suffix => 'START_DATE'
9956 );
9957
9958 -- END_DATE --
9959 update_dbis
9960 (p_input_value_id => p_input_value_id
9961 ,p_leg_code => l_leg_code
9962 ,p_bg_id => l_bg_id
9963 ,p_prefix => l_prefix
9964 ,p_dbi_prefixes => p_dbi_prefixes
9965 ,p_date_p => l_date_p
9966 ,p_startup_mode => l_startup_mode
9967 ,p_languages => p_languages
9968 ,p_user_entity_id => l_ueid
9969 ,p_suffix => 'END_DATE'
9970 );
9971
9972 -- ========================================= --
9973 -- Process the dbis for the _I4 user entity. --
9974 -- ========================================= --
9975
9976 --
9977 -- This must be done for the first dbi in each user entity.
9978 --
9979 l_ueid := null;
9980
9981 -- OVERRIDE_ENTRY_VALUE --
9982 update_dbis
9983 (p_input_value_id => p_input_value_id
9984 ,p_leg_code => l_leg_code
9985 ,p_bg_id => l_bg_id
9986 ,p_prefix => l_prefix
9987 ,p_dbi_prefixes => p_dbi_prefixes
9988 ,p_date_p => l_date_p
9989 ,p_startup_mode => l_startup_mode
9990 ,p_languages => p_languages
9991 ,p_user_entity_id => l_ueid
9992 ,p_suffix => 'OVERRIDE_ENTRY_VALUE'
9993 );
9994
9995 -- OVERRIDE_USER_ENTERED_CODE --
9996 update_dbis
9997 (p_input_value_id => p_input_value_id
9998 ,p_leg_code => l_leg_code
9999 ,p_bg_id => l_bg_id
10000 ,p_prefix => l_prefix
10001 ,p_dbi_prefixes => p_dbi_prefixes
10002 ,p_date_p => l_date_p
10003 ,p_startup_mode => l_startup_mode
10004 ,p_languages => p_languages
10005 ,p_user_entity_id => l_ueid
10006 ,p_suffix => 'OVERRIDE_USER_ENTERED_CODE'
10007 );
10008
10009 -- OVERRIDE_START_DATE --
10010 update_dbis
10011 (p_input_value_id => p_input_value_id
10012 ,p_leg_code => l_leg_code
10013 ,p_bg_id => l_bg_id
10014 ,p_prefix => l_prefix
10015 ,p_dbi_prefixes => p_dbi_prefixes
10016 ,p_date_p => l_date_p
10017 ,p_startup_mode => l_startup_mode
10018 ,p_languages => p_languages
10019 ,p_user_entity_id => l_ueid
10020 ,p_suffix => 'OVERRIDE_START_DATE'
10021 );
10022
10023 -- OVERRIDE_END_DATE --
10024 update_dbis
10025 (p_input_value_id => p_input_value_id
10026 ,p_leg_code => l_leg_code
10027 ,p_bg_id => l_bg_id
10028 ,p_prefix => l_prefix
10029 ,p_dbi_prefixes => p_dbi_prefixes
10030 ,p_date_p => l_date_p
10031 ,p_startup_mode => l_startup_mode
10032 ,p_languages => p_languages
10033 ,p_user_entity_id => l_ueid
10034 ,p_suffix => 'OVERRIDE_END_DATE'
10035 );
10036
10037 -- ============================= --
10038 -- Multiple Entries are allowed. --
10039 -- ============================= --
10040 else
10041 if uom_requires_dbis(p_uom => l_uom) then
10042 -- ========================================= --
10043 -- Process the dbis for the _I3 user entity. --
10044 -- ========================================= --
10045
10046 --
10047 -- This must be done for the first dbi in each user entity.
10048 --
10049 l_ueid := null;
10050
10051 -- ENTRY_VALUE --
10052 update_dbis
10053 (p_input_value_id => p_input_value_id
10054 ,p_leg_code => l_leg_code
10055 ,p_bg_id => l_bg_id
10056 ,p_prefix => l_prefix
10057 ,p_dbi_prefixes => p_dbi_prefixes
10058 ,p_date_p => l_date_p
10059 ,p_startup_mode => l_startup_mode
10060 ,p_languages => p_languages
10061 ,p_user_entity_id => l_ueid
10062 ,p_suffix => 'ENTRY_VALUE'
10063 );
10064
10065 -- ========================================= --
10066 -- Process the dbis for the _I4 user entity. --
10067 -- ========================================= --
10068
10069 --
10070 -- This must be done for the first dbi in each user entity.
10071 --
10072 l_ueid := null;
10073
10074 -- OVERRIDE_ENTRY_VALUE --
10075 update_dbis
10076 (p_input_value_id => p_input_value_id
10077 ,p_leg_code => l_leg_code
10078 ,p_bg_id => l_bg_id
10079 ,p_prefix => l_prefix
10080 ,p_dbi_prefixes => p_dbi_prefixes
10081 ,p_date_p => l_date_p
10082 ,p_startup_mode => l_startup_mode
10083 ,p_languages => p_languages
10084 ,p_user_entity_id => l_ueid
10085 ,p_suffix => 'OVERRIDE_ENTRY_VALUE'
10086 );
10087
10088 end if;
10089 end if;
10090 end loop;
10091
10092 end update_input_value;
10093
10094 --
10095 -- Interface 2: references PAY_INPUT_VALUES_F_TL.
10096 --
10097 procedure update_input_value
10098 (p_input_value_id in number
10099 ,p_effective_date in date
10100 ,p_languages in dbms_sql.varchar2s
10101 ) is
10102 l_prefixes t_dbi_prefixes;
10103 begin
10104 -- ========================== --
10105 -- Generate the _TL prefixes. --
10106 -- ========================== --
10107 gen_eiv_dbi_prefixes
10108 (p_input_value_id => p_input_value_id
10109 ,p_effective_date => p_effective_date
10110 ,p_languages => p_languages
10111 ,p_prefixes => l_prefixes
10112 );
10113
10114 -- ========================================== --
10115 -- Call the overloaded version with prefixes. --
10116 -- ========================================== --
10117 update_input_value
10118 (p_input_value_id => p_input_value_id
10119 ,p_effective_date => p_effective_date
10120 ,p_languages => p_languages
10121 ,p_dbi_prefixes => l_prefixes
10122 );
10123 end update_input_value;
10124
10125 --
10126 -- Is it necessary to generate database items for the UOM if multiple
10127 -- entries are allowed ?
10128 --
10129 -- Code extracted as it is used in more than one place.
10130 --
10131 function uom_requires_dbis
10132 (p_uom in varchar2
10133 ) return boolean is
10134 begin
10135 return p_uom like 'H_%' -- Hours
10136 or p_uom = 'I' -- Integer
10137 or p_uom = 'M' -- Money
10138 or p_uom = 'N' -- Number
10139 ;
10140 end uom_requires_dbis;
10141
10142 --
10143 -- Run legislation-specific translation procedure.
10144 --
10145 -- P_ERRORS collects errors in this procedure.
10146 --
10147 procedure process_leg_translations
10148 (p_errors in out nocopy dbms_sql.varchar2_table
10149 ) is
10150 l_dummy varchar2(1);
10151 l_package_name varchar2(1000);
10152 l_debug boolean := hr_utility.debug_enabled;
10153 --
10154 -- Cursor to fetch information on legislations that support translations.
10155 --
10156 cursor csr_fetch_legs is
10157 select plr.legislation_code
10158 from pay_legislation_rules plr
10159 where rule_type = 'FF_TRANSLATE_DATABASE_ITEMS'
10160 and rule_mode = 'Y'
10161 ;
10162 --
10163 -- Cursor to check validity of a package.
10164 --
10165 cursor csr_package_exists(p_package_name in varchar2) is
10166 select null
10167 from user_objects uo
10168 where uo.object_name = p_package_name
10169 and uo.object_type = 'PACKAGE BODY'
10170 and uo.status ='VALID'
10171 ;
10172 begin
10173 if l_debug then
10174 hr_utility.set_location('PROCESS_LEG_TRANSLATIONS', 5);
10175 end if;
10176
10177 --
10178 -- Loop through the available legislations.
10179 --
10180 for crec in csr_fetch_legs loop
10181
10182 if l_debug then
10183 hr_utility.set_location('PROCESS_LEG_TRANSLATIONS:' || crec.legislation_code, 15);
10184 end if;
10185 --
10186 -- Build the package name, PAY_<LEG_CODE>_DBI_PKG, and only execute <PKG>.TRANSLATE
10187 -- if it exists.
10188 --
10189 begin
10190 l_package_name := upper('PAY_' || crec.legislation_code || '_DBI_PKG');
10191 open csr_package_exists(p_package_name => l_package_name);
10192 fetch csr_package_exists
10193 into l_dummy
10194 ;
10195 if csr_package_exists%found then
10196 if l_debug then
10197 hr_utility.set_location('PROCESS_LEG_TRANSLATIONS:' || l_package_name || '.TRANSLATE', 25);
10198 end if;
10199
10200 execute immediate
10201 'begin '|| l_package_name || '.TRANSLATE; end;';
10202 end if;
10203
10204 close csr_package_exists;
10205 exception
10206 when others then
10207 if csr_package_exists%isopen then
10208 close csr_package_exists;
10209 end if;
10210
10211 if l_debug then
10212 hr_utility.set_location('PROCESS_LEG_TRANSLATIONS:' || sqlerrm, 30);
10213 end if;
10214
10215 p_errors(p_errors.count + 1) := sqlerrm;
10216 end;
10217
10218 end loop;
10219
10220 if l_debug then
10221 hr_utility.set_location('PROCESS_LEG_TRANSLATIONS', 35);
10222 end if;
10223
10224 exception
10225 when others then
10226
10227 if l_debug then
10228 hr_utility.set_location('PROCESS_LEG_TRANSLATIONS', 45);
10229 end if;
10230
10231 p_errors(p_errors.count + 1) := sqlerrm;
10232 end process_leg_translations;
10233
10234 -- ================================ --
10235 -- Process PAY_DYNDBI_CHANGES rows. --
10236 -- ================================ --
10237
10238 --
10239 -- Procedure to fetch changes for a particular entity type.
10240 --
10241 procedure fetch_dyndbi_changes
10242 (p_type in varchar2
10243 ,p_ids out nocopy dbms_sql.number_table
10244 ,p_languages out nocopy dbms_sql.varchar2s
10245 ) is
10246 cursor csr_dyndbi_changes
10247 (p_type in varchar2
10248 ) is
10249 select pdc.id
10250 , pdc.language
10251 from pay_dyndbi_changes pdc
10252 where pdc.type = p_type
10253 order by 1, 2
10254 ;
10255 begin
10256 open csr_dyndbi_changes(p_type => p_type);
10257 fetch csr_dyndbi_changes bulk collect
10258 into p_ids
10259 , p_languages
10260 ;
10261 close csr_dyndbi_changes;
10262 end fetch_dyndbi_changes;
10263
10264 --
10265 -- From the lists returned from FETCH_DYNDBI_CHANGES, return the
10266 -- _id to process, the list of languages, and the next index
10267 -- to start from.
10268 --
10269 procedure next_dyndbi_change
10270 (p_ids in dbms_sql.number_table
10271 ,p_languages in dbms_sql.varchar2s
10272 ,p_start in out nocopy binary_integer
10273 ,p_id out nocopy number
10274 ,p_id_langs out nocopy dbms_sql.varchar2s
10275 ) is
10276 i binary_integer;
10277 j binary_integer;
10278 l_id number;
10279 begin
10280 --
10281 -- Perform initialisations.
10282 --
10283 l_id := p_ids(p_start);
10284 p_id := l_id;
10285
10286 i := p_start;
10287 j := 1;
10288
10289 while p_ids.exists(i) and p_ids(i) = l_id loop
10290 p_id_langs(j) := p_languages(i);
10291 j := j + 1;
10292 i := i + 1;
10293 end loop;
10294
10295 --
10296 -- Set the next start point.
10297 --
10298 p_start := i;
10299 end next_dyndbi_change;
10300
10301 procedure process_pay_dyndbi_changes
10302 (errbuf out nocopy varchar2
10303 ,retcode out nocopy number
10304 ,p_element_types in varchar2
10305 ,p_input_values in varchar2
10306 ,p_defined_balances in varchar2
10307 ,p_localization in varchar2
10308 ) is
10309 l_proc varchar2(2000) := 'PROCESS_PAY_DYNDBI_CHANGES:';
10310 l_ids dbms_sql.number_table;
10311 l_languages dbms_sql.varchar2s;
10312 l_id number;
10313 l_id_langs dbms_sql.varchar2s;
10314 i binary_integer;
10315 l_eff_date date;
10316 l_found boolean;
10317 l_cnt binary_integer;
10318 l_dummy varchar2(1);
10319 l_rowids dbms_sql.varchar2s;
10320 l_messages dbms_sql.varchar2_table;
10321 l_errors dbms_sql.varchar2_table;
10322 l_debug boolean := hr_utility.debug_enabled;
10323 l_newline varchar2(10) := '
10324 ';
10325 l_separator varchar2(100);
10326 --
10327 cursor csr_ele_eff_date
10328 (p_element_type_id in number
10329 ) is
10330 select et.effective_end_date
10331 from pay_element_types_f et
10332 where et.element_type_id = p_element_type_id
10333 order by 1 desc
10334 ;
10335 --
10336 cursor csr_ipv_eff_date
10337 (p_input_value_id in number
10338 ) is
10339 select iv.effective_end_date
10340 from pay_input_values_f iv
10341 where iv.input_value_id = p_input_value_id
10342 order by 1 desc
10343 ;
10344 --
10345 cursor csr_def_balance
10346 (p_defined_balance_id in number
10347 ) is
10348 select to_char(null)
10349 from pay_defined_balances db
10350 where db.defined_balance_id = p_defined_balance_id
10351 ;
10352 --
10353 procedure init_cnt(p_cnt in out nocopy binary_integer) is
10354 begin
10355 p_cnt := 1;
10356 end init_cnt;
10357 --
10358 procedure incr_cnt(p_cnt in out nocopy binary_integer) is
10359 begin
10360 if mod(p_cnt, 50) = 0 then
10361 commit;
10362 init_cnt(p_cnt => p_cnt);
10363 else
10364 p_cnt := p_cnt + 1;
10365 end if;
10366 end incr_cnt;
10367
10368 begin
10369 -- Assume success.
10370 retcode := 0;
10371 errbuf := null;
10372
10373 g_dyndbi_changes := true;
10374 g_security_group_id :=
10375 fnd_global.lookup_security_group('NAME_TRANSLATIONS', 3);
10376
10377 if l_debug then
10378 hr_utility.set_location('process_pay_dyndbi_changes', 0);
10379 end if;
10380
10381 --
10382 -- Set log file message separator.
10383 --
10384 l_separator := l_newline || '--------------------------------' || l_newline;
10385
10386 -- ============== --
10387 -- Element Types. --
10388 -- ============== --
10389 if upper(p_element_types) = 'Y' then
10390
10391 if l_debug then
10392 hr_utility.set_location('process_pay_dyndbi_changes', 10);
10393 end if;
10394
10395 --
10396 -- Initialise everything.
10397 --
10398 l_ids.delete;
10399 l_languages.delete;
10400 i := 1;
10401
10402 --
10403 -- Fetch the PAY_DYNDBI_CHANGES rows.
10404 --
10405 fetch_dyndbi_changes
10406 (p_type => pay_dyndbi_changes_pkg.c_element_type
10407 ,p_ids => l_ids
10408 ,p_languages => l_languages
10409 );
10410
10411 if l_debug then
10412 hr_utility.set_location('process_pay_dyndbi_changes', 20);
10413 end if;
10414
10415 --
10416 -- Do the updates.
10417 --
10418 init_cnt(p_cnt => l_cnt);
10419
10420 while l_ids.exists(i) loop
10421
10422 if l_debug then
10423 hr_utility.set_location('process_pay_dyndbi_changes', 30);
10424 end if;
10425
10426 l_id_langs.delete;
10427 next_dyndbi_change
10428 (p_ids => l_ids
10429 ,p_languages => l_languages
10430 ,p_start => i
10431 ,p_id => l_id
10432 ,p_id_langs => l_id_langs
10433 );
10434
10435 --
10436 -- Fetch the effective date.
10437 --
10438 open csr_ele_eff_date(p_element_type_id => l_id);
10439 fetch csr_ele_eff_date
10440 into l_eff_date
10441 ;
10442 l_found := csr_ele_eff_date%found;
10443 close csr_ele_eff_date;
10444
10445 if l_debug then
10446 hr_utility.set_location('process_pay_dyndbi_changes', 40);
10447 end if;
10448
10449 g_dyndbi_changes_ok := true;
10450 if l_found then
10451
10452 if l_debug then
10453 hr_utility.set_location('process_pay_dyndbi_changes', 50);
10454 end if;
10455
10456 begin
10457 update_element_type
10458 (p_element_type_id => l_id
10459 ,p_effective_date => l_eff_date
10460 ,p_languages => l_id_langs
10461 );
10462 exception
10463 when others then
10464 g_dyndbi_changes_ok := false;
10465 fnd_file.put(fnd_file.log, l_separator);
10466 fnd_file.put(fnd_file.log, sqlerrm);
10467 errbuf := sqlerrm;
10468 retcode := 2;
10469 end;
10470
10471 if l_debug then
10472 hr_utility.set_location('process_pay_dyndbi_changes', 60);
10473 end if;
10474 else
10475 hr_utility.trace(l_proc||'no such element '||l_id);
10476 end if;
10477
10478 if l_debug then
10479 hr_utility.set_location('process_pay_dyndbi_changes', 70);
10480 end if;
10481
10482 --
10483 -- Delete the PAY_DYNDBI_CHANGES rows.
10484 --
10485 if g_dyndbi_changes_ok then
10486 pay_dyndbi_changes_pkg.delete_rows
10487 (p_id => l_id
10488 ,p_type => pay_dyndbi_changes_pkg.c_element_type
10489 );
10490 end if;
10491
10492 if l_debug then
10493 hr_utility.set_location('process_pay_dyndbi_changes', 80);
10494 end if;
10495
10496 incr_cnt(p_cnt => l_cnt);
10497 end loop;
10498
10499 --
10500 -- COMMIT the last lot of changes.
10501 --
10502 commit;
10503 end if;
10504
10505 if l_debug then
10506 hr_utility.set_location('process_pay_dyndbi_changes', 90);
10507 end if;
10508
10509 -- ============= --
10510 -- Input Values. --
10511 -- ============= --
10512 if upper(p_input_values) = 'Y' then
10513
10514 if l_debug then
10515 hr_utility.set_location('process_pay_dyndbi_changes', 100);
10516 end if;
10517
10518 --
10519 -- Initialise everything.
10520 --
10521 l_ids.delete;
10522 l_languages.delete;
10523 i := 1;
10524
10525 --
10526 -- Fetch the PAY_DYNDBI_CHANGES rows.
10527 --
10528 fetch_dyndbi_changes
10529 (p_type => pay_dyndbi_changes_pkg.c_input_value
10530 ,p_ids => l_ids
10531 ,p_languages => l_languages
10532 );
10533
10534 if l_debug then
10535 hr_utility.set_location('process_pay_dyndbi_changes', 110);
10536 end if;
10537
10538 --
10539 -- Do the updates.
10540 --
10541 init_cnt(p_cnt => l_cnt);
10542
10543 while l_ids.exists(i) loop
10544
10545 if l_debug then
10546 hr_utility.set_location('process_pay_dyndbi_changes', 120);
10547 end if;
10548
10549 l_id_langs.delete;
10550 next_dyndbi_change
10551 (p_ids => l_ids
10552 ,p_languages => l_languages
10553 ,p_start => i
10554 ,p_id => l_id
10555 ,p_id_langs => l_id_langs
10556 );
10557
10558 --
10559 -- Fetch the effective date.
10560 --
10561 open csr_ipv_eff_date(p_input_value_id => l_id);
10562 fetch csr_ipv_eff_date
10563 into l_eff_date
10564 ;
10565 l_found := csr_ipv_eff_date%found;
10566 close csr_ipv_eff_date;
10567
10568 if l_debug then
10569 hr_utility.set_location('process_pay_dyndbi_changes', 130);
10570 end if;
10571
10572 g_dyndbi_changes_ok := true;
10573 if l_found then
10574 begin
10575 update_input_value
10576 (p_input_value_id => l_id
10577 ,p_effective_date => l_eff_date
10578 ,p_languages => l_id_langs
10579 );
10580 exception
10581 when others then
10582 g_dyndbi_changes_ok := false;
10583 fnd_file.put(fnd_file.log, l_separator);
10584 fnd_file.put(fnd_file.log, sqlerrm);
10585 errbuf := sqlerrm;
10586 retcode := 2;
10587 end;
10588 else
10589 hr_utility.trace(l_proc||'no such input value '||l_id);
10590 end if;
10591
10592 if l_debug then
10593 hr_utility.set_location('process_pay_dyndbi_changes', 140);
10594 end if;
10595
10596 --
10597 -- Delete the PAY_DYNDBI_CHANGES rows.
10598 --
10599 if g_dyndbi_changes_ok then
10600 pay_dyndbi_changes_pkg.delete_rows
10601 (p_id => l_id
10602 ,p_type => pay_dyndbi_changes_pkg.c_input_value
10603 );
10604 end if;
10605
10606 if l_debug then
10607 hr_utility.set_location('process_pay_dyndbi_changes', 150);
10608 end if;
10609
10610 incr_cnt(p_cnt => l_cnt);
10611 end loop;
10612
10613 --
10614 -- COMMIT the last lot of changes.
10615 --
10616 commit;
10617 end if;
10618
10619 if l_debug then
10620 hr_utility.set_location('process_pay_dyndbi_changes', 160);
10621 end if;
10622
10623 -- ================= --
10624 -- Defined Balances. --
10625 -- ================= --
10626 if upper(p_defined_balances) = 'Y' then
10627
10628 if l_debug then
10629 hr_utility.set_location('process_pay_dyndbi_changes', 170);
10630 end if;
10631
10632 --
10633 -- Initialise everything.
10634 --
10635 l_ids.delete;
10636 l_languages.delete;
10637 i := 1;
10638
10639 --
10640 -- Fetch the PAY_DYNDBI_CHANGES rows.
10641 --
10642 fetch_dyndbi_changes
10643 (p_type => pay_dyndbi_changes_pkg.c_defined_balance
10644 ,p_ids => l_ids
10645 ,p_languages => l_languages
10646 );
10647
10648 if l_debug then
10649 hr_utility.set_location('process_pay_dyndbi_changes', 180);
10650 end if;
10651
10652 --
10653 -- Do the updates.
10654 --
10655 init_cnt(p_cnt => l_cnt);
10656
10657 while l_ids.exists(i) loop
10658
10659 if l_debug then
10660 hr_utility.set_location('process_pay_dyndbi_changes', 190);
10661 end if;
10662
10663 l_id_langs.delete;
10664 next_dyndbi_change
10665 (p_ids => l_ids
10666 ,p_languages => l_languages
10667 ,p_start => i
10668 ,p_id => l_id
10669 ,p_id_langs => l_id_langs
10670 );
10671
10672 open csr_def_balance(p_defined_balance_id => l_id);
10673 fetch csr_def_balance
10674 into l_dummy
10675 ;
10676 l_found := csr_def_balance%found;
10677 close csr_def_balance;
10678
10679 if l_debug then
10680 hr_utility.set_location('process_pay_dyndbi_changes', 200);
10681 end if;
10682
10683 g_dyndbi_changes_ok := true;
10684 if l_found then
10685
10686 if l_debug then
10687 hr_utility.set_location('process_pay_dyndbi_changes', 210);
10688 end if;
10689
10690 begin
10691 update_defined_balance
10692 (p_defined_balance_id => l_id
10693 ,p_languages => l_id_langs
10694 );
10695 exception
10696 when others then
10697 g_dyndbi_changes_ok := false;
10698 fnd_file.put(fnd_file.log, l_separator);
10699 fnd_file.put(fnd_file.log, sqlerrm);
10700 errbuf := sqlerrm;
10701 retcode := 2;
10702 end;
10703 else
10704 hr_utility.trace(l_proc||'no defined balance '||l_id);
10705 end if;
10706
10707 --
10708 -- Delete the PAY_DYNDBI_CHANGES rows.
10709 --
10710 if g_dyndbi_changes_ok then
10711 pay_dyndbi_changes_pkg.delete_rows
10712 (p_id => l_id
10713 ,p_type => pay_dyndbi_changes_pkg.c_defined_balance
10714 );
10715 end if;
10716
10717 if l_debug then
10718 hr_utility.set_location('process_pay_dyndbi_changes', 220);
10719 end if;
10720
10721 incr_cnt(p_cnt => l_cnt);
10722 end loop;
10723
10724 --
10725 -- COMMIT the last lot of changes.
10726 --
10727 commit;
10728 end if;
10729
10730 if l_debug then
10731 hr_utility.set_location('process_pay_dyndbi_changes', 230);
10732 end if;
10733
10734 --
10735 -- Do the legislation-specfic changes.
10736 --
10737 if upper(p_localization) = 'Y' then
10738
10739 if l_debug then
10740 hr_utility.set_location('process_pay_dyndbi_changes', 235);
10741 end if;
10742
10743 process_leg_translations(p_errors => l_errors);
10744 for i in 1 .. l_errors.count loop
10745 fnd_file.put(fnd_file.log, l_separator);
10746 fnd_file.put(fnd_file.log, l_errors(i));
10747 end loop;
10748 end if;
10749
10750 --
10751 -- Fetch any error log messages for this process.
10752 --
10753 pay_dbitl_update_errors_pkg.fetch_all_rows
10754 (p_rowids => l_rowids
10755 ,p_messages => l_messages
10756 );
10757
10758 if l_debug then
10759 hr_utility.set_location('process_pay_dyndbi_changes', 240);
10760 end if;
10761
10762 --
10763 -- Set error status if there are any error messages.
10764 --
10765 if l_messages.count <> 0 then
10766 errbuf := l_messages(1);
10767 retcode := 2;
10768 elsif l_errors.count <> 0 then
10769 errbuf := l_errors(1);
10770 retcode := 2;
10771 end if;
10772
10773 --
10774 -- Write messages to the log.
10775 --
10776 for i in 1 .. l_messages.count loop
10777 fnd_file.put(fnd_file.log, l_separator);
10778 fnd_message.set_encoded(l_messages(i));
10779 fnd_file.put(fnd_file.log, fnd_message.get);
10780 end loop;
10781
10782 --
10783 -- Delete the messages.
10784 --
10785 pay_dbitl_update_errors_pkg.delete_rows
10786 (p_rowids => l_rowids
10787 );
10788
10789 g_dyndbi_changes := false;
10790
10791 if l_debug then
10792 hr_utility.set_location('process_pay_dyndbi_changes', 250);
10793 end if;
10794
10795 commit; /*Bug 8512762 Added commit as FND is not commiting if status is error (retcode =2 )*/
10796
10797 exception
10798 when others then
10799 g_dyndbi_changes := false;
10800 errbuf := sqlerrm;
10801 retcode := 2;
10802
10803 if l_debug then
10804 hr_utility.set_location('process_pay_dyndbi_changes', 300);
10805 end if;
10806 end process_pay_dyndbi_changes;
10807
10808 end hrdyndbi;