[Home] [Help]
PACKAGE BODY: APPS.BEN_EXT_THREAD
Source
1 package body ben_ext_thread as
2 /* $Header: benxthrd.pkb 120.40.12010000.7 2008/10/01 13:20:17 vkodedal ship $ */
3
4 /*
5 +==============================================================================+
6 | Copyright (c) 1997 Oracle Corporation |
7 | Redwood Shores, California, USA |
8 | All rights reserved. |
9 +==============================================================================+
10
11 Name
12 Benefit Extract Thread
13 Purpose
14 This package is used to multithread benefit extract process
15 History
16 Date Who Version What?
17 10/15/98 Pdas 115.0 Created.
18 10/30/98 Yrathman 115.1 Added messages
19 11/04/98 Pdas 115.2 Modified call to
20 benutils.get_parameter
21 11/06/98 Yrathman 115.3 Added header/trailer
22 11/06/98 PDas 115.4 Added Person Count, Record Count
23 11/23/98 PDas 115.5 Added logic for smart totals
24 12/09/98 PDas 115.6 Modified call to process_ext_ht_recs
25 12/09/98 Thayden 115.7 Added logic for directroy name.
26 12/30/98 PDas 115.8 Added BENXSMRY report.
27 01/22/99 Pdas 115.9 Changed concurrent program date parameters
28 to varchar2.
29 02/10/99 Pdas 115.10 Modified process_ext_ht_recs procedure
30 02/17/99 Pdas 115.11 Modified process_ext_ht_recs procedure error handling
31 02/24/99 Pdas 115.12 Modified procedure process
32 02/26/99 Pdas 115.13 Modified procedure process
33 03/02/99 Pdas 115.14 Modified procedure process
34 03/09/99 Tmathers 115.15 changed != to <>.
35 03/09/99 Gperry 115.16 is to AS
36 03/09/99 Tmathers 115.18 Made dates MLS.
37 03/10/99 Tmathers 115.19 Missed one
38 03/22/99 Tmathers 115.20 Changed -MON- to /MM/
39 04/07/99 Thayden 115.22 Leapfrog version 115.4 for patch.
40 04/07/99 Thayden 115.23 Communication Fixes
41 04/13/99 Isen 115.24 Added upd_cm_sent_dt_flag to the
42 cursor ext_dfn_c
43 05/07/99 Asen 115.26 Solved the date conversion problem and moved the function
44 Calc_ext_date to benxutil.pkb, change the call accordingly.
45 05/13/99 Thayden 115.27 Major Fixes.
46 05/17/99 Isen 115.28 Corrected dates for header/triler
47 Bug - 2106
48 06/03/99 Asen 115.29 Added two parameters to action api call.
49 06/16/99 Isen 115.30 Added foreign key ref ext_rslt_id
50 07/09/99 Jcarpent 115.31 Added checks for backed out nocopy pil
51 20/07/99 Gperry 115.32 genutils -> benutils package
52 rename.
53 06/08/99 Asen 115.33 Added messages : Entering, Exiting.
54 08/31/99 Asen 115.34 Changed call to decode program (from ben_ext_decodes).
55 09/22/99 Thayden 115.36 Changes to cm and chg cursors (new incl crit).
56 09/27/99 Thayden 115.37 Added defaults for filename and directory.
57 10/01/99 Thayden 115.38 Changed call to calc_smart_totals.
58 10/04/99 Thayden 115.39 Added call for post processing rule.
59 10/06/99 Thayden 115.40 Fix bugs related with 115.39 changes.
60 Fix sql navigator erroring.
61 10/07/99 Thayden 115.41 load fnd_sessions table call.
62 10/11/99 Thayden 115.42 Comment calls to calc_ext_date.
63 11/03/99 Thayden 115.43 Move decode logic back to ben_ext_fmt.
64 01/10/2000 Thayden 115.44 Fix post process rule call.
65 02/06/2000 Thayden 115.45 Added performance enhancements.
66 02/23/2000 Thayden 115.46 Fixed performance enhancements.
67 03/01/2000 RChase 115.47 Fixed dynamic cursors in build_select_statements.
68 to use explict date conversion. This clears up
69 issues with clients using NLS date formats other
70 than DD-MON-YYYY.
71 Updated process procedure to output a wrapped dynamic
72 sql statement to the log file for better debugging
73 purposes.
74 03/14/2000 Thayden 115.48 Advanced Conditions for headers and trailers.
75 05/31/2000 gperry 115.49 Tuning.
76 06/20/2000 jcarpent 115.50 Fix for Tuning fix,
77 uninitialized collection.
78 bug 5339.
79 08/10/2000 tilak 115.51 Dynamic sql date format changed from YYYY to RRRR to
80 support all the other lang
81 08/17/2000 tilak 115.52
82 08/17/2000 tilak 115.53 bug 1381514 fixed before calling calc_ext_date the type of code is calidat ed
83 08/17/2000 tilak 115.54 Backport of 115.48 for 11.5.2
84 patchset with NLS fixes from
85 115.51. wwbug 1391217.
86 08/30/2000 stee 115.55 Leapfrog of 115.53.
87 09/03/2000 stee 115.56 Leapfrog of 115.51.
88 09/03/2000 stee 115.57 Leapfrog of 115.55.
89 12/06/2000 rchase 115.58 Leapfrog of 115.56 with fixes
90 for 1521958. Added rule contexts.
91 12/07/2000 jcarpent 115.59 Merged version of 115.57 and 115.58.
92 01/23/2001 rchase 115.60 Bug 1608852. Correct thread issue.
93 Lock being released before status
94 updating batch range status.
95 01/30/2001 tilak 115.61 error message changed ,get from get_error_messages
96 with element name
97 06/06/2001 tilak 115.62 caling formula is added for header/trailer - 1786750
98 06/21/2001 tilak 115.63 gv$_system_parameter used instead of v$system_paramter
99 07/27/2001 tilak 115.65 Change Event Dynomic sql is cahnged,
100 chg_eff_Dt is replaced p_effective date
101 11/07/2001 mhoyes 115.66 - bug 2100912. Moved call to ben_extract.set_ext_lvls
102 from chunk level to thread level. Globals were
103 being over refreshed.
104 11/09/2001 mhoyes 115.67 - bug 2100912. Moved call to ben_extract.setup_rcd_typ_lvl
105 from chunk level to thread level. Globals were
106 being over refreshed.
107 11/26/2001 mhoyes 115.68 - dbdrv lines.
108
109 01/20/2002 tjesumic 115.69 - restart process added
110 02/12/2002 hnarayan 115.70 added procedure update_ht_strt_end_dt to update
111 data which correspond to fields STRTDT and ENDDT
112 in header and trailer records of result detail.
113 03/11/2002 tjesumic 115.71 - UTF changes
114 03/12/2002 ikasire 115.72 BEN UTF8 Changes
115 05/06/2002 tjesumic 115.73 p_ext_crit_prfl_id ,p_rquest_id added as
116 paramter to process_ext_ht_recs
117 05/16/2002 tjesumic 115.74 dynamic sql chnaged the assg date validate changed from nvl to (+) bug : 2376285
118 05/21/2002 tjesumic 115.75 PLPLCY element added for header level
119 05/24/2002 tjesumic 115.76 change event dynomic sql fixed
120 08-Jun-02 pabodla 115.78 Do not select the contingent worker
121 assignment when assignment data is
122 fetched.
123 17-Jun-02 pabodla 115.79 Fetching assignment data even if assignment_type is null
124 15-Aug-02 tjesumic 115.79 Max_lenght added for String Element
125 28-Aug-02 tjesumic 115.80 if the string Element is null and max_lenght defined
126 string element will be considered as space
127 17-dec-02 tjesumic 115.81 115.78,115.79 reversed
128 27-Dec-02 lakrish 115.84 NOCOPY changes
129 13-Feb-03 rpillay 115.85 HRMS Debug Performance changes to
130 hr_utility.set_location calls
131 23-Aug-03 tjesumic 115.86 calcualted records added for detail record
132 02-Oct-03 tjesumic 115.87 Upper/lower/initcap applied for string format mask
133 29-Oct-03 tjesumic 115.88 total for detail records are considers only non hiden records
134 hiden recors are filterd
135 30-dec-03 mmudigon 115.89 Bug 3232205. Modified cursors on
136 ben_person_actions to drive by
137 benefit_action_id
138 19-Jan-03 tjesumic 115.91 New procedire load_extract added to import and export the
139 extract definition
140 19-Jan-03 tjesumic 115.92 extract sedded or not decided by the extract not the parameter
141 19-Jan-03 tjesumic 115.92 view name cahnged to ben_pl_v
142 26-Jan-03 tjesumic 115.94 validate_mode parameterized for fndload concurren mgr
143 26-Jan-03 tjesumic 115.95 Extract header formula format mask is fixed
144 10-Feb-03 tjesumic 115.96 Person Type usage added in dynamic sql - ppt
145 21-Apr-04 tjesumic 115.97 when the header/trailed element is null and mandatory
146 then throw the warning , if the record is mandatory then
147 throw the error and rollback the header and trailer
148 26-May-04 mmudigon 115.98 Bug 367237. Parameters changed
149 for Restart procedure
150 04-Jun-04 mmudigon 115.99 GSCC file.sql.6 fix
151 06-Jul-04 tjesumic 115.100 for security check_asg_security added and per_people_f view used
152 06-Jul-04 tjesumic 115.104 brought forward the version 100 above the leaf frog
153 02-Aug-04 nhunur 115.105 ensure request_id is not passed as null to benefit actions api.
154 06-Aug-04 nhunur 115.106 3810114 - Added code to prevent over polling of fnd_conc_requests.
155 13-aug-04 tjesumic 115.107 chg_actl_ct is truncated to validated the dates
156 18-Nov-04 rpinjala 115.108 New procedure chk_pqp_extract added
157 19-Nov-04 rpinjala 115.109 Changed chk_pqp_extract procedure.
158 05-Dec-04 rpinjala 115.110 Changed chk_pqp_extract procedure.
159 15-Dec-04 tjesumic 115.111 ext_rcd_in_file_id added to ben_Ext_rslt_dtl table
160 01-Feb-05 tjesumic 115.112 300 elements allowed in a record
161 08-Mar-05 tjesumic 115.113 check_asg_security changed for performance
162 09-Mar-05 tjesumic 115.114 check_asg_security changed for performance
163 22-Mar-05 tjesumic 115.115 CWB (CW) , subheader codes changes
164 new extract type for 'CW' and new header and trialer procedure
165 for subheader and new criteria for both added
166 24-Mar-05 tjesumic 115.116 position extracted from position base table
167 30-Mar-05 tjesumic 115.117 new param p_subhdr_chg_log added for nfc extract to get postion
168 suheader from history table
169 30-Mar-05 tjesumic 115.118 nfc changes
170 31-Mar-05 tjesumic 115.119 GHR changes
171 15-Mar-05 tjesumic 115.120 Global/Cross bg changes added
172 27-Apr-05 rpinjala 115.121 Changed chk_pqp_extract procedure.
173 28-Apr-05 tjesumic 115.122 to_date change to canonical_to_date for formula result date conversion
174 30-Apr-05 tjesumic 115.123 string element added for rule element
175 12-May-05 tjesumic 115.124 g_ext_dfn_id and g_ext_rslt_id intialised in subheader for subhdr formula
176 17-May-05 tjesumic 115.125 p_ghr_date parameter changed to p_eff_start/end_dte
177 08-Jun-05 tjesumic 115.125 pennserver enhancement for new parameter, outpput type
178 effective, actual date and pauroll change events
179 08-Jun-05 tjesumic 115.127 pennserver enhancement
180 13-Jun-05 tjesumic 115.128 payroll dynamic sql changed
181 13-Jun-05 tjesumic 115.129 ghr sql cahnged for pos02
182 25-Jul-05 tjesumic 115.130 Dynamic sql build changed fro performance and bug 4440823
183 22-Aug-05 tjesumic 115.131 business group id variable initalization in security check is changed
184 22-Aug-05 rbingi 115.132 Bug 4545881 - Global flag retrieved from Ext_Crit_Prfl
185 21-Sep-05 tjesumic 115.133 grade inforamtion extracted in subheader
186 13-Sep-05 tjesumic 115.134 when the extract excuted with only subheader, the process should not
187 go throuh person information
188 9-nov-05 nhunur 115.135 xcl > per for performance - bug 4721453
189 6-Dec-05 tjesumic 115.136 cm_display_flag is added and validated
190 9-Dec-05 tjesumic 115.137 benxmlwrit called for cm_display on
191 10-Dec-05 tjesumic 115.138 output_code to set the output type for display
192 20-Dec-05 tjesumic 115.139 cm_downlaod added for download and GHR fix as per 4609093
193 20-Dec-05 tjesumic 115.141 c_xdoi cursor closed
194 22-Dec-05 tjesumic 115.142 XSL changed to EXCEL
195 11-Jan-06 tjesumic 115.143 restart changed to send correct parameters to process
196 02-Feb-06 tjesumic 115.144 restart changed to process the errorerd ranges from advance condition
197 12-Feb-06 tjesumic 115.145 Assignment set added in extract criteria's person level
198 15-Mar-06 tjesumic 115.146 Penserver Sql changes
199 23-Mar-06 tjesumic 115.147 Penserver Sql changes
200 27-Mar-06 tjesumic 115.148 debug function call removed
201 29-Mar-06 tjesumic 115.149 end dte and start parsed in update_ht_strt_end_dt
202 28-APR-06 hgattu 115.150 new param p_out_dummy is added to process procedure(5131931)
203 07-Aug-06 tjesumic 115.151 parameter p_out_dummy passed in wrong position
204 06-Oct-06 tjesumic 115.152 The Advance Date criteria added to Dynamic sql
205 Pay change event sql splited into two, 1 for non Asg event
206 another one for Asg Events. New procedure
207 chck_non_asg_pay_evt and build_adv_criteria added.
208 20-oct-06 tjesumic 115.153 The dynamic query changed to calc the criteria value and validated
209 as in clause without using extract table. per_all_people removed
210 from pay change event query
211 23-Oct-06 tjesumic 115.154 nocopy added
212 31-Oct-06 tjesumic 115.155 payroll id added to the dynamic query
213 07-Dec-06 tjesumic 115.156 subheader's org, job and grade from and to date are validated
214 12-Feb-07 tjesumic 115.157 allow overide param added for uploading file
215 required file benextse.lct 115.40 , benextse,pkh/pkb 115.24/73
216 13-Feb-07 tjesumic 115.158 Legislation ang global check in pay_event_updates table is removed
217 The primary key is passed from process event table.
218 07-mar-07 tjesumic 115.159 Dynamic sql error is fixed
219 20-mar-07 tjesumic 115.162 115.160 and 161 reverted
220 04-Sep-07 tjesumic 115.163 total count and detail count elements are fixed by adding ext_rcd_in_file_id in validation
221 26-Nov-07 tjesumic 115.164 when the extract is global, for 'PPT' person type usage the criteria are validated from table
222 big - 6642051
223 30-Apr-08 vkodedal 115.165 Changes required for penserver - performance fix--6895935,6801389,6995291
224 11-Aug-08 vkodedal 115.167 Penserver perf issue-7274509
225 25-Aug-08 vkodedal 115.168 Penserver perf issue-7341530
226 12-Sep-08 jvaradra 115.170 Penserver perf issue-7358558
227
228 */
229
230 --
231 --
232 -- ----------------------------------------------------------------------------
233 -- | Private Global Definitions |
234 -- ----------------------------------------------------------------------------
235 --
236 g_debug boolean := hr_utility.debug_enabled;
237 --
238 g_val_def ben_ext_fmt.valtabtyp :=
239 ben_ext_fmt.valtabtyp(null,null,null,null,null,null,null,null,null,null,
240 null,null,null,null,null,null,null,null,null,null,
241 null,null,null,null,null,null,null,null,null,null,
242 null,null,null,null,null,null,null,null,null,null,
243 null,null,null,null,null,null,null,null,null,null,
244 null,null,null,null,null,null,null,null,null,null,
245 null,null,null,null,null,null,null,null,null,null,
246 null,null,null,null,null,null,null,null,null,null,
247 null,null,null,null,null,null,null,null,null,null,
248 null,null,null,null,null,null,null,null,null,null,
249 null,null,null,null,null,null,null,null,null,null,
250 null,null,null,null,null,null,null,null,null,null,
251 null,null,null,null,null,null,null,null,null,null,
252 null,null,null,null,null,null,null,null,null,null,
253 null,null,null,null,null,null,null,null,null,null,
254 null,null,null,null,null,null,null,null,null,null,
255 null,null,null,null,null,null,null,null,null,null,
256 null,null,null,null,null,null,null,null,null,null,
257 null,null,null,null,null,null,null,null,null,null,
258 null,null,null,null,null,null,null,null,null,null,
259 null,null,null,null,null,null,null,null,null,null,
260 null,null,null,null,null,null,null,null,null,null,
261 null,null,null,null,null,null,null,null,null,null,
262 null,null,null,null,null,null,null,null,null,null,
263 null,null,null,null,null,null,null,null,null,null,
264 null,null,null,null,null,null,null,null,null,null,
265 null,null,null,null,null,null,null,null,null,null,
266 null,null,null,null,null,null,null,null,null,null,
267 null,null,null,null,null,null,null,null,null,null,
268 null,null,null,null,null,null,null,null,null,null
269 );
270 --
271 -- ----------------------------------------------------------------------------
272 -- |-------------------------< write_error >-----------------------------------|
273 -- ----------------------------------------------------------------------------
274 --
275 Procedure write_error(p_err_num in number,
276 p_err_name in varchar2,
277 p_typ_cd in varchar2,
278 p_person_id in number,
279 p_request_id in number,
280 p_ext_rslt_id in number,
281 p_business_group_id in number
282 ) IS
283 --
284 l_proc varchar2(72);
285 --
286 begin
287 --
288 if g_debug then
289 l_proc := g_package || '.write_error';
290 hr_utility.set_location('Entering'||l_proc, 5);
291 end if;
292 --
293 if p_business_group_id is not null then
294 --
295 ben_ext_util.write_err
296 (p_err_num => p_err_num,
297 p_err_name => p_err_name,
298 p_typ_cd => p_typ_cd,
299 p_person_id => p_person_id,
300 p_request_id => p_request_id,
301 p_ext_rslt_id => p_ext_rslt_id,
302 p_business_group_id => p_business_group_id
303 );
304 --
305 commit;
306 --
307 end if;
308 --
309 if g_debug then
310 hr_utility.set_location('Exiting'||l_proc, 15);
311 end if;
312 --
313 end write_error;
314 --
315 -- ----------------------------------------------------------------------------
316 -- |---------------------< get_ext_prmtrs >-----------------------------------|
317 -- ----------------------------------------------------------------------------
318 --
319 Procedure get_ext_prmtrs(p_ext_dfn_id in number,
320 p_business_group_id in number,
321 p_data_typ_cd in out nocopy varchar2,
322 p_ext_typ_cd in out nocopy varchar2,
323 p_ext_crit_prfl_id in out nocopy number,
324 p_ext_file_id in out nocopy number,
325 p_ext_strt_dt in out nocopy varchar2,
326 p_ext_end_dt in out nocopy varchar2,
327 p_prmy_sort_cd in out nocopy varchar2,
328 p_scnd_sort_cd in out nocopy varchar2,
329 p_output_name in out nocopy varchar2,
330 p_drctry_name in out nocopy varchar2,
331 p_apnd_rqst_id_flag in out nocopy varchar2,
332 p_kickoff_wrt_prc_flag in out nocopy varchar2,
333 p_use_eff_dt_for_chgs_flag in out nocopy varchar2,
334 p_ext_post_prcs_rl in out nocopy number,
335 p_ext_global_flag in out nocopy varchar2,
336 p_cm_display_flag in out nocopy varchar2,
337 p_output_type in out nocopy varchar2,
338 p_xdo_template_id in out nocopy number
339 ) IS
340 --
341 l_proc varchar2(72);
342 --
343 cursor ext_dfn_c is
344 SELECT data_typ_cd
345 , ext_typ_cd
346 , strt_dt
347 , end_dt
348 , ext_crit_prfl_id
349 , ext_file_id
350 , prmy_sort_cd
351 , scnd_sort_cd
352 , output_name
353 , drctry_name
354 , apnd_rqst_id_flag
355 , kickoff_wrt_prc_flag
356 , use_eff_dt_for_chgs_flag
357 , upd_cm_sent_dt_flag
358 , ext_post_prcs_rl
359 , ext_global_flag
360 , output_type
361 , xdo_template_id
362 , cm_display_flag
363 FROM ben_ext_dfn
364 WHERE ext_dfn_id = p_ext_dfn_id;
365 --
366
367 -- subhead
368 cursor c_ext_file (p_file_id number) is
369 select ext_data_elmt_in_rcd_id1,
370 ext_data_elmt_in_rcd_id2
371 from ben_Ext_file exf
372 where exf.ext_file_id = p_file_id ;
373
374
375 cursor c_ext_elmt (p_data_elmt_in_rcd_id number
376 ) is
377 select exf.short_name
378 from ben_ext_fld exf,
379 ben_Ext_data_elmt_in_rcd edr,
380 ben_ext_data_elmt ede
381 where edr.ext_data_elmt_in_rcd_id = p_data_elmt_in_rcd_id
382 and edr.ext_data_elmt_id = ede.ext_Data_elmt_id
383 and ede.ext_fld_id = exf.ext_fld_id (+)
384 ;
385
386 l_ext_rcd c_ext_file%rowtype ;
387
388
389 cursor c_ext_global is
390 select ext_global_flag
391 from ben_ext_crit_prfl
392 where ext_crit_prfl_id = p_ext_crit_prfl_id
393 ;
394
395 begin
396 --
397 if g_debug then
398 l_proc := g_package||'.get_ext_prmtrs';
399 hr_utility.set_location('Entering'||l_proc, 5);
400 end if;
401 --
402 open ext_dfn_c;
403 fetch ext_dfn_c into p_data_typ_cd,
404 p_ext_typ_cd,
405 p_ext_strt_dt,
406 p_ext_end_dt,
407 p_ext_crit_prfl_id,
408 p_ext_file_id,
409 p_prmy_sort_cd,
410 p_scnd_sort_cd,
411 p_output_name,
412 p_drctry_name,
413 p_apnd_rqst_id_flag,
414 p_kickoff_wrt_prc_flag,
415 p_use_eff_dt_for_chgs_flag,
416 ben_ext_person.g_upd_cm_sent_dt_flag,
417 p_ext_post_prcs_rl,
418 p_ext_global_flag,
419 p_output_type ,
420 p_xdo_template_id,
421 p_cm_display_flag
422 ;
423 --
424 if ext_dfn_c%notfound then
425 ben_ext_thread.g_err_num := 91873;
426 ben_ext_thread.g_err_name := 'BEN_91873_EXT_NOT_FOUND';
427 close ext_dfn_c;
428 raise g_job_failure_error;
429 end if;
430 --
431 close ext_dfn_c;
432 --
433
434 -- confirm the global flag from criteria too
435 -- for CWB the criterai may not global but definition is global
436
437 /*if p_ext_global_flag <> 'Y' and p_Ext_crit_prfl_id is not null then
438 open c_ext_global ;
439 fetch c_ext_global into p_ext_global_flag ;
440 close c_ext_global ;
441 end if ; */ -- Bug 4545881 by rbingi
442 --
443 -- For CWB type is always global
444 -- for other types same as the Criteria profile
445 if p_data_typ_cd = 'CW' then
446 --
447 p_ext_global_flag := 'Y' ;
448 --
449 else
450 --
451 open c_ext_global ;
452 fetch c_ext_global into p_ext_global_flag ;
453 close c_ext_global ;
454 --
455 end if;
456
457 --subhead
458 open c_ext_file(p_ext_file_id) ;
459 fetch c_ext_file into l_ext_rcd ;
460 close c_ext_file ;
461
462 if l_ext_rcd.ext_data_elmt_in_rcd_id1 is not null then
463 open c_ext_elmt(l_ext_rcd.ext_data_elmt_in_rcd_id1) ;
464 fetch c_ext_elmt into g_ext_group_elmt1 ;
465 close c_ext_elmt ;
466
467 if l_ext_rcd.ext_data_elmt_in_rcd_id2 is not null then
468 open c_ext_elmt(l_ext_rcd.ext_data_elmt_in_rcd_id2) ;
469 fetch c_ext_elmt into g_ext_group_elmt2 ;
470 close c_ext_elmt ;
471 end if ;
472 end if ;
473 -- eof subheader
474
475 if g_debug then
476 hr_utility.set_location('Exiting'||l_proc, 15);
477 end if;
478 --
479 Exception
480 --
481 when g_job_failure_error then
482 raise g_job_failure_error;
483 --
484 End get_ext_prmtrs;
485 --
486 -- ----------------------------------------------------------------------------
487 -- |--------------------------< update_ht_strt_end_dt >-------------------------|
488 -- ----------------------------------------------------------------------------
489 --
490 Procedure update_ht_strt_end_dt (p_ext_rslt_id number)
491 IS
492 --
493 l_proc varchar2(72);
494 --
495 l_cursor_id integer;
496 l_cnt_rows_upd number;
497 l_tot_string varchar2(5000) := null;
498 l_col_name varchar2(5000) := null;
499 l_value varchar2(5000) := null;
500 l_curr_string varchar2(600) := null; --UTF8
501 l_run_strt_dt date := null;
502 l_run_end_dt date := null;
503 l_temp_dt date := null;
504 --
505 cursor c_ext_rslt is
506 SELECT rslt.run_strt_dt , rslt.run_end_dt
507 FROM ben_ext_rslt rslt
508 WHERE rslt.ext_rslt_id = p_ext_rslt_id;
509 --
510 cursor c_ext_rcd is
511 SELECT distinct rdtl.ext_rcd_id ext_rcd_id
512 FROM ben_ext_rcd rcd, ben_ext_rslt_dtl rdtl
513 WHERE rdtl.ext_rslt_id = p_ext_rslt_id
514 and rdtl.ext_rcd_id = rcd.ext_rcd_id
515 and rcd.rcd_type_cd in ('H','T');
516 --
517 cursor c_data_elmt_seq_num(p_ext_rcd_id number) is
518 SELECT elrc.seq_num, fld.short_name, elmt.frmt_mask_cd
519 FROM ben_ext_data_elmt_in_rcd elrc, ben_ext_data_elmt elmt, ben_ext_fld fld
520 WHERE elrc.ext_rcd_id = p_ext_rcd_id
521 and elrc.ext_data_elmt_id = elmt.ext_data_elmt_id
522 and elmt.ext_fld_id = fld.ext_fld_id
523 and ltrim(rtrim(fld.short_name)) in ('STRTDT','ENDDT');
524
525 BEGIN
526 --
527 if g_debug then
528 l_proc := g_package||'.update_ht_strt_end_dt';
529 hr_utility.set_location('Entering'||l_proc, 5);
530 end if;
531 --
532 --
533 l_cursor_id := DBMS_SQL.OPEN_CURSOR;
534 --
535 open c_ext_rslt;
536 fetch c_ext_rslt into l_run_strt_dt, l_run_end_dt ;
537 close c_ext_rslt;
538 --
539 for rcd_rec in c_ext_rcd loop
540 --
541 l_tot_string := null;
542 for elmt_rec in c_data_elmt_seq_num(rcd_rec.ext_rcd_id) loop
543 --
544 if (elmt_rec.short_name = 'STRTDT') then
545 l_temp_dt := l_run_strt_dt;
546 elsif (elmt_rec.short_name = 'ENDDT') then
547 l_temp_dt := l_run_end_dt;
548 else
549 l_temp_dt := null;
550 end if;
551 --
552
553 l_col_name := ' VAL_' || ltrim(to_char(elmt_rec.seq_num,'09')) ;
554 if (elmt_rec.frmt_mask_cd is null) then
555 --l_curr_string := ' VAL_' || ltrim(to_char(elmt_rec.seq_num,'09')) || ' = ''' || to_char(l_temp_dt) || ''' ' ;
556 l_value := to_char(l_temp_dt) ;
557 else
558 --l_curr_string := ' VAL_' || ltrim(to_char(elmt_rec.seq_num,'09')) || ' = ''' ||
559 -- to_char(l_temp_dt,hr_general.decode_lookup('BEN_EXT_FRMT_MASK',elmt_rec.frmt_mask_cd)) || ''' ' ;
560 l_col_name := ' VAL_' || ltrim(to_char(elmt_rec.seq_num,'09')) ;
561 l_value := to_char(l_temp_dt,hr_general.decode_lookup('BEN_EXT_FRMT_MASK',elmt_rec.frmt_mask_cd)) ;
562 end if;
563 --
564 /*
565 if l_tot_string is null then
566 l_tot_string := ' SET ' || l_curr_string ;
567 else
568 l_tot_string := l_tot_string || ' , ' || l_curr_string ;
569 end if;
570 --
571 end loop;
572 --
573
574 if l_tot_string is not null then
575 */
576 --
577 /*
578 l_tot_string := 'UPDATE BEN_EXT_RSLT_DTL ' || l_tot_string
579 || ' WHERE ext_rslt_id = ' || to_char(p_ext_rslt_id)
580 || ' AND ext_rcd_id = ' || to_char(rcd_rec.ext_rcd_id);
581
582 */
583
584 l_tot_string := 'UPDATE BEN_EXT_RSLT_DTL SET ' || l_col_name || ' = :VAL where ext_rslt_id = :RSLT_ID and ext_rcd_id = :RCD_ID' ;
585
586 DBMS_SQL.PARSE(l_cursor_id, l_tot_string, dbms_sql.v7);
587
588
589 --DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':COL' , l_col_name );
590 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':VAL' , l_value );
591 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':RSLT_ID' , p_ext_rslt_id );
592 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':RCD_ID' , rcd_rec.ext_rcd_id );
593
594
595 l_cnt_rows_upd := DBMS_SQL.EXECUTE(l_cursor_id);
596 --
597 -- end if;
598 --
599 end loop;
600 end loop;
601 --
602 DBMS_SQL.CLOSE_CURSOR(l_cursor_id);
603 --
604 --
605 if g_debug then
606 hr_utility.set_location('Exiting'||l_proc, 15);
607 end if;
608 --
609 EXCEPTION
610 --
611 when OTHERS then
612 if DBMS_SQL.IS_OPEN(l_cursor_id) then
613 DBMS_SQL.CLOSE_CURSOR(l_cursor_id);
614 end if;
615 raise;
616
617 END update_ht_strt_end_dt;
618
619
620
621
622 --
623 -- ----------------------------------------------------------------------------
624 -- |--------------------------< get_ht_elmt_data >-------------------------|
625 -- ----------------------------------------------------------------------------
626 --
627 Function get_ht_elmt_data(p_ext_rslt_id in number,
628 p_data_elmt_typ_cd in varchar2 ,
629 p_short_name in varchar2 ,
630 p_ext_data_elmt_id in number,
631 p_frmt_mask_cd in varchar2 default null,
632 p_frmt_mask_lookup_cd in varchar2 default null,
633 p_dflt_val in varchar2 default null,
634 p_data_elmt_rl in number default null,
635 p_pl_id in number default null,
636 p_business_group_id in number,
637 p_effective_date in date ,
638 p_request_id in number,
639 p_ext_file_id in number default null,
640 p_ttl_fnctn_cd in varchar2 default null,
641 p_ttl_sum_ext_data_elmt_id in number default null,
642 p_ttl_cond_ext_data_elmt_id in number default null,
643 p_rcd_typ_cd in varchar2 default null,
644 p_group_val_01 in varchar2 default null,
645 p_group_val_02 in varchar2 default null,
646 p_ext_per_bg_id in varchar2 default null,
647 p_String_val in varchar2 default null
648 )
649 return varchar2 IS
650
651
652 cursor c_rule_type(p_rule_id ff_formulas_f.formula_id%type) is
653 select formula_type_id
654 from ff_formulas_f
655 where formula_id = p_rule_id
656 and p_effective_date
657 between effective_start_date
658 and effective_end_date;
659
660 cursor bus_c (p_bg_id number) is
661 select name
662 from per_business_groups
663 where organization_id = p_bg_id ;
664
665 cursor c_plcy (l_pl_id Number , l_typ_cd varchar2) is
666 select a.plcy_r_grp
667 from ben_popl_org_f a,
668 ben_popl_org_role_f b
669 where a.pl_id = l_pl_id
670 and a.plcy_r_grp is not null
671 and a.popl_org_id = b.popl_org_id
672 and b.org_role_typ_cd = l_typ_cd
673 and p_effective_date between a.effective_start_date
674 and a.effective_end_date
675 and p_effective_date between b.effective_start_date
676 and b.effective_end_date;
677
678 cursor c_plplcy (l_pl_id Number) is
679 select a.plcy_r_grp
680 from ben_popl_org_f a
681 where a.pl_id = l_pl_id
682 and a.plcy_r_grp is not null
683 and p_effective_date between a.effective_start_date
684 and a.effective_end_date ;
685
686
687 cursor c_custid (l_pl_id Number , l_typ_cd varchar2) is
688 select a.cstmr_num
689 from ben_popl_org_f a,
690 ben_popl_org_role_f b
691 where a.pl_id = l_pl_id
692 and a.cstmr_num is not null
693 and a.popl_org_id = b.popl_org_id
694 and b.org_role_typ_cd = l_typ_cd
695 and p_effective_date between a.effective_start_date
696 and a.effective_end_date
697 and p_effective_date between b.effective_start_date
698 and b.effective_end_date;
699
700 cursor c_rolname (l_pl_id Number , l_typ_cd varchar2) is
701 select b.name
702 from ben_popl_org_f a,
703 ben_popl_org_role_f b
704 where a.pl_id = l_pl_id
705 and b.name is not null
706 and b.org_role_typ_cd = l_typ_cd
707 and a.popl_org_id = b.popl_org_id
708 and p_effective_date between a.effective_start_date
709 and a.effective_end_date
710 and p_effective_date between b.effective_start_date
711 and b.effective_end_date;
712
713
714 cursor get_per_cnt (p_group_val_01 varchar2 ,
715 p_group_val_02 varchar2) is
716 select count(distinct person_id)
717 from ben_ext_rslt_dtl xrd
718 where xrd.ext_rslt_id = p_ext_rslt_id
719 and person_id not in (0, 999999999999)
720 and xrd.group_val_01 = p_group_val_01
721 and nvl(xrd.group_val_02,'-1') = nvl(p_group_val_02,'-1') ;
722
723
724 cursor get_dtl_cnt(p_group_val_01 varchar2 ,
725 p_group_val_02 varchar2) is
726 select count(*)
727 from ben_ext_rslt_dtl xrd ,
728 ben_ext_rcd_in_file erf
729 where xrd.ext_rslt_id = p_ext_rslt_id
730 and xrd.ext_rcd_id = erf.ext_rcd_id
731 and xrd.ext_rcd_in_file_id = erf.ext_rcd_in_file_id
732 and erf.ext_file_id = p_ext_file_id
733 and erf.hide_flag = 'N'
734 and xrd. person_id not in (0, 999999999999)
735 and xrd.group_val_01 = p_group_val_01
736 and nvl(xrd.group_val_02,'-1') = nvl(p_group_val_02,'-1')
737 ;
738
739
740 cursor get_ttl_cnt(p_group_val_01 varchar2 ,
741 p_group_val_02 varchar2) is
742 select count(*)
743 from ben_ext_rslt_dtl xrd ,
744 ben_ext_rcd_in_file erf
745 where xrd.ext_rslt_id = p_ext_rslt_id
746 and xrd.ext_rcd_id = erf.ext_rcd_id
747 and xrd.ext_rcd_in_file_id = erf.ext_rcd_in_file_id
748 and erf.ext_file_id = p_ext_file_id
749 and erf.hide_flag = 'N'
750 and xrd.group_val_01 = p_group_val_01
751 and nvl(xrd.group_val_02,' ') = nvl(p_group_val_02,' ')
752 ;
753
754 cursor get_subtrl_cnt is
755 select count(*)
756 from ben_ext_rcd_in_file fil, ben_ext_rcd rcd
757 where fil.ext_rcd_id = rcd.ext_rcd_id
758 and fil.ext_file_id = p_ext_file_id
759 and rcd.rcd_type_cd = 'L';
760
761
762 l_subtrl_cnt number ;
763 l_business_group_name per_business_groups.name%TYPE;
764 l_rule_type c_rule_type%rowtype;
765 l_outputs ff_exec.outputs_t;
766 l_dummy_var varchar2(1000) ;
767 l_proc varchar2(72) ;
768 l_rslt_elmt varchar2(600) := null; -- UTF8
769 l_rslt_elmt_fmt varchar2(600) := null;
770
771 Begin
772
773 g_debug := hr_utility.debug_enabled;
774 if g_debug then
775 l_proc := g_package||'.get_ht_elmt_data';
776 hr_utility.set_location('Entering'||l_proc, 5);
777 end if;
778
779 IF p_data_elmt_typ_cd = 'F' THEN
780
781 IF p_short_name = 'EFFDT' THEN
782 l_rslt_elmt := ben_ext_fmt.apply_format_mask(p_effective_date, P_frmt_mask_cd);
783 ELSIF p_short_name = 'STRTDT' THEN
784 l_rslt_elmt := ben_ext_fmt.apply_format_mask(g_ext_strt_dt, P_frmt_mask_cd);
785 ELSIF p_short_name = 'ENDDT' THEN
786 l_rslt_elmt := ben_ext_fmt.apply_format_mask(g_ext_end_dt, P_frmt_mask_cd);
787 ELSIF p_short_name = 'RUNDT' THEN
788 l_rslt_elmt := ben_ext_fmt.apply_format_mask(sysdate, P_frmt_mask_cd);
789 ELSIF p_short_name = 'RECCNT' THEN
790
791 open get_subtrl_cnt ;
792 fetch get_subtrl_cnt into l_subtrl_cnt ;
793 close get_subtrl_cnt ;
794
795 --
796 -- 1 there can be sub trailer without grouping
797 -- 2 there could be multiple subtrailer
798 -- 3 sub trailer has to be counted when the total in subtrailer
799 -- 4 sub trailer has to be counted when the total in trailer or header
800 -- 5 g_rec_cnt calcualted when the header or trailer processes so
801 -- we have to count them for non grouping subtrailer
802
803 if g_subtrl_cnt is null or g_subtrl_cnt = 0 then
804 l_rslt_elmt := ben_ext_fmt.apply_format_mask(g_rec_cnt + nvl(l_subtrl_cnt,0) , P_frmt_mask_cd);
805 else
806 l_rslt_elmt := ben_ext_fmt.apply_format_mask(g_rec_cnt+ nvl(g_subtrl_cnt,0) , P_frmt_mask_cd);
807 end if ;
808
809 --- sub grouping trailer
810 if p_rcd_typ_cd = 'L' and p_group_val_01 is not null then
811 l_rslt_elmt := null ;
812 open get_ttl_cnt (p_group_val_01 ,
813 p_group_val_02) ;
814 fetch get_ttl_cnt into l_rslt_elmt ;
815 close get_ttl_cnt ;
816
817 hr_utility.set_location( ' ttl count ' || l_rslt_elmt , 99 ) ;
818 hr_utility.set_location( ' su ttl ' || l_subtrl_cnt , 99 ) ;
819 if l_rslt_elmt is not null or l_subtrl_cnt is not null then
820 l_rslt_elmt :=
821 ben_ext_fmt.apply_format_mask(nvl(to_number(l_rslt_elmt),0)+
822 nvl(l_subtrl_cnt,0),P_frmt_mask_cd);
823 end if ;
824
825 end if ;
826
827 ELSIF p_short_name = 'DTLCNT' THEN
828 l_rslt_elmt := ben_ext_fmt.apply_format_mask(g_dtl_cnt, P_frmt_mask_cd);
829 --- sub grouping trailer
830 if p_rcd_typ_cd = 'L' and p_group_val_01 is not null then
831 l_rslt_elmt := null ;
832 open get_dtl_cnt (p_group_val_01 ,
833 p_group_val_02) ;
834 fetch get_dtl_cnt into l_rslt_elmt ;
835 close get_dtl_cnt ;
836 hr_utility.set_location( ' dtl count ' || l_rslt_elmt , 99 ) ;
837 if l_rslt_elmt is not null then
838 l_rslt_elmt := ben_ext_fmt.apply_format_mask(l_rslt_elmt, P_frmt_mask_cd);
839 end if ;
840
841 end if ;
842
843 ELSIF p_short_name = 'HDRCNT' THEN
844 l_rslt_elmt := ben_ext_fmt.apply_format_mask(g_hdr_cnt, P_frmt_mask_cd);
845 ELSIF p_short_name = 'TRLCNT' THEN
846 l_rslt_elmt := ben_ext_fmt.apply_format_mask(g_trl_cnt, P_frmt_mask_cd);
847 ELSIF p_short_name = 'PERCNT' THEN
848 l_rslt_elmt := ben_ext_fmt.apply_format_mask(g_per_cnt, P_frmt_mask_cd);
849 if p_rcd_typ_cd = 'L' and p_group_val_01 is not null then
850 l_rslt_elmt := null ;
851 open get_per_cnt (p_group_val_01 ,
852 p_group_val_02) ;
853 fetch get_per_cnt into l_rslt_elmt ;
854 close get_per_cnt ;
855
856 if l_rslt_elmt is not null then
857 l_rslt_elmt := ben_ext_fmt.apply_format_mask(l_rslt_elmt, P_frmt_mask_cd);
858 end if ;
859
860 end if ;
861
862 ELSIF p_short_name = 'BSGRP' THEN
863 if p_ext_per_bg_id is not null then
864
865 open bus_c (p_ext_per_bg_id );
866 fetch bus_c into l_business_group_name;
867 close bus_c;
868 else
869 open bus_c (p_business_group_id);
870 fetch bus_c into l_business_group_name;
871 close bus_c;
872 end if ;
873 l_rslt_elmt := l_business_group_name;
874
875 ELSIF p_short_name = 'PBSGRP' THEN
876 open bus_c (p_business_group_id);
877 fetch bus_c into l_business_group_name;
878 close bus_c;
879 l_rslt_elmt := l_business_group_name;
880
881 ELSIF p_short_name = 'SHDRCNT' THEN
882 l_rslt_elmt := ben_ext_fmt.apply_format_mask(g_subhdr_cnt, P_frmt_mask_cd);
883 ELSIF p_short_name = 'STRLCNT' THEN
884 l_rslt_elmt := ben_ext_fmt.apply_format_mask(g_subtrl_cnt, P_frmt_mask_cd);
885
886 ELSIF p_short_name = 'EXRQID' THEN
887 l_rslt_elmt := ben_ext_fmt.apply_format_mask(p_request_id,P_frmt_mask_cd);
888 ELSIF p_short_name = 'SPOIDNO' THEN
889 open c_custid (p_pl_id ,'SPON');
890 fetch c_custid into l_rslt_elmt ;
891 close c_custid ;
892 ELSIF p_short_name = 'SPONAME' THEN
893 open c_rolname (p_pl_id ,'SPON');
894 fetch c_rolname into l_rslt_elmt ;
895 close c_rolname ;
896 ELSIF p_short_name = 'SPOPONO' THEN
897 open c_plcy (p_pl_id ,'SPON');
898 fetch c_plcy into l_rslt_elmt ;
899 close c_plcy ;
900 ELSIF p_short_name = 'SPOTYPCD' THEN
901 l_rslt_elmt := 'SPON' ;
902 ELSIF p_short_name = 'INSIDNO' THEN
903 open c_custid (p_pl_id ,'INSR');
904 fetch c_custid into l_rslt_elmt ;
905 close c_custid ;
906 ELSIF p_short_name = 'INSNAME' THEN
907 open c_rolname (p_pl_id ,'INSR');
908 fetch c_rolname into l_rslt_elmt ;
909 close c_rolname ;
910 ELSIF p_short_name = 'INSPONO' THEN
911 open c_plcy (p_pl_id ,'INSR');
912 fetch c_plcy into l_rslt_elmt ;
913 close c_plcy ;
914 ELSIF p_short_name = 'INSTYPCD' THEN
915 l_rslt_elmt := 'INSR' ;
916 ELSIF p_short_name = 'BROIDNO' THEN
917 open c_custid (p_pl_id ,'BROK');
918 fetch c_custid into l_rslt_elmt ;
919 close c_custid ;
920
921 ELSIF p_short_name = 'BRONAME' THEN
922 open c_rolname (p_pl_id ,'BROK');
923 fetch c_rolname into l_rslt_elmt ;
924 close c_rolname ;
925 ELSIF p_short_name = 'BROPONO' THEN
926 open c_plcy (p_pl_id ,'BROK');
927 fetch c_plcy into l_Rslt_elmt ;
928 close c_plcy ;
929 ELSIF p_short_name = 'BROTYPCD' THEN
930 l_rslt_elmt := 'BROK' ;
931 ELSIF p_short_name = 'PLPLCY' THEN
932 open c_plplcy (p_pl_id );
933 fetch c_plplcy into l_rslt_elmt ;
934 close c_plplcy ;
935 ELSIF p_short_name = 'FILLER' THEN
936 l_rslt_elmt := null;
937 END IF;
938 ELSIF p_data_elmt_typ_cd = 'D' THEN
939
940 IF p_short_name = 'BSGRP' THEN
941 if p_ext_per_bg_id is not null then
942 l_rslt_elmt := ben_ext_fmt.apply_decode
943 (to_char(p_ext_per_bg_id),
944 p_ext_data_elmt_id,
945 p_dflt_val);
946 else
947 l_rslt_elmt := ben_ext_fmt.apply_decode
948 (to_char(p_business_group_id),
949 p_ext_data_elmt_id,
950 p_dflt_val);
951 end if ;
952 ELSIF p_short_name = 'PBSGRP' THEN
953 l_rslt_elmt := ben_ext_fmt.apply_decode
954 (to_char(p_business_group_id),
955 p_ext_data_elmt_id,
956 p_dflt_val);
957
958 END IF ;
959
960
961 ELSIF p_data_elmt_typ_cd = 'R' THEN
962 -- data element is a rule:
963
964 --
965 if g_debug then
966 hr_utility.set_location(' Rule546:'||P_data_elmt_rl, 39);
967 end if;
968
969
970 open c_rule_type(P_data_elmt_rl);
971 fetch c_rule_type into l_rule_type;
972 close c_rule_type;
973
974 if g_debug then
975 hr_utility.set_location(' rule type :'||l_rule_type.formula_type_id, 39);
976 hr_utility.set_location(' ext_dfn_id :'||ben_ext_thread.g_ext_dfn_id, 39);
977 hr_utility.set_location(' rslt id :'||ben_ext_thread.g_ext_rslt_id, 39);
978 end if;
979 if l_rule_type.formula_type_id = -546 then
980 l_outputs := benutils.formula
981 (p_formula_id => p_data_elmt_rl,
982 p_effective_date => p_effective_date ,
983 p_business_group_id => nvl(p_ext_per_bg_id, p_business_group_id)
984 ,p_param1 => 'EXT_DFN_ID'
985 ,p_param1_value => to_char(nvl(ben_ext_thread.g_ext_dfn_id, -1))
986 ,p_param2 => 'EXT_RSLT_ID'
987 ,p_param2_value => to_char(nvl(ben_ext_thread.g_ext_rslt_id, -1))
988 ,p_param3 => 'EXT_USER_VALUE'
989 ,p_param3_value => p_string_val
990 ,p_param4 => 'EXT_PROCESS_BUSINESS_GROUP'
991 ,p_param4_value => to_char(p_business_group_id)
992 );
993
994 l_rslt_elmt := l_outputs(l_outputs.first).value;
995 --
996 hr_utility.set_location(' rule result :'|| l_rslt_elmt, 39);
997
998 -- format mask handling
999 if p_frmt_mask_lookup_cd is not null then
1000 begin
1001 if substr(p_frmt_mask_lookup_cd,1,1) = 'N' then
1002 l_rslt_elmt_fmt := ben_ext_fmt.apply_format_mask(to_number(l_rslt_elmt), p_frmt_mask_cd);
1003 l_rslt_elmt := l_rslt_elmt_fmt;
1004 end if;
1005 if substr(p_frmt_mask_lookup_cd,1,1) = 'D' then
1006 l_rslt_elmt_fmt := ben_ext_fmt.apply_format_mask(fnd_date.canonical_to_date(l_rslt_elmt), p_frmt_mask_cd);
1007 l_rslt_elmt := l_rslt_elmt_fmt;
1008 end if ;
1009 exception -- incase l_rslt_elmt is not valid for formatting, just don't format it.
1010 when others then
1011 null;
1012 end;
1013 end if ;
1014 hr_utility.set_location(' rule result frmt :'|| l_rslt_elmt, 39);
1015 else
1016 --- this avoid copying the previous result
1017 l_rslt_elmt := null ;
1018 end if ;
1019
1020 ELSIF p_data_elmt_typ_cd = 'T' THEN
1021 --
1022 -- data element is a total:
1023 -- ---------------------------------------------------------
1024 ben_ext_smart_total.calc_smart_total
1025 (p_ext_rslt_id => p_ext_rslt_id,
1026 p_ttl_fnctn_cd => p_ttl_fnctn_cd,
1027 p_ttl_sum_ext_data_elmt_id => p_ttl_sum_ext_data_elmt_id,
1028 p_ttl_cond_ext_data_elmt_id => p_ttl_cond_ext_data_elmt_id,
1029 p_ext_data_elmt_id => p_ext_data_elmt_id,
1030 p_frmt_mask_cd => p_frmt_mask_cd,
1031 p_ext_file_id => p_ext_file_id,
1032 p_business_group_id => p_business_group_id,
1033 p_smart_total => l_rslt_elmt);
1034
1035
1036 end if ;
1037
1038 return l_rslt_elmt ;
1039
1040 Exception
1041 when others then
1042 raise; -- such that the calling pgm will handle the rest.
1043
1044
1045 End get_ht_elmt_data ;
1046
1047
1048
1049 -- ----------------------------------------------------------------------------
1050 -- |---------< get_calc_value >---------------------------------------------|
1051 -- ----------------------------------------------------------------------------
1052 function get_calc_value
1053 (
1054 p_ext_rslt_id in number,
1055 p_ext_file_id in number,
1056 p_data_elmt_typ_cd in varchar2 ,
1057 p_short_name in varchar2 ,
1058 p_ext_data_elmt_id in number,
1059 p_frmt_mask_cd in varchar2 default null,
1060 p_frmt_mask_lookup_cd in varchar2 default null,
1061 p_dflt_val in varchar2 default null,
1062 p_data_elmt_rl in number default null,
1063 p_pl_id in number default null,
1064 p_business_group_id in number,
1065 p_effective_date in date ,
1066 p_request_id in number ,
1067 p_calc in varchar2 ,
1068 p_rcd_typ_cd in varchar2 default null
1069 ) return varchar2 IS
1070 --
1071 l_proc varchar2(72) := g_package||'get_calc_value';
1072 l_number varchar2(1);
1073 l_max_len integer ;
1074 --
1075 l_rslt_elmt varchar2(4000) ;
1076 l_rslt_calc varchar2(4000) ;
1077 Cursor c_calc_elmt is
1078 select ewc.seq_num
1079 ,xel.ext_data_elmt_id
1080 , xel.data_elmt_typ_cd
1081 , xel.data_elmt_rl
1082 , xel.name
1083 , xel.string_val
1084 , xel.dflt_val
1085 , xel.max_length_num
1086 , xel.ttl_fnctn_cd
1087 , xel.ttl_cond_oper_cd
1088 , xel.ttl_cond_val
1089 , xel.ttl_sum_ext_data_elmt_id
1090 , xel.ttl_cond_ext_data_elmt_id
1091 , efl.short_name
1092 from ben_Ext_where_clause ewc,
1093 ben_Ext_data_elmt xel,
1094 ben_ext_fld efl
1095 where ewc.ext_data_elmt_id = p_ext_data_elmt_id
1096 and xel.ext_data_elmt_id = ewc.cond_ext_data_elmt_id
1097 and xel.ext_fld_id = efl.ext_fld_id (+) ;
1098 begin
1099
1100 hr_utility.set_location('Entering'||l_proc, 5);
1101 for elmt in c_calc_elmt Loop
1102 l_rslt_calc :=get_ht_elmt_data(p_ext_rslt_id => p_ext_rslt_id,
1103 p_data_elmt_typ_cd => elmt.data_elmt_typ_cd ,
1104 p_short_name => elmt.short_name ,
1105 p_ext_data_elmt_id => elmt.ext_data_elmt_id,
1106 p_frmt_mask_cd => p_frmt_mask_cd ,
1107 p_frmt_mask_lookup_cd => p_frmt_mask_lookup_cd,
1108 p_dflt_val => elmt.dflt_val ,
1109 p_data_elmt_rl => elmt.data_elmt_rl ,
1110 p_pl_id => p_pl_id ,
1111 p_business_group_id => p_business_group_id,
1112 p_effective_date => p_effective_date ,
1113 p_request_id => p_request_id,
1114 p_ext_file_id => p_ext_file_id,
1115 p_ttl_fnctn_cd => elmt.ttl_fnctn_cd ,
1116 p_ttl_sum_ext_data_elmt_id => elmt.ttl_sum_ext_data_elmt_id,
1117 p_ttl_cond_ext_data_elmt_id => elmt.ttl_cond_ext_data_elmt_id,
1118 p_rcd_typ_cd => p_rcd_typ_cd
1119 ) ;
1120 hr_utility.set_location (' HT ' || elmt.short_name || l_rslt_calc , 999 );
1121 hr_utility.set_location (' type ' || elmt.short_name || elmt.data_elmt_typ_cd , 999 );
1122
1123 Begin
1124 l_rslt_calc := to_number(l_rslt_calc) ;
1125 exception
1126 when value_error then
1127 l_rslt_calc := null ;
1128 end ;
1129
1130 if l_rslt_elmt is null then
1131 l_rslt_elmt := l_rslt_calc ;
1132 else
1133 if l_rslt_calc is not null then
1134 l_rslt_elmt := ben_ext_fmt.Calculate_calc_value
1135 (p_firtst_value => to_number(l_rslt_elmt)
1136 ,p_second_value => l_rslt_calc
1137 ,p_calc => p_calc ) ;
1138 end if ;
1139 end if ;
1140 hr_utility.set_location (' HT result ' || l_rslt_elmt , 999 );
1141 end loop ;
1142 l_rslt_elmt := ben_ext_fmt.apply_format_mask(to_number(l_rslt_elmt), p_frmt_mask_cd);
1143
1144
1145 hr_utility.set_location (' HT return result ' || l_rslt_elmt , 999 );
1146 hr_utility.set_location(' Exiting:'||l_proc, 15);
1147 return l_rslt_elmt ;
1148 end get_calc_value ;
1149
1150
1151
1152
1153 --
1154 -- ----------------------------------------------------------------------------
1155 -- |--------------------------< process_ext_ht_recs >-------------------------|
1156 -- ----------------------------------------------------------------------------
1157 --
1158 Procedure process_ext_ht_recs(p_ext_rslt_id in number,
1159 p_ext_file_id in number,
1160 p_ext_typ_cd in varchar2,
1161 p_rcd_typ_cd in varchar2,
1162 p_business_group_id in number,
1163 p_effective_date in date,
1164 p_group_val_01 in varchar2 default null,
1165 p_group_val_02 in varchar2 default null,
1166 p_request_id in number default null,
1167 p_ext_crit_prfl_id in number default null,
1168 p_ext_per_bg_id in number default null
1169 )
1170 IS
1171 --
1172 l_proc varchar2(72);
1173 --
1174 l_chg varchar2(1) := 'I';
1175 l_ext_rcd_id number(15) := null;
1176 l_ext_rcd_in_file_id number(15) := null;
1177 l_rslt_elmt varchar2(600) := null; -- UTF8
1178 --
1179 l_ext_rslt_dtl_id number(15);
1180 l_object_version_number number(15);
1181 --
1182 l_trans_num number(15);
1183 l_person_id number(15);
1184 l_prmy_sort_val ben_ext_rslt_dtl.prmy_sort_val%TYPE; -- UTF8 varchar2(30);
1185 l_scnd_sort_val ben_ext_rslt_dtl.scnd_sort_val%TYPE; -- UTF8 varchar2(30);
1186 l_exclude_this_rcd_flag boolean;
1187 l_write_rcd varchar2(1);
1188 l_elmt_name varchar2(2000) ;
1189 l_error_message varchar2(2000) ;
1190 l_rqd_elmt_available varchar2(1) := 'Y' ;
1191 l_group_val_01 varchar2(2000) ;
1192 l_group_val_02 varchar2(2000) ;
1193 --
1194 cursor ext_rcd_typ_c is
1195 select a.ext_rcd_id,
1196 b.ext_rcd_in_file_id,
1197 b.seq_num,
1198 b.sprs_cd,
1199 b.rqd_flag
1200 from ben_ext_rcd a,
1201 ben_ext_rcd_in_file b
1202 where a.ext_rcd_id = b.ext_rcd_id
1203 and b.ext_file_id = p_ext_file_id
1204 and a.rcd_type_cd = p_rcd_typ_cd
1205 order by b.seq_num;
1206 --
1207 cursor rcd_elmt_c is
1208 select a.ext_data_elmt_in_rcd_id,
1209 a.seq_num,
1210 a.sprs_cd,
1211 a.strt_pos,
1212 a.dlmtr_val,
1213 a.rqd_flag,
1214 b.ext_data_elmt_id,
1215 b.data_elmt_typ_cd,
1216 b.data_elmt_rl,
1217 b.name,
1218 hr_general.decode_lookup('BEN_EXT_FRMT_MASK',b.frmt_mask_cd) frmt_mask_cd,
1219 b.frmt_mask_cd frmt_mask_lookup_cd ,
1220 b.string_val,
1221 b.dflt_val,
1222 b.max_length_num,
1223 b.just_cd,
1224 b.ttl_fnctn_cd,
1225 b.ttl_cond_oper_cd,
1226 b.ttl_cond_val,
1227 b.ttl_sum_ext_data_elmt_id,
1228 b.ttl_cond_ext_data_elmt_id,
1229 c.short_name
1230 from ben_ext_data_elmt_in_rcd a,
1231 ben_ext_data_elmt b,
1232 ben_ext_fld c
1233 where a.ext_rcd_id = l_ext_rcd_id
1234 and a.ext_data_elmt_id = b.ext_data_elmt_id
1235 and b.ext_fld_id = c.ext_fld_id (+)
1236 order by a.seq_num;
1237 --
1238
1239 CURSOR get_pl_val IS
1240 SELECT b.val_1
1241 FROM ben_ext_crit_typ a,
1242 ben_ext_crit_val b
1243 WHERE a.ext_crit_typ_id = b.ext_crit_typ_id
1244 and a.crit_typ_cd = 'BPL'
1245 and a.ext_crit_prfl_id = p_ext_crit_prfl_id;
1246
1247
1248 cursor get_subtrl_cnt is
1249 select count(*)
1250 from ben_Ext_rslt_dtl xrd,
1251 ben_ext_rcd rcd,
1252 ben_ext_rcd_in_file erf
1253 where xrd.ext_rslt_id = p_ext_rslt_id
1254 and xrd.ext_rcd_id = erf.ext_rcd_id
1255 and xrd.ext_rcd_in_file_id = erf.ext_rcd_in_file_id
1256 and erf.ext_file_id = p_ext_file_id
1257 and rcd.ext_rcd_id = erf.ext_rcd_id
1258 and erf.hide_flag = 'N'
1259 and rcd.rcd_type_cd = 'L' ;
1260
1261 l_pl_id number ;
1262 l_dummy_var varchar2(1000) ;
1263 --
1264 begin
1265 --
1266 g_debug := hr_utility.debug_enabled;
1267 if g_debug then
1268 l_proc := g_package||'.process_ext_ht_recs';
1269 hr_utility.set_location('Entering'||l_proc, 5);
1270 end if;
1271 --
1272 savepoint head_trail;
1273 --
1274 -- assign values for sorting
1275 -- for now let's do this, but maybe there is a better way
1276 --
1277 IF p_rcd_typ_cd = 'H' THEN
1278 l_person_id := 0;
1279 l_trans_num := 0;
1280 l_prmy_sort_val := ' ';
1281 l_scnd_sort_val := ' ';
1282 l_group_val_01 := ' ' ;
1283 l_group_val_02 := ' ' ;
1284 elsif p_rcd_typ_cd = 'T' THEN
1285 l_person_id := 999999999999;
1286 l_trans_num := 999999999999;
1287 l_prmy_sort_val := null;
1288 l_scnd_sort_val := null;
1289 l_group_val_01 := null ;
1290 l_group_val_02 := null ;
1291 elsif p_rcd_typ_cd = 'L' THEN
1292 l_person_id := 999999999999;
1293 l_trans_num := 999999999999;
1294 l_prmy_sort_val := null;
1295 l_scnd_sort_val := null;
1296 l_group_val_01 := p_group_val_01 ;
1297 l_group_val_02 := p_group_val_02 ;
1298 if p_group_val_01 = ' ' then
1299 l_group_val_01 := null ;
1300 l_group_val_02 := null ;
1301 elsif p_group_val_02 = ' ' then
1302 l_group_val_02 := null ;
1303 end if ;
1304
1305
1306 END IF;
1307
1308 if p_rcd_typ_cd <> 'L' and g_subtrl_cnt = 0 and
1309 ben_ext_thread.g_ext_group_elmt1 is not null then
1310 open get_subtrl_cnt ;
1311 fetch get_subtrl_cnt into g_subtrl_cnt ;
1312 close get_subtrl_cnt ;
1313 end if ;
1314
1315 -- Get the plan type for ansi
1316 open get_pl_val ;
1317 fetch get_pl_val into l_pl_id ;
1318 close get_pl_val ;
1319
1320
1321 -- This loop will be executed for each record in the extract definition
1322 -- of a given record type (Header, Trailer)
1323 --
1324 FOR rcd IN ext_rcd_typ_c LOOP
1325 --
1326 l_ext_rcd_id := rcd.ext_rcd_id;
1327 l_ext_rcd_in_file_id := rcd.ext_rcd_in_file_id;
1328 l_rqd_elmt_available := 'Y';
1329 --
1330 -- Initialize array
1331 --
1332 ben_ext_fmt.g_val_tab := g_val_def;
1333 --
1334 FOR elmt IN rcd_elmt_c LOOP
1335 --
1336 l_rslt_elmt := null ;
1337 if g_debug then
1338 hr_utility.set_location('element '||elmt.short_name, 5);
1339 hr_utility.set_location('element type '||elmt.data_elmt_typ_cd, 5);
1340 end if;
1341 IF elmt.data_elmt_typ_cd in ( 'F','D','R') THEN
1342
1343 l_rslt_elmt := get_ht_elmt_data(p_ext_rslt_id => p_ext_rslt_id,
1344 p_data_elmt_typ_cd => elmt.data_elmt_typ_cd ,
1345 p_short_name => elmt.short_name ,
1346 p_ext_data_elmt_id => elmt.ext_data_elmt_id,
1347 p_frmt_mask_cd => elmt.frmt_mask_cd ,
1348 p_frmt_mask_lookup_cd => elmt.frmt_mask_lookup_cd,
1349 p_dflt_val => elmt.dflt_val ,
1350 p_data_elmt_rl => elmt.data_elmt_rl ,
1351 p_pl_id => l_pl_id ,
1352 p_business_group_id => p_business_group_id,
1353 p_effective_date => p_effective_date ,
1354 p_request_id => p_request_id ,
1355 p_ext_file_id => p_ext_file_id,
1356 p_rcd_typ_cd => p_rcd_typ_cd ,
1357 p_group_val_01 => l_group_val_01,
1358 p_group_val_02 => l_group_val_02,
1359 p_ext_per_bg_id => p_ext_per_bg_id ,
1360 p_String_val => elmt.String_val
1361 ) ;
1362
1363 if substr(elmt.frmt_mask_lookup_cd,1,1) = 'C' then
1364 l_rslt_elmt := ben_ext_fmt.apply_format_Function(l_rslt_elmt, elmt.frmt_mask_lookup_cd);
1365 end if ;
1366
1367 --
1368 ELSIF elmt.data_elmt_typ_cd = 'C' THEN
1369 l_rslt_elmt := get_calc_value
1370 (p_ext_rslt_id => p_ext_rslt_id,
1371 p_data_elmt_typ_cd => elmt.data_elmt_typ_cd ,
1372 p_short_name => elmt.short_name ,
1373 p_ext_data_elmt_id => elmt.ext_data_elmt_id,
1374 p_frmt_mask_cd => elmt.frmt_mask_cd ,
1375 p_frmt_mask_lookup_cd => elmt.frmt_mask_lookup_cd,
1376 p_dflt_val => elmt.dflt_val ,
1377 p_data_elmt_rl => elmt.data_elmt_rl ,
1378 p_pl_id => l_pl_id ,
1379 p_business_group_id => p_business_group_id,
1380 p_effective_date => p_effective_date ,
1381 p_request_id => p_request_id,
1382 p_ext_file_id => p_ext_file_id,
1383 p_calc => elmt.ttl_fnctn_cd ,
1384 p_rcd_typ_cd => p_rcd_typ_cd
1385 );
1386
1387 --
1388 ELSIF elmt.data_elmt_typ_cd = 'S' THEN
1389 --
1390 -- data element is a string:
1391 l_rslt_elmt := elmt.string_val;
1392 if g_debug then
1393 hr_utility.set_location(' mass lengh :'||elmt.max_length_num , 39);
1394 end if;
1395 IF elmt.max_length_num is not null THEN
1396 l_rslt_elmt := rPad(nvl(l_rslt_elmt,' '),elmt.max_length_num );
1397 if g_debug then
1398 hr_utility.set_location('ele :'||l_rslt_elmt , 39);
1399 end if;
1400 end if ;
1401 ELSIF elmt.data_elmt_typ_cd = 'T' THEN
1402
1403 ben_ext_smart_total.calc_smart_total
1404 (p_ext_rslt_id => p_ext_rslt_id,
1405 p_ttl_fnctn_cd => elmt.ttl_fnctn_cd,
1406 p_ttl_sum_ext_data_elmt_id => elmt.ttl_sum_ext_data_elmt_id,
1407 p_ttl_cond_ext_data_elmt_id => elmt.ttl_cond_ext_data_elmt_id,
1408 p_ext_data_elmt_id => elmt.ext_data_elmt_id,
1409 p_frmt_mask_cd => elmt.frmt_mask_cd,
1410 p_ext_file_id => p_ext_file_id,
1411 p_group_val_01 => p_group_val_01 ,
1412 p_group_val_02 => p_group_val_02 ,
1413 p_business_group_id => p_business_group_id,
1414 p_smart_total => l_rslt_elmt);
1415
1416 --- set fromat mask
1417
1418 ---
1419
1420 /*
1421
1422 l_rslt_elmt :=get_ht_elmt_data(p_ext_rslt_id => p_ext_rslt_id,
1423 p_data_elmt_typ_cd => elmt.data_elmt_typ_cd ,
1424 p_short_name => elmt.short_name ,
1425 p_ext_data_elmt_id => elmt.ext_data_elmt_id,
1426 p_frmt_mask_cd => elmt.frmt_mask_cd ,
1427 p_dflt_val => elmt.dflt_val ,
1428 p_data_elmt_rl => elmt.data_elmt_rl ,
1429 p_pl_id => l_pl_id ,
1430 p_business_group_id => p_business_group_id,
1431 p_effective_date => p_effective_date ,
1432 p_request_id => p_request_id,
1433 p_ext_file_id => p_ext_file_id,
1434 p_ttl_fnctn_cd => elmt.ttl_fnctn_cd ,
1435 p_ttl_sum_ext_data_elmt_id => elmt.ttl_sum_ext_data_elmt_id,
1436 p_ttl_cond_ext_data_elmt_id => elmt.ttl_cond_ext_data_elmt_id
1437 ) ;
1438
1439
1440 */
1441 --
1442 END IF;
1443 --
1444 -- if resulting data element is null, substitute it with
1445 -- default value
1446 --
1447 IF l_rslt_elmt is null then
1448 --
1449 l_rslt_elmt := elmt.dflt_val;
1450 --
1451 END IF;
1452 --
1453 -- truncate data element
1454 --
1455 IF elmt.max_length_num is not null THEN
1456 --
1457 l_rslt_elmt := SUBSTR(l_rslt_elmt, 1, elmt.max_length_num);
1458 --
1459 END IF;
1460 --
1461 if g_debug then
1462 hr_utility.set_location(' max ele :'||l_rslt_elmt , 39);
1463 end if;
1464 -- if data element is mandatory, but l_rslt_elmt is null then
1465 -- raise ht error
1466 -- when the element is required and not elemnt skip the record
1467 -- dont skip the entire header or details : tilak
1468
1469 --
1470 IF elmt.rqd_flag = 'Y' and (l_rslt_elmt is null) then
1471 --
1472 g_err_name := 'BEN_91887_EXT_RQD_DATA_ELMT';
1473 l_elmt_name := elmt.name ;
1474 l_error_message :=
1475 ben_ext_fmt.get_error_msg(to_number(substr(g_err_name, 5, 5)),g_err_name,l_elmt_name );
1476 -- when the elmt is null and required can not create a record , if the record also required
1477 -- then throw the error or throw the warning , the assumption is header allwasy has one record
1478 -- for a record definition
1479 if nvl(rcd.rqd_flag,'N') = 'Y' then
1480 write_error(p_err_num => to_number(substr(g_err_name, 5, 5)),
1481 p_err_name => l_error_message,
1482 p_typ_cd => 'F',
1483 p_person_id => null,
1484 p_request_id => fnd_global.conc_request_id,
1485 p_ext_rslt_id => p_ext_rslt_id,
1486 p_business_group_id => p_business_group_id
1487 );
1488 raise g_ht_error;
1489 else
1490
1491 write_error(p_err_num => to_number(substr(g_err_name, 5, 5)),
1492 p_err_name => l_error_message,
1493 p_typ_cd => 'W',
1494 p_person_id => null,
1495 p_request_id => fnd_global.conc_request_id,
1496 p_ext_rslt_id => p_ext_rslt_id,
1497 p_business_group_id => p_business_group_id
1498 );
1499
1500 end if ;
1501 l_rqd_elmt_available := 'N' ;
1502 exit ;
1503 -- raise g_ht_error;
1504 --
1505 END IF;
1506 --
1507 --val_tab(elmt.seq_num) := l_rslt_elmt;
1508 ben_ext_fmt.g_val_tab(elmt.seq_num) := l_rslt_elmt;
1509 --
1510 END LOOP;
1511 --
1512 if l_rqd_elmt_available = 'Y' then
1513 l_write_rcd := 'Y';
1514 --
1515 ben_ext_adv_conditions.data_elmt_in_rcd
1516 (p_ext_rcd_id => l_ext_rcd_id,
1517 p_exclude_this_rcd_flag => l_exclude_this_rcd_flag);
1518 --
1519 if l_exclude_this_rcd_flag = true then
1520 l_write_rcd := 'N';
1521 end if;
1522 --
1523 if l_write_rcd = 'Y' then
1524 ben_ext_adv_conditions.rcd_in_file
1525 (p_ext_rcd_in_file_id => rcd.ext_rcd_in_file_id,
1526 p_sprs_cd => rcd.sprs_cd,
1527 p_exclude_this_rcd_flag => l_exclude_this_rcd_flag);
1528 --
1529 if l_exclude_this_rcd_flag = true then
1530 l_write_rcd := 'N';
1531 end if;
1532 --
1533 end if;
1534 --
1535 if l_write_rcd = 'Y' then
1536 --
1537 -- call 'create ext detail api' here
1538 --
1539 ben_ext_rslt_dtl_api.create_ext_rslt_dtl
1540 (p_validate => false
1541 ,p_ext_rslt_dtl_id => l_ext_rslt_dtl_id
1542 ,p_prmy_sort_val => l_prmy_sort_val
1543 ,p_scnd_sort_val => l_scnd_sort_val
1544 ,p_trans_seq_num => l_trans_num
1545 ,p_rcrd_seq_num => rcd.seq_num
1546 ,p_ext_rslt_id => p_ext_rslt_id
1547 ,p_ext_rcd_id => l_ext_rcd_id
1548 ,p_person_id => l_person_id
1549 ,p_business_group_id => p_business_group_id
1550 ,p_val_01 => ben_ext_fmt.g_val_tab(1)
1551 ,p_val_02 => ben_ext_fmt.g_val_tab(2)
1552 ,p_val_03 => ben_ext_fmt.g_val_tab(3)
1553 ,p_val_04 => ben_ext_fmt.g_val_tab(4)
1554 ,p_val_05 => ben_ext_fmt.g_val_tab(5)
1555 ,p_val_06 => ben_ext_fmt.g_val_tab(6)
1556 ,p_val_07 => ben_ext_fmt.g_val_tab(7)
1557 ,p_val_08 => ben_ext_fmt.g_val_tab(8)
1558 ,p_val_09 => ben_ext_fmt.g_val_tab(9)
1559 ,p_val_10 => ben_ext_fmt.g_val_tab(10)
1560 ,p_val_11 => ben_ext_fmt.g_val_tab(11)
1561 ,p_val_12 => ben_ext_fmt.g_val_tab(12)
1562 ,p_val_13 => ben_ext_fmt.g_val_tab(13)
1563 ,p_val_14 => ben_ext_fmt.g_val_tab(14)
1564 ,p_val_15 => ben_ext_fmt.g_val_tab(15)
1565 ,p_val_16 => ben_ext_fmt.g_val_tab(16)
1566 ,p_val_17 => ben_ext_fmt.g_val_tab(17)
1567 ,p_val_18 => ben_ext_fmt.g_val_tab(18)
1568 ,p_val_19 => ben_ext_fmt.g_val_tab(19)
1569 ,p_val_20 => ben_ext_fmt.g_val_tab(20)
1570 ,p_val_21 => ben_ext_fmt.g_val_tab(21)
1571 ,p_val_22 => ben_ext_fmt.g_val_tab(22)
1572 ,p_val_23 => ben_ext_fmt.g_val_tab(23)
1573 ,p_val_24 => ben_ext_fmt.g_val_tab(24)
1574 ,p_val_25 => ben_ext_fmt.g_val_tab(25)
1575 ,p_val_26 => ben_ext_fmt.g_val_tab(26)
1576 ,p_val_27 => ben_ext_fmt.g_val_tab(27)
1577 ,p_val_28 => ben_ext_fmt.g_val_tab(28)
1578 ,p_val_29 => ben_ext_fmt.g_val_tab(29)
1579 ,p_val_30 => ben_ext_fmt.g_val_tab(30)
1580 ,p_val_31 => ben_ext_fmt.g_val_tab(31)
1581 ,p_val_32 => ben_ext_fmt.g_val_tab(32)
1582 ,p_val_33 => ben_ext_fmt.g_val_tab(33)
1583 ,p_val_34 => ben_ext_fmt.g_val_tab(34)
1584 ,p_val_35 => ben_ext_fmt.g_val_tab(35)
1585 ,p_val_36 => ben_ext_fmt.g_val_tab(36)
1586 ,p_val_37 => ben_ext_fmt.g_val_tab(37)
1587 ,p_val_38 => ben_ext_fmt.g_val_tab(38)
1588 ,p_val_39 => ben_ext_fmt.g_val_tab(39)
1589 ,p_val_40 => ben_ext_fmt.g_val_tab(40)
1590 ,p_val_41 => ben_ext_fmt.g_val_tab(41)
1591 ,p_val_42 => ben_ext_fmt.g_val_tab(42)
1592 ,p_val_43 => ben_ext_fmt.g_val_tab(43)
1593 ,p_val_44 => ben_ext_fmt.g_val_tab(44)
1594 ,p_val_45 => ben_ext_fmt.g_val_tab(45)
1595 ,p_val_46 => ben_ext_fmt.g_val_tab(46)
1596 ,p_val_47 => ben_ext_fmt.g_val_tab(47)
1597 ,p_val_48 => ben_ext_fmt.g_val_tab(48)
1598 ,p_val_49 => ben_ext_fmt.g_val_tab(49)
1599 ,p_val_50 => ben_ext_fmt.g_val_tab(50)
1600 ,p_val_51 => ben_ext_fmt.g_val_tab(51)
1601 ,p_val_52 => ben_ext_fmt.g_val_tab(52)
1602 ,p_val_53 => ben_ext_fmt.g_val_tab(53)
1603 ,p_val_54 => ben_ext_fmt.g_val_tab(54)
1604 ,p_val_55 => ben_ext_fmt.g_val_tab(55)
1605 ,p_val_56 => ben_ext_fmt.g_val_tab(56)
1606 ,p_val_57 => ben_ext_fmt.g_val_tab(57)
1607 ,p_val_58 => ben_ext_fmt.g_val_tab(58)
1608 ,p_val_59 => ben_ext_fmt.g_val_tab(59)
1609 ,p_val_60 => ben_ext_fmt.g_val_tab(60)
1610 ,p_val_61 => ben_ext_fmt.g_val_tab(61)
1611 ,p_val_62 => ben_ext_fmt.g_val_tab(62)
1612 ,p_val_63 => ben_ext_fmt.g_val_tab(63)
1613 ,p_val_64 => ben_ext_fmt.g_val_tab(64)
1614 ,p_val_65 => ben_ext_fmt.g_val_tab(65)
1615 ,p_val_66 => ben_ext_fmt.g_val_tab(66)
1616 ,p_val_67 => ben_ext_fmt.g_val_tab(67)
1617 ,p_val_68 => ben_ext_fmt.g_val_tab(68)
1618 ,p_val_69 => ben_ext_fmt.g_val_tab(69)
1619 ,p_val_70 => ben_ext_fmt.g_val_tab(70)
1620 ,p_val_71 => ben_ext_fmt.g_val_tab(71)
1621 ,p_val_72 => ben_ext_fmt.g_val_tab(72)
1622 ,p_val_73 => ben_ext_fmt.g_val_tab(73)
1623 ,p_val_74 => ben_ext_fmt.g_val_tab(74)
1624 ,p_val_75 => ben_ext_fmt.g_val_tab(75)
1625 ,p_val_76 => ben_ext_fmt.g_val_tab(76)
1626 ,p_val_77 => ben_ext_fmt.g_val_tab(77)
1627 ,p_val_78 => ben_ext_fmt.g_val_tab(78)
1628 ,p_val_79 => ben_ext_fmt.g_val_tab(79)
1629 ,p_val_80 => ben_ext_fmt.g_val_tab(80)
1630 ,p_val_81 => ben_ext_fmt.g_val_tab(81)
1631 ,p_val_82 => ben_ext_fmt.g_val_tab(82)
1632 ,p_val_83 => ben_ext_fmt.g_val_tab(83)
1633 ,p_val_84 => ben_ext_fmt.g_val_tab(84)
1634 ,p_val_85 => ben_ext_fmt.g_val_tab(85)
1635 ,p_val_86 => ben_ext_fmt.g_val_tab(86)
1636 ,p_val_87 => ben_ext_fmt.g_val_tab(87)
1637 ,p_val_88 => ben_ext_fmt.g_val_tab(88)
1638 ,p_val_89 => ben_ext_fmt.g_val_tab(89)
1639 ,p_val_90 => ben_ext_fmt.g_val_tab(90)
1640 ,p_val_91 => ben_ext_fmt.g_val_tab(91)
1641 ,p_val_92 => ben_ext_fmt.g_val_tab(92)
1642 ,p_val_93 => ben_ext_fmt.g_val_tab(93)
1643 ,p_val_94 => ben_ext_fmt.g_val_tab(94)
1644 ,p_val_95 => ben_ext_fmt.g_val_tab(95)
1645 ,p_val_96 => ben_ext_fmt.g_val_tab(96)
1646 ,p_val_97 => ben_ext_fmt.g_val_tab(97)
1647 ,p_val_98 => ben_ext_fmt.g_val_tab(98)
1648 ,p_val_99 => ben_ext_fmt.g_val_tab(99)
1649 ,p_val_100 => ben_ext_fmt.g_val_tab(100)
1650 ,p_val_101 => ben_ext_fmt.g_val_tab(101)
1651 ,p_val_102 => ben_ext_fmt.g_val_tab(102)
1652 ,p_val_103 => ben_ext_fmt.g_val_tab(103)
1653 ,p_val_104 => ben_ext_fmt.g_val_tab(104)
1654 ,p_val_105 => ben_ext_fmt.g_val_tab(105)
1655 ,p_val_106 => ben_ext_fmt.g_val_tab(106)
1656 ,p_val_107 => ben_ext_fmt.g_val_tab(107)
1657 ,p_val_108 => ben_ext_fmt.g_val_tab(108)
1658 ,p_val_109 => ben_ext_fmt.g_val_tab(109)
1659 ,p_val_110 => ben_ext_fmt.g_val_tab(110)
1660 ,p_val_111 => ben_ext_fmt.g_val_tab(111)
1661 ,p_val_112 => ben_ext_fmt.g_val_tab(112)
1662 ,p_val_113 => ben_ext_fmt.g_val_tab(113)
1663 ,p_val_114 => ben_ext_fmt.g_val_tab(114)
1664 ,p_val_115 => ben_ext_fmt.g_val_tab(115)
1665 ,p_val_116 => ben_ext_fmt.g_val_tab(116)
1666 ,p_val_117 => ben_ext_fmt.g_val_tab(117)
1667 ,p_val_118 => ben_ext_fmt.g_val_tab(118)
1668 ,p_val_119 => ben_ext_fmt.g_val_tab(119)
1669 ,p_val_120 => ben_ext_fmt.g_val_tab(120)
1670 ,p_val_121 => ben_ext_fmt.g_val_tab(121)
1671 ,p_val_122 => ben_ext_fmt.g_val_tab(122)
1672 ,p_val_123 => ben_ext_fmt.g_val_tab(123)
1673 ,p_val_124 => ben_ext_fmt.g_val_tab(124)
1674 ,p_val_125 => ben_ext_fmt.g_val_tab(125)
1675 ,p_val_126 => ben_ext_fmt.g_val_tab(126)
1676 ,p_val_127 => ben_ext_fmt.g_val_tab(127)
1677 ,p_val_128 => ben_ext_fmt.g_val_tab(128)
1678 ,p_val_129 => ben_ext_fmt.g_val_tab(129)
1679 ,p_val_130 => ben_ext_fmt.g_val_tab(130)
1680 ,p_val_131 => ben_ext_fmt.g_val_tab(131)
1681 ,p_val_132 => ben_ext_fmt.g_val_tab(132)
1682 ,p_val_133 => ben_ext_fmt.g_val_tab(133)
1683 ,p_val_134 => ben_ext_fmt.g_val_tab(134)
1684 ,p_val_135 => ben_ext_fmt.g_val_tab(135)
1685 ,p_val_136 => ben_ext_fmt.g_val_tab(136)
1686 ,p_val_137 => ben_ext_fmt.g_val_tab(137)
1687 ,p_val_138 => ben_ext_fmt.g_val_tab(138)
1688 ,p_val_139 => ben_ext_fmt.g_val_tab(139)
1689 ,p_val_140 => ben_ext_fmt.g_val_tab(140)
1690 ,p_val_141 => ben_ext_fmt.g_val_tab(141)
1691 ,p_val_142 => ben_ext_fmt.g_val_tab(142)
1692 ,p_val_143 => ben_ext_fmt.g_val_tab(143)
1693 ,p_val_144 => ben_ext_fmt.g_val_tab(144)
1694 ,p_val_145 => ben_ext_fmt.g_val_tab(145)
1695 ,p_val_146 => ben_ext_fmt.g_val_tab(146)
1696 ,p_val_147 => ben_ext_fmt.g_val_tab(147)
1697 ,p_val_148 => ben_ext_fmt.g_val_tab(148)
1698 ,p_val_149 => ben_ext_fmt.g_val_tab(149)
1699 ,p_val_150 => ben_ext_fmt.g_val_tab(150)
1700 ,p_val_151 => ben_ext_fmt.g_val_tab(151)
1701 ,p_val_152 => ben_ext_fmt.g_val_tab(152)
1702 ,p_val_153 => ben_ext_fmt.g_val_tab(153)
1703 ,p_val_154 => ben_ext_fmt.g_val_tab(154)
1704 ,p_val_155 => ben_ext_fmt.g_val_tab(155)
1705 ,p_val_156 => ben_ext_fmt.g_val_tab(156)
1706 ,p_val_157 => ben_ext_fmt.g_val_tab(157)
1707 ,p_val_158 => ben_ext_fmt.g_val_tab(158)
1708 ,p_val_159 => ben_ext_fmt.g_val_tab(159)
1709 ,p_val_160 => ben_ext_fmt.g_val_tab(160)
1710 ,p_val_161 => ben_ext_fmt.g_val_tab(161)
1711 ,p_val_162 => ben_ext_fmt.g_val_tab(162)
1712 ,p_val_163 => ben_ext_fmt.g_val_tab(163)
1713 ,p_val_164 => ben_ext_fmt.g_val_tab(164)
1714 ,p_val_165 => ben_ext_fmt.g_val_tab(165)
1715 ,p_val_166 => ben_ext_fmt.g_val_tab(166)
1716 ,p_val_167 => ben_ext_fmt.g_val_tab(167)
1717 ,p_val_168 => ben_ext_fmt.g_val_tab(168)
1718 ,p_val_169 => ben_ext_fmt.g_val_tab(169)
1719 ,p_val_170 => ben_ext_fmt.g_val_tab(170)
1720 ,p_val_171 => ben_ext_fmt.g_val_tab(171)
1721 ,p_val_172 => ben_ext_fmt.g_val_tab(172)
1722 ,p_val_173 => ben_ext_fmt.g_val_tab(173)
1723 ,p_val_174 => ben_ext_fmt.g_val_tab(174)
1724 ,p_val_175 => ben_ext_fmt.g_val_tab(175)
1725 ,p_val_176 => ben_ext_fmt.g_val_tab(176)
1726 ,p_val_177 => ben_ext_fmt.g_val_tab(177)
1727 ,p_val_178 => ben_ext_fmt.g_val_tab(178)
1728 ,p_val_179 => ben_ext_fmt.g_val_tab(179)
1729 ,p_val_180 => ben_ext_fmt.g_val_tab(180)
1730 ,p_val_181 => ben_ext_fmt.g_val_tab(181)
1731 ,p_val_182 => ben_ext_fmt.g_val_tab(182)
1732 ,p_val_183 => ben_ext_fmt.g_val_tab(183)
1733 ,p_val_184 => ben_ext_fmt.g_val_tab(184)
1734 ,p_val_185 => ben_ext_fmt.g_val_tab(185)
1735 ,p_val_186 => ben_ext_fmt.g_val_tab(186)
1736 ,p_val_187 => ben_ext_fmt.g_val_tab(187)
1737 ,p_val_188 => ben_ext_fmt.g_val_tab(188)
1738 ,p_val_189 => ben_ext_fmt.g_val_tab(189)
1739 ,p_val_190 => ben_ext_fmt.g_val_tab(190)
1740 ,p_val_191 => ben_ext_fmt.g_val_tab(191)
1741 ,p_val_192 => ben_ext_fmt.g_val_tab(192)
1742 ,p_val_193 => ben_ext_fmt.g_val_tab(193)
1743 ,p_val_194 => ben_ext_fmt.g_val_tab(194)
1744 ,p_val_195 => ben_ext_fmt.g_val_tab(195)
1745 ,p_val_196 => ben_ext_fmt.g_val_tab(196)
1746 ,p_val_197 => ben_ext_fmt.g_val_tab(197)
1747 ,p_val_198 => ben_ext_fmt.g_val_tab(198)
1748 ,p_val_199 => ben_ext_fmt.g_val_tab(199)
1749 ,p_val_200 => ben_ext_fmt.g_val_tab(200)
1750 ,p_val_201 => ben_ext_fmt.g_val_tab(201)
1751 ,p_val_202 => ben_ext_fmt.g_val_tab(202)
1752 ,p_val_203 => ben_ext_fmt.g_val_tab(203)
1753 ,p_val_204 => ben_ext_fmt.g_val_tab(204)
1754 ,p_val_205 => ben_ext_fmt.g_val_tab(205)
1755 ,p_val_206 => ben_ext_fmt.g_val_tab(206)
1756 ,p_val_207 => ben_ext_fmt.g_val_tab(207)
1757 ,p_val_208 => ben_ext_fmt.g_val_tab(208)
1758 ,p_val_209 => ben_ext_fmt.g_val_tab(209)
1759 ,p_val_210 => ben_ext_fmt.g_val_tab(210)
1760 ,p_val_211 => ben_ext_fmt.g_val_tab(211)
1761 ,p_val_212 => ben_ext_fmt.g_val_tab(212)
1762 ,p_val_213 => ben_ext_fmt.g_val_tab(213)
1763 ,p_val_214 => ben_ext_fmt.g_val_tab(214)
1764 ,p_val_215 => ben_ext_fmt.g_val_tab(215)
1765 ,p_val_216 => ben_ext_fmt.g_val_tab(216)
1766 ,p_val_217 => ben_ext_fmt.g_val_tab(217)
1767 ,p_val_218 => ben_ext_fmt.g_val_tab(218)
1768 ,p_val_219 => ben_ext_fmt.g_val_tab(219)
1769 ,p_val_220 => ben_ext_fmt.g_val_tab(220)
1770 ,p_val_221 => ben_ext_fmt.g_val_tab(221)
1771 ,p_val_222 => ben_ext_fmt.g_val_tab(222)
1772 ,p_val_223 => ben_ext_fmt.g_val_tab(223)
1773 ,p_val_224 => ben_ext_fmt.g_val_tab(224)
1774 ,p_val_225 => ben_ext_fmt.g_val_tab(225)
1775 ,p_val_226 => ben_ext_fmt.g_val_tab(226)
1776 ,p_val_227 => ben_ext_fmt.g_val_tab(227)
1777 ,p_val_228 => ben_ext_fmt.g_val_tab(228)
1778 ,p_val_229 => ben_ext_fmt.g_val_tab(229)
1779 ,p_val_230 => ben_ext_fmt.g_val_tab(230)
1780 ,p_val_231 => ben_ext_fmt.g_val_tab(231)
1781 ,p_val_232 => ben_ext_fmt.g_val_tab(232)
1782 ,p_val_233 => ben_ext_fmt.g_val_tab(233)
1783 ,p_val_234 => ben_ext_fmt.g_val_tab(234)
1784 ,p_val_235 => ben_ext_fmt.g_val_tab(235)
1785 ,p_val_236 => ben_ext_fmt.g_val_tab(236)
1786 ,p_val_237 => ben_ext_fmt.g_val_tab(237)
1787 ,p_val_238 => ben_ext_fmt.g_val_tab(238)
1788 ,p_val_239 => ben_ext_fmt.g_val_tab(239)
1789 ,p_val_240 => ben_ext_fmt.g_val_tab(240)
1790 ,p_val_241 => ben_ext_fmt.g_val_tab(241)
1791 ,p_val_242 => ben_ext_fmt.g_val_tab(242)
1792 ,p_val_243 => ben_ext_fmt.g_val_tab(243)
1793 ,p_val_244 => ben_ext_fmt.g_val_tab(244)
1794 ,p_val_245 => ben_ext_fmt.g_val_tab(245)
1795 ,p_val_246 => ben_ext_fmt.g_val_tab(246)
1796 ,p_val_247 => ben_ext_fmt.g_val_tab(247)
1797 ,p_val_248 => ben_ext_fmt.g_val_tab(248)
1798 ,p_val_249 => ben_ext_fmt.g_val_tab(249)
1799 ,p_val_250 => ben_ext_fmt.g_val_tab(250)
1800 ,p_val_251 => ben_ext_fmt.g_val_tab(251)
1801 ,p_val_252 => ben_ext_fmt.g_val_tab(252)
1802 ,p_val_253 => ben_ext_fmt.g_val_tab(253)
1803 ,p_val_254 => ben_ext_fmt.g_val_tab(254)
1804 ,p_val_255 => ben_ext_fmt.g_val_tab(255)
1805 ,p_val_256 => ben_ext_fmt.g_val_tab(256)
1806 ,p_val_257 => ben_ext_fmt.g_val_tab(257)
1807 ,p_val_258 => ben_ext_fmt.g_val_tab(258)
1808 ,p_val_259 => ben_ext_fmt.g_val_tab(259)
1809 ,p_val_260 => ben_ext_fmt.g_val_tab(260)
1810 ,p_val_261 => ben_ext_fmt.g_val_tab(261)
1811 ,p_val_262 => ben_ext_fmt.g_val_tab(262)
1812 ,p_val_263 => ben_ext_fmt.g_val_tab(263)
1813 ,p_val_264 => ben_ext_fmt.g_val_tab(264)
1814 ,p_val_265 => ben_ext_fmt.g_val_tab(265)
1815 ,p_val_266 => ben_ext_fmt.g_val_tab(266)
1816 ,p_val_267 => ben_ext_fmt.g_val_tab(267)
1817 ,p_val_268 => ben_ext_fmt.g_val_tab(268)
1818 ,p_val_269 => ben_ext_fmt.g_val_tab(269)
1819 ,p_val_270 => ben_ext_fmt.g_val_tab(270)
1820 ,p_val_271 => ben_ext_fmt.g_val_tab(271)
1821 ,p_val_272 => ben_ext_fmt.g_val_tab(272)
1822 ,p_val_273 => ben_ext_fmt.g_val_tab(273)
1823 ,p_val_274 => ben_ext_fmt.g_val_tab(274)
1824 ,p_val_275 => ben_ext_fmt.g_val_tab(275)
1825 ,p_val_276 => ben_ext_fmt.g_val_tab(276)
1826 ,p_val_277 => ben_ext_fmt.g_val_tab(277)
1827 ,p_val_278 => ben_ext_fmt.g_val_tab(278)
1828 ,p_val_279 => ben_ext_fmt.g_val_tab(279)
1829 ,p_val_280 => ben_ext_fmt.g_val_tab(280)
1830 ,p_val_281 => ben_ext_fmt.g_val_tab(281)
1831 ,p_val_282 => ben_ext_fmt.g_val_tab(282)
1832 ,p_val_283 => ben_ext_fmt.g_val_tab(283)
1833 ,p_val_284 => ben_ext_fmt.g_val_tab(284)
1834 ,p_val_285 => ben_ext_fmt.g_val_tab(285)
1835 ,p_val_286 => ben_ext_fmt.g_val_tab(286)
1836 ,p_val_287 => ben_ext_fmt.g_val_tab(287)
1837 ,p_val_288 => ben_ext_fmt.g_val_tab(288)
1838 ,p_val_289 => ben_ext_fmt.g_val_tab(289)
1839 ,p_val_290 => ben_ext_fmt.g_val_tab(290)
1840 ,p_val_291 => ben_ext_fmt.g_val_tab(291)
1841 ,p_val_292 => ben_ext_fmt.g_val_tab(292)
1842 ,p_val_293 => ben_ext_fmt.g_val_tab(293)
1843 ,p_val_294 => ben_ext_fmt.g_val_tab(294)
1844 ,p_val_295 => ben_ext_fmt.g_val_tab(295)
1845 ,p_val_296 => ben_ext_fmt.g_val_tab(296)
1846 ,p_val_297 => ben_ext_fmt.g_val_tab(297)
1847 ,p_val_298 => ben_ext_fmt.g_val_tab(298)
1848 ,p_val_299 => ben_ext_fmt.g_val_tab(299)
1849 ,p_val_300 => ben_ext_fmt.g_val_tab(300)
1850 ,p_group_val_01 => l_group_val_01
1851 ,p_group_val_02 => l_group_val_02
1852 ,p_program_application_id => fnd_global.prog_appl_id
1853 ,p_program_id => fnd_global.conc_program_id
1854 ,p_program_update_date => sysdate
1855 ,p_request_id => fnd_global.conc_request_id
1856 ,p_object_version_number => l_object_version_number
1857 ,p_ext_per_bg_id => p_ext_per_bg_id
1858 ,p_ext_rcd_in_file_id => l_ext_rcd_in_file_id
1859 );
1860 --
1861 end if;
1862 end if ;
1863 --
1864 END LOOP;
1865 --
1866 commit;
1867 --
1868 if g_debug then
1869 hr_utility.set_location ('Exiting '||l_proc,15);
1870 end if;
1871 --
1872 exception
1873 --
1874 when g_ht_error then
1875
1876 rollback to head_trail;
1877 l_error_message :=
1878 ben_ext_fmt.get_error_msg(to_number(substr(g_err_name, 5, 5)),g_err_name,l_elmt_name );
1879 write_error(p_err_num => to_number(substr(g_err_name, 5, 5)),
1880 p_err_name => l_error_message,
1881 p_typ_cd => 'F',
1882 p_person_id => null,
1883 p_request_id => fnd_global.conc_request_id,
1884 p_ext_rslt_id => p_ext_rslt_id,
1885 p_business_group_id => p_business_group_id
1886 );
1887 raise ben_ext_thread.g_job_failure_error;
1888 --
1889 when others then
1890
1891 rollback to head_trail;
1892 raise; -- such that the calling pgm will handle the rest.
1893 --
1894 end process_ext_ht_recs;
1895 --
1896
1897
1898
1899 Procedure process_subtrailer(p_ext_rslt_id in number,
1900 p_ext_file_id in number,
1901 p_ext_typ_cd in varchar2,
1902 p_rcd_typ_cd in varchar2,
1903 p_business_group_id in number,
1904 p_effective_date in date,
1905 p_request_id in number default null,
1906 p_ext_group_elmt1 in varchar2,
1907 p_ext_group_elmt2 in varchar2,
1908 p_ext_crit_prfl_id in number default null)
1909 IS
1910 --
1911 l_proc varchar2(72);
1912 --
1913 cursor get_subhdr_group is
1914 select distinct
1915 xrd.group_val_01,
1916 xrd.group_val_02,
1917 nvl(xrd.ext_per_bg_id,-1) ext_per_bg_id
1918 from ben_Ext_rslt_dtl xrd,
1919 ben_ext_rcd rcd,
1920 ben_ext_rcd_in_file erf
1921 where xrd.ext_rslt_id = p_ext_rslt_id
1922 and xrd.ext_rcd_id = erf.ext_rcd_id
1923 and erf.ext_file_id = p_ext_file_id
1924 and rcd.ext_rcd_id = erf.ext_rcd_id
1925 and rcd.rcd_type_cd = 'S'
1926 and ltrim(xrd.group_val_01) is not null ;
1927
1928 --
1929 l_ext_per_bg_id number ;
1930 begin
1931 --
1932 g_debug := hr_utility.debug_enabled;
1933 if g_debug then
1934 l_proc := g_package||'.process_subtrailer';
1935 hr_utility.set_location('Entering'||l_proc, 5);
1936 end if;
1937
1938 if p_ext_group_elmt1 is null then
1939 process_ext_ht_recs
1940 (p_ext_rslt_id => p_ext_rslt_id,
1941 p_ext_file_id => p_ext_file_id,
1942 p_ext_typ_cd => p_ext_typ_cd,
1943 p_rcd_typ_cd => p_rcd_typ_cd,
1944 p_business_group_id => p_business_group_id,
1945 p_effective_date => p_effective_date,
1946 p_request_id => p_request_id,
1947 p_ext_crit_prfl_id => p_ext_crit_prfl_id ,
1948 p_ext_per_bg_id => p_business_group_id
1949 );
1950 else
1951
1952 for i in get_subhdr_group Loop
1953
1954 l_ext_per_bg_id := i.ext_per_bg_id ;
1955 if i.ext_per_bg_id = -1 then
1956 l_ext_per_bg_id := null ;
1957 end if ;
1958
1959
1960 process_ext_ht_recs
1961 (p_ext_rslt_id => p_ext_rslt_id,
1962 p_ext_file_id => p_ext_file_id,
1963 p_ext_typ_cd => p_ext_typ_cd,
1964 p_rcd_typ_cd => p_rcd_typ_cd,
1965 p_business_group_id => p_business_group_id,
1966 p_effective_date => p_effective_date,
1967 p_group_val_01 => i.group_val_01,
1968 p_group_val_02 => i.group_val_02,
1969 p_request_id => p_request_id,
1970 p_ext_crit_prfl_id => p_ext_crit_prfl_id ,
1971 p_ext_per_bg_id => l_ext_per_bg_id );
1972
1973 end Loop ;
1974
1975 end if ;
1976
1977
1978 --
1979 if g_debug then
1980 hr_utility.set_location ('Exiting '||l_proc,15);
1981 end if;
1982 --
1983 --
1984 end process_subtrailer;
1985
1986
1987
1988
1989 -- ----------------------------------------------------------------------------
1990 -- |--------------------< check_all_threads_finished >------------------------|
1991 -- ----------------------------------------------------------------------------
1992 --
1993 Procedure check_all_threads_finished
1994 (p_effective_date in date
1995 ,p_business_group_id in number
1996 ,p_data_typ_cd in varchar2
1997 ,p_ext_typ_cd in varchar2
1998 ,p_ext_crit_prfl_id in number
1999 ,p_ext_rslt_id in number
2000 ,p_request_id in number
2001 ,p_ext_file_id in number
2002 ,p_ext_strt_dt in date
2003 ,p_ext_end_dt in date
2004 ,p_master_process_flag in varchar2
2005 ) is
2006 --
2007 l_proc varchar2(80);
2008 l_no_threads boolean := true;
2009 l_globals_filled boolean;
2010 l_dummy varchar2(1);
2011 l_count binary_integer;
2012 l_xrs_object_version_number number;
2013 l_error_cd hr_lookups.lookup_code%TYPE; -- UTF8 varchar2(80);
2014 --
2015 cursor c_threads(p_request_id number) is
2016 select null
2017 from fnd_concurrent_requests fnd
2018 where fnd.phase_code <> 'C'
2019 and fnd.request_id = p_request_id;
2020 --
2021 cursor get_hdr_cnt is
2022 select count(*)
2023 from ben_ext_rcd_in_file fil, ben_ext_rcd rcd
2024 where fil.ext_rcd_id = rcd.ext_rcd_id
2025 and fil.ext_file_id = p_ext_file_id
2026 and rcd.rcd_type_cd = 'H';
2027 --
2028 cursor get_trl_cnt is
2029 select count(*)
2030 from ben_ext_rcd_in_file fil, ben_ext_rcd rcd
2031 where fil.ext_rcd_id = rcd.ext_rcd_id
2032 and fil.ext_file_id = p_ext_file_id
2033 and rcd.rcd_type_cd = 'T';
2034 --
2035
2036 cursor get_subhdr_cnt is
2037 select count(*)
2038 from ben_Ext_rslt_dtl xrd,
2039 ben_ext_rcd rcd,
2040 ben_ext_rcd_in_file erf
2041 where xrd.ext_rslt_id = p_ext_rslt_id
2042 and xrd.ext_rcd_id = erf.ext_rcd_id
2043 and xrd.ext_rcd_in_file_id = erf.ext_rcd_in_file_id
2044 and erf.ext_file_id = p_ext_file_id
2045 and rcd.ext_rcd_id = erf.ext_rcd_id
2046 and erf.hide_flag = 'N'
2047 and rcd.rcd_type_cd = 'S' ;
2048
2049 --
2050
2051 cursor get_dtl_cnt is
2052 select count(*)
2053 from ben_ext_rslt_dtl xrd , ben_ext_rcd_in_file erf
2054 where xrd.ext_rslt_id = p_ext_rslt_id
2055 and xrd.ext_rcd_id = erf.ext_rcd_id
2056 and xrd.ext_rcd_in_file_id = erf.ext_rcd_in_file_id
2057 and erf.ext_file_id = p_ext_file_id
2058 and erf.hide_flag = 'N'
2059 and person_id not in (0, 999999999999) ;
2060
2061 -- select count(*)
2062 -- from ben_ext_rslt_dtl xrd
2063 -- where xrd.ext_rslt_id = p_ext_rslt_id;
2064 --
2065 cursor get_per_cnt is
2066 select count(distinct person_id)
2067 from ben_ext_rslt_dtl xrd
2068 where xrd.ext_rslt_id = p_ext_rslt_id
2069 and person_id not in (0, 999999999999);
2070 --
2071 cursor get_err_cnt is
2072 select count(*)
2073 from ben_ext_rslt_err err
2074 where err.ext_rslt_id = p_ext_rslt_id;
2075 --
2076 begin
2077 --
2078 if g_debug then
2079 l_proc := g_package||'.check_all_threads_finished';
2080 hr_utility.set_location ('Entering '||l_proc,5);
2081 end if;
2082 --
2083 if g_num_processes <> 0 then
2084 --
2085 while l_no_threads loop
2086 --
2087 l_no_threads := false;
2088 for l_count in 1..g_num_processes loop
2089 --
2090 open c_threads(g_processes_rec(l_count));
2091 fetch c_threads into l_dummy;
2092 if c_threads%found then
2093 --
2094 -- Slave is still running
2095 --
2096 l_no_threads := true;
2097 close c_threads;
2098 exit;
2099 end if;
2100 close c_threads;
2101 --
2102 end loop;
2103 --
2104 -- To prevent over polling of fnd_concurrent_requests
2105 -- like all ben batch processes sleep for a while.
2106 --
2107 If (l_no_threads) then
2108 dbms_lock.sleep(5);
2109 End if;
2110 --
2111 end loop;
2112 --
2113 end if;
2114 --
2115 -- Log process information
2116 -- This is master specific only
2117 --
2118 if p_master_process_flag = 'Y' then
2119 --
2120 open get_dtl_cnt;
2121 fetch get_dtl_cnt into g_dtl_cnt;
2122 close get_dtl_cnt;
2123 --
2124 open get_hdr_cnt;
2125 fetch get_hdr_cnt into g_hdr_cnt;
2126 close get_hdr_cnt;
2127 --
2128 open get_trl_cnt;
2129 fetch get_trl_cnt into g_trl_cnt;
2130 close get_trl_cnt;
2131 --
2132
2133 open get_subhdr_cnt;
2134 fetch get_subhdr_cnt into g_subhdr_cnt;
2135 close get_subhdr_cnt;
2136 --
2137 open get_per_cnt;
2138 fetch get_per_cnt into g_per_cnt;
2139 close get_per_cnt;
2140 --
2141 open get_err_cnt;
2142 fetch get_err_cnt into g_err_cnt;
2143 close get_err_cnt;
2144 --
2145 g_rec_cnt := g_dtl_cnt + g_hdr_cnt + g_trl_cnt + g_subhdr_cnt ;
2146 --
2147 End if;
2148 --
2149 if g_debug then
2150 hr_utility.set_location ('Exiting '||l_proc,15);
2151 end if;
2152 --
2153 end check_all_threads_finished;
2154 --
2155 --
2156 -- =======================================================================
2157 -- <<do_multithread>>
2158 -- -----------------------------------------------------------------------
2159 -- This is the main batch procedure to be called from the concurrent manager
2160 -- or interactively to start extract.
2161 --
2162 -- ========================================================================
2163 procedure do_multithread
2164 (errbuf out nocopy varchar2
2165 ,retcode out nocopy number
2166 ,p_benefit_action_id in number
2167 ,p_ext_dfn_id in number
2168 ,p_thread_id in number
2169 ,p_effective_date in varchar2
2170 ,p_business_group_id in number
2171 ,p_data_typ_cd in varchar2
2172 ,p_ext_typ_cd in varchar2
2173 ,p_ext_crit_prfl_id in number
2174 ,p_ext_rslt_id in number
2175 ,p_ext_file_id in number
2176 ,p_ext_strt_dt in varchar2
2177 ,p_ext_end_dt in varchar2
2178 ,p_prmy_sort_cd in varchar2
2179 ,p_scnd_sort_cd in varchar2
2180 ,p_output_name in varchar2
2181 ,p_apnd_rqst_id_flag in varchar2
2182 ,p_request_id in number
2183 ,p_use_eff_dt_for_chgs_flag in varchar2
2184 ,p_master_process_flag in varchar2
2185 ,p_eff_start_date in varchar2
2186 ,p_eff_end_date in varchar2
2187 ,p_act_start_date in varchar2
2188 ,p_act_end_date in varchar2
2189 ,p_penserv_mode in varchar2
2190 ) is
2191 --
2192 -- Local variable declaration
2193 --
2194 l_proc varchar2(80);
2195 l_range_id ben_batch_ranges.range_id%type;
2196 l_start_person_action_id number := 0;
2197 l_end_person_action_id number := 0;
2198 l_xrs_object_version_number number;
2199 l_line number := 0;
2200 l_threads number;
2201 l_chunk_size number;
2202 l_effective_date date;
2203 l_ext_strt_dt date;
2204 l_ext_end_dt date;
2205 l_use_eff_dt_for_chgs_flag ben_ext_dfn.use_eff_dt_for_chgs_flag%TYPE; -- UTF8 varchar2(30);
2206 l_failure_in_other_thread boolean := false;
2207 --
2208 -- Cursors declaration
2209 --
2210 cursor c_range_thread is
2211 select ran.range_id
2212 ,ran.starting_person_action_id
2213 ,ran.ending_person_action_id
2214 from ben_batch_ranges ran
2215 where ran.range_status_cd = 'U'
2216 and ran.BENEFIT_ACTION_ID = P_BENEFIT_ACTION_ID
2217 and rownum < 2
2218 for update of ran.range_status_cd;
2219 --
2220 cursor c_range_err is
2221 select 1
2222 from ben_batch_ranges ran
2223 where ran.range_status_cd = 'E'
2224 and ran.BENEFIT_ACTION_ID = P_BENEFIT_ACTION_ID;
2225 --
2226 l_dummy number;
2227 l_dummy_c varchar2(1) ;
2228 l_status integer;
2229 -- l_value1 varchar2(20); Not Used
2230 -- l_value2 varchar2(20); Not Used
2231 l_commit number;
2232 --
2233 -- decide the change event source forevery thread
2234 -- Change event source type
2235 --
2236 cursor c_celt(p_type varchar2) is
2237 select 'X'
2238 from ben_ext_crit_typ xct
2239 ,ben_Ext_crit_val xcv
2240 where xct.ext_crit_prfl_id = p_ext_crit_prfl_id
2241 and xct.crit_typ_cd = p_type
2242 and xct.ext_crit_typ_id = xcv.ext_crit_typ_id ;
2243 --
2244
2245
2246 Begin
2247 --
2248 g_debug := hr_utility.debug_enabled;
2249 if g_debug then
2250 l_proc := g_package||'.do_multithread';
2251 hr_utility.set_location ('Entering '||l_proc,5);
2252 end if;
2253 g_ext_dfn_id := p_ext_dfn_id;
2254 g_ext_rslt_id := p_ext_rslt_id;
2255 --
2256 l_effective_date := to_date(p_effective_date, 'YYYY/MM/DD HH24:MI:SS');
2257 l_effective_date := to_date(to_char(trunc(l_effective_date), 'DD/MM/RRRR'),
2258 'DD/MM/RRRR');
2259 --
2260 --
2261 l_ext_strt_dt := to_date(p_ext_strt_dt, 'YYYY/MM/DD HH24:MI:SS');
2262 l_ext_strt_dt := to_date(to_char(trunc(l_ext_strt_dt), 'DD/MM/RRRR'),
2263 'DD/MM/RRRR');
2264 --
2265 l_ext_end_dt := to_date(p_ext_end_dt, 'YYYY/MM/DD HH24:MI:SS');
2266 l_ext_end_dt := to_date(to_char(trunc(l_ext_end_dt), 'DD/MM/RRRR'),
2267 'DD/MM/RRRR');
2268
2269
2270 g_effective_start_date := to_date(p_eff_start_date, 'YYYY/MM/DD HH24:MI:SS');
2271 g_effective_start_date := to_date(to_char(trunc(g_effective_start_date), 'DD/MM/RRRR'),
2272 'DD/MM/RRRR');
2273
2274 g_effective_end_date := to_date(p_eff_end_date, 'YYYY/MM/DD HH24:MI:SS');
2275 g_effective_end_date := to_date(to_char(trunc(g_effective_end_date), 'DD/MM/RRRR'),
2276 'DD/MM/RRRR');
2277
2278
2279
2280 g_actual_start_date := to_date(p_act_start_date, 'YYYY/MM/DD HH24:MI:SS');
2281 g_actual_start_date := to_date(to_char(trunc(g_actual_start_date), 'DD/MM/RRRR'),
2282 'DD/MM/RRRR');
2283
2284 g_actual_end_date := to_date(p_act_end_date, 'YYYY/MM/DD HH24:MI:SS');
2285 g_actual_end_date := to_date(to_char(trunc(g_actual_end_date), 'DD/MM/RRRR'),
2286 'DD/MM/RRRR');
2287
2288
2289 --
2290 -- load the fnd_session table in case a rule dbi needs it.
2291 --
2292 dt_fndate.change_ses_date
2293 (p_ses_date => l_effective_date,
2294 p_commit => l_commit);
2295 --
2296 l_line := 2;
2297 --
2298 benutils.get_parameter
2299 (p_business_group_id => p_business_group_id
2300 ,p_batch_exe_cd => 'BENXTRCT'
2301 ,p_threads => l_threads
2302 ,p_chunk_size => l_chunk_size
2303 ,p_max_errors => g_max_errors_allowed);
2304 --
2305 --
2306 -- MH moved call to thread level (ben_ext_thread.do_multithread)
2307 -- rather than chunk level to minimize
2308 -- memory consumption
2309 --
2310 -- Determine extract Levels
2311 --
2312 ben_extract.set_ext_lvls
2313 (p_ext_file_id => p_ext_file_id
2314 ,p_business_group_id => p_business_group_id
2315 );
2316 --
2317 -- Setup record and required level tables
2318 --
2319 ben_extract.setup_rcd_typ_lvl
2320 (p_ext_file_id => p_ext_file_id
2321 );
2322
2323 --
2324 -- decide the source for the change event from the change event log
2325 g_chg_ext_from_ben := 'N' ;
2326 g_chg_ext_from_pay := 'N' ;
2327
2328 if p_data_typ_cd = 'C' and p_ext_crit_prfl_id is not null then
2329 open c_celt ('CPE') ;
2330 fetch c_celt into l_dummy_c ;
2331 if c_celt%found then
2332 g_chg_ext_from_pay := 'Y' ;
2333 else
2334 g_chg_ext_from_ben := 'Y' ;
2335 end if ;
2336 close c_celt ;
2337
2338 open c_celt ('CCE') ;
2339 fetch c_celt into l_dummy_c ;
2340 if c_celt%found then
2341 g_chg_ext_from_ben := 'Y' ;
2342 end if ;
2343 close c_celt ;
2344
2345 hr_utility.set_location (' thread CELT ben/pay ' || g_chg_ext_from_ben || ' / ' || g_chg_ext_from_pay, 99 ) ;
2346 end if ;
2347 --
2348
2349 --
2350 Loop
2351 --
2352 open c_range_err;
2353 fetch c_range_err into l_dummy;
2354 if c_range_err%found then
2355 l_failure_in_other_thread := TRUE;
2356 close c_range_err;
2357 exit;
2358 end if;
2359 close c_range_err;
2360 --
2361 open c_range_thread;
2362 fetch c_range_thread
2363 into l_range_id,l_start_person_action_id,l_end_person_action_id;
2364 Exit when c_range_thread%notfound;
2365 --RCHASE 115.59 - move update within cursor context.
2366 --
2367 l_line := 3;
2368 --
2369 update ben_batch_ranges ran set ran.range_status_cd = 'P'
2370 where ran.range_id = l_range_id;
2371 --
2372 commit;
2373 --
2374 close c_range_thread;
2375 --
2376 l_line := 4;
2377 --
2378 ben_extract.Xtrct_skltn
2379 (p_ext_dfn_id => p_ext_dfn_id
2380 ,p_business_group_id => p_business_group_id
2381 ,p_effective_date => l_effective_date
2382 ,p_benefit_action_id => p_benefit_action_id
2383 ,p_range_id => l_range_id
2384 ,p_start_person_action_id => l_start_person_action_id
2385 ,p_end_person_action_id => l_end_person_action_id
2386 ,p_data_typ_cd => p_data_typ_cd
2387 ,p_ext_typ_cd => p_ext_typ_cd
2388 ,p_ext_crit_prfl_id => p_ext_crit_prfl_id
2389 ,p_ext_rslt_id => p_ext_rslt_id
2390 ,p_ext_file_id => p_ext_file_id
2391 ,p_ext_strt_dt => l_ext_strt_dt
2392 ,p_ext_end_dt => l_ext_end_dt
2393 ,p_prmy_sort_cd => p_prmy_sort_cd
2394 ,p_scnd_sort_cd => p_scnd_sort_cd
2395 ,p_request_id => p_request_id
2396 ,p_use_eff_dt_for_chgs_flag => p_use_eff_dt_for_chgs_flag
2397 ,p_penserv_mode => p_penserv_mode ---- vkodedal changes for penserver 30-Apr-2008
2398 );
2399 --
2400 l_line := 5;
2401 --
2402 End loop;
2403 --
2404 l_line := 6;
2405 --
2406 -- halt all other threads when job failure.
2407 if l_failure_in_other_thread then
2408 ben_ext_thread.g_err_num := 92184;
2409 ben_ext_thread.g_err_name := 'BEN_92184_THREAD_HALTED';
2410 raise g_job_failure_error;
2411 end if;
2412 --
2413 l_line := 7;
2414 --
2415 if fnd_global.conc_request_id <> -1 then
2416 fnd_message.set_name('BEN', 'BEN_92190_THREAD_LABEL');
2417 fnd_file.put_line(fnd_file.log, fnd_message.get || ' ' ||to_char(p_thread_id));
2418 fnd_file.put_line(fnd_file.log, ' ');
2419 if p_master_process_flag <> 'Y' then
2420 fnd_message.set_name('BEN', 'BEN_92185_THREAD_SUCCESS');
2421 fnd_file.put_line(fnd_file.log, fnd_message.get);
2422 fnd_file.put_line(fnd_file.log, ' ');
2423 end if;
2424 end if;
2425 --
2426 if g_debug then
2427 hr_utility.set_location ('Exiting '||l_proc,15);
2428 end if;
2429 --
2430 Exception
2431 --
2432 when g_job_failure_error then
2433 --
2434 -- this will halt all other threads.
2435 update ben_batch_ranges
2436 set range_status_cd = 'E'
2437 where range_id = l_range_id;
2438 --
2439 -- write to the extract error table, so error will be reported
2440 -- on the error report and viewed on the extract result form.
2441 if ben_ext_thread.g_err_num <> 92184 then --don't write if halt warning.
2442 write_error(p_err_num => ben_ext_thread.g_err_num,
2443 p_err_name => null , --ben_ext_thread.g_err_name,
2444 p_typ_cd => 'F',
2445 p_person_id => null,
2446 p_request_id => p_request_id,
2447 p_ext_rslt_id => p_ext_rslt_id,
2448 p_business_group_id => p_business_group_id
2449 );
2450 commit;
2451 end if;
2452 --
2453 if fnd_global.conc_request_id <> -1 then
2454 --
2455 -- write end of thread statistics which shows totals of what was
2456 -- processed
2457 fnd_message.set_name('BEN', 'BEN_92190_THREAD_LABEL');
2458 fnd_file.put_line(fnd_file.log, fnd_message.get || ' ' ||to_char(p_thread_id));
2459 --
2460 -- write the error message to the log file.
2461 --
2462 if ben_ext_thread.g_err_num <> 92184 then
2463 fnd_message.set_name('BEN', 'BEN_92186_THREAD_FAILURE');
2464 fnd_file.put_line(fnd_file.log, fnd_message.get);
2465 fnd_file.put_line(fnd_file.log, ' ');
2466 end if;
2467 fnd_message.set_name('BEN', ben_ext_thread.g_err_name);
2468 fnd_file.put_line(fnd_file.log, fnd_message.get);
2469 --
2470 -- if slave process, we are done. If master process, raise job failure in
2471 -- calling program (ben_ext_thread.process)
2472 --
2473 end if;
2474 --
2475 if p_master_process_flag = 'Y' then
2476 raise;
2477 else -- slave
2478 fnd_message.raise_error;
2479 end if;
2480
2481
2482 when others then
2483 --
2484 -- this will halt all other threads.
2485 --
2486 update ben_batch_ranges
2487 set range_status_cd = 'E'
2488 where range_id = l_range_id;
2489 --
2490 fnd_message.set_name('BEN', 'BEN_92190_THREAD_LABEL');
2491 fnd_file.put_line(fnd_file.log, fnd_message.get || ' ' ||to_char(p_thread_id));
2492 -- if slave process, we are done. If master process, raise job failure in
2493 -- calling program (ben_ext_thread.process)
2494 --
2495 if p_master_process_flag = 'Y' then
2496 raise;
2497 else -- slave
2498 write_error(p_err_num => null,
2499 p_err_name => substr(sqlerrm, 1, 200),
2500 p_typ_cd => 'F',
2501 p_person_id => null,
2502 p_request_id => p_request_id,
2503 p_ext_rslt_id => p_ext_rslt_id,
2504 p_business_group_id => p_business_group_id
2505 );
2506 --
2507 commit;
2508 --
2509 if fnd_global.conc_request_id <> -1 then
2510 fnd_message.set_name('BEN', 'BEN_92186_THREAD_FAILURE');
2511 fnd_file.put_line(fnd_file.log, fnd_message.get);
2512 fnd_file.put_line(fnd_file.log, ' ');
2513 fnd_message.set_name('PER', 'FFU10_GENERAL_ORACLE_ERROR');
2514 fnd_message.set_token('2', substr(sqlerrm, 1, 200));
2515 fnd_file.put_line(fnd_file.log, fnd_message.get);
2516 fnd_message.raise_error;
2517 end if;
2518 --
2519 end if;
2520 --
2521 end do_multithread;
2522 --
2523 -- =======================================================================
2524 -- <<Procedure:Initialize_Globals>>
2525 -- -----------------------------------------------------------------------
2526 -- -----------------------------------------------------------------------
2527 -- This is procedure initializes all globals in the pkh.
2528 -- ========================================================================
2529 --
2530 procedure initialize_globals is
2531 --
2532 --
2533 -- Local variable declaration
2534 --
2535 l_proc varchar2(80);
2536 --
2537 begin
2538 --
2539 if g_debug then
2540 l_proc := g_package||'.initialize_globals';
2541 hr_utility.set_location ('Entering '||l_proc,5);
2542 end if;
2543 --
2544 for i in 1..g_processes_rec.count loop
2545 if g_processes_rec.exists(i) then
2546 g_processes_rec(i) := null;
2547 end if;
2548 end loop;
2549 --
2550 g_max_errors_allowed := 0;
2551 g_num_processes := 0;
2552 g_err_name := null;
2553 g_err_num := null;
2554 g_ext_strt_dt := null;
2555 g_ext_end_dt := null;
2556 g_err_cnt := 0;
2557 g_per_cnt := 0;
2558 g_rec_cnt := 0;
2559 g_dtl_cnt := 0;
2560 g_hdr_cnt := 0;
2561 g_trl_cnt := 0;
2562 g_subhdr_cnt := 0;
2563 g_subtrl_cnt := 0;
2564 --
2565 if g_debug then
2566 hr_utility.set_location ('Exiting '||l_proc,15);
2567 end if;
2568 --
2569 end initialize_globals;
2570 -- =======================================================================
2571 -- <<Procedure:Thread_Summary>>
2572 -- -----------------------------------------------------------------------
2573 -- -----------------------------------------------------------------------
2574 -- This is procedure logs the status of all threads in the master's log file.
2575 -- ========================================================================
2576 --
2577 procedure thread_summary is
2578 --
2579 l_proc varchar2(80);
2580 l_text varchar2(70);
2581 --
2582 begin
2583 --
2584 if g_debug then
2585 l_proc := g_package||'.thread_summary';
2586 hr_utility.set_location ('Entering '||l_proc,5);
2587 end if;
2588 --
2589 fnd_file.put_line(fnd_file.log, ' ');
2590 fnd_message.set_name('BEN', 'BEN_92191_ALL_THREAD_LABEL');
2591 fnd_file.put_line(fnd_file.log, fnd_message.get);
2592 fnd_file.put_line(fnd_file.log, ' ');
2593 fnd_message.set_name('BEN', 'BEN_92192_EXT_STATS_LABEL');
2594 fnd_file.put_line(fnd_file.log, fnd_message.get);
2595 fnd_message.set_name('BEN', 'BEN_91956_EXT_TOT_REC');
2596 fnd_file.put_line(fnd_file.log, ' ' || fnd_message.get || ' ' || to_char(g_rec_cnt));
2597 --
2598 fnd_message.set_name('BEN', 'BEN_91957_EXT_TOT_PER');
2599 fnd_file.put_line(fnd_file.log, ' ' || fnd_message.get || ' ' || to_char(g_per_cnt));
2600 --
2601 fnd_message.set_name('BEN', 'BEN_91958_EXT_TOT_ERR');
2602 fnd_file.put_line(fnd_file.log, ' ' || fnd_message.get || ' ' || to_char(g_err_cnt));
2603 --
2604 fnd_file.put_line(fnd_file.log, ' ');
2605 --
2606 if g_debug then
2607 hr_utility.set_location ('Exiting '||l_proc,15);
2608 end if;
2609 --
2610 end thread_summary;
2611
2612
2613 ----
2614
2615
2616 Procedure build_adv_criteria(
2617 p_ext_crit_prfl_id in number default null,
2618 p_ext_dfn_id in number,
2619 p_business_group_id in number,
2620 p_effective_date in date,
2621 p_source in varchar2 default 'BEN' ,
2622 p_select_statement in out nocopy long) is
2623
2624 l_proc varchar2(80);
2625 l_text varchar2(70);
2626 --
2627 cursor c1 is
2628 select ecv.ext_crit_val_id
2629 from ben_ext_crit_typ ect, ben_ext_crit_val ecv
2630 where ect.crit_typ_cd = 'ADV'
2631 and ect.ext_crit_typ_id = ecv.ext_crit_typ_id
2632 and ect.ext_crit_prfl_id = p_ext_crit_prfl_id
2633 ;
2634
2635
2636
2637 cursor c2 (p_ext_crit_val_id number) is
2638 select ecc.crit_typ_cd,
2639 ecc.oper_cd,
2640 ecc.val_1,
2641 ecc.val_2
2642 from ben_ext_crit_cmbn ecc
2643 where ecc.ext_crit_val_id = p_ext_crit_val_id
2644 ;
2645
2646 l_sql_string long ;
2647 l_first_time varchar2(1) ;
2648 l_first_val varchar2(1) ;
2649 l_prev_first_val varchar2(1) ;
2650 l_from_date date ;
2651 l_to_date date ;
2652
2653 begin
2654 --
2655 if g_debug then
2656 l_proc := g_package||'.build_adv_criteria';
2657 hr_utility.set_location ('Entering '||l_proc,5);
2658 end if;
2659
2660 l_sql_string := '' ;
2661 l_first_time := 'Y' ;
2662 l_first_val := 'Y' ;
2663 l_prev_first_val := 'Y' ;
2664
2665 if p_ext_crit_prfl_id is not null then
2666 -- curosr on combination criteria type
2667 for i in c1
2668 Loop
2669
2670 l_first_val := 'Y' ;
2671 -- curosr on combination criteria value type
2672 for k in c2(i.ext_crit_val_id)
2673 Loop
2674 -- whne we switch to different criteria type
2675 -- add ( or ) 'or' condition a
2676 if l_prev_first_val <> 'Y' and l_first_val = 'Y' then
2677 l_sql_string := l_sql_string || ') OR ( ' ;
2678 else
2679 --- starting for the valu set
2680 if l_first_val = 'Y' then
2681 l_sql_string := l_sql_string || ' ( ' ;
2682 else
2683 l_sql_string := l_sql_string || ' AND ' ;
2684 end if ;
2685
2686 end if;
2687 -- eof variable manpulation
2688 -- bof set the variable values
2689 l_first_val := 'N' ;
2690 l_first_time := 'N' ;
2691 -- eof set the variable values
2692
2693
2694 -- bof get the values from
2695 if k.crit_typ_cd in ('CAD','CED') then
2696 if k.crit_typ_cd = 'CAD' then
2697 if p_source = 'PAY' then
2698 l_sql_string := l_sql_string || 'xcl.CREATION_DATE ' ;
2699 elsif p_source = 'BEN' then
2700 l_sql_string := l_sql_string || 'xcl.CHG_ACTL_DT ' ;
2701 end if ;
2702 elsif k.crit_typ_cd = 'CED' then
2703 if p_source = 'PAY' then
2704 l_sql_string := l_sql_string || 'xcl.EFFECTIVE_DATE ' ;
2705 elsif p_source = 'BEN' then
2706 l_sql_string := l_sql_string || ' xcl.CHG_EFF_DT ' ;
2707 end if ;
2708 end if ;
2709 -- determne the from date
2710 l_from_date := ben_ext_util.calc_ext_date
2711 (p_ext_date_cd => k.val_1,
2712 p_abs_date => p_effective_date,
2713 p_ext_dfn_id => p_ext_dfn_id);
2714
2715 if k.oper_cd = 'EQ' then
2716 if k.crit_typ_cd = 'CED' then
2717 l_sql_string := l_sql_string ||' = to_date('''||
2718 to_char(l_from_date,'DD-MM-RRRR')||''',''DD-MM-RRRR'')';
2719
2720 Else
2721 l_sql_string := l_sql_string|| ' BETWEEN '
2722 ||'to_date('''||to_char(l_from_date,'DD-MM-RRRR HH24:MI:SS')
2723 ||''',''DD-MM-RRRR HH24:MI:SS'')'
2724 ||' AND '
2725 ||'to_date('''||to_char(l_from_date+0.99999,'DD-MM-RRRR HH24:MI:SS')
2726 ||''',''DD-MM-RRRR HH24:MI:SS'')';
2727 End if ;
2728 elsif k.oper_cd = 'NE' then
2729 if k.crit_typ_cd = 'CED' then
2730 l_sql_string := l_sql_string ||'<> to_date('''||
2731 to_char(l_from_date,'DD-MM-RRRR')||''',''DD-MM-RRRR'')';
2732
2733 Else
2734 l_sql_string := l_sql_string|| ' NOT BETWEEN '
2735 ||'to_date('''||to_char(l_from_date,'DD-MM-RRRR HH24:MI:SS')
2736 ||''',''DD-MM-RRRR'')'
2737 ||' AND '
2738 ||'to_date('''||to_char(l_from_date+0.99999,'DD-MM-RRRR HH24:MI:SS')
2739 ||''',''DD-MM-RRRR HH24:MI:SS'')';
2740 end if;
2741
2742 elsif k.oper_cd = 'BE' then
2743 l_to_date := ben_ext_util.calc_ext_date
2744 (p_ext_date_cd => k.val_2,
2745 p_abs_date => p_effective_date,
2746 p_ext_dfn_id => p_ext_dfn_id);
2747 if k.crit_typ_cd = 'CAD' then
2748
2749 l_sql_string := l_sql_string|| ' BETWEEN '
2750 ||'to_date('''||to_char(l_from_date,'DD-MM-RRRR HH24:MI:SS')
2751 ||''',''DD-MM-RRRR HH24:MI:SS'')'
2752 ||' AND '
2753 ||'to_date('''||to_char(l_to_date+0.99999,'DD-MM-RRRR HH24:MI:SS')
2754 ||''',''DD-MM-RRRR HH24:MI:SS'')';
2755 else
2756 l_sql_string := l_sql_string|| ' BETWEEN '
2757 ||'to_date('''||to_char(l_from_date,'DD-MM-RRRR')||''',''DD-MM-RRRR'')'
2758 ||' AND '
2759 || 'to_date('''||to_char(l_to_date,'DD-MM-RRRR')||''',''DD-MM-RRRR'')';
2760 end if ;
2761
2762 end if ;
2763 elsif k.crit_typ_cd = 'CCE' then
2764 -- if this is ben change event get value else so dont do anything
2765 if p_source = 'BEN' then
2766 l_sql_string := l_sql_string || ' xcl.chg_evt_cd ' ;
2767 if k.oper_cd = 'EQ' then
2768 l_sql_string := l_sql_string || ' = ''' || k.val_1 || '''' ;
2769 elsif k.oper_cd = 'NE' then
2770 l_sql_string := l_sql_string || ' <> '''|| k.val_1 ||'''' ;
2771 end if ;
2772 else
2773 l_sql_string := l_sql_string || ' TRUE' ;
2774 end if ;
2775 elsif k.crit_typ_cd = 'CPE' then
2776 -- now we are not complicating the sql , this will be
2777 -- taken care in evaluation part so do nothing
2778 l_sql_string := l_sql_string || ' TRUE' ;
2779 end if ;
2780
2781 end Loop ;
2782
2783 -- set the previous value
2784 l_prev_first_val := l_first_val ;
2785
2786
2787 end Loop ;
2788
2789 end if ;
2790
2791
2792 if l_first_time = 'Y' then
2793 l_sql_string := null ;
2794 else
2795 l_sql_string := '( ' || l_sql_string || ' ) ) ' ;
2796 end if ;
2797
2798 p_select_statement := l_sql_string ;
2799
2800 if g_debug then
2801 hr_utility.set_location ('Exiting '||l_proc,15);
2802 end if;
2803
2804 end ;
2805
2806
2807
2808 Procedure chck_non_asg_pay_evt(
2809 p_ext_crit_prfl_id in number ,
2810 p_ext_dfn_id in number,
2811 p_business_group_id in number,
2812 p_effective_date in date,
2813 p_effective_from_date in date default null,
2814 p_effective_to_date in date default null,
2815 p_actual_from_date in date default null,
2816 p_actual_to_date in date default null,
2817 p_adv_crit_exist in varchar2 default null,
2818 p_result out nocopy varchar2 ) is
2819
2820 l_proc varchar2(80);
2821 l_text varchar2(70);
2822
2823
2824 cursor c_non_asg_crit is
2825 select 'X'
2826 from ben_ext_crit_typ ect
2827 ,ben_ext_crit_val ecv
2828 ,pay_datetracked_events pde
2829 ,pay_dated_tables pdt
2830 where ect.ext_crit_prfl_id = p_ext_crit_prfl_id
2831 and ect.crit_typ_cd = 'CPE'
2832 and ecv.ext_crit_typ_id = ect.ext_crit_typ_id
2833 and pde.event_group_id = to_number(ecv.val_1)
2834 and pde.dated_table_id = pdt.dated_table_id
2835 and pdt.TABLE_NAME in ( 'PAY_LINK_INPUT_VALUES_F'
2836 ,'PAY_ELEMENT_LINKS_F'
2837 ,'PAY_INPUT_VALUES_F'
2838 ,'PAY_ALL_PAYROLLS_F'
2839 ,'PAY_ELEMENT_TYPES_F'
2840 ,'PAY_GRADE_RULES_F'
2841 ,'PAY_USER_COLUMN_INSTANCES_F'
2842 ,'FF_GLOBALS_F'
2843 )
2844 ;
2845
2846
2847
2848 cursor c_non_asg_tabel_id is
2849 select pde.dated_table_id,pde.business_group_id ,pde.LEGISLATION_CODE,pde.update_type
2850 from ben_ext_crit_typ ect
2851 ,ben_ext_crit_val ecv
2852 ,pay_datetracked_events pde
2853 ,pay_dated_tables pdt
2854 where ect.ext_crit_prfl_id = p_ext_crit_prfl_id
2855 and ect.crit_typ_cd = 'CPE'
2856 and ecv.ext_crit_typ_id = ect.ext_crit_typ_id
2857 and pde.event_group_id = to_number(ecv.val_1)
2858 and pde.dated_table_id = pdt.dated_table_id
2859 and pdt.TABLE_NAME in ( 'PAY_LINK_INPUT_VALUES_F'
2860 ,'PAY_ELEMENT_LINKS_F'
2861 ,'PAY_INPUT_VALUES_F'
2862 ,'PAY_ALL_PAYROLLS_F'
2863 ,'PAY_ELEMENT_TYPES_F'
2864 ,'PAY_GRADE_RULES_F'
2865 ,'PAY_USER_COLUMN_INSTANCES_F'
2866 ,'FF_GLOBALS_F'
2867 )
2868 ;
2869
2870 l_result varchar2(1) ;
2871 l_dummy varchar2(1) ;
2872 l_dated_table_id pay_dated_tables.dated_table_id%type ;
2873 l_update_type varchar2(10) ;
2874 l_legislation_code varchar2(35) ;
2875 l_sql varchar2(4000) ;
2876 l_adv_sql varchar2(4000) ;
2877 l_column_name varchar2(35) ;
2878
2879
2880 TYPE nonasgevt is REF CURSOR;
2881 --
2882 c_nonasgevt nonasgevt;
2883
2884
2885 Begin
2886
2887
2888 --
2889 if g_debug then
2890 l_proc := g_package||'.chck_non_asg_pay_evt';
2891 hr_utility.set_location ('Entering '||l_proc,5);
2892 end if;
2893
2894
2895 hr_utility.set_location ('actual date '||p_actual_from_date ,5);
2896 hr_utility.set_location ('actual date '||p_actual_to_date ,5);
2897 hr_utility.set_location ('effect date '||p_effective_from_date ,5);
2898 hr_utility.set_location ('effect date '||p_effective_to_date ,5);
2899 hr_utility.set_location ('adv cond '||p_adv_crit_exist ,5);
2900
2901
2902 l_result := 'N' ;
2903 p_result := 'N' ;
2904 open c_non_asg_crit ;
2905 fetch c_non_asg_crit into l_dummy ;
2906 IF c_non_asg_crit%notfound then
2907 -- when there is criteria with non asg table
2908 -- do not process further
2909 close c_non_asg_crit ;
2910 hr_utility.set_location ('Exiting no criteria found '||l_proc,10);
2911 Return ;
2912 End if ;
2913 close c_non_asg_crit ;
2914
2915 -- when there is a event group with non asg table
2916 -- check there is any event on that dates
2917
2918 for i in c_non_asg_tabel_id
2919 Loop
2920
2921 l_sql := ' Select ''X'' From pay_event_updates peu ' ||
2922 ' where peu.dated_table_id = '|| i.dated_table_id ||
2923 ' and peu.event_type = '''|| i.update_type || '''' ;
2924
2925 if p_business_group_id is not null then
2926 l_sql:=l_sql||' and (peu.business_group_id is null or peu.business_group_id ='||p_business_group_id ||')' ;
2927 end if ;
2928
2929 if i.legislation_code is not null then
2930 l_sql := l_sql ||' and peu.legislation_code = ''' || i.legislation_code || '''' ;
2931 end if ;
2932
2933 l_sql := l_sql ||
2934 ' and exists ( ' ||
2935 ' Select xcl.process_event_id from pay_process_events xcl' ||
2936 ' where xcl.event_update_id = peu.event_update_id' ||
2937 --- if the event created for a bg then validate the bg with extract bg
2938 ' and (peu.business_group_id is null or xcl.business_group_id = peu.business_group_id)';
2939
2940 -- if the event group define for a bg then validate the bg with event
2941 if i.business_group_id is not null then
2942 l_sql := l_sql || ' and xcl.business_group_id = ' || i.business_group_id ;
2943 else
2944 if p_business_group_id is not null then
2945 l_sql:=l_sql||'and xcl.business_group_id ='||p_business_group_id ;
2946 end if ;
2947 end if ;
2948
2949 if p_actual_to_date is not null then
2950 l_sql := l_sql || ' and xcl.creation_date between to_date(''' ||
2951 to_char(p_actual_from_date,'DD-MM-RRRR HH24:MI:SS')|| ''',''DD-MM-RRRR HH24:MI:SS'') and to_date('''||
2952 to_char(p_actual_to_date+0.99999,'DD-MM-RRRR HH24:MI:SS') || ''',''DD-MM-RRRR HH24:MI:SS'') ';
2953 end if ;
2954
2955 if p_effective_to_date is not null then
2956 l_sql := l_sql || ' and xcl.effective_date between to_date(''' ||
2957 to_char(p_effective_from_date,'DD-MM-RRRR') || ''',''DD-MM-RRRR'') and to_date(''' ||
2958 to_char(p_effective_to_date,'DD-MM-RRRR') || ''',''DD-MM-RRRR'') ';
2959 end if ;
2960
2961 if p_adv_crit_exist = 'Y' then
2962
2963
2964 build_adv_criteria(
2965 p_ext_crit_prfl_id => p_ext_crit_prfl_id ,
2966 p_ext_dfn_id => p_ext_dfn_id,
2967 p_business_group_id => p_business_group_id,
2968 p_effective_date => p_effective_date,
2969 p_source => 'PAY' ,
2970 p_select_statement => l_ADV_sql) ;
2971 if l_ADV_sql is not null then
2972
2973 l_sql := l_sql || ' AND ' || l_adv_sql ;
2974 end if ;
2975
2976 end if ;
2977
2978 l_sql := l_sql || ' ) ' ;
2979
2980
2981
2982 --- Process the cursor
2983 begin
2984 open c_nonasgevt for l_sql ;
2985 exception
2986 --
2987 when others then
2988 --
2989 fnd_file.put_line(fnd_file.log,'Error executing this dynamically build payroll event SQL Statement:');
2990 end;
2991 --
2992 fetch c_nonasgevt into l_dummy ;
2993 if c_nonasgevt%found then
2994 close c_nonasgevt ;
2995 l_result := 'Y' ;
2996 exit ;
2997 end if ;
2998 close c_nonasgevt ;
2999 --
3000
3001 End Loop ;
3002
3003 hr_utility.set_location ('Non Asg Pay event found '||l_result,15);
3004 p_result := l_result ;
3005 if g_debug then
3006 hr_utility.set_location ('Exiting '||l_proc,15);
3007 end if;
3008
3009
3010 End chck_non_asg_pay_evt ;
3011
3012
3013 ----
3014
3015 Procedure get_ext_crit_string(p_ext_crit_prfl_id in number ,
3016 p_ext_crit_typ in varchar2,
3017 p_ext_num_str in varchar2 default 'N' ,
3018 p_string out nocopy varchar2 ) is
3019
3020
3021 l_proc varchar2(80);
3022 cursor c_crit_all is
3023 select xcv.val_1
3024 from ben_ext_crit_typ xct,
3025 ben_ext_crit_val xcv
3026 where xct.ext_crit_prfl_id = p_ext_crit_prfl_id
3027 and xct.ext_crit_typ_id = xcv.ext_crit_typ_id
3028 and xct.crit_typ_cd = p_ext_crit_typ;
3029
3030 l_crit_all varchar2(4000) ;
3031 l_first_time varchar2(1) ;
3032
3033
3034 Begin
3035 if g_debug then
3036 l_proc := g_package||'.get_ext_crit_string';
3037 hr_utility.set_location ('Entering '||l_proc,5);
3038 end if;
3039
3040 l_crit_all := '' ;
3041 l_first_time := 'Y' ;
3042
3043 for i in c_crit_all
3044 Loop
3045
3046 if l_first_time = 'N' then
3047 l_crit_all := l_crit_all || ',' ;
3048 end if ;
3049
3050 if p_ext_num_str = 'S' then
3051 l_crit_all := l_crit_all || '''' ;
3052 end if ;
3053
3054 l_crit_all := l_crit_all || ltrim(rtrim(i.val_1)) ;
3055 if p_ext_num_str = 'S' then
3056 l_crit_all := l_crit_all || '''' ;
3057 end if ;
3058
3059 l_first_time := 'N' ;
3060
3061 End Loop ;
3062
3063 if l_first_time = 'N' then
3064 p_string := '(' || l_crit_all || ')' ;
3065 end if ;
3066
3067 hr_utility.set_location ('Exiting '||l_proc,15);
3068 End get_ext_crit_string ;
3069
3070
3071
3072 -- =======================================================================
3073 -- <<Procedure:Build_Select_Statement>>
3074 -- -----------------------------------------------------------------------
3075 -- This procedure was added for performance improvements to filter as much
3076 -- data as possible up front using the criteria profiles. It probably can
3077 -- be expanded to include more criteria such as state and zip code. The
3078 -- sql statement is build dynamically, and used in an open statement in the
3079 -- calling program.
3080 --
3081 Procedure build_select_statement
3082 (p_data_typ_cd in varchar2,
3083 p_ext_crit_prfl_id in number default null,
3084 p_ext_dfn_id in number,
3085 p_business_group_id in number,
3086 p_effective_date in date,
3087 p_ext_rslt_id in number ,
3088 p_ext_global_flag in varchar2 default null,
3089 p_eff_start_date in date default null,
3090 p_eff_end_date in date default null,
3091 p_act_start_date in date default null,
3092 p_act_end_date in date default null,
3093 p_select_statement in out nocopy long,
3094 p_penserv_date in date default null) is
3095 --
3096 l_dynamic_sql long;
3097 l_dynamic_pay_sql long;
3098 l_dynamic_ben_sql long;
3099 l_dynamic_adv_sql long;
3100 l_pay_spl_process varchar2(1) ;
3101
3102
3103 -- For Pensrv
3104
3105 l_pen_config_values pqp_utilities.t_config_values;
3106
3107 l_pen_membership_col VARCHAR2(20);
3108 l_pen_membership_context VARCHAR2(80);
3109
3110 --
3111 -- Full Name/Person ID
3112 --
3113 cursor c_pid is
3114 select 'Y',
3115 xct.excld_flag
3116 from ben_ext_crit_typ xct,
3117 ben_ext_crit_val xcv
3118 where xct.ext_crit_prfl_id = p_ext_crit_prfl_id
3119 and xct.ext_crit_typ_id = xcv.ext_crit_typ_id
3120 and xct.crit_typ_cd = 'PID';
3121 --
3122 l_pid_exists varchar2(1) := 'N';
3123 l_pid_exclude varchar2(1);
3124 --
3125 -- Assignment Organization
3126 --
3127 cursor c_por is
3128 select 'Y',
3129 xct.excld_flag
3130 from ben_ext_crit_typ xct,
3131 ben_ext_crit_val xcv
3132 where xct.ext_crit_prfl_id = p_ext_crit_prfl_id
3133 and xct.ext_crit_typ_id = xcv.ext_crit_typ_id
3134 and xct.crit_typ_cd = 'POR';
3135 --
3136 l_por_exists varchar2(1) := 'N';
3137 l_por_exclude varchar2(1);
3138 --
3139 -- Assignment Status
3140 --
3141 cursor c_pas is
3142 select 'Y',
3143 xct.excld_flag
3144 from ben_ext_crit_typ xct,
3145 ben_ext_crit_val xcv
3146 where xct.ext_crit_prfl_id = p_ext_crit_prfl_id
3147 and xct.ext_crit_typ_id = xcv.ext_crit_typ_id
3148 and xct.crit_typ_cd = 'PAS';
3149 --
3150 l_pas_exists varchar2(1) := 'N';
3151 l_pas_exclude varchar2(1);
3152 --
3153
3154 -- Assignment Location
3155 --
3156 cursor c_plo is
3157 select 'Y',
3158 xct.excld_flag
3159 from ben_ext_crit_typ xct,
3160 ben_ext_crit_val xcv
3161 where xct.ext_crit_prfl_id = p_ext_crit_prfl_id
3162 and xct.ext_crit_typ_id = xcv.ext_crit_typ_id
3163 and xct.crit_typ_cd = 'PLO';
3164 --
3165 l_plo_exists varchar2(1) := 'N';
3166 l_plo_exclude varchar2(1);
3167 --
3168 -- Person Benefits Group
3169 --
3170 cursor c_pbg is
3171 select 'Y',
3172 xct.excld_flag
3173 from ben_ext_crit_typ xct,
3174 ben_ext_crit_val xcv
3175 where xct.ext_crit_prfl_id = p_ext_crit_prfl_id
3176 and xct.ext_crit_typ_id = xcv.ext_crit_typ_id
3177 and xct.crit_typ_cd = 'PBG';
3178 --
3179 l_pbg_exists varchar2(1) := 'N';
3180 l_pbg_exclude varchar2(1);
3181 --
3182
3183 -- Person business_grp Group
3184 --
3185 cursor c_pbgr is
3186 select 'Y',
3187 xct.excld_flag
3188 from ben_ext_crit_typ xct,
3189 ben_ext_crit_val xcv
3190 where xct.ext_crit_prfl_id = p_ext_crit_prfl_id
3191 and xct.ext_crit_typ_id = xcv.ext_crit_typ_id
3192 and xct.crit_typ_cd = 'PBGR';
3193 --
3194 l_pbgr_exists varchar2(1) := 'N';
3195 l_pbgr_exclude varchar2(1);
3196 --
3197
3198 -- person type usage
3199
3200 cursor c_ppt is
3201 select 'Y',
3202 xct.excld_flag
3203 from ben_ext_crit_typ xct,
3204 ben_ext_crit_val xcv
3205 where xct.ext_crit_prfl_id = p_ext_crit_prfl_id
3206 and xct.ext_crit_typ_id = xcv.ext_crit_typ_id
3207 and xct.crit_typ_cd = 'PPT';
3208 --
3209 l_ppt_exists varchar2(1) := 'N';
3210 l_ppt_exclude varchar2(1);
3211 --
3212
3213
3214
3215 l_Source_dummy varchar2(1) ;
3216
3217 -- Change Event Name
3218 --
3219 cursor c_cce is
3220 select 'Y',
3221 xct.excld_flag
3222 from ben_ext_crit_typ xct
3223 ,ben_ext_crit_val xcv
3224 where xct.ext_crit_prfl_id = p_ext_crit_prfl_id
3225 and xct.ext_crit_typ_id = xcv.ext_crit_typ_id
3226 and xct.crit_typ_cd = 'CCE';
3227 --
3228 l_cce_exists varchar2(1) := 'N';
3229 l_cce_exclude varchar2(1);
3230
3231
3232 cursor c_cpe is
3233 select 'Y',
3234 xct.excld_flag
3235 from ben_ext_crit_typ xct
3236 ,ben_ext_crit_val xcv
3237 where xct.ext_crit_prfl_id = p_ext_crit_prfl_id
3238 and xct.ext_crit_typ_id = xcv.ext_crit_typ_id
3239 and xct.crit_typ_cd = 'CPE';
3240
3241 l_cpe_exists varchar2(1) := 'N';
3242 l_cpe_exclude varchar2(1);
3243
3244
3245
3246 --
3247 -- Change Actual Date
3248 --
3249 cursor c_cad is
3250 Select 'Y',
3251 xct.excld_flag,
3252 xcv.val_1,
3253 xcv.val_2
3254 from ben_ext_crit_typ xct,
3255 ben_ext_crit_val xcv
3256 where xct.ext_crit_prfl_id = p_ext_crit_prfl_id
3257 and xct.ext_crit_typ_id = xcv.ext_crit_typ_id
3258 and xct.crit_typ_cd = 'CAD';
3259
3260 l_cad_exists varchar2(1) := 'N';
3261 l_cad_exclude varchar2(1);
3262 l_cad_val1 ben_ext_crit_val.val_1%type ;
3263 l_cad_val2 ben_ext_crit_val.val_2%type ;
3264 l_cad_date_from date;
3265 l_cad_date_to date;
3266 -- person data link
3267
3268 cursor c_pdl is
3269 Select 'Y',
3270 xct.excld_flag,
3271 xcv.val_1
3272 from ben_ext_crit_typ xct,
3273 ben_ext_crit_val xcv
3274 where xct.ext_crit_prfl_id = p_ext_crit_prfl_id
3275 and xct.ext_crit_typ_id = xcv.ext_crit_typ_id
3276 and xct.crit_typ_cd = 'PDL';
3277
3278 l_pdl_exists varchar2(1) := 'N';
3279 l_pdl_exclude varchar2(1);
3280 l_pdl_val1 ben_ext_crit_val.val_1%type ;
3281
3282 -- CWB
3283 cursor c_wplr is
3284 select 'Y',
3285 xct.excld_flag ,
3286 xct.EXT_CRIT_TYP_ID
3287 from ben_ext_crit_typ xct,
3288 ben_ext_crit_val xcv
3289 where xct.ext_crit_prfl_id = p_ext_crit_prfl_id
3290 and xct.ext_crit_typ_id = xcv.ext_crit_typ_id
3291 and xct.crit_typ_cd = 'WPLPR';
3292 --
3293 l_wplr_exists varchar2(1) := 'N';
3294 l_wplr_exclude varchar2(1);
3295 l_wlpr_EXT_CRIT_TYP_ID number ;
3296
3297
3298 -- person Assignment_set PASGSET
3299
3300
3301 cursor c_pasgset is
3302 Select 'Y',
3303 xct.excld_flag,
3304 xcv.val_1
3305 from ben_ext_crit_typ xct,
3306 ben_ext_crit_val xcv
3307 where xct.ext_crit_prfl_id = p_ext_crit_prfl_id
3308 and xct.ext_crit_typ_id = xcv.ext_crit_typ_id
3309 and xct.crit_typ_cd = 'PASGSET';
3310
3311 l_pasgset_exists varchar2(1) := 'N';
3312 l_pasgset_exclude varchar2(1);
3313 l_pasgset_val1 ben_ext_crit_val.val_1%type ;
3314
3315
3316
3317
3318
3319 --
3320 -- Change Effective Date
3321 --
3322 cursor c_ced is
3323 select 'Y',
3324 xct.excld_flag,
3325 xcv.val_1,
3326 xcv.val_2
3327 from ben_ext_crit_typ xct,
3328 ben_ext_crit_val xcv
3329 where xct.ext_crit_prfl_id = p_ext_crit_prfl_id
3330 and xct.ext_crit_typ_id = xcv.ext_crit_typ_id
3331 and xct.crit_typ_cd = 'CED';
3332 --
3333 l_ced_exists varchar2(1) := 'N';
3334 l_ced_exclude varchar2(1);
3335 l_ced_val1 ben_ext_crit_val.val_1%type;
3336 l_ced_val2 ben_ext_crit_val.val_2%type;
3337 l_ced_date_from date;
3338 l_ced_date_to date;
3339 --
3340
3341
3342
3343 -- Communication Type
3344 --
3345 cursor c_mtp is
3346 select 'Y',
3347 xct.excld_flag
3348 from ben_ext_crit_typ xct,
3349 ben_ext_crit_val xcv
3350 where xct.ext_crit_prfl_id = p_ext_crit_prfl_id
3351 and xct.ext_crit_typ_id = xcv.ext_crit_typ_id
3352 and xct.crit_typ_cd = 'MTP';
3353 --
3354 l_mtp_exists varchar2(1) := 'N';
3355 l_mtp_exclude varchar2(1);
3356 --
3357 -- Communication To Be Sent Date
3358 --
3359 cursor c_mtbsdt is
3360 select 'Y',
3361 xct.excld_flag,
3362 xcv.val_1,
3363 xcv.val_2
3364 from ben_ext_crit_typ xct,
3365 ben_ext_crit_val xcv
3366 where xct.ext_crit_prfl_id = p_ext_crit_prfl_id
3367 and xct.ext_crit_typ_id = xcv.ext_crit_typ_id
3368 and xct.crit_typ_cd = 'MTBSDT';
3369 --
3370 l_mtbsdt_exists varchar2(1) := 'N';
3371 l_mtbsdt_exclude varchar2(1);
3372 l_mtbsdt_val1 ben_ext_crit_val.val_1%type;
3373 l_mtbsdt_val2 ben_ext_crit_val.val_2%type;
3374 l_mtbsdt_date_from date;
3375 l_mtbsdt_date_to date;
3376
3377 --
3378 cursor c_adv is
3379 Select 'Y'
3380 from ben_ext_crit_typ xct
3381 where xct.ext_crit_prfl_id = p_ext_crit_prfl_id
3382 and xct.crit_typ_cd = 'ADV';
3383 --
3384 l_adv_exists varchar2(1) := 'N';
3385
3386 -- Communication Sent Date
3387 --
3388 cursor c_msdt is
3389 Select 'Y',
3390 xct.excld_flag,
3391 xcv.val_1,
3392 xcv.val_2
3393 from ben_ext_crit_typ xct,
3394 ben_ext_crit_val xcv
3395 where xct.ext_crit_prfl_id = p_ext_crit_prfl_id
3396 and xct.ext_crit_typ_id = xcv.ext_crit_typ_id
3397 and xct.crit_typ_cd = 'MSDT';
3398 --
3399 l_msdt_exists varchar2(1) := 'N';
3400 l_msdt_exclude varchar2(1);
3401 l_msdt_val1 ben_ext_crit_val.val_1%type;
3402 l_msdt_val2 ben_ext_crit_val.val_2%type;
3403 l_msdt_date_from date;
3404 l_msdt_date_to date;
3405
3406 -- Person payroll id
3407 cursor c_rrl is
3408 select 'Y',
3409 xct.excld_flag
3410 from ben_ext_crit_typ xct,
3411 ben_ext_crit_val xcv
3412 where xct.ext_crit_prfl_id = p_ext_crit_prfl_id
3413 and xct.ext_crit_typ_id = xcv.ext_crit_typ_id
3414 and xct.crit_typ_cd = 'RRL';
3415 --
3416 l_rrl_exists varchar2(1) := 'N';
3417 l_rrl_exclude varchar2(1);
3418
3419 --For Penserver 115.70
3420 -- Cursor to check for PQP Earnings Extract
3421 cursor c_pen_ern is
3422 select bed.ext_dfn_id
3423 from ben_ext_dfn bed
3424 where bed.name = 'PQP GB PenServer Standard Interface - Earnings History';
3425 --
3426 l_pen_ext_dfn_id number;
3427
3428 --
3429 l_pay_evt_non_asg varchar2(1) ;
3430 l_crit_val_all varchar2(4000) ;
3431 --
3432 begin
3433 --
3434 open c_pid;
3435 fetch c_pid into l_pid_exists, l_pid_exclude;
3436 close c_pid;
3437 --
3438 open c_por;
3439 fetch c_por into l_por_exists, l_por_exclude;
3440 close c_por;
3441 --
3442 open c_pas;
3443 fetch c_pas into l_pas_exists, l_pas_exclude;
3444 close c_pas;
3445 --
3446 open c_plo;
3447 fetch c_plo into l_plo_exists, l_plo_exclude;
3448 close c_plo;
3449 --
3450 open c_pbg;
3451 fetch c_pbg into l_pbg_exists, l_pbg_exclude;
3452 close c_pbg;
3453 -- person business group
3454 open c_pbgr;
3455 fetch c_pbgr into l_pbgr_exists, l_pbgr_exclude;
3456 close c_pbgr;
3457
3458 -- person type usage
3459 open c_ppt;
3460 fetch c_ppt into l_ppt_exists, l_ppt_exclude;
3461 close c_ppt;
3462 --
3463 open c_cpe;
3464 fetch c_cpe into l_cpe_exists, l_cpe_exclude;
3465 if c_cpe%found then
3466 g_chg_ext_from_pay := 'Y' ;
3467 else
3468 g_chg_ext_from_ben := 'Y' ;
3469 end if ;
3470 close c_cpe;
3471
3472
3473 open c_cce;
3474 fetch c_cce into l_cce_exists, l_cce_exclude;
3475 if c_cce%found then
3476 g_chg_ext_from_ben := 'Y' ;
3477 end if ;
3478 close c_cce;
3479
3480 -- person payroll
3481 open c_rrl;
3482 fetch c_rrl into l_rrl_exists, l_rrl_exclude;
3483 close c_rrl;
3484
3485
3486 hr_utility.set_location( 'CELT exist ' || g_chg_ext_from_ben || ' / ' || g_chg_ext_from_pay , 99 ) ;
3487
3488 -- cwb
3489
3490 open c_wplr;
3491 fetch c_wplr into l_wplr_exists, l_wplr_exclude, l_wlpr_EXT_CRIT_TYP_ID ;
3492 close c_wplr;
3493
3494 -- when the date param is passes used the data param
3495 if p_act_start_date is not null and p_act_end_date is not null then
3496 l_cad_exists := 'Y' ;
3497 l_cad_exclude := 'N' ;
3498 l_cad_val1 := to_char(p_act_start_date , 'MM/DD/RRRR') ;
3499 l_cad_val2 := to_char(p_act_end_date , 'MM/DD/RRRR') ;
3500 else
3501 open c_cad;
3502 fetch c_cad into l_cad_exists, l_cad_exclude, l_cad_val1, l_cad_val2;
3503 close c_cad;
3504 end if ;
3505 --
3506 open c_pdl;
3507 fetch c_pdl into l_pdl_exists, l_pdl_exclude, l_pdl_val1;
3508 close c_pdl;
3509
3510
3511
3512 --- Assignment set
3513 open c_pasgset;
3514 fetch c_pasgset into l_pasgset_exists, l_pasgset_exclude, l_pasgset_val1;
3515 close c_pasgset ;
3516
3517
3518
3519 -- when the date param is passes used the data param
3520 if p_eff_start_date is not null and p_eff_end_date is not null then
3521 l_ced_exists := 'Y' ;
3522 l_ced_exclude := 'N' ;
3523 l_ced_val1 := to_char(p_eff_start_date , 'MM/DD/RRRR') ;
3524 l_ced_val2 := to_char(p_eff_end_date , 'MM/DD/RRRR') ;
3525 else
3526 open c_ced;
3527 fetch c_ced into l_ced_exists, l_ced_exclude, l_ced_val1, l_ced_val2;
3528 close c_ced;
3529 end if ;
3530 --
3531
3532
3533 if g_chg_ext_from_pay = 'Y' and ( l_cpe_exclude = 'Y' or l_cad_exclude = 'Y' or l_ced_exclude = 'Y' ) then
3534 -- with payroll cahnge event exclude criteria on Event groups or Effective date or Actaul date is not allowed
3535
3536 ben_ext_thread.g_err_num := 94264;
3537 ben_ext_thread.g_err_name := 'BEN_94264_EXT_PAY_CHG_EXCLD';
3538 raise g_job_failure_error;
3539 end if ;
3540
3541
3542
3543
3544
3545 open c_mtp;
3546 fetch c_mtp into l_mtp_exists, l_mtp_exclude;
3547 close c_mtp;
3548 --
3549 open c_mtbsdt;
3550 fetch c_mtbsdt into l_mtbsdt_exists, l_mtbsdt_exclude, l_mtbsdt_val1, l_mtbsdt_val2;
3551 close c_mtbsdt;
3552 --
3553 open c_msdt;
3554 fetch c_msdt into l_msdt_exists, l_msdt_exclude, l_msdt_val1, l_msdt_val2;
3555 close c_msdt;
3556 -- ADV
3557 open c_adv ;
3558 fetch c_adv into l_adv_exists ;
3559 close c_adv ;
3560
3561
3562 --
3563 if p_data_typ_cd in ('F') then
3564 -- For Penserver 115.70
3565 IF p_penserv_date is not null
3566 THEN
3567 -- check if the current processed extract is Earnings
3568 OPEN c_pen_ern;
3569 FETCH c_pen_ern into l_pen_ext_dfn_id;
3570 CLOSE c_pen_ern;
3571
3572 IF l_pen_ext_dfn_id = p_ext_dfn_id
3573 THEN
3574 l_dynamic_sql :=
3575 ' SELECT distinct(per.person_id) person_id ' ||
3576 ' FROM per_all_assignments_f ben_asg ' ||
3577 ' ,per_periods_of_service ppos ' ||
3578 ' ,per_all_people_f per ' ||
3579 ' WHERE per.person_id = ben_asg.person_id (+) ' ||
3580 ' AND ben_asg.period_of_service_id = ppos.period_of_service_id ' ||
3581 ' AND ((ppos.actual_termination_date is NULL) ' ||
3582 ' OR ' ||
3583 ' (ppos.actual_termination_date >= to_date('''||to_char((add_months(p_effective_date,-1) + 1) ,'DD/MM/YYYY') ||''',''DD/MM/YYYY''))' ||
3584 ' OR ' ||
3585 ' ((ppos.actual_termination_date < to_date('''||to_char((add_months(p_effective_date,-1) + 1) ,'DD/MM/YYYY') ||''',''DD/MM/YYYY'') '||
3586 ' AND EXISTS (SELECT 1 ' ||
3587 ' FROM pay_assignment_actions paa ' ||
3588 ' ,pay_run_results prr ' ||
3589 ' ,pay_payroll_actions ppa ' ||
3590 ' WHERE paa.assignment_id = ben_asg.assignment_id ' ||
3591 ' AND paa.assignment_action_id = prr.assignment_action_id ' ||
3592 ' AND paa.payroll_action_id = ppa.payroll_action_id ' ||
3593 ' AND ppa.effective_date between to_date('''||to_char((add_months(p_effective_date,-1) + 1) ,'DD/MM/YYYY') ||''',''DD/MM/YYYY'') '||
3594 ' and last_day(to_date(''' || to_char(p_effective_date,'DD/MM/YYYY') || ''',''DD/MM/YYYY'')) '||
3595 ' ) ' ||
3596 ' ) ' ||
3597 ' ) ' ||
3598 ' ) ' ||
3599 ' AND NVL(ppos.actual_termination_date, GREATEST(TO_DATE('''||to_char((add_months(p_effective_date,-1) + 1) ,'DD/MM/YYYY') ||''',''DD/MM/YYYY''),ppos.date_start)) ' ||
3600 ' BETWEEN ben_asg.effective_start_date AND ben_asg.effective_end_date ' ;
3601 ELSE
3602 l_dynamic_sql :=
3603 'select distinct(per.person_id) person_id ' ||
3604 'from ' ||
3605 'per_all_people_f per, ' ||
3606 'per_all_assignments_f ben_asg ' ||
3607 'where ' ||
3608 'per.person_id = ben_asg.person_id (+)' ||
3609 ' and to_date(''' || to_char(p_effective_date,'DD-MM-RRRR') || ''',''DD-MM-RRRR'') between per.effective_start_date and per.effective_end_date ' ||
3610 ' and to_date(''' || to_char(p_effective_date,'DD-MM-RRRR') || ''',''DD-MM-YYYY'') between ben_asg.effective_start_date (+) ' ||
3611 ' and ben_asg.effective_end_date (+) ';
3612 END IF;
3613 ELSE
3614 l_dynamic_sql :=
3615 'select distinct(per.person_id) person_id ' ||
3616 'from ' ||
3617 'per_all_people_f per, ' ||
3618 'per_all_assignments_f ben_asg ' ||
3619 'where ' ||
3620 'per.person_id = ben_asg.person_id (+)' ||
3621 ' and to_date(''' || to_char(p_effective_date,'DD-MM-RRRR') || ''',''DD-MM-RRRR'') between per.effective_start_date and per.effective_end_date ' ||
3622 ' and to_date(''' || to_char(p_effective_date,'DD-MM-RRRR') || ''',''DD-MM-YYYY'') between ben_asg.effective_start_date (+) ' ||
3623 ' and ben_asg.effective_end_date (+) ';
3624 END IF;
3625
3626 -- For pensrv, Attribute check.Bug# 7341530
3627 IF (p_penserv_date is not null)
3628 THEN
3629 PQP_UTILITIES.get_config_type_values(
3630 p_configuration_type => 'PQP_GB_PENSERVER_ELIGBLTY_CONF'
3631 ,p_business_group_id => p_business_group_id
3632 ,p_legislation_code => 'GB' --g_legislation_code
3633 ,p_tab_config_values => l_pen_config_values
3634 );
3635
3636 IF l_pen_config_values.COUNT > 0
3637 THEN
3638 l_pen_membership_context := l_pen_config_values(l_pen_config_values.FIRST).pcv_information1;
3639 l_pen_membership_col := l_pen_config_values(l_pen_config_values.FIRST).pcv_information2;
3640
3641 IF l_pen_membership_col is not null
3642 THEN
3643
3644 IF l_pen_membership_context = 'Global Data Elements'
3645 THEN
3646 l_dynamic_sql := l_dynamic_sql || ' and ben_asg.'||l_pen_membership_col||' IS NOT NULL';
3647 ELSE
3648 l_dynamic_sql := l_dynamic_sql || ' and ben_asg.'||l_pen_membership_col||' IS NOT NULL'
3649 || ' and ben_asg.ASS_ATTRIBUTE_CATEGORY = '||''''||l_pen_membership_context||'''';
3650 END IF;
3651
3652 END IF;
3653
3654 END IF;
3655 END IF;
3656
3657 if nvl(P_ext_global_flag,'N') <> 'Y' then
3658 l_dynamic_sql := l_dynamic_sql||' and per.business_group_id = '||p_business_group_id||' ' ;
3659 end if ;
3660
3661
3662
3663 if g_debug then
3664 hr_utility.set_location('DATE FORMAT 1 ', 470);
3665 end if;
3666 end if;
3667
3668 -- intitialising
3669 l_pay_spl_process := 'N' ;
3670 l_pay_evt_non_asg := 'N';
3671
3672 if p_data_typ_cd in ('C') then
3673 l_dynamic_sql := ' ' ;
3674 --- for system extract change event
3675 -- when the celt criteria defined or not
3676 -- if the criterai value is null
3677 -- if the criteria value is not null and BEN is defined in the critertia
3678
3679 if g_chg_ext_from_ben = 'Y' then
3680 l_dynamic_ben_sql :=
3681 'select distinct(xcl.person_id) person_id ' ||
3682 'from ' ||
3683 'ben_ext_chg_evt_log xcl, ' ||
3684 'per_all_people_f per, ' ||
3685 'per_all_assignments_f ben_asg ' ||
3686 'where ' ||
3687 'xcl.person_id = per.person_id ' ||
3688 ' and xcl.person_id = ben_asg.person_id (+) ' ||
3689 ' and xcl.chg_eff_dt between per.effective_start_date and per.effective_end_date ' ||
3690 ' and xcl.chg_eff_dt between ben_asg.effective_start_date (+) ' ||
3691 ' and ben_asg.effective_end_date (+) '
3692 ;
3693
3694 if nvl(P_ext_global_flag, 'N' ) <> 'Y' then
3695 l_dynamic_ben_sql := l_dynamic_ben_sql ||
3696 ' and per.business_group_id = ' ||p_business_group_id ;
3697 end if ;
3698
3699
3700 end if ;
3701 -- for Payroll change event
3702 -- when the celt criteria defined and
3703 -- pay is part of the defintion
3704 hr_utility.set_location('g_chg_ext_from_pay ' || g_chg_ext_from_pay , 470);
3705
3706
3707 if g_chg_ext_from_pay = 'Y' then
3708 --- calcaulte the date for finding the non asg exisit in pay process events
3709
3710 if p_data_typ_cd in ('C') then
3711 if l_cad_exists = 'Y' then
3712 if l_cad_val1 in ('CHAD','CHED') then
3713 l_cad_date_from := hr_api.g_sot ;
3714 l_cad_date_to := hr_api.g_eot ;
3715 Else
3716 l_cad_date_from := ben_ext_util.calc_ext_date (p_ext_date_cd => l_cad_val1,
3717 p_abs_date => p_effective_date,
3718 p_ext_dfn_id => p_ext_dfn_id);
3719 l_cad_date_to := ben_ext_util.calc_ext_date (p_ext_date_cd => l_cad_val2,
3720 p_abs_date => p_effective_date,
3721 p_ext_dfn_id => p_ext_dfn_id);
3722 end if ;
3723
3724
3725 if l_ced_exists = 'Y' then
3726 if l_ced_val1 in ('CHAD','CHED') then
3727 l_cad_date_from := hr_api.g_sot ;
3728 l_cad_date_to := hr_api.g_eot ;
3729 Else
3730 l_ced_date_from := ben_ext_util.calc_ext_date (p_ext_date_cd => l_ced_val1,
3731 p_abs_date => p_effective_date,
3732 p_ext_dfn_id => p_ext_dfn_id);
3733 l_ced_date_to := ben_ext_util.calc_ext_date (p_ext_date_cd => l_ced_val2,
3734 p_abs_date => p_effective_date,
3735 p_ext_dfn_id => p_ext_dfn_id);
3736 end if;
3737 end if ;
3738
3739 End if ;
3740 End if ;
3741
3742 ---- check the payroll non asg exist
3743
3744 hr_utility.set_location('calling chck_non_asg_pay_evt ' , 470);
3745
3746 chck_non_asg_pay_evt(
3747 p_ext_crit_prfl_id => p_ext_crit_prfl_id ,
3748 p_ext_dfn_id => p_ext_dfn_id,
3749 p_business_group_id => p_business_group_id,
3750 p_effective_date => p_effective_date,
3751 p_effective_from_date => l_ced_date_from,
3752 p_effective_to_date => l_ced_date_to,
3753 p_actual_from_date => l_cad_date_from,
3754 p_actual_to_date => l_cad_date_to,
3755 p_adv_crit_exist => l_adv_exists,
3756 p_result => l_pay_evt_non_asg ) ;
3757
3758
3759 -- if non asg pay evt found then select the all the employees in
3760 -- the database with other person level criteria
3761 l_pay_spl_process := 'N' ;
3762
3763
3764 if nvl(l_pay_evt_non_asg,'N') = 'Y' then
3765 l_dynamic_pay_sql :=
3766 'select distinct(per.person_id) person_id ' ||
3767 'from ' ||
3768 'per_all_people_f per , ' ||
3769 'per_all_assignments_f ben_asg ' ||
3770 'where ' ||
3771 ' ben_asg.person_id = per.person_id ' ||
3772 ' and to_date(''' || to_char(p_effective_date,'DD-MM-RRRR') ||
3773 ''',''DD-MM-RRRR'') between per.effective_start_date and per.effective_end_date '
3774 ;
3775
3776 Else
3777 l_dynamic_pay_sql :=
3778 'select distinct(ben_asg.person_id) person_id ' ||
3779 'from ' ||
3780 'pay_process_events xcl, ' ||
3781 'per_all_assignments_f ben_asg ' ||
3782 'where ' ||
3783 ' xcl.assignment_id = ben_asg.assignment_id ' ||
3784 ' and xcl.effective_date between ben_Asg.effective_start_date and ben_Asg.effective_end_date ' ||
3785 ' and xcl.business_group_id = ben_Asg.business_group_id '
3786 ;
3787
3788 l_pay_spl_process := 'Y' ;
3789
3790 End if ;
3791
3792
3793 if nvl(P_ext_global_flag, 'N' ) <> 'Y' then
3794 if l_pay_spl_process = 'N' then
3795 l_dynamic_pay_sql := l_dynamic_pay_sql ||
3796 ' and per.business_group_id = ' ||p_business_group_id ;
3797 else
3798 l_dynamic_pay_sql := l_dynamic_pay_sql ||
3799 ' and ben_Asg.business_group_id = ' ||p_business_group_id ;
3800 end if ;
3801 end if ;
3802
3803 end if ;
3804
3805 -- End Update
3806 if g_debug then
3807 hr_utility.set_location('DATE FORMAT 2 ', 470);
3808 end if;
3809 end if; -- 'C'
3810
3811 if p_data_typ_cd in ('CM') then
3812 l_dynamic_sql :=
3813 'select distinct(pcm.person_id) person_id ' ||
3814 'from ' ||
3815 'ben_per_cm_f pcm, ' ||
3816 'ben_per_cm_prvdd_f pcp, ' ||
3817 'per_all_people_f per, ' ||
3818 'per_all_assignments_f ben_asg ' ||
3819 'where ' ||
3820 'pcm.per_cm_id = pcp.per_cm_id ' ||
3821 ' and pcm.person_id = per.person_id ' ||
3822 ' and per.person_id = ben_asg.person_id (+) ' ||
3823 ' and to_date(''' || to_char(p_effective_date,'DD-MM-RRRR') ||
3824 ''',''DD-MM-RRRR'') between per.effective_start_date and per.effective_end_date ' ||
3825 ' and to_date(''' || to_char(p_effective_date,'DD-MM-RRRR') ||
3826 ''',''DD-MM-RRRR'') between pcm.effective_start_date and pcm.effective_end_date ' ||
3827 ' and to_date(''' || to_char(p_effective_date,'DD-MM-RRRR') ||
3828 ''',''DD-MM-RRRR'') between pcp.effective_start_date and pcp.effective_end_date ' ||
3829 'and to_date(''' || to_char(p_effective_date,'DD-MM-RRRR') ||
3830 ''',''DD-MM-RRRR'') between ben_asg.effective_start_date (+) ' ||
3831 'and ben_asg.effective_end_date (+) ';
3832
3833 if nvl(P_ext_global_flag,'N') <> 'Y' then
3834 l_dynamic_sql := l_dynamic_sql||' and pcm.business_group_id = '||p_business_group_id||' ' ;
3835 end if ;
3836
3837 if g_debug then
3838 hr_utility.set_location('DATE FORMAT 3 ', 470);
3839 end if;
3840 end if; -- 'CM'
3841
3842 --- CWB
3843
3844 if p_data_typ_cd in ('CW') then
3845 l_dynamic_sql :=
3846 'select distinct(cpi.person_id) person_id ' ||
3847 'from ' ||
3848 'ben_cwb_person_info cpi, ' ||
3849 'per_all_people_f per, ' ||
3850 'per_all_assignments_f ben_asg ' ||
3851 'where ' ||
3852 'cpi.person_id = per.person_id ' ||
3853 ' and cpi.person_id = ben_asg.person_id (+) ' ||
3854 -- ' and cpi.business_group_id = ' || p_business_group_id ||
3855 ' and cpi.effective_date between per.effective_start_date and per.effective_end_date ' ||
3856 ' and cpi.effective_date between ben_asg.effective_start_date (+) ' ||
3857 ' and ben_asg.effective_end_date (+) '
3858 ;
3859
3860 -- End Update
3861 end if;
3862 --- CWB
3863
3864
3865 -- genral criteria
3866 if l_pid_exists = 'Y' then
3867
3868 if l_pay_spl_process = 'N' then
3869 if l_pid_exclude = 'N' then
3870 l_dynamic_sql := l_dynamic_sql || ' and ( per.person_id in ';
3871 else
3872 l_dynamic_sql := l_dynamic_sql || ' and ( per.person_id not in ';
3873 end if;
3874
3875 /*
3876 l_dynamic_sql := l_dynamic_sql ||
3877 '(select to_number(decode(ltrim (xcv.val_1,''0123456789''),NULL,xcv.val_1,-1))
3878 from ben_ext_crit_typ xct ,ben_ext_crit_val xcv ' ||
3879 ' where xct.ext_crit_prfl_id = ' || p_ext_crit_prfl_id ||
3880 ' and xct.ext_crit_typ_id = xcv.ext_crit_typ_id and '||
3881 'xct.crit_typ_cd = ''PID'') ';
3882 */
3883
3884
3885 Else
3886 if l_pid_exclude = 'N' then
3887 l_dynamic_sql := l_dynamic_sql || ' and ( ben_asg.person_id in ';
3888 else
3889 l_dynamic_sql := l_dynamic_sql || ' and ( ben_asg.person_id not in ';
3890 end if;
3891 End if ;
3892
3893 --- get the unique id in variable
3894 l_crit_val_all := null ;
3895 get_ext_crit_string(p_ext_crit_prfl_id => p_ext_crit_prfl_id ,
3896 p_ext_crit_typ => 'PID' ,
3897 p_string => l_crit_val_all ) ;
3898
3899 l_dynamic_sql := l_dynamic_sql || nvl(l_crit_val_all, '(-1)') || ')' ;
3900
3901
3902 end if; -- eof PID
3903 --
3904
3905 if l_pasgset_exists = 'Y' then
3906
3907 if l_pasgset_exclude = 'N' then
3908 l_dynamic_sql := l_dynamic_sql || ' and ( exists ';
3909 else
3910 l_dynamic_sql := l_dynamic_sql || ' and ( not exists ';
3911 end if ;
3912 --- this logic is taken from the pkg pyadcutl.pkb
3913 l_dynamic_sql := l_dynamic_sql ||
3914 '( SELECT 1 FROM hr_assignment_sets aset , ben_ext_crit_typ xct ,ben_ext_crit_val xcv ' ||
3915 ' where xct.ext_crit_prfl_id = ' || p_ext_crit_prfl_id ||
3916 ' and xct.ext_crit_typ_id = xcv.ext_crit_typ_id and '||
3917 ' xct.crit_typ_cd = ''PASGSET'' and to_number(xcv.val_1) = aset.assignment_set_id ' ||
3918 ' and (not exists (select 1 from hr_assignment_set_amendments hasa ' ||
3919 ' where hasa.assignment_set_id = aset.assignment_set_id and hasa.include_or_exclude = ''I'') ' ||
3920 ' or exists (select 1 from hr_assignment_set_amendments hasa ' ||
3921 ' where hasa.assignment_set_id=aset.assignment_set_id '||
3922 ' and hasa.assignment_id = ben_asg.assignment_id and hasa.include_or_exclude = ''I'' ) '||
3923 ' ) ' ||
3924 ' and not exists (select 1 from hr_assignment_set_amendments hasa ' ||
3925 ' where hasa.assignment_set_id=aset.assignment_set_id'||
3926 ' and hasa.assignment_id = ben_asg.assignment_id and hasa.include_or_exclude = ''E'') )) ' ;
3927
3928 end if ; -- eof PASGSET
3929
3930 if l_por_exists = 'Y' then
3931 if l_por_exclude = 'N' then
3932 l_dynamic_sql := l_dynamic_sql||' and (( ben_asg.organization_id in ';
3933 else
3934 l_dynamic_sql := l_dynamic_sql ||' and ((ben_asg.organization_id is null) or (ben_asg.organization_id not in ';
3935 end if;
3936 /*
3937 if l_pay_spl_process = 'N' then
3938 l_dynamic_sql := l_dynamic_sql ||
3939 '(select to_number(decode(ltrim (xcv.val_1,''0123456789''),NULL,xcv.val_1,-1))
3940 from ben_ext_crit_typ xct ,ben_ext_crit_val xcv ' ||
3941 ' where xct.ext_crit_prfl_id = ' || p_ext_crit_prfl_id ||
3942 ' and xct.ext_crit_typ_id = xcv.ext_crit_typ_id and '||
3943 'xct.crit_typ_cd = ''POR''))) ';
3944
3945 Else
3946 */
3947
3948
3949 --- get the unique id in variable
3950 l_crit_val_all := null ;
3951 get_ext_crit_string(p_ext_crit_prfl_id => p_ext_crit_prfl_id ,
3952 p_ext_crit_typ => 'POR' ,
3953 p_string => l_crit_val_all ) ;
3954
3955 l_dynamic_sql := l_dynamic_sql || nvl(l_crit_val_all, '(-1)') || '))' ;
3956
3957 end if; -- eof POR
3958 --
3959 if l_pas_exists = 'Y' then
3960 if l_pas_exclude = 'N' then
3961 l_dynamic_sql := l_dynamic_sql||' and ( (ben_asg.assignment_status_type_id in ';
3962 else
3963 l_dynamic_sql := l_dynamic_sql || ' and ((ben_asg.assignment_status_type_id is null) or
3964 (ben_asg.assignment_status_type_id not in ';
3965 end if;
3966
3967 --- get the unique id in variable
3968 l_crit_val_all := null ;
3969 get_ext_crit_string(p_ext_crit_prfl_id => p_ext_crit_prfl_id ,
3970 p_ext_crit_typ => 'PAS' ,
3971 p_string => l_crit_val_all ) ;
3972
3973 l_dynamic_sql := l_dynamic_sql || nvl(l_crit_val_all, '(-1)') || '))' ;
3974
3975 /*
3976 l_dynamic_sql := l_dynamic_sql ||
3977 '(select to_number(decode(ltrim (xcv.val_1,''0123456789''),NULL,xcv.val_1,-1)) |
3978 ' from ben_ext_crit_typ xct ,ben_ext_crit_val xcv ' ||
3979 ' where xct.ext_crit_prfl_id = ' || p_ext_crit_prfl_id ||
3980 ' and ben_asg.assignment_status_type_id = to_number(xcv.val_1) '||
3981 ' and xct.ext_crit_typ_id = xcv.ext_crit_typ_id '||
3982 ' and xct.crit_typ_cd = ''PAS''))) ';
3983 */
3984
3985 end if; -- eof PAS
3986 --
3987 if l_plo_exists = 'Y' then
3988 if l_plo_exclude = 'N' then
3989 l_dynamic_sql := l_dynamic_sql || ' and ( (ben_asg.location_id in ';
3990 else
3991 l_dynamic_sql := l_dynamic_sql || ' and ((ben_asg.location_id is null) or (ben_asg.location_id not in ';
3992 end if;
3993 /*
3994 l_dynamic_sql := l_dynamic_sql ||
3995 '(select to_number(decode(ltrim (xcv.val_1,''0123456789''),NULL,xcv.val_1,-1)) ' ||
3996 ' from ben_ext_crit_typ xct ,ben_ext_crit_val xcv ' ||
3997 ' where xct.ext_crit_prfl_id = ' || p_ext_crit_prfl_id ||
3998 ' and ben_asg.location_id = to_number(xcv.val_1) '||
3999 ' and xct.ext_crit_typ_id = xcv.ext_crit_typ_id and '||
4000 'xct.crit_typ_cd = ''PLO''))) ';
4001 */
4002
4003 --- get the unique id in variable
4004 l_crit_val_all := null ;
4005 get_ext_crit_string(p_ext_crit_prfl_id => p_ext_crit_prfl_id ,
4006 p_ext_crit_typ => 'PLO' ,
4007 p_string => l_crit_val_all ) ;
4008
4009 l_dynamic_sql := l_dynamic_sql || nvl(l_crit_val_all, '(-1)') || '))' ;
4010
4011
4012 end if; -- eof PLO
4013
4014 -- person payroll id
4015 if l_rrl_exists = 'Y' then
4016 if l_rrl_exclude = 'N' then
4017 l_dynamic_sql := l_dynamic_sql || ' and ( (ben_asg.payroll_id in ';
4018 else
4019 l_dynamic_sql := l_dynamic_sql || ' and ((ben_asg.payroll_id is null) or (ben_asg.payroll_id not in ';
4020 end if;
4021 l_crit_val_all := null ;
4022 get_ext_crit_string(p_ext_crit_prfl_id => p_ext_crit_prfl_id ,
4023 p_ext_crit_typ => 'RRL' ,
4024 p_string => l_crit_val_all ) ;
4025
4026 l_dynamic_sql := l_dynamic_sql || nvl(l_crit_val_all, '(-1)') || '))' ;
4027
4028 end if; -- eof RRL
4029
4030
4031
4032 if l_pbg_exists = 'Y' then
4033 if l_pay_spl_process = 'N' then
4034 if l_pbg_exclude = 'N' then
4035 l_dynamic_sql := l_dynamic_sql || ' and ( (per.benefit_group_id in ';
4036 else
4037 l_dynamic_sql := l_dynamic_sql || ' and ((per.benefit_group_id is null) or (per.benefit_group_id not in ';
4038 end if;
4039 l_dynamic_sql := l_dynamic_sql ||
4040 '(select to_number(decode(ltrim (xcv.val_1,''0123456789''),NULL,xcv.val_1,-1))
4041 from ben_ext_crit_typ xct ,ben_ext_crit_val xcv ' ||
4042 ' where xct.ext_crit_prfl_id = ' || p_ext_crit_prfl_id ||
4043 ' and xct.ext_crit_typ_id = xcv.ext_crit_typ_id and '||
4044 'xct.crit_typ_cd = ''PBG''))) ';
4045 else
4046
4047 if l_pbg_exclude = 'N' then
4048 l_dynamic_sql := l_dynamic_sql || ' and ( ( exists ';
4049 else
4050 l_dynamic_sql := l_dynamic_sql || ' and ( ( not exists ';
4051 end if;
4052
4053 l_dynamic_sql := l_dynamic_sql ||
4054 '(select ''x'' from per_all_people_f per , ben_ext_crit_typ xct, ben_ext_crit_val xcv where ' ||
4055 ' per.person_id = ben_asg.person_id ' ||
4056 ' and to_date(''' || to_char(p_effective_date,'DD-MM-RRRR') ||
4057 ''',''DD-MM-RRRR'') between per.effective_start_date and per.effective_end_date ' ||
4058 ' and per.benefit_group_id = to_number(xcv.val_1) '||
4059 ' and xct.ext_crit_prfl_id = ' || p_ext_crit_prfl_id ||
4060 ' and xct.ext_crit_typ_id = xcv.ext_crit_typ_id '||
4061 ' and xct.crit_typ_cd = ''PBG'') )) ';
4062
4063 end if ;
4064
4065 end if; -- eof PBG
4066
4067 -- Person business group id
4068 if l_pbgr_exists = 'Y' then
4069 if l_pay_spl_process = 'N' then
4070 if l_pbgr_exclude = 'N' then
4071 l_dynamic_sql := l_dynamic_sql || ' and ( per.business_group_id in ';
4072 else
4073 l_dynamic_sql := l_dynamic_sql || ' and ( per.business_group_id not in ';
4074 end if;
4075 else
4076 if l_pbgr_exclude = 'N' then
4077 l_dynamic_sql := l_dynamic_sql || ' and ( ben_asg.business_group_id in ';
4078 else
4079 l_dynamic_sql := l_dynamic_sql || ' and ( ben_asg.business_group_id not in ';
4080 end if;
4081 end if ;
4082
4083 --- Tilak get the unique id in variable
4084 l_crit_val_all := null ;
4085 get_ext_crit_string(p_ext_crit_prfl_id => p_ext_crit_prfl_id ,
4086 p_ext_crit_typ => 'PBGR' ,
4087 p_string => l_crit_val_all ) ;
4088 l_dynamic_sql := l_dynamic_sql || nvl(l_crit_val_all, '(-1)') || ')' ;
4089
4090 /*
4091 l_dynamic_sql := l_dynamic_sql ||
4092 '(select to_number(decode(ltrim (xcv.val_1,''0123456789''),NULL,xcv.val_1,-1))
4093 from ben_ext_crit_typ xct ,ben_ext_crit_val xcv ' ||
4094 ' where xct.ext_crit_prfl_id = ' || p_ext_crit_prfl_id ||
4095 ' and xct.ext_crit_typ_id = xcv.ext_crit_typ_id and '||
4096 'xct.crit_typ_cd = ''PBGR'') ';
4097 */
4098
4099 end if; -- eof PBGR
4100
4101 -- person type usage
4102 if l_ppt_exists = 'Y' then
4103
4104 hr_utility.set_location('PPT excluded ' || l_ppt_exclude, 99 ) ;
4105 if l_pay_spl_process = 'N' then
4106 if l_ppt_exclude = 'N' then
4107 l_dynamic_sql := l_dynamic_sql || ' and per.person_id in ';
4108 else
4109 l_dynamic_sql := l_dynamic_sql || ' and per.person_id not in ';
4110 end if;
4111 else
4112 if l_ppt_exclude = 'N' then
4113 l_dynamic_sql := l_dynamic_sql || ' and ben_asg.person_id in ';
4114 else
4115 l_dynamic_sql := l_dynamic_sql || ' and ben_asg.person_id not in ';
4116 end if;
4117
4118 end if ;
4119
4120 -- 6642051
4121 if nvl(P_ext_global_flag,'N') = 'Y' then
4122
4123 l_dynamic_sql := l_dynamic_sql ||
4124 ' (select ptu.person_id from per_person_type_usages_f ptu ' ;
4125 if l_pay_spl_process = 'N' then
4126 l_dynamic_sql := l_dynamic_sql ||
4127 ' where ptu.person_id = per.person_id ' ;
4128 else
4129 l_dynamic_sql := l_dynamic_sql ||
4130 ' where ptu.person_id = ben_asg.person_id ' ;
4131 end if ;
4132
4133 l_dynamic_sql := l_dynamic_sql ||
4134 ' and to_date(''' || to_char(p_effective_date,'DD-MM-RRRR') ||
4135 ''',''DD-MM-RRRR'') between ptu.effective_start_date and ptu.effective_end_date ' ||
4136 ' and ptu.person_type_id in '||
4137 ' (select to_number(decode(ltrim (xcv.val_1,''0123456789''),NULL,xcv.val_1,-1)) ' ||
4138 ' from ben_ext_crit_typ xct , ben_ext_crit_val xcv ' ||
4139 ' where xct.ext_crit_prfl_id = ' || p_ext_crit_prfl_id ||
4140 ' and xct.ext_crit_typ_id = xcv.ext_crit_typ_id and '||
4141 ' xct.crit_typ_cd = ''PPT'')) ';
4142
4143 else
4144
4145 --- get the unique id in variable
4146 l_crit_val_all := null ;
4147 get_ext_crit_string(p_ext_crit_prfl_id => p_ext_crit_prfl_id ,
4148 p_ext_crit_typ => 'PPT' ,
4149 p_string => l_crit_val_all ) ;
4150
4151
4152 if l_pay_spl_process = 'N' then
4153 l_dynamic_sql := l_dynamic_sql ||
4154 ' (select ptu.person_id from per_person_type_usages_f ptu where ptu.person_id = per.person_id ' ;
4155 else
4156 l_dynamic_sql := l_dynamic_sql ||
4157 ' (select ptu.person_id from per_person_type_usages_f ptu where ptu.person_id = ben_Asg.person_id ' ;
4158 end if ;
4159
4160 l_dynamic_sql := l_dynamic_sql ||
4161 ' and to_date(''' || to_char(p_effective_date,'DD-MM-RRRR') ||
4162 ''',''DD-MM-RRRR'') between ptu.effective_start_date and ptu.effective_end_date ' ||
4163 ' and ptu.person_type_id in '|| nvl(l_crit_val_all, '(-1)') || ')' ;
4164
4165 end if ;
4166
4167
4168 /*
4169 ' (select to_number(decode(ltrim (xcv.val_1,''0123456789''),NULL,xcv.val_1,-1))
4170 from ben_ext_crit_typ xct ,ben_ext_crit_val xcv ' ||
4171 ' where xct.ext_crit_prfl_id = ' || p_ext_crit_prfl_id ||
4172 ' and xct.ext_crit_typ_id = xcv.ext_crit_typ_id '||
4173 ' and ptu.person_type_id = to_number(xcv.val_1) and '||
4174 ' xct.crit_typ_cd = ''PPT'')) ';
4175 */
4176
4177 end if;
4178
4179 if l_cce_exists = 'Y' and p_data_typ_cd in ('C') then
4180
4181 if l_dynamic_BEN_sql is not null then
4182 if l_cce_exclude = 'N' then
4183 l_dynamic_BEN_sql := l_dynamic_BEN_sql || ' and ( xcl.chg_evt_cd in ';
4184 else
4185 l_dynamic_BEN_sql := l_dynamic_BEN_sql || ' and ( xcl.chg_evt_cd not in ';
4186 end if;
4187
4188
4189 l_crit_val_all := null ;
4190 get_ext_crit_string(p_ext_crit_prfl_id => p_ext_crit_prfl_id ,
4191 p_ext_crit_typ => 'CCE' ,
4192 p_ext_num_str => 'S' ,
4193 p_string => l_crit_val_all ) ;
4194
4195 l_dynamic_BEN_sql := l_dynamic_BEN_sql || nvl(l_crit_val_all, '(''-1'')') || ')' ;
4196
4197 /*
4198
4199 l_dynamic_BEN_sql := l_dynamic_BEN_sql ||
4200 '(select xcv.val_1 from ben_ext_crit_typ xct ,ben_ext_crit_val xcv ' ||
4201 ' where xct.ext_crit_prfl_id = ' || p_ext_crit_prfl_id ||
4202 ' and xct.ext_crit_typ_id = xcv.ext_crit_typ_id '||
4203 ' and xct.crit_typ_cd = ''CCE'') ';
4204 */
4205
4206 end if ;
4207 end if ; -- eof CCE
4208
4209 if l_cpe_exists = 'Y' and p_data_typ_cd in ('C') then
4210
4211 -- if any issue with following sql , pls contact PQP
4212 if l_dynamic_PAY_sql is not null then
4213
4214 if nvl(l_pay_evt_non_asg,'N') = 'N' then
4215
4216 ---get the unique id in variable
4217 l_crit_val_all := null ;
4218 get_ext_crit_string(p_ext_crit_prfl_id => p_ext_crit_prfl_id ,
4219 p_ext_crit_typ => 'CPE' ,
4220 p_string => l_crit_val_all ) ;
4221
4222
4223 if l_cpe_exclude = 'N' then
4224 l_dynamic_PAY_Sql := l_dynamic_PAY_Sql || ' and exists ';
4225 else
4226 l_dynamic_PAY_Sql := l_dynamic_PAY_Sql || ' and not exists ';
4227 end if;
4228 /* Added for Penserver Performance (check elements in elements sets if table_name is PAY_ELEMENT_ENTRIES_F */
4229 -- BEGIN for Pensrv
4230 if(p_penserv_date is not null)
4231 then
4232 -- END for Pensrv
4233 -- as per the babu sql
4234 l_dynamic_PAY_sql := l_dynamic_PAY_sql ||
4235 ' (select pde.event_group_id ' ||
4236 ' from pay_datetracked_events pde, ' ||
4237 ' pay_event_updates peu ' ||
4238 -- BEGIN for Pensrv
4239 ' ,pay_dated_tables pdt '||
4240 -- END for Pensrv
4241 ' where ' ||
4242 --' and (pde.business_group_id = bg.organization_id OR (pde.business_group_id IS NULL ' ||
4243 --' and (pde.legislation_code is null or pde.legislation_code = bg.org_information9) ) ) ' ||
4244 --' and xct.crit_typ_cd = ''CPE'' and xct.ext_crit_prfl_id = ' || p_ext_crit_prfl_id ||
4245 --' and xct.ext_crit_typ_id = xcv.ext_crit_typ_id ' ||
4246 --' and pde.event_group_id = to_number(xcv.val_1) ' ||
4247 ' pde.event_group_id in ' || l_crit_val_all ||
4248 ' and xcl.event_update_id = peu.event_update_id ' ||
4249 ' and peu.dated_table_id = pde.dated_table_id ' ||
4250 --' and (pde.column_name is null or pde.column_name = peu.column_name) ' ||
4251 --' and (peu.business_group_id = pde.business_group_id OR (peu.business_group_id is null ' ||
4252 --' and (peu.legislation_code is null or peu.legislation_code = pde.legislation_code)))' ||
4253 -- BEGIN for Pensrv
4254 -- Modified the below sql to cater for purge events more efficiently
4255 ' AND pde.dated_table_id = pdt.dated_table_id ' ||
4256 ' AND ((pdt.table_name = '||'''PAY_ELEMENT_ENTRIES_F'''||
4257 ' AND (EXISTS (SELECT 1 ' ||
4258 ' FROM pay_event_group_usages pegu ' ||
4259 ' ,pay_element_type_rules petr ' ||
4260 ' ,pay_element_entries_f peef ' ||
4261 ' WHERE pegu.event_group_id = pde.event_group_id ' ||
4262 ' AND ((xcl.noted_value IS NOT NULL ' ||
4263 ' AND xcl.noted_value = petr.element_type_id ' ||
4264 ' AND petr.element_set_id = pegu.element_set_id ' ||
4265 ' ) ' ||
4266 ' OR ' ||
4267 ' (xcl.surrogate_key = peef.element_entry_id ' ||
4268 ' AND peef.assignment_id = ben_asg.assignment_id ' ||
4269 ' AND peef.element_type_id = petr.element_type_id ' ||
4270 ' AND petr.element_set_id = pegu.element_set_id ' ||
4271 ' ) ' ||
4272 ' ) ' ||
4273 ' ) ' ||
4274 ' ) ' ||
4275 ' ) ' ||
4276 ' OR ' ||
4277 ' (pdt.table_name = '||'''PAY_ELEMENT_ENTRY_VALUES_F'''||
4278 ' AND (EXISTS (SELECT 1 ' ||
4279 ' FROM pay_event_group_usages pegu ' ||
4280 ' ,pay_element_type_rules petr ' ||
4281 ' ,pay_element_entries_f peef ' ||
4282 ' ,pay_element_entry_values_f peevf ' ||
4283 ' WHERE peef.assignment_id = ben_asg.assignment_id ' ||
4284 ' AND peef.element_type_id = petr.element_type_id ' ||
4285 ' AND petr.element_set_id = pegu.element_set_id ' ||
4286 ' AND pegu.event_group_id = pde.event_group_id ' ||
4287 ' AND peef.element_entry_id = peevf.element_entry_id ' ||
4288 ' AND xcl.surrogate_key = peevf.element_entry_value_id ' ||
4289 ' ) ' ||
4290 ' ) ' ||
4291 ' ) ' ||
4292 ' OR ' ||
4293 ' (pdt.table_name not in (' || '''PAY_ELEMENT_ENTRIES_F''' ||','|| '''PAY_ELEMENT_ENTRY_VALUES_F''' ||
4294 ' )) ' ||
4295 ' ) ' ||
4296 -- End for pensrv
4297 ' ) ' ;
4298 else
4299 -- as per the babu sql
4300 l_dynamic_PAY_sql := l_dynamic_PAY_sql ||
4301 ' (select pde.event_group_id ' ||
4302 ' from pay_datetracked_events pde, ' ||
4303 ' pay_event_updates peu ' ||
4304 ' where ' ||
4305 --' and (pde.business_group_id = bg.organization_id OR (pde.business_group_id IS NULL ' ||
4306 --' and (pde.legislation_code is null or pde.legislation_code = bg.org_information9) ) ) ' ||
4307 --' and xct.crit_typ_cd = ''CPE'' and xct.ext_crit_prfl_id = ' || p_ext_crit_prfl_id ||
4308 --' and xct.ext_crit_typ_id = xcv.ext_crit_typ_id ' ||
4309 --' and pde.event_group_id = to_number(xcv.val_1) ' ||
4310 ' pde.event_group_id in ' || l_crit_val_all ||
4311 ' and xcl.event_update_id = peu.event_update_id ' ||
4312 ' and peu.dated_table_id = pde.dated_table_id ' ||
4313 --' and (pde.column_name is null or pde.column_name = peu.column_name) ' ||
4314 --' and (peu.business_group_id = pde.business_group_id OR (peu.business_group_id is null ' ||
4315 --' and (peu.legislation_code is null or peu.legislation_code = pde.legislation_code)))' ||
4316 ' ) ' ;
4317 end if;
4318 end if ;
4319 end if ;
4320 end if; -- CPE
4321 -- change event actual date
4322 if l_cad_exists = 'Y' and p_data_typ_cd in ('C') then
4323 if g_debug then
4324 hr_utility.set_location(' called from benxthrd 1 '|| l_cad_val1 ,514);
4325 end if;
4326 if l_cad_val1 in ('CHAD','CHED') then
4327 l_cad_date_from := hr_api.g_sot ;
4328 l_cad_date_to := hr_api.g_eot ;
4329 Else
4330 l_cad_date_from := ben_ext_util.calc_ext_date (p_ext_date_cd => l_cad_val1,
4331 p_abs_date => p_effective_date,
4332 p_ext_dfn_id => p_ext_dfn_id);
4333 l_cad_date_to := ben_ext_util.calc_ext_date (p_ext_date_cd => l_cad_val2,
4334 p_abs_date => p_effective_date,
4335 p_ext_dfn_id => p_ext_dfn_id);
4336 end if ;
4337
4338 if l_dynamic_BEN_sql is not null then
4339
4340 if l_cad_exclude = 'N' then
4341 l_dynamic_BEN_sql := l_dynamic_BEN_sql || ' and xcl.chg_actl_dt between to_date(''' ||
4342 to_char(nvl(l_cad_date_from,hr_api.g_sot),'DD-MM-RRRR HH24:MI:SS')||
4343 ''',''DD-MM-RRRR HH24:MI:SS'') and to_date(''' ||
4344 to_char(nvl(l_cad_date_to+0.99999,hr_api.g_eot),'DD-MM-RRRR HH24:MI:SS') || ''',''DD-MM-RRRR HH24:MI:SS'') ';
4345 else
4346 l_dynamic_BEN_sql := l_dynamic_BEN_sql ||
4347 ' and xcl.chg_actl_dt not between to_date(''' ||
4348 to_char(nvl(l_cad_date_from,hr_api.g_sot),'DD-MM-RRRR HH24:MI:SS') ||
4349 ''',''DD-MM-RRRR HH24:MI:SS'') and to_date(''' ||
4350 to_char(nvl(l_cad_date_to+0.99999,hr_api.g_eot),'DD-MM-RRRR HH24:MI:SS') ||''',''DD-MM-RRRR HH24:MI:SS'') ';
4351 end if;
4352 end if ;
4353
4354 if l_dynamic_PAY_sql is not null then
4355 if nvl(l_pay_evt_non_asg,'N') = 'N' then
4356 if l_cad_exclude = 'N' then
4357 l_dynamic_PAY_sql := l_dynamic_PAY_sql || ' and xcl.CREATION_DATE between to_date(''' ||
4358 to_char(nvl(l_cad_date_from,hr_api.g_sot),'DD-MM-RRRR HH24:MI:SS') ||
4359 ''',''DD-MM-RRRR HH24:MI:SS'') and to_date(''' ||
4360 to_char(nvl(l_cad_date_to+0.99999,hr_api.g_eot),'DD-MM-RRRR HH24:MI:SS')||''',''DD-MM-RRRR HH24:MI:SS'')';
4361 else
4362 l_dynamic_PAY_sql := l_dynamic_PAY_sql ||
4363 ' and xcl.CREATION_DATE not between to_date(''' ||
4364 to_char(nvl(l_cad_date_from,hr_api.g_sot),'DD-MM-RRRR HH24:MI:SS') ||
4365 ''',''DD-MM-RRRR HH24:MI:SS'') and to_date(''' ||
4366 to_char(nvl(l_cad_date_to+0.99999,hr_api.g_eot),'DD-MM-YYYY HH24:MI:SS')||''',''DD-MM-RRRR HH24:MI:SS'') ';
4367 end if;
4368 end if ;
4369 end if ;
4370 end if; -- CAD
4371 -- chage event Effective date
4372 if l_ced_exists = 'Y' and p_data_typ_cd in ('C') then
4373 if g_debug then
4374 hr_utility.set_location(' called from benxthrd 2 '|| l_ced_val1 ,514);
4375 end if;
4376 if l_ced_val1 in ('CHAD','CHED') then
4377 l_cad_date_from := hr_api.g_sot ;
4378 l_cad_date_to := hr_api.g_eot ;
4379 Else
4380 l_ced_date_from := ben_ext_util.calc_ext_date (p_ext_date_cd => l_ced_val1,
4381 p_abs_date => p_effective_date,
4382 p_ext_dfn_id => p_ext_dfn_id);
4383 l_ced_date_to := ben_ext_util.calc_ext_date (p_ext_date_cd => l_ced_val2,
4384 p_abs_date => p_effective_date,
4385 p_ext_dfn_id => p_ext_dfn_id);
4386
4387 End if ;
4388
4389 if l_dynamic_BEN_sql is not null then
4390
4391 if l_ced_exclude = 'N' then
4392 l_dynamic_BEN_sql := l_dynamic_BEN_sql || ' and xcl.chg_eff_dt between to_date(''' ||
4393 to_char(nvl(l_ced_date_from,hr_api.g_sot),'DD-MM-RRRR') || ''',''DD-MM-RRRR'') and to_date(''' ||
4394 to_char(nvl(l_ced_date_to,hr_api.g_eot),'DD-MM-RRRR') || ''',''DD-MM-RRRR'') ';
4395 else
4396 l_dynamic_BEN_sql := l_dynamic_BEN_sql ||
4397 ' and xcl.chg_eff_dt not between to_date(''' ||
4398 to_char(nvl(l_ced_date_from,hr_api.g_sot),'DD-MM-RRRR') || ''',''DD-MM-RRRR'') and to_date(''' ||
4399 to_char(nvl(l_ced_date_to,hr_api.g_eot),'DD-MM-RRRR') || ''',''DD-MM-RRRR'') ';
4400 end if;
4401 end if ;
4402
4403 /*
4404 if l_dynamic_PAY_sql is not null then
4405 if nvl(l_pay_evt_non_asg,'N') = 'N' then
4406 if l_ced_exclude = 'N' then
4407 l_dynamic_PAY_sql := l_dynamic_PAY_sql || ' and xcl.EFFECTIVE_DATE between to_date(''' ||
4408 to_char(nvl(l_ced_date_from,hr_api.g_sot),'DD-MM-RRRR') || ''',''DD-MM-RRRR'') and to_date(''' ||
4409 to_char(nvl(l_ced_date_to,hr_api.g_eot),'DD-MM-RRRR') || ''',''DD-MM-RRRR'') ';
4410 else
4411 l_dynamic_PAY_sql := l_dynamic_PAY_sql ||
4412 ' and xcl.EFFECTIVE_DATE not between to_date(''' ||
4413 to_char(nvl(l_ced_date_from,hr_api.g_sot),'DD-MM-RRRR') || ''',''DD-MM-RRRR'') and to_date(''' ||
4414 to_char(nvl(l_ced_date_to,hr_api.g_eot),'DD-MM-RRRR') || ''',''DD-MM-RRRR'') ';
4415 end if;
4416 end if ;
4417 end if ;
4418 end if;
4419 */
4420 if l_dynamic_PAY_sql is not null then
4421 if nvl(l_pay_evt_non_asg,'N') = 'N' then
4422 if l_ced_exclude = 'N' then
4423 -- penserver performance fix - vkodedal
4424 if(p_penserv_date is not null)
4425 then
4426
4427 l_dynamic_PAY_sql := l_dynamic_PAY_sql || ' and ( ( xcl.EFFECTIVE_DATE between to_date(''' ||
4428 to_char(nvl(l_ced_date_from,hr_api.g_sot),'DD-MM-RRRR') || ''',''DD-MM-RRRR'') and to_date(''' ||
4429 to_char(nvl(l_ced_date_to,hr_api.g_eot),'DD-MM-RRRR') || ''',''DD-MM-RRRR'') '
4430 || ' and xcl.CREATION_DATE between to_date(''' ||
4431 to_char(nvl(p_penserv_date,hr_api.g_sot),'DD-MM-RRRR') || ''',''DD-MM-RRRR'') and to_date(''' ||
4432 to_char(nvl(l_ced_date_to + 1,hr_api.g_eot),'DD-MM-RRRR') || ''',''DD-MM-RRRR'') )'
4433 || ' or ( xcl.CREATION_DATE between to_date(''' ||
4434 to_char(nvl(l_ced_date_from,hr_api.g_sot),'DD-MM-RRRR') || ''',''DD-MM-RRRR'') and to_date(''' ||
4435 to_char(nvl(l_ced_date_to,hr_api.g_eot),'DD-MM-RRRR') || ''',''DD-MM-RRRR'') '
4436 || ' and xcl.EFFECTIVE_DATE between to_date(''' ||
4437 to_char(nvl(p_penserv_date,hr_api.g_sot),'DD-MM-RRRR') || ''',''DD-MM-RRRR'') and to_date(''' ||
4438 to_char(nvl(l_ced_date_to,hr_api.g_eot),'DD-MM-RRRR') || ''',''DD-MM-RRRR'') ))';
4439
4440 -- For pensrv, Attribute check.Bug# 7341530
4441
4442 PQP_UTILITIES.get_config_type_values(
4443 p_configuration_type => 'PQP_GB_PENSERVER_ELIGBLTY_CONF'
4444 ,p_business_group_id => p_business_group_id
4445 ,p_legislation_code => 'GB' --g_legislation_code
4446 ,p_tab_config_values => l_pen_config_values
4447 );
4448
4449 IF l_pen_config_values.COUNT > 0
4450 THEN
4451 l_pen_membership_context := l_pen_config_values(l_pen_config_values.FIRST).pcv_information1;
4452 l_pen_membership_col := l_pen_config_values(l_pen_config_values.FIRST).pcv_information2;
4453
4454 IF l_pen_membership_col is not null
4455 THEN
4456
4457 IF l_pen_membership_context = 'Global Data Elements'
4458 THEN
4459 l_dynamic_PAY_sql := l_dynamic_PAY_sql || ' and ben_asg.'||l_pen_membership_col||' IS NOT NULL';
4460 ELSE
4461 l_dynamic_PAY_sql := l_dynamic_PAY_sql || ' and ben_asg.'||l_pen_membership_col||' IS NOT NULL'
4462 || ' and ben_asg.ASS_ATTRIBUTE_CATEGORY = '||''''||l_pen_membership_context||'''';
4463 END IF;
4464
4465 END IF;
4466
4467 END IF;
4468
4469 else ----- vkodedal
4470 l_dynamic_PAY_sql := l_dynamic_PAY_sql || ' and xcl.EFFECTIVE_DATE between to_date(''' ||
4471 to_char(nvl(l_ced_date_from,hr_api.g_sot),'DD-MM-RRRR') || ''',''DD-MM-RRRR'') and to_date(''' ||
4472 to_char(nvl(l_ced_date_to,hr_api.g_eot),'DD-MM-RRRR') || ''',''DD-MM-RRRR'') ';
4473 end if;
4474 else
4475 l_dynamic_PAY_sql := l_dynamic_PAY_sql ||
4476 ' and xcl.EFFECTIVE_DATE not between to_date(''' ||
4477 to_char(nvl(l_ced_date_from,hr_api.g_sot),'DD-MM-RRRR') || ''',''DD-MM-RRRR'') and to_date(''' ||
4478 to_char(nvl(l_ced_date_to,hr_api.g_eot),'DD-MM-RRRR') || ''',''DD-MM-RRRR'') ';
4479 end if;
4480 end if ;
4481 end if ;
4482 end if;
4483 --
4484 -- advance criteria
4485
4486 if l_adv_exists = 'Y' and p_data_typ_cd in ('C') then
4487
4488 if l_dynamic_PAY_sql is not null then
4489 if nvl(l_pay_evt_non_asg,'N') = 'N' then
4490 build_adv_criteria(
4491 p_ext_crit_prfl_id => p_ext_crit_prfl_id ,
4492 p_ext_dfn_id => p_ext_dfn_id,
4493 p_business_group_id => p_business_group_id,
4494 p_effective_date => p_effective_date,
4495 p_source => 'PAY' ,
4496 p_select_statement => l_dynamic_ADV_sql) ;
4497
4498 if l_dynamic_ADV_sql is not null then
4499 l_dynamic_PAY_sql := l_dynamic_PAY_sql || ' AND ' || l_dynamic_ADV_sql ;
4500 end if ;
4501 end if ;
4502 end if ;
4503
4504 if l_dynamic_BEN_sql is not null then
4505
4506 build_adv_criteria(
4507 p_ext_crit_prfl_id => p_ext_crit_prfl_id ,
4508 p_ext_dfn_id => p_ext_dfn_id,
4509 p_business_group_id => p_business_group_id,
4510 p_effective_date => p_effective_date,
4511 p_source => 'BEN' ,
4512 p_select_statement => l_dynamic_ADV_sql) ;
4513
4514 if l_dynamic_BEN_sql is not null then
4515 l_dynamic_BEN_sql := l_dynamic_BEN_sql || ' AND ' || l_dynamic_ADV_sql ;
4516 end if ;
4517
4518 end if ;
4519 end if ;
4520
4521 -- communication type
4522 if l_mtp_exists = 'Y' and p_data_typ_cd in ('CM') then
4523 if l_mtp_exclude = 'N' then
4524 l_dynamic_sql := l_dynamic_sql || ' and to_char(pcm.cm_typ_id) in ';
4525 else
4526 l_dynamic_sql := l_dynamic_sql || ' and to_char(pcm.cm_typ_id) not in ';
4527 end if;
4528 l_dynamic_sql := l_dynamic_sql ||
4529 '(select xcv.val_1 from ben_ext_crit_typ xct ,ben_ext_crit_val xcv ' ||
4530 ' where xct.ext_crit_prfl_id = ' || p_ext_crit_prfl_id ||
4531 ' and xct.ext_crit_typ_id = xcv.ext_crit_typ_id and '||
4532 'xct.crit_typ_cd = ''MTP'') ';
4533 end if;
4534 -- communication tobe send date
4535 if l_mtbsdt_exists = 'Y' and p_data_typ_cd in ('CM') then
4536 l_mtbsdt_date_from := ben_ext_util.calc_ext_date (p_ext_date_cd => l_mtbsdt_val1,
4537 p_abs_date => p_effective_date,
4538 p_ext_dfn_id => p_ext_dfn_id);
4539 l_mtbsdt_date_to := ben_ext_util.calc_ext_date (p_ext_date_cd => l_mtbsdt_val2,
4540 p_abs_date => p_effective_date,
4541 p_ext_dfn_id => p_ext_dfn_id);
4542 if l_mtbsdt_exclude = 'N' then
4543 l_dynamic_sql := l_dynamic_sql || ' and pcp.to_be_sent_dt between to_date(''' ||
4544 to_char(nvl(l_mtbsdt_date_from,hr_api.g_sot),'DD-MM-RRRR') || ''',''DD-MM-RRRR'') and to_date(''' ||
4545 to_char(nvl(l_mtbsdt_date_to,hr_api.g_eot),'DD-MM-RRRR') || ''',''DD-MM-RRRR'') ';
4546 else
4547 l_dynamic_sql := l_dynamic_sql ||
4548 ' and (pcp.to_be_sent_dt is null or pcp.to_be_sent_dt not between to_date(''' ||
4549 to_char(nvl(l_mtbsdt_date_from,hr_api.g_sot),'DD-MM-RRRR') || ''',''DD-MM-RRRR'') and to_date(''' ||
4550 to_char(nvl(l_mtbsdt_date_to,hr_api.g_eot),'DD-MM-RRRR') || ''',''DD-MM-RRRR'')) ';
4551 end if;
4552 end if;
4553 -- communication send date
4554 if l_msdt_exists = 'Y' and p_data_typ_cd in ('CM') then
4555 l_msdt_date_from := ben_ext_util.calc_ext_date (p_ext_date_cd => l_msdt_val1,
4556 p_abs_date => p_effective_date,
4557 p_ext_dfn_id => p_ext_dfn_id);
4558 l_msdt_date_to := ben_ext_util.calc_ext_date (p_ext_date_cd => l_msdt_val2,
4559 p_abs_date => p_effective_date,
4560 p_ext_dfn_id => p_ext_dfn_id);
4561 if l_msdt_exclude = 'N' then
4562 l_dynamic_sql := l_dynamic_sql || ' and pcp.sent_dt between to_date(''' ||
4563 to_char(nvl(l_msdt_date_from,hr_api.g_sot),'DD-MM-YYYY') || ''',''DD-MM-RRRR'') and to_date(''' ||
4564 to_char(nvl(l_msdt_date_to,hr_api.g_eot),'DD-MM-RRRR') || ''',''DD-MM-RRRR'')';
4565 else
4566 l_dynamic_sql := l_dynamic_sql ||
4567 ' and (pcp.sent_dt is null or pcp.sent_dt not between to_date(''' ||
4568 to_char(nvl(l_msdt_date_from,hr_api.g_sot),'DD-MM-RRRR') || ''',''DD-MM-RRRR'') and to_date(''' ||
4569 to_char(nvl(l_msdt_date_to,hr_api.g_eot),'DD-MM-RRRR') || ''',''DD-MM-RRRR'')) ';
4570 end if;
4571 end if;
4572
4573
4574 -- person data link
4575 if l_pdl_exists = 'Y' then
4576 hr_utility.set_location('pdl excluded ' || l_pdl_exclude, 99 ) ;
4577 if l_pdl_exclude = 'N' then
4578 l_dynamic_sql := l_dynamic_sql || ' and EXISTS ';
4579 else
4580 l_dynamic_sql := l_dynamic_sql || ' and not EXISTS ';
4581 end if ;
4582 if l_pdl_val1 = 'PDLJOB' then
4583 l_dynamic_sql := l_dynamic_sql ||
4584 ' (select 1 from per_jobs job where job.job_id = ben_asg.job_id and ' ||
4585 ' exists ( select group_val_01 from ben_ext_rslt_dtl erd where ' ||
4586 ' erd.ext_rslt_id = ' || p_ext_rslt_id ||
4587 ' and group_val_01 is not null and group_val_01 = job.name ) ) ' ;
4588 elsif l_pdl_val1 = 'PDLPOS' then
4589 l_dynamic_sql := l_dynamic_sql ||
4590 ' (select 1 from HR_ALL_POSITIONS_F pos where pos.position_id = ben_asg.position_id and '||
4591 ' to_date(''' || to_char(p_effective_date,'DD-MM-RRRR') ||
4592 ''',''DD-MM-RRRR'') between pos.effective_start_date and pos.effective_end_date and ' ||
4593 ' exists ( select group_val_01 from ben_ext_rslt_dtl erd where ' ||
4594 ' erd.ext_rslt_id = ' || p_ext_rslt_id ||
4595 ' and group_val_01 is not null and group_val_01 = pos.name )) ' ;
4596
4597 elsif l_pdl_val1 = 'PDLPAY' then
4598 l_dynamic_sql := l_dynamic_sql ||
4599 ' (select 1 from pay_payrolls pay where pay.payroll_id = ben_asg.payroll_id and ' ||
4600 ' exists ( select group_val_01 from ben_ext_rslt_dtl erd where ' ||
4601 ' erd.ext_rslt_id = ' || p_ext_rslt_id ||
4602 ' and group_val_01 is not null and group_val_01 = pay.payroll_name )) ' ;
4603 elsif l_pdl_val1 = 'PDLLOC' then
4604 l_dynamic_sql := l_dynamic_sql ||
4605 ' (select 1 from hr_locations_all loc where loc.location_id = ben_asg.location_id ' ||
4606 ' and to_date(''' || to_char(p_effective_date,'DD-MM-RRRR') ||
4607 ''',''DD-MM-RRRR'') between loc.effective_start_date and loc.effective_end_date ' ||
4608 ' and exists ( select group_val_01 from ben_ext_rslt_dtl erd where ' ||
4609 ' erd.ext_rslt_id = ' || p_ext_rslt_id ||
4610 ' and group_val_01 is not null and group_val_01 = loc.location_code )) ' ;
4611 elsif l_pdl_val1 = 'PDLEAPP' then
4612 l_dynamic_sql := l_dynamic_sql ||
4613 ' ( select 1 from per_time_periods tim where ben_asg.payroll_id = tim.payroll_id ' ||
4614 ' and to_date(''' || to_char(p_effective_date,'DD-MM-RRRR') ||
4615 ''',''DD-MM-RRRR'') between tim.start_date and tim.end_date ' ||
4616 ' and ben_asg.effective_start_date<=tim.end_date and ben_asg.effective_end_date>= tim.start_date) ';
4617
4618
4619 elsif l_pdl_val1 = 'PDLGRD' then
4620 l_dynamic_sql := l_dynamic_sql ||
4621 ' (select 1 from per_grades grd where grd.grade_id = ben_asg.grade_id ' ||
4622 ' and exists ( select group_val_01 from ben_ext_rslt_dtl erd where ' ||
4623 ' erd.ext_rslt_id = ' || p_ext_rslt_id ||
4624 ' and group_val_01 is not null and group_val_01 = grd.name )) ' ;
4625
4626 end if;
4627
4628 end if;
4629
4630 hr_utility.set_location( p_data_typ_cd || ' '|| l_wplr_exists , 99 ) ;
4631
4632 if l_wplr_exists = 'Y' and p_data_typ_cd in ('CW') then
4633 if l_wplr_exclude = 'N' then
4634 l_dynamic_sql := l_dynamic_sql || ' and exists ' ;
4635 else
4636 l_dynamic_sql := l_dynamic_sql || ' and not exists ' ;
4637 end if ;
4638 l_dynamic_sql := l_dynamic_sql ||
4639 ' ( select 1 from ben_ext_crit_val cvl , ben_enrt_perd enp , ben_per_in_ler pil' ||
4640 ' where cpi.group_per_in_ler_id = pil.per_in_ler_id and pil.group_pl_id = cvl.val_2 ' ||
4641 ' and cvl.EXT_CRIT_TYP_ID = ' || l_wlpr_EXT_CRIT_TYP_ID ||
4642 ' and enp.enrt_perd_id = cvl.val_1 and pil.lf_evt_ocrd_dt = enp.ASND_LF_EVT_DT ) ' ;
4643 end if;
4644
4645 if p_data_typ_cd = 'C' then
4646
4647 if l_dynamic_BEN_sql is not null then
4648 l_dynamic_BEN_sql := l_dynamic_BEN_sql || ' ' || nvl(l_dynamic_sql, ' ' ) ;
4649 end if ;
4650 if l_dynamic_PAY_sql is not null then
4651 l_dynamic_PAY_sql := l_dynamic_PAY_sql || ' ' || nvl(l_dynamic_sql, ' ' ) ;
4652 end if ;
4653
4654 l_dynamic_sql := l_dynamic_BEN_sql ;
4655 if l_dynamic_sql is not null then
4656 hr_utility.set_location(' first l_dynamic_sql not null ' , 99 );
4657
4658 if l_dynamic_PAY_sql is not null then
4659 hr_utility.set_location(' first l_dynamic_pay sql not null ' , 99 );
4660 l_dynamic_sql := l_dynamic_sql || ' UNION ' ||
4661 l_dynamic_PAY_sql ;
4662 end if ;
4663 else
4664 hr_utility.set_location(' first l_dynamic_pay sql null ' , 99 );
4665 if l_dynamic_PAY_sql is not null then
4666 l_dynamic_sql := l_dynamic_PAY_sql ;
4667 end if ;
4668 end if ;
4669
4670 end if ;
4671
4672 hr_utility.set_location(' build completed ' , 99 );
4673 p_select_statement := l_dynamic_sql;
4674
4675 --ptilak(p_select_statement) ;
4676
4677
4678 end build_select_statement;
4679
4680
4681
4682
4683
4684
4685 Function check_asg_security
4686 (p_person_id in number
4687 ,p_effective_date in date
4688 ,p_business_group_id in number )
4689 return boolean as
4690
4691 l_proc varchar2(80) := g_package||'.check_asg_security';
4692
4693 cursor c_asg is
4694 select asg.ASSIGNMENT_TYPE ,asg.assignment_id,asg.business_group_id
4695 from per_all_assignments_f asg
4696 where asg.person_id = p_person_id
4697 and asg.primary_flag = 'Y'
4698 and p_effective_date between asg.effective_start_date
4699 and asg.effective_end_date
4700 ;
4701
4702
4703 cursor c_sec_asg (p_assignment_id number) is
4704 select 'x'
4705 from per_all_assignments_f asg
4706 where asg.assignment_id = p_assignment_id
4707 and p_effective_date between asg.effective_start_date
4708 and asg.effective_end_date ;
4709
4710
4711
4712 l_ASSIGNMENT_TYPE per_all_assignments_f.ASSIGNMENT_TYPE%type ;
4713 l_assignment_id per_all_assignments_f.assignment_id%type ;
4714 l_business_group_id per_all_assignments_f.business_group_id%type ;
4715 l_return boolean ;
4716 l_temp varchar2(1) ;
4717 begin
4718
4719 l_return := true ;
4720 -- if g_debug then
4721 -- hr_utility.set_location ('Entering '||l_proc,5);
4722 -- hr_utility.set_location ('person '||p_person_id ,5);
4723 -- end if;
4724
4725 if HR_SECURITY.VIEW_ALL = 'Y' and hr_general.get_xbg_profile = 'Y' then
4726 -- hr_utility.set_location ('Exiting '||l_proc,5);
4727 return l_return ;
4728 end if ;
4729
4730 /* moved down
4731 -- this is common validation for asg and person
4732 if hr_general.get_xbg_profile <> 'Y'
4733 and hr_general.get_business_group_id is not null
4734 and hr_general.get_business_group_id <> p_business_group_id then
4735 -- hr_utility.set_location ('Exiting false'||l_proc,8);
4736 Return false ;
4737 end if ;
4738
4739 */
4740
4741
4742 open c_asg ;
4743 fetch c_asg into l_ASSIGNMENT_TYPE,l_assignment_id, l_business_group_id ;
4744 if c_asg%notfound then
4745 -- if there is no assignmnet, allow the security , it could be dpnt
4746 -- hr_utility.set_location ('assignment not exist dependent ',5);
4747 close c_asg ;
4748 return l_return ;
4749 end if ;
4750 close c_asg ;
4751
4752
4753
4754 -- this is common validation for asg and person
4755 if hr_general.get_xbg_profile <> 'Y'
4756 and hr_general.get_business_group_id is not null
4757 and hr_general.get_business_group_id <> l_business_group_id then
4758 -- hr_utility.set_location ('Exiting false'||l_proc,8);
4759 Return false ;
4760 end if ;
4761
4762
4763 -- if the assignment type is E or C validate against the sec view
4764 if l_ASSIGNMENT_TYPE in ('E','C') then
4765
4766 if HR_SECURITY.VIEW_ALL <> 'Y' and
4767 HR_SECURITY.SHOW_RECORD('PER_ALL_ASSIGNMENTS_F', L_ASSIGNMENT_ID, P_PERSON_ID, L_ASSIGNMENT_TYPE) <> 'TRUE' then
4768 -- hr_utility.set_location ('Exiting false'||l_proc,9);
4769 return false ;
4770 end if ;
4771 end if ;
4772
4773
4774 -- if g_debug then
4775 -- hr_utility.set_location ('Exiting '||l_proc,15);
4776 -- end if;
4777 return l_return ;
4778
4779 end check_asg_security ;
4780
4781 procedure init_sub_lvl is
4782 l_proc varchar2(80) := g_package||'.init_sub_lvl';
4783 begin
4784
4785 if g_debug then
4786 hr_utility.set_location ('Entering '||l_proc,5);
4787 end if;
4788 ben_ext_person.g_location_id := null;
4789 ben_ext_person.g_location_code := null;
4790 ben_ext_person.g_location_addr1 := null;
4791 ben_ext_person.g_location_addr2 := null;
4792 ben_ext_person.g_location_addr3 := null;
4793 ben_ext_person.g_location_city := null;
4794 ben_ext_person.g_location_country := null;
4795 ben_ext_person.g_location_zip := null;
4796 ben_ext_person.g_location_region1 := null;
4797 ben_ext_person.g_location_region2 := null;
4798 ben_ext_person.g_location_region3 := null;
4799 ben_ext_person.g_alc_flex_01 := null;
4800 ben_ext_person.g_alc_flex_02 := null;
4801 ben_ext_person.g_alc_flex_03 := null;
4802 ben_ext_person.g_alc_flex_04 := null;
4803 ben_ext_person.g_alc_flex_05 := null;
4804 ben_ext_person.g_alc_flex_06 := null;
4805 ben_ext_person.g_alc_flex_07 := null;
4806 ben_ext_person.g_alc_flex_08 := null;
4807 ben_ext_person.g_alc_flex_09 := null;
4808 ben_ext_person.g_alc_flex_10 := null;
4809 ben_ext_person.g_position_id := null;
4810 ben_ext_person.g_position := null;
4811 ben_ext_person.g_pos_flex_01 := null;
4812 ben_ext_person.g_pos_flex_02 := null;
4813 ben_ext_person.g_pos_flex_03 := null;
4814 ben_ext_person.g_pos_flex_04 := null;
4815 ben_ext_person.g_pos_flex_05 := null;
4816 ben_ext_person.g_pos_flex_06 := null;
4817 ben_ext_person.g_pos_flex_07 := null;
4818 ben_ext_person.g_pos_flex_08 := null;
4819 ben_ext_person.g_pos_flex_09 := null;
4820 ben_ext_person.g_pos_flex_10 := null;
4821 ben_ext_person.g_job_id := null;
4822 ben_ext_person.g_job := null;
4823 ben_ext_person.g_job_flex_01 := null;
4824 ben_ext_person.g_job_flex_02 := null;
4825 ben_ext_person.g_job_flex_03 := null;
4826 ben_ext_person.g_job_flex_04 := null;
4827 ben_ext_person.g_job_flex_05 := null;
4828 ben_ext_person.g_job_flex_06 := null;
4829 ben_ext_person.g_job_flex_07 := null;
4830 ben_ext_person.g_job_flex_08 := null;
4831 ben_ext_person.g_job_flex_09 := null;
4832 ben_ext_person.g_job_flex_10 := null;
4833 ben_ext_person.g_payroll := null;
4834 ben_ext_person.g_payroll_period_type := null ;
4835 ben_ext_person.g_prl_flex_01 := null ;
4836 ben_ext_person.g_prl_flex_02 := null ;
4837 ben_ext_person.g_prl_flex_03 := null ;
4838 ben_ext_person.g_prl_flex_04 := null ;
4839 ben_ext_person.g_prl_flex_05 := null ;
4840 ben_ext_person.g_prl_flex_06 := null ;
4841 ben_ext_person.g_prl_flex_07 := null ;
4842 ben_ext_person.g_prl_flex_08 := null ;
4843 ben_ext_person.g_prl_flex_09 := null ;
4844 ben_ext_person.g_prl_flex_10 := null ;
4845 ben_ext_person.g_payroll_period_number:= null ;
4846 ben_ext_person.g_payroll_period_strtdt:= null ;
4847 ben_ext_person.g_payroll_period_enddt := null ;
4848 ben_ext_person.g_payroll_costing := null ;
4849 ben_ext_person.g_payroll_costing_id := null ;
4850 ben_ext_person.g_payroll_consolidation_set := null ;
4851 ben_ext_person.g_payroll_consolidation_set_id := null ;
4852 ben_ext_person.g_group_elmt_value1 := null ;
4853 ben_ext_person.g_group_elmt_value2 := null ;
4854 --
4855 ben_ext_person.g_employee_grade_id := null;
4856 ben_ext_person.g_employee_grade := null;
4857 ben_ext_person.g_grd_flex_01 := null;
4858 ben_ext_person.g_grd_flex_02 := null;
4859 ben_ext_person.g_grd_flex_03 := null;
4860 ben_ext_person.g_grd_flex_04 := null;
4861 ben_ext_person.g_grd_flex_05 := null;
4862 ben_ext_person.g_grd_flex_06 := null;
4863 ben_ext_person.g_grd_flex_07 := null;
4864 ben_ext_person.g_grd_flex_08 := null;
4865 ben_ext_person.g_grd_flex_09 := null;
4866 ben_ext_person.g_grd_flex_10 := null;
4867
4868
4869 if g_debug then
4870 hr_utility.set_location ('Exiting '||l_proc,15);
4871 end if;
4872 end init_sub_lvl ;
4873
4874
4875 procedure process_subheader(p_ext_file_id in number
4876 ,p_ext_dfn_id in number
4877 ,p_ext_rslt_id in number
4878 ,p_data_typ_cd in varchar2
4879 ,p_ext_typ_cd in varchar2
4880 ,p_effective_date in date
4881 ,p_ext_crit_prfl_id in number
4882 ,p_ext_global_flag in varchar2
4883 ,p_business_group_id in number
4884 ,p_subhdr_ghr_from_dt in date default null
4885 ,p_subhdr_ghr_to_dt in date default null
4886 ) is
4887
4888 l_proc varchar2(80) := g_package||'.process_subheader';
4889
4890 cursor c_pos(p_org_id number,
4891 p_bg_id number ) is
4892 select pos.position_id,pos.job_id
4893 from HR_ALL_POSITIONS_F pos
4894 where pos.business_group_id = p_bg_id
4895 and pos.organization_id = p_org_id
4896 and p_effective_date between pos.EFFECTIVE_START_DATE
4897 and nvl(pos.EFFECTIVE_END_DATE ,p_effective_date)
4898 ;
4899
4900 cursor c_job (p_bg_id number ) is
4901 select job.job_id
4902 from per_jobs_vl job
4903 where job.business_group_id = p_bg_id
4904 and p_effective_date between job.date_from and nvl(job.date_to,p_effective_date)
4905 ;
4906
4907
4908 cursor c_loc(p_bg_id number ) is
4909 select loc.location_id
4910 from hr_locations_all loc
4911 where loc.business_group_id = p_bg_id
4912 or loc.business_group_id is null -- for global location
4913 ;
4914
4915
4916 cursor c_org (p_bg_id number ) is
4917 select org.organization_id
4918 ,org.name
4919 from hr_all_organization_units_vl org
4920 where org.business_group_id = p_bg_id
4921 and p_effective_date between org.date_from and nvl(org.date_to,p_effective_date) ;
4922
4923
4924 cursor c_pay (p_bg_id number ) is
4925 select payroll_id
4926 from pay_payrolls_f pay
4927 where pay.business_group_id = p_bg_id
4928 -- and pay.organization_id = p_org_id
4929 and p_effective_date between pay.EFFECTIVE_START_DATE and pay.EFFECTIVE_END_DATE
4930 ;
4931
4932
4933 cursor c_grade (p_bg_id number ) is
4934 select grade_id
4935 from per_grades_vl grd
4936 where grd.business_group_id = p_bg_id
4937 and p_effective_date between grd.date_from and nvl(grd.date_to,p_effective_date)
4938 ;
4939
4940 cursor c_pos2(p_org_id number,
4941 p_bg_id number ,
4942 p_subhdr_ghr_from_dt date ,
4943 p_subhdr_ghr_to_dt date
4944 ) is
4945 select
4946 distinct pos.position_id position_id
4947 from ghr_pa_history gph ,
4948 HR_ALL_POSITIONS_F pos
4949 where ( (gph.table_name = 'HR_ALL_POSITIONS_F'
4950 and pos.POSITION_ID = gph.information1 )
4951 or (gph.table_name = 'PER_POSITION_EXTRA_INFO'
4952 and pos.position_id = gph.information4 -- info4 is position_id
4953 and gph.information5 in ('GHR_US_POS_GRP1','GHR_US_POS_GRP2' ,'GHR_US_POS_VALID_GRADE','GHR_US_POS_GRP3',
4954 'GHR_US_POS_OBLIG', 'GHR_US_POS_MASS_ACTIONS', 'GHR_US_POSITION_LANGUAGE',
4955 'GHR_US_POSITION_INTERDISC', 'GHR_US_POSITION_DESCRIPTION' )
4956 )
4957 )
4958 and pos.business_group_id = p_bg_id
4959 and pos.organization_id = p_org_id
4960 and gph.effective_date between pos.EFFECTIVE_START_DATE
4961 and pos.EFFECTIVE_END_DATE
4962 and ( p_subhdr_ghr_from_dt is null
4963 or (
4964 trunc(gph.effective_date) between p_subhdr_ghr_from_dt and nvl(p_subhdr_ghr_to_dt, p_subhdr_ghr_from_dt)
4965 or
4966 ( trunc(gph.process_date) between p_subhdr_ghr_from_dt and nvl(p_subhdr_ghr_to_dt, p_subhdr_ghr_from_dt)
4967 and trunc(gph.effective_date) <= nvl(p_subhdr_ghr_to_dt, p_subhdr_ghr_from_dt)
4968 )
4969 )
4970 )
4971 ;
4972
4973
4974 cursor c_ced is
4975 select
4976 xct.excld_flag,
4977 xcv.val_1,
4978 xcv.val_2
4979 from ben_ext_crit_typ xct,
4980 ben_ext_crit_val xcv
4981 where xct.ext_crit_prfl_id = p_ext_crit_prfl_id
4982 and xct.ext_crit_typ_id = xcv.ext_crit_typ_id
4983 and xct.crit_typ_cd = 'CED';
4984
4985
4986 cursor c_cad is
4987 Select
4988 xct.excld_flag,
4989 xcv.val_1,
4990 xcv.val_2
4991 from ben_ext_crit_typ xct,
4992 ben_ext_crit_val xcv
4993 where xct.ext_crit_prfl_id = p_ext_crit_prfl_id
4994 and xct.ext_crit_typ_id = xcv.ext_crit_typ_id
4995 and xct.crit_typ_cd = 'CAD';
4996
4997
4998
4999 cursor c_bg is
5000 select business_group_id , name
5001 from per_business_groups
5002 where p_ext_global_flag = 'Y'
5003 or business_group_id = p_business_group_id
5004 ;
5005
5006 cursor c_pbg is
5007 select business_group_id , name
5008 from per_business_groups
5009 where business_group_id = p_business_group_id
5010 ;
5011
5012
5013 l_include varchar2(1) ;
5014 l_person_id number ;
5015 l_business_group_id number ;
5016 l_proc_business_group_id number ;
5017 l_proc_business_group_name per_business_groups.name%type ;
5018
5019 p_chg_actl_dt_from date ;
5020 p_chg_actl_dt_to date ;
5021 p_chg_eff_dt_from date ;
5022 p_chg_eff_dt_to date ;
5023 l_actl_exclude_flag varchar2(1) ;
5024 l_eff_exclude_flag varchar2(1) ;
5025 l_val1 ben_ext_crit_val.val_1%type ;
5026 l_val2 ben_ext_crit_val.val_1%type ;
5027
5028
5029 Begin
5030
5031 l_person_id := 0 ;
5032 l_include := 'Y' ;
5033 if g_debug then
5034 hr_utility.set_location ('Entering '||l_proc,5);
5035 end if;
5036 --
5037 ben_extract.set_ext_lvls
5038 (p_ext_file_id => p_ext_file_id
5039 ,p_business_group_id => p_business_group_id
5040 );
5041
5042 if nvl(ben_extract.g_subhead_dfn,'N') <> 'Y' then
5043 if g_debug then
5044 hr_utility.set_location ('Exiting no definition found '||l_proc,10);
5045 end if;
5046 return ;
5047 end if ;
5048 --
5049 IF p_ext_crit_prfl_id is not null THEN
5050 --
5051 ben_ext_person.g_effective_date := p_effective_date ;
5052 ben_ext_evaluate_inclusion.Determine_Incl_Crit_To_Check(p_ext_crit_prfl_id);
5053 --
5054 END IF;
5055
5056
5057 -- Setup record and required level tables
5058 --
5059 ben_extract.setup_rcd_typ_lvl
5060 (p_ext_file_id => p_ext_file_id
5061 );
5062 --
5063 g_ext_dfn_id := p_ext_dfn_id;
5064 g_ext_rslt_id := p_ext_rslt_id;
5065
5066 hr_utility.set_location ( ' org ' || ben_extract.g_org_lvl || ' pos '|| ben_extract.g_pos_lvl ||
5067 ' pay ' || ben_extract.g_pay_lvl || ' bg ' || ben_extract.g_bg_csr , 99 ) ;
5068 --- get the processing bg
5069 --if ben_extract.g_bg_csr = 'Y' then
5070 open c_pbg ;
5071 fetch c_pbg into
5072 ben_extract.g_proc_business_group_id ,
5073 ben_extract.g_proc_business_group_name;
5074 close c_pbg ;
5075 hr_utility.set_location ( ' proc bg ' || ben_extract.g_proc_business_group_name , 99 ) ;
5076 --end if ;
5077
5078
5079 for l_bg in c_bg Loop
5080
5081 if p_ext_crit_prfl_id is not null then
5082 ben_ext_evaluate_inclusion.Evaluate_subhead_incl
5083 (
5084 p_business_group_id => l_bg.business_group_id,
5085 p_include => l_include,
5086 p_effective_date => p_effective_date );
5087 end if ;
5088
5089
5090 if p_ext_crit_prfl_id is not null then
5091 ben_ext_evaluate_inclusion.Evaluate_subhead_incl
5092 (p_business_group_id => l_bg.business_group_id ,
5093 p_include => l_include,
5094 p_effective_date => p_effective_date );
5095 end if ;
5096
5097
5098 if l_include = 'Y' then
5099
5100 if ben_extract.g_bg_csr = 'Y' then
5101
5102 ben_ext_person.g_business_group_id := l_bg.business_group_id ;
5103 ben_extract.g_business_group_name := l_bg.name ;
5104 end if ;
5105
5106 --- extract organization and postion level
5107 if ben_extract.g_org_lvl = 'Y' or ben_extract.g_pos_lvl = 'Y' then
5108 for i in c_org(l_bg.business_group_id) loop
5109
5110 hr_utility.set_location ('_organization '||i.name,10);
5111 if ben_extract.g_org_lvl = 'Y' then
5112
5113 if p_ext_crit_prfl_id is not null then
5114 ben_ext_evaluate_inclusion.Evaluate_subhead_incl
5115 (p_organization_id => i.organization_id ,
5116 p_business_group_id => l_bg.business_group_id ,
5117 p_include => l_include,
5118 p_effective_date => p_effective_date );
5119 end if ;
5120
5121 if l_include = 'Y' then
5122 ben_ext_person.g_employee_organization_id := i.organization_id ;
5123 ben_ext_person.g_employee_organization := i.name ;
5124 ben_ext_fmt.process_ext_recs(p_ext_rslt_id => p_ext_rslt_id,
5125 p_ext_file_id => p_ext_file_id,
5126 p_data_typ_cd => p_data_typ_cd,
5127 p_ext_typ_cd => p_ext_typ_cd,
5128 p_rcd_typ_cd => 'S',
5129 p_low_lvl_cd => 'OR',
5130 p_person_id => l_person_id,
5131 p_chg_evt_cd => null,
5132 p_business_group_id => p_business_group_id,
5133 p_ext_per_bg_id => l_bg.business_group_id,
5134 p_effective_date => p_effective_date
5135 );
5136 end if ; -- include
5137 end if ; -- ben_extract.g_org_lvl
5138
5139 --- position
5140
5141 if ben_extract.g_pos_lvl = 'Y' then
5142
5143 hr_utility.set_location( 'spl flag ' || g_subhdr_chg_log , 99 );
5144
5145 if g_subhdr_chg_log = 'Y' then
5146
5147 ---
5148 for j in c_pos2 (i.organization_id
5149 ,l_bg.business_group_id
5150 ,p_subhdr_ghr_from_dt
5151 ,p_subhdr_ghr_to_dt
5152 ) Loop
5153
5154 init_sub_lvl ;
5155 l_include := 'Y' ;
5156 -- call inclusion criteris
5157 if p_ext_crit_prfl_id is not null then
5158 ben_ext_evaluate_inclusion.Evaluate_subhead_incl
5159 (p_organization_id => i.organization_id ,
5160 p_position_id => j.position_id ,
5161 p_business_group_id => l_bg.business_group_id ,
5162 p_include => l_include,
5163 p_effective_date => p_effective_date
5164 );
5165
5166 hr_utility.set_location( ' include ' || l_include , 99 );
5167
5168 end if ;
5169
5170 -- call the function from per_person_extract
5171 if l_include = 'Y' then
5172 ben_ext_person.g_employee_organization_id := i.organization_id ;
5173 ben_ext_person.g_employee_organization := i.name ;
5174 ben_ext_person.g_position_id := j.position_id ;
5175
5176 ben_ext_person.get_pos_info(p_position_id => j.position_id,
5177 p_effective_date => p_effective_date) ;
5178
5179 hr_utility.set_location ('position '||j.position_id,10);
5180 ben_ext_fmt.process_ext_recs(
5181 p_ext_rslt_id => p_ext_rslt_id,
5182 p_ext_file_id => p_ext_file_id,
5183 p_data_typ_cd => p_data_typ_cd,
5184 p_ext_typ_cd => p_ext_typ_cd,
5185 p_rcd_typ_cd => 'S',
5186 p_low_lvl_cd => 'PO',
5187 p_person_id => l_person_id,
5188 p_chg_evt_cd => null,
5189 p_business_group_id => p_business_group_id,
5190 p_ext_per_bg_id => l_bg.business_group_id,
5191 p_effective_date => p_effective_date
5192 );
5193 end if ;
5194 end loop ;
5195
5196
5197 else
5198 for j in c_pos (i.organization_id
5199 ,l_bg.business_group_id) Loop
5200 init_sub_lvl ;
5201 l_include := 'Y' ;
5202 -- call inclusion criteris
5203 if p_ext_crit_prfl_id is not null then
5204 ben_ext_evaluate_inclusion.Evaluate_subhead_incl
5205 (p_organization_id => i.organization_id ,
5206 p_position_id => j.position_id ,
5207 p_business_group_id => l_bg.business_group_id ,
5208 p_include => l_include,
5209 p_effective_date => p_effective_date );
5210 end if ;
5211
5212 -- call the function from per_person_extract
5213 if l_include = 'Y' then
5214 ben_ext_person.g_employee_organization_id := i.organization_id ;
5215 ben_ext_person.g_employee_organization := i.name ;
5216 ben_ext_person.g_position_id := j.position_id ;
5217 ben_ext_person.get_pos_info(p_position_id => j.position_id,
5218 p_effective_date => p_effective_date ) ;
5219
5220 hr_utility.set_location ('position '||j.position_id,10);
5221 ben_ext_fmt.process_ext_recs(p_ext_rslt_id => p_ext_rslt_id,
5222 p_ext_file_id => p_ext_file_id,
5223 p_data_typ_cd => p_data_typ_cd,
5224 p_ext_typ_cd => p_ext_typ_cd,
5225 p_rcd_typ_cd => 'S',
5226 p_low_lvl_cd => 'PO',
5227 p_person_id => l_person_id,
5228 p_chg_evt_cd => null,
5229 p_business_group_id => p_business_group_id,
5230 p_ext_per_bg_id => l_bg.business_group_id,
5231 p_effective_date => p_effective_date
5232 );
5233 end if ;
5234 end loop ;
5235 end if ; --- g_subhdr_chg_log
5236 end if ;
5237 end loop ;
5238 end if ;
5239
5240
5241 --- payroll
5242
5243
5244 if ben_extract.g_pay_lvl = 'Y' then
5245 for j in c_pay (l_bg.business_group_id ) Loop
5246 init_sub_lvl ;
5247 l_include := 'Y' ;
5248 -- call inclusion criteris
5249 if p_ext_crit_prfl_id is not null then
5250 ben_ext_evaluate_inclusion.Evaluate_subhead_incl
5251 (
5252 p_payroll_id => j.payroll_id ,
5253 p_business_group_id => l_bg.business_group_id ,
5254 p_include => l_include,
5255 p_effective_date => p_effective_date );
5256 end if ;
5257 --
5258 -- call the function from per_person_extract
5259 if l_include = 'Y' then
5260 ben_ext_person.get_payroll_info(p_payroll_id => j.payroll_id,
5261 p_effective_date => p_effective_date ) ;
5262
5263 hr_utility.set_location ('payroll id '||j.payroll_id,10);
5264 ben_ext_fmt.process_ext_recs(p_ext_rslt_id => p_ext_rslt_id,
5265 p_ext_file_id => p_ext_file_id,
5266 p_data_typ_cd => p_data_typ_cd,
5267 p_ext_typ_cd => p_ext_typ_cd,
5268 p_rcd_typ_cd => 'S',
5269 p_low_lvl_cd => 'PY',
5270 p_person_id => l_person_id,
5271 p_chg_evt_cd => null,
5272 p_business_group_id => p_business_group_id,
5273 p_ext_per_bg_id => l_bg.business_group_id,
5274 p_effective_date => p_effective_date
5275 );
5276 end if ;
5277 end loop ;
5278 end if ;
5279
5280
5281
5282
5283 --- extract job level
5284
5285 if ben_extract.g_job_lvl = 'Y' then
5286 for i in c_job (l_bg.business_group_id) loop
5287 init_sub_lvl ;
5288 l_include := 'Y' ;
5289 -- call inclusion criteris
5290 if p_ext_crit_prfl_id is not null then
5291 ben_ext_evaluate_inclusion.Evaluate_subhead_incl(
5292 p_job_id => i.job_id ,
5293 p_business_group_id => l_bg.business_group_id ,
5294 p_include => l_include,
5295 p_effective_date => p_effective_date );
5296 end if ;
5297 --
5298 -- call the function from per_person_extract
5299 if l_include = 'Y' then
5300 ben_ext_person.g_job_id := i.job_id ;
5301 ben_ext_person.get_job_info(p_job_id => i.job_id,
5302 p_effective_date => p_effective_date ) ;
5303
5304 hr_utility.set_location ('job id '||i.job_id,10);
5305 ben_ext_fmt.process_ext_recs(p_ext_rslt_id => p_ext_rslt_id,
5306 p_ext_file_id => p_ext_file_id,
5307 p_data_typ_cd => p_data_typ_cd,
5308 p_ext_typ_cd => p_ext_typ_cd,
5309 p_rcd_typ_cd => 'S',
5310 p_low_lvl_cd => 'JB',
5311 p_person_id => l_person_id,
5312 p_chg_evt_cd => null,
5313 p_business_group_id => p_business_group_id,
5314 p_ext_per_bg_id => l_bg.business_group_id,
5315 p_effective_date => p_effective_date
5316 );
5317 end if ;
5318
5319 end loop;
5320 end if ;
5321 --- extractr location level
5322
5323 if ben_extract.g_loc_lvl = 'Y' then
5324 for i in c_loc (l_bg.business_group_id) loop
5325 init_sub_lvl ;
5326 l_include := 'Y' ;
5327 -- call inclusion criteris
5328 if p_ext_crit_prfl_id is not null then
5329 ben_ext_evaluate_inclusion.Evaluate_subhead_incl(
5330 p_location_id => i.location_id ,
5331 p_business_group_id => l_bg.business_group_id ,
5332 p_include => l_include,
5333 p_effective_date => p_effective_date );
5334 end if ;
5335 --
5336 -- call the function from per_person_extract
5337 if l_include = 'Y' then
5338 ben_ext_person.g_location_id := i.location_id ;
5339 ben_ext_person.get_loc_info(p_location_id => i.location_id,
5340 p_effective_date => p_effective_date ) ;
5341
5342 hr_utility.set_location ('payroll id '||i.location_id,10);
5343 ben_ext_fmt.process_ext_recs(p_ext_rslt_id => p_ext_rslt_id,
5344 p_ext_file_id => p_ext_file_id,
5345 p_data_typ_cd => p_data_typ_cd,
5346 p_ext_typ_cd => p_ext_typ_cd,
5347 p_rcd_typ_cd => 'S',
5348 p_low_lvl_cd => 'LO',
5349 p_person_id => l_person_id,
5350 p_chg_evt_cd => null,
5351 p_business_group_id => p_business_group_id,
5352 p_ext_per_bg_id => l_bg.business_group_id,
5353 p_effective_date => p_effective_date
5354 );
5355 end if ;
5356 end loop;
5357 end if ;
5358
5359 -- extract grade informations
5360 if ben_extract.g_grd_lvl = 'Y' then
5361 for i in c_grade (l_bg.business_group_id) loop
5362 init_sub_lvl ;
5363 l_include := 'Y' ;
5364 -- call inclusion criteris
5365 if p_ext_crit_prfl_id is not null then
5366 ben_ext_evaluate_inclusion.Evaluate_subhead_incl(
5367 p_grade_id => i.grade_id ,
5368 p_business_group_id => l_bg.business_group_id ,
5369 p_include => l_include,
5370 p_effective_date => p_effective_date );
5371 end if ;
5372 --
5373 -- call the function from per_person_extract
5374 if l_include = 'Y' then
5375 ben_ext_person.g_employee_grade_id := i.grade_id ;
5376 ben_ext_person.get_grade_info(p_grade_id => i.grade_id,
5377 p_effective_date => p_effective_date ) ;
5378
5379 hr_utility.set_location ('grade id '||i.grade_id,10);
5380 ben_ext_fmt.process_ext_recs(p_ext_rslt_id => p_ext_rslt_id,
5381 p_ext_file_id => p_ext_file_id,
5382 p_data_typ_cd => p_data_typ_cd,
5383 p_ext_typ_cd => p_ext_typ_cd,
5384 p_rcd_typ_cd => 'S',
5385 p_low_lvl_cd => 'GR',
5386 p_person_id => l_person_id,
5387 p_chg_evt_cd => null,
5388 p_business_group_id => p_business_group_id,
5389 p_ext_per_bg_id => l_bg.business_group_id,
5390 p_effective_date => p_effective_date
5391 );
5392 end if ;
5393 end loop;
5394 end if ;
5395
5396
5397 end if ; -- bg include
5398 end Loop ; -- bg level
5399 --reintialize all the variable before person is extracted
5400 init_sub_lvl ;
5401 if g_debug then
5402 hr_utility.set_location ('Exiting '||l_proc,15);
5403 end if;
5404
5405 End ;
5406
5407
5408
5409
5410 -- =======================================================================
5411 -- <<Procedure:Process>>
5412 -- -----------------------------------------------------------------------
5413 -- -----------------------------------------------------------------------
5414 -- This is the main batch procedure to be called from the concurrent manager
5415 -- or interactively to start extract.
5416 -- ========================================================================
5417 --
5418 procedure process
5419 (errbuf out nocopy varchar2
5420 ,retcode out nocopy varchar2
5421 ,p_benefit_action_id in number
5422 ,p_ext_dfn_id in number
5423 ,p_effective_date in varchar2
5424 ,p_business_group_id in number
5425 ---
5426 ,p_output_type in varchar2 default null
5427 ,p_out_dummy in varchar2 default null
5428 ,p_xdo_template_id in number default null
5429 ,p_eff_start_date in varchar2 default null
5430 ,p_eff_end_date in varchar2 default null
5431 ,p_act_start_date in varchar2 default null
5432 ,p_act_end_date in varchar2 default null
5433 ---for restart
5434 ,p_ext_rslt_id in number default null
5435 -- for PQP subheader
5436 ,p_subhdr_chg_log in varchar2 default null
5437 ,p_penserv_date in date default null -- vkodedal changes for penserver
5438 ,p_penserv_mode in varchar2 default 'N' --- '' ''
5439 ) is
5440 --
5441 -- if directory not specified, then grab the first
5442 -- in the utl_file_dir path
5443 --
5444 /* cursor c_get_dflt_dir is
5445 select substr(value,1,instr(value,',')-1)
5446 from gv$system_parameter
5447 where name = 'utl_file_dir'
5448 and value is not null ; */
5449 -- bug 3187407
5450 -- to handle situations where only 1 directory specified in utl_file_dir.
5451 --
5452 cursor c_get_dflt_dir is
5453 select decode (instr(ltrim(value),','), 0 ,
5454 ltrim(value),
5455 substrb(value,1,instr(ltrim(value),',')-1) )
5456 from v$parameter where name = 'utl_file_dir';
5457 --
5458 l_proc varchar2(80) := g_package||'.process';
5459 --
5460 -- Update by RChase 01-MAR-2000
5461 --
5462 l_current_loc NUMBER:=0;
5463 -- End Update
5464 l_request_id number;
5465 l_benefit_action_id ben_benefit_actions.benefit_action_id%type;
5466 l_person_id l_number_type := l_number_type();
5467 l_person_action_id l_number_type := l_number_type();
5468 l_range_id ben_batch_ranges.range_id%type;
5469 l_object_version_number ben_batch_ranges.object_version_number%type;
5470 l_chunk_size number(5) := 20;
5471 l_threads number(5) := 1;
5472 l_max_errors_allowed number(5) := 20;
5473 l_start_person_action_id number := 0;
5474 l_end_person_action_id number := 0;
5475 l_prev_person_id number := 0;
5476 l_person_cnt number := 0;
5477 l_step number := 0;
5478 l_num_range number := 0;
5479 l_dump_num number(15);
5480 l_count number;
5481 l_data_typ_cd hr_lookups.lookup_code%TYPE ; -- UTF8 varchar2(30);
5482 l_ext_typ_cd hr_lookups.lookup_code%TYPE ; -- UTF8 varchar2(30);
5483 l_ext_crit_prfl_id number(15);
5484 l_ext_file_id number(15);
5485 l_ext_rslt_id number(15);
5486 l_ext_strt_dt_cd hr_lookups.lookup_code%TYPE ; -- UTF8 varchar2(30);
5487 l_ext_end_dt_cd hr_lookups.lookup_code%TYPE ; -- UTF8 varchar2(30);
5488 l_ext_strt_dt date;
5489 l_ext_end_dt date;
5490 l_prmy_sort_cd hr_lookups.lookup_code%TYPE ; -- UTF8 varchar2(30);
5491 l_scnd_sort_cd hr_lookups.lookup_code%TYPE ; -- UTF8 varchar2(30);
5492 l_output_name ben_ext_rslt.output_name%type ;
5493 l_drctry_name ben_ext_rslt.drctry_name%type ;
5494 l_apnd_rqst_id_flag ben_ext_dfn.apnd_rqst_id_flag%TYPE; -- UTF8 varchar2(40);
5495 l_kickoff_wrt_prc_flag ben_ext_dfn.kickoff_wrt_prc_flag%TYPE; -- UTF8 varchar2(40);
5496 l_use_eff_dt_for_chgs_flag ben_ext_dfn.use_eff_dt_for_chgs_flag%TYPE ; -- UTF8 varchar2(40);
5497 l_ext_post_prcs_rl number;
5498 l_xrs_object_version_number number;
5499 l_error_cd hr_lookups.lookup_code%TYPE ; -- UTF8 varchar2(80);
5500 l_line number := 0;
5501 l_effective_date date;
5502 l_conc_request_id number;
5503 l_select_statement varchar2(32000);
5504 l_num_rows number := 0;
5505 l_ext_global_flag varchar2(30) ;
5506 l_cm_display_flag varchar2(30) ;
5507 l_ext_stat_cd varchar2(30) ;
5508 l_dummy varchar2(30) ;
5509 --
5510
5511 cursor c_rslt is
5512 select object_version_number
5513 from ben_ext_rslt
5514 where ext_rslt_id = p_ext_rslt_id ;
5515
5516 -- check the defintion of detail levle
5517 cursor chk_D_lvl(p_ext_file_id number) is
5518 select 'Y'
5519 from ben_ext_rcd a,
5520 ben_ext_rcd_in_file b
5521 where a.ext_rcd_id = b.ext_rcd_id
5522 and b.ext_file_id = p_ext_file_id
5523 and a.rcd_type_cd = 'D'
5524 ;
5525 --
5526 cursor c_Ext_err_only (c_ext_rslt_id number) is
5527 select 'x' from
5528 ben_Ext_rslt_err
5529 where typ_cd = 'E'
5530 and ext_rslt_id = c_ext_rslt_id
5531 ;
5532 --
5533 l_outputs ff_exec.outputs_t;
5534 --
5535 TYPE PersonCurType is REF CURSOR;
5536 --
5537 PersonCur PersonCurType;
5538 --
5539 TYPE PersonRec is RECORD
5540 (person_id number(15));
5541 --
5542 l_rec PersonRec;
5543 l_status integer;
5544 l_chg_actl_strt_dt date;
5545 l_chg_actl_end_dt date;
5546 l_chg_eff_strt_dt date;
5547 l_chg_eff_end_dt date;
5548 l_to_be_sent_strt_dt date;
5549 l_to_be_sent_end_dt date;
5550 l_commit number;
5551 l_output_type varchar2(30) ;
5552 l_output_code varchar2(30) ;
5553 l_xdo_template_id number ;
5554 l_eff_start_date date ;
5555 l_eff_end_date date ;
5556 l_act_start_date date ;
5557 l_act_end_date date ;
5558 l_D_lvl_found varchar2(1) ;
5559 --
5560
5561 cursor c_xdoi (c_xdo_id number) is
5562 select application_short_name ,
5563 template_code ,
5564 default_language,
5565 default_territory
5566 from xdo_templates_b
5567 where template_id = c_xdo_id ;
5568
5569 l_application_short_name xdo_templates_b.application_short_name%type ;
5570 l_template_code xdo_templates_b.template_code%type ;
5571 l_default_language xdo_templates_b.default_language%type ;
5572 l_default_territory xdo_templates_b.default_territory%type ;
5573 l_fnd_out boolean ;
5574
5575 Begin
5576 --
5577 g_debug := hr_utility.debug_enabled;
5578 if g_debug then
5579 hr_utility.set_location ('Entering '||l_proc,5);
5580 end if;
5581 --
5582
5583 l_conc_request_id := fnd_global.conc_request_id;
5584 g_subhdr_chg_log := nvl(p_subhdr_chg_log, 'N') ;
5585 --
5586 initialize_globals;
5587 --
5588 l_effective_date := to_date(p_effective_date, 'YYYY/MM/DD HH24:MI:SS');
5589 l_effective_date := to_date(to_char(trunc(l_effective_date), 'DD/MM/RRRR'),
5590 'DD/MM/RRRR');
5591
5592
5593 if p_eff_start_date is not null then
5594
5595 l_eff_start_date := to_date(p_eff_start_date, 'YYYY/MM/DD HH24:MI:SS');
5596 l_eff_start_date := to_date(to_char(trunc(l_eff_start_date), 'DD/MM/RRRR'),
5597 'DD/MM/RRRR');
5598
5599 l_eff_end_date := to_date(p_eff_end_date, 'YYYY/MM/DD HH24:MI:SS');
5600 l_eff_end_date := to_date(to_char(trunc(l_eff_end_date), 'DD/MM/RRRR'),
5601 'DD/MM/RRRR');
5602
5603 end if ;
5604
5605 if p_act_start_date is not null then
5606 l_act_start_date := to_date(p_act_start_date, 'YYYY/MM/DD HH24:MI:SS');
5607 l_act_start_date := to_date(to_char(trunc(l_act_start_date), 'DD/MM/RRRR'),
5608 'DD/MM/RRRR');
5609
5610 l_act_end_date := to_date(p_act_end_date, 'YYYY/MM/DD HH24:MI:SS');
5611 l_act_end_date := to_date(to_char(trunc(l_act_end_date), 'DD/MM/RRRR'),
5612 'DD/MM/RRRR');
5613
5614
5615 end if ;
5616
5617 -- if customer pass one parameter errro
5618 if ( p_eff_start_date is not null and p_eff_end_date is null )
5619 or ( p_act_start_date is not null and p_act_end_date is null )
5620 then
5621 ben_ext_thread.g_err_num := 91919;
5622 ben_ext_thread.g_err_name := 'BEN_91919_EXT_END_DT_NULL';
5623 raise g_job_failure_error;
5624
5625 end if ;
5626
5627
5628 l_line := 1;
5629 --
5630 -- load the fnd_session table in case a rule dbi needs it.
5631 --
5632 dt_fndate.change_ses_date
5633 (p_ses_date => l_effective_date,
5634 p_commit => l_commit);
5635 --
5636 if p_ext_dfn_id is null then
5637 --
5638 hr_api.mandatory_arg_error(p_api_name => l_proc
5639 ,p_argument => 'p_ext_dfn_id'
5640 ,p_argument_value => p_ext_dfn_id);
5641 --
5642 elsif p_effective_date is null then
5643 --
5644 hr_api.mandatory_arg_error(p_api_name => l_proc
5645 ,p_argument => 'p_effective_date'
5646 ,p_argument_value => p_effective_date);
5647 --
5648 elsif p_business_group_id is null then
5649 --
5650 hr_api.mandatory_arg_error(p_api_name => l_proc
5651 ,p_argument => 'p_business_group_id'
5652 ,p_argument_value => p_business_group_id);
5653 --
5654 end if;
5655 --
5656 l_line := 2;
5657 --
5658 get_ext_prmtrs
5659 (p_ext_dfn_id => p_ext_dfn_id,
5660 p_business_group_id => p_business_group_id,
5661 p_data_typ_cd => l_data_typ_cd,
5662 p_ext_typ_cd => l_ext_typ_cd,
5663 p_ext_crit_prfl_id => l_ext_crit_prfl_id,
5664 p_ext_file_id => l_ext_file_id,
5665 p_ext_strt_dt => l_ext_strt_dt_cd,
5666 p_ext_end_dt => l_ext_end_dt_cd,
5667 p_prmy_sort_cd => l_prmy_sort_cd,
5668 p_scnd_sort_cd => l_scnd_sort_cd,
5669 p_output_name => l_output_name,
5670 p_drctry_name => l_drctry_name,
5671 p_apnd_rqst_id_flag => l_apnd_rqst_id_flag,
5672 p_kickoff_wrt_prc_flag => l_kickoff_wrt_prc_flag,
5673 p_use_eff_dt_for_chgs_flag => l_use_eff_dt_for_chgs_flag,
5674 p_ext_post_prcs_rl => l_ext_post_prcs_rl,
5675 p_ext_global_flag => l_ext_global_flag ,
5676 p_cm_display_flag => l_cm_display_flag ,
5677 p_output_type => l_output_type,
5678 p_xdo_template_id => l_xdo_template_id
5679 );
5680 --
5681 if l_ext_file_id is null then
5682 --
5683 ben_ext_thread.g_err_num := 91917;
5684 ben_ext_thread.g_err_name := 'BEN_91917_EXT_FILE_NULL';
5685 raise g_job_failure_error;
5686 --
5687 end if;
5688
5689 l_D_lvl_found := 'N' ;
5690 open chk_D_lvl(l_ext_file_id) ;
5691 fetch chk_D_lvl into l_D_lvl_found ;
5692 close chk_D_lvl ;
5693
5694 if p_output_type is not null then
5695 l_output_type := p_output_type ;
5696 l_xdo_template_id := nvl(p_xdo_template_id, l_xdo_template_id) ;
5697 -- in case ext dfn for pdf and parameter is file then
5698 -- nullify the template if
5699 if p_output_type in ('F','X') and l_xdo_template_id is not null then
5700 l_xdo_template_id := null ;
5701 end if ;
5702 end if ;
5703
5704
5705 --
5706 -- Determine output file name
5707 --
5708 IF l_output_name is not null and l_apnd_rqst_id_flag = 'Y' THEN
5709 --
5710 l_output_name := l_output_name || '.' ||
5711 to_char(l_conc_request_id);
5712 --
5713 END IF;
5714 --
5715 l_line := 3;
5716 -- Calculate actual extract dates
5717 --
5718 /*
5719 l_ext_strt_dt := ben_ext_util.calc_ext_date
5720 (p_ext_date_cd => l_ext_strt_dt_cd,
5721 p_abs_date => l_effective_date,
5722 p_ext_dfn_id => p_ext_dfn_id
5723 );
5724 g_ext_strt_dt := l_ext_strt_dt;
5725 --
5726 IF l_data_typ_cd = 'F' THEN
5727 --
5728 l_ext_end_dt := l_ext_strt_dt;
5729 --
5730 ELSE
5731 --
5732 l_ext_end_dt := ben_ext_util.calc_ext_date
5733 (p_ext_date_cd => l_ext_end_dt_cd,
5734 p_abs_date => l_effective_date,
5735 p_ext_dfn_id => p_ext_dfn_id
5736 );
5737 --
5738 END IF;
5739 --
5740 if l_ext_end_dt < l_ext_strt_dt then
5741 ben_ext_thread.g_err_num := 92080;
5742 ben_ext_thread.g_err_name := 'BEN_92080_EXT_STRT_END_DT';
5743 raise g_job_failure_error;
5744 end if;
5745 --
5746 g_ext_end_dt := l_ext_end_dt;
5747 --
5748 if l_ext_strt_dt is null then
5749 ben_ext_thread.g_err_num := 91918;
5750 ben_ext_thread.g_err_name := 'BEN_91918_EXT_STRT_DT_NULL';
5751 raise g_job_failure_error;
5752 end if;
5753 --
5754 if l_ext_end_dt is null then
5755 ben_ext_thread.g_err_num := 91919;
5756 ben_ext_thread.g_err_name := 'BEN_91919_EXT_END_DT_NULL';
5757 raise g_job_failure_error;
5758 end if;
5759 --
5760 */
5761 --
5762 l_line := 4;
5763 --
5764 if l_output_name is null then
5765 l_output_name := 'outfile';
5766 end if;
5767 --
5768 if l_drctry_name is null then
5769 --
5770 open c_get_dflt_dir;
5771 --
5772 fetch c_get_dflt_dir into l_drctry_name;
5773 --
5774 close c_get_dflt_dir;
5775 --
5776 end if;
5777 --
5778
5779
5780 if l_cm_display_flag = 'Y' then
5781 l_output_name := null ;
5782 l_drctry_name := null ;
5783 end if ;
5784
5785
5786 if p_benefit_action_id is not null and p_ext_rslt_id is not null then
5787
5788 l_ext_rslt_id := p_ext_rslt_id ;
5789 open c_rslt ;
5790 fetch c_rslt into l_xrs_object_version_number ;
5791 close c_rslt ;
5792
5793
5794 if l_xrs_object_version_number is null then
5795 ben_ext_rslt_api.create_ext_rslt
5796 (p_validate => FALSE
5797 ,p_ext_rslt_id => l_ext_rslt_id
5798 ,p_run_strt_dt => sysdate
5799 ,p_run_end_dt => null
5800 ,p_ext_stat_cd => 'X'
5801 ,p_eff_dt => l_effective_date
5802 ,p_ext_strt_dt => l_ext_strt_dt
5803 ,p_ext_end_dt => l_ext_end_dt
5804 ,p_output_name => l_output_name
5805 ,p_drctry_name => l_drctry_name
5806 ,p_ext_dfn_id => p_ext_dfn_id
5807 ,p_business_group_id => p_business_group_id
5808 ,p_program_application_id => fnd_global.prog_appl_id
5809 ,p_program_id => fnd_global.conc_program_id
5810 ,p_program_update_date => sysdate
5811 ,p_request_id => l_conc_request_id
5812 ,p_output_type => l_output_type
5813 ,p_xdo_template_id => l_xdo_template_id
5814 ,p_object_version_number => l_xrs_object_version_number
5815 ,p_effective_date => l_effective_date);
5816
5817 commit;
5818 end if ;
5819 else
5820 ben_ext_rslt_api.create_ext_rslt
5821 (p_validate => FALSE
5822 ,p_ext_rslt_id => l_ext_rslt_id
5823 ,p_run_strt_dt => sysdate
5824 ,p_run_end_dt => null
5825 ,p_ext_stat_cd => 'X'
5826 ,p_eff_dt => l_effective_date
5827 ,p_ext_strt_dt => l_ext_strt_dt
5828 ,p_ext_end_dt => l_ext_end_dt
5829 ,p_output_name => l_output_name
5830 ,p_drctry_name => l_drctry_name
5831 ,p_ext_dfn_id => p_ext_dfn_id
5832 ,p_business_group_id => p_business_group_id
5833 ,p_program_application_id => fnd_global.prog_appl_id
5834 ,p_program_id => fnd_global.conc_program_id
5835 ,p_program_update_date => sysdate
5836 ,p_request_id => l_conc_request_id
5837 ,p_output_type => l_output_type
5838 ,p_xdo_template_id => l_xdo_template_id
5839 ,p_object_version_number => l_xrs_object_version_number
5840 ,p_effective_date => l_effective_date);
5841 --
5842 commit;
5843 --
5844 end if ;
5845
5846 if g_debug then
5847 hr_utility.set_location(' resilt_id ' || l_ext_rslt_id,177 ) ;
5848 end if;
5849 benutils.get_parameter
5850 (p_business_group_id => p_business_group_id
5851 ,p_batch_exe_cd => 'BENXTRCT'
5852 ,p_threads => l_threads
5853 ,p_chunk_size => l_chunk_size
5854 ,p_max_errors => l_max_errors_allowed);
5855 --
5856 l_line := 5;
5857 --
5858 if p_benefit_action_id is null then
5859
5860
5861
5862 --
5863 ben_benefit_actions_api.create_perf_benefit_actions
5864 (p_validate => FALSE
5865 ,p_benefit_action_id => l_benefit_action_id
5866 ,p_process_date => l_effective_date
5867 ,p_uneai_effective_date => NULL
5868 ,p_mode_cd => 'S'
5869 ,p_derivable_factors_flag => 'N'
5870 ,p_close_uneai_flag => 'N'
5871 ,p_validate_flag => 'N'
5872 ,p_person_id => NULL
5873 ,p_person_type_id => NULL
5874 ,p_pgm_id => p_ext_dfn_id
5875 ,p_business_group_id => p_business_group_id
5876 ,p_pl_id => l_ext_rslt_id
5877 ,p_popl_enrt_typ_cycl_id => NULL
5878 ,p_no_programs_flag => 'N'
5879 ,p_no_plans_flag => 'N'
5880 ,p_comp_selection_rl => NULL
5881 ,p_person_selection_rl => NULL
5882 ,p_ler_id => NULL
5883 ,p_organization_id => NULL
5884 ,p_benfts_grp_id => NULL
5885 ,p_location_id => NULL
5886 ,p_pstl_zip_rng_id => NULL
5887 ,p_rptg_grp_id => NULL
5888 ,p_pl_typ_id => NULL
5889 ,p_opt_id => NULL
5890 ,p_eligy_prfl_id => NULL
5891 ,p_vrbl_rt_prfl_id => NULL
5892 ,p_legal_entity_id => NULL
5893 ,p_payroll_id => NULL
5894 ,p_request_id => nvl(l_conc_request_id, fnd_global.conc_request_id )
5895 ,p_inelg_action_cd => 'X' --Unique for extract benefit action recs
5896 ,p_debug_messages_flag => 'N'
5897 ,p_object_version_number => l_object_version_number
5898 ,p_effective_date => l_effective_date);
5899 --
5900 commit;
5901 --
5902 l_line := 6;
5903 --
5904 l_line := 7;
5905 --
5906 benutils.g_benefit_action_id := l_benefit_action_id;
5907 benutils.g_thread_id := 99;
5908 --
5909 l_line := 8;
5910
5911 -- process the subheader
5912
5913 process_subheader(p_ext_file_id => l_ext_file_id
5914 ,p_ext_dfn_id => p_ext_dfn_id
5915 ,p_ext_rslt_id => l_ext_rslt_id
5916 ,p_data_typ_cd => l_data_typ_cd
5917 ,p_ext_typ_cd => l_ext_typ_cd
5918 ,p_effective_date => l_effective_date
5919 ,p_ext_crit_prfl_id => l_ext_crit_prfl_id
5920 ,p_ext_global_flag => nvl(l_ext_global_flag, 'N')
5921 ,p_business_group_id => p_business_group_id
5922 ,p_subhdr_ghr_from_dt => l_eff_start_date
5923 ,p_subhdr_ghr_to_dt => l_eff_end_date
5924 ) ;
5925
5926
5927 --
5928 l_person_cnt := 0;
5929
5930 --
5931 --- dont build the person information when there is no detail defintion
5932 --- after intoridction of subheader , there could be setup with subheader alone
5933 if l_D_lvl_found = 'Y' then
5934 build_select_statement
5935 (p_data_typ_cd => l_data_typ_cd,
5936 p_ext_crit_prfl_id => l_ext_crit_prfl_id,
5937 p_ext_dfn_id => p_ext_dfn_id,
5938 p_business_group_id => p_business_group_id,
5939 p_effective_date => l_effective_date,
5940 p_ext_rslt_id => l_ext_rslt_id ,
5941 p_ext_global_flag => nvl(l_ext_global_flag, 'N') ,
5942 p_eff_start_date => l_eff_start_date,
5943 p_eff_end_date => l_eff_end_date,
5944 p_act_start_date => l_act_start_date,
5945 p_act_end_date => l_act_end_date,
5946 p_select_statement => l_select_statement, --out
5947 p_penserv_date => p_penserv_date);
5948 --
5949
5950 begin
5951 --
5952 open PersonCur for l_select_statement;
5953
5954 --
5955 exception
5956 --
5957 when others then
5958 --
5959 fnd_file.put_line(fnd_file.log,'Error executing this dynamically build SQL Statement: ');
5960 -- Update by RChase, 01-MAR-2000
5961 -- fnd_file.put_line(fnd_file.log, ' ' ||l_select_statement);
5962 FOR i in 1..LENGTH(l_select_statement) LOOP
5963 --
5964 IF mod(i,80)=0 OR i=LENGTH(l_select_statement) THEN
5965 --
5966 fnd_file.put_line(fnd_file.log,' ' ||substr(l_select_statement,l_current_loc+1,i-l_current_loc));
5967 l_current_loc:=i;
5968 --
5969 END IF;
5970 --
5971 END LOOP;
5972 --
5973 raise;
5974 --
5975 end;
5976 --
5977 l_line := 10;
5978 --
5979 loop
5980 --
5981 fetch personcur into l_rec;
5982 exit when personcur%notfound;
5983 --
5984
5985 if check_asg_security (p_person_id => l_rec.person_id
5986 ,p_effective_date => l_effective_date
5987 ,p_business_group_id => p_business_group_id ) then
5988
5989 l_person_cnt := l_person_cnt + 1;
5990 l_num_rows := l_num_rows + 1;
5991 --
5992 l_person_action_id.extend(1);
5993 --
5994 select ben_person_actions_s.nextval
5995 into l_person_action_id(l_num_rows)
5996 from sys.dual;
5997 --
5998 l_person_id.extend(1);
5999 l_person_id(l_num_rows) := l_rec.person_id;
6000 --
6001 If l_num_rows = l_chunk_size then
6002 --
6003 forall l_count in 1..l_num_rows
6004 --
6005 insert into ben_person_actions
6006 (person_action_id,
6007 person_id,
6008 ler_id,
6009 benefit_action_id,
6010 action_status_cd,
6011 object_version_number)
6012 values
6013 (l_person_action_id(l_count),
6014 l_person_id(l_count),
6015 null,
6016 l_benefit_action_id,
6017 'U',
6018 1);
6019 --
6020 select ben_batch_ranges_s.nextval
6021 into l_range_id
6022 from sys.dual;
6023 --
6024 l_start_person_action_id := l_person_action_id(1);
6025 l_end_person_action_id := l_person_action_id(l_num_rows);
6026 --
6027 insert into ben_batch_ranges
6028 (range_id,
6029 benefit_action_id,
6030 range_status_cd,
6031 starting_person_action_id,
6032 ending_person_action_id,
6033 object_version_number)
6034 values
6035 (l_range_id,
6036 l_benefit_action_id,
6037 'U',
6038 l_start_person_action_id,
6039 l_end_person_action_id,
6040 1);
6041 --
6042 -- Dispose of varray
6043 --
6044 l_person_action_id.delete;
6045 l_person_id.delete;
6046 --
6047 l_num_rows := 0;
6048 l_num_range := l_num_range + 1;
6049 --
6050 End if;
6051 --
6052 End if ;
6053 End loop;
6054 close personcur ;
6055
6056 -- Create a range of data to be multithreaded for the rest of
6057 -- person_action_id which are left over.
6058 --
6059 l_line := 12;
6060 --
6061 If l_num_rows > 0 then
6062 --
6063 forall l_count in 1..l_num_rows
6064 --
6065 -- Bulk bind in person actions
6066 --
6067 insert into ben_person_actions
6068 (person_action_id,
6069 person_id,
6070 ler_id,
6071 benefit_action_id,
6072 action_status_cd,
6073 object_version_number)
6074 values
6075 (l_person_action_id(l_count),
6076 l_person_id(l_count),
6077 null,
6078 l_benefit_action_id,
6079 'U',
6080 1);
6081 --
6082 l_num_range := l_num_range + 1;
6083 --
6084 -- Get next sequence for the range
6085 --
6086 select ben_batch_ranges_s.nextval
6087 into l_range_id
6088 from sys.dual;
6089 --
6090 l_start_person_action_id := l_person_action_id(1);
6091 l_end_person_action_id := l_person_action_id(l_num_rows);
6092 --
6093 insert into ben_batch_ranges
6094 (range_id,
6095 benefit_action_id,
6096 range_status_cd,
6097 starting_person_action_id,
6098 ending_person_action_id,
6099 object_version_number)
6100 values
6101 (l_range_id,
6102 l_benefit_action_id,
6103 'U',
6104 l_start_person_action_id,
6105 l_end_person_action_id,
6106 1);
6107 --
6108 l_num_rows := 0;
6109 --
6110 -- Dispose of data in varrays
6111 --
6112 l_person_action_id.delete;
6113 l_person_id.delete;
6114 --
6115 End if;
6116 end if ; -- only when the detail level found
6117 --
6118 Else -- benefit_action_id is null
6119 select count(*)
6120 into l_person_cnt
6121 from ben_person_actions
6122 where benefit_action_id = p_benefit_action_id;
6123
6124 ---
6125 l_benefit_action_id := p_benefit_action_id ;
6126 ---
6127 End if; -- End of if benefit_action_id is null;
6128 --
6129 -- Now to multithread the code.
6130 -- We can't multithread unless we are commiting data as we need to
6131 -- reset the status of the processed ranges and force a commit.
6132 --
6133 l_line := 15;
6134 --
6135 commit;
6136 --
6137 fnd_file.put_line(fnd_file.log, 'Total People Scanned: ' || l_person_cnt);
6138 --
6139 l_count := 0;
6140 --
6141 If l_person_cnt > 0 and l_conc_request_id <> -1 then
6142 --
6143 For l_count in 1..least(l_threads,l_num_range) - 1 loop
6144 --
6145 l_request_id := fnd_request.submit_request
6146 (application => 'BEN'
6147 ,program => 'BENXTHRD'
6148 ,description => 'Thread '||to_char(l_count+1)
6149 ,sub_request => FALSE
6150 ,argument1 => l_benefit_action_id
6151 ,argument2 => p_ext_dfn_id
6152 ,argument3 => l_count+1 -- so that we start on 2, because master is 1.
6153 ,argument4 => p_effective_date
6154 ,argument5 => p_business_group_id
6155 ,argument6 => l_data_typ_cd
6156 ,argument7 => l_ext_typ_cd
6157 ,argument8 => l_ext_crit_prfl_id
6158 ,argument9 => l_ext_rslt_id
6159 ,argument10 => l_ext_file_id
6160 ,argument11 => to_char(l_ext_strt_dt, 'YYYY/MM/DD HH24:MI:SS')
6161 ,argument12 => to_char(l_ext_end_dt, 'YYYY/MM/DD HH24:MI:SS')
6162 ,argument13 => l_prmy_sort_cd
6163 ,argument14 => l_scnd_sort_cd
6164 ,argument15 => l_output_name
6165 ,argument16 => l_apnd_rqst_id_flag
6166 ,argument17 => l_conc_request_id
6167 ,argument18 => l_use_eff_dt_for_chgs_flag
6168 ,argument19 => 'N'
6169 ,argument20 => p_eff_start_date
6170 ,argument21 => p_eff_end_date
6171 ,argument22 => p_act_start_date
6172 ,argument23 => p_act_end_date
6173 ,argument24 => p_penserv_mode --------vkodedal changes for penserver
6174 );
6175 --
6176 g_num_processes := g_num_processes + 1;
6177 g_processes_rec(g_num_processes) := l_request_id;
6178 --
6179 End loop;
6180 --
6181 End if;
6182 --
6183 l_line := 16;
6184 --
6185 do_multithread
6186 (errbuf => errbuf
6187 ,retcode => retcode
6188 ,p_benefit_action_id => l_benefit_action_id
6189 ,p_ext_dfn_id => p_ext_dfn_id
6190 ,p_thread_id => 1
6191 ,p_effective_date => p_effective_date
6192 ,p_business_group_id => p_business_group_id
6193 ,p_data_typ_cd => l_data_typ_cd
6194 ,p_ext_typ_cd => l_ext_typ_cd
6195 ,p_ext_crit_prfl_id => l_ext_crit_prfl_id
6196 ,p_ext_rslt_id => l_ext_rslt_id
6197 ,p_ext_file_id => l_ext_file_id
6198 ,p_ext_strt_dt => to_char(l_ext_strt_dt, 'YYYY/MM/DD HH24:MI:SS')
6199 ,p_ext_end_dt => to_char(l_ext_end_dt, 'YYYY/MM/DD HH24:MI:SS')
6200 ,p_prmy_sort_cd => l_prmy_sort_cd
6201 ,p_scnd_sort_cd => l_scnd_sort_cd
6202 ,p_output_name => l_output_name
6203 ,p_apnd_rqst_id_flag => l_apnd_rqst_id_flag
6204 ,p_request_id => l_conc_request_id
6205 ,p_use_eff_dt_for_chgs_flag => l_use_eff_dt_for_chgs_flag
6206 ,p_master_process_flag => 'Y'
6207 ,p_eff_start_date => p_eff_start_date
6208 ,p_eff_end_date => p_eff_end_date
6209 ,p_act_start_date => p_act_start_date
6210 ,p_act_end_date => p_act_end_date
6211 ,p_penserv_mode => p_penserv_mode
6212 );
6213 --
6214 l_line := 116;
6215 --
6216 check_all_threads_finished
6217 (p_effective_date => l_effective_date
6218 ,p_business_group_id => p_business_group_id
6219 ,p_data_typ_cd => l_data_typ_cd
6220 ,p_ext_typ_cd => l_ext_typ_cd
6221 ,p_ext_crit_prfl_id => l_ext_crit_prfl_id
6222 ,p_ext_rslt_id => l_ext_rslt_id
6223 ,p_request_id => l_conc_request_id
6224 ,p_ext_file_id => l_ext_file_id
6225 ,p_ext_strt_dt => l_ext_strt_dt
6226 ,p_ext_end_dt => l_ext_end_dt
6227 ,p_master_process_flag => 'Y');
6228 --
6229
6230 -- Process sub trailer
6231 --
6232 process_subtrailer
6233 (p_ext_rslt_id => l_ext_rslt_id,
6234 p_ext_file_id => l_ext_file_id,
6235 p_ext_typ_cd => l_ext_typ_cd,
6236 p_rcd_typ_cd => 'L',
6237 p_business_group_id => p_business_group_id,
6238 p_effective_date => l_effective_date,
6239 p_request_id => l_conc_request_id,
6240 p_ext_group_elmt1 => ben_ext_thread.g_ext_group_elmt1,
6241 p_ext_group_elmt2 => ben_ext_thread.g_ext_group_elmt2,
6242 p_ext_crit_prfl_id => l_ext_crit_prfl_id);
6243 --
6244 -- Process Footer Records
6245
6246
6247
6248 -- Process Header Records
6249 --
6250 process_ext_ht_recs
6251 (p_ext_rslt_id => l_ext_rslt_id,
6252 p_ext_file_id => l_ext_file_id,
6253 p_ext_typ_cd => l_ext_typ_cd,
6254 p_rcd_typ_cd => 'H',
6255 p_business_group_id => p_business_group_id,
6256 p_effective_date => l_effective_date,
6257 p_request_id => l_conc_request_id,
6258 p_ext_crit_prfl_id => l_ext_crit_prfl_id);
6259 --
6260 -- Process Footer Records
6261 --
6262 process_ext_ht_recs
6263 (p_ext_rslt_id => l_ext_rslt_id,
6264 p_ext_file_id => l_ext_file_id,
6265 p_ext_typ_cd => l_ext_typ_cd,
6266 p_rcd_typ_cd => 'T',
6267 p_business_group_id => p_business_group_id,
6268 p_effective_date => l_effective_date,
6269 p_request_id => l_conc_request_id,
6270 p_ext_crit_prfl_id => l_ext_crit_prfl_id );
6271 --
6272 -- Call Extract Post Processing Rule. This rule is a
6273 -- catch all, that can call a function to do additional
6274 -- iserting or deleting of records, changing sort order,
6275 -- updating fields, or anything. Since this rule is used
6276 -- with formula function, it returns nothing. l_output
6277 -- will not be used here.
6278 --
6279 if l_ext_post_prcs_rl is not null then
6280 --
6281 l_outputs := benutils.formula
6282 (p_formula_id => l_ext_post_prcs_rl,
6283 p_effective_date => l_effective_date,
6284 p_business_group_id => p_business_group_id,
6285 p_param1 => 'EXT_RSLT_ID',
6286 p_param1_value => to_char(l_ext_rslt_id)
6287 --RChase pass extract definition id as input value
6288 ,p_param2 => 'EXT_DFN_ID'
6289 ,p_param2_value => to_char(nvl(ben_ext_thread.g_ext_dfn_id, -1)));
6290 --
6291 end if;
6292 --
6293 commit; -- anything that the formula did.
6294 --
6295 if g_err_cnt > 0 then
6296 --
6297 -- Call update API to update Extract Run Rslts row here
6298 -- Extract status - Completed with Errors
6299 --
6300 l_line := 126;
6301 l_ext_stat_cd := 'E' ;
6302 --
6303 if l_ext_rslt_id is not null then
6304 --
6305 open c_Ext_err_only( l_ext_rslt_id) ;
6306 fetch c_Ext_err_only into l_dummy ;
6307 if c_Ext_err_only%notfound then
6308 l_ext_stat_cd := 'W' ;
6309 end if ;
6310 close c_Ext_err_only ;
6311
6312
6313 ben_ext_rslt_api.update_ext_rslt
6314 (p_validate => false
6315 ,p_ext_rslt_id => l_ext_rslt_id
6316 ,p_run_end_dt => sysdate
6317 ,p_ext_stat_cd => l_ext_stat_cd
6318 ,p_tot_rec_num => g_rec_cnt
6319 ,p_tot_per_num => g_per_cnt
6320 ,p_tot_err_num => g_err_cnt
6321 ,p_program_application_id => fnd_global.prog_appl_id
6322 ,p_program_id => fnd_global.conc_program_id
6323 ,p_program_update_date => sysdate
6324 ,p_request_id => l_conc_request_id
6325 ,p_object_version_number => l_xrs_object_version_number
6326 ,p_effective_date => l_effective_date);
6327 --
6328 end if;
6329 --
6330 else
6331 --
6332 if l_ext_rslt_id is not null then
6333 --
6334 ben_ext_rslt_api.update_ext_rslt
6335 (p_validate => false
6336 ,p_ext_rslt_id => l_ext_rslt_id
6337 ,p_run_end_dt => sysdate
6338 ,p_ext_stat_cd => 'S'
6339 ,p_tot_rec_num => g_rec_cnt
6340 ,p_tot_per_num => g_per_cnt
6341 ,p_tot_err_num => g_err_cnt
6342 ,p_program_application_id => fnd_global.prog_appl_id
6343 ,p_program_id => fnd_global.conc_program_id
6344 ,p_program_update_date => sysdate
6345 ,p_request_id => l_conc_request_id
6346 ,p_object_version_number => l_xrs_object_version_number
6347 ,p_effective_date => l_effective_date);
6348 --
6349 end if;
6350 --
6351 end if;
6352 --
6353 -- Bug fix 1801219
6354 update_ht_strt_end_dt(l_ext_rslt_id);
6355 -- End fix 1801219
6356 commit;
6357 --
6358 if l_conc_request_id <> -1 then
6359 --
6360 fnd_message.set_name('BEN', 'BEN_92185_THREAD_SUCCESS');
6361 fnd_file.put_line(fnd_file.log, fnd_message.get);
6362 fnd_file.put_line(fnd_file.log, ' ');
6363 --
6364 l_line := 127;
6365 --
6366 thread_summary;
6367 --
6368 l_request_id := fnd_request.submit_request
6369 (application => 'BEN',
6370 program => 'BENXERRO',
6371 description => NULL,
6372 sub_request => FALSE,
6373 argument1 => l_conc_request_id
6374 );
6375 --
6376 if l_ext_rslt_id is not null then
6377 --
6378 l_request_id := fnd_request.submit_request
6379 (application => 'BEN',
6380 program => 'BENXSMRY',
6381 description => NULL,
6382 sub_request => FALSE,
6383 argument1 => l_ext_rslt_id);
6384 --
6385 end if;
6386 --
6387 if l_kickoff_wrt_prc_flag = 'Y' then
6388 --
6389 if l_ext_rslt_id is not null then
6390 -- when the output is XDO type and display on call different process
6391 if l_cm_display_flag = 'Y' and l_xdo_template_id is not null then
6392
6393 open c_xdoi (l_xdo_template_id ) ;
6394 fetch c_xdoi into
6395 l_application_short_name ,
6396 l_template_code ,
6397 l_default_language,
6398 l_default_territory ;
6399 close c_xdoi ;
6400
6401 if l_output_type = 'H' then
6402 l_output_code := 'HTML' ;
6403 elsif l_output_type = 'R' then
6404 l_output_code := 'RTF' ;
6405 elsif l_output_type = 'P' then
6406 l_output_code := 'PDF' ;
6407 elsif l_output_type = 'E' then
6408 l_output_code := 'EXCEL' ;
6409 else
6410 l_output_code := 'PDF' ;
6411 end if ;
6412
6413 --- popilate the variable for post poroccing of cm - templates
6414
6415 l_fnd_out := fnd_request.add_layout
6416 (template_appl_name => l_application_short_name,
6417 template_code => l_template_code,
6418 template_language => l_default_language,
6419 template_territory => l_default_territory,
6420 output_format => l_output_code
6421 ) ;
6422
6423 --- call the concurrent manager with XML output
6424
6425
6426 l_request_id := fnd_request.submit_request
6427 (application => 'BEN',
6428 program => 'BENXMLWRIT',
6429 description => NULL,
6430 sub_request => FALSE,
6431 argument1 => l_ext_rslt_id,
6432 argument2 => l_output_type ,
6433 argument3 => p_out_dummy ,
6434 argument4 => null,
6435 argument5 => 'BENXMLWRIT'
6436 );
6437
6438 Else
6439
6440 l_request_id := fnd_request.submit_request
6441 (application => 'BEN',
6442 program => 'BENXWRIT',
6443 description => NULL,
6444 sub_request => FALSE,
6445 argument1 => l_ext_rslt_id,
6446 argument2 => l_output_type ,
6447 argument3 => p_out_dummy ,
6448 argument4 => l_xdo_template_id,
6449 argument5 => 'BENXWRIT'
6450 );
6451 end if ;
6452 --
6453 end if;
6454 --
6455 end if;
6456 --
6457 end if;
6458 --
6459 if g_debug then
6460 hr_utility.set_location ('Exiting '||l_proc,15);
6461 end if;
6462 --
6463 exception
6464 --
6465 when g_job_failure_error then
6466 --
6467 if l_conc_request_id <> -1 then
6468 --
6469 check_all_threads_finished
6470 (p_effective_date => l_effective_date
6471 ,p_business_group_id => p_business_group_id
6472 ,p_data_typ_cd => l_data_typ_cd
6473 ,p_ext_typ_cd => l_ext_typ_cd
6474 ,p_ext_crit_prfl_id => l_ext_crit_prfl_id
6475 ,p_ext_rslt_id => l_ext_rslt_id
6476 ,p_request_id => l_conc_request_id
6477 ,p_ext_file_id => l_ext_file_id
6478 ,p_ext_strt_dt => l_ext_strt_dt
6479 ,p_ext_end_dt => l_ext_end_dt
6480 ,p_master_process_flag => 'Y');
6481 --
6482 end if;
6483 --
6484 if l_ext_rslt_id is not null then
6485 --
6486 ben_ext_rslt_api.update_ext_rslt
6487 (p_validate => false
6488 ,p_ext_rslt_id => l_ext_rslt_id
6489 ,p_run_end_dt => sysdate
6490 ,p_ext_stat_cd => 'F'
6491 ,p_tot_rec_num => g_rec_cnt
6492 ,p_tot_per_num => g_per_cnt
6493 ,p_tot_err_num => g_err_cnt
6494 ,p_program_application_id => fnd_global.prog_appl_id
6495 ,p_program_id => fnd_global.conc_program_id
6496 ,p_program_update_date => sysdate
6497 ,p_request_id => l_conc_request_id
6498 ,p_object_version_number => l_xrs_object_version_number
6499 ,p_effective_date => l_effective_date);
6500 --
6501 commit;
6502 --
6503 end if;
6504 --
6505 if l_conc_request_id <> -1 then
6506 --
6507 l_request_id := fnd_request.submit_request
6508 (application => 'BEN',
6509 program => 'BENXERRO',
6510 description => NULL,
6511 sub_request => FALSE,
6512 argument1 => l_conc_request_id);
6513 --
6514 thread_summary;
6515 fnd_message.set_name('BEN',g_err_name);
6516 fnd_file.put_line(fnd_file.log, fnd_message.get);
6517 fnd_message.raise_error;
6518 --
6519 end if;
6520 --
6521 when others then
6522 --
6523 -- Call update API to update Extract Run Rslts row here
6524 -- Extract status - Job Failure
6525 --
6526 --
6527 if l_conc_request_id <> -1 then
6528 --
6529 check_all_threads_finished
6530 (p_effective_date => l_effective_date
6531 ,p_business_group_id => p_business_group_id
6532 ,p_data_typ_cd => l_data_typ_cd
6533 ,p_ext_typ_cd => l_ext_typ_cd
6534 ,p_ext_crit_prfl_id => l_ext_crit_prfl_id
6535 ,p_ext_rslt_id => l_ext_rslt_id
6536 ,p_request_id => l_conc_request_id
6537 ,p_ext_file_id => l_ext_file_id
6538 ,p_ext_strt_dt => l_ext_strt_dt
6539 ,p_ext_end_dt => l_ext_end_dt
6540 ,p_master_process_flag => 'Y');
6541 --
6542 end if;
6543 --
6544 if l_ext_rslt_id is not null then
6545 --
6546 ben_ext_rslt_api.update_ext_rslt
6547 (p_validate => false
6548 ,p_ext_rslt_id => l_ext_rslt_id
6549 ,p_run_end_dt => sysdate
6550 ,p_ext_stat_cd => 'F'
6551 ,p_tot_rec_num => g_rec_cnt
6552 ,p_tot_per_num => g_per_cnt
6553 ,p_tot_err_num => g_err_cnt
6554 ,p_program_application_id => fnd_global.prog_appl_id
6555 ,p_program_id => fnd_global.conc_program_id
6556 ,p_program_update_date => sysdate
6557 ,p_request_id => l_conc_request_id
6558 ,p_object_version_number => l_xrs_object_version_number
6559 ,p_effective_date => l_effective_date);
6560 --
6561 write_error(p_err_num => null,
6562 p_err_name => substr(sqlerrm, 1, 200),
6563 p_typ_cd => 'F',
6564 p_person_id => null,
6565 p_request_id => l_conc_request_id,
6566 p_ext_rslt_id => l_ext_rslt_id,
6567 p_business_group_id => p_business_group_id);
6568 commit;
6569 --
6570 end if;
6571 --
6572 if l_conc_request_id <> -1 then
6573 --
6574 l_request_id := fnd_request.submit_request
6575 (application => 'BEN',
6576 program => 'BENXERRO',
6577 description => NULL,
6578 sub_request => FALSE,
6579 argument1 => l_conc_request_id);
6580 --
6581 thread_summary;
6582 fnd_message.set_name('PER', 'FFU10_GENERAL_ORACLE_ERROR');
6583 fnd_message.set_token('2', substr(sqlerrm, 1, 200));
6584 fnd_file.put_line(fnd_file.log, fnd_message.get);
6585 fnd_message.raise_error;
6586 --
6587 end if;
6588 --
6589 End process;
6590
6591
6592
6593 procedure ext_restart_clear(
6594 p_benefit_action_id in number
6595 ,p_ext_rslt_id in number
6596 ,p_start_person_action_id in number
6597 ,p_end_person_action_id in number
6598 ,p_effective_date in date
6599 ) is
6600
6601 l_package varchar2(80);
6602
6603 cursor per_cursor is
6604 select person_id
6605 from ben_person_actions act
6606 where act.person_action_id between p_start_person_action_id
6607 and p_end_person_action_id
6608 and act.benefit_action_id = p_benefit_action_id
6609 and action_status_cd <> 'P' ;
6610
6611 cursor c_xrdt (c_person_id number) is
6612 select ext_rslt_dtl_id,
6613 object_version_number
6614 from ben_ext_rslt_dtl
6615 where person_id = c_person_id
6616 and ext_rslt_id = p_ext_rslt_id ;
6617
6618
6619 cursor c_xrer (c_person_id number) is
6620 select ext_rslt_err_id,
6621 object_version_number
6622 from ben_ext_rslt_err
6623 where person_id = c_person_id
6624 and ext_rslt_id = p_ext_rslt_id ;
6625
6626 ---
6627
6628 l_object_version_number number ;
6629
6630 begin
6631 if g_debug then
6632 l_package := g_package||'.ext_restart_clear';
6633 hr_utility.set_location ('Entering '||l_package,10);
6634 hr_utility.set_location ('result_id '||p_ext_rslt_id,10);
6635 end if;
6636
6637 for pact in per_cursor
6638 loop
6639
6640 if g_debug then
6641 hr_utility.set_location ('person '||pact.person_id,10);
6642 end if;
6643 ---delete extract results for the person proccessed
6644 --- and in the error range
6645 for xrdt in c_xrdt(pact.person_id)
6646 loop
6647
6648 if g_debug then
6649 hr_utility.set_location ('deleting '|| pact.person_id, 177);
6650 end if;
6651
6652 l_object_version_number := xrdt.object_version_number ;
6653 ben_EXT_RSLT_DTL_api.delete_EXT_RSLT_DTL
6654 (p_ext_rslt_dtl_id => xrdt.ext_rslt_dtl_id
6655 ,p_object_version_number => l_object_version_number
6656 );
6657 end loop ;
6658
6659 ---delete all the error created for the persopns
6660 for xrer in c_xrer(pact.person_id)
6661 loop
6662
6663 if g_debug then
6664 hr_utility.set_location ('deleting error'||pact.person_id, 177);
6665 end if;
6666
6667 l_object_version_number := xrer.object_version_number ;
6668 ben_EXT_RSLT_ERR_api.delete_EXT_RSLT_ERR
6669 (p_ext_rslt_err_id => xrer.ext_rslt_err_id
6670 ,p_object_version_number => l_object_version_number
6671 ,p_effective_date => p_effective_date
6672 );
6673 end loop ;
6674
6675 end loop ;
6676 if g_debug then
6677 hr_utility.set_location ('Leaving '||l_package,10);
6678 end if;
6679 end ext_restart_clear ;
6680 --
6681 --old proc. Not used
6682 --
6683 /*procedure restart(errbuf out nocopy varchar2
6684 ,retcode out nocopy varchar2
6685 ,p_benefit_action_id in number
6686 ,p_ext_rslt_id in number default null) is
6687 --
6688 l_package varchar2(80);
6689
6690 cursor c_parameters is
6691 select pgm_id
6692 ,pl_id
6693 ,business_group_id
6694 ,process_date
6695 from ben_benefit_actions ben
6696 where ben.benefit_action_id = p_benefit_action_id;
6697
6698
6699 cursor c_range_err is
6700 select *
6701 from ben_batch_ranges ran
6702 where ran.range_status_cd = 'E'
6703 and ran.BENEFIT_ACTION_ID = P_BENEFIT_ACTION_ID;
6704
6705
6706 --
6707 l_parameters c_parameters%rowtype;
6708 l_errbuf varchar2(80);
6709 l_retcode number;
6710 l_ext_rslt_id number ;
6711 --
6712 begin
6713 g_debug := hr_utility.debug_enabled;
6714 if g_debug then
6715 l_package := g_package||'.restart';
6716 hr_utility.set_location ('Entering '||l_package,10);
6717 end if;
6718 --
6719 -- get the parameters for a previous run and do a restart
6720 --
6721 open c_parameters;
6722 --
6723 fetch c_parameters into l_parameters;
6724 if c_parameters%notfound then
6725 --
6726 fnd_message.set_name('BEN','BEN_91666_BENMNGLE_NO_RESTART');
6727 fnd_message.raise_error;
6728 --
6729 end if;
6730 --
6731 close c_parameters;
6732
6733 l_ext_rslt_id := l_parameters.pl_id ;
6734 if l_ext_rslt_id is null then
6735 l_ext_rslt_id := p_ext_rslt_id ;
6736 if l_ext_rslt_id is null then
6737 --- create new error for this
6738 fnd_message.set_name('BEN','BEN_91666_RSLT_ID_NOT_FOUND');
6739 fnd_message.raise_error;
6740 end if ;
6741 end if ;
6742
6743
6744
6745 --- Clearup all detail of the person processed
6746 --- and the action_status not updated
6747 --- changes the errored status of the ranges to
6748 --- unprocessed
6749 if l_ext_rslt_id is not null then
6750 for rng in c_range_err
6751 Loop
6752 if g_debug then
6753 hr_utility.set_location ('range id '||rng.starting_person_action_id,10);
6754 end if;
6755 ext_restart_clear(
6756 p_benefit_action_id => p_benefit_action_id
6757 ,p_ext_rslt_id => l_ext_rslt_id
6758 ,p_start_person_action_id => rng.starting_person_action_id
6759 ,p_end_person_action_id => rng.ending_person_action_id
6760 ,p_effective_date => l_parameters.process_date
6761 ) ;
6762 ---- range_id is updated
6763 update ben_batch_ranges
6764 set range_Status_cd = 'U'
6765 where range_id = rng.range_id ;
6766 end loop ;
6767 end if ;
6768
6769
6770
6771 process(l_errbuf
6772 ,l_retcode
6773 ,p_benefit_action_id
6774 ,l_parameters.pgm_id -- cover for ext_id
6775 ,fnd_date.date_to_canonical(l_parameters.process_date)
6776 ,l_parameters.business_group_id
6777 ,l_ext_rslt_id);
6778
6779 if g_debug then
6780 hr_utility.set_location ('Leaving '||l_package,10);
6781 end if;
6782 end; */
6783 --
6784 --new proc
6785 --
6786 -- =============================================================================
6787 -- ~ Chk_PQP_Extract:
6788 -- =============================================================================
6789 PROCEDURE Chk_PQP_Extract
6790 (p_ext_dfn_id IN NUMBER
6791 ,p_ext_rslt_id IN NUMBER
6792 ,p_business_group_id IN NUMBER
6793 ,p_conc_req_id IN NUMBER
6794 ) AS
6795 -- Cursor to check if the extract is PQP extract.
6796 CURSOR check_pqp_extract (c_ext_dfn_id IN NUMBER,
6797 c_business_group_id IN NUMBER) IS
6798 SELECT ea.ext_dfn_type
6799 FROM ben_ext_dfn ed,
6800 per_business_groups bg,
6801 pqp_extract_attributes ea
6802 WHERE ((bg.business_group_id = ed.business_group_id)OR
6803 (bg.legislation_code = ed.legislation_code) OR
6804 (ed.business_group_id IS NULL AND
6805 ed.legislation_code IS NULL)
6806 )
6807 AND bg.business_group_id = c_business_group_id
6808 AND ed.ext_dfn_id = ea.ext_dfn_id
6809 AND ed.ext_dfn_id = c_ext_dfn_id
6810 AND ea.ext_dfn_type in
6811 ('PEN_FPR', 'PEN_CHG', 'FID_PTC','FID_CAC',
6812 'FID_ERC', 'FID_LPY', 'FID_ATE','FID_CHG',
6813 'GBL_FPR', 'GBL_CHG', 'GBL_MUL_CHG');
6814 --
6815 CURSOR csr_org_req (c_ext_dfn_id IN NUMBER
6816 ,c_ext_rslt_id IN NUMBER
6817 ,c_business_group_id IN NUMBER) IS
6818 SELECT bba.pgm_id
6819 ,bba.pl_id
6820 ,bba.benefit_action_id
6821 ,bba.business_group_id
6822 ,bba.process_date
6823 ,bba.request_id
6824 FROM ben_benefit_actions bba
6825 WHERE bba.pl_id = c_ext_rslt_id
6826 AND bba.pgm_id = c_ext_dfn_id
6827 AND bba.business_group_id = c_business_group_id;
6828 l_org_req csr_org_req%ROWTYPE;
6829
6830 -- Cursor to get the extract parameters of the last req.
6831 CURSOR csr_req_params ( c_req_id IN NUMBER) IS
6832 SELECT *
6833 FROM fnd_concurrent_requests
6834 WHERE request_id = c_req_id;
6835
6836 l_conc_params csr_req_params%ROWTYPE;
6837 l_pqp_extract BOOLEAN;
6838 l_ext_type VARCHAR2(50);
6839 l_session_id NUMBER;
6840 l_conc_request_id NUMBER;
6841 l_proc_name VARCHAR2(150);
6842
6843 BEGIN
6844 IF g_debug THEN
6845 l_proc_name := g_package||'.Chk_PQP_Extract';
6846 Hr_Utility.set_location('Entering: '||l_proc_name, 5);
6847 END IF;
6848
6849 OPEN check_pqp_extract (p_ext_dfn_id,
6850 p_business_group_id);
6851 FETCH check_pqp_extract INTO l_ext_type;
6852 l_pqp_extract := check_pqp_extract%FOUND;
6853 CLOSE check_pqp_extract;
6854 --
6855 -- Return if not a PQP seeded/copied extract.
6856 --
6857 IF NOT l_pqp_extract THEN
6858 RETURN;
6859 END IF;
6860 --
6861 -- Delete the existing completed extracts for the extract def. within
6862 -- this business group.
6863 --
6864 DELETE FROM pay_us_rpt_totals
6865 WHERE tax_unit_id = p_conc_req_id
6866 AND attribute5 = 'EXTRACT_COMPLETED'
6867 AND business_group_id = p_business_group_id
6868 AND organization_id = p_business_group_id
6869 AND location_id = p_ext_dfn_id;
6870
6871 OPEN csr_org_req (c_ext_dfn_id => p_ext_dfn_id
6872 ,c_ext_rslt_id => p_ext_rslt_id
6873 ,c_business_group_id => p_business_group_id);
6874 FETCH csr_org_req INTO l_org_req;
6875 CLOSE csr_org_req;
6876 --
6877 -- Get the old paramters used by the extract, based on the concurrent
6878 -- request id passed.
6879 --
6880 OPEN csr_req_params(l_org_req.request_id);
6881 FETCH csr_req_params INTO l_conc_params;
6882 CLOSE csr_req_params;
6883 --
6884 -- Get session id and the concurrent req. id
6885 --
6886 l_session_id := Userenv('SESSIONID');
6887 l_conc_request_id := Fnd_Global.conc_request_id;
6888 --
6889 IF l_ext_type IN
6890 ('PEN_FPR', 'PEN_CHG', 'FID_PTC','FID_CAC',
6891 'FID_ERC', 'FID_LPY', 'FID_ATE','FID_CHG') THEN
6892
6893 INSERT INTO pay_us_rpt_totals
6894 (session_id -- session id
6895 ,organization_name -- Conc. Program Name
6896 ,business_group_id -- business group id
6897 ,organization_id -- -do-
6898 ,location_id -- Ext Def Id
6899 ,tax_unit_id -- concurrent request id
6900 ,value1 -- extract def. id
6901 ,value2 -- element set id
6902 ,value3 -- element type id
6903 ,value4 -- Payroll Id
6904 ,value5 -- GRE Org Id
6905 ,value6 -- Consolidation set id
6906 ,attribute1 -- Selection Criteria
6907 ,attribute2 -- Reporting dimension
6908 ,attribute3 -- Extract Start Date
6909 ,attribute4 -- Extract End Date
6910 ,attribute5 -- Status
6911 )
6912 VALUES
6913 (l_session_id
6914 ,'US Pension Extracts'
6915 ,p_business_group_id -- p_business_group_id
6916 ,p_business_group_id -- Org Id
6917 ,p_ext_dfn_id -- location id for key
6918 ,l_conc_request_id -- New Conc Req Id.
6919 ,l_conc_params.argument2 -- p_ext_dfn_id
6920 ,l_conc_params.argument9 -- p_element_set_id
6921 ,l_conc_params.argument12 -- p_element_type_id
6922 ,l_conc_params.argument17 -- p_payroll_id
6923 ,l_conc_params.argument16 -- p_gre_id
6924 ,l_conc_params.argument20 -- p_con_set
6925 ,l_conc_params.argument7 -- p_selection_criteria
6926 ,l_conc_params.argument5 -- p_reporting_dimension
6927 ,l_conc_params.argument14 -- p_start_date
6928 ,l_conc_params.argument15 -- p_end_date
6929 ,'EXTRACT_RUNNING' -- Status
6930 );
6931 ELSIF l_ext_type IN
6932 ('GBL_FPR', 'GBL_CHG', 'GBL_MUL_CHG') THEN
6933
6934 INSERT INTO pay_us_rpt_totals
6935 (session_id -- session id
6936 ,organization_name -- Conc. Program Name
6937 ,business_group_id -- business group id
6938 ,organization_id -- -do-
6939 ,location_id -- Ext Def Id
6940 ,tax_unit_id -- concurrent request id
6941 ,value1 -- extract def. id
6942 ,value2 -- element set id
6943 ,value3 -- element type id
6944 ,value4 -- Payroll Id
6945 ,value5 -- GRE Org Id
6946 ,value6 -- Consolidation set id
6947 ,attribute1 -- Selection Criteria
6948 ,attribute2 -- Reporting dimension
6949 ,attribute3 -- Extract Start Date
6950 ,attribute4 -- Extract End Date
6951 ,attribute5 -- Organization Name
6952 ,attribute6 -- Person Type
6953 ,attribute7 -- Location
6954 )
6955 VALUES
6956 (l_session_id -- session id
6957 ,'Global Pension Extracts'
6958 ,p_business_group_id -- p_business_group_id
6959 ,p_business_group_id -- Org Id
6960 ,p_ext_dfn_id -- ext dfn id for key purpose
6961 ,l_conc_request_id -- New Conc Req Id.
6962 ,l_conc_params.argument2 -- p_ext_dfn_id
6963 ,l_conc_params.argument8 -- p_element_set_id
6964 ,l_conc_params.argument10 -- p_element_type_id
6965 ,l_conc_params.argument15 -- p_payroll_id
6966 ,l_conc_params.argument14 -- p_gre_id
6967 ,l_conc_params.argument18 -- p_con_set
6968 ,l_conc_params.argument6 -- p_selection_criteria
6969 ,l_conc_params.argument4 -- p_reporting_dimension
6970 ,l_conc_params.argument12 -- p_start_date
6971 ,l_conc_params.argument13 -- p_end_date
6972 ,l_conc_params.argument20 -- p_org_id
6973 ,l_conc_params.argument21 -- p_person_type_id
6974 ,l_conc_params.argument22 -- p_location_id
6975 );
6976
6977 END IF;
6978 IF g_debug THEN
6979 Hr_Utility.set_location('Leaving: '||l_proc_name, 80);
6980 END IF;
6981 END Chk_PQP_Extract;
6982
6983 -- =============================================================================
6984 -- ~ Restart:
6985 -- =============================================================================
6986 procedure Restart(errbuf out nocopy varchar2
6987 ,retcode out nocopy varchar2
6988 ,p_ext_dfn_id in number
6989 ,p_concurrent_request_id in number) is
6990
6991
6992 l_errbuf varchar2(80);
6993 l_retcode number;
6994 l_ext_rslt_id number ;
6995 l_benefit_action_id number;
6996 l_business_group_id number;
6997 l_session_id number;
6998 l_request_id number;
6999 l_pqp_extract boolean;
7000 l_dummy varchar2(1);
7001 l_package varchar2(80);
7002
7003 cursor c_parameters is
7004 select pgm_id
7005 ,pl_id
7006 ,benefit_action_id
7007 ,business_group_id
7008 ,process_date
7009 from ben_benefit_actions ben
7010 where ben.request_id = p_concurrent_request_id;
7011 l_parameters c_parameters%rowtype;
7012
7013 cursor c_range_err is
7014 select *
7015 from ben_batch_ranges ran
7016 where ran.range_status_cd in ( 'E', 'W')
7017 and ran.benefit_action_id = l_benefit_action_id;
7018
7019
7020 BEGIN
7021
7022 g_debug := hr_utility.debug_enabled;
7023 if g_debug then
7024 l_package := g_package||'.restart';
7025 hr_utility.set_location ('Entering '||l_package,10);
7026 end if;
7027 --
7028 -- get the parameters for a previous run and do a restart
7029 --
7030 open c_parameters;
7031 --
7032 fetch c_parameters into l_parameters;
7033 if c_parameters%notfound then
7034 --
7035 fnd_message.set_name('BEN','BEN_91666_BENMNGLE_NO_RESTART');
7036 fnd_message.raise_error;
7037 --
7038 end if;
7039 --
7040 close c_parameters;
7041
7042 l_ext_rslt_id := l_parameters.pl_id ;
7043 l_benefit_action_id := l_parameters.benefit_action_id;
7044 l_business_group_id := l_parameters.business_group_id;
7045
7046 if l_ext_rslt_id is null then
7047 -- create new error for this
7048 fnd_message.set_name('BEN','BEN_91666_RSLT_ID_NOT_FOUND');
7049 fnd_message.raise_error;
7050 end if ;
7051 --
7052 -- Check to see if the extract being re-started is a PQP US/Global seeded
7053 -- or copied extract, if yes then the following procedure insert the values
7054 -- of the extract parameters of the failed run into table pay_us_rpt_totals.
7055 --
7056 Chk_PQP_Extract
7057 (p_ext_dfn_id => p_ext_dfn_id
7058 ,p_ext_rslt_id => l_ext_rslt_id
7059 ,p_business_group_id => l_business_group_id
7060 ,p_conc_req_id => p_concurrent_request_id
7061 );
7062 --
7063 -- Clearup all detail of the person processed and the action_status
7064 -- not updated changes the errored status of the ranges to unprocessed
7065 --
7066 if l_ext_rslt_id is not null then
7067 for rng in c_range_err
7068 Loop
7069 if g_debug then
7070 hr_utility.set_location ('range id '||rng.starting_person_action_id,10);
7071 end if;
7072 ext_restart_clear
7073 (p_benefit_action_id => l_benefit_action_id
7074 ,p_ext_rslt_id => l_ext_rslt_id
7075 ,p_start_person_action_id => rng.starting_person_action_id
7076 ,p_end_person_action_id => rng.ending_person_action_id
7077 ,p_effective_date => l_parameters.process_date
7078 ) ;
7079 -- range_id is updated
7080 update ben_batch_ranges
7081 set range_status_cd = 'U'
7082 where range_id = rng.range_id;
7083 end loop;
7084 end if ;
7085 -- Re-process the failed records.
7086
7087 process(errbuf => l_errbuf
7088 ,retcode => l_retcode
7089 ,p_benefit_action_id => l_benefit_action_id
7090 ,p_ext_dfn_id => l_parameters.pgm_id -- cover for ext_id
7091 ,p_effective_date => fnd_date.date_to_canonical(l_parameters.process_date)
7092 ,p_business_group_id => l_parameters.business_group_id
7093 ,p_ext_rslt_id => l_ext_rslt_id);
7094
7095 /*
7096 process(l_errbuf
7097 ,l_retcode
7098 ,l_benefit_action_id
7099 ,l_parameters.pgm_id -- cover for ext_id
7100 ,fnd_date.date_to_canonical(l_parameters.process_date)
7101 ,l_parameters.business_group_id
7102 ,l_ext_rslt_id);
7103
7104 */
7105
7106 if g_debug then
7107 hr_utility.set_location ('Leaving '||l_package,10);
7108 end if;
7109
7110 end Restart;
7111
7112 -- =============================================================================
7113 -- ~ Load_Extract:
7114 -- =============================================================================
7115 Procedure load_extract(
7116 errbuf out nocopy varchar2
7117 ,retcode out nocopy number
7118 ,p_mode in varchar2
7119 ,p_seeded in varchar2 default 'N'
7120 ,p_loader_file in varchar2 default null
7121 ,p_file_name in varchar2
7122 ,p_view_name in varchar2 default null
7123 ,p_extract_file_id in number default null
7124 ,p_business_group_id in number
7125 ,p_validate in varchar2 default 'N'
7126 ,p_allow_override in varchar2 default 'N'
7127 ) is
7128
7129
7130 l_proc varchar2(72) := g_package||'Load_extract';
7131
7132
7133 --
7134 cursor c_threads(p_request_id number) is
7135 select null
7136 from fnd_concurrent_requests fnd
7137 where /*fnd.phase_code <> 'C' and */
7138 fnd.request_id = p_request_id;
7139 --
7140 cursor c_bg_name is
7141 select name
7142 from per_business_groups bg
7143 where business_group_id = p_business_group_id ;
7144
7145 cursor c_ext is
7146 select name,business_group_id
7147 from ben_ext_file
7148 where ext_file_id = p_extract_file_id ;
7149
7150 l_business_goup_name per_business_groups.name%Type ;
7151 l_request_id number ;
7152 l_business_group_name varchar2(2000) ;
7153 l_business_group_id number ;
7154 l_view_name varchar2(2000) ;
7155 l_loader_file varchar2(2000) := p_loader_file ;
7156 l_ext_file_name varchar2(2000) ;
7157 l_seeded varchar2(2000) := p_seeded ;
7158 l_dummy varchar2(1) ;
7159 l_validate varchar2(2000) ;
7160 l_override varchar2(2000) ;
7161 begin
7162 --
7163 fnd_msg_pub.initialize;
7164 --
7165 hr_utility.set_location('Entering:'|| l_proc, 10);
7166 hr_utility.set_location('p_mode '|| p_mode ,10) ;
7167 hr_utility.set_location('p_seeded '|| p_seeded ,10) ;
7168 hr_utility.set_location('p_loader_file '|| p_loader_file,10) ;
7169 hr_utility.set_location('p_file_name '|| p_file_name ,10) ;
7170 hr_utility.set_location('p_view_name '|| p_view_name,10) ;
7171 hr_utility.set_location('p_extract_file_id'||p_extract_file_id ,10) ;
7172 hr_utility.set_location('p_business_group_id'||p_business_group_id ,10) ;
7173 hr_utility.set_location('p_validate '|| p_validate ,10) ;
7174 --
7175 --
7176 -- Issue a savepoint if operating in validation only mode
7177 --
7178 savepoint SUBMIT_COPY_REQUEST;
7179 --
7180 hr_utility.set_location(l_proc, 20);
7181
7182 open c_bg_name ;
7183 fetch c_bg_name into l_business_goup_name ;
7184 if c_bg_name%notfound then
7185 close c_bg_name ;
7186 fnd_message.set_name('BEN','BEN_91000_INVALID_BUS_GROUP');
7187 fnd_message.raise_error;
7188 end if ;
7189 close c_bg_name ;
7190
7191 -- decide whether it is seede or not for when the process is export
7192 if p_mode = 'EXP' then
7193 -- get the extract name and validate
7194 open c_ext ;
7195 fetch c_ext into l_ext_file_name,l_business_group_id ;
7196 close c_ext ;
7197 --
7198 if l_ext_file_name is null then
7199 fnd_message.set_name('BEN','BEN_91000_INVALID_EXT_NAME');
7200 fnd_message.raise_error;
7201 end if ;
7202 --
7203 if l_business_group_id is not null then
7204 l_seeded := 'N' ;
7205 l_business_group_name := 'BUSINESS_GROUP='|| l_business_goup_name ;
7206 else
7207 l_seeded := 'Y' ;
7208 end if ;
7209
7210 l_ext_file_name := 'FILE_NAME='|| l_ext_file_name ;
7211 else
7212 --- import to system
7213 -- the upload only suppport business group base uploads
7214 -- seeded should be uploaded from hrglobals
7215 l_business_group_name := 'UPLOAD_BUSINESS_GROUP='|| l_business_goup_name ;
7216 l_view_name := 'LEG_VIEW=' || 'BEN_PL_V' ;
7217
7218 -- if validate mode then set the variable
7219 if p_validate = 'Y' then
7220 l_validate := 'VALIDATE_MODE='|| p_validate ;
7221 end if ;
7222
7223 if p_allow_override = 'Y' then
7224 l_override := 'EXT_OVERRIDE='||p_allow_override ;
7225 end if ;
7226 end if ;
7227
7228
7229 hr_utility.set_location('Bg Name ' || l_business_group_name , 20);
7230
7231
7232 if p_file_name is null then
7233 fnd_message.set_name('BEN','BEN_91000_INVALID_FILE_NAME');
7234 fnd_message.raise_error;
7235 end if ;
7236
7237 if l_loader_file is null then
7238 l_loader_file := '@ben:/patch/115/import/benextse.lct';
7239 end if ;
7240
7241 --
7242
7243 if p_mode = 'EXP' then
7244 l_request_id := fnd_request.submit_request
7245 (application => 'BEN'
7246 ,program => 'BENXUPLDR'
7247 ,description => NULL
7248 ,sub_request => FALSE
7249 ,argument1 => 'DOWNLOAD'
7250 ,argument2 => l_loader_file
7251 ,argument3 => p_file_name
7252 ,argument4 => 'EXTRACT'
7253 ,argument5 => l_ext_file_name
7254 ,argument6 => 'CM_DOWNLOAD=Y'
7255 ,argument7 => l_business_group_name
7256 );
7257 else
7258 l_request_id := fnd_request.submit_request
7259 (application => 'BEN'
7260 ,program => 'BENXDNLDR'
7261 ,description => NULL
7262 ,sub_request => FALSE
7263 ,argument1 => 'UPLOAD_PARTIAL'
7264 ,argument2 => l_loader_file
7265 ,argument3 => p_file_name
7266 ,argument4 => 'EXTRACT'
7267 ,argument5 => l_view_name
7268 ,argument6 => l_business_group_name
7269 ,argument7 => l_validate
7270 ,argument8 => l_override
7271 );
7272 end if ;
7273
7274 -- When in validation only mode raise the Validate_Enabled exception
7275 --
7276 hr_utility.set_location(' Leaving:'||l_proc, 70);
7277 --
7278 exception
7279 --
7280 when app_exception.application_exception then
7281
7282 fnd_msg_pub.add;
7283
7284 --
7285 when others then
7286 --
7287 -- A validation or unexpected error has occured
7288 --
7289 ROLLBACK TO SUBMIT_COPY_REQUEST;
7290 raise;
7291 --
7292 end Load_extract;
7293
7294
7295 --
7296 End ben_ext_thread;