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