DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_IE_EHECS_REPORT_PKG

Source


1 PACKAGE BODY PAY_IE_EHECS_REPORT_PKG AS
2 /* $Header: pyieehecs.pkb 120.5.12010000.3 2008/10/20 06:36:56 rsahai ship $ */
3 
4 g_package	VARCHAR2(50)  := 'PAY_IE_EHECS_REPORT_PKG.';
5 EOL		VARCHAR2(5)   := fnd_global.local_chr(10);
6 l_errflag VARCHAR2(1) := 'N';
7 error_message boolean;
8 l_str_Common VARCHAR2(2000);
9 l_employee_categories VARCHAR(200);
10 l_ehecs_exception exception;
11 
12 -----------------------------------------------------------------------
13 -- setup_balance_table
14 -----------------------------------------------------------------------
15 
16 PROCEDURE setup_balance_table
17 IS
18 
19 CURSOR csr_balance_dimension(p_balance   IN CHAR,
20                              p_dimension IN CHAR) IS
21 SELECT pdb.defined_balance_id
22 FROM   pay_balance_types pbt,
23        pay_balance_dimensions pbd,
24        pay_defined_balances pdb
25 WHERE  pdb.balance_type_id = pbt.balance_type_id
26 AND    pdb.balance_dimension_id = pbd.balance_dimension_id
27 AND    pbt.balance_name = p_balance
28 AND    pbd.database_item_suffix = p_dimension
29 AND    pbd.legislation_code = 'IE'
30 AND    pbd.business_group_id is NULL
31 AND    pbt.legislation_code = 'IE'
32 AND    pbt.business_group_id is NULL
33 AND    pdb.legislation_code = 'IE'
34 AND    pdb.business_group_id is NULL;
35 
36 l_archive_index		NUMBER       := 0;
37 l_dimension			VARCHAR2(16) := '_ASG_QTD';
38 l_max_stat_balance	NUMBER       := 24;
39 l_index_id			NUMBER       := 0;
40 
41 l_proc                          VARCHAR2(120) := g_package || 'setup_balance_table';
42 BEGIN
43 
44   hr_utility.set_location('Entering ' || l_proc,10);
45   hr_utility.set_location('Step ' || l_proc,20);
46 
47   g_balance_name(1).balance_name   := 'Regular Earnings';
48   g_balance_name(2).balance_name   := 'Irregular Earnings';
49   g_balance_name(3).balance_name   := 'Overtime Payments';
50   g_balance_name(4).balance_name   := 'Paid Overtime Hours';
51   g_balance_name(5).balance_name   := 'Paid Maternity Hours';
52   g_balance_name(6).balance_name   := 'Paid Sick Leave Hours';
53   g_balance_name(7).balance_name   := 'Paid Other Leave Hours';
54   g_balance_name(8).balance_name   := 'Income Continuance Insurance';
55   g_balance_name(9).balance_name   := 'Redundancy Payments';
56   g_balance_name(10).balance_name  := 'Employee Related Payments';
57   g_balance_name(11).balance_name  := 'Training Subsidies';
58   g_balance_name(12).balance_name  := 'Refunds';
59   g_balance_name(13).balance_name  := 'Voluntary Sickness Insurance';
60   g_balance_name(14).balance_name  := 'Staff Housing';
61   g_balance_name(15).balance_name  := 'Other Benefits';
62   g_balance_name(16).balance_name  := 'Other Subsidies';
63   g_balance_name(17).balance_name  := 'Hourly Rate';
64   g_balance_name(18).balance_name  := 'Stock Options and Share Purchase';
65   g_balance_name(19).balance_name  := 'IE RBS ER Contribution';
66   g_balance_name(20).balance_name  := 'IE PRSA ER Contribution';
67   g_balance_name(21).balance_name  := 'IE RAC ER Contribution';
68   g_balance_name(22).balance_name  := 'IE PRSI Employer';
69   g_balance_name(23).balance_name  := 'IE BIK Company Vehicle';
70   g_balance_name(24).balance_name  := 'Normal Working Hours';
71 /*6856473 */
72   g_balance_name(25).balance_name  := 'Paid Maternity Days';
73   g_balance_name(26).balance_name  := 'Paid Other Leave Days';
74   g_balance_name(27).balance_name  := 'Paid Sick Leave Days';
75 
76   /* 6856473 */
77 
78   g_balance_name(28).balance_name  := 'Annual Leave and Bank Holiday Hours';
79   g_balance_name(29).balance_name  := 'Annual Leave and Bank Holiday Days';
80 
81   hr_utility.set_location('Step = ' || l_proc,30);
82 
83   FOR l_index IN 1 .. g_balance_name.COUNT
84   LOOP
85 
86     l_dimension := '_ASG_QTD';
87     hr_utility.set_location('l_index      = ' || l_index,30);
88     hr_utility.set_location('balance_name = ' || g_balance_name(l_index).balance_name,30);
89     hr_utility.set_location('l_dimension  = ' || l_dimension,30);
90 
91     l_index_id := l_index_id +1;
92     OPEN csr_balance_dimension(g_balance_name(l_index).balance_name,
93                                l_dimension);
94     FETCH csr_balance_dimension
95     INTO	g_def_bal_id(l_index_id).defined_balance_id;
96     g_def_bal_id(l_index_id).balance_name := g_balance_name(l_index).balance_name;
97 
98     IF csr_balance_dimension%NOTFOUND
99     THEN
100       g_def_bal_id(l_index_id).defined_balance_id := 0;
101     END IF;
102 
103     CLOSE csr_balance_dimension;
104 
105     hr_utility.set_location('Balance Name = ' || g_def_bal_id(l_index_id).balance_name,30);
106     hr_utility.set_location('defined_balance_id = ' || g_def_bal_id(l_index_id).defined_balance_id,30);
107 
108   END LOOP;
109 
110   hr_utility.set_location('Step ' || l_proc,50);
111 
112   hr_utility.set_location('Leaving ' || l_proc,60);
113 
114 END setup_balance_table;
115 
116 -----------------------------------------------------------------------
117 -- GET_PARAMETERS
118 -----------------------------------------------------------------------
119  PROCEDURE get_parameters
120 (
121    p_payroll_action_id IN  NUMBER,
122    p_token_name        IN  VARCHAR2,
123    p_token_value       out nocopy VARCHAR2
124 )  IS
125 
126  CURSOR csr_parameter_info
127 (
128    p_pact_id NUMBER,
129    p_token   CHAR
130 )  IS
131 
132     SELECT TRIM(SUBSTR
133         (
134            legislative_parameters,
135            DECODE(INSTR
136            (
137               legislative_parameters,
138               p_token
139            ),0,LENGTH(legislative_parameters),INSTR
140            (
141               legislative_parameters,
142               p_token
143            )) + (LENGTH(p_token) + 1),
144 	DECODE(INSTR
145           (
146              legislative_parameters,
147              ' ',
148              INSTR
149              (
150                 legislative_parameters,
151                 p_token
152              )),0,LENGTH(legislative_parameters),INSTR
153           (
154              legislative_parameters,
155              ' ',
156              INSTR
157              (
158                 legislative_parameters,
159                 p_token
160              )))
161            -
162            (
163               INSTR
164               (
165                  legislative_parameters,
166                  p_token
167               )  + LENGTH(p_token)
168            )
169         )),
170 	TRIM(business_group_id)
171 	   FROM pay_payroll_actions
172 	   WHERE payroll_action_id = p_pact_id;
173 
174  l_business_group_id            VARCHAR2(300);
175  l_token_value                  VARCHAR2(300);
176  l_proc                         VARCHAR2(50) := g_package ||'get_parameters';
177 
178 /*6856473 */
179 
180 CURSOR csr_comments (
181    p_pact_id NUMBER,
182    p_token   CHAR
183 )  IS
184 SELECT TRIM(SUBSTR
185         (
186            legislative_parameters,
187            DECODE(
188            INSTR(
189               legislative_parameters,
190               p_token
191            )--INSTR
192            ,0,LENGTH(legislative_parameters),
193            INSTR
194            (
195               legislative_parameters,
196               p_token
197            )--INSTR 2 DEFAULT FOR DECODE
198            )--CLOSE DECODE
199             + (LENGTH(p_token) + 1),--END OF SECOND PARAMETER FOR SUBSTR
200             LENGTH(legislative_parameters)
201 	  )
202 	 )
203 
204 	FROM pay_payroll_actions
205 	WHERE payroll_action_id = p_pact_id;
206 
207 
208  BEGIN
209 
210    hr_utility.set_location('Entering ' || l_proc, 100);
211    hr_utility.set_location('p_token_name ' || TO_CHAR(p_token_name), 110);
212 
213    OPEN  csr_parameter_info
214          (
215             p_payroll_action_id,
216             p_token_name
217          );
218    FETCH csr_parameter_info INTO l_token_value, l_business_group_id;
219    CLOSE csr_parameter_info;
220 
221    hr_utility.set_location('l_token_value ' || TO_CHAR(l_token_value), 115);
222    hr_utility.set_location('l_business_group_id ' || TO_CHAR(l_business_group_id), 120);
223 
224    IF p_token_name = 'BG_ID' THEN
225       p_token_value := l_business_group_id;
226       hr_utility.set_location('p_token_name '||p_token_name,125);
227 /*6856473 */
228 
229    ELSIF p_token_name= 'COMMENTS' THEN
230       hr_utility.set_location('comments before replace ' || TO_CHAR(l_token_value), 120);
231      OPEN  csr_comments
232          (
233             p_payroll_action_id,
234             p_token_name
235          );
236    FETCH csr_comments INTO l_token_value;
237    CLOSE csr_comments;
238       hr_utility.set_location('comments after replace ' || TO_CHAR(l_token_value), 120);
239     p_token_value := l_token_value;
240    ELSE
241       p_token_value := l_token_value;
242 	--7367314
243       IF p_token_name= 'ADD_CHANGE' THEN
244 	   IF p_token_value = 'Y' THEN
245 	      p_token_value := '1' ;
246 	   ELSE
247 		p_token_value := '0' ;
248 	   END IF;
249 	END IF;
250 	--7367314
251 	  hr_utility.set_location('p_token_name '||p_token_name,130);
252    END IF;
253 
254    hr_utility.set_location('Leaving         ' || l_proc, 135);
255 --
256  EXCEPTION
257    WHEN others THEN
258    hr_utility.set_location('Leaving' || l_proc,140);
259    p_token_value := NULL;
260 --
261  END get_parameters;
262 -----------------------------------------------------------------------
263 -- GET_ALL_PARAMETERS
264 -----------------------------------------------------------------------
265  PROCEDURE get_all_parameters(p_payroll_action_id IN   NUMBER
266 					,p_rep_group OUT NOCOPY VARCHAR2
267 					,p_payroll_id OUT NOCOPY VARCHAR2
268 					,p_year OUT NOCOPY VARCHAR2
269 					,p_quarter OUT NOCOPY VARCHAR2
270 					,p_business_Group_id OUT NOCOPY VARCHAR2
271 					,p_assignment_set_id OUT NOCOPY VARCHAR2
272 					,p_occupational_category OUT NOCOPY VARCHAR2
273 					,p_employer_id OUT NOCOPY VARCHAR2
274 					,p_report_type OUT NOCOPY VARCHAR2
275 					,p_declare_date OUT NOCOPY VARCHAR2
276 					,p_change_add OUT NOCOPY VARCHAR2
277 					,p_comments OUT NOCOPY VARCHAR2
278 					)
279 IS
280 
281 CURSOR cur_nat_min_wg
282 IS
283 SELECT fnd_number.canonical_to_number(global_value)
284 FROM ff_globals_f
285 WHERE GLOBAL_NAME = 'IE_NAT_MIN_WAGE_RATE'
286 AND legislation_code = 'IE'
287 AND g_archive_effective_date BETWEEN effective_start_date AND effective_end_date;
288 
289 CURSOR cur_inc_exc_flag
290 IS
291 SELECT DISTINCT hasa.include_or_exclude inc_or_exc
292 FROM
293 	hr_assignment_set_amendments hasa,
294 	hr_assignment_sets has
295 WHERE hasa.assignment_set_id = has.assignment_set_id
296 AND	has.business_group_id  = p_business_Group_id
297 AND	has.assignment_set_id  = p_assignment_set_id;
298 
299 l_occupational_catg VARCHAR2(50);
300 l_cur_inc_exc_flag_rec cur_inc_exc_flag%rowtype;
301 
302  BEGIN
303     hr_utility.set_location(' Entering PAY_IE_EHECS_REPORT.get_all_parameters ', 200);
304 
305     get_parameters(p_payroll_action_id,'REP_GROUP',p_rep_group);
306     get_parameters(p_payroll_action_id,'PAYROLL',p_payroll_id);
307     get_parameters(p_payroll_action_id,'YEAR',p_year);
308     get_parameters(p_payroll_action_id,'QUARTER',p_quarter);
309     get_parameters(p_payroll_action_id,'BG_ID',p_business_Group_id);
310     get_parameters(p_payroll_action_id,'ASSIGNMENT_SET_ID',p_assignment_set_id);
311     get_parameters(p_payroll_action_id,'OCCUPATION',p_occupational_category);
312     get_parameters(p_payroll_action_id,'EMPLOYER',p_employer_id);
313     get_parameters(p_payroll_action_id,'REPTYPE',p_report_type);
314     get_parameters(p_payroll_action_id,'DDATE',p_declare_date);
315     get_parameters(p_payroll_action_id,'ADD_CHANGE',p_change_add);
316     get_parameters(p_payroll_action_id,'COMMENTS',p_comments);
317 
318 hr_utility.set_location(' After last get_parameters call ', 210);
319 
320 IF p_quarter = '1' THEN
321 	g_qtr_start_date := to_date('01/01/' || p_year,'DD/MM/RRRR');
322 	g_qtr_end_date := to_date('31/03/' || p_year,'DD/MM/RRRR');
323 ELSIF p_quarter = '2' THEN
324 	g_qtr_start_date := to_date('01/04/' || p_year,'DD/MM/RRRR');
325 	g_qtr_end_date := to_date('30/06/' || p_year,'DD/MM/RRRR');
326 ELSIF p_quarter = '3' THEN
327 	g_qtr_start_date := to_date('01/07/' || p_year,'DD/MM/RRRR');
328 	g_qtr_end_date := to_date('30/09/' || p_year,'DD/MM/RRRR');
329 ELSIF p_quarter = '4' THEN
330 	g_qtr_start_date := to_date('01/10/' || p_year,'DD/MM/RRRR');
331 	g_qtr_end_date := to_date('31/12/' || p_year,'DD/MM/RRRR');
332 END IF;
333 
334 hr_utility.set_location(' After populating the Quarter dates. ', 220);
335 
336 OPEN cur_nat_min_wg;
337 FETCH cur_nat_min_wg INTO g_ie_nat_min_wage_rate;
338 CLOSE cur_nat_min_wg;
339 
340 hr_utility.set_location(' After cur_nat_min_wg Cursor ', 230);
341 hr_utility.set_location(' g_ie_nat_min_wage_rate '||g_ie_nat_min_wage_rate, 230);
342 
343 OPEN cur_inc_exc_flag;
344 FETCH cur_inc_exc_flag INTO l_cur_inc_exc_flag_rec;
345 CLOSE cur_inc_exc_flag;
346 
347 g_exc_inc := l_cur_inc_exc_flag_rec.inc_or_exc;
348 
349 hr_utility.set_location(' After cur_inc_exc_flag Cursor ', 235);
350 hr_utility.set_location(' l_cur_inc_exc_flag_rec.inc_or_exc '||l_cur_inc_exc_flag_rec.inc_or_exc, 235);
351 hr_utility.set_location(' p_business_Group_id = '||p_business_Group_id,240);
352 hr_utility.set_location(' REP_GROUP = '||p_rep_group,240);
353 hr_utility.set_location(' PAYROLL = '||p_payroll_id,240);
354 hr_utility.set_location(' YEAR = '||p_year,240);
355 hr_utility.set_location(' QUARTER = '||p_quarter,240);
356 hr_utility.set_location(' ASSIGNMENT_SET_ID = '||p_assignment_set_id,240);
357 hr_utility.set_location(' OCCUPATION CATEGORY = '||p_occupational_category,240);
358 hr_utility.set_location(' EMPLOYER = '||p_employer_id,240);
359 hr_utility.set_location(' REPORT TYPE = '||p_report_type,240);
360 hr_utility.set_location(' DDATE = '||p_declare_date,240);
361 hr_utility.set_location(' ADD_CHANGE = '||p_change_add,240);
362 hr_utility.set_location(' COMMENTS = '||p_comments,240);
363 hr_utility.set_location(' g_qtr_start_date = '||g_qtr_start_date,240);
364 hr_utility.set_location(' g_qtr_end_date = '||g_qtr_end_date,240);
365 
366 IF p_occupational_category IS NOT NULL THEN
367 	--g_occupational_category_M_C_P :=
368 	/*NVL(hruserdt.get_table_value(p_business_Group_id,'EHECS_CATG_TAB','MPAP',substr(p_occupational_category,-2,length(p_occupational_category)),g_qtr_start_date),
369 	NVL(hruserdt.get_table_value(p_business_Group_id,'EHECS_CATG_TAB','CSSW',substr(p_occupational_category,-2,length(p_occupational_category)),g_qtr_start_date),
370 	hruserdt.get_table_value(p_business_Group_id,'EHECS_CATG_TAB','PTCO',substr(p_occupational_category,-2,length(p_occupational_category)),g_qtr_start_date)));*/
371 
372 	/*
373 	NVL(hruserdt.get_table_value(p_business_Group_id,'EHECS_CATG_TAB','Managers',p_occupational_category,g_qtr_start_date),
374 	NVL(hruserdt.get_table_value(p_business_Group_id,'EHECS_CATG_TAB','Clerical Workers',p_occupational_category,g_qtr_start_date),
375 	hruserdt.get_table_value(p_business_Group_id,'EHECS_CATG_TAB','Production Workers',p_occupational_category,g_qtr_start_date)));
376         */
377 
378         SELECT  NVL(hruserdt.get_table_value(p_business_Group_id,'EHECS_CATG_TAB','Managers',p_occupational_category,g_qtr_start_date),
379 	NVL(hruserdt.get_table_value(p_business_Group_id,'EHECS_CATG_TAB','Clerical Workers',p_occupational_category,g_qtr_start_date),
380 	hruserdt.get_table_value(p_business_Group_id,'EHECS_CATG_TAB','Production Workers',p_occupational_category,g_qtr_start_date))) ff
381 	into g_occupational_category_M_C_P
382         FROM dual;
383 
384 
385 END IF;
386 
387 hr_utility.set_location(' g_occupational_category_M_C_P = '||g_occupational_category_M_C_P,245);
388 
389 IF p_payroll_id IS NOT NULL THEN
390  g_where_clause :=
391  ' and papf.payroll_id = '||to_char(p_payroll_id);
392 ELSE
393     g_where_clause :='  and 1=1 ';
394 END IF;
395 
396 IF p_occupational_category IS NOT NULL THEN
397  g_where_clause1 :=
398  ' and paaf.employee_category = '||to_char(g_occupational_category);
399 
400 ELSE
401  g_where_clause1 :='  and 1=1 ';
402 END IF;
403 
404 IF p_assignment_set_id IS NOT NULL THEN
405  IF l_cur_inc_exc_flag_rec.inc_or_exc = 'I' THEN
406   g_where_clause_asg_set := ' AND EXISTS(SELECT 1
407 						    FROM  hr_assignment_set_amendments hasa
408 							 ,  hr_assignment_sets has
409 							 ,  per_assignments_f paf
410 					  WHERE has.assignment_set_id = hasa.assignment_set_id
411 					  AND   has.business_group_id = paaf.business_group_id
412 					  AND   has.assignment_set_id = '|| p_assignment_set_id
413 					  ||' AND   hasa.assignment_id    = paf.assignment_id
414 					  AND   paf.person_id         = ppf.person_id) ';
415  ELSIF l_cur_inc_exc_flag_rec.inc_or_exc = 'E' THEN
416   g_where_clause_asg_set  := ' AND NOT EXISTS(SELECT 1
417 						    FROM  hr_assignment_set_amendments hasa
418 							 ,  hr_assignment_sets has
419 							 ,  per_assignments_f paf
420 					  WHERE has.assignment_set_id = hasa.assignment_set_id
421 					  AND   has.business_group_id = paaf.business_group_id
422 					  AND   has.assignment_set_id = '|| p_assignment_set_id
423 					  ||' AND   hasa.assignment_id    = paf.assignment_id
424 					  AND   paf.person_id         = ppf.person_id) ';
425  ELSIF l_cur_inc_exc_flag_rec.inc_or_exc IS NULL THEN
426   g_where_clause_asg_set := ' and 1=2 ';
427  END IF;
428 ELSE
429   g_where_clause_asg_set := ' and 1=1 ';
430 END IF;
431 
432 
433  hr_utility.set_location(' Inside get_all_parameters:g_where_clause: '||g_where_clause,250);
434  hr_utility.set_location(' Inside get_all_parameters:g_where_clause1: '||g_where_clause1,260);
435  hr_utility.set_location(' Inside get_all_parameters:g_where_clause1: '||g_where_clause_asg_set,265);
436 
437  hr_utility.set_location(' Leaving: PAY_IE_EHECS_REPORT.get_all_parameters: ', 270);
438 
439 EXCEPTION
440   WHEN Others THEN
441     hr_utility.set_location(' Leaving: PAY_IE_EHECS_REPORT.get_all_parameters with errors: ', 280);
442     Hr_Utility.set_location('..'||'SQL-ERRM :'||SQLERRM,1215);
443 END get_all_parameters;
444 
445 -----------------------------------------------------------------------
446 -- RANGE_CODE
447 -----------------------------------------------------------------------
448  PROCEDURE range_code(pactid IN NUMBER,
449 		 sqlstr OUT nocopy VARCHAR2)
450  IS
451  l_procedure_name   VARCHAR2(100);
452 
453  l_year varchar2(50);
454  l_quarter varchar2(50);
455  l_assignment_set_id varchar2(50);
456  l_occupational_category varchar2(50);
457  l_report_type varchar2(50);
458 l_declare_date varchar2(50):=' ';
459 l_change_indicator varchar2(50):=' ';
460 l_comments varchar2(300);
461 
462  CURSOR  csr_archive_effective_date(pactid NUMBER) IS
463      SELECT effective_date
464      FROM   pay_payroll_actions
465      WHERE  payroll_action_id = pactid;
466 
467  CURSOR csr_employer_details(c_org_id  hr_organization_information.organization_id%type
468                             ,c_bg_id hr_organization_units.business_group_id%type) IS
469      select hou.organization_id org_id
470             ,hou.name employer_name
471             ,hla.address_line_1 addr1
472             ,hla.address_line_2 addr2
473             ,hla.address_line_3 addr3
474              from hr_organization_units hou
475                  ,hr_organization_information hoi
476                  ,hr_locations_all hla
477               where hoi.org_information_context='IE_EMPLOYER_INFO'
478               and hoi.organization_id=c_org_id
479               and hoi.organization_id=hou.organization_id
480               and hou.business_group_id= c_bg_id
481               and hou.location_id=hla.location_id(+);
482 
483 
484  CURSOR csr_declarant(c_org_id  hr_organization_information.organization_id%type
485                             ,c_bg_id hr_organization_units.business_group_id%type
486 				    ,p_year varchar2
487 				    ,p_qtr varchar2) IS
488  select hoi.org_information3 cbr_no
489        ,hoi.org_information13 person_id
490        ,hoi.org_information17 position  -- bug 6850742
491        ,hoi.org_information19 email     -- bug 6850742
492        ,hoi.org_information20 phone     -- bug 6850742
493      from hr_organization_units hou
494     ,hr_organization_information hoi
495   where hoi.org_information_context='IE_EHECS'
496   and hoi.organization_id=c_org_id
497   and hoi.organization_id=hou.organization_id
498   and hou.business_group_id= c_bg_id
499   and hoi.ORG_INFORMATION1 = p_year
500   and hoi.ORG_INFORMATION2 = p_qtr;
501 /*
502 CURSOR csr_declarant_details(c_person_id per_all_people_f.person_id%type) is
503 select papf.full_name declarant_name
504        ,pav.telephone_number_1 declarant_phone
505        ,papf.email_address declarant_email
506        ,pap.NAME declarant_position
507 from per_all_people_f papf
508      ,per_all_assignments_f paaf
509      ,per_all_positions pap
510      ,per_addresses_v pav
511 where    papf.person_id=c_person_id  ;
512       and paaf.person_id=papf.person_id
513       and pav.person_id=papf.person_id
514      and pap.position_id=paaf.position_id
515 	and g_archive_effective_date between paaf.effective_start_date and paaf.effective_end_date
516 	and g_archive_effective_date between papf.effective_start_date and papf.effective_end_date;
517 */
518 /* bug 6850742  */
519 CURSOR csr_declarant_details(c_person_id per_all_people_f.person_id%type) is
520 select papf.full_name declarant_name
521 from per_all_people_f papf
522 where    papf.person_id=c_person_id  ;
523 
524 
525  l_employer_details csr_employer_details%rowtype;
526  l_declarant csr_declarant%rowtype;
527  l_declarant_details csr_declarant_details%rowtype;
528  l_action_info_id NUMBER;
529  l_ovn NUMBER;
530  l_org_id         hr_organization_units.organization_id%type;
531  l_employer_name  hr_organization_units.name%type;
532 
533  l_addr1        hr_locations_all.address_line_1%type;
534  l_addr2        hr_locations_all.address_line_2%type;
535  l_addr3        hr_locations_all.address_line_3%type;
536  l_addr4        hr_locations_all.address_line_3%type;
537  l_addr5        hr_locations_all.address_line_3%type;
538  l_cbr_no       hr_organization_information.org_information3%type;
539  l_person_id    hr_organization_information.org_information13%type;
540  l_declarant_name per_all_people_f.full_name%type;
541  l_declarant_phone        per_all_people_f.office_number%type ;
542  l_declarant_email_add    per_all_people_f.email_address%type;
543  l_declarant_position     per_all_positions.name%type;
544 
545 
546  BEGIN
547 
548  l_procedure_name := g_package||'range_code';
549 
550  hr_utility.set_location('Entering '||l_procedure_name, 300);
551  hr_utility.set_location('pactid '||TO_CHAR(pactid), 300);
552 
553  sqlstr := ' select distinct p.person_id'                                       ||
554              ' from   per_people_f p,'                                        ||
555                     ' pay_payroll_actions pa'                                     ||
556              ' where  pa.payroll_action_id = :payroll_action_id'                  ||
557              ' and    p.business_group_id = pa.business_group_id'                 ||
558              ' order by p.person_id';
559 
560 -------------
561 
562    OPEN csr_archive_effective_date(pactid);
563    FETCH csr_archive_effective_date
564    INTO  g_archive_effective_date;
565    CLOSE csr_archive_effective_date;
566 
567  hr_utility.set_location('After fetching the g_archive_effective_date '||g_archive_effective_date, 310);
568 
569    get_all_parameters(pactid
570 			,g_rep_group
571 			,g_payroll_id
572 			,l_year
573 			,l_quarter
574 			,g_business_group_id
575 			,l_assignment_set_id
576 			,l_occupational_category
577 			,g_employer_id
578 			,l_report_type
579 			,l_declare_date
580 			,l_change_indicator
581 			,l_comments);
582 
583 g_year := l_year;
584 g_quarter := l_quarter;
585 g_occupational_category := l_occupational_category;
586 g_assignment_set_id := l_assignment_set_id;
587 
588  hr_utility.set_location('After fetching the g_archive_effective_date '||g_archive_effective_date, 310);
589 
590   setup_balance_table;
591 
592  hr_utility.set_location('After the call of setup_balance_table in '||l_procedure_name, 320);
593 
594   OPEN csr_employer_details(g_employer_id, g_business_group_id);
595   FETCH csr_employer_details INTO l_employer_details;
596   CLOSE csr_employer_details;
597 
598  hr_utility.set_location('After fetching the csr_employer_details ', 330);
599 
600   l_org_id :=		l_employer_details.org_id;
601   l_employer_name :=	l_employer_details.employer_name;
602   l_addr1 :=		l_employer_details.addr1;
603   l_addr2 :=		l_employer_details.addr2;
604   l_addr3 :=		l_employer_details.addr3;
605   l_addr4 := ' ';
606   l_addr5 := ' ';
607 
608 hr_utility.set_location('After fetching the csr_employer_details l_org_id'||l_org_id, 330);
609 hr_utility.set_location('After fetching the csr_employer_details l_employer_name'||l_employer_name, 330);
610 hr_utility.set_location('After fetching the csr_employer_details l_addr1'||l_addr1, 330);
611 hr_utility.set_location('After fetching the csr_employer_details l_addr2'||l_addr2, 330);
612 hr_utility.set_location('After fetching the csr_employer_details l_addr3'||l_addr3, 330);
613 
614   OPEN csr_declarant(g_employer_id, g_business_group_id, l_year, l_quarter);
615   FETCH csr_declarant INTO l_declarant;
616   CLOSE csr_declarant;
617   l_cbr_no := l_declarant.cbr_no;
618   l_person_id :=	l_declarant.person_id;
619   l_declarant_position	:= l_declarant.position; -- bug 6850742
620   l_declarant_phone	:= l_declarant.phone;    -- bug 6850742
621   l_declarant_email_add := l_declarant.email;    -- bug 6850742
622 
623 hr_utility.set_location('After fetching the csr_declarant ', 340);
624 hr_utility.set_location('After fetching the l_cbr_no '||l_cbr_no, 340);
625 hr_utility.set_location('After fetching the l_person_id '||l_person_id, 340);
626 hr_utility.set_location('l_declarant_position '||l_declarant_position, 340);
627 hr_utility.set_location('l_declarant_phone '||l_declarant_phone, 340);
628 hr_utility.set_location('l_declarant_email_add '||l_declarant_email_add, 340);
629 
630   OPEN csr_declarant_details(l_person_id);
631   FETCH csr_declarant_details into l_declarant_details;
632   CLOSE	csr_declarant_details;
633 
634  hr_utility.set_location('After fetching the csr_declarant_details ', 350);
635 
636   l_declarant_name	:= l_declarant_details.declarant_name;
637   /* bug 6850742*/
638 --  l_declarant_phone	:= l_declarant_details.declarant_phone;
639   --l_declarant_email_add := l_declarant_details.declarant_email;
640 --  l_declarant_position	:= l_declarant_details.declarant_position;
641 
642 hr_utility.set_location('l_declarant_name '||l_declarant_name, 350);
643 --hr_utility.set_location('l_declarant_phone '||l_declarant_phone, 350);
644 --hr_utility.set_location('l_declarant_email_add '||l_declarant_email_add, 350);
645 --hr_utility.set_location('l_declarant_position '||l_declarant_position, 350);
646 
647 IF l_employer_name IS NULL THEN
648 	l_errflag := 'Y';
649      --Fnd_file.put_line(FND_FILE.LOG,'Employer name is missing. Please enter it first.' );
650      Fnd_file.put_line(FND_FILE.LOG,'You have not entered the employer name. Enter a valid employer name.' );
651 END IF;
652 IF l_addr1 IS NULL OR l_addr2 IS NULL THEN
653 	l_errflag := 'Y';
654      --Fnd_file.put_line(FND_FILE.LOG,'Employer Address line 1/2 is missing. Please enter it first.' );
655 	Fnd_file.put_line(FND_FILE.LOG,'You have not entered a complete address for the employer. Enter a valid address.' );
656 END IF;
657 IF l_cbr_no IS NULL THEN
658 	l_errflag := 'Y';
659      --Fnd_file.put_line(FND_FILE.LOG,'CBR Number is missing. Please enter it first.' );
660      Fnd_file.put_line(FND_FILE.LOG,'You have not entered the CBR Number. Enter a valid CBR Number.' );
661 END IF;
662 IF l_declarant_name IS NULL OR l_declarant_phone IS NULL OR
663 	l_declarant_email_add IS NULL OR l_declarant_position IS NULL THEN
664 	l_errflag := 'Y';
665       --Fnd_file.put_line(FND_FILE.LOG,'Declarant details are missing. Please check for Name, Phone, Email, Position.' );
666 	Fnd_file.put_line(FND_FILE.LOG,'You have not entered the declaration contact details. Enter the Name, Phone, Email and Position of the declaration contact.' );
667 END IF;
668 
669 hr_utility.set_location('l_errflag '||l_errflag, 370);
670 
671 IF l_errflag = 'Y' THEN
672   Fnd_file.put_line(FND_FILE.LOG,'Some mandatory data is misssing.' );
673   Raise l_ehecs_exception;
674 END IF;
675 
676 hr_utility.set_location('Before entering record for IE_EHECS_HEADER ', 380);
677 
678     pay_action_information_api.create_action_information
679     ( p_action_information_id => l_action_info_id
680     ,p_action_context_id => pactid
681     ,p_action_context_type => 'PA'
682     ,p_object_version_number => l_ovn
683     ,p_effective_date => g_archive_effective_date --g_end_date
684     ,p_source_id => NULL
685     ,p_source_text => NULL
686     ,p_action_information_category => 'IE_EHECS_HEADER'
687     ,p_action_information6  => l_year
688     ,p_action_information7  => l_quarter
689     ,p_action_information8  => l_report_type
690     ,p_action_information9  => 'Oracle HRMS'			--SOFTWARE NAME (HARD CODED)
691     ,p_action_information10 => '1.0'				--SOFTWARE VERSION(HARD CODED)
692     ,p_action_information11 => 'Oracle Corporation'		--VENDOR NAME
693     ,p_action_information12 => '870.4000.900'		--VENDOR PHONE
694     ,p_action_information13 => l_org_id
695     ,p_action_information14 => l_employer_name
696     ,p_action_information15 => l_addr1
697     ,p_action_information16 => l_addr2
698     ,p_action_information17 => l_addr3
699     ,p_action_information18 => l_addr4
700     ,p_action_information19 => l_addr5
701     ,p_action_information20 => l_change_indicator --parameter
702     ,p_action_information21 => l_cbr_no
703     ,p_action_information22 => l_declarant_name
704     ,p_action_information23 => l_declarant_phone
705     ,p_action_information24 => l_declarant_email_add
706     ,p_action_information25 => l_declare_date
707     ,p_action_information26 => l_declarant_position
708     );
709 
710 hr_utility.set_location('After entering record for IE_EHECS_HEADER ', 390);
711 
712 hr_utility.set_location('Leaving '||l_procedure_name, 400);
713 
714  EXCEPTION
715  WHEN l_ehecs_exception THEN
716     Hr_Utility.set_location('..'||'SQL-ERRM :'||SQLERRM,410);
717     error_message := FND_CONCURRENT.SET_COMPLETION_STATUS('ERROR','EHECS Report errors out. Some mandatory values are missing.');
718  WHEN Others THEN
719     Hr_Utility.set_location('..'||'SQL-ERRM :'||SQLERRM,410);
720  END range_code;
721  -----------------------------------------------------------------------
722 -- ASSIGNMENT_ACTION_CODE
723 -----------------------------------------------------------------------
724 
725 PROCEDURE assignment_action_code(pactid in number,
726 					   stperson in number,
727 					   endperson in number,
728 					   chunk in number)
729 IS
730     l_assg_id per_assignments_f.assignment_id%TYPE;
731     l_person_id Number;
732     l_assignment_number per_all_assignments_f.assignment_number%type;
733     l_period_of_service_id per_all_assignments_f.period_of_service_id%type;
734 
735     l_prev_person_id Number := 0;
736     l_prev_period_of_service_id per_all_assignments_f.period_of_service_id%type := 0;
737 
738     l_start_date VARCHAR2(50);
739     l_end_date VARCHAR2(50);
740     l_select_str VARCHAR2(3000);
741     lockingactid NUMBER;
742     l_valid_assg boolean := False;
743     l_file_type pay_element_entry_values_f.screen_entry_value%TYPE;
744     l_submitted pay_element_entry_values_f.screen_entry_value%TYPE;
745     l_element_name varchar2(50);
746 
747     TYPE asg_ref IS REF CURSOR;
748     csr_get_asg asg_ref;
749 
750  l_ass_check  varchar2(1);
751  l_csr_already_archived pay_element_entry_values_f.screen_entry_value%TYPE := 'N';
752  BEGIN
753 
754  hr_utility.set_location('Entering PAY_IE_EHECS_REPORT_PKG.assignment_action_code',500);
755 
756 -- Get all the parameters
757 /*6978389 */
758 hr_utility.set_location('Before get_all_parameters',501);
759 get_all_parameters(pactid
760 			,g_rep_group
761 			,g_payroll_id
762 			,g_year
763 			,g_quarter
764 			,g_business_group_id
765 			,g_assignment_set_id
766 			,g_occupational_category
767 			,g_employer_id
768 			,g_report_type
769 			,g_declare_date
770 			,g_change_indicator
771 			,g_comments);
772 hr_utility.set_location('after get_all_parameters',502);
773 hr_utility.set_location(' g_qtr_start_date = '||g_qtr_start_date,505);
774 hr_utility.set_location(' g_qtr_end_date = '||g_qtr_end_date,505);
775 hr_utility.set_location(' g_business_group_id = '||g_business_group_id,505);
776 hr_utility.set_location(' g_employer_id = '||g_employer_id,505);
777 
778  --g_start_date := fnd_date.canonical_to_date(l_start_date);
779  --g_end_date := fnd_date.canonical_to_date(l_end_date);
780 
781 -- g_pact_id := pactid;
782 
783  --hr_utility.set_location('after get_all_parameter called',225);
784  --hr_utility.set_location('report start date= '||g_start_date,300);
785 
786 hr_utility.set_location('Before building the dynamic query.',510);
787 /* 6856486   modified the employment_category 's IN condition to a value fetch from USER TABLE EHECS_ASG_CATG_TAB */
788 l_select_str :='select distinct paaf.assignment_id asgid
789 from                        per_all_assignments_f paaf,
790                             per_all_people_f ppf,
791                             pay_all_payrolls_f papf,
792                             pay_payroll_actions ppa,
793    				    hr_soft_coding_keyflex scl
794 where                       paaf.business_group_id = '|| g_business_group_id
795                             ||' and papf.business_group_id = paaf.business_group_id '
796 				    ||' and paaf.effective_start_date <= '||''''||g_qtr_end_date||''''
797 				    ||' and paaf.effective_end_date >= '||''''||g_qtr_start_date||''''
798 				    ||' and paaf.person_id = ppf.person_id '
799 				    ||' and paaf.employment_category = '
800 			--	    ||' IN ('||'''FT'''||','||'''FR'''||','||'''PT'''||','||'''PR'''||','||'''AT'''||') '
801                             ||'nvl(hruserdt.get_table_value(paaf.business_group_id,'||''''||'EHECS_ASG_CATG_TAB'||''''||','||''''||'Full_Time'||''''||',paaf.EMPLOYMENT_CATEGORY,'||''''||g_qtr_start_date||''''||')'
802 			    ||      ',nvl(hruserdt.get_table_value(paaf.business_group_id,'||''''||'EHECS_ASG_CATG_TAB'||''''||','||''''||'Part_Time'||''''||',paaf.EMPLOYMENT_CATEGORY,'||''''||g_qtr_start_date||''''||')'
803 			    ||	    ',  hruserdt.get_table_value(paaf.business_group_id,'||''''||'EHECS_ASG_CATG_TAB'||''''||','||''''||'Apprentice_Trainee'||''''||',paaf.EMPLOYMENT_CATEGORY,'||''''||g_qtr_start_date||''''||')'
804 			    ||	' ))'
805 
806 			    ||' and ppf.person_id between '|| stperson || ' and ' || endperson
807 				    ||g_where_clause1
808 				    ||' and ppa.payroll_action_id = '||pactid
809                             ||' and papf.payroll_id = paaf.payroll_id '
810                             ||' and papf.soft_coding_keyflex_id = scl.soft_coding_keyflex_id '
811 				    ||' and scl.segment4 = to_char('||g_employer_id||') '
812 				    ||g_where_clause
813 				    ||g_where_clause_asg_set
814           		          ||' Order by paaf.assignment_id';
815 
816 hr_utility.set_location('After building the dynamic query.',520);
817 
818 /*6978389 */
819 Fnd_file.put_line(FND_FILE.LOG,'Dynamic Query:'||l_select_str );
820 
821 OPEN csr_get_asg FOR l_select_str; -- ref cursor
822  LOOP
823 	hr_utility.set_location(' Inside ass action code, inside loop for ref cursor',530);
824 	FETCH csr_get_asg INTO l_assg_id;
825 	EXIT WHEN csr_get_asg%NOTFOUND;
826 		SELECT pay_assignment_actions_s.nextval
827 		INTO lockingactid
828 		FROM dual;
829 
830 	hr_utility.set_location('assignment_action_code, the assignment id finally picked up: '||l_assg_id, 540);
831 		-- Insert assignment into PAY_ASSIGNMENT_ACTIONS TABLE
832 		/*	hr_nonrun_asact.insact(lockingactid => lockingactid
833 					,assignid     => l_assg_id
834 					,pactid       => pactid
835 					,chunk        => chunk
836 					,greid        => NULL);
837 		*/
838 
839 		-- Insert assignment into PAY_TEMP_OBJECT_ACTION TABLE.
840 	hr_utility.set_location(' Before hr_nonrun_asact.insact call',550);
841 		hr_nonrun_asact.insact(lockingactid => lockingactid
842 				,assignid     =>    l_assg_id       --asgrec.assignment_id        --
843 				,object_id    =>    l_assg_id       --asgrec.assignment_id        --
844 				,pactid       => pactid
845 				,chunk        => chunk
846 				,greid        => NULL);
847 				--,p_transient_action => TRUE);
848 	hr_utility.set_location(' After hr_nonrun_asact.insact call',560);
849 
850  END LOOP;-- ref cursor
851 
852  END assignment_action_code;
853  -----------------------------------------------------------------------
854 -- ARCHIVE_INIT
855 -----------------------------------------------------------------------
856 
857  PROCEDURE archive_init(p_payroll_action_id IN NUMBER)
858  IS
859  l_start_date VARCHAR2(50);
860  l_end_date VARCHAR2(50);
861 
862 
863  CURSOR  csr_archive_effective_date(pactid NUMBER) IS
864      SELECT effective_date
865      FROM   pay_payroll_actions
866      WHERE  payroll_action_id = pactid;
867 
868   BEGIN
869 
870    hr_utility.set_location('Entering: PAY_IE_EHECS_REPORT_PKG.archive_init: ',600);
871 
872    OPEN csr_archive_effective_date(p_payroll_action_id);
873    FETCH csr_archive_effective_date
874    INTO  g_archive_effective_date;
875    CLOSE csr_archive_effective_date;
876 
877    hr_utility.set_location('Before calling get_all_parameters ',610);
878 
879  get_all_parameters(p_payroll_action_id
880 			,g_rep_group
881 			,g_payroll_id
882 			,g_year
883 			,g_quarter
884 			,g_business_group_id
885 			,g_assignment_set_id
886 			,g_occupational_category
887 			,g_employer_id
888 			,g_report_type
889 			,g_declare_date
890 			,g_change_indicator
891 			,g_comments);
892 
893    hr_utility.set_location('After calling get_all_parameters ',620);
894 
895 setup_balance_table;
896 
897    hr_utility.set_location('After calling setup_balance_table ',630);
898 
899     hr_utility.set_location(' Leaving PAY_IE_EHECS_REPORT_PKG.archive_init', 640);
900 
901 EXCEPTION
902 WHEN Others THEN
903 hr_utility.set_location(' Leaving PAY_IE_EHECS_REPORT_PKG.archive_init with errors', 650);
904 Hr_Utility.set_location('..'||'SQL-ERRM :'||SQLERRM,1211);
905 
906 END archive_init;
907  -----------------------------------------------------------------------
908 -- ARCHIVE_DATA
909 -----------------------------------------------------------------------
910  PROCEDURE archive_data(p_assactid in number,
911                         p_effective_date in date)
912  IS
913 
914  BEGIN
915 
916   hr_utility.set_location(' Entering PAY_IE_EHECS_REPORT_PKG.ARCHIVE_CODE: ',700);
917   hr_utility.set_location('g_pact_id '||TO_CHAR(g_pact_id),700);
918   hr_utility.set_location('p_assignment_action_id '||TO_CHAR(p_assactid),700);
919 
920 NUll;
921 
922   hr_utility.set_location(' Leaving PAY_IE_EHECS_REPORT_PKG.ARCHIVE_CODE: ',700);
923 
924 END archive_data;
925 
926 PROCEDURE ehecs_main_proc(p_business_group_id IN VARCHAR2
927 				  ,p_payroll_action_id IN NUMBER
928 				  ,p_assignment_id IN NUMBER
929 				  ,p_person_id IN NUMBER)
930 IS
931 
932 CURSOR cur_valid_asg(c_assignment_id NUMBER, c_person_id NUMBER)
933 IS
934 SELECT distinct paaf.assignment_id, paaf.person_id, paaf.payroll_id,
935 	--decode(paaf.EMPLOYMENT_CATEGORY,'FT','F','FR','F','PR','P','PT','P',paaf.EMPLOYMENT_CATEGORY) EMP_CATG,
936    /* 6856486 */
937         decode(paaf.EMPLOYMENT_CATEGORY
938 	,hruserdt.get_table_value(paaf.business_group_id,'EHECS_ASG_CATG_TAB','Full_Time',paaf.EMPLOYMENT_CATEGORY,g_qtr_start_date),'F'
939 	,hruserdt.get_table_value(paaf.business_group_id,'EHECS_ASG_CATG_TAB','Part_Time',paaf.EMPLOYMENT_CATEGORY,g_qtr_start_date),'P'
940 	,hruserdt.get_table_value(paaf.business_group_id,'EHECS_ASG_CATG_TAB','Apprentice_Trainee',paaf.EMPLOYMENT_CATEGORY,g_qtr_start_date),'AT'
941 	) EMP_CATG,
942 
943 	/*
944 	NVL(hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','Managers',substr(paaf.EMPLOYEE_CATEGORY,-2,length(paaf.EMPLOYEE_CATEGORY)),paaf.effective_start_date),
945 	NVL(hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','CSSW',substr(paaf.EMPLOYEE_CATEGORY,-2,length(paaf.EMPLOYEE_CATEGORY)),paaf.effective_start_date),
946 	  hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','Production Workers',substr(paaf.EMPLOYEE_CATEGORY,-2,length(paaf.EMPLOYEE_CATEGORY)),paaf.effective_start_date)
947 	  )
948 	) EHECS_CATG*/
949 	NVL(hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','Managers',paaf.EMPLOYEE_CATEGORY,g_qtr_start_date),
950 	NVL(hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','Clerical Workers',paaf.EMPLOYEE_CATEGORY,g_qtr_start_date),
951 	  hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','Production Workers',paaf.EMPLOYEE_CATEGORY,g_qtr_start_date)
952 	  )
953 	) EHECS_CATG
954 	, paaf.effective_start_date
955 	,normal_hours normal_hours                /*6856473*/
956 	,frequency frequency                      /*6856473*/
957 	,hourly_salaried_code hourly_or_salaried  /*6856473*/
958 FROM
959 per_all_assignments_f paaf
960 WHERE paaf.assignment_id = c_assignment_id
961 and paaf.person_id = c_person_id
962 and paaf.effective_start_date <= g_qtr_end_date
963 and paaf.effective_end_date >= g_qtr_start_date
964 and assignment_status_type_id in (SELECT assignment_status_type_id
965                            FROM per_assignment_status_types
966                           WHERE per_system_status = 'ACTIVE_ASSIGN'
967                             AND active_flag       = 'Y')/*6856473 to filter the terminated assingment*/
968 ORDER BY paaf.effective_start_date desc;
969 
970 l_valid_asg_rec cur_valid_asg%ROWTYPE;
971 
972 CURSOR cur_valid_asg_act(p_asg_id NUMBER, p_payroll_id NUMBER)
973 IS
974 SELECT /*+ USE_NL(paa, ppa) */
975 	 max(paa.assignment_action_id) assignment_action_id
976 FROM   pay_assignment_actions paa,
977 	 pay_payroll_actions    ppa
978 WHERE  paa.assignment_id  = p_asg_id
979 AND    ppa.payroll_action_id = paa.payroll_action_id
980 AND    (paa.source_action_id is not null or ppa.action_type in ('I','V','B'))
981 AND    ppa.effective_date between g_qtr_start_date and g_qtr_end_date
982 --bug 7294966
983 /*					   (  select max(pay_advice_date)
984 						from per_time_periods
985 						where payroll_id = p_payroll_id
986 						and pay_advice_date <= g_qtr_end_date
987 					   )
988 */
989 --bug 7294966
990 AND    ppa.action_type in ('R', 'Q', 'I', 'V','B')
991 AND    paa.action_status = 'C'
992 HAVING max(paa.assignment_action_id) IS NOT NULL;
993 
994 l_valid_asg_act_rec cur_valid_asg_act%ROWTYPE;
995 
996 /*6856473 added the cursor and the variables */
997 CURSOR csr_hours_per_day(c_org_id  hr_organization_information.organization_id%type
998                             ,c_bg_id hr_organization_units.business_group_id%type
999 			 ) IS
1000  select hoi.org_information18 hrs_per_day
1001      from hr_organization_units hou
1002     ,hr_organization_information hoi
1003   where hoi.org_information_context='IE_EHECS'
1004   and hoi.organization_id=c_org_id
1005   and hoi.organization_id=hou.organization_id
1006   and hou.business_group_id= c_bg_id;
1007 --l_hours_per_day csr_hours_per_day%rowtype;
1008 l_hours_per_day varchar2(10);
1009 l_org_id hr_organization_units.organization_id%type;
1010 l_normal_hours per_all_assignments_f.normal_hours%type;
1011 l_frequency    per_all_assignments_f.frequency%type;
1012 
1013 --------------------------- Variables which will hold the Balance Values.
1014 l_regwg_bal_val	Number := 0;
1015 l_irrb_bal_val	Number := 0;
1016 l_ovrt_bal_val	Number := 0;
1017 l_othr_bal_val	Number := 0;
1018 l_chrs_bal_val    number := 0;
1019 l_mat_bal_val	Number := 0;
1020 l_sic_bal_val	Number := 0;
1021 l_otl_bal_val	Number := 0;
1022 l_incct_bal_val	Number := 0;
1023 l_red_bal_val	Number := 0;
1024 l_otsoc_bal_val	Number := 0;
1025 l_tr_sub_bal_val  Number := 0;
1026 l_refund_bal_val  Number := 0;
1027 l_vhi_bal_val	Number := 0;
1028 l_hse_bal_val	Number := 0;
1029 l_otben_bal_val	Number := 0;
1030 l_ot_sub_bal_val  Number := 0;
1031 l_nmw_bal_val	Number := 0;
1032 l_stks_bal_val	Number := 0;
1033 l_rbs_er_bal_val	Number := 0;
1034 l_prsa_er_bal_val Number := 0;
1035 l_rac_er_bal_val	Number := 0;
1036 l_prsi_bal_val	Number := 0;
1037 l_bik_veh_bal_val Number := 0;
1038 
1039 l_pen_bal_val_tot Number := 0;
1040 l_lap_bal_val_tot Number := 0;
1041 l_app_wg_bal_val_tot Number := 0;
1042 l_ssec_bal_val_tot Number := 0;
1043 
1044 l_nmw_count Number := 0;
1045 
1046 /* 6856473 */
1047 l_al_bal_val number:=0;
1048 --------------------------- Variables which will hold the Balance Values.
1049 
1050 BEGIN
1051     hr_utility.set_location(' Entering PAY_IE_EHECS_REPORT_PKG.ehecs_main_proc', 800);
1052 
1053 /*6856473*/
1054 hr_utility.set_location(' before calling get parameters ', 800);
1055 
1056 get_parameters(p_payroll_action_id,'EMPLOYER',l_org_id);
1057 hr_utility.set_location(' before  cursor csr_hours_per_day and org_id '||l_org_id, 801);
1058 OPEN csr_hours_per_day(l_org_id,p_business_group_id);
1059 FETCH csr_hours_per_day INTO l_hours_per_day;
1060 CLOSE csr_hours_per_day;
1061 
1062 hr_utility.set_location(' AFTER  cursor csr_hours_per_day  '||l_hours_per_day, 801);
1063 
1064 hr_utility.set_location(' Before Cursor cur_valid_asg', 810);
1065 
1066 OPEN cur_valid_asg(p_assignment_id, p_person_id);
1067 FETCH cur_valid_asg INTO l_valid_asg_rec;
1068 --EXIT WHEN cur_valid_asg%NOTFOUND;
1069     hr_utility.set_location(' Inside Cursor cur_valid_asg', 820);
1070     hr_utility.set_location(' l_valid_asg_rec.assignment_id '||l_valid_asg_rec.assignment_id, 820);
1071     hr_utility.set_location(' l_valid_asg_rec.payroll_id '||l_valid_asg_rec.payroll_id, 820);
1072 
1073     hr_utility.set_location(' Before Cursor cur_valid_asg_act', 830);
1074 
1075   OPEN cur_valid_asg_act(l_valid_asg_rec.assignment_id, l_valid_asg_rec.payroll_id);
1076   FETCH cur_valid_asg_act INTO l_valid_asg_act_rec;
1077 
1078   hr_utility.set_location(' Inside Cursor cur_valid_asg_act', 840);
1079 
1080   IF cur_valid_asg_act%FOUND THEN
1081      --IF l_valid_asg_act_rec.assignment_action_id IS NOT NULL
1082      --THEN
1083 		FOR bal_index IN 1..g_def_bal_id.COUNT
1084 		LOOP
1085 			IF g_def_bal_id(bal_index).balance_name   = 'Regular Earnings' THEN
1086 
1087 hr_utility.set_location(' Inside balance Loop ', 850);
1088 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1089 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1090 
1091 				l_regwg_bal_val := PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1092 							l_valid_asg_act_rec.assignment_action_id,
1093 							g_employer_id,
1094 							null,
1095 							null,
1096 							null,
1097 							null,
1098 							null);
1099 hr_utility.set_location(' l_regwg_bal_val '|| l_regwg_bal_val, 850);
1100 			ELSIF g_def_bal_id(bal_index).balance_name   = 'Irregular Earnings' THEN
1101 
1102 hr_utility.set_location(' Inside balance Loop ', 850);
1103 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1104 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1105 
1106 				l_irrb_bal_val := PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1107 							l_valid_asg_act_rec.assignment_action_id,
1108 							g_employer_id,
1109 							null,
1110 							null,
1111 							null,
1112 							null,
1113 							null);
1114 hr_utility.set_location(' l_irrb_bal_val '|| l_irrb_bal_val, 850);
1115 			ELSIF g_def_bal_id(bal_index).balance_name   = 'Overtime Payments' THEN
1116 
1117 hr_utility.set_location(' Inside balance Loop ', 850);
1118 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1119 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1120 
1121 				l_ovrt_bal_val := PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1122 							l_valid_asg_act_rec.assignment_action_id,
1123 							g_employer_id,
1124 							null,
1125 							null,
1126 							null,
1127 							null,
1128 							null);
1129 hr_utility.set_location(' l_ovrt_bal_val '|| l_ovrt_bal_val, 850);
1130 			ELSIF g_def_bal_id(bal_index).balance_name   = 'Paid Overtime Hours' THEN
1131 
1132 hr_utility.set_location(' Inside balance Loop ', 850);
1133 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1134 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1135 
1136 				l_othr_bal_val := PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1137 							l_valid_asg_act_rec.assignment_action_id,
1138 							g_employer_id,
1139 							null,
1140 							null,
1141 							null,
1142 							null,
1143 							null);
1144 hr_utility.set_location(' l_othr_bal_val '|| l_othr_bal_val, 850);
1145 			ELSIF g_def_bal_id(bal_index).balance_name   = 'Normal Working Hours' THEN
1146 
1147 hr_utility.set_location(' Inside balance Loop ', 850);
1148 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1149 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1150 
1151 
1152 
1153 /*6856473 added if conditions to check for salaried code*/
1154 
1155 hr_utility.set_location(' l_valid_asg_rec.normal_hours '||l_valid_asg_rec.normal_hours, 850);
1156 hr_utility.set_location(' l_valid_asg_rec.frequency '||l_valid_asg_rec.frequency, 850);
1157 hr_utility.set_location(' l_valid_asg_rec.hourly_or_salaried '||l_valid_asg_rec.hourly_or_salaried, 850);
1158 
1159 	IF(l_valid_asg_rec.hourly_or_salaried='S')
1160 	THEN
1161 
1162 		        IF(l_valid_asg_rec.frequency='D')
1163 			THEN
1164 			     l_chrs_bal_val:=nvl(l_valid_asg_rec.normal_hours,0)*91;
1165 			ELSIF(l_valid_asg_rec.frequency='M')
1166 			THEN
1167 			     l_chrs_bal_val:=nvl(l_valid_asg_rec.normal_hours,0)*3;
1168 
1169 			ELSIF(l_valid_asg_rec.frequency='W')
1170 			THEN
1171 			     l_chrs_bal_val:=nvl(l_valid_asg_rec.normal_hours,0)*13;
1172 			ELSIF(l_valid_asg_rec.frequency='Y')
1173 			THEN
1174 			     l_chrs_bal_val:=(nvl(l_valid_asg_rec.normal_hours,0))/4;
1175                         END IF;
1176 	      /* ELSE
1177 	       l_errflag := 'Y';
1178                Fnd_file.put_line(FND_FILE.LOG,'Ensure that Normal hours value is not null at the assignment level of person'||p_person_id );
1179 	       Raise l_ehecs_exception;
1180 	       END IF;
1181 	       */
1182 	ELSE
1183 				l_chrs_bal_val := PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1184 							l_valid_asg_act_rec.assignment_action_id,
1185 							g_employer_id,
1186 							null,
1187 							null,
1188 							null,
1189 							null,
1190 							null);
1191        END IF;
1192 hr_utility.set_location(' l_chrs_bal_val '|| l_chrs_bal_val, 850);
1193 --Bug # 6774024
1194 			ELSIF (g_def_bal_id(bal_index).balance_name   = 'Paid Maternity Hours') THEN
1195 
1196 hr_utility.set_location(' Inside balance Loop ', 850);
1197 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1198 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1199 
1200 				l_mat_bal_val := nvl(l_mat_bal_val,0)
1201 				+
1202 				PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1203 							l_valid_asg_act_rec.assignment_action_id,
1204 							g_employer_id,
1205 							null,
1206 							null,
1207 							null,
1208 							null,
1209 							null);/*6856473*/
1210 
1211 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1212 
1213 hr_utility.set_location(' l_mat_bal_val '|| l_mat_bal_val, 850);
1214 			ELSIF (g_def_bal_id(bal_index).balance_name   = 'Paid Sick Leave Hours' ) THEN
1215 
1216 hr_utility.set_location(' Inside balance Loop ', 850);
1217 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1218 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1219 
1220 				l_sic_bal_val :=
1221 				nvl(l_sic_bal_val,0)
1222 				+
1223 				PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1224 							l_valid_asg_act_rec.assignment_action_id,
1225 							g_employer_id,
1226 							null,
1227 							null,
1228 							null,
1229 							null,
1230 							null);/*6856473*/
1231 
1232 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1233 hr_utility.set_location(' l_sic_bal_val '|| l_sic_bal_val, 850);
1234 			ELSIF (g_def_bal_id(bal_index).balance_name   = 'Paid Other Leave Hours' ) THEN
1235 
1236 hr_utility.set_location(' Inside balance Loop ', 850);
1237 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1238 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1239 
1240 				l_otl_bal_val :=
1241 				l_otl_bal_val
1242 				+
1243 				PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1244 							l_valid_asg_act_rec.assignment_action_id,
1245 							g_employer_id,
1246 							null,
1247 							null,
1248 							null,
1249 							null,
1250 							null);/*6856473*/
1251 
1252 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1253 hr_utility.set_location(' l_otl_bal_val '|| l_otl_bal_val, 850);
1254 
1255 /*6856473 added checks for balances Paid Maternity Days, Paid Sick Leave Days and Paid Other Leave Days*/
1256 
1257                         ELSIF (g_def_bal_id(bal_index).balance_name   = 'Paid Maternity Days') THEN
1258 
1259 hr_utility.set_location(' Inside balance Loop ', 850);
1260 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1261 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1262 
1263 				l_mat_bal_val :=
1264 				nvl(l_mat_bal_val,0)
1265 				+
1266 				PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1267 							l_valid_asg_act_rec.assignment_action_id,
1268 							g_employer_id,
1269 							null,
1270 							null,
1271 							null,
1272 							null,
1273 							null)*l_hours_per_day;
1274 
1275 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1276 
1277 hr_utility.set_location(' l_mat_bal_val '|| l_mat_bal_val, 850);
1278 			ELSIF ( g_def_bal_id(bal_index).balance_name   = 'Paid Sick Leave Days') THEN
1279 
1280 hr_utility.set_location(' Inside balance Loop ', 850);
1281 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1282 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1283 
1284 				l_sic_bal_val :=
1285 				nvl(l_sic_bal_val,0)
1286 				+
1287 				PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1288 							l_valid_asg_act_rec.assignment_action_id,
1289 							g_employer_id,
1290 							null,
1291 							null,
1292 							null,
1293 							null,
1294 							null)*l_hours_per_day;
1295 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1296 hr_utility.set_location(' l_sic_bal_val '|| l_sic_bal_val, 850);
1297 			ELSIF ( g_def_bal_id(bal_index).balance_name   = 'Paid Other Leave Days') THEN
1298 
1299 hr_utility.set_location(' Inside balance Loop ', 850);
1300 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1301 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1302 
1303 				l_otl_bal_val :=
1304 				nvl(l_otl_bal_val,0)
1305                                 +
1306 				PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1307 							l_valid_asg_act_rec.assignment_action_id,
1308 							g_employer_id,
1309 							null,
1310 							null,
1311 							null,
1312 							null,
1313 							null)*l_hours_per_day
1314 							;
1315 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1316 
1317 hr_utility.set_location(' l_otl_bal_val '|| l_otl_bal_val, 850);
1318 
1319 			ELSIF g_def_bal_id(bal_index).balance_name   = 'Income Continuance Insurance' THEN
1320 
1321 hr_utility.set_location(' Inside balance Loop ', 850);
1322 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1323 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1324 
1325 				l_incct_bal_val :=  PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1326 							l_valid_asg_act_rec.assignment_action_id,
1327 							g_employer_id,
1328 							null,
1329 							null,
1330 							null,
1331 							null,
1332 							null);
1333 hr_utility.set_location(' l_incct_bal_val '|| l_incct_bal_val, 850);
1334 			ELSIF g_def_bal_id(bal_index).balance_name   = 'Redundancy Payments' THEN
1335 
1336 hr_utility.set_location(' Inside balance Loop ', 850);
1337 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1338 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1339 
1340 				l_red_bal_val := PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1341 							l_valid_asg_act_rec.assignment_action_id,
1342 							g_employer_id,
1343 							null,
1344 							null,
1345 							null,
1346 							null,
1347 							null);
1348 hr_utility.set_location(' l_red_bal_val '|| l_red_bal_val, 850);
1349 			ELSIF g_def_bal_id(bal_index).balance_name  = 'Employee Related Payments' THEN
1350 
1351 hr_utility.set_location(' Inside balance Loop ', 850);
1352 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1353 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1354 
1355 				l_otsoc_bal_val := PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1356 							l_valid_asg_act_rec.assignment_action_id,
1357 							g_employer_id,
1358 							null,
1359 							null,
1360 							null,
1361 							null,
1362 							null);
1363 hr_utility.set_location(' l_otsoc_bal_val '|| l_otsoc_bal_val, 850);
1364 			ELSIF g_def_bal_id(bal_index).balance_name  = 'Training Subsidies' THEN
1365 
1366 hr_utility.set_location(' Inside balance Loop ', 850);
1367 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1368 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1369 
1370 				l_tr_sub_bal_val := PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1371 							l_valid_asg_act_rec.assignment_action_id,
1372 							g_employer_id,
1373 							null,
1374 							null,
1375 							null,
1376 							null,
1377 							null);
1378 hr_utility.set_location(' l_tr_sub_bal_val '|| l_tr_sub_bal_val, 850);
1379 			ELSIF g_def_bal_id(bal_index).balance_name  = 'Refunds' THEN
1380 
1381 hr_utility.set_location(' Inside balance Loop ', 850);
1382 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1383 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1384 
1385 				l_refund_bal_val := PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1386 							l_valid_asg_act_rec.assignment_action_id,
1387 							g_employer_id,
1388 							null,
1389 							null,
1390 							null,
1391 							null,
1392 							null);
1393 hr_utility.set_location(' l_refund_bal_val '|| l_refund_bal_val, 850);
1394 			ELSIF g_def_bal_id(bal_index).balance_name  = 'Voluntary Sickness Insurance' THEN
1395 
1396 hr_utility.set_location(' Inside balance Loop ', 850);
1397 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1398 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1399 
1400 				l_vhi_bal_val := PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1401 							l_valid_asg_act_rec.assignment_action_id,
1402 							g_employer_id,
1403 							null,
1404 							null,
1405 							null,
1406 							null,
1407 							null);
1408 hr_utility.set_location(' l_vhi_bal_val '|| l_vhi_bal_val, 850);
1409 			ELSIF g_def_bal_id(bal_index).balance_name  = 'Staff Housing' THEN
1410 
1411 hr_utility.set_location(' Inside balance Loop ', 850);
1412 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1413 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1414 
1415 				l_hse_bal_val := PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1416 							l_valid_asg_act_rec.assignment_action_id,
1417 							g_employer_id,
1418 							null,
1419 							null,
1420 							null,
1421 							null,
1422 							null);
1423 hr_utility.set_location(' l_hse_bal_val '|| l_hse_bal_val, 850);
1424 			ELSIF g_def_bal_id(bal_index).balance_name  = 'Other Benefits' THEN
1425 
1426 hr_utility.set_location(' Inside balance Loop ', 850);
1427 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1428 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1429 
1430 				l_otben_bal_val := PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1431 							l_valid_asg_act_rec.assignment_action_id,
1432 							g_employer_id,
1433 							null,
1434 							null,
1435 							null,
1436 							null,
1437 							null);
1438 hr_utility.set_location(' l_otben_bal_val '|| l_otben_bal_val, 850);
1439 			ELSIF g_def_bal_id(bal_index).balance_name  = 'Other Subsidies' THEN
1440 
1441 hr_utility.set_location(' Inside balance Loop ', 850);
1442 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1443 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1444 
1445 				l_ot_sub_bal_val := PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1446 							l_valid_asg_act_rec.assignment_action_id,
1447 							g_employer_id,
1448 							null,
1449 							null,
1450 							null,
1451 							null,
1452 							null);
1453 hr_utility.set_location(' l_ot_sub_bal_val '|| l_ot_sub_bal_val, 850);
1454 			ELSIF g_def_bal_id(bal_index).balance_name  = 'Hourly Rate' THEN
1455 
1456 hr_utility.set_location(' Inside balance Loop ', 850);
1457 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1458 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1459 
1460 		/*		l_nmw_bal_val := PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1461 							l_valid_asg_act_rec.assignment_action_id,
1462 							g_employer_id,
1463 							null,
1464 							null,
1465 							null,
1466 							null,
1467 							null);
1468                */
1469 	                        l_nmw_bal_val:=( NVL(l_regwg_bal_val,0) + NVL(l_irrb_bal_val,0));
1470 hr_utility.set_location(' l_nmw_bal_val '|| l_nmw_bal_val, 850);
1471 			ELSIF g_def_bal_id(bal_index).balance_name  = 'Stock Options and Share Purchase' THEN
1472 
1473 hr_utility.set_location(' Inside balance Loop ', 850);
1474 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1475 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1476 
1477 				l_stks_bal_val := PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1478 							l_valid_asg_act_rec.assignment_action_id,
1479 							g_employer_id,
1480 							null,
1481 							null,
1482 							null,
1483 							null,
1484 							null);
1485 hr_utility.set_location(' l_stks_bal_val '|| l_stks_bal_val, 850);
1486 			ELSIF g_def_bal_id(bal_index).balance_name  = 'IE RBS ER Contribution' THEN
1487 
1488 hr_utility.set_location(' Inside balance Loop ', 850);
1489 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1490 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1491 
1492 				l_rbs_er_bal_val := PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1493 							l_valid_asg_act_rec.assignment_action_id,
1494 							g_employer_id,
1495 							null,
1496 							null,
1497 							null,
1498 							null,
1499 							null);
1500 hr_utility.set_location(' l_rbs_er_bal_val '|| l_rbs_er_bal_val, 850);
1501 			ELSIF g_def_bal_id(bal_index).balance_name  = 'IE PRSA ER Contribution' THEN
1502 
1503 hr_utility.set_location(' Inside balance Loop ', 850);
1504 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1505 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1506 
1507 				l_prsa_er_bal_val := PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1508 							l_valid_asg_act_rec.assignment_action_id,
1509 							g_employer_id,
1510 							null,
1511 							null,
1512 							null,
1513 							null,
1514 							null);
1515 hr_utility.set_location(' l_prsa_er_bal_val '|| l_prsa_er_bal_val, 850);
1516 			ELSIF g_def_bal_id(bal_index).balance_name  = 'IE RAC ER Contribution' THEN
1517 
1518 hr_utility.set_location(' Inside balance Loop ', 850);
1519 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1520 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1521 
1522 				l_rac_er_bal_val := PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1523 							l_valid_asg_act_rec.assignment_action_id,
1524 							g_employer_id,
1525 							null,
1526 							null,
1527 							null,
1528 							null,
1529 							null);
1530 hr_utility.set_location(' l_rac_er_bal_val '|| l_rac_er_bal_val, 850);
1531 			ELSIF g_def_bal_id(bal_index).balance_name  = 'IE PRSI Employer' THEN
1532 
1533 hr_utility.set_location(' Inside balance Loop ', 850);
1534 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1535 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1536 
1537 				l_prsi_bal_val := PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1538 							l_valid_asg_act_rec.assignment_action_id,
1539 							g_employer_id,
1540 							null,
1541 							null,
1542 							null,
1543 							null,
1544 							null);
1545 hr_utility.set_location(' l_prsi_bal_val '|| l_prsi_bal_val, 850);
1546 			ELSIF g_def_bal_id(bal_index).balance_name  = 'IE BIK Company Vehicle' THEN
1547 
1548 hr_utility.set_location(' Inside balance Loop ', 850);
1549 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1550 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1551 
1552 				l_bik_veh_bal_val := PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1553 							l_valid_asg_act_rec.assignment_action_id,
1554 							g_employer_id,
1555 							null,
1556 							null,
1557 							null,
1558 							null,
1559 							null);
1560 
1561 hr_utility.set_location(' l_bik_veh_bal_val '|| l_bik_veh_bal_val, 850);
1562 
1563 /* 6856473 */
1564                       ELSIF g_def_bal_id(bal_index).balance_name  = 'Annual Leave and Bank Holiday Hours' THEN
1565 hr_utility.set_location(' Inside balance Loop ', 850);
1566 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1567 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1568 				l_al_bal_val := PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1569 							l_valid_asg_act_rec.assignment_action_id,
1570 							g_employer_id,
1571 							null,
1572 							null,
1573 							null,
1574 							null,
1575 							null);
1576 hr_utility.set_location(' l_al_bal_val  '|| l_al_bal_val, 850);
1577                       ELSIF ( g_def_bal_id(bal_index).balance_name   = 'Annual Leave and Bank Holiday Days') THEN
1578 hr_utility.set_location(' Inside balance Loop ', 850);
1579 hr_utility.set_location(' g_def_bal_id(bal_index).balance_name '||g_def_bal_id(bal_index).balance_name, 850);
1580 hr_utility.set_location(' l_valid_asg_act_rec.assignment_action_id '||l_valid_asg_act_rec.assignment_action_id, 850);
1581 				l_al_bal_val :=
1582 				nvl(l_al_bal_val,0)
1583                                 +
1584 				PAY_BALANCE_PKG.GET_VALUE(g_def_bal_id(bal_index).defined_balance_id,
1585 							l_valid_asg_act_rec.assignment_action_id,
1586 							g_employer_id,
1587 							null,
1588 							null,
1589 							null,
1590 							null,
1591 							null)*l_hours_per_day
1592 							;
1593 hr_utility.set_location(' l_al_bal_val  '|| l_al_bal_val, 850);
1594 
1595 			END IF;
1596 		END LOOP;
1597 
1598 
1599 
1600 
1601 
1602 
1603 		IF l_chrs_bal_val > 0 THEN
1604 		  IF (l_nmw_bal_val / l_chrs_bal_val) <= g_ie_nat_min_wage_rate THEN
1605 		   l_nmw_count := l_nmw_count + 1;
1606 		  END IF;
1607 		 END IF;
1608 hr_utility.set_location(' l_nmw_count '|| l_nmw_count , 860);
1609 
1610 		l_pen_bal_val_tot := NVL(l_rbs_er_bal_val,0) + NVL(l_prsa_er_bal_val,0) + NVL(l_rac_er_bal_val,0);
1611 
1612 hr_utility.set_location(' l_pen_bal_val_tot '|| l_pen_bal_val_tot , 870);
1613 
1614 		IF l_valid_asg_rec.EMP_CATG = 'AT' THEN
1615 			l_app_wg_bal_val_tot := NVL(l_regwg_bal_val,0)  + NVL(l_ovrt_bal_val,0)  + NVL(l_irrb_bal_val,0);
1616 			l_lap_bal_val_tot	   := NVL(l_mat_bal_val,0)    + NVL(l_sic_bal_val,0)   + NVL(l_otl_bal_val,0);
1617 			l_ssec_bal_val_tot   := NVL(l_prsi_bal_val,0)   + NVL(l_incct_bal_val,0)
1618 						    + NVL(l_red_bal_val,0)    + NVL(l_otsoc_bal_val,0);
1619 
1620 			hr_utility.set_location(' l_app_wg_bal_val_tot '|| l_app_wg_bal_val_tot , 880);
1621 			hr_utility.set_location(' l_lap_bal_val_tot '|| l_lap_bal_val_tot , 880);
1622 			hr_utility.set_location(' l_ssec_bal_val_tot '|| l_ssec_bal_val_tot , 880);
1623 		END IF;
1624 	-- END IF;  --assignment action ID
1625   END IF;
1626   CLOSE cur_valid_asg_act;
1627 
1628 hr_utility.set_location(' Before Inserting PAY_US_RPT_TOTALS', 890);
1629 hr_utility.set_location(' VALUE OF EMP_CATG'||l_valid_asg_rec.EMP_CATG, 890);
1630 
1631 	INSERT INTO PAY_US_RPT_TOTALS
1632 	(BUSINESS_GROUP_ID
1633 	,ATTRIBUTE1		--payroll_action_id
1634 	,ATTRIBUTE2		--Assignment_id
1635 	,ATTRIBUTE3		--EHECS_CATG		M(Managers)/C(Clerk)/P(Production Wrk)
1636 	,ATTRIBUTE4		--EMP_CATG			F(full)/P(Part)/AT(Apprnt)
1637 	,ATTRIBUTE5		--l_nmw_bal_val		Hourly Rate
1638 	,ATTRIBUTE6		--l_regwg_bal_val		Regular Earning
1639 	,ATTRIBUTE7		--l_ovrt_bal_val		Overtime Payments
1640 	,ATTRIBUTE8		--l_irrb_bal_val		Irregular Earnings
1641 	,ATTRIBUTE9		--l_app_wg_bal_val_tot	Irregular Earnings + Regular Earning + Overtime Payments
1642 	,ATTRIBUTE10	--l_chrs_bal_val		Normal Working Hours
1643 	,ATTRIBUTE11	--l_othr_bal_val		Paid Overtime Hours
1644 	,ATTRIBUTE12	--l_nmw_count           Count for National Min Wage
1645 	,ATTRIBUTE13	--l_mat_bal_val		Paid Maternity Leave
1646 	,ATTRIBUTE14	--l_sic_bal_val		Paid Sick leave Hours
1647 	,ATTRIBUTE15	--l_otl_bal_val		Paid Other Leave Hours
1648 	,ATTRIBUTE16	--l_lap_bal_val_tot	l_mat_bal_val + l_sic_bal_val + l_otl_bal_val
1649 	,ATTRIBUTE17	--l_pen_bal_val_tot	(IE RBS + IE PRSA + IE RAC) ER Contri
1650 	,ATTRIBUTE18	--l_prsi_bal_val		IE PRSI Employer
1651 	,ATTRIBUTE19	--l_incct_bal_val		Income Continuance Insurance
1652 	,ATTRIBUTE20	--l_red_bal_val		Redundancy Payments
1653 	,ATTRIBUTE21	--l_otsoc_bal_val		Employee Related Payments
1654 	,ATTRIBUTE22	--l_ssec_bal_val_tot	l_prsi_bal_val+l_incct_bal_val+l_red_bal_val+l_otsoc_bal_val
1655 	,ATTRIBUTE23	--l_bik_veh_bal_val	IE BIK Company Vehicle
1656 	,ATTRIBUTE24	--l_stks_bal_val		Stock Options and Share Purchase.
1657 	,ATTRIBUTE25	--l_vhi_bal_val		Voluntary Sickness Insurance
1658 	,ATTRIBUTE26	--l_hse_bal_val		Staff Housing
1659 	,ATTRIBUTE27	--l_otben_bal_val		Other Benifits
1660 	,ATTRIBUTE28	--l_tr_sub_bal_val	Training Subsidies
1661 	,ATTRIBUTE29	--l_ot_sub_bal_val	Other Subsidies
1662 	,ATTRIBUTE30	--l_refund_bal_val	Refunds
1663 	,ATTRIBUTE31	--l_rbs_er_bal_val	IE RBS ER Contribution
1664 	,ATTRIBUTE32	--l_prsa_er_bal_val	IE PRSA ER Contribution
1665 	,ATTRIBUTE33	--l_rac_er_bal_val	IE RAC ER Contribution
1666 	,ATTRIBUTE34    --l_al_bal_val          Annual Leave and Bank Holidays  (both hours and days)          6856473
1667 	)
1668 	VALUES
1669 	(p_business_group_id
1670 	,p_payroll_action_id
1671 	,l_valid_asg_rec.assignment_id
1672 	,l_valid_asg_rec.EHECS_CATG
1673 	,l_valid_asg_rec.EMP_CATG
1674 	,l_nmw_bal_val
1675 	,l_regwg_bal_val
1676 	,l_ovrt_bal_val
1677 	,l_irrb_bal_val
1678 	,l_app_wg_bal_val_tot
1679 	,l_chrs_bal_val
1680 	,l_othr_bal_val
1681 	,l_nmw_count
1682 	,l_mat_bal_val
1683 	,l_sic_bal_val
1684 	,l_otl_bal_val
1685 	,l_lap_bal_val_tot
1686 	,l_pen_bal_val_tot
1687 	,l_prsi_bal_val
1688 	,l_incct_bal_val
1689 	,l_red_bal_val
1690 	,l_otsoc_bal_val
1691 	,l_ssec_bal_val_tot
1692 	,l_bik_veh_bal_val
1693 	,l_stks_bal_val
1694 	,l_vhi_bal_val
1695 	,l_hse_bal_val
1696 	,l_otben_bal_val
1697 	,l_tr_sub_bal_val
1698 	,l_ot_sub_bal_val
1699 	,l_refund_bal_val
1700 	,l_rbs_er_bal_val
1701 	,l_prsa_er_bal_val
1702 	,l_rac_er_bal_val
1703 	,l_al_bal_val      -- 6856473
1704 	 );
1705 
1706 hr_utility.set_location(' After Inserting PAY_US_RPT_TOTALS', 900);
1707 
1708 CLOSE cur_valid_asg;
1709 
1710 hr_utility.set_location(' Leaving PAY_IE_EHECS_REPORT_PKG.ehecs_main_proc', 910);
1711 
1712 END;
1713 
1714 -----------------------------------------------------------------------
1715 --C2B
1716 -----------------------------------------------------------------------
1717 
1718 FUNCTION c2b( c IN CLOB ) RETURN BLOB
1719 -- typecasts CLOB to BLOB (binary conversion)
1720 IS
1721 pos PLS_INTEGER := 1;
1722 buffer RAW( 32767 );
1723 res BLOB;
1724 lob_len PLS_INTEGER := DBMS_LOB.getLength( c );
1725 BEGIN
1726 Hr_Utility.set_location('Entering: PAY_IE_EHECS_REPORT_PKG.c2b',1000);
1727 DBMS_LOB.createTemporary( res, TRUE );
1728 DBMS_LOB.OPEN( res, DBMS_LOB.LOB_ReadWrite );
1729 
1730 
1731 LOOP
1732 buffer := UTL_RAW.cast_to_raw( DBMS_LOB.SUBSTR( c, 16000, pos ) );
1733 
1734 IF UTL_RAW.LENGTH( buffer ) > 0 THEN
1735 DBMS_LOB.writeAppend( res, UTL_RAW.LENGTH( buffer ), buffer );
1736 END IF;
1737 
1738 pos := pos + 16000;
1739 EXIT WHEN pos > lob_len;
1740 END LOOP;
1741 
1742 Hr_Utility.set_location('Leaving: PAY_IE_EHECS_REPORT_PKG.c2b',1010);
1743 RETURN res; -- res is OPEN here
1744 END c2b;
1745 -----------------------------------------------------------------------
1746 -- GEN_BODY_XML
1747 -----------------------------------------------------------------------
1748 
1749 PROCEDURE gen_body_xml
1750   IS
1751 l_string  varchar2(32767) := NULL;
1752 l_clob PAY_FILE_DETAILS.FILE_FRAGMENT%TYPE;
1753 l_blob PAY_FILE_DETAILS.BLOB_FILE_FRAGMENT%TYPE;
1754 
1755 l_person_id per_all_people_f.person_id%TYPE;
1756 l_assignment_id per_all_assignments_f.assignment_id%TYPE;
1757 l_payroll_action_id pay_payroll_actions.payroll_action_id%TYPE;
1758 l_object_action_id pay_temp_object_actions.object_action_id%TYPE;
1759 
1760 CURSOR C_Perid_Asgid(p_payroll_action_id NUMBER, p_object_action_id NUMBER)  IS
1761 	SELECT DISTINCT ppf.person_id, paa.assignment_id
1762 	FROM per_all_people_f         ppf
1763 	,per_all_assignments_f        paa
1764 	,pay_payroll_actions          ppa
1765 	,pay_temp_object_actions      ptoa
1766 	WHERE paa.business_group_id = ppa.business_group_id
1767 	AND paa.person_id = ppf.person_id
1768 	AND ppa.payroll_action_id = p_payroll_action_id
1769 	AND paa.business_group_id = g_business_Group_id
1770 	AND ppa.payroll_action_id = ptoa.payroll_action_id
1771 	AND ptoa.Object_id	  = paa.assignment_id
1772 	AND ptoa.object_action_id = p_object_action_id;
1773 
1774 BEGIN
1775 hr_utility.set_location(' Entering: pay_ie_p45part3_p46_pkg_test.gen_body_xml: ', 2000);
1776 
1777 l_payroll_action_id := pay_magtape_generic.get_parameter_value('TRANSFER_PAYROLL_ACTION_ID');
1778 l_object_action_id := pay_magtape_generic.get_parameter_value('TRANSFER_ACT_ID');
1779 
1780 OPEN C_Perid_Asgid(l_payroll_action_id, l_object_action_id);
1781 FETCH C_Perid_Asgid into l_person_id, l_assignment_id;
1782 CLOSE C_Perid_Asgid;
1783 
1784 hr_utility.set_location('l_person_id '||TO_CHAR(l_person_id),2010);
1785 hr_utility.set_location('l_assignment_id '||TO_CHAR(l_assignment_id),2010);
1786 hr_utility.set_location('l_payroll_action_id '||TO_CHAR(l_payroll_action_id),2010);
1787 hr_utility.set_location('l_object_action_id '||TO_CHAR(l_object_action_id),2010);
1788 
1789 hr_utility.set_location('befiore calling Ehecs_main_proc ',2020);
1790 
1791 ehecs_main_proc(	g_business_Group_id
1792 			,l_payroll_action_id
1793 			,l_assignment_id
1794 			,l_person_id);
1795 
1796 hr_utility.set_location('befiore calling Ehecs_main_proc ',2030);
1797 
1798 hr_utility.set_location(' Leaving: pay_ie_p45part3_p46_pkg_test.gen_body_xml: ', 2040);
1799 
1800 EXCEPTION
1801 WHEN Others THEN
1802 	Hr_Utility.set_location('..'||'SQL-ERRM :'||SQLERRM,2050);
1803 END gen_body_xml;
1804 -----------------------------------------------------------------------
1805 -- GEN_HEADER_XML
1806 -----------------------------------------------------------------------
1807 PROCEDURE gen_header_xml
1808 IS
1809 	l_string  varchar2(32767) := NULL;
1810 	l_clob PAY_FILE_DETAILS.FILE_FRAGMENT%TYPE;
1811 	l_blob PAY_FILE_DETAILS.BLOB_FILE_FRAGMENT%TYPE;
1812 
1813 	l_proc VARCHAR2(100);
1814 	l_buf  VARCHAR2(2000);
1815 
1816 	CURSOR c_get_header(c_pact_id NUMBER) IS
1817 	SELECT
1818 	action_information6 year,
1819 	action_information7 quarter,
1820 	action_information8 report_type,
1821 	action_information9 software_name,
1822 	action_information10 software_version,
1823 	action_information11 vendor_name,
1824 	action_information12 Vendor_phone,
1825 	action_information13 org_id,
1826 	action_information14 employer_name,
1827         action_information15 addr1,
1828 	action_information16 addr2,
1829 	action_information17 addr3,
1830 	action_information18 addr4,
1831 	action_information19 addr5,
1832 	action_information20 change_indicator,
1833 	action_information21 cbr_no,
1834 	action_information22 declarant_name,
1835 	action_information23 declarant_phone,
1836 	action_information24 declarant_email,
1837 	action_information25 declare_date,
1838 	action_information26 declarant_position
1839 	FROM    pay_action_information
1840 	WHERE   action_context_id = c_pact_id
1841 	AND     action_context_type = 'PA'
1842 	AND     action_information_category ='IE_EHECS_HEADER';
1843 
1844 	l_header c_get_header%rowtype;
1845 	l_payroll_action_id number;
1846 
1847 BEGIN
1848 	l_proc := g_package || 'gen_header_xml';
1849 	hr_utility.set_location ('Entering '||l_proc,1500);
1850 
1851 	l_payroll_action_id := pay_magtape_generic.get_parameter_value('TRANSFER_PAYROLL_ACTION_ID');
1852 	hr_utility.set_location('Inside PAY_IE_EHECS_REPORT_PKG.gen_header_xml,l_payroll_action_id: '||l_payroll_action_id,300);
1853 
1854 	OPEN c_get_header(l_payroll_action_id);
1855 	FETCH c_get_header into l_header;
1856 	CLOSE c_get_header;
1857 
1858 	l_string := l_string || '<EHECS' ;
1859 	l_string := l_string || ' Yr="'|| l_header.year ||'"';
1860 	l_string := l_string || ' Qtr="'|| l_header.quarter ||'"'  ;
1861 	l_string := l_string || ' TypRt="'|| l_header.report_type||'"';
1862         l_string := l_string || ' SoftwareName="'|| l_header.software_name||'"';
1863 	l_string := l_string || ' SoftwareVersion="'|| l_header.software_version||'"';
1864 	l_string := l_string || ' VendorName="'|| l_header.vendor_name||'"';
1865 	l_string := l_string || ' VendorPhone="'|| l_header.vendor_phone ||'">'||EOL ;
1866 
1867 	l_string := l_string || '<Company>'||EOL ;
1868 
1869 	l_string := l_string || ' <Name>'|| substr(l_header.employer_name,1,80)||'</Name>' ;
1870 	l_string := l_string || ' <Addr1>'|| substr(l_header.addr1,1,80)||'</Addr1>';
1871 	l_string := l_string || ' <Addr2>'|| substr(l_header.addr2,1,80)||'</Addr2>';
1872 	l_string := l_string || ' <Addr3>'|| substr(l_header.addr3,1,80)||'</Addr3>';
1873 	l_string := l_string || ' <Addr4>'|| substr(l_header.addr4,1,80)||'</Addr4>';
1874 	l_string := l_string || ' <Addr5>'|| substr(l_header.addr5,1,80)||'</Addr5>';
1875 	l_string := l_string || ' <ChgAd>'|| substr(l_header.change_indicator,1,20)||'</ChgAd>';
1876 	l_string := l_string || ' <CBR>'||substr(l_header.cbr_no,1,12)||'</CBR>' ;
1877 
1878 	l_string := l_string ||'</Company>'||EOL ;
1879 
1880       l_string := l_string || '<Declaration>'||EOL ;
1881    	l_string := l_string || ' <Contact>'|| substr(l_header.declarant_name,1,40) ||'</Contact>';
1882 	l_string := l_string || ' <Phone>'|| substr(l_header.declarant_phone,1,14) ||'</Phone>' ;
1883 	l_string := l_string || ' <Email>'|| substr(l_header.declarant_email,1,80) ||'</Email>';
1884 	--l_string := l_string || ' <Date>'|| l_header.declare_date ||'</Date>';
1885 	l_string := l_string || ' <Date>'|| to_char(fnd_date.canonical_to_date(l_header.declare_date),'DD/MM/YYYY') ||'</Date>';
1886 	l_string := l_string || ' <Position>'||l_header.declarant_position||'</Position>';
1887 
1888       l_string := l_string ||'</Declaration>'||EOL ;
1889 	l_clob := l_clob||l_string;
1890 	IF l_clob IS NOT NULL THEN
1891 	  l_blob := c2b(l_clob);
1892 	  pay_core_files.write_to_magtape_lob(l_blob);
1893 	END IF;
1894 
1895 EXCEPTION
1896 WHEN Others THEN
1897 Hr_Utility.set_location('..'||'SQL-ERRM :'||SQLERRM,1214);
1898 
1899 END gen_header_xml;
1900 -----------------------------------------------------------------------
1901 -- GEN_FOOTER_XML
1902 -----------------------------------------------------------------------
1903 PROCEDURE gen_footer_xml
1904 IS
1905  l_string  varchar2(32767) := NULL;
1906  l_clob PAY_FILE_DETAILS.FILE_FRAGMENT%TYPE;
1907  l_blob PAY_FILE_DETAILS.BLOB_FILE_FRAGMENT%TYPE;
1908 l_buf  VARCHAR2(2000);
1909 l_proc VARCHAR2(100);
1910 
1911 CURSOR cur_get_totals (c_pact_id NUMBER)
1912 IS
1913 SELECT
1914 EHECS_CATG,
1915 --SUM(decode(EMP_CATG,'P',sum_nmw_bal_val,'F',sum_nmw_bal_val)) nmw_pt_ft_mg_cl_ot
1916 SUM(decode(EMP_CATG,'P',sum_nmw_count_val,'F',sum_nmw_count_val)) nmw_pt_ft_mg_cl_ot
1917 
1918 ,SUM(decode(EMP_CATG,'F',sum_regwg_bal_val)) regwg_ft_mg_cl_ot
1919 ,SUM(decode(EMP_CATG,'F',sum_ovrt_bal_val)) ovrt_ft_mg_cl_ot
1920 ,SUM(decode(EMP_CATG,'F',sum_irrb_bal_val)) irrb_ft_mg_cl_ot
1921 ,SUM(decode(EMP_CATG,'P',sum_regwg_bal_val)) regwg_pt_mg_cl_ot
1922 ,SUM(decode(EMP_CATG,'P',sum_ovrt_bal_val)) ovrt_pt_mg_cl_ot
1923 ,SUM(decode(EMP_CATG,'P',sum_irrb_bal_val)) irrb_pt_mg_cl_ot
1924 ,SUM(decode(EMP_CATG,'AT',sum_regwg_bal_val)) regwg_at_mg_cl_ot
1925 ,SUM(decode(EMP_CATG,'AT',sum_ovrt_bal_val)) ovrt_at_mg_cl_ot
1926 ,SUM(decode(EMP_CATG,'AT',sum_irrb_bal_val)) irrb_at_mg_cl_ot
1927 
1928 ,SUM(decode(EMP_CATG,'AT',sum_app_wg_bal_val_tot)) appwg_at_mg_cl_ot
1929 
1930 ,SUM(decode(EMP_CATG,'F',sum_chrs_bal_val)) chrs_ft_mg_cl_ot
1931 ,SUM(decode(EMP_CATG,'P',sum_chrs_bal_val)) chrs_pt_mg_cl_ot
1932 ,SUM(decode(EMP_CATG,'AT',sum_chrs_bal_val)) chrs_at_mg_cl_ot
1933 ,SUM(decode(EMP_CATG,'F',sum_othr_bal_val)) othr_ft_mg_cl_ot
1934 ,SUM(decode(EMP_CATG,'P',sum_othr_bal_val)) othr_pt_mg_cl_ot
1935 ,SUM(decode(EMP_CATG,'AT',sum_othr_bal_val)) othr_at_mg_cl_ot
1936 
1937 ,SUM(decode(EMP_CATG,'F',sum_al_bal_val)) al_ft_mg_cl_ot   -- 6856473
1938 ,SUM(decode(EMP_CATG,'P',sum_al_bal_val)) al_pt_mg_cl_ot   -- 6856473
1939 ,SUM(decode(EMP_CATG,'AT',sum_al_bal_val)) al_at_mg_cl_ot  -- 6856473
1940 
1941 ,SUM(decode(EMP_CATG,'F',sum_mat_bal_val)) mat_ft_mg_cl_ot
1942 ,SUM(decode(EMP_CATG,'F',sum_sic_bal_val)) sic_ft_mg_cl_ot
1943 ,SUM(decode(EMP_CATG,'F',sum_otl_bal_val)) otl_ft_mg_cl_ot
1944 ,SUM(decode(EMP_CATG,'P',sum_mat_bal_val)) mat_pt_mg_cl_ot
1945 ,SUM(decode(EMP_CATG,'P',sum_sic_bal_val)) sic_pt_mg_cl_ot
1946 ,SUM(decode(EMP_CATG,'P',sum_otl_bal_val)) otl_pt_mg_cl_ot
1947 ,SUM(decode(EMP_CATG,'AT',sum_mat_bal_val)) mat_at_mg_cl_ot
1948 ,SUM(decode(EMP_CATG,'AT',sum_sic_bal_val)) sic_at_mg_cl_ot
1949 ,SUM(decode(EMP_CATG,'AT',sum_otl_bal_val)) otl_at_mg_cl_ot
1950 
1951 ,SUM(decode(EMP_CATG,'AT',sum_lap_bal_val_tot)) lap_at_mg_cl_ot
1952 
1953 ,SUM(sum_pen_bal_val_tot) pen_pt_ft_at_mg_cl_ot
1954 ,SUM(decode(EMP_CATG,'P',sum_prsi_bal_val,'F',sum_prsi_bal_val)) prsi_pt_ft_mg_cl_ot
1955 ,SUM(decode(EMP_CATG,'P',sum_incct_bal_val,'F',sum_incct_bal_val)) incct_pt_ft_mg_cl_ot
1956 ,SUM(decode(EMP_CATG,'P',sum_red_bal_val,'F',sum_red_bal_val)) red_pt_ft_mg_cl_ot
1957 ,SUM(decode(EMP_CATG,'P',sum_otsoc_bal_val,'F',sum_otsoc_bal_val)) otsoc_pt_ft_mg_cl_ot
1958 ,SUM(decode(EMP_CATG,'AT',sum_prsi_bal_val)) prsi_at_mg_cl_ot
1959 ,SUM(decode(EMP_CATG,'AT',sum_incct_bal_val)) incct_at_mg_cl_ot
1960 ,SUM(decode(EMP_CATG,'AT',sum_red_bal_val)) red_at_mg_cl_ot
1961 ,SUM(decode(EMP_CATG,'AT',sum_otsoc_bal_val)) otsoc_at_mg_cl_ot
1962 
1963 ,SUM(decode(EMP_CATG,'AT',sum_ssec_bal_val_tot)) ssec_at_mg_cl_ot
1964 
1965 ,SUM(decode(EMP_CATG,'P',sum_bik_veh_bal_val,'F',sum_bik_veh_bal_val)) car_pt_ft_mg_cl_ot
1966 ,SUM(decode(EMP_CATG,'P',sum_stks_bal_val,'F',sum_stks_bal_val)) stks_pt_ft_mg_cl_ot
1967 ,SUM(decode(EMP_CATG,'P',sum_vhi_bal_val,'F',sum_vhi_bal_val)) vhi_pt_ft_mg_cl_ot
1968 ,SUM(decode(EMP_CATG,'P',sum_hse_bal_val,'F',sum_hse_bal_val)) hse_pt_ft_mg_cl_ot
1969 ,SUM(decode(EMP_CATG,'P',sum_otben_bal_val,'F',sum_otben_bal_val)) otben_pt_ft_mg_cl_ot
1970 ,SUM(sum_tr_sub_bal_val) trsub_all
1971 ,SUM(sum_ot_sub_bal_val) otsub_all
1972 ,SUM(sum_refund_bal_val) rfund_all
1973 FROM
1974 (
1975 	SELECT
1976 	 ATTRIBUTE3	EHECS_CATG
1977 	,ATTRIBUTE4	EMP_CATG
1978 	--,SUM(fnd_number.canonical_to_number(ATTRIBUTE5))	sum_nmw_bal_val
1979 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE12))	sum_nmw_count_val
1980 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE6))	sum_regwg_bal_val
1981 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE7))	sum_ovrt_bal_val
1982 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE8))	sum_irrb_bal_val
1983 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE9))	sum_app_wg_bal_val_tot
1984 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE10))	sum_chrs_bal_val
1985 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE11))	sum_othr_bal_val
1986 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE13))	sum_mat_bal_val
1987 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE14))	sum_sic_bal_val
1988 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE15))	sum_otl_bal_val
1989 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE16))	sum_lap_bal_val_tot
1990 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE17))	sum_pen_bal_val_tot
1991 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE18))	sum_prsi_bal_val
1992 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE19))	sum_incct_bal_val
1993 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE20))	sum_red_bal_val
1994 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE21))	sum_otsoc_bal_val
1995 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE22))	sum_ssec_bal_val_tot
1996 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE23))	sum_bik_veh_bal_val
1997 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE24))	sum_stks_bal_val
1998 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE25))	sum_vhi_bal_val
1999 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE26))	sum_hse_bal_val
2000 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE27))	sum_otben_bal_val
2001 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE28))	sum_tr_sub_bal_val
2002 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE29))	sum_ot_sub_bal_val
2003 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE30))	sum_refund_bal_val
2004 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE31))	sum_rbs_er_bal_val
2005 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE32))	sum_prsa_er_bal_val
2006 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE33))	sum_rac_er_bal_val
2007 	,SUM(fnd_number.canonical_to_number(ATTRIBUTE34))	sum_al_bal_val	-- 6856473
2008 	FROM PAY_US_RPT_TOTALS
2009 	WHERE ATTRIBUTE1 = to_char(c_pact_id)
2010 	AND ATTRIBUTE3 IS NOT NULL
2011 	AND ATTRIBUTE4 IS NOT NULL
2012 	GROUP BY ATTRIBUTE3, ATTRIBUTE4
2013 )
2014 GROUP BY EHECS_CATG;
2015 
2016 l_get_totals_rec cur_get_totals%rowtype;
2017 l_get_totals_empty_rec cur_get_totals%rowtype;
2018 
2019 Type tab_get_totals is table of cur_get_totals%rowtype index by varchar2(10);
2020 l_tab_get_totals tab_get_totals;
2021 
2022 l_appwgmg Number := 0;
2023 l_appwgcl Number := 0;
2024 l_appwgot Number := 0;
2025 
2026 l_lapmg Number := 0;
2027 l_lapcl Number := 0;
2028 l_lapot Number := 0;
2029 
2030 l_ssecapmg Number := 0;
2031 l_ssecapcl Number := 0;
2032 l_ssecapot Number := 0;
2033 
2034 ----------------------Override
2035 CURSOR cur_get_Override_totals (c_org_id Number, c_bg_id Number)
2036 IS
2037 SELECT
2038 EHECS_CATG,
2039 SUM(decode(EMP_CATG,'P',l_nmw,'F',l_nmw)) l_sum_nmw
2040 ,SUM(decode(EMP_CATG,'F',l_regwg)) l_sum_regwg_ft
2041 ,SUM(decode(EMP_CATG,'F',l_ovrt)) l_sum_ovrt_ft
2042 ,SUM(decode(EMP_CATG,'F',l_irrb)) l_sum_irrb_ft
2043 ,SUM(decode(EMP_CATG,'P',l_regwg)) l_sum_regwg_pt
2044 ,SUM(decode(EMP_CATG,'P',l_ovrt)) l_sum_ovrt_pt
2045 ,SUM(decode(EMP_CATG,'P',l_irrb)) l_sum_irrb_pt
2046 
2047 ,SUM(decode(EMP_CATG,'AT',l_regwg)) l_sum_regwg_at
2048 ,SUM(decode(EMP_CATG,'AT',l_ovrt)) l_sum_ovrt_at
2049 ,SUM(decode(EMP_CATG,'AT',l_irrb)) l_sum_irrb_at
2050 
2051 ,SUM(decode(EMP_CATG,'F',l_chrs)) l_sum_chrs_ft
2052 ,SUM(decode(EMP_CATG,'P',l_chrs)) l_sum_chrs_pt
2053 ,SUM(decode(EMP_CATG,'AT',l_chrs)) l_sum_chrs_at
2054 
2055 ,SUM(decode(EMP_CATG,'F',l_othr)) l_sum_othr_ft
2056 ,SUM(decode(EMP_CATG,'P',l_othr)) l_sum_othr_pt
2057 ,SUM(decode(EMP_CATG,'AT',l_othr)) l_sum_othr_at
2058 
2059 ,SUM(decode(EMP_CATG,'F',l_al)) l_sum_al_ft
2060 ,SUM(decode(EMP_CATG,'F',l_mat)) l_sum_mat_ft
2061 ,SUM(decode(EMP_CATG,'F',l_sic)) l_sum_sic_ft
2062 ,SUM(decode(EMP_CATG,'F',l_otl)) l_sum_otl_ft
2063 ,SUM(decode(EMP_CATG,'P',l_al)) l_sum_al_pt
2064 ,SUM(decode(EMP_CATG,'P',l_mat)) l_sum_mat_pt
2065 ,SUM(decode(EMP_CATG,'P',l_sic)) l_sum_sic_pt
2066 ,SUM(decode(EMP_CATG,'P',l_otl)) l_sum_otl_pt
2067 
2068 ,SUM(decode(EMP_CATG,'AT',l_al)) l_sum_al_at
2069 ,SUM(decode(EMP_CATG,'AT',l_mat)) l_sum_mat_at
2070 ,SUM(decode(EMP_CATG,'AT',l_sic)) l_sum_sic_at
2071 ,SUM(decode(EMP_CATG,'AT',l_otl)) l_sum_otl_at
2072 
2073 ,SUM(decode(EMP_CATG,'P',l_incc,'F',l_incc)) l_sum_incc_pt_ft
2074 ,SUM(decode(EMP_CATG,'P',l_red,'F',l_red)) l_sum_red_pt_ft
2075 ,SUM(decode(EMP_CATG,'P',l_otsoc,'F',l_otsoc)) l_sum_otsoc_pt_ft
2076 
2077 ,SUM(decode(EMP_CATG,'AT',l_incc)) l_sum_incc_at
2078 ,SUM(decode(EMP_CATG,'AT',l_red)) l_sum_red_at
2079 ,SUM(decode(EMP_CATG,'AT',l_otsoc)) l_sum_otsoc_at
2080 
2081 ,SUM(decode(EMP_CATG,'P',l_stks,'F',l_stks)) l_sum_stks_pt_ft
2082 
2083 ,SUM(decode(EMP_CATG,'P',l_vhi,'F',l_vhi)) l_sum_vhi_pt_ft
2084 ,SUM(decode(EMP_CATG,'P',l_hse,'F',l_hse)) l_sum_hse_pt_ft
2085 
2086 ,SUM(decode(EMP_CATG,'P',l_otben,'F',l_otben)) l_sum_otben_ft
2087 FROM
2088 (
2089   select
2090        --decode(hoi.org_information1,'MPAP','M','CSSW','C','PTCO','P')  EHECS_CATG
2091 	 decode(hoi.org_information1,'Managers','M','Clerical Workers','C','Production Workers','P')  EHECS_CATG
2092 	,decode(hoi.org_information2,'FR','F','PR','P',hoi.org_information2) EMP_CATG
2093 	,SUM(fnd_number.canonical_to_number(hoi.org_information3))  l_nmw
2094 	,SUM(fnd_number.canonical_to_number(hoi.org_information4))  l_regwg
2095 	,SUM(fnd_number.canonical_to_number(hoi.org_information5))  l_ovrt
2096 	,SUM(fnd_number.canonical_to_number(hoi.org_information6))  l_irrb
2097 	,SUM(fnd_number.canonical_to_number(hoi.org_information12)) l_chrs
2098 	,SUM(fnd_number.canonical_to_number(hoi.org_information7))  l_othr
2099 	,SUM(fnd_number.canonical_to_number(hoi.org_information8))  l_al
2100 	,SUM(fnd_number.canonical_to_number(hoi.org_information9))  l_mat
2101 	,SUM(fnd_number.canonical_to_number(hoi.org_information10)) l_sic
2102 	,SUM(fnd_number.canonical_to_number(hoi.org_information11)) l_otl
2103 	--,SUM(fnd_number.canonical_to_number(hoi.org_information13)) l_prsi
2104 	,SUM(fnd_number.canonical_to_number(hoi.org_information14)) l_incc
2105 	,SUM(fnd_number.canonical_to_number(hoi.org_information15)) l_red
2106 	,SUM(fnd_number.canonical_to_number(hoi.org_information16)) l_otsoc
2107 	,SUM(fnd_number.canonical_to_number(hoi.org_information17)) l_stks
2108 	,SUM(fnd_number.canonical_to_number(hoi.org_information18)) l_vhi
2109 	,SUM(fnd_number.canonical_to_number(hoi.org_information19)) l_hse
2110 	,SUM(fnd_number.canonical_to_number(hoi.org_information20)) l_otben
2111   from hr_organization_units hou
2112 	,hr_organization_information hoi
2113   where hoi.org_information_context='IE_EHECS_OVERRIDE'
2114 	and hoi.organization_id=c_org_id
2115 	and hoi.organization_id=hou.organization_id
2116 	and hou.business_group_id= c_bg_id
2117 	and hoi.org_information1 IS NOT NULL
2118 	and hoi.org_information2 IS NOT NULL
2119 	--and decode(hoi.org_information1,'MPAP','M','CSSW','C','PTCO','P') = NVL(g_occupational_category_M_C_P,decode(hoi.org_information1,'MPAP','M','CSSW','C','PTCO','P'))
2120 	and decode(hoi.org_information1,'Managers','M','Clerical Workers','C','Production Workers','P') = NVL(g_occupational_category_M_C_P,decode(hoi.org_information1,'Managers','M','Clerical Workers','C','Production Workers','P'))
2121 	and fnd_date.canonical_to_date(hoi.org_information13) between g_qtr_start_date and g_qtr_end_date
2122   --group by decode(hoi.org_information1,'MPAP','M','CSSW','C','PTCO','P'),
2123   group by decode(hoi.org_information1,'Managers','M','Clerical Workers','C','Production Workers','P'),
2124 	decode(hoi.org_information2,'FR','F','PR','P',hoi.org_information2)
2125 )
2126 GROUP BY EHECS_CATG;
2127 
2128 l_get_override_totals_rec cur_get_override_totals%rowtype;
2129 l_get_ovrrd_tot_empty_rec cur_get_override_totals%rowtype;
2130 
2131 Type tab_get_override_totals is table of cur_get_override_totals%rowtype index by varchar2(10);
2132 l_tab_get_override_totals tab_get_override_totals;
2133 
2134 ------------------------------
2135 
2136 CURSOR c_get_part1(c_pact_id NUMBER) IS
2137 	SELECT
2138 	NVL(action_information1,0) l_fst_ft_mg,
2139 	NVL(action_information2,0) l_fst_ft_cl,
2140 	NVL(action_information3,0) l_fst_ft_ot,
2141 	NVL(action_information4,0) l_lst_ft_mg,
2142 	NVL(action_information5,0) l_lst_ft_cl,
2143 	NVL(action_information6,0) l_lst_ft_ot,
2144 	NVL(action_information7,0) l_hire_ft_mg,
2145 	NVL(action_information8,0) l_hire_ft_cl,
2146 	NVL(action_information9,0) l_hire_ft_ot,
2147 	NVL(action_information10,0) l_fst_pt_mg,
2148 	NVL(action_information11,0) l_fst_pt_cl,
2149 	NVL(action_information12,0) l_fst_pt_ot,
2150 	NVL(action_information13,0) l_lst_pt_mg,
2151 	NVL(action_information14,0) l_lst_pt_cl,
2152 	NVL(action_information15,0) l_lst_pt_ot,
2153 	NVL(action_information16,0) l_hire_pt_mg,
2154 	NVL(action_information17,0) l_hire_pt_cl,
2155 	NVL(action_information18,0) l_hire_pt_ot,
2156 	NVL(action_information19,0) l_app_mg,
2157 	NVL(action_information20,0) l_app_cl,
2158 	NVL(action_information21,0) l_app_ot,
2159 	NVL(action_information22,0) l_not_payroll_mg,
2160 	NVL(action_information23,0) l_not_payroll_cl,
2161 	NVL(action_information24,0) l_not_payroll_ot,
2162 	NVL(action_information25,0) l_vac_mg,
2163 	NVL(action_information26,0) l_vac_cl,
2164 	NVL(action_information27,0) l_vac_ot,
2165 	NVL(action_information28,0) l_min_paid_mg,
2166 	NVL(action_information29,0) l_min_paid_cl,
2167 	NVL(action_information30,0) l_min_paid_ot
2168 	FROM    pay_action_information
2169 	WHERE   action_context_id = c_pact_id
2170 	AND     action_context_type = 'PA'
2171 	AND     action_information_category ='IE_EHECS_PART1';
2172 
2173 
2174 
2175 	CURSOR c_get_part2(c_pact_id NUMBER) IS
2176 	SELECT
2177 	ROUND(NVL(action_information1,0)) l_reg_wg_ft_mg,
2178 	ROUND(NVL(action_information2,0)) l_reg_wg_ft_cl,
2179 	ROUND(NVL(action_information3,0)) l_reg_wg_ft_ot,
2180 	ROUND(NVL(action_information4,0)) l_ot_paid_ft_mg,
2181 	ROUND(NVL(action_information5,0)) l_ot_paid_ft_cl,
2182 	ROUND(NVL(action_information6,0)) l_ot_paid_ft_ot,
2183 	ROUND(NVL(action_information7,0)) l_irr_bonus_ft_mg,
2184 	ROUND(NVL(action_information8,0)) l_irr_bonus_ft_cl,
2185 	ROUND(NVL(action_information9,0)) l_irr_bonus_ft_ot,
2186 	ROUND(NVL(action_information10,0)) l_reg_wg_pt_mg,
2187 	ROUND(NVL(action_information11,0)) l_reg_wg_pt_cl,
2188 	ROUND(NVL(action_information12,0)) l_reg_wg_pt_ot,
2189 	ROUND(NVL(action_information13,0)) l_ot_paid_pt_mg,
2190 	ROUND(NVL(action_information14,0)) l_ot_paid_pt_cl,
2191 	ROUND(NVL(action_information15,0)) l_ot_paid_pt_ot,
2192 	ROUND(NVL(action_information16,0)) l_irr_bonus_pt_mg,
2193 	ROUND(NVL(action_information17,0)) l_irr_bonus_pt_cl,
2194 	ROUND(NVL(action_information18,0)) l_irr_bonus_pt_ot,
2195 	ROUND(NVL(action_information19,0)) l_tot_wg_app_mg,
2196 	ROUND(NVL(action_information20,0)) l_tot_wg_app_cl,
2197 	ROUND(NVL(action_information21,0)) l_tot_wg_app_ot
2198 	FROM    pay_action_information
2199 	WHERE   action_context_id = c_pact_id
2200 	AND     action_context_type = 'PA'
2201 	AND     action_information_category ='IE_EHECS_PART2';
2202 
2203 CURSOR c_get_part3(c_pact_id NUMBER) IS
2204 	SELECT
2205 	ROUND(NVL(action_information1,0)) l_contracted_hrs_paid_ft_mg,
2206 	ROUND(NVL(action_information2,0)) l_contracted_hrs_paid_ft_cl,
2207 	ROUND(NVL(action_information3,0)) l_contracted_hrs_paid_ft_ot,
2208 	ROUND(NVL(action_information4,0)) l_ot_hrs_paid_ft_mg,
2209 	ROUND(NVL(action_information5,0)) l_ot_hrs_paid_ft_cl,
2210 	ROUND(NVL(action_information6,0)) l_ot_hrs_paid_ft_ot,
2211 	ROUND(NVL(action_information7,0)) l_contracted_hrs_paid_pt_mg,
2212 	ROUND(NVL(action_information8,0)) l_contracted_hrs_paid_pt_cl,
2213 	ROUND(NVL(action_information9,0)) l_contracted_hrs_paid_pt_ot,
2214 	ROUND(NVL(action_information10,0)) l_ot_hrs_paid_pt_mg,
2215 	ROUND(NVL(action_information11,0)) l_ot_hrs_paid_pt_cl,
2216 	ROUND(NVL(action_information12,0)) l_ot_hrs_paid_pt_ot,
2217 	ROUND(NVL(action_information13,0)) l_contracted_hrs_paid_app_mg,
2218 	ROUND(NVL(action_information14,0)) l_contracted_hrs_paid_app_cl,
2219 	ROUND(NVL(action_information15,0)) l_contracted_hrs_paid_app_ot,
2220 	ROUND(NVL(action_information16,0)) l_ot_hrs_paid_app_mg,
2221 	ROUND(NVL(action_information17,0)) l_ot_hrs_paid_app_cl,
2222 	ROUND(NVL(action_information18,0)) l_ot_hrs_paid_app_ot
2223 	FROM    pay_action_information
2224 	WHERE   action_context_id = c_pact_id
2225 	AND     action_context_type = 'PA'
2226 	AND     action_information_category ='IE_EHECS_PART3';
2227 
2228 CURSOR c_get_part4(c_pact_id NUMBER) IS
2229 	SELECT
2230 	ROUND(NVL(action_information1,0)) l_ann_leave_ft_mg,
2231 	ROUND(NVL(action_information2,0))l_ann_leave_ft_cl,
2232 	ROUND(NVL(action_information3,0)) l_ann_leave_ft_ot,
2233 	ROUND(NVL(action_information4,0)) l_mat_leave_ft_mg,
2234 	ROUND(NVL(action_information5,0)) l_mat_leave_ft_cl,
2235 	ROUND(NVL(action_information6,0)) l_mat_leave_ft_ot,
2236 	ROUND(NVL(action_information7,0)) l_sck_leave_ft_mg,
2237 	ROUND(NVL(action_information8,0)) l_sck_leave_ft_cl,
2238 	ROUND(NVL(action_information9,0)) l_sck_leave_ft_ot,
2239 	ROUND(NVL(action_information10,0)) l_other_leave_ft_mg,
2240 	ROUND(NVL(action_information11,0)) l_other_leave_ft_cl,
2241 	ROUND(NVL(action_information12,0)) l_other_leave_ft_ot,
2242 	ROUND(NVL(action_information13,0)) l_ann_leave_pt_mg,
2243 	ROUND(NVL(action_information14,0)) l_ann_leave_pt_cl,
2244 	ROUND(NVL(action_information15,0)) l_ann_leave_pt_ot,
2245 	ROUND(NVL(action_information16,0)) l_mat_leave_pt_mg,
2246 	ROUND(NVL(action_information17,0)) l_mat_leave_pt_cl,
2247 	ROUND(NVL(action_information18,0)) l_mat_leave_pt_ot,
2248 	ROUND(NVL(action_information19,0)) l_sck_leave_pt_mg,
2249 	ROUND(NVL(action_information20,0)) l_sck_leave_pt_cl,
2250 	ROUND(NVL(action_information21,0)) l_sck_leave_pt_ot,
2251 	ROUND(NVL(action_information22,0)) l_other_leave_pt_mg,
2252 	ROUND(NVL(action_information23,0)) l_other_leave_pt_cl,
2253 	ROUND(NVL(action_information24,0)) l_other_leave_pt_ot,
2254 	ROUND(NVL(action_information25,0)) l_all_paid_leave_app_mg,
2255 	ROUND(NVL(action_information26,0)) l_all_paid_leave_app_cl,
2256 	ROUND(NVL(action_information27,0)) l_all_paid_leave_app_ot
2257 	FROM    pay_action_information
2258 	WHERE   action_context_id = c_pact_id
2259 	AND     action_context_type = 'PA'
2260 	AND     action_information_category ='IE_EHECS_PART4';
2261 
2262 CURSOR c_get_part7(c_pact_id NUMBER) IS
2263 	SELECT
2264 	ROUND(NVL(action_information1,0)) l_employer_prsi_mg,
2265 	ROUND(NVL(action_information2,0)) l_employer_prsi_cl,
2266 	ROUND(NVL(action_information3,0)) l_employer_prsi_ot,
2267 	ROUND(NVL(action_information4,0)) l_continuance_income_mg,
2268 	ROUND(NVL(action_information5,0)) l_continuance_income_cl,
2269 	ROUND(NVL(action_information6,0)) l_continuance_income_ot,
2270 	ROUND(NVL(action_information7,0)) l_redundacny_paid_mg,
2271 	ROUND(NVL(action_information8,0)) l_redundacny_paid_cl,
2272 	ROUND(NVL(action_information9,0)) l_redundacny_paid_ot,
2273 	ROUND(NVL(action_information10,0)) l_other_paid_mg,
2274 	ROUND(NVL(action_information11,0)) l_other_paid_cl,
2275 	ROUND(NVL(action_information12,0)) l_other_paid_ot,
2276 	ROUND(NVL(action_information13,0)) l_ssc_contributions_app_mg,
2277 	ROUND(NVL(action_information14,0)) l_ssc_contributions_app_cl,
2278 	ROUND(NVL(action_information15,0)) l_ssc_contributions_app_ot
2279 	FROM    pay_action_information
2280 	WHERE   action_context_id = c_pact_id
2281 	AND     action_context_type = 'PA'
2282 	AND     action_information_category ='IE_EHECS_PART7';
2283 
2284 CURSOR c_get_part8(c_pact_id NUMBER) IS
2285 	SELECT
2286 	ROUND(NVL(action_information1,0)) l_company_car_mg,
2287 	ROUND(NVL(action_information2,0)) l_company_car_cl,
2288 	ROUND(NVL(action_information3,0)) l_company_car_ot,
2289 	ROUND(NVL(action_information4,0)) l_stock_options_mg,
2290 	ROUND(NVL(action_information5,0)) l_stock_options_cl,
2291 	ROUND(NVL(action_information6,0)) l_stock_options_ot,
2292 	ROUND(NVL(action_information7,0)) l_vol_sick_insurance_mg,
2293 	ROUND(NVL(action_information8,0)) l_vol_sick_insurance_cl,
2294 	ROUND(NVL(action_information9,0)) l_vol_sick_insurance_ot,
2295 	ROUND(NVL(action_information10,0)) l_staff_housing_mg,
2296 	ROUND(NVL(action_information11,0)) l_staff_housing_cl,
2297 	ROUND(NVL(action_information12,0)) l_staff_housing_ot,
2298 	ROUND(NVL(action_information13,0)) l_other_benefits_mg,
2299 	ROUND(NVL(action_information14,0)) l_other_benefits_cl,
2300 	ROUND(NVL(action_information15,0)) l_other_benefits_ot
2301 	FROM    pay_action_information
2302 	WHERE   action_context_id = c_pact_id
2303 	AND     action_context_type = 'PA'
2304 	AND     action_information_category ='IE_EHECS_PART8';
2305 
2306 CURSOR c_get_part_all_other(c_pact_id NUMBER) IS
2307 	SELECT
2308 	ROUND(NVL(action_information1,0)) l_employer_pension_mg,
2309 	ROUND(NVL(action_information2,0)) l_employer_pension_cl,
2310 	ROUND(NVL(action_information3,0)) l_employer_pension_ot,
2311 	ROUND(NVL(action_information4,0)) l_employer_liability_premium,
2312 	ROUND(NVL(action_information5,0)) l_employer_training_costs,
2313 	ROUND(NVL(action_information6,0)) l_other_expenditure,
2314 	ROUND(NVL(action_information7,0)) l_training_subsudies,
2315 	ROUND(NVL(action_information8,0)) l_other_subsidies,
2316 	ROUND(NVL(action_information9,0)) l_refunds,
2317 	action_information10 l_comment_line1,
2318 	action_information11 l_comment_line2,
2319 	action_information12 l_comment_line3
2320 	FROM    pay_action_information
2321 	WHERE   action_context_id = c_pact_id
2322 	AND     action_context_type = 'PA'
2323 	AND     action_information_category ='IE_EHECS_ALL_OTHER';
2324 
2325 l_data_part1 c_get_part1%rowtype;
2326 l_data_part2 c_get_part2%rowtype;
2327 l_data_part3 c_get_part3%rowtype;
2328 l_data_part4 c_get_part4%rowtype;
2329 l_data_part7 c_get_part7%rowtype;
2330 l_data_part8 c_get_part8%rowtype;
2331 l_data_part_all_other c_get_part_all_other%rowtype;
2332 
2333 l_payroll_action_id NUMBER;
2334 --l_asg_action_id NUMBER;
2335 l_action_info_id NUMBER;
2336 l_ovn NUMBER;
2337 
2338 CURSOR csr_ehecs_eit(c_org_id  hr_organization_information.organization_id%type
2339                            ,c_bg_id hr_organization_units.business_group_id%type
2340 				   ,p_year VARCHAR2
2341 				   ,p_qtr VARCHAR2) IS
2342 select hoi.org_information1 Year,
2343 	hoi.org_information2 Qtr,
2344 	hoi.org_information3 CBR,
2345 	hoi.org_information4 avg_mgr_not_pyrl,
2346 	hoi.org_information5 avg_clk_not_pyrl,
2347 	hoi.org_information6 avg_prod_not_pyrl,
2348 	hoi.org_information7 Job_Vac_Mgr,
2349 	hoi.org_information8 Job_Vac_clk,
2350 	hoi.org_information9 Job_Vac_prod,
2351 	hoi.org_information10 Tot_empr_Lblt_Ins,
2352 	hoi.org_information11 Trng_cost,
2353 	hoi.org_information12 Lbr_Expdtr,
2354 	hoi.org_information13 Declarant,
2355 	hoi.org_information14 Trng_subsidy,
2356 	hoi.org_information15 otr_subsidy,
2357 	hoi.org_information16 refunds
2358 from	hr_organization_units hou
2359 	,hr_organization_information hoi
2360 where hoi.org_information_context='IE_EHECS'
2361 	and hoi.organization_id=c_org_id
2362 	and hoi.organization_id=hou.organization_id
2363 	and hou.business_group_id= c_bg_id
2364 	and hoi.ORG_INFORMATION1 = p_year
2365 	and hoi.ORG_INFORMATION2 = p_qtr;
2366 
2367 l_csr_ehecs_eit csr_ehecs_eit%rowtype;
2368 
2369 
2370 CURSOR csr_part1_qtr_start
2371 IS
2372 SELECT COUNT(1) tot, EMP_CATG, EHECS_CATG
2373 FROM
2374 (
2375 SELECT
2376 --decode(count(1),0,0,1) cnt,
2377 distinct
2378 --decode(paaf.EMPLOYMENT_CATEGORY,'FT','F','FR','F','PR','P','PT','P',paaf.EMPLOYMENT_CATEGORY) EMP_CATG,
2379  /* 6856486 */
2380 
2381  decode(paaf.EMPLOYMENT_CATEGORY
2382 	,hruserdt.get_table_value(paaf.business_group_id,'EHECS_ASG_CATG_TAB','Full_Time',paaf.EMPLOYMENT_CATEGORY,g_qtr_start_date),'F'
2383 	,hruserdt.get_table_value(paaf.business_group_id,'EHECS_ASG_CATG_TAB','Part_Time',paaf.EMPLOYMENT_CATEGORY,g_qtr_start_date),'P'
2384 	,hruserdt.get_table_value(paaf.business_group_id,'EHECS_ASG_CATG_TAB','Apprentice_Trainee',paaf.EMPLOYMENT_CATEGORY,g_qtr_start_date),'AT'
2385 	) EMP_CATG,
2386 /*
2387 NVL(hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','MPAP',substr(paaf.EMPLOYEE_CATEGORY,-2,length(paaf.EMPLOYEE_CATEGORY)),g_qtr_start_date),
2388     NVL(hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','CSSW',substr(paaf.EMPLOYEE_CATEGORY,-2,length(paaf.EMPLOYEE_CATEGORY)),g_qtr_start_date),
2389         hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','PTCO',substr(paaf.EMPLOYEE_CATEGORY,-2,length(paaf.EMPLOYEE_CATEGORY)),g_qtr_start_date)
2390         )
2391     ) EHECS_CATG, */
2392 NVL(hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','Managers',paaf.EMPLOYEE_CATEGORY,g_qtr_start_date),
2393 NVL(hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','Clerical Workers',paaf.EMPLOYEE_CATEGORY,g_qtr_start_date),
2394   hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','Production Workers',paaf.EMPLOYEE_CATEGORY,g_qtr_start_date)
2395   )
2396 ) EHECS_CATG,
2397 paaf.assignment_id
2398 from
2399 per_all_assignments_f paaf,
2400 pay_all_payrolls_f papf,
2401 hr_soft_coding_keyflex scl
2402 where
2403 paaf.business_group_id = g_business_group_id
2404 and paaf.payroll_id is not null
2405 and paaf.payroll_id = nvl(g_payroll_id,paaf.payroll_id)
2406 and paaf.payroll_id = papf.payroll_id
2407 and papf.soft_coding_keyflex_id = scl.soft_coding_keyflex_id
2408 and scl.segment4 = g_employer_id
2409 and paaf.employee_category = nvl(g_occupational_category,paaf.employee_category)
2410 /*
2411 and (	select min(ptp.pay_advice_date)
2412 	from per_time_periods ptp
2413 	where ptp.payroll_id = paaf.payroll_id
2414 	and ptp.pay_advice_date >= g_qtr_start_date
2415     )
2416 */
2417 --and g_qtr_start_date between paaf.effective_start_date and paaf.effective_end_date
2418 --and paaf.effective_start_date between g_qtr_start_date and g_qtr_end_date
2419 and paaf.effective_start_date <= g_qtr_end_date  --g_qtr_start_date  --bug 7294966
2420 --
2421 AND ((g_assignment_set_id is not null
2422 	     AND (g_exc_inc ='I' AND EXISTS(SELECT 1
2423 						    FROM  hr_assignment_set_amendments hasa
2424 							 ,  hr_assignment_sets has
2425 							 ,  per_assignments_f paf
2426 					  WHERE has.assignment_set_id = hasa.assignment_set_id
2427 					  AND   has.business_group_id = g_business_group_id
2428 					  AND   has.assignment_set_id = g_assignment_set_id
2429 					  AND   hasa.assignment_id    = paf.assignment_id
2430 					  AND   paf.person_id         = paaf.person_id)
2431 		OR g_exc_inc = 'E' AND NOT EXISTS(SELECT 1
2432 						    FROM  hr_assignment_set_amendments hasa
2433 							 ,  hr_assignment_sets has
2434 							 ,  per_assignments_f paf
2435 					  WHERE has.assignment_set_id = hasa.assignment_set_id
2436 					  AND   has.business_group_id = g_business_group_id
2437 					  AND   has.assignment_set_id = g_assignment_set_id
2438 					  AND   hasa.assignment_id    = paf.assignment_id
2439 					  AND   paf.person_id         = paaf.person_id
2440 					  )))
2441 	  OR g_assignment_set_id IS NULL)
2442 --
2443 and exists (SELECT paa.assignment_action_id child_assignment_action_id,
2444        prt.run_method run_type
2445 FROM   pay_assignment_actions paa,
2446        pay_run_types_f prt
2447 WHERE  paa.run_type_id = prt.run_type_id
2448 AND    prt.run_method IN ('N','P')
2449 AND    g_qtr_start_date BETWEEN prt.effective_start_date AND prt.effective_end_date
2450 AND    paa.assignment_action_id = (SELECT /*+ USE_NL(paa, ppa) */
2451 				          fnd_number.canonical_to_number(max(paa.assignment_action_id)) child_assignment_action_id
2452 				   FROM   pay_assignment_actions paa,
2453 					  pay_payroll_actions    ppa
2454 				   WHERE
2455 					paa.assignment_id = paaf.assignment_id
2456 					AND    ppa.payroll_action_id = paa.payroll_action_id
2457 					AND    (paa.source_action_id is not null or ppa.action_type in ('I','V','B'))
2458 					AND    ppa.effective_date = (select min(regular_payment_date)   --min(pay_advice_date) --bug 7294966
2459 							from per_time_periods
2460 							where payroll_id = paaf.payroll_id
2461 							--and pay_advice_date >= g_qtr_start_date
2462 							and regular_payment_date >= g_qtr_start_date   --bug 7294966
2463 							)
2464 					AND    ppa.action_type in ('R', 'Q', 'I', 'V','B')
2465 					AND    paa.action_status = 'C'
2466 					AND ppa.effective_date between paaf.effective_start_date AND  paaf.effective_end_date))	--Bug 7294966 QA
2467 /*group by
2468 decode(paaf.EMPLOYMENT_CATEGORY,'FT','F','FR','F','PR','P','PT','P',paaf.EMPLOYMENT_CATEGORY),
2469 NVL(hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','MPAP',paaf.EMPLOYEE_CATEGORY,paaf.effective_start_date),
2470     NVL(hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','CSSW',paaf.EMPLOYEE_CATEGORY,paaf.effective_start_date),
2471     hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','PTCO',paaf.EMPLOYEE_CATEGORY,paaf.effective_start_date)
2472     )), paaf.person_id */
2473 )
2474 GROUP BY EMP_CATG, EHECS_CATG;
2475 
2476 l_part1_qtr_start csr_part1_qtr_start%rowtype;
2477 
2478 CURSOR csr_part1_qtr_end
2479 IS
2480 SELECT COUNT(1) tot, EMP_CATG, EHECS_CATG
2481 FROM
2482 (
2483 SELECT
2484 --decode(count(1),0,0,1) cnt,
2485 distinct
2486 --decode(paaf.EMPLOYMENT_CATEGORY,'FT','F','FR','F','PR','P','PT','P',paaf.EMPLOYMENT_CATEGORY) EMP_CATG,
2487 
2488 /* 6856486 */
2489 
2490  decode(paaf.EMPLOYMENT_CATEGORY
2491 	,hruserdt.get_table_value(paaf.business_group_id,'EHECS_ASG_CATG_TAB','Full_Time',paaf.EMPLOYMENT_CATEGORY,g_qtr_start_date),'F'
2492 	,hruserdt.get_table_value(paaf.business_group_id,'EHECS_ASG_CATG_TAB','Part_Time',paaf.EMPLOYMENT_CATEGORY,g_qtr_start_date),'P'
2493 	,hruserdt.get_table_value(paaf.business_group_id,'EHECS_ASG_CATG_TAB','Apprentice_Trainee',paaf.EMPLOYMENT_CATEGORY,g_qtr_start_date),'AT'
2494 	) EMP_CATG,
2495 /*
2496 NVL(hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','MPAP',substr(paaf.EMPLOYEE_CATEGORY,-2,length(paaf.EMPLOYEE_CATEGORY)),g_qtr_end_date),
2497     NVL(hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','CSSW',substr(paaf.EMPLOYEE_CATEGORY,-2,length(paaf.EMPLOYEE_CATEGORY)),g_qtr_end_date),
2498         hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','PTCO',substr(paaf.EMPLOYEE_CATEGORY,-2,length(paaf.EMPLOYEE_CATEGORY)),g_qtr_end_date)
2499         )
2500     ) EHECS_CATG, */
2501 NVL(hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','Managers',paaf.EMPLOYEE_CATEGORY,g_qtr_end_date),
2502 NVL(hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','Clerical Workers',paaf.EMPLOYEE_CATEGORY,g_qtr_end_date),
2503   hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','Production Workers',paaf.EMPLOYEE_CATEGORY,g_qtr_end_date)
2504   )
2505 ) EHECS_CATG,
2506 paaf.assignment_id
2507 from
2508 per_all_assignments_f paaf,
2509 pay_all_payrolls_f papf,
2510 hr_soft_coding_keyflex scl
2511 where
2512 paaf.business_group_id = g_business_group_id
2513 and paaf.payroll_id is not null
2514 and paaf.payroll_id = nvl(g_payroll_id,paaf.payroll_id)
2515 and paaf.payroll_id = papf.payroll_id
2516 and papf.soft_coding_keyflex_id = scl.soft_coding_keyflex_id
2517 and scl.segment4 = g_employer_id
2518 and paaf.employee_category = nvl(g_occupational_category,paaf.employee_category)
2519 /*
2520 and (	select max(ptp.pay_advice_date)
2521 	from per_time_periods ptp
2522 	where ptp.payroll_id = paaf.payroll_id
2523 	and ptp.pay_advice_date <= g_qtr_end_date
2524     )
2525 */
2526 --and g_qtr_start_date between paaf.effective_start_date and paaf.effective_end_date
2527 --and paaf.effective_start_date between g_qtr_start_date and g_qtr_end_date
2528 and paaf.effective_start_date <= g_qtr_end_date
2529 --
2530 AND ((g_assignment_set_id is not null
2531 	     AND (g_exc_inc ='I' AND EXISTS(SELECT 1
2532 						    FROM  hr_assignment_set_amendments hasa
2533 							 ,  hr_assignment_sets has
2534 							 ,  per_assignments_f paf
2535 					  WHERE has.assignment_set_id = hasa.assignment_set_id
2536 					  AND   has.business_group_id = g_business_group_id
2537 					  AND   has.assignment_set_id = g_assignment_set_id
2538 					  AND   hasa.assignment_id    = paf.assignment_id
2539 					  AND   paf.person_id         = paaf.person_id)
2540 		OR g_exc_inc = 'E' AND NOT EXISTS(SELECT 1
2541 						    FROM  hr_assignment_set_amendments hasa
2542 							 ,  hr_assignment_sets has
2543 							 ,  per_assignments_f paf
2544 					  WHERE has.assignment_set_id = hasa.assignment_set_id
2545 					  AND   has.business_group_id = g_business_group_id
2546 					  AND   has.assignment_set_id = g_assignment_set_id
2547 					  AND   hasa.assignment_id    = paf.assignment_id
2548 					  AND   paf.person_id         = paaf.person_id
2549 					  )))
2550 	  OR g_assignment_set_id IS NULL)
2551 --
2552 and exists (SELECT paa.assignment_action_id child_assignment_action_id,
2553        prt.run_method run_type
2554 FROM   pay_assignment_actions paa,
2555        pay_run_types_f prt
2556 WHERE  paa.run_type_id = prt.run_type_id
2557 AND    prt.run_method IN ('N','P')
2558 AND    g_qtr_start_date BETWEEN prt.effective_start_date AND prt.effective_end_date
2559 AND    paa.assignment_action_id = (SELECT /*+ USE_NL(paa, ppa) */
2560 				          fnd_number.canonical_to_number(max(paa.assignment_action_id)) child_assignment_action_id
2561 				   FROM   pay_assignment_actions paa,
2562 					  pay_payroll_actions    ppa
2563 				   WHERE
2564 					paa.assignment_id = paaf.assignment_id
2565 					AND    ppa.payroll_action_id = paa.payroll_action_id
2566 					AND    (paa.source_action_id is not null or ppa.action_type in ('I','V','B'))
2567 					AND    ppa.effective_date = (select  max(regular_payment_date)  --max(pay_advice_date)  --bug 7294966
2568 							from per_time_periods
2569 							where payroll_id = paaf.payroll_id
2570 							--and pay_advice_date <= g_qtr_end_date
2571 							and regular_payment_date <= g_qtr_end_date    --bug 7294966
2572 							)
2573 					AND    ppa.action_type in ('R', 'Q', 'I', 'V','B')
2574 					AND    paa.action_status = 'C'
2575 					AND    ppa.effective_date between paaf.effective_start_date AND  paaf.effective_end_date))	--Bug 7294966 QA
2576 /*
2577 group by
2578 decode(paaf.EMPLOYMENT_CATEGORY,'FT','F','FR','F','PR','P','PT','P',paaf.EMPLOYMENT_CATEGORY),
2579 NVL(hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','MPAP',paaf.EMPLOYEE_CATEGORY,paaf.effective_start_date),
2580     NVL(hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','CSSW',paaf.EMPLOYEE_CATEGORY,paaf.effective_start_date),
2581     hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','PTCO',paaf.EMPLOYEE_CATEGORY,paaf.effective_start_date)
2582     )), paaf.person_id
2583 */
2584 )
2585 GROUP BY EMP_CATG, EHECS_CATG;
2586 
2587 l_part1_qtr_end csr_part1_qtr_end%ROWTYPE;
2588 
2589 CURSOR csr_part1_hire_qtr
2590 IS
2591 SELECT COUNT(1) tot, EMP_CATG, EHECS_CATG
2592 FROM
2593 (
2594 SELECT
2595 --decode(count(1),0,0,1) cnt,
2596 distinct
2597 --decode(paaf.EMPLOYMENT_CATEGORY,'FT','F','FR','F','PR','P','PT','P',paaf.EMPLOYMENT_CATEGORY) EMP_CATG,
2598 /* 6856486 */
2599 
2600  decode(paaf.EMPLOYMENT_CATEGORY
2601 	,hruserdt.get_table_value(paaf.business_group_id,'EHECS_ASG_CATG_TAB','Full_Time',paaf.EMPLOYMENT_CATEGORY,g_qtr_start_date),'F'
2602 	,hruserdt.get_table_value(paaf.business_group_id,'EHECS_ASG_CATG_TAB','Part_Time',paaf.EMPLOYMENT_CATEGORY,g_qtr_start_date),'P'
2603 	,hruserdt.get_table_value(paaf.business_group_id,'EHECS_ASG_CATG_TAB','Apprentice_Trainee',paaf.EMPLOYMENT_CATEGORY,g_qtr_start_date),'AT'
2604 	) EMP_CATG,
2605 /*
2606 NVL(hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','MPAP',substr(paaf.EMPLOYEE_CATEGORY,-2,length(paaf.EMPLOYEE_CATEGORY)),paaf.effective_start_date),
2607     NVL(hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','CSSW',substr(paaf.EMPLOYEE_CATEGORY,-2,length(paaf.EMPLOYEE_CATEGORY)),paaf.effective_start_date),
2608         hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','PTCO',substr(paaf.EMPLOYEE_CATEGORY,-2,length(paaf.EMPLOYEE_CATEGORY)),paaf.effective_start_date)
2609         )
2610     ) EHECS_CATG, */
2611 NVL(hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','Managers',paaf.EMPLOYEE_CATEGORY,g_qtr_end_date),
2612     NVL(hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','Clerical Workers',paaf.EMPLOYEE_CATEGORY,g_qtr_end_date),
2613         hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','Production Workers',paaf.EMPLOYEE_CATEGORY,g_qtr_end_date)
2614         )
2615     ) EHECS_CATG,
2616 paaf.assignment_id,
2617 pps.period_of_service_id
2618 from
2619 per_all_assignments_f paaf,
2620 pay_all_payrolls_f papf,
2621 hr_soft_coding_keyflex scl,
2622 per_periods_of_service pps
2623 where
2624 paaf.business_group_id = g_business_group_id
2625 and paaf.payroll_id is not null
2626 and paaf.payroll_id = nvl(g_payroll_id,paaf.payroll_id)
2627 and paaf.payroll_id = papf.payroll_id
2628 and papf.soft_coding_keyflex_id = scl.soft_coding_keyflex_id
2629 and scl.segment4 = g_employer_id
2630 and paaf.employee_category = nvl(g_occupational_category,paaf.employee_category)
2631 and pps.person_id = paaf.person_id
2632 and pps.business_group_id = paaf.business_group_id
2633 and pps.period_of_service_id = paaf.period_of_service_id
2634 and pps.date_start between g_qtr_start_date And g_qtr_end_date
2635 and paaf.effective_start_date between pps.date_start and g_qtr_end_date
2636 --
2637 AND ((g_assignment_set_id is not null
2638 	     AND (g_exc_inc ='I' AND EXISTS(SELECT 1
2639 						    FROM  hr_assignment_set_amendments hasa
2640 							 ,  hr_assignment_sets has
2641 							 ,  per_assignments_f paf
2642 					  WHERE has.assignment_set_id = hasa.assignment_set_id
2643 					  AND   has.business_group_id = g_business_group_id
2644 					  AND   has.assignment_set_id = g_assignment_set_id
2645 					  AND   hasa.assignment_id    = paf.assignment_id
2646 					  AND   paf.person_id         = paaf.person_id)
2647 		OR g_exc_inc = 'E' AND NOT EXISTS(SELECT 1
2648 						    FROM  hr_assignment_set_amendments hasa
2649 							 ,  hr_assignment_sets has
2650 							 ,  per_assignments_f paf
2651 					  WHERE has.assignment_set_id = hasa.assignment_set_id
2652 					  AND   has.business_group_id = g_business_group_id
2653 					  AND   has.assignment_set_id = g_assignment_set_id
2654 					  AND   hasa.assignment_id    = paf.assignment_id
2655 					  AND   paf.person_id         = paaf.person_id
2656 					  )))
2657 	  OR g_assignment_set_id IS NULL)
2658 --
2659 --and g_qtr_start_date between paaf.effective_start_date and paaf.effective_end_date
2660 /*
2661 and (	select min(ptp.pay_advice_date)
2662 	from per_time_periods ptp
2663 	where ptp.payroll_id = paaf.payroll_id
2664 	and ptp.pay_advice_date >= g_qtr_start_date
2665     )
2666 */
2667 /*
2668 and g_qtr_start_date between paaf.effective_start_date and paaf.effective_end_date
2669 and exists (SELECT paa.assignment_action_id child_assignment_action_id,
2670        prt.run_method run_type
2671 FROM   pay_assignment_actions paa,
2672        pay_run_types_f prt
2673 WHERE  paa.run_type_id = prt.run_type_id
2674 AND    prt.run_method IN ('N','P')
2675 AND    g_qtr_start_date BETWEEN prt.effective_start_date AND prt.effective_end_date
2676 AND    paa.assignment_action_id = (SELECT /*+ USE_NL(paa, ppa)
2677 				          fnd_number.canonical_to_number(max(paa.assignment_action_id)) child_assignment_action_id
2678 				   FROM   pay_assignment_actions paa,
2679 					  pay_payroll_actions    ppa
2680 				   WHERE
2681 					paa.assignment_id = paaf.assignment_id
2682 					AND    ppa.payroll_action_id = paa.payroll_action_id
2683 					AND    (paa.source_action_id is not null or ppa.action_type in ('I','V'))
2684 					AND    ppa.effective_date between (select min(pay_advice_date)
2685 									from per_time_periods
2686 									where payroll_id = paaf.payroll_id
2687 									and pay_advice_date >= g_qtr_start_date
2688 									)
2689 								  AND g_qtr_end_date
2690 					AND    ppa.action_type in ('R', 'Q', 'I', 'V')
2691 					AND    paa.action_status = 'C'))
2692 
2693 group by
2694 decode(paaf.employment_category,'FT','F','FR','F','PR','P','PT','P',paaf.employment_category),
2695 
2696 NVL(hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','MPAP',paaf.EMPLOYEE_CATEGORY,paaf.effective_start_date),
2697     NVL(hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','CSSW',paaf.EMPLOYEE_CATEGORY,paaf.effective_start_date),
2698     hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','PTCO',paaf.EMPLOYEE_CATEGORY,paaf.effective_start_date)
2699     )), paaf.person_id, pps.period_of_service_id
2700 */
2701 )
2702 GROUP BY EMP_CATG, EHECS_CATG;
2703 
2704 l_part1_hire_qtr csr_part1_hire_qtr%ROWTYPE;
2705 
2706 CURSOR csr_all_payrolls
2707 IS
2708 select distinct papf.payroll_id
2709 from
2710 per_all_assignments_f paaf,
2711 pay_all_payrolls_f papf,
2712 hr_soft_coding_keyflex scl
2713 where
2714 paaf.business_group_id = g_business_group_id
2715 and paaf.payroll_id is not null
2716 and paaf.payroll_id = nvl(g_payroll_id,paaf.payroll_id)
2717 and paaf.payroll_id = papf.payroll_id
2718 and papf.soft_coding_keyflex_id = scl.soft_coding_keyflex_id
2719 and scl.segment4 = g_employer_id
2720 and paaf.employee_category = nvl(g_occupational_category,paaf.employee_category)
2721 --and paaf.employment_category = 'AT'	--Apprentice
2722  /* 6856486 */
2723 and paaf.employment_category=hruserdt.get_table_value(paaf.business_group_id,'EHECS_ASG_CATG_TAB','Apprentice_Trainee',paaf.EMPLOYMENT_CATEGORY,g_qtr_start_date)
2724 and paaf.effective_start_date <= g_qtr_end_date
2725 and paaf.effective_end_date >= g_qtr_start_date;
2726 
2727 
2728 CURSOR csr_period_dates(p_payroll_id Number)
2729 IS
2730 select pay_advice_date
2731 from per_time_periods ptp
2732 where ptp.payroll_id = p_payroll_id
2733 and ptp.pay_advice_date between g_qtr_start_date and g_qtr_end_date;
2734 
2735 
2736 CURSOR csr_app_mgr_clk_pro(p_payroll_id Number, p_period_date date)
2737 IS
2738 SELECT COUNT(1) tot, EMP_CATG, EHECS_CATG
2739 FROM
2740 (
2741 SELECT
2742 distinct
2743 --decode(paaf.EMPLOYMENT_CATEGORY,'FT','F','FR','F','PR','P','PT','P',paaf.EMPLOYMENT_CATEGORY) EMP_CATG,
2744 /* 6856486 */
2745  decode(paaf.EMPLOYMENT_CATEGORY
2746 	,hruserdt.get_table_value(paaf.business_group_id,'EHECS_ASG_CATG_TAB','Full_Time',paaf.EMPLOYMENT_CATEGORY,g_qtr_start_date),'F'
2747 	,hruserdt.get_table_value(paaf.business_group_id,'EHECS_ASG_CATG_TAB','Part_Time',paaf.EMPLOYMENT_CATEGORY,g_qtr_start_date),'P'
2748 	,hruserdt.get_table_value(paaf.business_group_id,'EHECS_ASG_CATG_TAB','Apprentice_Trainee',paaf.EMPLOYMENT_CATEGORY,g_qtr_start_date),'AT'
2749 	) EMP_CATG,
2750 /*
2751 NVL(hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','MPAP',substr(paaf.EMPLOYEE_CATEGORY,-2,length(paaf.EMPLOYEE_CATEGORY)),paaf.effective_start_date),
2752     NVL(hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','CSSW',substr(paaf.EMPLOYEE_CATEGORY,-2,length(paaf.EMPLOYEE_CATEGORY)),paaf.effective_start_date),
2753         hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','PTCO',substr(paaf.EMPLOYEE_CATEGORY,-2,length(paaf.EMPLOYEE_CATEGORY)),paaf.effective_start_date)
2754         )
2755     ) EHECS_CATG, */
2756 NVL(hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','Managers',paaf.EMPLOYEE_CATEGORY,g_qtr_start_date),
2757     NVL(hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','Clerical Workers',paaf.EMPLOYEE_CATEGORY,g_qtr_start_date),
2758         hruserdt.get_table_value(paaf.business_group_id,'EHECS_CATG_TAB','Production Workers',paaf.EMPLOYEE_CATEGORY,g_qtr_start_date)
2759         )
2760     ) EHECS_CATG,
2761 paaf.assignment_id
2762 from
2763 per_all_assignments_f paaf,
2764 pay_all_payrolls_f papf,
2765 hr_soft_coding_keyflex scl
2766 where
2767 paaf.business_group_id = g_business_group_id
2768 and paaf.payroll_id is not null
2769 and paaf.payroll_id = p_payroll_id
2770 and paaf.payroll_id = papf.payroll_id
2771 and papf.soft_coding_keyflex_id = scl.soft_coding_keyflex_id
2772 and scl.segment4 = g_employer_id
2773 and paaf.employee_category = nvl(g_occupational_category,paaf.employee_category)
2774 --and paaf.employment_category = 'AT'
2775  /* 6856486 */
2776 and paaf.employment_category=hruserdt.get_table_value(paaf.business_group_id,'EHECS_ASG_CATG_TAB','Apprentice_Trainee',paaf.EMPLOYMENT_CATEGORY,g_qtr_start_date)
2777 and paaf.effective_start_date <= g_qtr_end_date
2778 and paaf.effective_end_date >= g_qtr_start_date
2779 --
2780 AND ((g_assignment_set_id is not null
2781 	     AND (g_exc_inc ='I' AND EXISTS(SELECT 1
2782 						    FROM  hr_assignment_set_amendments hasa
2783 							 ,  hr_assignment_sets has
2784 							 ,  per_assignments_f paf
2785 					  WHERE has.assignment_set_id = hasa.assignment_set_id
2786 					  AND   has.business_group_id = g_business_group_id
2787 					  AND   has.assignment_set_id = g_assignment_set_id
2788 					  AND   hasa.assignment_id    = paf.assignment_id
2789 					  AND   paf.person_id         = paaf.person_id)
2790 		OR g_exc_inc = 'E' AND NOT EXISTS(SELECT 1
2791 						    FROM  hr_assignment_set_amendments hasa
2792 							 ,  hr_assignment_sets has
2793 							 ,  per_assignments_f paf
2794 					  WHERE has.assignment_set_id = hasa.assignment_set_id
2795 					  AND   has.business_group_id = g_business_group_id
2796 					  AND   has.assignment_set_id = g_assignment_set_id
2797 					  AND   hasa.assignment_id    = paf.assignment_id
2798 					  AND   paf.person_id         = paaf.person_id
2799 					  )))
2800 	  OR g_assignment_set_id IS NULL)
2801 --
2802 and exists (SELECT paa.assignment_action_id child_assignment_action_id,
2803        prt.run_method run_type
2804 FROM   pay_assignment_actions paa,
2805        pay_run_types_f prt
2806 WHERE  paa.run_type_id = prt.run_type_id
2807 AND    prt.run_method IN ('N','P')
2808 AND    g_qtr_start_date BETWEEN prt.effective_start_date AND prt.effective_end_date
2809 AND    paa.assignment_action_id = (SELECT /*+ USE_NL(paa, ppa) */
2810 				          fnd_number.canonical_to_number(max(paa.assignment_action_id)) child_assignment_action_id
2811 				   FROM   pay_assignment_actions paa,
2812 					    pay_payroll_actions    ppa
2813 				   WHERE
2814 					paa.assignment_id = paaf.assignment_id
2815 					AND    ppa.payroll_action_id = paa.payroll_action_id
2816 					AND    (paa.source_action_id is not null or ppa.action_type in ('I','V','B'))
2817 					AND    ppa.effective_date = p_period_date
2818 					AND    ppa.action_type in ('R', 'Q', 'I', 'V','B')
2819 					AND    paa.action_status = 'C'))
2820 )
2821 GROUP BY EMP_CATG, EHECS_CATG;
2822 
2823 l_fst_ft_mg number := 0;
2824 l_fst_pt_mg number := 0;
2825 
2826 l_fst_ft_cl number := 0;
2827 l_fst_pt_cl number := 0;
2828 
2829 l_fst_ft_ot number := 0;
2830 l_fst_pt_ot number := 0;
2831 
2832 l_lst_ft_mg number := 0;
2833 l_lst_pt_mg number := 0;
2834 
2835 l_lst_ft_cl number := 0;
2836 l_lst_pt_cl number := 0;
2837 
2838 l_lst_ft_ot number := 0;
2839 l_lst_pt_ot number := 0;
2840 
2841 l_hire_ft_mg number := 0;
2842 l_hire_pt_mg number := 0;
2843 
2844 l_hire_ft_cl number := 0;
2845 l_hire_pt_cl number := 0;
2846 
2847 l_hire_ft_ot number := 0;
2848 l_hire_pt_ot number := 0;
2849 
2850 l_number_of_periods Number := 0;
2851 l_cnt_app_mgr Number := 0;
2852 l_cnt_app_clk Number := 0;
2853 l_cnt_app_oth Number := 0;
2854 
2855 l_cnt_app_mgr_final Number := 0;
2856 l_cnt_app_clk_final Number := 0;
2857 l_cnt_app_oth_final Number := 0;
2858 
2859 l_is_gt_0 Varchar2(100);
2860 
2861 begin
2862 
2863 hr_utility.set_location('entering pay_ie_ehecs_report_pkg,gen_footer ',3000);
2864 
2865 l_payroll_action_id := pay_magtape_generic.get_parameter_value('TRANSFER_PAYROLL_ACTION_ID');
2866 hr_utility.set_location('l_payroll_action_id. '||TO_CHAR(l_payroll_action_id),3010);
2867 
2868 
2869 l_tab_get_totals.delete;
2870 hr_utility.set_location('After deleting l_tab_get_totals pltable ',3020);
2871 
2872 --Initializing to prevent the no data found error
2873 l_tab_get_totals('M') := l_get_totals_empty_rec;
2874 l_tab_get_totals('C') := l_get_totals_empty_rec;
2875 l_tab_get_totals('P') := l_get_totals_empty_rec;
2876 
2877 hr_utility.set_location('After initializing l_tab_get_totals pltable ',3030);
2878 
2879 open cur_get_totals(l_payroll_action_id);
2880 loop
2881   fetch cur_get_totals into l_get_totals_rec;
2882   EXIT WHEN cur_get_totals%NOTFOUND;
2883   hr_utility.set_location('Inside cursor cur_get_totals.',3031);
2884   l_tab_get_totals(l_get_totals_rec.ehecs_catg) := l_get_totals_rec;
2885 end loop;
2886 close cur_get_totals;
2887 
2888 hr_utility.set_location('After cursor cur_get_totals ',3040);
2889 
2890 -- Override Values.
2891 l_tab_get_override_totals.delete;
2892 hr_utility.set_location('After deleting l_tab_get_override_totals pltable ',3050);
2893 
2894 --Initializing to prevent the no data found error
2895 l_tab_get_override_totals('M') := l_get_ovrrd_tot_empty_rec;
2896 l_tab_get_override_totals('C') := l_get_ovrrd_tot_empty_rec;
2897 l_tab_get_override_totals('P') := l_get_ovrrd_tot_empty_rec;
2898 
2899 hr_utility.set_location('After initializing l_tab_get_override_totals pltable ',3060);
2900 
2901 open cur_get_override_totals(g_employer_id,g_business_group_id);
2902 loop
2903   fetch cur_get_override_totals into l_get_override_totals_rec;
2904   EXIT WHEN cur_get_override_totals%NOTFOUND;
2905   hr_utility.set_location('Inside cursor cur_get_override_totals.',3061);
2906   l_tab_get_override_totals(l_get_override_totals_rec.ehecs_catg) := l_get_override_totals_rec;
2907 end loop;
2908 close cur_get_override_totals;
2909 
2910 hr_utility.set_location('After Cursor cur_get_override_totals ',3070);
2911 
2912 OPEN csr_ehecs_eit(g_employer_id, g_business_group_id, g_year, g_quarter);
2913 FETCH csr_ehecs_eit INTO l_csr_ehecs_eit;
2914 CLOSE csr_ehecs_eit;
2915 
2916 hr_utility.set_location('After Cursor csr_ehecs_eit ',3080);
2917 
2918 OPEN csr_part1_qtr_start;
2919 LOOP
2920 FETCH csr_part1_qtr_start INTO l_part1_qtr_start;
2921 EXIT WHEN csr_part1_qtr_start%NOTFOUND;
2922 hr_utility.set_location('Inside Cursor csr_part1_qtr_start ',3085);
2923 hr_utility.set_location('l_part1_qtr_start.EMP_CATG '||l_part1_qtr_start.EMP_CATG,3086);
2924 hr_utility.set_location('l_part1_qtr_start.EHECS_CATG '||l_part1_qtr_start.EHECS_CATG,3087);
2925 
2926 	IF l_part1_qtr_start.EMP_CATG = 'F' AND l_part1_qtr_start.EHECS_CATG = 'M' THEN
2927 		l_fst_ft_mg := l_part1_qtr_start.tot;
2928 	ELSIF l_part1_qtr_start.EMP_CATG = 'F' AND l_part1_qtr_start.EHECS_CATG = 'C' THEN
2929 		l_fst_ft_cl := l_part1_qtr_start.tot;
2930 	ELSIF l_part1_qtr_start.EMP_CATG = 'F' AND l_part1_qtr_start.EHECS_CATG = 'P' THEN
2931 		l_fst_ft_ot := l_part1_qtr_start.tot;
2932 	ELSIF l_part1_qtr_start.EMP_CATG = 'P' AND l_part1_qtr_start.EHECS_CATG = 'M' THEN
2933 		l_fst_pt_mg := l_part1_qtr_start.tot;
2934 	ELSIF l_part1_qtr_start.EMP_CATG = 'P' AND l_part1_qtr_start.EHECS_CATG = 'C' THEN
2935 		l_fst_pt_cl := l_part1_qtr_start.tot;
2936 	ELSIF l_part1_qtr_start.EMP_CATG = 'P' AND l_part1_qtr_start.EHECS_CATG = 'P' THEN
2937 		l_fst_pt_ot := l_part1_qtr_start.tot;
2938 	END IF;
2939 END LOOP;
2940 CLOSE csr_part1_qtr_start;
2941 
2942 hr_utility.set_location('l_fst_ft_mg'||l_fst_ft_mg,3085);
2943 hr_utility.set_location('l_fst_ft_cl'||l_fst_ft_cl,3085);
2944 hr_utility.set_location('l_fst_ft_ot'||l_fst_ft_ot,3085);
2945 hr_utility.set_location('l_fst_pt_mg'||l_fst_pt_mg,3085);
2946 hr_utility.set_location('l_fst_pt_cl'||l_fst_pt_cl,3085);
2947 hr_utility.set_location('l_fst_pt_ot'||l_fst_pt_ot,3085);
2948 
2949 
2950 hr_utility.set_location('After Cursor csr_part1_qtr_start ',3090);
2951 
2952 OPEN csr_part1_qtr_end;
2953 LOOP
2954 FETCH csr_part1_qtr_end INTO l_part1_qtr_end;
2955 EXIT WHEN csr_part1_qtr_end%NOTFOUND;
2956 hr_utility.set_location('Inside Cursor csr_part1_qtr_end ',3091);
2957 hr_utility.set_location('l_part1_qtr_end.EMP_CATG '||l_part1_qtr_end.EMP_CATG,3092);
2958 hr_utility.set_location('l_part1_qtr_end.EHECS_CATG  '||l_part1_qtr_end.EHECS_CATG,3093);
2959 
2960 	IF l_part1_qtr_end.EMP_CATG = 'F' AND l_part1_qtr_end.EHECS_CATG = 'M' THEN
2961 		l_lst_ft_mg := l_part1_qtr_end.tot;
2962 	ELSIF l_part1_qtr_end.EMP_CATG = 'F' AND l_part1_qtr_end.EHECS_CATG = 'C' THEN
2963 		l_lst_ft_cl := l_part1_qtr_end.tot;
2964 	ELSIF l_part1_qtr_end.EMP_CATG = 'F' AND l_part1_qtr_end.EHECS_CATG = 'P' THEN
2965 		l_lst_ft_ot := l_part1_qtr_end.tot;
2966 	ELSIF l_part1_qtr_end.EMP_CATG = 'P' AND l_part1_qtr_end.EHECS_CATG = 'M' THEN
2967 		l_lst_pt_mg := l_part1_qtr_end.tot;
2968 	ELSIF l_part1_qtr_end.EMP_CATG = 'P' AND l_part1_qtr_end.EHECS_CATG = 'C' THEN
2969 		l_lst_pt_cl := l_part1_qtr_end.tot;
2970 	ELSIF l_part1_qtr_end.EMP_CATG = 'P' AND l_part1_qtr_end.EHECS_CATG = 'P' THEN
2971 		l_lst_pt_ot := l_part1_qtr_end.tot;
2972 	END IF;
2973 END LOOP;
2974 CLOSE csr_part1_qtr_end;
2975 
2976 hr_utility.set_location('l_lst_ft_mg'||l_lst_ft_mg,3095);
2977 hr_utility.set_location('l_lst_ft_cl'||l_lst_ft_cl,3095);
2978 hr_utility.set_location('l_lst_ft_ot'||l_lst_ft_ot,3095);
2979 hr_utility.set_location('l_lst_pt_mg'||l_lst_pt_mg,3095);
2980 hr_utility.set_location('l_lst_pt_cl'||l_lst_pt_cl,3095);
2981 hr_utility.set_location('l_lst_pt_ot'||l_lst_pt_ot,3095);
2982 
2983 hr_utility.set_location('After Cursor csr_part1_qtr_end ',3100);
2984 
2985 OPEN csr_part1_hire_qtr;
2986 LOOP
2987 FETCH csr_part1_hire_qtr INTO l_part1_hire_qtr;
2988 EXIT WHEN csr_part1_hire_qtr%NOTFOUND;
2989 hr_utility.set_location('Inside Cursor csr_part1_hire_qtr ',3101);
2990 hr_utility.set_location('l_part1_hire_qtr.EMP_CATG '||l_part1_hire_qtr.EMP_CATG,3102);
2991 hr_utility.set_location('l_part1_hire_qtr.EHECS_CATG  '||l_part1_hire_qtr.EHECS_CATG,3103);
2992 
2993 	IF l_part1_hire_qtr.EMP_CATG = 'F' AND l_part1_hire_qtr.EHECS_CATG = 'M' THEN
2994 		l_hire_ft_mg := l_part1_hire_qtr.tot;
2995 	ELSIF l_part1_hire_qtr.EMP_CATG = 'F' AND l_part1_hire_qtr.EHECS_CATG = 'C' THEN
2996 		l_hire_ft_cl := l_part1_hire_qtr.tot;
2997 	ELSIF l_part1_hire_qtr.EMP_CATG = 'F' AND l_part1_hire_qtr.EHECS_CATG = 'P' THEN
2998 		l_hire_ft_ot := l_part1_hire_qtr.tot;
2999 	ELSIF l_part1_hire_qtr.EMP_CATG = 'P' AND l_part1_hire_qtr.EHECS_CATG = 'M' THEN
3000 		l_hire_pt_mg := l_part1_hire_qtr.tot;
3001 	ELSIF l_part1_hire_qtr.EMP_CATG = 'P' AND l_part1_hire_qtr.EHECS_CATG = 'C' THEN
3002 		l_hire_pt_cl := l_part1_hire_qtr.tot;
3003 	ELSIF l_part1_hire_qtr.EMP_CATG = 'P' AND l_part1_hire_qtr.EHECS_CATG = 'P' THEN
3004 		l_hire_pt_ot := l_part1_hire_qtr.tot;
3005 	END IF;
3006 END LOOP;
3007 CLOSE csr_part1_hire_qtr;
3008 
3009 hr_utility.set_location('l_hire_ft_mg'||l_hire_ft_mg,3095);
3010 hr_utility.set_location('l_hire_ft_cl'||l_hire_ft_cl,3095);
3011 hr_utility.set_location('l_hire_ft_ot'||l_hire_ft_ot,3095);
3012 hr_utility.set_location('l_hire_pt_mg'||l_hire_pt_mg,3095);
3013 hr_utility.set_location('l_hire_pt_cl'||l_hire_pt_cl,3095);
3014 hr_utility.set_location('l_hire_pt_ot'||l_hire_pt_ot,3095);
3015 
3016 hr_utility.set_location('After Cursor csr_part1_hire_qtr ',3110);
3017 
3018 l_cnt_app_mgr_final := 0;
3019 l_cnt_app_clk_final := 0;
3020 l_cnt_app_oth_final := 0;
3021 
3022 hr_utility.set_location('Before Cursor csr_all_payrolls ',3130);
3023 
3024 FOR pyr_index IN csr_all_payrolls
3025 LOOP
3026 hr_utility.set_location('Inside Cursor csr_all_payrolls ',3140);
3027 	l_number_of_periods := 0;
3028 	FOR prd_index IN csr_period_dates(pyr_index.payroll_id)
3029 	LOOP
3030 hr_utility.set_location('Inside Cursor csr_period_dates ',3150);
3031 hr_utility.set_location('l_number_of_periods '||l_number_of_periods,3150);
3032 		l_number_of_periods := l_number_of_periods + 1;
3033 		FOR asg_index IN csr_app_mgr_clk_pro(pyr_index.payroll_id, prd_index.pay_advice_date)
3034 		LOOP
3035 hr_utility.set_location('Inside Cursor csr_app_mgr_clk_pro ',3160);
3036 hr_utility.set_location('asg_index.EHECS_CATG '||asg_index.EHECS_CATG,3160);
3037 hr_utility.set_location('l_cnt_app_mgr '||l_cnt_app_mgr,3160);
3038 hr_utility.set_location('l_cnt_app_clk '||l_cnt_app_clk,3160);
3039 hr_utility.set_location('l_cnt_app_oth '||l_cnt_app_oth,3160);
3040 hr_utility.set_location('asg_index.tot '||asg_index.tot,3160);
3041 
3042 			IF asg_index.EHECS_CATG = 'M' THEN
3043 				l_cnt_app_mgr := l_cnt_app_mgr + asg_index.tot;
3044 			ELSIF asg_index.EHECS_CATG = 'C' THEN
3045 				l_cnt_app_clk := l_cnt_app_clk + asg_index.tot;
3046 			ELSIF asg_index.EHECS_CATG = 'P' THEN
3047 				l_cnt_app_oth := l_cnt_app_oth + asg_index.tot;
3048 			END IF;
3049 		END LOOP;
3050 	END LOOP;
3051 
3052 	IF l_number_of_periods > 0 THEN
3053 	hr_utility.set_location('Inside IF l_number_of_periods > 0 before ',3170);
3054 	hr_utility.set_location('l_cnt_app_mgr_final '||l_cnt_app_mgr_final,3170);
3055 	hr_utility.set_location('l_cnt_app_mgr '||l_cnt_app_mgr,3170);
3056 
3057 	hr_utility.set_location('l_cnt_app_clk_final '||l_cnt_app_clk_final,3170);
3058 	hr_utility.set_location('l_cnt_app_clk '||l_cnt_app_clk,3170);
3059 
3060 	hr_utility.set_location('l_cnt_app_oth_final '||l_cnt_app_oth_final,3170);
3061 	hr_utility.set_location('l_cnt_app_oth '||l_cnt_app_oth,3170);
3062 
3063 		l_cnt_app_mgr_final := l_cnt_app_mgr_final + ROUND(l_cnt_app_mgr/l_number_of_periods);
3064 		l_cnt_app_clk_final := l_cnt_app_clk_final + ROUND(l_cnt_app_clk/l_number_of_periods);
3065 		l_cnt_app_oth_final := l_cnt_app_oth_final + ROUND(l_cnt_app_oth/l_number_of_periods);
3066 
3067 	hr_utility.set_location('Inside IF l_number_of_periods > 0 after ',3170);
3068 	hr_utility.set_location('l_cnt_app_mgr_final '||l_cnt_app_mgr_final,3170);
3069 	hr_utility.set_location('l_cnt_app_clk_final '||l_cnt_app_clk_final,3170);
3070 	hr_utility.set_location('l_cnt_app_oth_final '||l_cnt_app_oth_final,3170);
3071 	END IF;
3072 
3073 END LOOP;
3074 
3075 
3076 hr_utility.set_location('l_payroll_action_id. '||TO_CHAR(l_payroll_action_id),3180);
3077 hr_utility.set_location('Before Inserting IE_EHECS_PART1 ',3190);
3078 
3079     pay_action_information_api.create_action_information
3080     ( p_action_information_id => l_action_info_id
3081     ,p_action_context_id => l_payroll_action_id
3082     ,p_action_context_type => 'PA'
3083     ,p_object_version_number => l_ovn
3084     ,p_effective_date => g_archive_effective_date --g_end_date
3085     ,p_source_id => NULL
3086     ,p_source_text => NULL
3087     ,p_action_information_category => 'IE_EHECS_PART1'
3088     ,p_action_information1 =>  l_fst_ft_mg
3089     ,p_action_information2 =>  l_fst_ft_cl
3090     ,p_action_information3 =>  l_fst_ft_ot
3091     ,p_action_information4 =>  l_lst_ft_mg
3092     ,p_action_information5 =>  l_lst_ft_cl
3093     ,p_action_information6  => l_lst_ft_ot
3094     ,p_action_information7  => l_hire_ft_mg
3095     ,p_action_information8  => l_hire_ft_cl
3096     ,p_action_information9  => l_hire_ft_ot
3097     ,p_action_information10 => l_fst_pt_mg
3098     ,p_action_information11 => l_fst_pt_cl
3099     ,p_action_information12 => l_fst_pt_ot
3100     ,p_action_information13 => l_lst_pt_mg
3101     ,p_action_information14 => l_lst_pt_cl
3102     ,p_action_information15 => l_lst_pt_ot
3103     ,p_action_information16 => l_hire_pt_mg
3104     ,p_action_information17 => l_hire_pt_cl
3105     ,p_action_information18 => l_hire_pt_ot
3106     ,p_action_information19 => l_cnt_app_mgr_final
3107     ,p_action_information20 => l_cnt_app_clk_final
3108     ,p_action_information21 => l_cnt_app_oth_final
3109     ,p_action_information22 => l_csr_ehecs_eit.avg_mgr_not_pyrl
3110     ,p_action_information23 => l_csr_ehecs_eit.avg_clk_not_pyrl
3111     ,p_action_information24 => l_csr_ehecs_eit.avg_prod_not_pyrl
3112     ,p_action_information25 => l_csr_ehecs_eit.Job_Vac_Mgr
3113     ,p_action_information26 => l_csr_ehecs_eit.Job_Vac_clk
3114     ,p_action_information27 => l_csr_ehecs_eit.Job_Vac_prod
3115     ,p_action_information28 => NVL(l_tab_get_override_totals('M').l_sum_nmw,l_tab_get_totals('M').nmw_pt_ft_mg_cl_ot)
3116     ,p_action_information29 => NVL(l_tab_get_override_totals('C').l_sum_nmw,l_tab_get_totals('C').nmw_pt_ft_mg_cl_ot)
3117     ,p_action_information30 => NVL(l_tab_get_override_totals('P').l_sum_nmw,l_tab_get_totals('P').nmw_pt_ft_mg_cl_ot)
3118     );
3119 
3120 hr_utility.set_location('After Inserting IE_EHECS_PART1 ',3200);
3121 
3122 l_appwgmg :=   NVL(l_tab_get_override_totals('M').l_sum_regwg_at,NVL(l_tab_get_totals('M').regwg_at_mg_cl_ot,0))
3123 	     + NVL(l_tab_get_override_totals('M').l_sum_ovrt_at,NVL(l_tab_get_totals('M').ovrt_at_mg_cl_ot,0))
3124 	     + NVL(l_tab_get_override_totals('M').l_sum_irrb_at,NVL(l_tab_get_totals('M').irrb_at_mg_cl_ot,0));
3125 
3126 l_appwgcl :=   NVL(l_tab_get_override_totals('C').l_sum_regwg_at,NVL(l_tab_get_totals('C').regwg_at_mg_cl_ot,0))
3127 	     + NVL(l_tab_get_override_totals('C').l_sum_ovrt_at,NVL(l_tab_get_totals('C').ovrt_at_mg_cl_ot,0))
3128 	     + NVL(l_tab_get_override_totals('C').l_sum_irrb_at,NVL(l_tab_get_totals('C').irrb_at_mg_cl_ot,0));
3129 
3130 l_appwgot :=   NVL(l_tab_get_override_totals('P').l_sum_regwg_at,NVL(l_tab_get_totals('P').regwg_at_mg_cl_ot,0))
3131 	     + NVL(l_tab_get_override_totals('P').l_sum_ovrt_at,NVL(l_tab_get_totals('P').ovrt_at_mg_cl_ot,0))
3132 	     + NVL(l_tab_get_override_totals('P').l_sum_irrb_at,NVL(l_tab_get_totals('P').irrb_at_mg_cl_ot,0));
3133 
3134 hr_utility.set_location('Before Inserting IE_EHECS_PART2 ',3210);
3135 
3136     pay_action_information_api.create_action_information
3137     ( p_action_information_id => l_action_info_id
3138     ,p_action_context_id => l_payroll_action_id
3139     ,p_action_context_type => 'PA'
3140     ,p_object_version_number => l_ovn
3141     ,p_effective_date => g_archive_effective_date  --g_end_date
3142     ,p_source_id => NULL
3143     ,p_source_text => NULL
3144     ,p_action_information_category => 'IE_EHECS_PART2'
3145     ,p_action_information1 => NVL(l_tab_get_override_totals('M').l_sum_regwg_ft,NVL(l_tab_get_totals('M').regwg_ft_mg_cl_ot,0))
3146     ,p_action_information2 => NVL(l_tab_get_override_totals('C').l_sum_regwg_ft,NVL(l_tab_get_totals('C').regwg_ft_mg_cl_ot,0))
3147     ,p_action_information3 => NVL(l_tab_get_override_totals('P').l_sum_regwg_ft,NVL(l_tab_get_totals('P').regwg_ft_mg_cl_ot,0))
3148     ,p_action_information4 => NVL(l_tab_get_override_totals('M').l_sum_ovrt_ft,NVL(l_tab_get_totals('M').ovrt_ft_mg_cl_ot,0))
3149     ,p_action_information5 => NVL(l_tab_get_override_totals('C').l_sum_ovrt_ft,NVL(l_tab_get_totals('C').ovrt_ft_mg_cl_ot,0))
3150     ,p_action_information6  => NVL(l_tab_get_override_totals('P').l_sum_ovrt_ft,NVL(l_tab_get_totals('P').ovrt_ft_mg_cl_ot,0))
3151     ,p_action_information7  => NVL(l_tab_get_override_totals('M').l_sum_irrb_ft,NVL(l_tab_get_totals('M').irrb_ft_mg_cl_ot,0))
3152     ,p_action_information8  => NVL(l_tab_get_override_totals('C').l_sum_irrb_ft,NVL(l_tab_get_totals('C').irrb_ft_mg_cl_ot,0))
3153     ,p_action_information9  => NVL(l_tab_get_override_totals('P').l_sum_irrb_ft,NVL(l_tab_get_totals('P').irrb_ft_mg_cl_ot,0))
3154     ,p_action_information10 => NVL(l_tab_get_override_totals('M').l_sum_regwg_pt,NVL(l_tab_get_totals('M').regwg_pt_mg_cl_ot,0))
3155     ,p_action_information11 => NVL(l_tab_get_override_totals('C').l_sum_regwg_pt,NVL(l_tab_get_totals('C').regwg_pt_mg_cl_ot,0))
3156     ,p_action_information12 => NVL(l_tab_get_override_totals('P').l_sum_regwg_pt,NVL(l_tab_get_totals('P').regwg_pt_mg_cl_ot,0))
3157     ,p_action_information13 => NVL(l_tab_get_override_totals('M').l_sum_ovrt_pt,NVL(l_tab_get_totals('M').ovrt_pt_mg_cl_ot,0))
3158     ,p_action_information14 => NVL(l_tab_get_override_totals('C').l_sum_ovrt_pt,NVL(l_tab_get_totals('C').ovrt_pt_mg_cl_ot,0))
3159     ,p_action_information15 => NVL(l_tab_get_override_totals('P').l_sum_ovrt_pt,NVL(l_tab_get_totals('P').ovrt_pt_mg_cl_ot,0))
3160     ,p_action_information16 => NVL(l_tab_get_override_totals('M').l_sum_irrb_pt,NVL(l_tab_get_totals('M').irrb_pt_mg_cl_ot,0))
3161     ,p_action_information17 => NVL(l_tab_get_override_totals('C').l_sum_irrb_pt,NVL(l_tab_get_totals('C').irrb_pt_mg_cl_ot,0))
3162     ,p_action_information18 => NVL(l_tab_get_override_totals('P').l_sum_irrb_pt,NVL(l_tab_get_totals('P').irrb_pt_mg_cl_ot,0))
3163     ,p_action_information19 => l_appwgmg
3164     ,p_action_information20 => l_appwgcl
3165     ,p_action_information21 => l_appwgot
3166     );
3167 
3168 hr_utility.set_location('After Inserting IE_EHECS_PART2 ',3220);
3169 
3170     pay_action_information_api.create_action_information
3171     ( p_action_information_id => l_action_info_id
3172     ,p_action_context_id => l_payroll_action_id
3173     ,p_action_context_type => 'PA'
3174     ,p_object_version_number => l_ovn
3175     ,p_effective_date => g_archive_effective_date --g_end_date
3176     ,p_source_id => NULL
3177     ,p_source_text => NULL
3178     ,p_action_information_category => 'IE_EHECS_PART3'
3179     ,p_action_information1  => NVL(l_tab_get_override_totals('M').l_sum_chrs_ft,NVL(l_tab_get_totals('M').chrs_ft_mg_cl_ot,0))
3180     ,p_action_information2  => NVL(l_tab_get_override_totals('C').l_sum_chrs_ft,NVL(l_tab_get_totals('C').chrs_ft_mg_cl_ot,0))
3181     ,p_action_information3  => NVL(l_tab_get_override_totals('P').l_sum_chrs_ft,NVL(l_tab_get_totals('P').chrs_ft_mg_cl_ot,0))
3182     ,p_action_information4  => NVL(l_tab_get_override_totals('M').l_sum_othr_ft,NVL(l_tab_get_totals('M').othr_ft_mg_cl_ot,0))
3183     ,p_action_information5  => NVL(l_tab_get_override_totals('C').l_sum_othr_ft,NVL(l_tab_get_totals('C').othr_ft_mg_cl_ot,0))
3184     ,p_action_information6  => NVL(l_tab_get_override_totals('P').l_sum_othr_ft,NVL(l_tab_get_totals('P').othr_ft_mg_cl_ot,0))
3185     ,p_action_information7  => NVL(l_tab_get_override_totals('M').l_sum_chrs_pt,NVL(l_tab_get_totals('M').chrs_pt_mg_cl_ot,0))
3186     ,p_action_information8  => NVL(l_tab_get_override_totals('C').l_sum_chrs_pt,NVL(l_tab_get_totals('C').chrs_pt_mg_cl_ot,0))
3187     ,p_action_information9  => NVL(l_tab_get_override_totals('P').l_sum_chrs_pt,NVL(l_tab_get_totals('P').chrs_pt_mg_cl_ot,0))
3188     ,p_action_information10 => NVL(l_tab_get_override_totals('M').l_sum_othr_pt,NVL(l_tab_get_totals('M').othr_pt_mg_cl_ot,0))
3189     ,p_action_information11 => NVL(l_tab_get_override_totals('C').l_sum_othr_pt,NVL(l_tab_get_totals('C').othr_pt_mg_cl_ot,0))
3190     ,p_action_information12 => NVL(l_tab_get_override_totals('P').l_sum_othr_pt,NVL(l_tab_get_totals('P').othr_pt_mg_cl_ot,0))
3191     ,p_action_information13 => NVL(l_tab_get_override_totals('M').l_sum_chrs_at,NVL(l_tab_get_totals('M').chrs_at_mg_cl_ot,0))
3192     ,p_action_information14 => NVL(l_tab_get_override_totals('C').l_sum_chrs_at,NVL(l_tab_get_totals('C').chrs_at_mg_cl_ot,0))
3193     ,p_action_information15 => NVL(l_tab_get_override_totals('P').l_sum_chrs_at,NVL(l_tab_get_totals('P').chrs_at_mg_cl_ot,0))
3194     ,p_action_information16 => NVL(l_tab_get_override_totals('M').l_sum_othr_at,NVL(l_tab_get_totals('M').othr_at_mg_cl_ot,0))
3195     ,p_action_information17 => NVL(l_tab_get_override_totals('C').l_sum_othr_at,NVL(l_tab_get_totals('C').othr_at_mg_cl_ot,0))
3196     ,p_action_information18 => NVL(l_tab_get_override_totals('P').l_sum_othr_at,NVL(l_tab_get_totals('P').othr_at_mg_cl_ot,0))
3197     );
3198 
3199 hr_utility.set_location('After Inserting IE_EHECS_PART3 ',3230);
3200 
3201 /* 6856473 */
3202 hr_utility.set_location(' l_tab_get_totals:M.al_at_mg_cl_ot  ' || l_tab_get_totals('M').al_at_mg_cl_ot,3230);
3203 hr_utility.set_location(' l_tab_get_totals:C.al_at_mg_cl_ot  ' || l_tab_get_totals('C').al_at_mg_cl_ot,3230);
3204 hr_utility.set_location(' l_tab_get_totals:P.al_at_mg_cl_ot  ' || l_tab_get_totals('P').al_at_mg_cl_ot,3230);
3205 
3206 
3207 l_lapmg :=   NVL(l_tab_get_override_totals('M').l_sum_al_at,NVL(l_tab_get_totals('M').al_at_mg_cl_ot,0))  -- 6856473
3208 	     + NVL(l_tab_get_override_totals('M').l_sum_mat_at,NVL(l_tab_get_totals('M').mat_at_mg_cl_ot,0))
3209 	     + NVL(l_tab_get_override_totals('M').l_sum_sic_at,NVL(l_tab_get_totals('M').sic_at_mg_cl_ot,0))
3210 	     + NVL(l_tab_get_override_totals('M').l_sum_otl_at,NVL(l_tab_get_totals('M').otl_at_mg_cl_ot,0));
3211 
3212 l_lapcl :=   NVL(l_tab_get_override_totals('C').l_sum_al_at,NVL(l_tab_get_totals('C').al_at_mg_cl_ot,0)) -- 6856473
3213 	     + NVL(l_tab_get_override_totals('C').l_sum_mat_at,NVL(l_tab_get_totals('C').mat_at_mg_cl_ot,0))
3214 	     + NVL(l_tab_get_override_totals('C').l_sum_sic_at,NVL(l_tab_get_totals('C').sic_at_mg_cl_ot,0))
3215 	     + NVL(l_tab_get_override_totals('C').l_sum_otl_at,NVL(l_tab_get_totals('C').otl_at_mg_cl_ot,0));
3216 
3217 l_lapot :=   NVL(l_tab_get_override_totals('P').l_sum_al_at,NVL(l_tab_get_totals('P').al_at_mg_cl_ot,0)) -- 6856473
3218 	     + NVL(l_tab_get_override_totals('P').l_sum_mat_at,NVL(l_tab_get_totals('P').mat_at_mg_cl_ot,0))
3219 	     + NVL(l_tab_get_override_totals('P').l_sum_sic_at,NVL(l_tab_get_totals('P').sic_at_mg_cl_ot,0))
3220 	     + NVL(l_tab_get_override_totals('P').l_sum_otl_at,NVL(l_tab_get_totals('P').otl_at_mg_cl_ot,0));
3221 
3222 hr_utility.set_location('Before Inserting IE_EHECS_PART4 ',3240);
3223 
3224 /* 6856473 */
3225 hr_utility.set_location(' l_tab_get_totals:M.al_ft_mg_cl_ot  ' || l_tab_get_totals('M').al_ft_mg_cl_ot,3230);
3226 hr_utility.set_location(' l_tab_get_totals:C.al_ft_mg_cl_ot  ' || l_tab_get_totals('C').al_ft_mg_cl_ot,3230);
3227 hr_utility.set_location(' l_tab_get_totals:P.al_ft_mg_cl_ot  ' || l_tab_get_totals('P').al_ft_mg_cl_ot,3230);
3228 
3229 
3230 hr_utility.set_location(' l_tab_get_totals:M.al_pt_mg_cl_ot  ' || l_tab_get_totals('M').al_pt_mg_cl_ot,3230);
3231 hr_utility.set_location(' l_tab_get_totals:C.al_pt_mg_cl_ot  ' || l_tab_get_totals('C').al_pt_mg_cl_ot,3230);
3232 hr_utility.set_location(' l_tab_get_totals:Pal_pt_mg_cl_ot  ' || l_tab_get_totals('P').al_pt_mg_cl_ot,3230);
3233     pay_action_information_api.create_action_information
3234     ( p_action_information_id => l_action_info_id
3235     ,p_action_context_id => l_payroll_action_id
3236     ,p_action_context_type => 'PA'
3237     ,p_object_version_number => l_ovn
3238     ,p_effective_date => g_archive_effective_date --g_end_date
3239     ,p_source_id => NULL
3240     ,p_source_text => NULL
3241     ,p_action_information_category => 'IE_EHECS_PART4'
3242     ,p_action_information1  => NVL(l_tab_get_override_totals('M').l_sum_al_ft,NVL(l_tab_get_totals('M').al_ft_mg_cl_ot,0)) -- 6856473
3243     ,p_action_information2  => NVL(l_tab_get_override_totals('C').l_sum_al_ft,NVL(l_tab_get_totals('C').al_ft_mg_cl_ot,0)) -- 6856473
3244     ,p_action_information3  => NVL(l_tab_get_override_totals('P').l_sum_al_ft,NVL(l_tab_get_totals('P').al_ft_mg_cl_ot,0)) -- 6856473
3245     ,p_action_information4  => NVL(l_tab_get_override_totals('M').l_sum_mat_ft,NVL(l_tab_get_totals('M').mat_ft_mg_cl_ot,0))
3246     ,p_action_information5  => NVL(l_tab_get_override_totals('C').l_sum_mat_ft,NVL(l_tab_get_totals('C').mat_ft_mg_cl_ot,0))
3247     ,p_action_information6  => NVL(l_tab_get_override_totals('P').l_sum_mat_ft,NVL(l_tab_get_totals('P').mat_ft_mg_cl_ot,0))
3248     ,p_action_information7  => NVL(l_tab_get_override_totals('M').l_sum_sic_ft,NVL(l_tab_get_totals('M').sic_ft_mg_cl_ot,0))
3249     ,p_action_information8  => NVL(l_tab_get_override_totals('C').l_sum_sic_ft,NVL(l_tab_get_totals('C').sic_ft_mg_cl_ot,0))
3250     ,p_action_information9  => NVL(l_tab_get_override_totals('P').l_sum_sic_ft,NVL(l_tab_get_totals('P').sic_ft_mg_cl_ot,0))
3251     ,p_action_information10 => NVL(l_tab_get_override_totals('M').l_sum_otl_ft,NVL(l_tab_get_totals('M').otl_ft_mg_cl_ot,0))
3252     ,p_action_information11 => NVL(l_tab_get_override_totals('C').l_sum_otl_ft,NVL(l_tab_get_totals('C').otl_ft_mg_cl_ot,0))
3253     ,p_action_information12 => NVL(l_tab_get_override_totals('P').l_sum_otl_ft,NVL(l_tab_get_totals('P').otl_ft_mg_cl_ot,0))
3254     ,p_action_information13 => NVL(l_tab_get_override_totals('M').l_sum_al_pt,NVL(l_tab_get_totals('M').al_pt_mg_cl_ot,0)) -- 6856473
3255     ,p_action_information14 => NVL(l_tab_get_override_totals('C').l_sum_al_pt,NVL(l_tab_get_totals('C').al_pt_mg_cl_ot,0)) -- 6856473
3256     ,p_action_information15 => NVL(l_tab_get_override_totals('P').l_sum_al_pt,NVL(l_tab_get_totals('P').al_pt_mg_cl_ot,0)) -- 6856473
3257     ,p_action_information16 => NVL(l_tab_get_override_totals('M').l_sum_mat_pt,NVL(l_tab_get_totals('M').mat_pt_mg_cl_ot,0))
3258     ,p_action_information17 => NVL(l_tab_get_override_totals('C').l_sum_mat_pt,NVL(l_tab_get_totals('C').mat_pt_mg_cl_ot,0))
3259     ,p_action_information18 => NVL(l_tab_get_override_totals('P').l_sum_mat_pt,NVL(l_tab_get_totals('P').mat_pt_mg_cl_ot,0))
3260     ,p_action_information19 => NVL(l_tab_get_override_totals('M').l_sum_sic_pt,NVL(l_tab_get_totals('M').sic_pt_mg_cl_ot,0))
3261     ,p_action_information20 => NVL(l_tab_get_override_totals('C').l_sum_sic_pt,NVL(l_tab_get_totals('C').sic_pt_mg_cl_ot,0))
3262     ,p_action_information21 => NVL(l_tab_get_override_totals('P').l_sum_sic_pt,NVL(l_tab_get_totals('P').sic_pt_mg_cl_ot,0))
3263     ,p_action_information22 => NVL(l_tab_get_override_totals('M').l_sum_otl_pt,NVL(l_tab_get_totals('M').otl_pt_mg_cl_ot,0))
3264     ,p_action_information23 => NVL(l_tab_get_override_totals('C').l_sum_otl_pt,NVL(l_tab_get_totals('C').otl_pt_mg_cl_ot,0))
3265     ,p_action_information24 => NVL(l_tab_get_override_totals('P').l_sum_otl_pt,NVL(l_tab_get_totals('P').otl_pt_mg_cl_ot,0))
3266     ,p_action_information25 => l_lapmg
3267     ,p_action_information26 => l_lapcl
3268     ,p_action_information27 => l_lapot
3269 );
3270 
3271 hr_utility.set_location('After Inserting IE_EHECS_PART4 ',3250);
3272 
3273 l_ssecapmg :=   NVL(l_tab_get_totals('M').prsi_at_mg_cl_ot,0)
3274 	     + NVL(l_tab_get_override_totals('M').l_sum_incc_at,NVL(l_tab_get_totals('M').incct_at_mg_cl_ot,0))
3275 	     + NVL(l_tab_get_override_totals('M').l_sum_red_at,NVL(l_tab_get_totals('M').red_at_mg_cl_ot,0))
3276 	     + NVL(l_tab_get_override_totals('M').l_sum_otsoc_at,NVL(l_tab_get_totals('M').otsoc_at_mg_cl_ot,0));
3277 
3278 l_ssecapcl :=    NVL(l_tab_get_totals('C').prsi_at_mg_cl_ot,0)
3279 	     + NVL(l_tab_get_override_totals('C').l_sum_incc_at,NVL(l_tab_get_totals('C').incct_at_mg_cl_ot,0))
3280 	     + NVL(l_tab_get_override_totals('C').l_sum_red_at,NVL(l_tab_get_totals('C').red_at_mg_cl_ot,0))
3281 	     + NVL(l_tab_get_override_totals('C').l_sum_otsoc_at,NVL(l_tab_get_totals('C').otsoc_at_mg_cl_ot,0));
3282 
3283 l_ssecapot :=   NVL(l_tab_get_totals('P').prsi_at_mg_cl_ot,0)
3284 	     + NVL(l_tab_get_override_totals('P').l_sum_incc_at,NVL(l_tab_get_totals('P').incct_at_mg_cl_ot,0))
3285 	     + NVL(l_tab_get_override_totals('P').l_sum_red_at,NVL(l_tab_get_totals('P').red_at_mg_cl_ot,0))
3286 	     + NVL(l_tab_get_override_totals('P').l_sum_otsoc_at,NVL(l_tab_get_totals('P').otsoc_at_mg_cl_ot,0));
3287 
3288 hr_utility.set_location('Before Inserting IE_EHECS_PART7 ',3260);
3289 
3290     pay_action_information_api.create_action_information
3291     ( p_action_information_id => l_action_info_id
3292     ,p_action_context_id => l_payroll_action_id
3293     ,p_action_context_type => 'PA'
3294     ,p_object_version_number => l_ovn
3295     ,p_effective_date => g_archive_effective_date --g_end_date
3296     ,p_source_id => NULL
3297     ,p_source_text => NULL
3298     ,p_action_information_category => 'IE_EHECS_PART7'
3299     ,p_action_information1 => NVL(l_tab_get_totals('M').prsi_pt_ft_mg_cl_ot,0)
3300     ,p_action_information2 => NVL(l_tab_get_totals('C').prsi_pt_ft_mg_cl_ot,0)
3301     ,p_action_information3 => NVL(l_tab_get_totals('P').prsi_pt_ft_mg_cl_ot,0)
3302     ,p_action_information4 => NVL(l_tab_get_override_totals('M').l_sum_incc_pt_ft,NVL(l_tab_get_totals('M').incct_pt_ft_mg_cl_ot,0))
3303     ,p_action_information5 => NVL(l_tab_get_override_totals('C').l_sum_incc_pt_ft,NVL(l_tab_get_totals('C').incct_pt_ft_mg_cl_ot,0))
3304     ,p_action_information6  => NVL(l_tab_get_override_totals('P').l_sum_incc_pt_ft,NVL(l_tab_get_totals('P').incct_pt_ft_mg_cl_ot,0))
3305     ,p_action_information7  => NVL(l_tab_get_override_totals('M').l_sum_red_pt_ft,NVL(l_tab_get_totals('M').red_pt_ft_mg_cl_ot,0))
3306     ,p_action_information8  => NVL(l_tab_get_override_totals('C').l_sum_red_pt_ft,NVL(l_tab_get_totals('C').red_pt_ft_mg_cl_ot,0))
3307     ,p_action_information9  => NVL(l_tab_get_override_totals('P').l_sum_red_pt_ft,NVL(l_tab_get_totals('P').red_pt_ft_mg_cl_ot,0))
3308     ,p_action_information10 => NVL(l_tab_get_override_totals('M').l_sum_otsoc_pt_ft,NVL(l_tab_get_totals('M').otsoc_pt_ft_mg_cl_ot,0))
3309     ,p_action_information11 => NVL(l_tab_get_override_totals('C').l_sum_otsoc_pt_ft,NVL(l_tab_get_totals('C').otsoc_pt_ft_mg_cl_ot,0))
3310     ,p_action_information12 => NVL(l_tab_get_override_totals('P').l_sum_otsoc_pt_ft,NVL(l_tab_get_totals('P').otsoc_pt_ft_mg_cl_ot,0))
3311     ,p_action_information13 => l_ssecapmg
3312     ,p_action_information14 => l_ssecapcl
3313     ,p_action_information15 => l_ssecapot
3314     );
3315 
3316 hr_utility.set_location('After Inserting IE_EHECS_PART7 ',3270);
3317 
3318     pay_action_information_api.create_action_information
3319     ( p_action_information_id => l_action_info_id
3320     ,p_action_context_id => l_payroll_action_id
3321     ,p_action_context_type => 'PA'
3322     ,p_object_version_number => l_ovn
3323     ,p_effective_date => g_archive_effective_date --g_end_date
3324     ,p_source_id => NULL
3325     ,p_source_text => NULL
3326     ,p_action_information_category => 'IE_EHECS_PART8'
3327     ,p_action_information1 => NVL(l_tab_get_totals('M').car_pt_ft_mg_cl_ot,0)
3328     ,p_action_information2 => NVL(l_tab_get_totals('C').car_pt_ft_mg_cl_ot,0)
3329     ,p_action_information3 => NVL(l_tab_get_totals('P').car_pt_ft_mg_cl_ot,0)
3330     ,p_action_information4 => NVL(l_tab_get_override_totals('M').l_sum_stks_pt_ft,NVL(l_tab_get_totals('M').stks_pt_ft_mg_cl_ot,0))
3331     ,p_action_information5 => NVL(l_tab_get_override_totals('C').l_sum_stks_pt_ft,NVL(l_tab_get_totals('C').stks_pt_ft_mg_cl_ot,0))
3332     ,p_action_information6  => NVL(l_tab_get_override_totals('P').l_sum_stks_pt_ft,NVL(l_tab_get_totals('P').stks_pt_ft_mg_cl_ot,0))
3333     ,p_action_information7  => NVL(l_tab_get_override_totals('M').l_sum_vhi_pt_ft,NVL(l_tab_get_totals('M').vhi_pt_ft_mg_cl_ot,0))
3334     ,p_action_information8  => NVL(l_tab_get_override_totals('C').l_sum_vhi_pt_ft,NVL(l_tab_get_totals('C').vhi_pt_ft_mg_cl_ot,0))
3335     ,p_action_information9  => NVL(l_tab_get_override_totals('P').l_sum_vhi_pt_ft,NVL(l_tab_get_totals('P').vhi_pt_ft_mg_cl_ot,0))
3336     ,p_action_information10 => NVL(l_tab_get_override_totals('M').l_sum_hse_pt_ft,NVL(l_tab_get_totals('M').hse_pt_ft_mg_cl_ot,0))
3337     ,p_action_information11 => NVL(l_tab_get_override_totals('C').l_sum_hse_pt_ft,NVL(l_tab_get_totals('C').hse_pt_ft_mg_cl_ot,0))
3338     ,p_action_information12 => NVL(l_tab_get_override_totals('P').l_sum_hse_pt_ft,NVL(l_tab_get_totals('P').hse_pt_ft_mg_cl_ot,0))
3339     ,p_action_information13 => NVL(l_tab_get_override_totals('M').l_sum_otben_ft,NVL(l_tab_get_totals('M').otben_pt_ft_mg_cl_ot,0))
3340     ,p_action_information14 => NVL(l_tab_get_override_totals('C').l_sum_otben_ft,NVL(l_tab_get_totals('C').otben_pt_ft_mg_cl_ot,0))
3341     ,p_action_information15 => NVL(l_tab_get_override_totals('P').l_sum_otben_ft,NVL(l_tab_get_totals('P').otben_pt_ft_mg_cl_ot,0))
3342     );
3343 
3344 hr_utility.set_location('After Inserting IE_EHECS_PART8 ',3270);
3345 
3346     pay_action_information_api.create_action_information
3347     ( p_action_information_id => l_action_info_id
3348     ,p_action_context_id => l_payroll_action_id
3349     ,p_action_context_type => 'PA'
3350     ,p_object_version_number => l_ovn
3351     ,p_effective_date => g_archive_effective_date --g_end_date
3352     ,p_source_id => NULL
3353     ,p_source_text => NULL
3354     ,p_action_information_category => 'IE_EHECS_ALL_OTHER'
3355     ,p_action_information1  => NVL(l_tab_get_totals('M').pen_pt_ft_at_mg_cl_ot,0)
3356     ,p_action_information2  => NVL(l_tab_get_totals('C').pen_pt_ft_at_mg_cl_ot,0)
3357     ,p_action_information3  => NVL(l_tab_get_totals('P').pen_pt_ft_at_mg_cl_ot,0)
3358     ,p_action_information4  => l_csr_ehecs_eit.Tot_empr_Lblt_Ins
3359     ,p_action_information5  => l_csr_ehecs_eit.Trng_cost
3360     ,p_action_information6  => l_csr_ehecs_eit.Lbr_Expdtr		  --using index M below as all indexes wud hv same value
3361     ,p_action_information7  => NVL(l_csr_ehecs_eit.Trng_subsidy,NVL(l_tab_get_totals('M').trsub_all,0))
3362     ,p_action_information8  => NVL(l_csr_ehecs_eit.otr_subsidy,NVL(l_tab_get_totals('M').otsub_all,0))
3363     ,p_action_information9  => NVL(l_csr_ehecs_eit.refunds,NVL(l_tab_get_totals('M').rfund_all,0))
3364     ,p_action_information10 => NULL	-- not used
3365     ,p_action_information11 => NULL -- not used
3366     ,p_action_information12 => NULL -- not used
3367     );
3368 
3369 hr_utility.set_location('After Inserting IE_EHECS_ALL_OTHER ',3280);
3370 
3371 OPEN c_get_part1(l_payroll_action_id);
3372 FETCH c_get_part1 INTO l_data_part1;
3373 CLOSE c_get_part1;
3374 
3375 OPEN c_get_part2(l_payroll_action_id);
3376 FETCH c_get_part2 INTO l_data_part2;
3377 CLOSE c_get_part2;
3378 
3379 OPEN c_get_part3(l_payroll_action_id);
3380 FETCH c_get_part3 INTO l_data_part3;
3381 CLOSE c_get_part3;
3382 
3383 OPEN c_get_part4(l_payroll_action_id);
3384 FETCH c_get_part4 INTO l_data_part4;
3385 CLOSE c_get_part4;
3386 
3387 OPEN c_get_part7(l_payroll_action_id);
3388 FETCH c_get_part7 INTO l_data_part7;
3389 CLOSE c_get_part7;
3390 
3391 OPEN c_get_part8(l_payroll_action_id);
3392 FETCH c_get_part8 INTO l_data_part8;
3393 CLOSE c_get_part8;
3394 
3395 OPEN  c_get_part_all_other(l_payroll_action_id);
3396 FETCH c_get_part_all_other INTO l_data_part_all_other;
3397 CLOSE c_get_part_all_other;
3398 
3399 hr_utility.set_location('After Fetching ALL Cursors.',3280);
3400 
3401 --for l_data_part1 in c_get_part1(l_payroll_action_id)
3402 --loop
3403 
3404 l_errflag := 'N';
3405 l_is_gt_0 := ' is greater than 0.';
3406 
3407 -------------------Section A: Full time and part time managers, professionals and associate professionals:
3408 l_employee_categories := 'managers, professionals and associate professionals';
3409 
3410 IF l_data_part1.l_fst_ft_mg >0 OR l_data_part1.l_lst_ft_mg > 0 THEN
3411 l_str_common := 'An entry exists for full time ' || l_employee_categories ||' employed at the first day of the quarter or the last day of the quarter.';
3412    --
3413    IF l_data_part2.l_reg_wg_ft_mg = 0 THEN
3414      l_errflag := 'Y';
3415      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - full time '|| l_employee_categories || l_is_gt_0);
3416      --||' must be > 0 '||l_str_common);
3417    END IF;
3418    --
3419    IF l_data_part3.l_contracted_hrs_paid_ft_mg = 0 THEN
3420      l_errflag := 'Y';
3421      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - full time '|| l_employee_categories || l_is_gt_0 );
3422      --||' must be > 0 '||l_str_common );
3423    END IF;
3424    --
3425    IF l_data_part4.l_ann_leave_ft_mg = 0 THEN
3426      l_errflag := 'Y';
3427      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - full time '|| l_employee_categories || l_is_gt_0 );
3428      --||' must be > 0 '||l_str_common);
3429    END IF;
3430    --
3431 
3432 END IF;
3433 
3434 
3435 IF l_data_part2.l_reg_wg_ft_mg > 0 THEN
3436 l_str_common := 'An entry exists for regular wages and salaries for full time '|| l_employee_categories;
3437    --
3438    IF l_data_part3.l_contracted_hrs_paid_ft_mg = 0 THEN
3439      l_errflag := 'Y';
3440      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - full time '|| l_employee_categories || l_is_gt_0 );
3441 
3442    END IF;
3443    --
3444    IF l_data_part4.l_ann_leave_ft_mg = 0 THEN
3445      l_errflag := 'Y';
3446      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - full time '|| l_employee_categories || l_is_gt_0 );
3447 
3448    END IF;
3449 
3450 END IF;
3451 
3452 IF l_data_part2.l_irr_bonus_ft_mg > 0 THEN
3453 l_str_common := 'An entry exists for irregular bonuses and allowances for full time '|| l_employee_categories;
3454    --
3455    IF l_data_part2.l_reg_wg_ft_mg = 0 THEN
3456      l_errflag := 'Y';
3457      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - full time '|| l_employee_categories|| l_is_gt_0 );
3458      --||' must be > 0 '||l_str_common );
3459    END IF;
3460    --
3461    IF l_data_part3.l_contracted_hrs_paid_ft_mg = 0 THEN
3462      l_errflag := 'Y';
3463      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - full time '|| l_employee_categories|| l_is_gt_0 );
3464      --||' must be > 0 '||l_str_common );
3465    END IF;
3466    --
3467    IF l_data_part4.l_ann_leave_ft_mg = 0 THEN
3468      l_errflag := 'Y';
3469      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - full time '|| l_employee_categories|| l_is_gt_0 );
3470      --||' must be > 0 '||l_str_common );
3471    END IF;
3472 END IF;
3473 --
3474 IF l_data_part2.l_ot_paid_ft_mg > 0 THEN
3475 l_str_common := 'An entry exists for overtime for full time '|| l_employee_categories ;
3476    --
3477    IF l_data_part2.l_reg_wg_ft_mg = 0 THEN
3478      l_errflag := 'Y';
3479      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - full time '|| l_employee_categories|| l_is_gt_0 );
3480      --||' must be > 0 '||l_str_common );
3481    END IF;
3482    --
3483    IF l_data_part3.l_contracted_hrs_paid_ft_mg = 0 THEN
3484      l_errflag := 'Y';
3485      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - full time '|| l_employee_categories|| l_is_gt_0 );
3486      --||' must be > 0 '||l_str_common );
3487    END IF;
3488    --
3489    IF l_data_part3.l_ot_hrs_paid_ft_mg = 0 THEN
3490      l_errflag := 'Y';
3491      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid overtime hours - full time '|| l_employee_categories|| l_is_gt_0 );
3492      --||' must be > 0 '||l_str_common );
3493    END IF;
3494    --
3495    IF l_data_part4.l_ann_leave_ft_mg = 0 THEN
3496      l_errflag := 'Y';
3497      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - full time '|| l_employee_categories|| l_is_gt_0 );
3498      --||' must be > 0 '||l_str_common );
3499    END IF;
3500    --
3501 END IF;
3502 --
3503 IF l_data_part3.l_contracted_hrs_paid_ft_mg > 0 THEN
3504 l_str_common := 'An entry exists for contracted hours for full time '|| l_employee_categories;
3505    --
3506    IF l_data_part2.l_reg_wg_ft_mg = 0 THEN
3507      l_errflag := 'Y';
3508      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - full time '|| l_employee_categories|| l_is_gt_0 );
3509      --||' must be > 0 '||l_str_common );
3510    END IF;
3511    --
3512    IF l_data_part4.l_ann_leave_ft_mg = 0 THEN
3513      l_errflag := 'Y';
3514      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - full time '|| l_employee_categories|| l_is_gt_0 );
3515      --||' must be > 0 '||l_str_common );
3516    END IF;
3517    --
3518 END IF;
3519 --
3520 
3521 IF l_data_part3.l_ot_hrs_paid_ft_mg > 0 THEN
3522 l_str_common := 'An entry exists for overtime hours for full time '|| l_employee_categories;
3523    --
3524    IF l_data_part2.l_reg_wg_ft_mg = 0 THEN
3525      l_errflag := 'Y';
3526      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - full time '|| l_employee_categories|| l_is_gt_0 );
3527      --||' must be > 0 '||l_str_common );
3528    END IF;
3529    --
3530    IF l_data_part3.l_contracted_hrs_paid_ft_mg = 0 THEN
3531      l_errflag := 'Y';
3532      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - full time '|| l_employee_categories|| l_is_gt_0 );
3533      --||' must be > 0 '||l_str_common );
3534    END IF;
3535    --
3536    IF l_data_part2.l_ot_paid_ft_mg = 0 THEN
3537      l_errflag := 'Y';
3538      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Overtime - full time '|| l_employee_categories|| l_is_gt_0 );
3539      --||' must be > 0 '||l_str_common );
3540    END IF;
3541    --
3542    IF l_data_part4.l_ann_leave_ft_mg = 0 THEN
3543      l_errflag := 'Y';
3544      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - full time '|| l_employee_categories|| l_is_gt_0 );
3545      --||' must be > 0 '||l_str_common );
3546    END IF;
3547    --
3548 END IF;
3549 
3550 IF (l_data_part4.l_ann_leave_ft_mg >0 OR l_data_part4.l_mat_leave_ft_mg > 0 OR
3551     l_data_part4.l_sck_leave_ft_mg >0 OR l_data_part4.l_other_leave_ft_mg >0 ) THEN
3552 l_str_common := 'An entry exists for Annual Leave and Bank Holidays or Maternity Leave or Sick Leave or Other Leave- full time '|| l_employee_categories;
3553    --
3554    IF l_data_part2.l_reg_wg_ft_mg = 0 THEN
3555      l_errflag := 'Y';
3556      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - full time '|| l_employee_categories|| l_is_gt_0 );
3557      --||' must be > 0 '||l_str_common );
3558    END IF;
3559    --
3560    IF l_data_part3.l_contracted_hrs_paid_ft_mg = 0 THEN
3561      l_errflag := 'Y';
3562      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - full time '|| l_employee_categories|| l_is_gt_0 );
3563      --||' must be > 0 '||l_str_common );
3564    END IF;
3565    --
3566 END IF;
3567 
3568 IF (l_data_part1.l_fst_pt_mg >0 OR l_data_part1.l_lst_pt_mg > 0 ) THEN
3569 l_str_common := 'An entry exists for part time '|| l_employee_categories||' employed at '
3570 ||' the first day of the quarter or the last day of the quarter.';
3571    --
3572    IF l_data_part2.l_reg_wg_pt_mg = 0 THEN
3573      l_errflag := 'Y';
3574      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - part time '|| l_employee_categories|| l_is_gt_0 );
3575     --||' must be > 0 '||l_str_common );
3576    END IF;
3577    --
3578    IF l_data_part3.l_contracted_hrs_paid_pt_mg = 0 THEN
3579      l_errflag := 'Y';
3580      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - part time '|| l_employee_categories|| l_is_gt_0 );
3581      --||' must be > 0 '||l_str_common );
3582    END IF;
3583    --
3584    IF l_data_part4.l_ann_leave_pt_mg = 0 THEN
3585      l_errflag := 'Y';
3586      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - part time '|| l_employee_categories|| l_is_gt_0 );
3587      --||' must be > 0 '||l_str_common );
3588    END IF;
3589    --
3590 END IF;
3591 
3592 IF l_data_part2.l_reg_wg_pt_mg > 0 THEN
3593 l_str_common := 'An entry exists for regular wages and salaries for part time '|| l_employee_categories;
3594    --
3595    IF l_data_part3.l_contracted_hrs_paid_pt_mg = 0 THEN
3596      l_errflag := 'Y';
3597      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - part time '|| l_employee_categories|| l_is_gt_0 );
3598      --||' must be > 0 '||l_str_common );
3599    END IF;
3600    --
3601    IF l_data_part4.l_ann_leave_pt_mg = 0 THEN
3602      l_errflag := 'Y';
3603      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - part time '|| l_employee_categories|| l_is_gt_0 );
3604      --||' must be > 0 '||l_str_common );
3605    END IF;
3606    --
3607 END IF;
3608 
3609 IF l_data_part2.l_irr_bonus_pt_mg > 0 THEN
3610 l_str_common := 'An entry exists for irregular bonuses and allowances for part time '|| l_employee_categories;
3611    --
3612    IF l_data_part2.l_reg_wg_pt_mg = 0 THEN
3613      l_errflag := 'Y';
3614      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - part time '|| l_employee_categories|| l_is_gt_0 );
3615      --||' must be > 0 '||l_str_common );
3616    END IF;
3617    --
3618    IF l_data_part3.l_contracted_hrs_paid_pt_mg = 0 THEN
3619      l_errflag := 'Y';
3620      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - part time '|| l_employee_categories|| l_is_gt_0 );
3621      --||' must be > 0 '||l_str_common );
3622    END IF;
3623    --
3624    IF l_data_part4.l_ann_leave_pt_mg = 0 THEN
3625      l_errflag := 'Y';
3626      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - part time '|| l_employee_categories|| l_is_gt_0 );
3627      --||' must be > 0 '||l_str_common );
3628    END IF;
3629    --
3630 END IF;
3631 
3632 IF l_data_part2.l_ot_paid_pt_mg > 0 THEN
3633 l_str_common := 'An entry exists for overtime for part time '|| l_employee_categories;
3634    --
3635    IF l_data_part2.l_reg_wg_pt_mg = 0 THEN
3636      l_errflag := 'Y';
3637      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - part time '|| l_employee_categories|| l_is_gt_0 );
3638      --||' must be > 0 '||l_str_common );
3639    END IF;
3640    --
3641    IF l_data_part3.l_contracted_hrs_paid_pt_mg = 0 THEN
3642      l_errflag := 'Y';
3643      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - part time '|| l_employee_categories|| l_is_gt_0 );
3644      --||' must be > 0 '||l_str_common );
3645    END IF;
3646    --
3647    IF l_data_part3.l_ot_hrs_paid_pt_mg = 0 THEN
3648      l_errflag := 'Y';
3649      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid overtime hours - part time '|| l_employee_categories|| l_is_gt_0 );
3650      --||' must be > 0 '||l_str_common );
3651    END IF;
3652    --
3653    IF l_data_part4.l_ann_leave_pt_mg = 0 THEN
3654      l_errflag := 'Y';
3655      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - part time '|| l_employee_categories|| l_is_gt_0 );
3656      --||' must be > 0 '||l_str_common );
3657    END IF;
3658 END IF;
3659 
3660 IF l_data_part3.l_contracted_hrs_paid_pt_mg > 0 THEN
3661 l_str_common := 'An entry exists for paid contracted hours for part time '|| l_employee_categories;
3662    --
3663    IF l_data_part2.l_reg_wg_pt_mg = 0 THEN
3664      l_errflag := 'Y';
3665      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - part time '|| l_employee_categories|| l_is_gt_0 );
3666      --||' must be > 0 '||l_str_common );
3667    END IF;
3668    --
3669    IF l_data_part4.l_ann_leave_pt_mg = 0 THEN
3670      l_errflag := 'Y';
3671      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - part time '|| l_employee_categories|| l_is_gt_0 );
3672      --||' must be > 0 '||l_str_common );
3673    END IF;
3674 END IF;
3675 
3676 IF l_data_part3.l_ot_hrs_paid_pt_mg > 0 THEN
3677 l_str_common := 'An entry exists for overtime hours for part time '|| l_employee_categories;
3678    --
3679    IF l_data_part2.l_reg_wg_pt_mg = 0 THEN
3680      l_errflag := 'Y';
3681      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - part time '|| l_employee_categories|| l_is_gt_0 );
3682      --||' must be > 0 '||l_str_common );
3683    END IF;
3684    --
3685    IF l_data_part4.l_ann_leave_pt_mg = 0 THEN
3686      l_errflag := 'Y';
3687      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - part time '|| l_employee_categories|| l_is_gt_0 );
3688      --||' must be > 0 '||l_str_common );
3689    END IF;
3690    --
3691    IF l_data_part3.l_contracted_hrs_paid_pt_mg = 0 THEN
3692      l_errflag := 'Y';
3693      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - part time '|| l_employee_categories|| l_is_gt_0 );
3694      --||' must be > 0 '||l_str_common );
3695    END IF;
3696 END IF;
3697 
3698 IF l_data_part_all_other.l_employer_pension_mg > 0 THEN
3699 l_str_common := ' An entry exists for Employers contributions to pension funds for '|| l_employee_categories;
3700    --
3701    IF l_data_part2.l_reg_wg_ft_mg = 0 AND l_data_part2.l_reg_wg_pt_mg = 0 AND l_data_part2.l_tot_wg_app_mg = 0 THEN
3702      l_errflag := 'Y';
3703      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries for any one of them - full time / part time / apprentice/trainee '|| l_is_gt_0 );
3704      --||' must be > 0 '||l_str_common );
3705    END IF;
3706    --
3707    IF l_data_part3.l_contracted_hrs_paid_ft_mg = 0 AND l_data_part3.l_contracted_hrs_paid_pt_mg = 0 AND l_data_part3.l_contracted_hrs_paid_app_mg = 0 THEN
3708      l_errflag := 'Y';
3709      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours for any one of them - full time / part time / apprentice/trainee '|| l_is_gt_0 );
3710      --||' must be > 0 '||l_str_common );
3711    END IF;
3712    --
3713    IF l_data_part4.l_ann_leave_ft_mg = 0 AND l_data_part4.l_ann_leave_pt_mg = 0 AND l_data_part4.l_all_paid_leave_app_mg = 0 THEN
3714      l_errflag := 'Y';
3715      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays for any one of them - full time / part time / apprentice/trainee '|| l_is_gt_0 );
3716      --||' must be > 0 '||l_str_common );
3717    END IF;
3718 END IF;
3719 
3720 IF ( l_data_part7.l_employer_prsi_mg > 0 OR l_data_part7.l_continuance_income_mg > 0 OR
3721      l_data_part7.l_redundacny_paid_mg > 0 OR l_data_part7.l_other_paid_mg > 0 ) THEN
3722 l_str_common := 'An entry exists for Social Security Contributions for full time and part time '|| l_employee_categories||' employees.';
3723 
3724    IF l_data_part2.l_reg_wg_ft_mg = 0 AND l_data_part2.l_reg_wg_pt_mg = 0 THEN
3725      l_errflag := 'Y';
3726      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries for any one of them - full time / part time '|| l_is_gt_0 );
3727      --||' must be > 0 '||l_str_common );
3728    END IF;
3729    --
3730    IF l_data_part3.l_contracted_hrs_paid_ft_mg = 0 AND l_data_part3.l_contracted_hrs_paid_pt_mg = 0 THEN
3731      l_errflag := 'Y';
3732      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours for any one of them - full time / part time '|| l_is_gt_0 );
3733      --||' must be > 0 '||l_str_common );
3734    END IF;
3735    --
3736    IF l_data_part4.l_ann_leave_ft_mg = 0 AND l_data_part4.l_ann_leave_pt_mg = 0 THEN
3737      l_errflag := 'Y';
3738      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays for any one of them - full time / part time '|| l_is_gt_0 );
3739      --||' must be > 0 '||l_str_common );
3740    END IF;
3741    --
3742 END If;
3743 
3744 IF (l_data_part8.l_company_car_mg > 0 OR l_data_part8.l_stock_options_mg > 0 OR
3745     l_data_part8.l_vol_sick_insurance_mg > 0 OR l_data_part8.l_staff_housing_mg > 0 OR
3746     l_data_part8.l_other_benefits_mg > 0 ) THEN
3747 l_str_common := ' An entry exists for Other Benefits to Employees - full time and part time '|| l_employee_categories;
3748    --
3749    IF l_data_part2.l_reg_wg_ft_mg = 0 AND l_data_part2.l_reg_wg_pt_mg = 0 THEN
3750      l_errflag := 'Y';
3751      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries for any one of them - full time / part time '|| l_is_gt_0 );
3752      --||' must be > 0 '||l_str_common );
3753    END IF;
3754    --
3755    --
3756    IF l_data_part3.l_contracted_hrs_paid_ft_mg = 0 AND l_data_part3.l_contracted_hrs_paid_pt_mg = 0 THEN
3757      l_errflag := 'Y';
3758      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours for any one of them - full time / part time '|| l_is_gt_0 );
3759      --||' must be > 0 '||l_str_common );
3760    END IF;
3761    --
3762    IF l_data_part4.l_ann_leave_ft_mg = 0 AND l_data_part4.l_ann_leave_pt_mg = 0 THEN
3763      l_errflag := 'Y';
3764      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays for any one of them - full time / part time '|| l_is_gt_0 );
3765      --||' must be > 0 '||l_str_common );
3766    END IF;
3767 END IF;
3768 ----------------Section B: Full and part time clerical, sales and service workers:
3769 l_employee_categories := 'clerical, sales and service workers';
3770 
3771 IF l_data_part1.l_fst_ft_cl >0 OR l_data_part1.l_lst_ft_cl > 0 THEN
3772 l_str_common := 'as full time ' || l_employee_categories ||' employed at the first day of the quarter or the last day of the quarter exists ';
3773    --
3774    IF l_data_part2.l_reg_wg_ft_cl = 0 THEN
3775      l_errflag := 'Y';
3776      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - full time '|| l_employee_categories|| l_is_gt_0 );
3777      --||' must be > 0 '||l_str_common);
3778    END IF;
3779    --
3780    IF l_data_part3.l_contracted_hrs_paid_ft_cl = 0 THEN
3781      l_errflag := 'Y';
3782      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - full time '|| l_employee_categories|| l_is_gt_0 );
3783      --||' must be > 0 '||l_str_common );
3784    END IF;
3785    --
3786    IF l_data_part4.l_ann_leave_ft_cl = 0 THEN
3787      l_errflag := 'Y';
3788      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - full time '|| l_employee_categories|| l_is_gt_0 );
3789      --||' must be > 0 '||l_str_common);
3790    END IF;
3791    --
3792 
3793 END IF;
3794 
3795 IF l_data_part2.l_reg_wg_ft_cl > 0 THEN
3796 l_str_common := 'An entry exists for regular wages and salaries for full time '|| l_employee_categories;
3797    --
3798    IF l_data_part3.l_contracted_hrs_paid_ft_cl = 0 THEN
3799      l_errflag := 'Y';
3800      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - full time '|| l_employee_categories|| l_is_gt_0 );
3801      --||' must be > 0 '||l_str_common );
3802    END IF;
3803    --
3804    IF l_data_part4.l_ann_leave_ft_cl = 0 THEN
3805      l_errflag := 'Y';
3806      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - full time '|| l_employee_categories|| l_is_gt_0 );
3807      --||' must be > 0 '||l_str_common);
3808    END IF;
3809    --
3810 
3811 END IF;
3812 
3813 IF l_data_part2.l_irr_bonus_ft_cl > 0 THEN
3814 l_str_common := 'An entry exists for irregular bonuses and allowances for full time '|| l_employee_categories;
3815    --
3816    IF l_data_part2.l_reg_wg_ft_cl = 0 THEN
3817      l_errflag := 'Y';
3818      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - full time '|| l_employee_categories|| l_is_gt_0 );
3819      --||' must be > 0 '||l_str_common );
3820    END IF;
3821    --
3822    IF l_data_part3.l_contracted_hrs_paid_ft_cl = 0 THEN
3823      l_errflag := 'Y';
3824      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - full time '|| l_employee_categories|| l_is_gt_0 );
3825      --||' must be > 0 '||l_str_common );
3826    END IF;
3827    --
3828    IF l_data_part4.l_ann_leave_ft_cl = 0 THEN
3829      l_errflag := 'Y';
3830      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - full time '|| l_employee_categories|| l_is_gt_0 );
3831      --||' must be > 0 '||l_str_common );
3832    END IF;
3833 END IF;
3834 --
3835 IF l_data_part2.l_ot_paid_ft_cl > 0 THEN
3836 l_str_common := 'An entry exists for overtime for full time '|| l_employee_categories;
3837    --
3838    IF l_data_part2.l_reg_wg_ft_cl = 0 THEN
3839      l_errflag := 'Y';
3840      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - full time '|| l_employee_categories|| l_is_gt_0 );
3841      --||' must be > 0 '||l_str_common );
3842    END IF;
3843    --
3844    IF l_data_part3.l_contracted_hrs_paid_ft_cl = 0 THEN
3845      l_errflag := 'Y';
3846      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - full time '|| l_employee_categories|| l_is_gt_0 );
3847      --||' must be > 0 '||l_str_common );
3848    END IF;
3849    --
3850    IF l_data_part3.l_ot_hrs_paid_ft_cl = 0 THEN
3851      l_errflag := 'Y';
3852      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid overtime hours - full time '|| l_employee_categories|| l_is_gt_0 );
3853      --||' must be > 0 '||l_str_common );
3854    END IF;
3855    --
3856    IF l_data_part4.l_ann_leave_ft_cl = 0 THEN
3857      l_errflag := 'Y';
3858      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - full time '|| l_employee_categories|| l_is_gt_0 );
3859      --||' must be > 0 '||l_str_common );
3860    END IF;
3861    --
3862 END IF;
3863 --
3864 IF l_data_part3.l_contracted_hrs_paid_ft_cl > 0 THEN
3865 l_str_common := 'An entry exists for contracted hours for full time '|| l_employee_categories;
3866    --
3867    IF l_data_part2.l_reg_wg_ft_cl = 0 THEN
3868      l_errflag := 'Y';
3869      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - full time '|| l_employee_categories|| l_is_gt_0 );
3870      --||' must be > 0 '||l_str_common );
3871    END IF;
3872    --
3873    IF l_data_part4.l_ann_leave_ft_cl = 0 THEN
3874      l_errflag := 'Y';
3875      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - full time '|| l_employee_categories|| l_is_gt_0 );
3876      --||' must be > 0 '||l_str_common );
3877    END IF;
3878    --
3879 END IF;
3880 --
3881 
3882 IF l_data_part3.l_ot_hrs_paid_ft_cl > 0 THEN
3883 l_str_common := 'An entry exists for overtime hours for full time '|| l_employee_categories;
3884    --
3885    IF l_data_part2.l_reg_wg_ft_cl = 0 THEN
3886      l_errflag := 'Y';
3887      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - full time '|| l_employee_categories|| l_is_gt_0 );
3888      --||' must be > 0 '||l_str_common );
3889    END IF;
3890    --
3891    IF l_data_part3.l_contracted_hrs_paid_ft_cl = 0 THEN
3892      l_errflag := 'Y';
3893      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - full time '|| l_employee_categories|| l_is_gt_0 );
3894      --||' must be > 0 '||l_str_common );
3895    END IF;
3896    --
3897    IF l_data_part2.l_ot_paid_ft_cl = 0 THEN
3898      l_errflag := 'Y';
3899      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Overtime - full time '|| l_employee_categories|| l_is_gt_0 );
3900     -- ||' must be > 0 '||l_str_common );
3901    END IF;
3902    --
3903    IF l_data_part4.l_ann_leave_ft_cl = 0 THEN
3904      l_errflag := 'Y';
3905      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - full time '|| l_employee_categories|| l_is_gt_0 );
3906      --||' must be > 0 '||l_str_common );
3907    END IF;
3908    --
3909 END IF;
3910 
3911 IF (l_data_part4.l_ann_leave_ft_cl >0 OR l_data_part4.l_mat_leave_ft_cl > 0 OR
3912     l_data_part4.l_sck_leave_ft_cl >0 OR l_data_part4.l_other_leave_ft_cl >0 ) THEN
3913 l_str_common := 'An entry exists for Annual Leave and Bank Holidays or Maternity Leave or Sick Leave or Other Leave- full time '|| l_employee_categories;
3914 
3915    --
3916    IF l_data_part2.l_reg_wg_ft_cl = 0 THEN
3917      l_errflag := 'Y';
3918      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - full time '|| l_employee_categories|| l_is_gt_0 );
3919      --||' must be > 0 '||l_str_common );
3920    END IF;
3921    --
3922    IF l_data_part3.l_contracted_hrs_paid_ft_cl = 0 THEN
3923      l_errflag := 'Y';
3924      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - full time '|| l_employee_categories|| l_is_gt_0 );
3925      --||' must be > 0 '||l_str_common );
3926    END IF;
3927    --
3928 END IF;
3929 
3930 IF (l_data_part1.l_fst_pt_cl >0 OR l_data_part1.l_lst_pt_cl > 0 ) THEN
3931 l_str_common := 'An entry exists for part time '|| l_employee_categories ||' employed at '
3932 ||' the first day of the quarter or the last day of the quarter.';
3933    --
3934    IF l_data_part2.l_reg_wg_pt_cl = 0 THEN
3935      l_errflag := 'Y';
3936      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - part time '|| l_employee_categories|| l_is_gt_0 );
3937      --||' must be > 0 '||l_str_common );
3938    END IF;
3939    --
3940    IF l_data_part3.l_contracted_hrs_paid_pt_cl = 0 THEN
3941      l_errflag := 'Y';
3942      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - part time '|| l_employee_categories|| l_is_gt_0 );
3943      --||' must be > 0 '||l_str_common );
3944    END IF;
3945    --
3946    IF l_data_part4.l_ann_leave_pt_cl = 0 THEN
3947      l_errflag := 'Y';
3948      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - part time '|| l_employee_categories|| l_is_gt_0 );
3949      --||' must be > 0 '||l_str_common );
3950    END IF;
3951    --
3952 END IF;
3953 
3954 IF l_data_part2.l_reg_wg_pt_cl > 0 THEN
3955 l_str_common := 'An entry exists for regular wages and salaries for part time '|| l_employee_categories;
3956    --
3957    IF l_data_part3.l_contracted_hrs_paid_pt_cl = 0 THEN
3958      l_errflag := 'Y';
3959      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - part time '|| l_employee_categories|| l_is_gt_0 );
3960      --||' must be > 0 '||l_str_common );
3961    END IF;
3962    --
3963    IF l_data_part4.l_ann_leave_pt_cl = 0 THEN
3964      l_errflag := 'Y';
3965      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - part time '|| l_employee_categories|| l_is_gt_0 );
3966      --||' must be > 0 '||l_str_common );
3967    END IF;
3968    --
3969 END IF;
3970 
3971 IF l_data_part2.l_irr_bonus_pt_cl > 0 THEN
3972 l_str_common := 'An entry exists for irregular bonuses and allowances for part time '|| l_employee_categories;
3973    --
3974    IF l_data_part2.l_reg_wg_pt_cl = 0 THEN
3975      l_errflag := 'Y';
3976      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - part time '|| l_employee_categories|| l_is_gt_0 );
3977      --||' must be > 0 '||l_str_common );
3978    END IF;
3979    --
3980    IF l_data_part3.l_contracted_hrs_paid_pt_cl = 0 THEN
3981      l_errflag := 'Y';
3982      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - part time '|| l_employee_categories|| l_is_gt_0 );
3983      --||' must be > 0 '||l_str_common );
3984    END IF;
3985    --
3986    IF l_data_part4.l_ann_leave_pt_cl = 0 THEN
3987      l_errflag := 'Y';
3988      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - part time '|| l_employee_categories|| l_is_gt_0 );
3989      --||' must be > 0 '||l_str_common );
3990    END IF;
3991    --
3992 END IF;
3993 
3994 IF l_data_part2.l_ot_paid_pt_cl > 0 THEN
3995 l_str_common := 'An entry exists for overtime for part time '|| l_employee_categories;
3996    --
3997    IF l_data_part2.l_reg_wg_pt_cl = 0 THEN
3998      l_errflag := 'Y';
3999      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - part time '|| l_employee_categories|| l_is_gt_0 );
4000      --||' must be > 0 '||l_str_common );
4001    END IF;
4002    --
4003    IF l_data_part3.l_contracted_hrs_paid_pt_cl = 0 THEN
4004      l_errflag := 'Y';
4005      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - part time '|| l_employee_categories|| l_is_gt_0 );
4006      --||' must be > 0 '||l_str_common );
4007    END IF;
4008    --
4009    IF l_data_part3.l_ot_hrs_paid_pt_cl = 0 THEN
4010      l_errflag := 'Y';
4011      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid overtime hours - part time '|| l_employee_categories|| l_is_gt_0 );
4012      --||' must be > 0 '||l_str_common );
4013    END IF;
4014    --
4015    IF l_data_part4.l_ann_leave_pt_cl = 0 THEN
4016      l_errflag := 'Y';
4017      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - part time '|| l_employee_categories|| l_is_gt_0 );
4018      --||' must be > 0 '||l_str_common );
4019    END IF;
4020 END IF;
4021 
4022 IF l_data_part3.l_contracted_hrs_paid_pt_cl > 0 THEN
4023 l_str_common := 'An entry exists for paid contracted hours for part time '|| l_employee_categories;
4024    --
4025    IF l_data_part2.l_reg_wg_pt_cl = 0 THEN
4026      l_errflag := 'Y';
4027      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - part time '|| l_employee_categories|| l_is_gt_0 );
4028      --||' must be > 0 '||l_str_common );
4029    END IF;
4030    --
4031    IF l_data_part4.l_ann_leave_pt_cl = 0 THEN
4032      l_errflag := 'Y';
4033      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - part time '|| l_employee_categories|| l_is_gt_0 );
4034      --||' must be > 0 '||l_str_common );
4035    END IF;
4036 END IF;
4037 
4038 IF l_data_part3.l_ot_hrs_paid_pt_cl > 0 THEN
4039 l_str_common := 'An entry exists for overtime hours for part time '|| l_employee_categories;
4040    --
4041    IF l_data_part2.l_reg_wg_pt_cl = 0 THEN
4042      l_errflag := 'Y';
4043      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - part time '|| l_employee_categories|| l_is_gt_0 );
4044      --||' must be > 0 '||l_str_common );
4045    END IF;
4046    --
4047    IF l_data_part4.l_ann_leave_pt_cl = 0 THEN
4048      l_errflag := 'Y';
4049      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - part time '|| l_employee_categories|| l_is_gt_0 );
4050      --||' must be > 0 '||l_str_common );
4051    END IF;
4052    --
4053    IF l_data_part3.l_contracted_hrs_paid_pt_cl = 0 THEN
4054      l_errflag := 'Y';
4055      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - part time '|| l_employee_categories|| l_is_gt_0 );
4056      --||' must be > 0 '||l_str_common );
4057    END IF;
4058 END IF;
4059 
4060 IF l_data_part_all_other.l_employer_pension_cl > 0 THEN
4061 l_str_common := ' An entry exists for Employers contributions to pension funds for '|| l_employee_categories;
4062    --
4063    IF l_data_part2.l_reg_wg_ft_cl = 0 AND l_data_part2.l_reg_wg_pt_cl = 0 AND l_data_part2.l_tot_wg_app_cl = 0 THEN
4064      l_errflag := 'Y';
4065      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries for any one of them - full time / part time / apprentice/trainee '|| l_is_gt_0 );
4066      --||' must be > 0 '||l_str_common );
4067    END IF;
4068    --
4069    IF l_data_part3.l_contracted_hrs_paid_ft_cl = 0 AND l_data_part3.l_contracted_hrs_paid_pt_cl = 0 AND l_data_part3.l_contracted_hrs_paid_app_cl = 0 THEN
4070      l_errflag := 'Y';
4071      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours for any one of them - full time / part time / apprentice/trainee '|| l_is_gt_0 );
4072      --||' must be > 0 '||l_str_common );
4073    END IF;
4074    --
4075    IF l_data_part4.l_ann_leave_ft_cl = 0 AND l_data_part4.l_ann_leave_pt_cl = 0 AND l_data_part4.l_all_paid_leave_app_cl = 0 THEN
4076      l_errflag := 'Y';
4077      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays for any one of them - full time / part time / apprentice/trainee '|| l_is_gt_0 );
4078      --||' must be > 0 '||l_str_common );
4079    END IF;
4080 END IF;
4081 
4082 IF ( l_data_part7.l_employer_prsi_cl > 0 OR l_data_part7.l_continuance_income_cl > 0 OR
4083      l_data_part7.l_redundacny_paid_cl > 0 OR l_data_part7.l_other_paid_cl > 0 ) THEN
4084 l_str_common := 'An entry exists for Social Security Contributions for full time and part time '|| l_employee_categories||' employees.';
4085 
4086    IF l_data_part2.l_reg_wg_ft_cl = 0 AND l_data_part2.l_reg_wg_pt_cl = 0 THEN
4087      l_errflag := 'Y';
4088      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries for any one of them - full time / part time '|| l_is_gt_0 );
4089      --||' must be > 0 '||l_str_common );
4090    END IF;
4091    --
4092    IF l_data_part3.l_contracted_hrs_paid_ft_cl = 0 AND l_data_part3.l_contracted_hrs_paid_pt_cl = 0 THEN
4093      l_errflag := 'Y';
4094      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours for any one of them - full time / part time '|| l_is_gt_0 );
4095      --||' must be > 0 '||l_str_common );
4096    END IF;
4097    --
4098    IF l_data_part4.l_ann_leave_ft_cl = 0 AND l_data_part4.l_ann_leave_pt_cl = 0 THEN
4099      l_errflag := 'Y';
4100      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays for any one of them - full time / part time '|| l_is_gt_0 );
4101      --||' must be > 0 '||l_str_common );
4102    END IF;
4103    --
4104 END If;
4105 
4106 IF (l_data_part8.l_company_car_cl > 0 OR l_data_part8.l_stock_options_cl > 0 OR
4107     l_data_part8.l_vol_sick_insurance_cl > 0 OR l_data_part8.l_staff_housing_cl > 0 OR
4108     l_data_part8.l_other_benefits_cl > 0 ) THEN
4109 l_str_common := 'An entry exists for Other Benefits to Employees - full time and part time '|| l_employee_categories;
4110    --
4111    IF l_data_part2.l_reg_wg_ft_cl = 0 AND l_data_part2.l_reg_wg_pt_cl = 0 THEN
4112      l_errflag := 'Y';
4113      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries for any one of them - full time / part time '|| l_is_gt_0 );
4114      --||' must be > 0 '||l_str_common );
4115    END IF;
4116    --
4117    --
4118    IF l_data_part3.l_contracted_hrs_paid_ft_cl = 0 AND l_data_part3.l_contracted_hrs_paid_pt_cl = 0 THEN
4119      l_errflag := 'Y';
4120      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours for any one of them - full time / part time '|| l_is_gt_0 );
4121      --||' must be > 0 '||l_str_common );
4122    END IF;
4123    --
4124    IF l_data_part4.l_ann_leave_ft_cl = 0 AND l_data_part4.l_ann_leave_pt_cl = 0 THEN
4125      l_errflag := 'Y';
4126      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays for any one of them - full time / part time '|| l_is_gt_0 );
4127      --||' must be > 0 '||l_str_common );
4128    END IF;
4129 END IF;
4130 
4131 ----------------Section C: Full and part time production, transport, craft, tradespersons and other manual workers:
4132 l_employee_categories := 'production, transport, craft, tradespersons and other manual workers';
4133 
4134 IF l_data_part1.l_fst_ft_ot >0 OR l_data_part1.l_lst_ft_ot > 0 THEN
4135 l_str_common := 'An entry exists for full time ' || l_employee_categories ||' employed at the first day of the quarter or the last day of the quarter.';
4136    --
4137    IF l_data_part2.l_reg_wg_ft_ot = 0 THEN
4138      l_errflag := 'Y';
4139      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - full time '|| l_employee_categories|| l_is_gt_0 );
4140      --||' must be > 0 '||l_str_common);
4141    END IF;
4142    --
4143    IF l_data_part3.l_contracted_hrs_paid_ft_ot = 0 THEN
4144      l_errflag := 'Y';
4145      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - full time '|| l_employee_categories|| l_is_gt_0 );
4146      --||' must be > 0 '||l_str_common );
4147    END IF;
4148    --
4149    IF l_data_part4.l_ann_leave_ft_ot = 0 THEN
4150      l_errflag := 'Y';
4151      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - full time '|| l_employee_categories|| l_is_gt_0 );
4152      --||' must be > 0 '||l_str_common);
4153    END IF;
4154    --
4155    --
4156 END IF;
4157 
4158 IF l_data_part2.l_reg_wg_ft_ot > 0 THEN
4159 l_str_common := 'An entry exists for regular wages and salaries for full time '|| l_employee_categories;
4160    --
4161    IF l_data_part3.l_contracted_hrs_paid_ft_ot = 0 THEN
4162      l_errflag := 'Y';
4163      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - full time '|| l_employee_categories|| l_is_gt_0 );
4164      --||' must be > 0 '||l_str_common );
4165    END IF;
4166    --
4167    IF l_data_part4.l_ann_leave_ft_ot = 0 THEN
4168      l_errflag := 'Y';
4169      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - full time '|| l_employee_categories|| l_is_gt_0 );
4170      --||' must be > 0 '||l_str_common);
4171    END IF;
4172    --
4173    --
4174 END IF;
4175 
4176 IF l_data_part2.l_irr_bonus_ft_ot > 0 THEN
4177 l_str_common := 'An entry exists for irregular bonuses and allowances for full time '|| l_employee_categories;
4178    --
4179    IF l_data_part2.l_reg_wg_ft_ot = 0 THEN
4180      l_errflag := 'Y';
4181      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - full time '|| l_employee_categories|| l_is_gt_0 );
4182      --||' must be > 0 '||l_str_common );
4183    END IF;
4184    --
4185    IF l_data_part3.l_contracted_hrs_paid_ft_ot = 0 THEN
4186      l_errflag := 'Y';
4187      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - full time '|| l_employee_categories|| l_is_gt_0 );
4188      --||' must be > 0 '||l_str_common );
4189    END IF;
4190    --
4191    IF l_data_part4.l_ann_leave_ft_ot = 0 THEN
4192      l_errflag := 'Y';
4193      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - full time '|| l_employee_categories|| l_is_gt_0 );
4194      --||' must be > 0 '||l_str_common );
4195    END IF;
4196 END IF;
4197 --
4198 IF l_data_part2.l_ot_paid_ft_ot > 0 THEN
4199 l_str_common := 'An entry exists for overtime for full time '|| l_employee_categories;
4200    --
4201    IF l_data_part2.l_reg_wg_ft_ot = 0 THEN
4202      l_errflag := 'Y';
4203      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - full time '|| l_employee_categories|| l_is_gt_0 );
4204      --||' must be > 0 '||l_str_common );
4205    END IF;
4206    --
4207    IF l_data_part3.l_contracted_hrs_paid_ft_ot = 0 THEN
4208      l_errflag := 'Y';
4209      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - full time '|| l_employee_categories|| l_is_gt_0 );
4210      --||' must be > 0 '||l_str_common );
4211    END IF;
4212    --
4213    IF l_data_part3.l_ot_hrs_paid_ft_ot = 0 THEN
4214      l_errflag := 'Y';
4215      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid overtime hours - full time '|| l_employee_categories|| l_is_gt_0 );
4216      --||' must be > 0 '||l_str_common );
4217    END IF;
4218    --
4219    IF l_data_part4.l_ann_leave_ft_ot = 0 THEN
4220      l_errflag := 'Y';
4221      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - full time '|| l_employee_categories|| l_is_gt_0 );
4222      --||' must be > 0 '||l_str_common );
4223    END IF;
4224    --
4225 END IF;
4226 --
4227 IF l_data_part3.l_contracted_hrs_paid_ft_ot > 0 THEN
4228 l_str_common := 'An entry exists for contracted hours for full time '|| l_employee_categories;
4229    --
4230    IF l_data_part2.l_reg_wg_ft_ot = 0 THEN
4231      l_errflag := 'Y';
4232      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - full time '|| l_employee_categories|| l_is_gt_0 );
4233      --||' must be > 0 '||l_str_common );
4234    END IF;
4235    --
4236    IF l_data_part4.l_ann_leave_ft_ot = 0 THEN
4237      l_errflag := 'Y';
4238      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - full time '|| l_employee_categories|| l_is_gt_0 );
4239      --||' must be > 0 '||l_str_common );
4240    END IF;
4241    --
4242 END IF;
4243 --
4244 
4245 IF l_data_part3.l_ot_hrs_paid_ft_ot > 0 THEN
4246 l_str_common := 'An entry exists for overtime hours for full time '|| l_employee_categories;
4247    --
4248    IF l_data_part2.l_reg_wg_ft_ot = 0 THEN
4249      l_errflag := 'Y';
4250      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - full time '|| l_employee_categories|| l_is_gt_0 );
4251      --||' must be > 0 '||l_str_common );
4252    END IF;
4253    --
4254    IF l_data_part3.l_contracted_hrs_paid_ft_ot = 0 THEN
4255      l_errflag := 'Y';
4256      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - full time '|| l_employee_categories|| l_is_gt_0 );
4257      --||' must be > 0 '||l_str_common );
4258    END IF;
4259    --
4260    IF l_data_part2.l_ot_paid_ft_ot = 0 THEN
4261      l_errflag := 'Y';
4262      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Overtime - full time '|| l_employee_categories|| l_is_gt_0 );
4263      --||' must be > 0 '||l_str_common );
4264    END IF;
4265    --
4266    IF l_data_part4.l_ann_leave_ft_ot = 0 THEN
4267      l_errflag := 'Y';
4268      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - full time '|| l_employee_categories|| l_is_gt_0 );
4269      --||' must be > 0 '||l_str_common );
4270    END IF;
4271    --
4272 END IF;
4273 
4274 IF (l_data_part4.l_ann_leave_ft_ot >0 OR l_data_part4.l_mat_leave_ft_ot > 0 OR
4275     l_data_part4.l_sck_leave_ft_ot >0 OR l_data_part4.l_other_leave_ft_ot >0 ) THEN
4276 l_str_common := 'An entry exists for Annual Leave and Bank Holidays or Maternity Leave or Sick Leave or Other Leave- full time '|| l_employee_categories;
4277    --
4278    IF l_data_part2.l_reg_wg_ft_ot = 0 THEN
4279      l_errflag := 'Y';
4280      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - full time '|| l_employee_categories|| l_is_gt_0 );
4281      --||' must be > 0 '||l_str_common );
4282    END IF;
4283    --
4284    IF l_data_part3.l_contracted_hrs_paid_ft_ot = 0 THEN
4285      l_errflag := 'Y';
4286      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - full time '|| l_employee_categories|| l_is_gt_0 );
4287      --||' must be > 0 '||l_str_common );
4288    END IF;
4289    --
4290 END IF;
4291 
4292 IF (l_data_part1.l_fst_pt_ot >0 OR l_data_part1.l_lst_pt_ot > 0 ) THEN
4293 l_str_common := 'An entry exists for part time '|| l_employee_categories ||' employed at '
4294 ||' the first day of the quarter or the last day of the quarter.';
4295    --
4296    IF l_data_part2.l_reg_wg_pt_ot = 0 THEN
4297      l_errflag := 'Y';
4298      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - part time '|| l_employee_categories|| l_is_gt_0 );
4299      --||' must be > 0 '||l_str_common );
4300    END IF;
4301    --
4302    IF l_data_part3.l_contracted_hrs_paid_pt_ot = 0 THEN
4303      l_errflag := 'Y';
4304      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - part time '|| l_employee_categories|| l_is_gt_0 );
4305      --||' must be > 0 '||l_str_common );
4306    END IF;
4307    --
4308    IF l_data_part4.l_ann_leave_pt_ot = 0 THEN
4309      l_errflag := 'Y';
4310      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - part time '|| l_employee_categories|| l_is_gt_0 );
4311      --||' must be > 0 '||l_str_common );
4312    END IF;
4313    --
4314 END IF;
4315 
4316 IF l_data_part2.l_reg_wg_pt_ot > 0 THEN
4317 l_str_common := 'An entry exists for regular wages and salaries for part time '|| l_employee_categories;
4318    --
4319    IF l_data_part3.l_contracted_hrs_paid_pt_ot = 0 THEN
4320      l_errflag := 'Y';
4321      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - part time '|| l_employee_categories|| l_is_gt_0 );
4322      --||' must be > 0 '||l_str_common );
4323    END IF;
4324    --
4325    IF l_data_part4.l_ann_leave_pt_ot = 0 THEN
4326      l_errflag := 'Y';
4327      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - part time '|| l_employee_categories|| l_is_gt_0 );
4328      --||' must be > 0 '||l_str_common );
4329    END IF;
4330    --
4331 END IF;
4332 
4333 IF l_data_part2.l_irr_bonus_pt_ot > 0 THEN
4334 l_str_common := 'An entry exists for irregular bonuses and allowances for part time '|| l_employee_categories;
4335    --
4336    IF l_data_part2.l_reg_wg_pt_ot = 0 THEN
4337      l_errflag := 'Y';
4338      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - part time '|| l_employee_categories|| l_is_gt_0 );
4339      --||' must be > 0 '||l_str_common );
4340    END IF;
4341    --
4342    IF l_data_part3.l_contracted_hrs_paid_pt_ot = 0 THEN
4343      l_errflag := 'Y';
4344      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - part time '|| l_employee_categories|| l_is_gt_0 );
4345      --||' must be > 0 '||l_str_common );
4346    END IF;
4347    --
4348    IF l_data_part4.l_ann_leave_pt_ot = 0 THEN
4349      l_errflag := 'Y';
4350      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - part time '|| l_employee_categories|| l_is_gt_0 );
4351      --||' must be > 0 '||l_str_common );
4352    END IF;
4353    --
4354 END IF;
4355 
4356 IF l_data_part2.l_ot_paid_pt_ot > 0 THEN
4357 l_str_common := 'An entry exists for overtime for part time '|| l_employee_categories;
4358    --
4359    IF l_data_part2.l_reg_wg_pt_ot = 0 THEN
4360      l_errflag := 'Y';
4361      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - part time '|| l_employee_categories|| l_is_gt_0 );
4362      --||' must be > 0 '||l_str_common );
4363    END IF;
4364    --
4365    IF l_data_part3.l_contracted_hrs_paid_pt_ot = 0 THEN
4366      l_errflag := 'Y';
4367      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - part time '|| l_employee_categories|| l_is_gt_0 );
4368      --||' must be > 0 '||l_str_common );
4369    END IF;
4370    --
4371    IF l_data_part3.l_ot_hrs_paid_pt_ot = 0 THEN
4372      l_errflag := 'Y';
4373      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid overtime hours - part time '|| l_employee_categories|| l_is_gt_0 );
4374      --||' must be > 0 '||l_str_common );
4375    END IF;
4376    --
4377    IF l_data_part4.l_ann_leave_pt_ot = 0 THEN
4378      l_errflag := 'Y';
4379      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - part time '|| l_employee_categories|| l_is_gt_0 );
4380      --||' must be > 0 '||l_str_common );
4381    END IF;
4382 END IF;
4383 
4384 IF l_data_part3.l_contracted_hrs_paid_pt_ot > 0 THEN
4385 l_str_common := 'An entry exists for paid contracted hours for part time '|| l_employee_categories;
4386    --
4387    IF l_data_part2.l_reg_wg_pt_ot = 0 THEN
4388      l_errflag := 'Y';
4389      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - part time '|| l_employee_categories|| l_is_gt_0 );
4390      --||' must be > 0 '||l_str_common );
4391    END IF;
4392    --
4393    IF l_data_part4.l_ann_leave_pt_ot = 0 THEN
4394      l_errflag := 'Y';
4395      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - part time '|| l_employee_categories|| l_is_gt_0 );
4396      --||' must be > 0 '||l_str_common );
4397    END IF;
4398 END IF;
4399 
4400 IF l_data_part3.l_ot_hrs_paid_pt_ot > 0 THEN
4401 l_str_common := 'An entry exists for overtime hours for part time '|| l_employee_categories;
4402    --
4403    IF l_data_part2.l_reg_wg_pt_ot = 0 THEN
4404      l_errflag := 'Y';
4405      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries - part time '|| l_employee_categories|| l_is_gt_0 );
4406      --||' must be > 0 '||l_str_common );
4407    END IF;
4408    --
4409    IF l_data_part4.l_ann_leave_pt_ot = 0 THEN
4410      l_errflag := 'Y';
4411      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays - part time '|| l_employee_categories|| l_is_gt_0 );
4412      --||' must be > 0 '||l_str_common );
4413    END IF;
4414    --
4415    IF l_data_part3.l_contracted_hrs_paid_pt_ot = 0 THEN
4416      l_errflag := 'Y';
4417      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours - part time '|| l_employee_categories|| l_is_gt_0 );
4418      --||' must be > 0 '||l_str_common );
4419    END IF;
4420 END IF;
4421 
4422 IF l_data_part_all_other.l_employer_pension_ot > 0 THEN
4423 l_str_common := ' An entry exists for Employers contributions to pension funds for '|| l_employee_categories;
4424    --
4425    IF l_data_part2.l_reg_wg_ft_ot = 0 AND l_data_part2.l_reg_wg_pt_ot = 0 AND l_data_part2.l_tot_wg_app_ot = 0 THEN
4426      l_errflag := 'Y';
4427      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries for any one of them - full time / part time / apprentice/trainee '|| l_is_gt_0 );
4428      --||' must be > 0 '||l_str_common );
4429    END IF;
4430    --
4431    IF l_data_part3.l_contracted_hrs_paid_ft_ot = 0 AND l_data_part3.l_contracted_hrs_paid_pt_ot = 0 AND l_data_part3.l_contracted_hrs_paid_app_ot = 0 THEN
4432      l_errflag := 'Y';
4433      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours for any one of them - full time / part time / apprentice/trainee '|| l_is_gt_0 );
4434      --||' must be > 0 '||l_str_common );
4435    END IF;
4436    --
4437    IF l_data_part4.l_ann_leave_ft_ot = 0 AND l_data_part4.l_ann_leave_pt_ot = 0 AND l_data_part4.l_all_paid_leave_app_ot = 0 THEN
4438      l_errflag := 'Y';
4439      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays for any one of them - full time / part time / apprentice/trainee '|| l_is_gt_0 );
4440      --||' must be > 0 '||l_str_common );
4441    END IF;
4442 END IF;
4443 
4444 IF ( l_data_part7.l_employer_prsi_ot > 0 OR l_data_part7.l_continuance_income_ot > 0 OR
4445      l_data_part7.l_redundacny_paid_ot > 0 OR l_data_part7.l_other_paid_ot > 0 ) THEN
4446 l_str_common := ' An entry exists for Social Security Contributions for full time and part time '|| l_employee_categories||' employees ';
4447 
4448    IF l_data_part2.l_reg_wg_ft_ot = 0 AND l_data_part2.l_reg_wg_pt_ot = 0 THEN
4449      l_errflag := 'Y';
4450      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries for any one of them - full time / part time '|| l_is_gt_0 );
4451      --||' must be > 0 '||l_str_common );
4452    END IF;
4453    --
4454    IF l_data_part3.l_contracted_hrs_paid_ft_ot = 0 AND l_data_part3.l_contracted_hrs_paid_pt_ot = 0 THEN
4455      l_errflag := 'Y';
4456      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours for any one of them - full time / part time '|| l_is_gt_0 );
4457      --||' must be > 0 '||l_str_common );
4458    END IF;
4459    --
4460    IF l_data_part4.l_ann_leave_ft_ot = 0 AND l_data_part4.l_ann_leave_pt_ot = 0 THEN
4461      l_errflag := 'Y';
4462      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays for any one of them - full time / part time '|| l_is_gt_0 );
4463      --||' must be > 0 '||l_str_common );
4464    END IF;
4465    --
4466 END If;
4467 
4468 IF (l_data_part8.l_company_car_ot > 0 OR l_data_part8.l_stock_options_ot > 0 OR
4469     l_data_part8.l_vol_sick_insurance_ot > 0 OR l_data_part8.l_staff_housing_ot > 0 OR
4470     l_data_part8.l_other_benefits_ot > 0 ) THEN
4471 l_str_common := 'An entry exists for Other Benefits to Employees - full time and part time '|| l_employee_categories;
4472    --
4473    IF l_data_part2.l_reg_wg_ft_ot = 0 AND l_data_part2.l_reg_wg_pt_ot = 0 THEN
4474      l_errflag := 'Y';
4475      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Regular wages and salaries for any one of them - full time / part time '|| l_is_gt_0 );
4476      --||' must be > 0 '||l_str_common );
4477    END IF;
4478    --
4479    --
4480    IF l_data_part3.l_contracted_hrs_paid_ft_ot = 0 AND l_data_part3.l_contracted_hrs_paid_pt_ot = 0 THEN
4481      l_errflag := 'Y';
4482      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours for any one of them - full time / part time '|| l_is_gt_0 );
4483      --||' must be > 0 '||l_str_common );
4484    END IF;
4485    --
4486    IF l_data_part4.l_ann_leave_ft_ot = 0 AND l_data_part4.l_ann_leave_pt_ot = 0 THEN
4487      l_errflag := 'Y';
4488      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Annual Leave and Bank Holidays for any one of them - full time / part time '|| l_is_gt_0 );
4489      --||' must be > 0 '||l_str_common );
4490    END IF;
4491 END IF;
4492 
4493 ----------------Section D: Apprentices/Trainees:
4494 l_employee_categories := 'apprentice/trainee managers, professionals and associate professionals';
4495 
4496 IF l_data_part1.l_app_mg >0  THEN
4497 l_str_common := 'An entry exists for the average number of '||l_employee_categories;
4498    --
4499    IF l_data_part2.l_tot_wg_app_mg = 0 THEN
4500      l_errflag := 'Y';
4501      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Total wages and salaries '|| l_employee_categories|| l_is_gt_0 );
4502      --||' must be > 0 '||l_str_common);
4503    END IF;
4504    --
4505    IF l_data_part3.l_contracted_hrs_paid_app_mg = 0 THEN
4506      l_errflag := 'Y';
4507      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours '|| l_employee_categories|| l_is_gt_0 );
4508      --||' must be > 0 '||l_str_common );
4509    END IF;
4510    --
4511    IF l_data_part4.l_all_paid_leave_app_mg = 0 THEN
4512      l_errflag := 'Y';
4513      Fnd_file.put_line(FND_FILE.LOG,'Ensure that All paid leave '|| l_employee_categories|| l_is_gt_0 );
4514      --||' must be > 0 '||l_str_common);
4515    END IF;
4516    --
4517 END IF;
4518 
4519 IF l_data_part2.l_tot_wg_app_mg > 0 THEN
4520 l_str_common := 'An entry exists for total wages and salaries for '|| l_employee_categories;
4521    --
4522    IF l_data_part3.l_contracted_hrs_paid_app_mg = 0 THEN
4523      l_errflag := 'Y';
4524      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours '|| l_employee_categories|| l_is_gt_0 );
4525      --||' must be > 0 '||l_str_common );
4526    END IF;
4527    --
4528    IF l_data_part4.l_all_paid_leave_app_mg = 0 THEN
4529      l_errflag := 'Y';
4530      Fnd_file.put_line(FND_FILE.LOG,'Ensure that All paid leave '|| l_employee_categories|| l_is_gt_0 );
4531      --||' must be > 0 '||l_str_common);
4532    END IF;
4533    --
4534 END IF;
4535 
4536 IF l_data_part3.l_contracted_hrs_paid_app_mg > 0 THEN
4537 l_str_common := 'An entry exists for paid contracted hours for '|| l_employee_categories;
4538    --
4539    IF l_data_part2.l_tot_wg_app_mg = 0 THEN
4540      l_errflag := 'Y';
4541      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Total wages and salaries '|| l_employee_categories|| l_is_gt_0 );
4542      --||' must be > 0 '||l_str_common );
4543    END IF;
4544    --
4545    IF l_data_part4.l_all_paid_leave_app_mg = 0 THEN
4546      l_errflag := 'Y';
4547      Fnd_file.put_line(FND_FILE.LOG,'Ensure that All paid leave '|| l_employee_categories|| l_is_gt_0 );
4548      --||' must be > 0 '||l_str_common );
4549    END IF;
4550 END IF;
4551 
4552 --
4553 IF l_data_part3.l_ot_hrs_paid_app_mg > 0 THEN
4554 l_str_common := 'An entry exists for overtime hours for '|| l_employee_categories ;
4555    --
4556    IF l_data_part2.l_tot_wg_app_mg = 0 THEN
4557      l_errflag := 'Y';
4558      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Total wages and salaries '|| l_employee_categories|| l_is_gt_0 );
4559      --||' must be > 0 '||l_str_common );
4560    END IF;
4561    --
4562    IF l_data_part3.l_contracted_hrs_paid_app_mg = 0 THEN
4563      l_errflag := 'Y';
4564      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours '|| l_employee_categories|| l_is_gt_0 );
4565      --||' must be > 0 '||l_str_common );
4566    END IF;
4567    --
4568    IF l_data_part4.l_all_paid_leave_app_mg = 0 THEN
4569      l_errflag := 'Y';
4570      Fnd_file.put_line(FND_FILE.LOG,'Ensure that All paid leave '|| l_employee_categories|| l_is_gt_0 );
4571      --||' must be > 0 '||l_str_common );
4572    END IF;
4573    --
4574 END IF;
4575 
4576 --
4577 IF l_data_part4.l_all_paid_leave_app_mg > 0 THEN
4578 l_str_common := 'An entry exists for All paid leave for '|| l_employee_categories;
4579    --
4580    IF l_data_part2.l_tot_wg_app_mg = 0 THEN
4581      l_errflag := 'Y';
4582      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Total wages and salaries '|| l_employee_categories|| l_is_gt_0 );
4583      --||' must be > 0 '||l_str_common );
4584    END IF;
4585    --
4586    IF l_data_part3.l_contracted_hrs_paid_app_mg = 0 THEN
4587      l_errflag := 'Y';
4588      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contract hours '|| l_employee_categories|| l_is_gt_0 );
4589      --||' must be > 0 '||l_str_common );
4590    END IF;
4591    --
4592 END IF;
4593 --
4594 
4595 IF l_data_part7.l_ssc_contributions_app_mg > 0 THEN
4596 l_str_common := 'An entry exists for total social security contributions for '|| l_employee_categories;
4597    --
4598    IF l_data_part2.l_tot_wg_app_mg = 0 THEN
4599      l_errflag := 'Y';
4600      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Total wages and salaries '|| l_employee_categories|| l_is_gt_0 );
4601      --||' must be > 0 '||l_str_common );
4602    END IF;
4603    --
4604    IF l_data_part3.l_contracted_hrs_paid_app_mg = 0 THEN
4605      l_errflag := 'Y';
4606      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours '|| l_employee_categories|| l_is_gt_0 );
4607      --||' must be > 0 '||l_str_common );
4608    END IF;
4609    --
4610    IF l_data_part4.l_all_paid_leave_app_mg = 0 THEN
4611      l_errflag := 'Y';
4612      Fnd_file.put_line(FND_FILE.LOG,'Ensure that All paid leave '|| l_employee_categories|| l_is_gt_0 );
4613      --||' must be > 0 '||l_str_common );
4614    END IF;
4615 END IF;
4616 -------------
4617 
4618 l_employee_categories := 'apprentice/trainee clerical, sales and service workers';
4619 
4620 IF l_data_part1.l_app_cl > 0  THEN
4621 l_str_common := 'An entry exists for the average number of '||l_employee_categories;
4622    --
4623    IF l_data_part2.l_tot_wg_app_cl = 0 THEN
4624      l_errflag := 'Y';
4625      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Total wages and salaries '|| l_employee_categories|| l_is_gt_0 );
4626      --||' must be > 0 '||l_str_common);
4627    END IF;
4628    --
4629    IF l_data_part3.l_contracted_hrs_paid_app_cl = 0 THEN
4630      l_errflag := 'Y';
4631      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours '|| l_employee_categories|| l_is_gt_0 );
4632      --||' must be > 0 '||l_str_common );
4633    END IF;
4634    --
4635    IF l_data_part4.l_all_paid_leave_app_cl = 0 THEN
4636      l_errflag := 'Y';
4637      Fnd_file.put_line(FND_FILE.LOG,'Ensure that All paid leave '|| l_employee_categories|| l_is_gt_0 );
4638      --||' must be > 0 '||l_str_common);
4639    END IF;
4640    --
4641 END IF;
4642 
4643 IF l_data_part2.l_tot_wg_app_cl > 0 THEN
4644 l_str_common := 'An entry exists for total wages and salaries for '|| l_employee_categories;
4645    --
4646    IF l_data_part3.l_contracted_hrs_paid_app_cl = 0 THEN
4647      l_errflag := 'Y';
4648      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours '|| l_employee_categories|| l_is_gt_0 );
4649      --||' must be > 0 '||l_str_common );
4650    END IF;
4651    --
4652    IF l_data_part4.l_all_paid_leave_app_cl = 0 THEN
4653      l_errflag := 'Y';
4654      Fnd_file.put_line(FND_FILE.LOG,'Ensure that All paid leave '|| l_employee_categories|| l_is_gt_0 );
4655      --||' must be > 0 '||l_str_common);
4656    END IF;
4657    --
4658 END IF;
4659 
4660 IF l_data_part3.l_contracted_hrs_paid_app_cl > 0 THEN
4661 l_str_common := 'An entry exists for paid contracted hours for '|| l_employee_categories;
4662    --
4663    IF l_data_part2.l_tot_wg_app_cl = 0 THEN
4664      l_errflag := 'Y';
4665      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Total wages and salaries '|| l_employee_categories|| l_is_gt_0 );
4666      --||' must be > 0 '||l_str_common );
4667    END IF;
4668    --
4669    IF l_data_part4.l_all_paid_leave_app_cl = 0 THEN
4670      l_errflag := 'Y';
4671      Fnd_file.put_line(FND_FILE.LOG,'Ensure that All paid leave '|| l_employee_categories|| l_is_gt_0 );
4672      --||' must be > 0 '||l_str_common );
4673    END IF;
4674 END IF;
4675 
4676 --
4677 IF l_data_part3.l_ot_hrs_paid_app_cl > 0 THEN
4678 l_str_common := 'An entry exists for overtime hours for '|| l_employee_categories ;
4679    --
4680    IF l_data_part2.l_tot_wg_app_cl = 0 THEN
4681      l_errflag := 'Y';
4682      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Total wages and salaries '|| l_employee_categories|| l_is_gt_0 );
4683      --||' must be > 0 '||l_str_common );
4684    END IF;
4685    --
4686    IF l_data_part3.l_contracted_hrs_paid_app_cl = 0 THEN
4687      l_errflag := 'Y';
4688      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours '|| l_employee_categories|| l_is_gt_0 );
4689      --||' must be > 0 '||l_str_common );
4690    END IF;
4691    --
4692    IF l_data_part4.l_all_paid_leave_app_cl = 0 THEN
4693      l_errflag := 'Y';
4694      Fnd_file.put_line(FND_FILE.LOG,'Ensure that All paid leave '|| l_employee_categories|| l_is_gt_0 );
4695      --||' must be > 0 '||l_str_common );
4696    END IF;
4697    --
4698 END IF;
4699 
4700 --
4701 IF l_data_part4.l_all_paid_leave_app_cl > 0 THEN
4702 l_str_common := 'An entry exists for All paid leave for '|| l_employee_categories;
4703    --
4704    IF l_data_part2.l_tot_wg_app_cl = 0 THEN
4705      l_errflag := 'Y';
4706      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Total wages and salaries '|| l_employee_categories|| l_is_gt_0 );
4707      --||' must be > 0 '||l_str_common );
4708    END IF;
4709    --
4710    IF l_data_part3.l_contracted_hrs_paid_app_cl = 0 THEN
4711      l_errflag := 'Y';
4712      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contract hours '|| l_employee_categories|| l_is_gt_0 );
4713      --||' must be > 0 '||l_str_common );
4714    END IF;
4715    --
4716 END IF;
4717 --
4718 
4719 IF l_data_part7.l_ssc_contributions_app_cl > 0 THEN
4720 l_str_common := 'An entry exists for total social security contributions for '|| l_employee_categories;
4721    --
4722    IF l_data_part2.l_tot_wg_app_cl = 0 THEN
4723      l_errflag := 'Y';
4724      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Total wages and salaries '|| l_employee_categories|| l_is_gt_0 );
4725      --||' must be > 0 '||l_str_common );
4726    END IF;
4727    --
4728    IF l_data_part3.l_contracted_hrs_paid_app_cl = 0 THEN
4729      l_errflag := 'Y';
4730      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours '|| l_employee_categories|| l_is_gt_0 );
4731      --||' must be > 0 '||l_str_common );
4732    END IF;
4733    --
4734    IF l_data_part4.l_all_paid_leave_app_cl = 0 THEN
4735      l_errflag := 'Y';
4736      Fnd_file.put_line(FND_FILE.LOG,'Ensure that All paid leave '|| l_employee_categories|| l_is_gt_0 );
4737      --||' must be > 0 '||l_str_common );
4738    END IF;
4739 END IF;
4740 -------------
4741 l_employee_categories := 'apprentice/trainee production, transport, craft, tradespersons and other manual workers';
4742 
4743 IF l_data_part1.l_app_ot > 0  THEN
4744 l_str_common := 'An entry exists for the average number of '||l_employee_categories;
4745    --
4746    IF l_data_part2.l_tot_wg_app_ot = 0 THEN
4747      l_errflag := 'Y';
4748      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Total wages and salaries '|| l_employee_categories|| l_is_gt_0 );
4749      --||' must be > 0 '||l_str_common);
4750    END IF;
4751    --
4752    IF l_data_part3.l_contracted_hrs_paid_app_ot = 0 THEN
4753      l_errflag := 'Y';
4754      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours '|| l_employee_categories|| l_is_gt_0 );
4755      --||' must be > 0 '||l_str_common );
4756    END IF;
4757    --
4758    IF l_data_part4.l_all_paid_leave_app_ot = 0 THEN
4759      l_errflag := 'Y';
4760      Fnd_file.put_line(FND_FILE.LOG,'Ensure that All paid leave '|| l_employee_categories|| l_is_gt_0 );
4761      --||' must be > 0 '||l_str_common);
4762    END IF;
4763    --
4764 END IF;
4765 
4766 IF l_data_part2.l_tot_wg_app_ot > 0 THEN
4767 l_str_common := 'An entry exists for total wages and salaries for '|| l_employee_categories;
4768    --
4769    IF l_data_part3.l_contracted_hrs_paid_app_ot = 0 THEN
4770      l_errflag := 'Y';
4771      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours '|| l_employee_categories|| l_is_gt_0 );
4772      --||' must be > 0 '||l_str_common );
4773    END IF;
4774    --
4775    IF l_data_part4.l_all_paid_leave_app_ot = 0 THEN
4776      l_errflag := 'Y';
4777      Fnd_file.put_line(FND_FILE.LOG,'Ensure that All paid leave '|| l_employee_categories|| l_is_gt_0 );
4778      --||' must be > 0 '||l_str_common);
4779    END IF;
4780    --
4781 END IF;
4782 
4783 IF l_data_part3.l_contracted_hrs_paid_app_ot > 0 THEN
4784 l_str_common := 'An entry exists for paid contracted hours for '|| l_employee_categories;
4785    --
4786    IF l_data_part2.l_tot_wg_app_ot = 0 THEN
4787      l_errflag := 'Y';
4788      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Total wages and salaries '|| l_employee_categories|| l_is_gt_0 );
4789      --||' must be > 0 '||l_str_common );
4790    END IF;
4791    --
4792    IF l_data_part4.l_all_paid_leave_app_ot = 0 THEN
4793      l_errflag := 'Y';
4794      Fnd_file.put_line(FND_FILE.LOG,'Ensure that All paid leave '|| l_employee_categories|| l_is_gt_0 );
4795      --||' must be > 0 '||l_str_common );
4796    END IF;
4797 END IF;
4798 
4799 --
4800 IF l_data_part3.l_ot_hrs_paid_app_ot > 0 THEN
4801 l_str_common := 'An entry exists for overtime hours for '|| l_employee_categories ;
4802    --
4803    IF l_data_part2.l_tot_wg_app_ot = 0 THEN
4804      l_errflag := 'Y';
4805      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Total wages and salaries '|| l_employee_categories|| l_is_gt_0 );
4806      --||' must be > 0 '||l_str_common );
4807    END IF;
4808    --
4809    IF l_data_part3.l_contracted_hrs_paid_app_ot = 0 THEN
4810      l_errflag := 'Y';
4811      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours '|| l_employee_categories|| l_is_gt_0 );
4812      --||' must be > 0 '||l_str_common );
4813    END IF;
4814    --
4815    IF l_data_part4.l_all_paid_leave_app_ot = 0 THEN
4816      l_errflag := 'Y';
4817      Fnd_file.put_line(FND_FILE.LOG,'Ensure that All paid leave '|| l_employee_categories|| l_is_gt_0 );
4818      --||' must be > 0 '||l_str_common );
4819    END IF;
4820    --
4821 END IF;
4822 
4823 --
4824 IF l_data_part4.l_all_paid_leave_app_ot > 0 THEN
4825 l_str_common := 'An entry exists for All paid leave for '|| l_employee_categories;
4826    --
4827    IF l_data_part2.l_tot_wg_app_ot = 0 THEN
4828      l_errflag := 'Y';
4829      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Total wages and salaries '|| l_employee_categories|| l_is_gt_0 );
4830      --||' must be > 0 '||l_str_common );
4831    END IF;
4832    --
4833    IF l_data_part3.l_contracted_hrs_paid_app_ot = 0 THEN
4834      l_errflag := 'Y';
4835      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contract hours '|| l_employee_categories|| l_is_gt_0 );
4836      --||' must be > 0 '||l_str_common );
4837    END IF;
4838    --
4839 END IF;
4840 --
4841 
4842 IF l_data_part7.l_ssc_contributions_app_ot > 0 THEN
4843 l_str_common := 'An entry exists for total social security contributions for '|| l_employee_categories;
4844    --
4845    IF l_data_part2.l_tot_wg_app_ot = 0 THEN
4846      l_errflag := 'Y';
4847      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Total wages and salaries '|| l_employee_categories|| l_is_gt_0 );
4848      --||' must be > 0 '||l_str_common );
4849    END IF;
4850    --
4851    IF l_data_part3.l_contracted_hrs_paid_app_ot = 0 THEN
4852      l_errflag := 'Y';
4853      Fnd_file.put_line(FND_FILE.LOG,'Ensure that Paid contracted hours '|| l_employee_categories|| l_is_gt_0 );
4854      --||' must be > 0 '||l_str_common );
4855    END IF;
4856    --
4857    IF l_data_part4.l_all_paid_leave_app_ot = 0 THEN
4858      l_errflag := 'Y';
4859      Fnd_file.put_line(FND_FILE.LOG,'Ensure that All paid leave '|| l_employee_categories|| l_is_gt_0 );
4860      --||' must be > 0 '||l_str_common );
4861    END IF;
4862 END IF;
4863 
4864 
4865 -----Section E: The total of all paid hours not worked cannot exceed the total of paid contracted hours for any given category of employees
4866 
4867 IF (  l_data_part4.l_ann_leave_ft_mg + l_data_part4.l_mat_leave_ft_mg +
4868        l_data_part4.l_sck_leave_ft_mg + l_data_part4.l_other_leave_ft_mg ) >
4869        l_data_part3.l_contracted_hrs_paid_ft_mg THEN
4870 
4871 	 l_str_common := 'Ensure that the sum of annual leave, maternity leave, sick leave and other leave for all full time'
4872 	 ||' managers, professionals and associate professional employees is less than total paid'
4873 	 ||' contracted hours for all full time managers, professional and associate professional employees.';
4874        l_errflag := 'Y';
4875        Fnd_file.put_line(FND_FILE.LOG,l_str_common);
4876 END IF;
4877 
4878 IF (l_data_part4.l_ann_leave_ft_cl + l_data_part4.l_mat_leave_ft_cl +
4879     l_data_part4.l_sck_leave_ft_cl + l_data_part4.l_other_leave_ft_cl) >
4880     l_data_part3.l_contracted_hrs_paid_ft_cl THEN
4881 
4882      l_str_common := 'Ensure that the sum of annual leave, maternity leave, sick leave and other leave for all full time'
4883      ||' clerical, sales and service workers is less than or equal to total paid contracted hours for'
4884      ||' all full time clerical, sales and service workers.';
4885      l_errflag := 'Y';
4886      Fnd_file.put_line(FND_FILE.LOG,l_str_common);
4887 END IF;
4888 
4889 IF (l_data_part4.l_ann_leave_ft_ot + l_data_part4.l_mat_leave_ft_ot +
4890    l_data_part4.l_sck_leave_ft_ot + l_data_part4.l_other_leave_ft_ot  ) >
4891    l_data_part3.l_contracted_hrs_paid_ft_ot THEN
4892 
4893      l_str_common := 'Ensure that the sum of annual leave, maternity leave, sick leave and other leave for all full time'
4894      ||' production, transport, craft, tradespersons and other manual workers is less than or equal to'
4895      ||' the total of paid contracted hours for all full time production, transport, craft, tradespersons and other manual workers.';
4896      l_errflag := 'Y';
4897      Fnd_file.put_line(FND_FILE.LOG,l_str_common);
4898 END IF;
4899 
4900 IF (l_data_part4.l_ann_leave_pt_mg + l_data_part4.l_mat_leave_pt_mg +
4901     l_data_part4.l_sck_leave_pt_mg + l_data_part4.l_other_leave_pt_mg) >
4902     l_data_part3.l_contracted_hrs_paid_pt_mg THEN
4903 
4904      l_str_common := 'Ensure that the sum of annual leave, maternity leave, sick leave and other leave for all part time managers,'
4905      ||' professionals and associate professional employees is less than or equal to total paid contracted hours for'
4906      ||' all part time managers, professional and associate professional employees.';
4907      l_errflag := 'Y';
4908      Fnd_file.put_line(FND_FILE.LOG,l_str_common);
4909 
4910 END IF;
4911 
4912 IF (l_data_part4.l_ann_leave_pt_cl + l_data_part4.l_mat_leave_pt_cl +
4913     l_data_part4.l_sck_leave_pt_cl + l_data_part4.l_other_leave_pt_cl) >
4914     l_data_part3.l_contracted_hrs_paid_pt_cl THEN
4915 
4916      l_str_common := 'The sum of annual leave, maternity leave, sick leave and other leave for all part time clerical,'
4917      ||' sales and service workers must be less than or equal to total paid contracted hours for all part time clerical,'
4918      ||' sales and service workers.';
4919      l_errflag := 'Y';
4920      Fnd_file.put_line(FND_FILE.LOG,l_str_common);
4921 END IF;
4922 
4923 IF ( l_data_part4.l_ann_leave_pt_ot + l_data_part4.l_mat_leave_pt_ot +
4924      l_data_part4.l_sck_leave_pt_ot + l_data_part4.l_other_leave_pt_ot) >
4925      l_data_part3.l_contracted_hrs_paid_pt_ot THEN
4926 
4927      l_str_common := 'Ensure that the sum of annual leave, maternity leave, sick leave and other leave for all part time production, '
4928      ||' transport, craft, tradespersons and other manual workers is less than or equal to the total of paid contracted '
4929      ||' hours for all part time production, transport, craft, tradespersons and other manual workers.';
4930      l_errflag := 'Y';
4931      Fnd_file.put_line(FND_FILE.LOG,l_str_common);
4932 END IF;
4933 
4934 IF ( l_data_part4.l_ann_leave_pt_ot + l_data_part4.l_mat_leave_pt_ot +
4935      l_data_part4.l_sck_leave_pt_ot + l_data_part4.l_other_leave_pt_ot) >
4936      l_data_part3.l_contracted_hrs_paid_pt_ot THEN
4937 	l_errflag := 'Y';
4938      l_str_common := 'Ensure that the sum of annual leave, maternity leave, sick leave and other leave for all part time production,'
4939      ||' transport, craft, tradespersons and other manual workers is less than or equal to the total of paid contracted '
4940      ||' hours for all part time production, transport, craft, tradespersons and other manual workers.';
4941      Fnd_file.put_line(FND_FILE.LOG,l_str_common);
4942 END IF;
4943 
4944 IF l_data_part4.l_all_paid_leave_app_mg > l_data_part3.l_contracted_hrs_paid_app_mg THEN
4945 	l_errflag := 'Y';
4946      l_str_common := 'Ensure that all paid leave for apprentice/trainee managers, professionals and associate professional employees '
4947      ||'is less than or equal to total paid contracted hours for all apprentice/trainee managers, professionals and '
4948      ||' associate professionals.';
4949      Fnd_file.put_line(FND_FILE.LOG,l_str_common);
4950 END IF;
4951 
4952 IF l_data_part4.l_all_paid_leave_app_cl > l_data_part3.l_contracted_hrs_paid_app_cl THEN
4953 	l_errflag := 'Y';
4954      l_str_common := 'Ensure that all paid leave for apprentice/trainee clerical, sales and service workers is less than'
4955      ||' or equal to total paid contracted hours for all apprentice/trainee clerical, sales and service workers.';
4956      Fnd_file.put_line(FND_FILE.LOG,l_str_common);
4957 END IF;
4958 
4959 IF l_data_part4.l_all_paid_leave_app_ot > l_data_part3.l_contracted_hrs_paid_app_ot THEN
4960 	l_errflag := 'Y';
4961      l_str_common := 'Ensure that all paid leave for apprentice/trainee production, transport, craft, tradespersons and other '
4962      ||' manual workers is less than or equal to total paid contracted hours for all apprentice/trainee '
4963      ||' production, transport, craft, tradespersons and other manual workers.';
4964      Fnd_file.put_line(FND_FILE.LOG,l_str_common);
4965 END IF;
4966 
4967 --6922250
4968 /*
4969 IF l_errflag = 'Y' THEN
4970     Raise l_ehecs_exception;
4971 END IF;
4972 */
4973 
4974   l_string:='<Data>';
4975   l_string:=l_string || '<FstFtMg>'  || l_data_part1.l_fst_ft_mg || '</FstFtMg>';
4976   l_string:=l_string || '<FstFtCl>'  || l_data_part1.l_fst_ft_cl || '</FstFtCl>';
4977   l_string:=l_string || '<FstFtOt>'  || l_data_part1.l_fst_ft_ot || '</FstFtOt>';
4978   l_string:=l_string || '<LstFtMg>'  || l_data_part1.l_lst_ft_mg || '</LstFtMg>';
4979   l_string:=l_string || '<LstFtCl>'  || l_data_part1.l_lst_ft_cl || '</LstFtCl>';
4980   l_string:=l_string || '<LstFtOt>'	 || l_data_part1.l_lst_ft_ot || '</LstFtOt>';
4981   l_string:=l_string || '<HireFtMg>' || l_data_part1.l_hire_ft_mg || '</HireFtMg>';
4982   l_string:=l_string || '<HireFtCl>' || l_data_part1.l_hire_ft_cl || '</HireFtCl>';
4983   l_string:=l_string || '<HireFtOt>' || l_data_part1.l_hire_ft_ot || '</HireFtOt>';
4984   l_string:=l_string || '<FstPtMg>' || l_data_part1.l_fst_pt_mg || '</FstPtMg>';
4985   l_string:=l_string || '<FstPtCl>' || l_data_part1.l_fst_pt_cl || '</FstPtCl>';
4986   l_string:=l_string || '<FstPtOt>' || l_data_part1.l_fst_pt_ot || '</FstPtOt>';
4987   l_string:=l_string || '<LstPtMg>' || l_data_part1.l_lst_pt_mg || '</LstPtMg>';
4988   l_string:=l_string || '<LstPtCl>' || l_data_part1.l_lst_pt_cl || '</LstPtCl>';
4989   l_string:=l_string || '<LstPtOt>' || l_data_part1.l_lst_pt_ot || '</LstPtOt>';
4990   l_string:=l_string || '<HirePtMg>' || l_data_part1.l_hire_pt_mg || '</HirePtMg>';
4991   l_string:=l_string || '<HirePtCl>' || l_data_part1.l_hire_pt_cl || '</HirePtCl>';
4992   l_string:=l_string || '<HirePtOt>' || l_data_part1.l_hire_pt_ot || '</HirePtOt>';
4993   l_string:=l_string || '<AppMg>' || l_data_part1.l_app_mg || '</AppMg>';
4994   l_string:=l_string || '<AppCl>' || l_data_part1.l_app_cl || '</AppCl>';
4995   l_string:=l_string || '<AppOt>' || l_data_part1.l_app_ot || '</AppOt>';
4996   l_string:=l_string || '<OtPerMg>' || l_data_part1.l_not_payroll_mg || '</OtPerMg>';
4997   l_string:=l_string || '<OtPerCl>' || l_data_part1.l_not_payroll_cl || '</OtPerCl>';
4998   l_string:=l_string || '<OtPerOt>' || l_data_part1.l_not_payroll_ot || '</OtPerOt>';
4999   l_string:=l_string || '<VacMg>' || l_data_part1.l_vac_mg || '</VacMg>';
5000   l_string:=l_string || '<VacCl>' || l_data_part1.l_vac_cl || '</VacCl>';
5001   l_string:=l_string || '<VacOt>' || l_data_part1.l_vac_ot || '</VacOt>';
5002   l_string:=l_string || '<NMWMg>' || l_data_part1.l_min_paid_mg || '</NMWMg>';
5003   l_string:=l_string || '<NMWCl>' || l_data_part1.l_min_paid_cl || '</NMWCl>';
5004   l_string:=l_string || '<NMWOt>' || l_data_part1.l_min_paid_ot || '</NMWOt>';
5005 
5006 --end loop;
5007 
5008 hr_utility.set_location('Before completing the l_data_part1: length(l_string) = '||length(l_string),3300);
5009 l_clob := l_clob||l_string;
5010 
5011 IF l_clob IS NOT NULL THEN
5012 	l_blob := c2b(l_clob);
5013 	pay_core_files.write_to_magtape_lob(l_blob);
5014 END IF;
5015 
5016 l_string:='';
5017 l_clob:='';
5018 
5019 --for l_data_part2 in c_get_part2(l_payroll_action_id)
5020 --loop
5021 hr_utility.set_location('entering c_get_part2 ',280);
5022   l_string:=l_string || '<RegWgFtMg>' || l_data_part2.l_reg_wg_ft_mg || '</RegWgFtMg>';
5023   l_string:=l_string || '<RegWgFtCl>' || l_data_part2.l_reg_wg_ft_cl || '</RegWgFtCl>';
5024   l_string:=l_string || '<RegWgFtOt>' || l_data_part2.l_reg_wg_ft_ot || '</RegWgFtOt>';
5025   l_string:=l_string || '<OvrtFtMg>' || l_data_part2.l_ot_paid_ft_mg || '</OvrtFtMg>';
5026   l_string:=l_string || '<OvrtFtCl>' || l_data_part2.l_ot_paid_ft_cl || '</OvrtFtCl>';
5027   l_string:=l_string || '<OvrtFtOt>' || l_data_part2.l_ot_paid_ft_ot || '</OvrtFtOt>';
5028   l_string:=l_string || '<IrrBFtMg>' || l_data_part2.l_irr_bonus_ft_mg || '</IrrBFtMg>';
5029   l_string:=l_string || '<IrrBFtCl>' || l_data_part2.l_irr_bonus_ft_cl || '</IrrBFtCl>';
5030   l_string:=l_string || '<IrrBFtOt>' || l_data_part2.l_irr_bonus_ft_ot || '</IrrBFtOt>';
5031   l_string:=l_string || '<RegWgPtMg>' || l_data_part2.l_reg_wg_pt_mg || '</RegWgPtMg>';
5032   l_string:=l_string || '<RegWgPtCl>' || l_data_part2.l_reg_wg_pt_cl || '</RegWgPtCl>';
5033   l_string:=l_string || '<RegWgPtOt>' || l_data_part2.l_reg_wg_pt_ot || '</RegWgPtOt>';
5034   l_string:=l_string || '<OvrtPtMg>' || l_data_part2.l_ot_paid_pt_mg || '</OvrtPtMg>';
5035   l_string:=l_string || '<OvrtPtCl>' || l_data_part2.l_ot_paid_pt_cl || '</OvrtPtCl>';
5036   l_string:=l_string || '<OvrtPtOt>' || l_data_part2.l_ot_paid_pt_ot || '</OvrtPtOt>';
5037   l_string:=l_string || '<IrrBPtMg>' || l_data_part2.l_irr_bonus_pt_mg || '</IrrBPtMg>';
5038   l_string:=l_string || '<IrrBPtCl>' || l_data_part2.l_irr_bonus_pt_cl || '</IrrBPtCl>';
5039   l_string:=l_string || '<IrrBPtOt>' || l_data_part2.l_irr_bonus_pt_ot || '</IrrBPtOt>';
5040   l_string:=l_string || '<AppWgMg>' || l_data_part2.l_tot_wg_app_mg || '</AppWgMg>';
5041   l_string:=l_string || '<AppWgCl>' || l_data_part2.l_tot_wg_app_cl || '</AppWgCl>';
5042   l_string:=l_string || '<AppWgOt>' || l_data_part2.l_tot_wg_app_ot || '</AppWgOt>';
5043 --  end loop;
5044 
5045   hr_utility.set_location('Before completing the l_data_part2: length(l_string) = '||length(l_string),3310);
5046 l_clob := l_clob||l_string;
5047 
5048 IF l_clob IS NOT NULL THEN
5049 	l_blob := c2b(l_clob);
5050 	pay_core_files.write_to_magtape_lob(l_blob);
5051 END IF;
5052 
5053 l_string:='';
5054 l_clob:='';
5055 --for l_data_part3 in c_get_part3(l_payroll_action_id)
5056 --loop
5057 hr_utility.set_location('entering c_get_part3 ',280);
5058    l_string:=l_string || '<CHrsFtMg>' || l_data_part3.l_contracted_hrs_paid_ft_mg || '</CHrsFtMg>';
5059   l_string:=l_string || '<CHrsFtCl>' || l_data_part3.l_contracted_hrs_paid_ft_cl || '</CHrsFtCl>';
5060   l_string:=l_string || '<CHrsFtOt>' || l_data_part3.l_contracted_hrs_paid_ft_ot || '</CHrsFtOt>';
5061   l_string:=l_string || '<OTHrFtMg>' || l_data_part3.l_ot_hrs_paid_ft_mg || '</OTHrFtMg>';
5062   l_string:=l_string || '<OTHrFtCl>' || l_data_part3.l_ot_hrs_paid_ft_cl || '</OTHrFtCl>';
5063   l_string:=l_string || '<OTHrFtOt>' || l_data_part3.l_ot_hrs_paid_ft_ot || '</OTHrFtOt>';
5064   l_string:=l_string || '<CHrsPtMg>' || l_data_part3.l_contracted_hrs_paid_pt_mg || '</CHrsPtMg>';
5065   l_string:=l_string || '<CHrsPtCl>' || l_data_part3.l_contracted_hrs_paid_pt_cl || '</CHrsPtCl>';
5066   l_string:=l_string || '<CHrsPtOt>' || l_data_part3.l_contracted_hrs_paid_pt_ot || '</CHrsPtOt>';
5067   l_string:=l_string || '<OTHrPtMg>' || l_data_part3.l_ot_hrs_paid_pt_mg || '</OTHrPtMg>';
5068   l_string:=l_string || '<OTHrPtCl>' || l_data_part3.l_ot_hrs_paid_pt_cl || '</OTHrPtCl>';
5069   l_string:=l_string || '<OTHrPtOt>' || l_data_part3.l_ot_hrs_paid_pt_ot || '</OTHrPtOt>';
5070   l_string:=l_string || '<CHrsApMg>' || l_data_part3.l_contracted_hrs_paid_app_mg || '</CHrsApMg>';
5071   l_string:=l_string || '<CHrsApCl>' || l_data_part3.l_contracted_hrs_paid_app_cl || '</CHrsApCl>';
5072   l_string:=l_string || '<CHrsApOt>' || l_data_part3.l_contracted_hrs_paid_app_ot || '</CHrsApOt>';
5073   l_string:=l_string || '<OTHrApMg>' || l_data_part3.l_ot_hrs_paid_app_mg || '</OTHrApMg>';
5074   l_string:=l_string || '<OTHrApCl>' || l_data_part3.l_ot_hrs_paid_app_cl || '</OTHrApCl>';
5075   l_string:=l_string || '<OTHrApOt>' || l_data_part3.l_ot_hrs_paid_app_ot || '</OTHrApOt>';
5076 --  end loop;
5077 
5078 hr_utility.set_location('Before completing the l_data_part3: length(l_string) = '||length(l_string),3320);
5079 l_clob := l_clob||l_string;
5080 
5081 IF l_clob IS NOT NULL THEN
5082 	l_blob := c2b(l_clob);
5083 	pay_core_files.write_to_magtape_lob(l_blob);
5084 END IF;
5085 
5086 l_string:='';
5087 l_clob:='';
5088 --for l_data_part4 in c_get_part4(l_payroll_action_id)
5089 --loop
5090 hr_utility.set_location('entering c_get_part4 ',280);
5091   l_string:=l_string || '<ALFtMg>'  || l_data_part4.l_ann_leave_ft_mg || '</ALFtMg>';
5092   l_string:=l_string || '<ALFtCl>'  || l_data_part4.l_ann_leave_ft_cl || '</ALFtCl>';
5093   l_string:=l_string || '<ALFtOt>'  || l_data_part4.l_ann_leave_ft_ot || '</ALFtOt>';
5094   l_string:=l_string || '<MatFtMg>' || l_data_part4.l_mat_leave_ft_mg || '</MatFtMg>';
5095   l_string:=l_string || '<MatFtCl>' || l_data_part4.l_mat_leave_ft_cl || '</MatFtCl>';
5096   l_string:=l_string || '<MatFtOt>' || l_data_part4.l_mat_leave_ft_ot || '</MatFtOt>';
5097   l_string:=l_string || '<SicFtMg>' || l_data_part4.l_sck_leave_ft_mg || '</SicFtMg>';
5098   l_string:=l_string || '<SicFtCl>' || l_data_part4.l_sck_leave_ft_cl || '</SicFtCl>';
5099   l_string:=l_string || '<SicFtOt>' || l_data_part4.l_sck_leave_ft_ot || '</SicFtOt>';
5100   l_string:=l_string || '<OtLFtMg>' || l_data_part4.l_other_leave_ft_mg || '</OtLFtMg>';
5101   l_string:=l_string || '<OtLFtCl>' || l_data_part4.l_other_leave_ft_cl || '</OtLFtCl>';
5102   l_string:=l_string || '<OtLFtOt>' || l_data_part4.l_other_leave_ft_ot || '</OtLFtOt>';
5103   l_string:=l_string || '<ALPtMg>'  || l_data_part4.l_ann_leave_pt_mg || '</ALPtMg>';
5104   l_string:=l_string || '<ALPtCl>'  || l_data_part4.l_ann_leave_pt_cl || '</ALPtCl>';
5105   l_string:=l_string || '<ALPtOt>'  || l_data_part4.l_ann_leave_pt_ot || '</ALPtOt>';
5106   l_string:=l_string || '<MatPtMg>' || l_data_part4.l_mat_leave_pt_mg || '</MatPtMg>';
5107   l_string:=l_string || '<MatPtCl>' || l_data_part4.l_mat_leave_pt_cl || '</MatPtCl>';
5108   l_string:=l_string || '<MatPtOt>' || l_data_part4.l_mat_leave_pt_ot || '</MatPtOt>';
5109   l_string:=l_string || '<SicPtMg>' || l_data_part4.l_sck_leave_pt_mg || '</SicPtMg>';
5110   l_string:=l_string || '<SicPtCl>' || l_data_part4.l_sck_leave_pt_cl || '</SicPtCl>';
5111   l_string:=l_string || '<SicPtOt>' || l_data_part4.l_sck_leave_pt_ot || '</SicPtOt>';
5112   l_string:=l_string || '<OtLPtMg>' || l_data_part4.l_other_leave_pt_mg || '</OtLPtMg>';
5113   l_string:=l_string || '<OtLPtCl>' || l_data_part4.l_other_leave_pt_cl || '</OtLPtCl>';
5114   l_string:=l_string || '<OtLPtOt>' || l_data_part4.l_other_leave_pt_ot || '</OtLPtOt>';
5115   l_string:=l_string || '<LApMg>'   || l_data_part4.l_all_paid_leave_app_mg || '</LApMg>';
5116   l_string:=l_string || '<LApCl>'   || l_data_part4.l_all_paid_leave_app_cl || '</LApCl>';
5117   l_string:=l_string || '<LApOt>'   || l_data_part4.l_all_paid_leave_app_ot || '</LApOt>';
5118 --end loop;
5119 
5120 hr_utility.set_location('Before completing the l_data_part4: length(l_string) = '||length(l_string),3330);
5121 l_clob := l_clob||l_string;
5122 
5123 IF l_clob IS NOT NULL THEN
5124 	l_blob := c2b(l_clob);
5125 	pay_core_files.write_to_magtape_lob(l_blob);
5126 END IF;
5127 
5128 /*
5129 open  c_get_part_all_other(l_payroll_action_id);
5130 fetch c_get_part_all_other into l_data_part_all_other;
5131 close c_get_part_all_other;
5132 */
5133 
5134 l_string:='';
5135 l_clob:='';
5136 
5137   l_string:=l_string || '<PenMg>'  || l_data_part_all_other.l_employer_pension_mg || '</PenMg>';
5138   l_string:=l_string || '<PenCl>'  || l_data_part_all_other.l_employer_pension_cl || '</PenCl>';
5139   l_string:=l_string || '<PenOt>'  || l_data_part_all_other.l_employer_pension_ot || '</PenOt>';
5140   l_string:=l_string || '<LibIns>' || l_data_part_all_other.l_employer_liability_premium || '</LibIns>';
5141 
5142 --for l_data_part7 in c_get_part7(l_payroll_action_id)
5143 --loop
5144 hr_utility.set_location('entering c_get_part7 ',280);
5145   l_string:=l_string || '<PRSIMg>'	|| l_data_part7.l_employer_prsi_mg || '</PRSIMg>';
5146   l_string:=l_string || '<PRSICl>'	|| l_data_part7.l_employer_prsi_cl || '</PRSICl>';
5147   l_string:=l_string || '<PRSIOt>'	|| l_data_part7.l_employer_prsi_ot || '</PRSIOt>';
5148   l_string:=l_string || '<IncCtMg>' || l_data_part7.l_continuance_income_mg || '</IncCtMg>';
5149   l_string:=l_string || '<IncCtCl>' || l_data_part7.l_continuance_income_cl || '</IncCtCl>';
5150   l_string:=l_string || '<IncCtOt>' || l_data_part7.l_continuance_income_ot || '</IncCtOt>';
5151   l_string:=l_string || '<RedMg>'	|| l_data_part7.l_redundacny_paid_mg || '</RedMg>';
5152   l_string:=l_string || '<RedCl>'	|| l_data_part7.l_redundacny_paid_cl || '</RedCl>';
5153   l_string:=l_string || '<RedOt>'	|| l_data_part7.l_redundacny_paid_ot || '</RedOt>';
5154   l_string:=l_string || '<OtSocMg>' || l_data_part7.l_other_paid_mg || '</OtSocMg>';
5155   l_string:=l_string || '<OtSocCl>' || l_data_part7.l_other_paid_cl || '</OtSocCl>';
5156   l_string:=l_string || '<OtSocOt>' || l_data_part7.l_other_paid_ot || '</OtSocOt>';
5157   l_string:=l_string || '<SSecApMg>' || l_data_part7.l_ssc_contributions_app_mg || '</SSecApMg>';
5158   l_string:=l_string || '<SSecApCl>' || l_data_part7.l_ssc_contributions_app_cl || '</SSecApCl>';
5159   l_string:=l_string || '<SSecApOt>' || l_data_part7.l_ssc_contributions_app_ot || '</SSecApOt>';
5160 --end loop;
5161 
5162 hr_utility.set_location('Before completing the l_data_part7: length(l_string) = '||length(l_string),3340);
5163 l_clob := l_clob||l_string;
5164 
5165 IF l_clob IS NOT NULL THEN
5166 	l_blob := c2b(l_clob);
5167 	pay_core_files.write_to_magtape_lob(l_blob);
5168 END IF;
5169 l_string:='';
5170 l_clob:='';
5171 --for l_data_part8 in c_get_part8(l_payroll_action_id)
5172 --loop
5173 hr_utility.set_location('entering c_get_part8 ',280);
5174    l_string:=l_string || '<CarMg>' || l_data_part8.l_company_car_mg || '</CarMg>';
5175   l_string:=l_string || '<CarCl>' || l_data_part8.l_company_car_cl || '</CarCl>';
5176   l_string:=l_string || '<CarOt>' || l_data_part8.l_company_car_ot || '</CarOt>';
5177   l_string:=l_string || '<StksMg>' || l_data_part8.l_stock_options_mg || '</StksMg>';
5178   l_string:=l_string || '<StksCl>' || l_data_part8.l_stock_options_cl || '</StksCl>';
5179   l_string:=l_string || '<StksOt>' || l_data_part8.l_stock_options_ot || '</StksOt>';
5180   l_string:=l_string || '<VHIMg>' || l_data_part8.l_vol_sick_insurance_mg || '</VHIMg>';
5181   l_string:=l_string || '<VHICl>' || l_data_part8.l_vol_sick_insurance_cl || '</VHICl>';
5182   l_string:=l_string || '<VHIOt>' || l_data_part8.l_vol_sick_insurance_ot || '</VHIOt>';
5183   l_string:=l_string || '<HseMg>' || l_data_part8.l_staff_housing_mg || '</HseMg>';
5184   l_string:=l_string || '<HseCl>' || l_data_part8.l_staff_housing_cl || '</HseCl>';
5185   l_string:=l_string || '<HseOt>' || l_data_part8.l_staff_housing_ot || '</HseOt>';
5186   l_string:=l_string || '<OtBenMg>' || l_data_part8.l_other_benefits_mg || '</OtBenMg>';
5187   l_string:=l_string || '<OtBenCl>' || l_data_part8.l_other_benefits_cl || '</OtBenCl>';
5188   l_string:=l_string || '<OtBenOt>' || l_data_part8.l_other_benefits_ot || '</OtBenOt>';
5189 --end loop;
5190 
5191 hr_utility.set_location('Before completing the l_data_part8: length(l_string) = '||length(l_string),3350);
5192 
5193 /*
5194 for l_data_part_all_other in c_get_part_all_other(l_payroll_action_id)
5195 loop
5196 */
5197 hr_utility.set_location('entering c_get_part others ',280);
5198   l_string:=l_string || '<TrExp>' || l_data_part_all_other.l_employer_training_costs || '</TrExp>';
5199   l_string:=l_string || '<OtExp>' || l_data_part_all_other.l_other_expenditure || '</OtExp>';
5200   l_string:=l_string || '<TrSub>' || l_data_part_all_other.l_training_subsudies || '</TrSub>';
5201   l_string:=l_string || '<OtSub>' || l_data_part_all_other.l_other_subsidies || '</OtSub>';
5202   l_string:=l_string || '<Rfund>' || l_data_part_all_other.l_refunds || '</Rfund>';
5203   --l_string:=l_string || '<FstFtMg>' || l_data_part_all_other.l_comment_line2 || '</FstFtMg>';
5204   --l_string:=l_string || '<FstFtMg>' || l_data_part_all_other.l_comment_line3 || '</FstFtMg>';
5205 /*end loop;*/
5206 l_string:=l_string||'</Data>';
5207 
5208 /*
5209 l_string:=l_string || '<comment>' || l_data_part_all_other.l_comment_line1 ||
5210                                          l_data_part_all_other.l_comment_line2 ||
5211 					 l_data_part_all_other.l_comment_line2 || '</comment>';
5212 */
5213 l_string:=l_string || '<Comment>' || g_comments || '</Comment>';
5214 
5215 l_string := l_string ||'</EHECS>'||EOL ;
5216 hr_utility.set_location('Before completing the l_data_part_all_other: length(l_string) = '||length(l_string),3360);
5217 
5218 l_clob := l_clob||l_string;
5219 
5220 IF l_clob IS NOT NULL THEN
5221 	l_blob := c2b(l_clob);
5222 	pay_core_files.write_to_magtape_lob(l_blob);
5223 END IF;
5224 	--l_buf := l_buf || '</EHECS>'||EOL ;
5225 
5226 --6922250
5227 l_str_common := 'The report completed with validation warning(s). Do not submit the generated XML file '
5228 		    ||'as it may not be in the correct format. You can, however, modify and use the template output.';
5229 
5230 IF l_errflag = 'Y' THEN
5231    Fnd_file.put_line(FND_FILE.LOG,l_str_common);
5232    error_message := FND_CONCURRENT.SET_COMPLETION_STATUS('WARNING',
5233 			  'EHECS Report completed with validation warning(s).');
5234 END IF;
5235 
5236 
5237 EXCEPTION
5238 WHEN l_ehecs_exception THEN
5239 	Hr_Utility.set_location('..'||'SQL-ERRM :'||SQLERRM,1223);
5240 	l_string := l_string ||'</EHECS>'||EOL ;
5241 	l_clob := l_clob||l_string;
5242 	IF l_clob IS NOT NULL THEN
5243 		l_blob := c2b(l_clob);
5244 		pay_core_files.write_to_magtape_lob(l_blob);
5245 	END IF;
5246 	error_message := FND_CONCURRENT.SET_COMPLETION_STATUS('ERROR','EHECS Report errors out.');
5247 WHEN Others THEN
5248 	Hr_Utility.set_location('..'||'SQL-ERRM :'||SQLERRM,3370);
5249 	l_string := l_string ||'</EHECS>'||EOL ;
5250 	l_clob := l_clob||l_string;
5251 	IF l_clob IS NOT NULL THEN
5252 		l_blob := c2b(l_clob);
5253 		pay_core_files.write_to_magtape_lob(l_blob);
5254 	END IF;
5255 
5256 end gen_footer_xml;
5257 
5258 procedure archive_deinit(pactid IN NUMBER)
5259  IS
5260  l_action_info_id NUMBER;
5261  l_ovn NUMBER;
5262 begin
5263  null;
5264 end archive_deinit;
5265 END PAY_IE_EHECS_REPORT_PKG;