[Home] [Help]
PACKAGE BODY: APPS.AMW_FINSTMT_CERT_PVT
Source
1 PACKAGE BODY AMW_FINSTMT_CERT_PVT as
2 /* $Header: amwvfscb.pls 120.4 2006/05/25 23:52:58 npanandi noship $ */
3
4 g_user_id NUMBER;
5 g_login_id NUMBER;
6 g_errbuf VARCHAR2(2000) := null;
7 g_retcode VARCHAR2(2);
8
9 G_PKG_NAME CONSTANT VARCHAR2 (30) := 'AMW_FINSTMT_CERT_PVT';
10 G_API_NAME CONSTANT VARCHAR2 (15) := 'amwvfcsb.pls';
11
12
13 /************comment by dong ************************
14 before AMW.D
15 this package was composed of 5 major procedures. one is main procedure, which calls the other
16 4 procedures to populate data in dashboard, process, organization and financial item-accounts
17 Main: Populate_Fin_Stmt_Cert_Sum:
18 1)Populate_All_Cert_General_Sum
19 2)Populate_All_Fin_Proc_Eval_Sum
20 3)Populate_All_Fin_Org_Eval_Sum
21 4)build_amw_fin_cert_eval_sum
22
23 after AMW.D
24 this package is composed of 2 procedures. one is main procedure, which is the similar as the one
25 before amw.d. but this new main procedure only calls one procedure which is Populate_All_Fin_Proc_Eval_Sum.
26 within in this one sub_procedure, we populate all of summary tables. note: all of logic are embeded in
27 anther package AMW_FINSTMT_CERT_BES_PKG, which is new pl/slq package from amw.d
28
29 Major feature in AMW.D is 1) bussiness event 2) combine previous independent 4 procedures into 1 proceudre.
30 so the execution order is critical.
31
32 ***************************************************************/
33
34
35
36
37
38
39 PROCEDURE Update_Next_Level_Proc_Info(p_process_id IN NUMBER, p_org_id IN NUMBER, p_certification_id IN NUMBER) is
40
41 cursor c2 (l_process_id number,l_org_id number) is
42 select CHILD_PROCESS_ID
43 from Amw_Process_Org_Relations
44 where PARENT_PROCESS_ID=l_process_id and ORGANIZATION_ID = l_org_id;
45
46 c2_rec c2%rowtype;
47
48 l_sum_certified number;
49 l_subprocess_total number;
50 l_audit_result varchar2(50);
51
52
53
54 BEGIN
55
56 --Initialise the sums for each process to zero - no. of next-level subprocesses/ number among them --certified
57
58 l_sum_certified := 0;
59 l_subprocess_total := 0;
60
61 -- loop through the org hierarchy and calculate sub_processes certified stats
62 for c2_rec in c2(p_process_id, p_org_id) loop
63
64 exit when c2%notfound;
65
66 -- Increment counter for next level subprocesses
67 l_subprocess_total := l_subprocess_total + 1;
68
69 -- Fetch the certification result for each next level subprocess
70
71
72 select opinion.audit_result INTO l_audit_result
73 FROM AMW_OPINIONS_V opinion, AMW_OPINION_TYPES_TL opiniontype, FND_OBJECTS fndobject, AMW_OBJECT_OPINION_TYPES objectopiniontype
74 WHERE
75
76 (opinion.AUTHORED_DATE in (Select MAX(opinion.AUTHORED_DATE)
77 from AMW_OPINIONS_V opinion
78 Group By PK1_VALUE)) AND
79
80 opinion.PK3_VALUE = p_org_id AND
81 opinion.PK2_VALUE = p_certification_id AND
82 opinion.PK1_VALUE = c2_rec.CHILD_PROCESS_ID AND
83 opinion.OBJECT_OPINION_TYPE_ID = objectopiniontype.OBJECT_OPINION_TYPE_ID AND
84 opiniontype.OPINION_TYPE_ID = objectopiniontype.OPINION_TYPE_ID AND
85 opiniontype.OPINION_TYPE_NAME = 'Certification' AND
86 opiniontype.LANGUAGE = 'US' AND
87 fndobject.OBJECT_ID = objectopiniontype.OBJECT_ID AND
88 fndobject.obj_name = 'AMW_ORG_PROCESS';
89
90 -- Increment the counter of those certified appropriately
91
92 If ((l_audit_result = 'Certified') or (l_audit_result = 'Certified with Issues'))
93
94 then l_sum_certified := l_sum_certified + 1;
95
96 end if;
97
98 end loop;
99
100 -- /* Update the summary table with the certified subprocess info*/
101
102 g_user_id := fnd_global.user_id;
103 Update AMW_PROC_CERT_EVAL_SUM
104 SET SUB_PROCESS_CERT = l_sum_certified,TOTAL_SUB_PROCESS_CERT = l_subprocess_total, LAST_UPDATE_DATE = SYSDATE, LAST_UPDATED_BY = G_USER_ID
105 where PROCESS_ID = p_process_id and CERTIFICATION_ID = p_certification_id and ORGANIZATION_ID = p_org_id;
106
107 EXCEPTION
108 WHEN NO_DATA_FOUND
109 THEN
110 fnd_file.put_line (fnd_file.LOG, SUBSTR ('No data found in Update_Next_Level_Proc_Info'
111 || SUBSTR (SQLERRM, 1, 100), 1, 200));
112
113 WHEN OTHERS
114 THEN
115 fnd_file.put_line (fnd_file.LOG, SUBSTR ('Unexpected Error in Update_Next_Level_Proc_Info'
116 || SUBSTR (SQLERRM, 1, 100), 1, 200));
117
118 ---COMMIT;
119 end Update_Next_Level_Proc_Info;
120
121
122
123
124
125
126 --Update the summary table with the certification status (audit_result_code) - to facilitate image lookups etc.,last_updated_by, last_update_time for all these processes */
127
128
129 Procedure Update_Certification_Detail(p_process_id IN NUMBER, p_org_id IN NUMBER, p_certification_id IN NUMBER) is
130
131
132
133 BEGIN
134 g_user_id := fnd_global.user_id;
135
136 Update AMW_PROC_CERT_EVAL_SUM
137 SET (CERTIFICATION_OPINION_ID) =
138 (select opinion.OPINION_ID
139 FROM AMW_OPINIONS_V opinion, AMW_OPINION_TYPES_TL opiniontype, FND_OBJECTS fndobject, AMW_OBJECT_OPINION_TYPES objectopiniontype
140 WHERE
141
142 (opinion.AUTHORED_DATE in (Select MAX(AMW_OPINIONS_V.AUTHORED_DATE)
143 from AMW_OPINIONS_V
144 Group By PK1_VALUE)) AND
145 opinion.PK3_VALUE = p_org_id AND
146 opinion.PK2_VALUE = p_certification_id AND
147 opinion.PK1_VALUE = p_process_id AND
148 opinion.OBJECT_OPINION_TYPE_ID = objectopiniontype.OBJECT_OPINION_TYPE_ID AND
149 opiniontype.OPINION_TYPE_ID = objectopiniontype.OPINION_TYPE_ID AND
150 opiniontype.OPINION_TYPE_NAME = 'Certification' AND
151 opiniontype.LANGUAGE = 'US' AND
152 fndobject.OBJECT_ID = objectopiniontype.OBJECT_ID AND
153 fndobject.obj_name = 'AMW_ORG_PROCESS'), LAST_UPDATE_DATE = SYSDATE, LAST_UPDATED_BY = G_USER_ID
154 WHERE PROCESS_ID = p_process_id and CERTIFICATION_ID = p_certification_id and ORGANIZATION_ID = p_org_id;
155
156 EXCEPTION
157 WHEN NO_DATA_FOUND
158 THEN
159 fnd_file.put_line (fnd_file.LOG, SUBSTR ('No data found in Update_Certification_Detail'
160 || SUBSTR (SQLERRM, 1, 100), 1, 200));
161
162 WHEN OTHERS
163 THEN
164 fnd_file.put_line (fnd_file.LOG, SUBSTR ('Unexpected Error in Update_Certification_Detail'
165 || SUBSTR (SQLERRM, 1, 100), 1, 200));
166
167
168
169
170 END Update_Certification_Detail;
171
172
173
174
175
176 -- For each process, calculate number of orgs in which the process is present, restricted by scope of the certification
177
178 PROCEDURE UPDATE_GLOBAL_PROC_INFO(p_process_id IN NUMBER, p_certification_id IN NUMBER, p_global_org_id IN NUMBER) is
179
180 l_total_org_cert NUMBER;
181 l_org_cert NUMBER;
182
183
184
185 BEGIN
186
187 -- Set Global Process flag for each row of the global process, also update the total no. of orgs in which
188 -- the process is executed in
189 g_user_id := fnd_global.user_id;
190 Update AMW_PROC_CERT_EVAL_SUM
191 SET TOTAL_ORG_PROCESS_CERT =
192 (Select distinct count(*) from AMW_PROCESS_ORGANIZATION processorg where
193 (processorg.PROCESS_ID = p_process_id) and
194 (processorg.ORGANIZATION_ID = p_global_org_id))
195 , GLOBAL_PROCESS ='Y', LAST_UPDATE_DATE = SYSDATE, LAST_UPDATED_BY = G_USER_ID
196 where PROCESS_ID = p_process_id and CERTIFICATION_ID = p_certification_id
197 and ORGANIZATION_ID = p_global_org_id;
198
199 -- Update the row again with number of orgs where the process is certified
200 Update AMW_PROC_CERT_EVAL_SUM
201 SET ORG_PROCESS_CERT =
202 (
203 select distinct count(*)
204 FROM AMW_OPINIONS_V opinion, AMW_OPINION_TYPES_TL opiniontype, FND_OBJECTS fndobject, AMW_OBJECT_OPINION_TYPES objectopiniontype
205 WHERE
206
207 (opinion.AUTHORED_DATE in (Select MAX(AMW_OPINIONS_V.AUTHORED_DATE)
208 from AMW_OPINIONS_V
209 Group By PK1_VALUE)) AND
210 opinion.PK2_VALUE = p_certification_id AND
211 opinion.PK1_VALUE = p_process_id AND
212 opinion.OBJECT_OPINION_TYPE_ID = objectopiniontype.OBJECT_OPINION_TYPE_ID AND
213 opiniontype.OPINION_TYPE_ID = objectopiniontype.OPINION_TYPE_ID AND
214 opiniontype.OPINION_TYPE_NAME = 'Certification' AND
215 opiniontype.LANGUAGE = 'US' AND
216 fndobject.OBJECT_ID = objectopiniontype.OBJECT_ID AND
217 fndobject.obj_name = 'AMW_ORG_PROCESS' AND
218 ((opinion.AUDIT_RESULT = 'Certified') OR (opinion.AUDIT_RESULT = 'Certified with Issues'))
219 ), LAST_UPDATE_DATE = SYSDATE, LAST_UPDATED_BY = G_USER_ID
220 WHERE PROCESS_ID = p_process_id and CERTIFICATION_ID = p_certification_id and ORGANIZATION_ID = p_global_org_id;
221
222
223 EXCEPTION
224 WHEN NO_DATA_FOUND
225 THEN
226 fnd_file.put_line (fnd_file.LOG, SUBSTR ('No data found in Update_Global_Proc_Info'
227 || SUBSTR (SQLERRM, 1, 100), 1, 200));
228
229
230 WHEN OTHERS
231 THEN
232 fnd_file.put_line (fnd_file.LOG, SUBSTR ('Unexpected Error in Update_Global_Proc_Info'
233 || SUBSTR (SQLERRM, 1, 100), 1, 200));
234
235
236
237 END UPDATE_GLOBAL_PROC_INFO;
238
239
240
241
242
243 -- The last evaluation results, unmitigated risks, ineffective controls and open findings are all populated based on audit opinions
244
245 PROCEDURE UPDATE_LAST_EVALUATION_INFO(p_process_id IN NUMBER, p_org_id IN NUMBER,p_certification_id IN NUMBER) is
246
247
248
249 BEGIN
250 g_user_id := fnd_global.user_id;
251
252 Update AMW_PROC_CERT_EVAL_SUM
253 SET (EVALUATION_OPINION_ID) =
254 (
255 select opinion.OPINION_ID
256 FROM AMW_OPINIONS_V opinion, AMW_OPINION_TYPES_TL opiniontype, FND_OBJECTS fndobject, AMW_OBJECT_OPINION_TYPES objectopiniontype
257 WHERE
258
259 (opinion.AUTHORED_DATE in (Select MAX(AMW_OPINIONS_V.AUTHORED_DATE)
260 from AMW_OPINIONS_V
261 Group By PK1_VALUE)) AND
262 opinion.PK1_VALUE = p_process_id AND
263 opinion.PK3_VALUE = p_org_id AND
264 opinion.OBJECT_OPINION_TYPE_ID = objectopiniontype.OBJECT_OPINION_TYPE_ID AND
265 opiniontype.OPINION_TYPE_ID = objectopiniontype.OPINION_TYPE_ID AND
266 opiniontype.OPINION_TYPE_NAME = 'Evaluation' AND
267 opiniontype.LANGUAGE = 'US' AND
268 fndobject.OBJECT_ID = objectopiniontype.OBJECT_ID AND
269 fndobject.obj_name = 'AMW_ORG_PROCESS'
270 ) , LAST_UPDATE_DATE = SYSDATE, LAST_UPDATED_BY = G_USER_ID
271 WHERE PROCESS_ID = p_process_id and CERTIFICATION_ID = p_certification_id and ORGANIZATION_ID = p_org_id;
272
273 EXCEPTION
274 WHEN NO_DATA_FOUND
275 THEN
276 fnd_file.put_line (fnd_file.LOG, SUBSTR ('No data found in Update_Last_Evaluation_Info'
277 || SUBSTR (SQLERRM, 1, 100), 1, 200));
278
279 WHEN OTHERS
280 THEN
281 fnd_file.put_line (fnd_file.LOG, SUBSTR ('Unexpected Error in Update_Last_Evaluation_Info'
282 || SUBSTR (SQLERRM, 1, 100), 1, 200));
283
284
285 END UPDATE_LAST_EVALUATION_INFO;
286
287
288
289
290 PROCEDURE UPDATE_UNMITIGATED_RISKS(p_process_id IN NUMBER, p_org_id IN NUMBER, p_certification_id IN NUMBER) is
291
292
293
294 BEGIN
295 g_user_id := fnd_global.user_id;
296
297 Update AMW_PROC_CERT_EVAL_SUM
298 SET UNMITIGATED_RISKS =
299 (
300 select distinct count(*)
301 from amw_risk_associations assoctable,
302 amw_risks_all_vl risktable,
303 amw_audit_units_v orgtable,
304 amw_wf_org_hierarchy_main_v processtable,
305 fnd_objects fo,
306 amw_opinion_types_tl optypes,
307 AMW_OBJECT_OPINION_TYPES objoptypes,
308 amw_opinions_v opinionstable,
309 pa_project_lists_v pap,
310 AMW_PROCESS_ORGANIZATION procorg
311
312 where assoctable.object_type = 'PROCESS_ORG'
313 and orgtable.organization_id = procorg.organization_id
314 and processtable.process_id = procorg.process_id
315 and assoctable.risk_id = risktable.risk_id
316 and assoctable.pk1 = procorg.PROCESS_ORGANIZATION_ID
317 and opinionstable.pk1_value = assoctable.risk_id
318 and opinionstable.pk3_value = procorg.organization_id
319 and opinionstable.pk3_value = p_org_id
320 and opinionstable.pk4_value = procorg.process_id
321 and opinionstable.pk4_value = p_process_id
322 and opinionstable.pk5_value is null
323 and opinionstable.object_opinion_type_id =
324 objoptypes.object_opinion_type_id
325
326 and opinionstable.last_update_date in
327 ( select max ( a.last_update_date )
328 from amw_opinions_v a
329 where a.pk1_value = opinionstable.pk1_value
330 and a.pk3_value = opinionstable.pk3_value
331 and a.pk4_value = opinionstable.pk4_value
332 and a.object_opinion_type_id =
333 opinionstable.object_opinion_type_id
334 group by a.pk1_value )
335
336 and opinionstable.audit_result_code = 'INEFFECTIVE'
337 and pap.project_id = opinionstable.pk2_value
338 and pap.project_status_code = 'CLOSED'
339
340 and objoptypes.object_id = fo.object_id
341 and fo.obj_name = 'AMW_ORG_PROCESS_RISK'
342 and objoptypes.opinion_type_id = optypes.opinion_type_id
343 and optypes.opinion_type_name = 'Evaluation'
344 and optypes.LANGUAGE = 'US'
345
346 ) , LAST_UPDATE_DATE = SYSDATE, LAST_UPDATED_BY = G_USER_ID
347 WHERE PROCESS_ID = p_process_id and CERTIFICATION_ID = p_certification_id and ORGANIZATION_ID = p_org_id;
348
349
350 EXCEPTION
351 WHEN NO_DATA_FOUND
352 THEN
353 fnd_file.put_line (fnd_file.LOG, SUBSTR ('No data found in Update_Unmitigated_Risks'
354 || SUBSTR (SQLERRM, 1, 100), 1, 200));
355
356 WHEN OTHERS
357 THEN
358 fnd_file.put_line (fnd_file.LOG, SUBSTR ('Unexpected Error in Update_Unmitigated_Risks'
359 || SUBSTR (SQLERRM, 1, 100), 1, 200));
360
361
362
363 END UPDATE_UNMITIGATED_RISKS;
364
365
366
367 PROCEDURE UPDATE_INEFFECTIVE_CONTROLS(p_process_id IN NUMBER, p_org_id IN NUMBER, p_certification_id IN NUMBER) is
368
369
370
371
372 BEGIN
373 g_user_id := fnd_global.user_id;
374
375 Update AMW_PROC_CERT_EVAL_SUM
376 SET INEFFECTIVE_CONTROLS =
377 (select distinct Count(*)
378
379 from amw_control_associations ctrlassoc,
380 amw_risk_associations riskassoc,
381 amw_process_organization procorg,
382 amw_controls_all_vl controltable,
383 amw_audit_units_v orgtable,
384 amw_wf_org_hierarchy_main_v processtable,
385 fnd_objects fo,
386 amw_opinion_types_tl optypes,
387 AMW_OBJECT_OPINION_TYPES objoptypes,
388 pa_project_lists_v pap,
389 amw_opinions_v opinionstable
390
391 where procorg.process_id = processtable.process_id
392 and procorg.process_id = p_process_id
393 and procorg.organization_id = orgtable.organization_id
394 and procorg.organization_id = p_org_id
395 and procorg.process_organization_id = riskassoc.pk1
396 and riskassoc.object_type = 'PROCESS_ORG'
397 and riskassoc.risk_association_id = ctrlassoc.pk1
398 and ctrlassoc.object_type = 'RISK_ORG'
399 and ctrlassoc.control_id = controltable.control_id
400
401 and opinionstable.pk1_value = controltable.control_id
402 and opinionstable.pk3_value = orgtable.organization_id
403 and opinionstable.pk4_value is null
404 and opinionstable.pk5_value is null
405 and opinionstable.object_opinion_type_id =
406 objoptypes.object_opinion_type_id
407
408 and opinionstable.last_update_date in
409 ( select max ( a.last_update_date )
410 from amw_opinions_v a
411 where a.pk1_value = opinionstable.pk1_value
412 and a.pk3_value = opinionstable.pk3_value
413 and a.object_opinion_type_id =
414 opinionstable.object_opinion_type_id
415 group by a.pk1_value )
416
417 and opinionstable.audit_result_code = 'INEFFECTIVE'
418 and pap.project_id = opinionstable.pk2_value
419 and pap.project_status_code = 'CLOSED'
420
421 and objoptypes.object_id = fo.object_id
422 and fo.obj_name = 'AMW_ORG_CONTROL'
423 and objoptypes.opinion_type_id = optypes.opinion_type_id
424 and optypes.opinion_type_name = 'Evaluation'
425 and optypes.LANGUAGE = 'US'
426 ), LAST_UPDATE_DATE = SYSDATE, LAST_UPDATED_BY = G_USER_ID
427 WHERE PROCESS_ID = p_process_id and CERTIFICATION_ID = p_certification_id and ORGANIZATION_ID = p_org_id;
428
429 EXCEPTION
430 WHEN NO_DATA_FOUND
431 THEN
432 fnd_file.put_line (fnd_file.LOG, SUBSTR ('No data found in Update_Ineffective_Controls'
433 || SUBSTR (SQLERRM, 1, 100), 1, 200));
434
435 WHEN OTHERS
436 THEN
437 fnd_file.put_line (fnd_file.LOG, SUBSTR ('Unexpected Error in Update_Ineffective_Controls'
438 || SUBSTR (SQLERRM, 1, 100), 1, 200));
439
440
441
442 END UPDATE_INEFFECTIVE_CONTROLS;
443
444
445
446
447 PROCEDURE Populate_Summary(p_certification_id IN VARCHAR2) IS
448
449 -- select all processes
450
451 cursor proc is
452
453 select process_id, organization_id
454 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc,
455 AMW_ACCT_ASSOCIATIONS acct_assoc, AMW_PROCESS_ORGANIZATION process_org
456 where cert.certification_id = p_certification_id and cert.object_type = 'FIN_STMT'
457 and cert.statement_group_id = key_acc.statement_group_id and
458 cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID and
459 acct_assoc.natural_account_id = key_acc.natural_account_id and
460 acct_assoc.object_type = 'PROCESS_ORG' and
461 process_org.process_organization_id = acct_assoc.pk1;
462
463 c1_rec proc%rowtype;
464
465 proc_rec proc%rowtype;
466
467 l_global_org_id NUMBER;
468 l_count NUMBER;
469
470
471 BEGIN
472 -- Insert all this info into the summary table with one row per process, org.
473 l_global_org_id := fnd_profile.value('AMW_GLOBAL_ORG_ID');
474 g_user_id := fnd_global.user_id;
475 g_login_id := fnd_global.conc_login_id;
476
477 for proc_rec in proc loop
478
479 select count(*) into l_count from amw_proc_cert_eval_sum
480 where certification_id = p_certification_id and
481 process_id = proc_rec.process_id and organization_id = proc_rec.organization_id;
482
483 if l_count = 0 then
484
485 INSERT into AMW_PROC_CERT_EVAL_SUM(CERTIFICATION_ID, PROCESS_ID, ORGANIZATION_ID, CREATED_BY, CREATION_DATE, LAST_UPDATED_BY, lAST_UPDATE_DATE, LAST_UPDATE_LOGIN)
486 VALUES (p_certification_id, proc_rec.PROCESS_ID, proc_rec.ORGANIZATION_ID,G_USER_ID,SYSDATE,G_USER_ID,SYSDATE,G_LOGIN_ID);
487
488 end if;
489
490 Update_Next_Level_Proc_Info(proc_rec.PROCESS_ID, proc_rec.ORGANIZATION_ID, p_certification_id);
491
492 Update_Certification_Detail(proc_rec.PROCESS_ID, proc_rec.ORGANIZATION_ID, p_certification_id);
493
494 if (l_global_org_id is not null) and(proc_rec.ORGANIZATION_ID = l_global_org_id)
495 then UPDATE_GLOBAL_PROC_INFO(proc_rec.PROCESS_ID, p_certification_id, l_global_org_id);
496 end if;
497
498 UPDATE_LAST_EVALUATION_INFO(proc_rec.PROCESS_ID, proc_rec.ORGANIZATION_ID, p_certification_id);
499
500 UPDATE_UNMITIGATED_RISKS(proc_rec.PROCESS_ID, proc_rec.ORGANIZATION_ID, p_certification_id);
501
502 UPDATE_INEFFECTIVE_CONTROLS(proc_rec.PROCESS_ID, proc_rec.ORGANIZATION_ID, p_certification_id);
503
504
505 end loop;
506
507 EXCEPTION
508 WHEN NO_DATA_FOUND
509 THEN
510 fnd_file.put_line (fnd_file.LOG, SUBSTR ('No data found in Populate_Summary'
511 || SUBSTR (SQLERRM, 1, 100), 1, 200));
512
513 WHEN OTHERS
514 THEN
515 fnd_file.put_line (fnd_file.LOG, SUBSTR ('Unexpected Error in Populate_Summary'
516 || SUBSTR (SQLERRM, 1, 100), 1, 200));
517
518 END Populate_Summary;
519
520
521 PROCEDURE POPULATE_ALL_CERT_SUMMARY
522 (x_errbuf OUT NOCOPY VARCHAR2,
523 x_retcode OUT NOCOPY NUMBER,
524 p_certification_id IN NUMBER
525 )
526 IS
527
528 -- select all processes in scope for the certification
529
530 cursor c1 is
531 Select distinct CERTIFICATION_ID
532 from AMW_CERTIFICATION_VL
533 where object_type = 'FIN_STMT' and
534 CERTIFICATION_STATUS in ('ACTIVE','DRAFT');
535
536 c1_rec c1%rowtype;
537
538 BEGIN
539
540 for c1_rec in c1 loop
541
542 Populate_Summary(c1_rec.CERTIFICATION_ID);
543
544 end loop;
545
546
547 EXCEPTION
548 WHEN NO_DATA_FOUND
549 THEN
550 fnd_file.put_line (fnd_file.LOG, SUBSTR ('No data found in Populate_All_Cert_Summary'
551 || SUBSTR (SQLERRM, 1, 100), 1, 200));
552
553 WHEN OTHERS
554 THEN
555 fnd_file.put_line (fnd_file.LOG, SUBSTR ('Unexpected Error in Populate_All_Cert_Summary'
556 || SUBSTR (SQLERRM, 1, 100), 1, 200));
557
558 END Populate_All_Cert_Summary;
559
560 /************* the implementation before bussiness event takes in place in amw.d *********/
561 PROCEDURE Populate_Cert_General_Sum(
562 p_certification_id IN NUMBER,
563 p_start_date IN DATE
564 )
565 is
566
567 CURSOR new_risks_added IS
568 SELECT count(1)
569 FROM AMW_RISK_ASSOCIATIONS
570 WHERE creation_date >= p_start_date
571 AND object_type = 'PROCESS_ORG'
572 AND pk1 in (
573 select distinct p_org.process_organization_id
574 from AMW_ACCT_ASSOCIATIONS acct_assoc,
575 AMW_PROCESS_ORGANIZATION process_org,
576 AMW_PROCESS_ORGANIZATION p_org,
577 (select process_id, organization_id, parent_child_id child_process_id, up_down_ind
578 from Amw_Org_Hierarchy_Denorm
579 union
580 select process_id, organization_id, process_id child_process_id, 'D' up_down_ind
581 from amw_process_organization) hier
582 where acct_assoc.natural_account_id in
583 -- (select natural_account_id
584 -- from amw_fin_key_accounts_b
585 -- start with (natural_account_id, account_group_id) in
586 -- (select natural_account_id, account_group_id
587 -- from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
588 -- where cert.certification_id = p_certification_id and
589 -- cert.object_type = 'FIN_STMT' and
590 -- cert.statement_group_id = key_acc.statement_group_id and
591 -- cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID)
592 -- connect by parent_natural_account_id = PRIOR natural_account_id and
593 -- account_group_id = PRIOR account_group_id)
594 -- Note by Sanket: The above connect by was replaced by the below query
595 -- which uses the newly created flat table. We have to use a union because
596 -- the first part of the query only returns the children (if any) of the (natural
597 -- account id = x, account group id = y) pair returned by the subquery, while the
598 -- second part of the query returns the actual pair (x, y). Such unions
599 -- are used in all the flattened queries in this file.
600
601 ( select distinct acc.child_natural_account_id
602 from amw_fin_key_acct_flat acc
603 where ( acc.parent_natural_account_id, acc.account_group_id ) in
604 ( select natural_account_id, account_group_id
605 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
606 where cert.certification_id = p_certification_id
607 and cert.object_type = 'FIN_STMT'
608 and cert.statement_group_id = key_acc.statement_group_id
609 and cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID
610 )
611 union
612 select distinct acc.natural_account_id
613 from amw_fin_key_accounts_b acc
614 where ( acc.natural_account_id, acc.account_group_id ) in
615 ( select natural_account_id, account_group_id
616 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
617 where cert.certification_id = p_certification_id
618 and cert.object_type = 'FIN_STMT'
619 and cert.statement_group_id = key_acc.statement_group_id
620 and cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID
621 )
622 )
623
624 and acct_assoc.object_type = 'PROCESS_ORG' and
625 process_org.process_organization_id = acct_assoc.pk1 and
626 hier.process_id = process_org.process_id and
627 hier.organization_id = process_org.organization_id and
628 hier.up_down_ind = 'D' and
629 p_org.process_id = hier.child_process_id and
630 p_org.organization_id = hier.organization_id
631 );
632
633
634 CURSOR new_controls_added IS
635 SELECT count(1)
636 FROM (
637 SELECT distinct aca.control_id, p_org.organization_id
638 FROM AMW_CONTROL_ASSOCIATIONS aca,
639 AMW_RISK_ASSOCIATIONS ara,
640 AMW_PROCESS_ORGANIZATION apo,
641 AMW_ACCT_ASSOCIATIONS acct_assoc,
642 AMW_PROCESS_ORGANIZATION p_org,
643 (select process_id, organization_id, parent_child_id child_process_id, up_down_ind
644 from Amw_Org_Hierarchy_Denorm
645 union
646 select process_id, organization_id, process_id child_process_id, 'D' up_down_ind
647 from amw_process_organization) hier
648 WHERE acct_assoc.natural_account_id in
649 -- (select natural_account_id
650 -- from amw_fin_key_accounts_b
651 -- start with (natural_account_id, account_group_id) in
652 -- (select natural_account_id, account_group_id
653 -- from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
654 -- where cert.certification_id = p_certification_id and
655 -- cert.object_type = 'FIN_STMT' and
656 -- cert.statement_group_id = key_acc.statement_group_id and
657 -- cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID)
658 -- connect by parent_natural_account_id = PRIOR natural_account_id and
659 -- account_group_id = PRIOR account_group_id)
660 -- Modifed for flatting key_acct table
661 ( select distinct acc.child_natural_account_id
662 from amw_fin_key_acct_flat acc
663 where ( acc.parent_natural_account_id, acc.account_group_id ) in
664 ( select natural_account_id, account_group_id
665 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
666 where cert.certification_id = p_certification_id
667 and cert.object_type = 'FIN_STMT'
668 and cert.statement_group_id = key_acc.statement_group_id
669 and cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID
670 )
671 union
672 select distinct acc.natural_account_id
673 from amw_fin_key_accounts_b acc
674 where ( acc.natural_account_id, acc.account_group_id ) in
675 ( select natural_account_id, account_group_id
676 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
677 where cert.certification_id = p_certification_id
678 and cert.object_type = 'FIN_STMT'
679 and cert.statement_group_id = key_acc.statement_group_id
680 and cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID
681 )
682 )
683
684
685 AND acct_assoc.object_type = 'PROCESS_ORG'
686 AND apo.process_organization_id = acct_assoc.pk1
687 AND hier.process_id = apo.process_id
688 AND hier.organization_id = apo.organization_id
689 AND hier.up_down_ind = 'D'
690 AND p_org.process_id = hier.child_process_id
691 AND p_org.organization_id = hier.organization_id
692 AND ara.object_type = 'PROCESS_ORG'
693 AND ara.pk1 = p_org.process_organization_id
694 AND aca.creation_date >= p_start_date
695 AND aca.object_type = 'RISK_ORG'
696 AND aca.pk1 = ara.risk_association_id
697 AND not exists (SELECT 'Y'
698 FROM AMW_CONTROL_ASSOCIATIONS aca2,
699 AMW_RISK_ASSOCIATIONS ara2
700 WHERE aca2.creation_date < p_start_date
701 AND aca2.object_type = 'RISK_ORG'
702 AND aca2.pk1 = ara2.risk_association_id
703 AND ara2.object_type = 'PROCESS_ORG'
704 AND ara2.pk1 = p_org.process_organization_id
705 AND aca2.control_id = aca.control_id
706 ));
707
708
709 CURSOR global_proc_not_certified IS
710 SELECT count(1)
711 FROM (
712 SELECT distinct hier.organization_id, hier.child_process_id
713 FROM AMW_PROCESS_ORGANIZATION apo,
714 AMW_ACCT_ASSOCIATIONS acct_assoc,
715 (select process_id, organization_id, parent_child_id child_process_id, up_down_ind
716 from Amw_Org_Hierarchy_Denorm
717 union
718 select process_id, organization_id, process_id child_process_id, 'D' up_down_ind
719 from amw_process_organization) hier
720 WHERE acct_assoc.natural_account_id in
721 -- (select natural_account_id
722 -- from amw_fin_key_accounts_b
723 -- start with (natural_account_id, account_group_id) in
724 -- (select natural_account_id, account_group_id
725 -- from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
726 -- where cert.certification_id = p_certification_id and
727 -- cert.object_type = 'FIN_STMT' and
728 -- cert.statement_group_id = key_acc.statement_group_id and
729 -- cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID)
730 -- connect by parent_natural_account_id = PRIOR natural_account_id and
731 -- account_group_id = PRIOR account_group_id)
732
733 ( select distinct acc.child_natural_account_id
734 from amw_fin_key_acct_flat acc
735 where ( acc.parent_natural_account_id, acc.account_group_id ) in
736 ( select natural_account_id, account_group_id
737 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
738 where cert.certification_id = p_certification_id
739 and cert.object_type = 'FIN_STMT'
740 and cert.statement_group_id = key_acc.statement_group_id
741 and cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID
742 )
743 union
744 select distinct acc.natural_account_id
745 from amw_fin_key_accounts_b acc
746 where ( acc.natural_account_id, acc.account_group_id ) in
747 ( select natural_account_id, account_group_id
748 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
749 where cert.certification_id = p_certification_id
750 and cert.object_type = 'FIN_STMT'
751 and cert.statement_group_id = key_acc.statement_group_id
752 and cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID
753 )
754 )
755
756 AND acct_assoc.object_type = 'PROCESS_ORG'
757 AND apo.process_organization_id = acct_assoc.pk1
758 AND apo.organization_id = fnd_profile.value('AMW_GLOBAL_ORG_ID')
759 AND apo.process_id = hier.process_id
760 AND apo.organization_id = hier.organization_id
761 AND hier.up_down_ind = 'D'
762 AND not exists (SELECT 'Y'
763 FROM AMW_OPINIONS_V aov
764 WHERE aov.object_name = 'AMW_ORG_PROCESS'
765 AND aov.opinion_type_code = 'CERTIFICATION'
766 AND aov.pk3_value = hier.organization_id
767 AND aov.pk2_value in (select proc_cert_id from AMW_FIN_PROC_CERT_RELAN where fin_stmt_cert_id = p_certification_id)
768 AND aov.pk1_value = hier.child_process_id)
769 );
770
771
772 CURSOR global_proc_with_issue IS
773 SELECT count(1)
774 FROM (
775 SELECT distinct hier.organization_id, hier.child_process_id
776 FROM AMW_PROCESS_ORGANIZATION apo,
777 AMW_ACCT_ASSOCIATIONS acct_assoc,
778 AMW_OPINIONS_V aov,
779 (select process_id, organization_id, parent_child_id child_process_id, up_down_ind
780 from Amw_Org_Hierarchy_Denorm
781 union
782 select process_id, organization_id, process_id child_process_id, 'D' up_down_ind
783 from amw_process_organization) hier
784 WHERE acct_assoc.natural_account_id in
785 -- (select natural_account_id
786 -- from amw_fin_key_accounts_b
787 -- start with (natural_account_id, account_group_id) in
788 -- (select natural_account_id, account_group_id
789 -- from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
790 -- where cert.certification_id = p_certification_id and
791 -- cert.object_type = 'FIN_STMT' and
792 -- cert.statement_group_id = key_acc.statement_group_id and
793 -- cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID)
794 -- connect by parent_natural_account_id = PRIOR natural_account_id and
795 -- account_group_id = PRIOR account_group_id)
796
797 ( select distinct acc.child_natural_account_id
798 from amw_fin_key_acct_flat acc
799 where ( acc.parent_natural_account_id, acc.account_group_id ) in
800 ( select natural_account_id, account_group_id
801 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
802 where cert.certification_id = p_certification_id
803 and cert.object_type = 'FIN_STMT'
804 and cert.statement_group_id = key_acc.statement_group_id
805 and cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID
806 )
807 union
808 select distinct acc.natural_account_id
809 from amw_fin_key_accounts_b acc
810 where ( acc.natural_account_id, acc.account_group_id ) in
811 ( select natural_account_id, account_group_id
812 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
813 where cert.certification_id = p_certification_id
814 and cert.object_type = 'FIN_STMT'
815 and cert.statement_group_id = key_acc.statement_group_id
816 and cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID
817 )
818 )
819
820 AND acct_assoc.object_type = 'PROCESS_ORG'
821 AND apo.process_organization_id = acct_assoc.pk1
822 AND apo.organization_id = fnd_profile.value('AMW_GLOBAL_ORG_ID')
823 AND hier.process_id = apo.process_id
824 AND hier.organization_id = apo.organization_id
825 AND hier.up_down_ind = 'D'
826 AND aov.object_name = 'AMW_ORG_PROCESS'
827 AND aov.opinion_type_code = 'CERTIFICATION'
828 AND aov.pk3_value = hier.organization_id
829 AND aov.pk2_value in (select proc_cert_id from AMW_FIN_PROC_CERT_RELAN where fin_stmt_cert_id = p_certification_id)
830 AND aov.pk1_value = hier.child_process_id
831 AND aov.audit_result_code <> 'EFFECTIVE'
832 );
833
834 CURSOR local_proc_not_certified IS
835 SELECT count(1)
836 FROM (SELECT distinct hier.organization_id, hier.child_process_id
837 FROM AMW_PROCESS_ORGANIZATION apo,
838 AMW_ACCT_ASSOCIATIONS acct_assoc,
839 (select process_id, organization_id, parent_child_id child_process_id, up_down_ind
840 from Amw_Org_Hierarchy_Denorm
841 union
842 select process_id, organization_id, process_id child_process_id, 'D' up_down_ind
843 from amw_process_organization) hier
844 WHERE acct_assoc.natural_account_id in
845 -- (select natural_account_id
846 -- from amw_fin_key_accounts_b
847 -- start with (natural_account_id, account_group_id) in
848 -- (select natural_account_id, account_group_id
849 -- from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
850 -- where cert.certification_id = p_certification_id and
851 -- cert.object_type = 'FIN_STMT' and
852 -- cert.statement_group_id = key_acc.statement_group_id and
853 -- cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID)
854 -- connect by parent_natural_account_id = PRIOR natural_account_id and
855 -- account_group_id = PRIOR account_group_id)
856
857 ( select distinct acc.child_natural_account_id
858 from amw_fin_key_acct_flat acc
859 where ( acc.parent_natural_account_id, acc.account_group_id ) in
860 ( select natural_account_id, account_group_id
861 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
862 where cert.certification_id = p_certification_id
863 and cert.object_type = 'FIN_STMT'
864 and cert.statement_group_id = key_acc.statement_group_id
865 and cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID
866 )
867 union
868 select distinct acc.natural_account_id
869 from amw_fin_key_accounts_b acc
870 where ( acc.natural_account_id, acc.account_group_id ) in
871 ( select natural_account_id, account_group_id
872 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
873 where cert.certification_id = p_certification_id
874 and cert.object_type = 'FIN_STMT'
875 and cert.statement_group_id = key_acc.statement_group_id
876 and cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID
877 )
878 )
879
880 AND acct_assoc.object_type = 'PROCESS_ORG'
881 AND apo.process_organization_id = acct_assoc.pk1
882 AND apo.organization_id <> NVL(fnd_profile.value('AMW_GLOBAL_ORG_ID'),-999)
883 AND hier.process_id = apo.process_id
884 AND hier.organization_id = apo.organization_id
885 AND hier.up_down_ind = 'D'
886 AND not exists (SELECT 'Y'
887 FROM AMW_OPINIONS_V aov
888 WHERE aov.object_name = 'AMW_ORG_PROCESS'
889 AND aov.opinion_type_code = 'CERTIFICATION'
890 AND aov.pk3_value = hier.organization_id
891 AND aov.pk2_value in (select proc_cert_id from AMW_FIN_PROC_CERT_RELAN where fin_stmt_cert_id = p_certification_id)
892 AND aov.pk1_value = hier.child_process_id));
893
894 CURSOR local_proc_with_issue IS
895 SELECT count(1)
896 FROM (SELECT distinct hier.organization_id, hier.child_process_id
897 FROM AMW_PROCESS_ORGANIZATION apo,
898 AMW_ACCT_ASSOCIATIONS acct_assoc,
899 AMW_OPINIONS_V aov,
900 (select process_id, organization_id, parent_child_id child_process_id, up_down_ind
901 from Amw_Org_Hierarchy_Denorm
902 union
903 select process_id, organization_id, process_id child_process_id, 'D' up_down_ind
904 from amw_process_organization) hier
905 WHERE acct_assoc.natural_account_id in
906 -- (select natural_account_id
907 -- from amw_fin_key_accounts_b
908 -- start with (natural_account_id, account_group_id) in
909 -- (select natural_account_id, account_group_id
910 -- from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
911 -- where cert.certification_id = p_certification_id and
912 -- cert.object_type = 'FIN_STMT' and
913 -- cert.statement_group_id = key_acc.statement_group_id and
914 -- cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID)
915 -- connect by parent_natural_account_id = PRIOR natural_account_id and
916 -- account_group_id = PRIOR account_group_id)
917
918 ( select distinct acc.child_natural_account_id
919 from amw_fin_key_acct_flat acc
920 where ( acc.parent_natural_account_id, acc.account_group_id ) in
921 ( select natural_account_id, account_group_id
922 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
923 where cert.certification_id = p_certification_id
924 and cert.object_type = 'FIN_STMT'
925 and cert.statement_group_id = key_acc.statement_group_id
926 and cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID
927 )
928 union
929 select distinct acc.natural_account_id
930 from amw_fin_key_accounts_b acc
931 where ( acc.natural_account_id, acc.account_group_id ) in
932 ( select natural_account_id, account_group_id
933 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
934 where cert.certification_id = p_certification_id
935 and cert.object_type = 'FIN_STMT'
936 and cert.statement_group_id = key_acc.statement_group_id
937 and cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID
938 )
939 )
940
941 AND acct_assoc.object_type = 'PROCESS_ORG'
942 AND apo.process_organization_id = acct_assoc.pk1
943 AND apo.organization_id <> NVL(fnd_profile.value('AMW_GLOBAL_ORG_ID'), -999)
944 AND hier.process_id = apo.process_id
945 AND hier.organization_id = apo.organization_id
946 AND hier.up_down_ind = 'D'
947 AND aov.object_name = 'AMW_ORG_PROCESS'
948 AND aov.opinion_type_code = 'CERTIFICATION'
949 AND aov.pk3_value = hier.organization_id
950 AND aov.pk2_value in (select proc_cert_id from AMW_FIN_PROC_CERT_RELAN where fin_stmt_cert_id = p_certification_id)
951 AND aov.pk1_value = hier.child_process_id
952 AND aov.audit_result_code <> 'EFFECTIVE');
953
954 CURSOR global_proc_with_ineff_ctrl IS
955 SELECT count(distinct hier.child_process_id)
956 FROM AMW_PROCESS_ORGANIZATION apo,
957 AMW_ACCT_ASSOCIATIONS acct_assoc,
958 AMW_OPINIONS_V aov,
959 (select process_id, organization_id, parent_child_id child_process_id, up_down_ind
960 from Amw_Org_Hierarchy_Denorm
961 union
962 select process_id, organization_id, process_id child_process_id, 'D' up_down_ind
963 from amw_process_organization) hier
964 WHERE acct_assoc.natural_account_id in
965 -- (select natural_account_id
966 -- from amw_fin_key_accounts_b
967 -- start with (natural_account_id, account_group_id) in
968 -- (select natural_account_id, account_group_id
969 -- from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
970 -- where cert.certification_id = p_certification_id and
971 -- cert.object_type = 'FIN_STMT' and
972 -- cert.statement_group_id = key_acc.statement_group_id and
973 -- cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID)
974 -- connect by parent_natural_account_id = PRIOR natural_account_id and
975 -- account_group_id = PRIOR account_group_id)
976
977 ( select distinct acc.child_natural_account_id
978 from amw_fin_key_acct_flat acc
979 where ( acc.parent_natural_account_id, acc.account_group_id ) in
980 ( select natural_account_id, account_group_id
981 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
982 where cert.certification_id = p_certification_id
983 and cert.object_type = 'FIN_STMT'
984 and cert.statement_group_id = key_acc.statement_group_id
985 and cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID
986 )
987 union
988 select distinct acc.natural_account_id
989 from amw_fin_key_accounts_b acc
990 where ( acc.natural_account_id, acc.account_group_id ) in
991 ( select natural_account_id, account_group_id
992 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
993 where cert.certification_id = p_certification_id
994 and cert.object_type = 'FIN_STMT'
995 and cert.statement_group_id = key_acc.statement_group_id
996 and cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID
997 )
998 )
999
1000 AND acct_assoc.object_type = 'PROCESS_ORG'
1001 AND apo.process_organization_id = acct_assoc.pk1
1002 AND apo.organization_id = fnd_profile.value('AMW_GLOBAL_ORG_ID')
1003 AND hier.process_id = apo.process_id
1004 AND hier.organization_id = apo.organization_id
1005 AND hier.up_down_ind = 'D'
1006 AND aov.object_name = 'AMW_ORG_PROCESS'
1007 AND aov.opinion_type_code = 'EVALUATION'
1008 AND aov.pk3_value = hier.organization_id
1009 AND aov.pk1_value = hier.child_process_id
1010 AND aov.authored_date = (select max(aov2.authored_date)
1011 from AMW_OPINIONS_V aov2
1012 where aov2.object_opinion_type_id = aov.object_opinion_type_id
1013 and aov2.pk3_value = aov.pk3_value
1014 and aov2.pk1_value = aov.pk1_value)
1015 and aov.audit_result_code <> 'EFFECTIVE';
1016
1017 CURSOR local_proc_with_ineff_ctrl IS
1018 SELECT count(1)
1019 FROM (SELECT distinct hier.organization_id, hier.child_process_id
1020 FROM AMW_PROCESS_ORGANIZATION apo,
1021 AMW_ACCT_ASSOCIATIONS acct_assoc,
1022 AMW_OPINIONS_V aov,
1023 (select process_id, organization_id, parent_child_id child_process_id, up_down_ind
1024 from Amw_Org_Hierarchy_Denorm
1025 union
1026 select process_id, organization_id, process_id child_process_id, 'D' up_down_ind
1027 from amw_process_organization) hier
1028 WHERE acct_assoc.natural_account_id in
1029
1030 -- (select natural_account_id
1031 -- from amw_fin_key_accounts_b
1032 -- start with (natural_account_id, account_group_id) in
1033 -- (select natural_account_id, account_group_id
1034 -- from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
1035 -- where cert.certification_id = p_certification_id and
1036 -- cert.object_type = 'FIN_STMT' and
1037 -- cert.statement_group_id = key_acc.statement_group_id and
1038 -- cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID)
1039 -- connect by parent_natural_account_id = PRIOR natural_account_id and
1040 -- account_group_id = PRIOR account_group_id)
1041
1042 ( select distinct acc.child_natural_account_id
1043 from amw_fin_key_acct_flat acc
1044 where ( acc.parent_natural_account_id, acc.account_group_id ) in
1045 ( select natural_account_id, account_group_id
1046 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
1047 where cert.certification_id = p_certification_id
1048 and cert.object_type = 'FIN_STMT'
1049 and cert.statement_group_id = key_acc.statement_group_id
1050 and cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID
1051 )
1052 union
1053 select distinct acc.natural_account_id
1054 from amw_fin_key_accounts_b acc
1055 where ( acc.natural_account_id, acc.account_group_id ) in
1056 ( select natural_account_id, account_group_id
1057 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
1058 where cert.certification_id = p_certification_id
1059 and cert.object_type = 'FIN_STMT'
1060 and cert.statement_group_id = key_acc.statement_group_id
1061 and cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID
1062 )
1063 )
1064
1065 AND acct_assoc.object_type = 'PROCESS_ORG'
1066 AND apo.process_organization_id = acct_assoc.pk1
1067 AND apo.organization_id <> NVL(fnd_profile.value('AMW_GLOBAL_ORG_ID'), -999)
1068 AND hier.process_id = apo.process_id
1069 AND hier.organization_id = apo.organization_id
1070 AND hier.up_down_ind = 'D'
1071 AND aov.object_name = 'AMW_ORG_PROCESS'
1072 AND aov.opinion_type_code = 'EVALUATION'
1073 AND aov.pk3_value = hier.organization_id
1074 AND aov.pk1_value = hier.child_process_id
1075 AND aov.authored_date = (select max(aov2.authored_date)
1076 from AMW_OPINIONS_V aov2
1077 where aov2.object_opinion_type_id = aov.object_opinion_type_id
1078 and aov2.pk3_value = aov.pk3_value
1079 AND aov.audit_result_code <> 'EFFECTIVE'
1080 and aov2.pk1_value = aov.pk1_value));
1081
1082
1083 CURSOR unmitigated_risks IS
1084 SELECT count(1)
1085 FROM (SELECT distinct p_org.organization_id, p_org.process_id, ara.risk_id
1086 FROM AMW_PROCESS_ORGANIZATION apo,
1087 AMW_ACCT_ASSOCIATIONS acct_assoc,
1088 AMW_RISK_ASSOCIATIONS ara,
1089 AMW_OPINIONS_V aov,
1090 AMW_PROCESS_ORGANIZATION p_org,
1091 (select process_id, organization_id, parent_child_id child_process_id, up_down_ind
1092 from Amw_Org_Hierarchy_Denorm
1093 union
1094 select process_id, organization_id, process_id child_process_id, 'D' up_down_ind
1095 from amw_process_organization) hier
1096 WHERE acct_assoc.natural_account_id in
1097
1098 -- (select natural_account_id
1099 -- from amw_fin_key_accounts_b
1100 -- start with (natural_account_id, account_group_id) in
1101 -- (select natural_account_id, account_group_id
1102 -- from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
1103 -- where cert.certification_id = p_certification_id and
1104 -- cert.object_type = 'FIN_STMT' and
1105 -- cert.statement_group_id = key_acc.statement_group_id and
1106 -- cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID)
1107 -- connect by parent_natural_account_id = PRIOR natural_account_id and
1108 -- account_group_id = PRIOR account_group_id)
1109
1110 ( select distinct acc.child_natural_account_id
1111 from amw_fin_key_acct_flat acc
1112 where ( acc.parent_natural_account_id, acc.account_group_id ) in
1113 ( select natural_account_id, account_group_id
1114 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
1115 where cert.certification_id = p_certification_id
1116 and cert.object_type = 'FIN_STMT'
1117 and cert.statement_group_id = key_acc.statement_group_id
1118 and cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID
1119 )
1120 union
1121 select distinct acc.natural_account_id
1122 from amw_fin_key_accounts_b acc
1123 where ( acc.natural_account_id, acc.account_group_id ) in
1124 ( select natural_account_id, account_group_id
1125 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
1126 where cert.certification_id = p_certification_id
1127 and cert.object_type = 'FIN_STMT'
1128 and cert.statement_group_id = key_acc.statement_group_id
1129 and cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID
1130 )
1131 )
1132
1133 AND acct_assoc.object_type = 'PROCESS_ORG'
1134 AND apo.process_organization_id = acct_assoc.pk1
1135 AND hier.process_id = apo.process_id
1136 AND hier.organization_id = apo.organization_id
1137 AND hier.up_down_ind = 'D'
1138 AND p_org.process_id = hier.child_process_id
1139 AND p_org.organization_id = hier.organization_id
1140 AND ara.object_type = 'PROCESS_ORG'
1141 AND ara.pk1 = p_org.process_organization_id
1142 AND aov.object_name = 'AMW_ORG_PROCESS_RISK'
1143 AND aov.opinion_type_code = 'EVALUATION'
1144 AND aov.pk3_value = p_org.organization_id
1145 AND aov.pk4_value = p_org.process_id
1146 AND aov.pk1_value = ara.risk_id
1147 AND aov.authored_date =
1148 (select max(aov2.authored_date)
1149 from AMW_OPINIONS_V aov2
1150 where aov2.object_opinion_type_id = aov.object_opinion_type_id
1151 and aov2.pk4_value = aov.pk4_value
1152 and aov2.pk3_value = aov.pk3_value
1153 and aov2.pk1_value = aov.pk1_value)
1154 AND aov.audit_result_code <> 'EFFECTIVE');
1155
1156 CURSOR ineffective_controls IS
1157 SELECT count(1)
1158 FROM (SELECT distinct p_org.organization_id, aca.control_id
1159 FROM AMW_PROCESS_ORGANIZATION apo,
1160 AMW_ACCT_ASSOCIATIONS acct_assoc,
1161 AMW_RISK_ASSOCIATIONS ara, AMW_CONTROL_ASSOCIATIONS aca,
1162 AMW_OPINIONS_V aov,
1163 AMW_PROCESS_ORGANIZATION p_org,
1164 (select process_id, organization_id, parent_child_id child_process_id, up_down_ind
1165 from Amw_Org_Hierarchy_Denorm
1166 union
1167 select process_id, organization_id, process_id child_process_id, 'D' up_down_ind
1168 from amw_process_organization) hier
1169 WHERE acct_assoc.natural_account_id in
1170
1171 -- (select natural_account_id
1172 -- from amw_fin_key_accounts_b
1173 -- start with (natural_account_id, account_group_id) in
1174 -- (select natural_account_id, account_group_id
1175 -- from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
1176 -- where cert.certification_id = p_certification_id and
1177 -- cert.object_type = 'FIN_STMT' and
1178 -- cert.statement_group_id = key_acc.statement_group_id and
1179 -- cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID)
1180 -- connect by parent_natural_account_id = PRIOR natural_account_id and
1181 -- account_group_id = PRIOR account_group_id)
1182
1183 ( select distinct acc.child_natural_account_id
1184 from amw_fin_key_acct_flat acc
1185 where ( acc.parent_natural_account_id, acc.account_group_id ) in
1186 ( select natural_account_id, account_group_id
1187 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
1188 where cert.certification_id = p_certification_id
1189 and cert.object_type = 'FIN_STMT'
1190 and cert.statement_group_id = key_acc.statement_group_id
1191 and cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID
1192 )
1193 union
1194 select distinct acc.natural_account_id
1195 from amw_fin_key_accounts_b acc
1196 where ( acc.natural_account_id, acc.account_group_id ) in
1197 ( select natural_account_id, account_group_id
1198 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
1199 where cert.certification_id = p_certification_id
1200 and cert.object_type = 'FIN_STMT'
1201 and cert.statement_group_id = key_acc.statement_group_id
1202 and cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID
1203 )
1204 )
1205
1206 AND acct_assoc.object_type = 'PROCESS_ORG'
1207 AND apo.process_organization_id = acct_assoc.pk1
1208 AND hier.process_id = apo.process_id
1209 AND hier.organization_id = apo.organization_id
1210 AND hier.up_down_ind = 'D'
1211 AND p_org.process_id = hier.child_process_id
1212 AND p_org.organization_id = hier.organization_id
1213 AND ara.object_type = 'PROCESS_ORG'
1214 AND ara.pk1 = p_org.process_organization_id
1215 AND aca.object_type = 'RISK_ORG'
1216 AND aca.pk1 = ara.risk_association_id
1217 AND aov.object_name = 'AMW_ORG_CONTROL'
1218 AND aov.opinion_type_code = 'EVALUATION'
1219 AND aov.pk3_value = p_org.organization_id
1220 AND aov.pk1_value = aca.control_id
1221 AND aov.authored_date =
1222 (select max(aov2.authored_date)
1223 from AMW_OPINIONS_V aov2
1224 where aov2.object_opinion_type_id = aov.object_opinion_type_id
1225 and aov2.pk3_value = aov.pk3_value
1226 and aov2.pk1_value = aov.pk1_value)
1227 AND aov.audit_result_code <> 'EFFECTIVE');
1228
1229
1230 CURSOR orgs_pending_in_scope IS
1231 SELECT count(distinct p_org.organization_id)
1232 FROM AMW_PROCESS_ORGANIZATION apo,
1233 AMW_ACCT_ASSOCIATIONS acct_assoc,
1234 AMW_PROCESS_ORGANIZATION p_org,
1235 (select process_id, organization_id, parent_child_id child_process_id, up_down_ind
1236 from Amw_Org_Hierarchy_Denorm
1237 union
1238 select process_id, organization_id, process_id child_process_id, 'D' up_down_ind
1239 from amw_process_organization) hier
1240 WHERE acct_assoc.natural_account_id in
1241
1242 -- (select natural_account_id
1243 -- from amw_fin_key_accounts_b
1244 -- start with (natural_account_id, account_group_id) in
1245 -- (select natural_account_id, account_group_id
1246 -- from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
1247 -- where cert.certification_id = p_certification_id and
1248 -- cert.object_type = 'FIN_STMT' and
1249 -- cert.statement_group_id = key_acc.statement_group_id and
1250 -- cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID)
1251 -- connect by parent_natural_account_id = PRIOR natural_account_id and
1252 -- account_group_id = PRIOR account_group_id)
1253
1254 ( select distinct acc.child_natural_account_id
1255 from amw_fin_key_acct_flat acc
1256 where ( acc.parent_natural_account_id, acc.account_group_id ) in
1257 ( select natural_account_id, account_group_id
1258 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
1259 where cert.certification_id = p_certification_id
1260 and cert.object_type = 'FIN_STMT'
1261 and cert.statement_group_id = key_acc.statement_group_id
1262 and cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID
1263 )
1264 union
1265 select distinct acc.natural_account_id
1266 from amw_fin_key_accounts_b acc
1267 where ( acc.natural_account_id, acc.account_group_id ) in
1268 ( select natural_account_id, account_group_id
1269 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
1270 where cert.certification_id = p_certification_id
1271 and cert.object_type = 'FIN_STMT'
1272 and cert.statement_group_id = key_acc.statement_group_id
1273 and cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID
1274 )
1275 )
1276
1277 AND acct_assoc.object_type = 'PROCESS_ORG'
1278 AND apo.process_organization_id = acct_assoc.pk1
1279 AND hier.process_id = apo.process_id
1280 AND hier.organization_id = apo.organization_id
1281 AND hier.up_down_ind = 'D'
1282 AND p_org.process_id = hier.child_process_id
1283 AND p_org.organization_id = hier.organization_id
1284 AND not exists (SELECT 'Y'
1285 FROM AMW_OPINIONS_V aov
1286 WHERE aov.object_name = 'AMW_ORG_PROCESS'
1287 AND aov.opinion_type_code = 'CERTIFICATION'
1288 AND aov.pk3_value = p_org.organization_id
1289 AND aov.pk2_value = p_certification_id
1290 AND aov.pk1_value = p_org.process_id);
1291
1292 CURSOR orgs_in_scope IS
1293 SELECT count(distinct apo.organization_id)
1294 FROM AMW_PROCESS_ORGANIZATION apo,
1295 AMW_ACCT_ASSOCIATIONS acct_assoc
1296 WHERE acct_assoc.natural_account_id in
1297
1298 -- (select natural_account_id
1299 -- from amw_fin_key_accounts_b
1300 -- start with (natural_account_id, account_group_id) in
1301 -- (select natural_account_id, account_group_id
1302 -- from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
1303 -- where cert.certification_id = p_certification_id and
1304 -- cert.object_type = 'FIN_STMT' and
1305 -- cert.statement_group_id = key_acc.statement_group_id and
1306 -- cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID)
1307 -- connect by parent_natural_account_id = PRIOR natural_account_id and
1308 -- account_group_id = PRIOR account_group_id)
1309
1310 ( select distinct acc.child_natural_account_id
1311 from amw_fin_key_acct_flat acc
1312 where ( acc.parent_natural_account_id, acc.account_group_id ) in
1313 ( select natural_account_id, account_group_id
1314 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
1315 where cert.certification_id = p_certification_id
1316 and cert.object_type = 'FIN_STMT'
1317 and cert.statement_group_id = key_acc.statement_group_id
1318 and cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID
1319 )
1320 union
1321 select distinct acc.natural_account_id
1322 from amw_fin_key_accounts_b acc
1323 where ( acc.natural_account_id, acc.account_group_id ) in
1324 ( select natural_account_id, account_group_id
1325 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC key_acc
1326 where cert.certification_id = p_certification_id
1327 and cert.object_type = 'FIN_STMT'
1328 and cert.statement_group_id = key_acc.statement_group_id
1329 and cert.financial_statement_id = key_acc.FINANCIAL_STATEMENT_ID
1330 )
1331 )
1332
1333 AND acct_assoc.object_type = 'PROCESS_ORG'
1334 AND apo.process_organization_id = acct_assoc.pk1;
1335
1336 l_new_risks_added NUMBER;
1337 l_new_controls_added NUMBER;
1338 l_global_proc_not_certified NUMBER;
1339 l_global_proc_with_issue NUMBER;
1340 l_local_proc_not_certified NUMBER;
1341 l_local_proc_with_issue NUMBER;
1342 l_global_proc_with_ineff_ctrl NUMBER;
1343 l_local_proc_with_ineff_ctrl NUMBER;
1344 l_unmitigated_risks NUMBER;
1345 l_ineffective_controls NUMBER;
1346 l_orgs_in_scope NUMBER;
1347 l_orgs_pending_in_scope NUMBER;
1348
1349 BEGIN
1350
1351 fnd_file.put_line (fnd_file.LOG, 'p_certification_id='||to_char(p_certification_id));
1352 fnd_file.put_line(fnd_file.LOG, 'before new_risks_added :'||to_char(sysdate, 'hh:mi:ss dd-mon-rrrr'));
1353
1354 OPEN new_risks_added;
1355 FETCH new_risks_added INTO l_new_risks_added;
1356 CLOSE new_risks_added;
1357
1358 fnd_file.put_line(fnd_file.LOG, 'before new_controls_added :'||to_char(sysdate, 'hh:mi:ss dd-mon-rrrr'));
1359 OPEN new_controls_added;
1360 FETCH new_controls_added INTO l_new_controls_added;
1361 CLOSE new_controls_added;
1362
1363 fnd_file.put_line(fnd_file.LOG, 'before global_proc_not_certified :'||to_char(sysdate, 'hh:mi:ss dd-mon-rrrr'));
1364 OPEN global_proc_not_certified;
1365 FETCH global_proc_not_certified INTO l_global_proc_not_certified;
1366 CLOSE global_proc_not_certified;
1367
1368 fnd_file.put_line(fnd_file.LOG, 'before global_proc_with_issue :'||to_char(sysdate, 'hh:mi:ss dd-mon-rrrr'));
1369 OPEN global_proc_with_issue;
1370 FETCH global_proc_with_issue INTO l_global_proc_with_issue;
1371 CLOSE global_proc_with_issue;
1372
1373 fnd_file.put_line(fnd_file.LOG, 'before local_proc_not_certified :'||to_char(sysdate, 'hh:mi:ss dd-mon-rrrr'));
1374 OPEN local_proc_not_certified;
1375 FETCH local_proc_not_certified INTO l_local_proc_not_certified;
1376 CLOSE local_proc_not_certified;
1377
1378 fnd_file.put_line(fnd_file.LOG, 'before local_proc_with_issue :'||to_char(sysdate, 'hh:mi:ss dd-mon-rrrr'));
1379 OPEN local_proc_with_issue;
1380 FETCH local_proc_with_issue INTO l_local_proc_with_issue;
1381 CLOSE local_proc_with_issue;
1382
1383 fnd_file.put_line(fnd_file.LOG, 'before global_proc_with_ineff_ctrl :'||to_char(sysdate, 'hh:mi:ss dd-mon-rrrr'));
1384 OPEN global_proc_with_ineff_ctrl;
1385 FETCH global_proc_with_ineff_ctrl INTO l_global_proc_with_ineff_ctrl;
1386 CLOSE global_proc_with_ineff_ctrl;
1387
1388 fnd_file.put_line(fnd_file.LOG, 'before local_proc_with_ineff_ctrl :'||to_char(sysdate, 'hh:mi:ss dd-mon-rrrr'));
1389 OPEN local_proc_with_ineff_ctrl;
1390 FETCH local_proc_with_ineff_ctrl INTO l_local_proc_with_ineff_ctrl;
1391 CLOSE local_proc_with_ineff_ctrl;
1392
1393 fnd_file.put_line(fnd_file.LOG, 'before unmitigated_risks :'||to_char(sysdate, 'hh:mi:ss dd-mon-rrrr'));
1394 OPEN unmitigated_risks;
1395 FETCH unmitigated_risks INTO l_unmitigated_risks;
1396 CLOSE unmitigated_risks;
1397
1398 fnd_file.put_line(fnd_file.LOG, 'before ineffective_controls :'||to_char(sysdate, 'hh:mi:ss dd-mon-rrrr'));
1399 OPEN ineffective_controls;
1400 FETCH ineffective_controls INTO l_ineffective_controls;
1401 CLOSE ineffective_controls;
1402
1403 fnd_file.put_line(fnd_file.LOG, 'before orgs_pending_in_scope :'||to_char(sysdate, 'hh:mi:ss dd-mon-rrrr'));
1404 OPEN orgs_pending_in_scope;
1405 FETCH orgs_pending_in_scope INTO l_orgs_pending_in_scope;
1406 CLOSE orgs_pending_in_scope;
1407
1408 fnd_file.put_line(fnd_file.LOG, 'before orgs_in_scope :'||to_char(sysdate, 'hh:mi:ss dd-mon-rrrr'));
1409 OPEN orgs_in_scope;
1410 FETCH orgs_in_scope INTO l_orgs_in_scope;
1411 CLOSE orgs_in_scope;
1412
1413 UPDATE AMW_CERT_DASHBOARD_SUM
1414 SET NEW_RISKS_ADDED = l_new_risks_added,
1415 NEW_CONTROLS_ADDED = l_new_controls_added,
1416 PROCESSES_NOT_CERT = l_global_proc_not_certified,
1417 PROCESSES_CERT_ISSUES = l_global_proc_with_issue,
1418 ORG_PROCESS_NOT_CERT = l_local_proc_not_certified,
1419 ORG_PROCESS_CERT_ISSUES = l_local_proc_with_issue,
1420 PROC_INEFF_CONTROL = l_global_proc_with_ineff_ctrl,
1421 ORG_PROC_INEFF_CONTROL = l_local_proc_with_ineff_ctrl,
1422 UNMITIGATED_RISKS = l_unmitigated_risks,
1423 INEFFECTIVE_CONTROLS = l_ineffective_controls,
1424 ORGS_IN_SCOPE = l_orgs_in_scope,
1425 ORGS_PENDING_IN_SCOPE = l_orgs_pending_in_scope,
1426 PERIOD_START_DATE = p_start_date,
1427 LAST_UPDATE_DATE = sysdate,
1428 LAST_UPDATED_BY = FND_GLOBAL.USER_ID,
1429 LAST_UPDATE_LOGIN = FND_GLOBAL.USER_ID
1430 WHERE certification_id = p_certification_id;
1431
1432 IF (SQL%NOTFOUND) THEN
1433 INSERT INTO AMW_CERT_DASHBOARD_SUM (
1434 CERTIFICATION_ID,
1435 NEW_RISKS_ADDED,
1436 NEW_CONTROLS_ADDED,
1437 PROCESSES_NOT_CERT,
1438 PROCESSES_CERT_ISSUES,
1439 ORG_PROCESS_NOT_CERT,
1440 ORG_PROCESS_CERT_ISSUES,
1441 PROC_INEFF_CONTROL,
1442 ORG_PROC_INEFF_CONTROL,
1443 UNMITIGATED_RISKS,
1444 INEFFECTIVE_CONTROLS,
1445 ORGS_IN_SCOPE,
1446 ORGS_PENDING_IN_SCOPE,
1447 PERIOD_START_DATE,
1448 CREATED_BY,
1449 CREATION_DATE,
1450 LAST_UPDATE_DATE,
1451 LAST_UPDATED_BY,
1452 LAST_UPDATE_LOGIN)
1453 SELECT p_certification_id,
1454 l_new_risks_added,
1455 l_new_controls_added,
1456 l_global_proc_not_certified,
1457 l_global_proc_with_issue,
1458 l_local_proc_not_certified,
1459 l_local_proc_with_issue,
1460 l_global_proc_with_ineff_ctrl,
1461 l_local_proc_with_ineff_ctrl,
1462 l_unmitigated_risks,
1463 l_ineffective_controls,
1464 l_orgs_in_scope,
1465 l_orgs_pending_in_scope,
1466 p_start_date,
1467 FND_GLOBAL.USER_ID,
1468 SYSDATE,
1469 SYSDATE,
1470 FND_GLOBAL.USER_ID,
1471 FND_GLOBAL.USER_ID
1472 FROM DUAL;
1473 END IF;
1474
1475 commit;
1476 EXCEPTION WHEN OTHERS THEN
1477 fnd_file.put_line (fnd_file.LOG, SUBSTR ('Unexpected Error in Populate_All_Cert_DetSummary'
1478 || SUBSTR (SQLERRM, 1, 100), 1, 200));
1479 END Populate_Cert_General_Sum;
1480
1481
1482 /***************************OBSOLATED. USED IN CONCURRENT PROGRAM BEFORE BES AMW.D ********
1483 PROCEDURE Populate_All_Cert_General_Sum(
1484 errbuf OUT NOCOPY VARCHAR2,
1485 retcode OUT NOCOPY VARCHAR2,
1486 p_certification_id IN NUMBER
1487 )
1488 IS
1489 -- select all processes in scope for the certification
1490 CURSOR c_cert IS
1491 SELECT cert.CERTIFICATION_ID, period.start_date
1492 FROM AMW_CERTIFICATION_B cert, AMW_GL_PERIODS_V period
1493 WHERE cert.object_type = 'FIN_STMT' and cert.certification_period_name = period.period_name
1494 AND cert.certification_period_set_name = period.period_set_name
1495 and cert.CERTIFICATION_STATUS in ('ACTIVE', 'DRAFT');
1496
1497 CURSOR c_start_date IS
1498 SELECT period.start_date
1499 FROM AMW_CERTIFICATION_B cert, AMW_GL_PERIODS_V period
1500 WHERE cert.object_type = 'FIN_STMT' and cert.certification_period_name = period.period_name
1501 AND cert.certification_period_set_name = period.period_set_name
1502 and cert.CERTIFICATION_STATUS in ('ACTIVE', 'DRAFT')
1503 AND cert.certification_id = p_certification_id;
1504
1505 l_start_date DATE;
1506 BEGIN
1507 fnd_file.put_line (fnd_file.LOG,
1508 'Certification_Id:'||p_certification_id);
1509 IF p_certification_id IS NOT NULL THEN
1510 OPEN c_start_date;
1511 FETCH c_start_date INTO l_start_date;
1512 IF c_start_date%FOUND THEN
1513 Populate_Cert_General_Sum(p_certification_id, l_start_date);
1514 END IF;
1515 CLOSE c_start_date;
1516 ELSE
1517 FOR cert_rec IN c_cert LOOP
1518 Populate_Cert_General_Sum(cert_rec.certification_id, cert_rec.start_date);
1519 END LOOP;
1520 END IF;
1521
1522 EXCEPTION
1523 WHEN NO_DATA_FOUND THEN
1524 fnd_file.put_line (fnd_file.LOG, SUBSTR ('No data found in Populate_All_Cert_General_Sum'
1525 || SUBSTR (SQLERRM, 1, 100), 1, 200));
1526 WHEN OTHERS THEN
1527 fnd_file.put_line (fnd_file.LOG, SUBSTR ('Unexpected Error in Populate_All_Cert_General_Sum'
1528 || SUBSTR (SQLERRM, 1, 100), 1, 200));
1529 errbuf := SQLERRM;
1530 retcode := FND_API.G_RET_STS_UNEXP_ERROR;
1531 END Populate_All_Cert_General_Sum;
1532
1533 *******************************************************/
1534
1535 /**** the implemention before business event takes place since amw.d ***********/
1536 PROCEDURE Populate_Fin_Process_Eval_Sum(
1537 p_certification_id IN NUMBER,
1538 p_start_date IN DATE,
1539 p_end_date IN DATE,
1540 p_process_organization_id IN NUMBER,
1541 p_process_id IN NUMBER,
1542 p_organization_id IN NUMBER,
1543 p_account_process_flag IN VARCHAR2
1544 )
1545 IS
1546
1547 CURSOR sub_processes_certified IS
1548 SELECT count(distinct aov.pk1_value)
1549 FROM AMW_OPINIONS_V aov
1550 WHERE aov.object_name = 'AMW_ORG_PROCESS'
1551 AND aov.opinion_type_code = 'CERTIFICATION'
1552 AND aov.pk3_value = p_organization_id
1553 -- AND aov.authored_date >= p_start_date
1554 -- AND aov.authored_date <= p_end_date
1555 AND aov.pk2_value in (select proc_cert_Id from AMW_FIN_PROC_CERT_RELAN
1556 where fin_stmt_cert_id = p_certification_id)
1557 AND aov.pk1_value in (select distinct(orgrel.child_process_id)
1558 from AMW_PROCESS_ORG_RELATIONS orgrel
1559 START WITH orgrel.parent_process_id = p_process_id
1560 and orgrel.organization_id = p_organization_id
1561 CONNECT BY PRIOR orgrel.child_process_id = orgrel.parent_process_id
1562 and PRIOR orgrel.organization_id = orgrel.organization_id);
1563
1564 CURSOR total_sub_processes IS
1565 SELECT count(distinct child_process_id)
1566 FROM AMW_PROCESS_ORG_RELATIONS
1567 START WITH parent_process_id = p_process_id
1568 AND organization_id = p_organization_id
1569 CONNECT BY PRIOR child_process_id = parent_process_id
1570 AND PRIOR organization_id = organization_id;
1571
1572 /*
1573 CURSOR org_processes_certified IS
1574 SELECT count(distinct aov.pk3_value)
1575 FROM AMW_OPINIONS_V aov
1576 WHERE aov.object_name = 'AMW_ORG_PROCESS'
1577 AND aov.opinion_type_code = 'CERTIFICATION'
1578 AND aov.pk3_value <> NVL(fnd_profile.value('AMW_GLOBAL_ORG_ID'),-999)
1579 AND aov.pk1_value = p_process_id
1580 AND aov.pk2_value in (select proc_cert_Id from AMW_FIN_PROC_CERT_RELAN
1581 where fin_stmt_cert_id = p_certification_id);
1582 --AND aov.authored_date >= p_start_date
1583 --AND aov.authored_date <= p_end_date ;
1584
1585
1586 CURSOR total_org_processes IS
1587 SELECT count(distinct po.organization_id)
1588 FROM AMW_ACCT_ASSOCIATIONS aa,
1589 AMW_FIN_ITEMS_KEY_ACC fika,
1590 AMW_PROCESS_ORGANIZATION po,
1591 AMW_CERTIFICATION_B cert
1592 WHERE aa.object_type = 'PROCESS_ORG'
1593 AND aa.pk1 = po.process_organization_id
1594 AND aa.natural_account_id in
1595 -- (select acc.natural_account_id
1596 -- from AMW_FIN_KEY_ACCOUNTS_B acc
1597 -- START WITH acc.natural_account_id = fika.natural_account_id
1598 -- and acc.account_group_id = fika.account_group_id
1599 -- CONNECT BY PRIOR acc.natural_account_id = acc.parent_natural_account_id
1600 -- and PRIOR acc.account_group_id = acc.account_group_id)
1601
1602 ( select distinct acc.child_natural_account_id
1603 from AMW_FIN_KEY_ACCT_FLAT acc
1604 where acc.parent_natural_account_id = fika.natural_account_id
1605 and acc.account_group_id = fika.account_group_id
1606 union
1607 select distinct acc.natural_account_id
1608 from amw_fin_key_accounts_b acc
1609 where acc.natural_account_id = fika.natural_account_id
1610 and acc.account_group_id = fika.account_group_id
1611 )
1612
1613 AND fika.statement_group_id = cert.statement_group_id
1614 AND fika.financial_statement_id = cert.financial_statement_id
1615 AND cert.certification_id = p_certification_id
1616 AND po.process_id = p_process_id
1617 AND po.organization_id <> NVL(fnd_profile.value('AMW_GLOBAL_ORG_ID'),-999);
1618 */
1619
1620 CURSOR certification_result IS
1621 SELECT aov.opinion_id
1622 FROM AMW_OPINIONS_V aov
1623 WHERE aov.object_name = 'AMW_ORG_PROCESS'
1624 AND aov.opinion_type_code = 'CERTIFICATION'
1625 AND aov.pk3_value = p_organization_id
1626 AND aov.pk2_value in (select proc_cert_Id from AMW_FIN_PROC_CERT_RELAN
1627 where fin_stmt_cert_id = p_certification_id)
1628 AND aov.pk1_value = p_process_id
1629 AND aov.authored_date = (select max(aov2.authored_date)
1630 from AMW_OPINIONS_V aov2
1631 where aov2.object_opinion_type_id = aov.object_opinion_type_id
1632 and aov2.pk3_value = aov.pk3_value
1633 and aov2.pk1_value = aov.pk1_value
1634 and aov2.pk2_value in
1635 (select proc_cert_Id from AMW_FIN_PROC_CERT_RELAN
1636 where fin_stmt_cert_id = p_certification_id));
1637 -- and aov2.authored_date >= p_start_date
1638 -- and aov2.authored_date <= p_end_date) ;
1639
1640 CURSOR last_evaluation IS
1641 SELECT aov.opinion_id
1642 FROM AMW_OPINIONS_V aov
1643 WHERE aov.object_name = 'AMW_ORG_PROCESS'
1644 AND aov.opinion_type_code = 'EVALUATION'
1645 AND aov.pk3_value = p_organization_id
1646 AND aov.pk1_value = p_process_id
1647 AND aov.authored_date = (select max(aov2.authored_date)
1648 from AMW_OPINIONS_V aov2
1649 where aov2.object_opinion_type_id = aov.object_opinion_type_id
1650 and aov2.pk3_value = aov.pk3_value
1651 and aov2.pk1_value = aov.pk1_value);
1652
1653 CURSOR unmitigated_risks IS
1654 SELECT count(1)
1655 FROM AMW_PROCESS_ORGANIZATION apo,
1656 AMW_RISK_ASSOCIATIONS ara,
1657 AMW_OPINIONS_V aov
1658 WHERE apo.organization_id = p_organization_id
1659 AND apo.process_id in ( select distinct(orgrel.child_process_id)
1660 from AMW_PROCESS_ORG_RELATIONS orgrel
1661 START WITH orgrel.child_process_id = p_process_id
1662 and orgrel.organization_id = apo.organization_id
1663 CONNECT BY PRIOR orgrel.child_process_id = orgrel.parent_process_id
1664 and PRIOR orgrel.organization_id = orgrel.organization_id )
1665 AND ara.object_type = 'PROCESS_ORG'
1666 AND ara.pk1 = apo.process_organization_id
1667 AND aov.object_name = 'AMW_ORG_PROCESS_RISK'
1668 AND aov.opinion_type_code = 'EVALUATION'
1669 AND aov.pk3_value = apo.organization_id
1670 AND aov.pk4_value = apo.process_id
1671 AND aov.pk1_value = ara.risk_id
1672 AND aov.authored_date = (select max(aov2.authored_date)
1673 from AMW_OPINIONS_V aov2
1674 where aov2.object_opinion_type_id = aov.object_opinion_type_id
1675 and aov2.pk4_value = aov.pk4_value
1676 and aov2.pk3_value = aov.pk3_value
1677 and aov2.pk1_value = aov.pk1_value)
1678 -- commented by qliu
1679 -- and aov2.authored_date >= p_start_date
1680 -- and aov2.authored_date <= p_end_date)
1681 AND aov.audit_result_code <> 'EFFECTIVE';
1682
1683
1684
1685 CURSOR ineffective_controls IS
1686 SELECT count(distinct aca.control_id)
1687 FROM AMW_PROCESS_ORGANIZATION apo,
1688 AMW_RISK_ASSOCIATIONS ara,
1689 AMW_CONTROL_ASSOCIATIONS aca,
1690 AMW_OPINIONS_V aov
1691 WHERE apo.organization_id = p_organization_id
1692 AND apo.process_id in ( select distinct(orgrel.child_process_id)
1693 from AMW_PROCESS_ORG_RELATIONS orgrel
1694 START WITH orgrel.child_process_id = p_process_id
1695 and orgrel.organization_id = apo.organization_id
1696 CONNECT BY PRIOR orgrel.child_process_id = orgrel.parent_process_id
1697 and PRIOR orgrel.organization_id = orgrel.organization_id )
1698 AND ara.object_type = 'PROCESS_ORG'
1699 AND ara.pk1 = apo.process_organization_id
1700 AND aca.object_type = 'RISK_ORG'
1701 AND aca.pk1 = ara.risk_association_id
1702 AND aov.object_name = 'AMW_ORG_CONTROL'
1703 AND aov.opinion_type_code = 'EVALUATION'
1704 AND aov.pk3_value = apo.organization_id
1705 AND aov.pk1_value = aca.control_id
1706 AND aov.authored_date = (select max(aov2.authored_date)
1707 from AMW_OPINIONS_V aov2
1708 where aov2.object_opinion_type_id = aov.object_opinion_type_id
1709 and aov2.pk3_value = aov.pk3_value
1710 and aov2.pk1_value = aov.pk1_value)
1711 -- commented by qliu
1712 -- and aov2.authored_date >= p_start_date
1713 -- and aov2.authored_date <= p_end_date)
1714 AND aov.audit_result_code <> 'EFFECTIVE';
1715
1716
1717
1718 l_sub_processes_certified NUMBER;
1719 l_total_sub_processes NUMBER;
1720 l_org_processes_certified NUMBER;
1721 l_total_org_processes NUMBER;
1722 l_cert_opinion_id NUMBER;
1723 l_eval_opinion_id NUMBER;
1724 l_last_evaluation NUMBER;
1725 l_unmitigated_risks NUMBER;
1726 l_ineffective_controls NUMBER;
1727 l_open_findings NUMBER;
1728
1729 BEGIN
1730
1731 OPEN sub_processes_certified;
1732 FETCH sub_processes_certified INTO l_sub_processes_certified;
1733 CLOSE sub_processes_certified;
1734
1735 OPEN total_sub_processes;
1736 FETCH total_sub_processes INTO l_total_sub_processes;
1737 CLOSE total_sub_processes;
1738
1739 IF (p_organization_id = NVL(fnd_profile.value('AMW_GLOBAL_ORG_ID'),-999)) THEN
1740 /*
1741 OPEN org_processes_certified;
1742 FETCH org_processes_certified INTO l_org_processes_certified;
1743 CLOSE org_processes_certified;
1744 */
1745 l_org_processes_certified := 0;
1746 /*
1747 OPEN total_org_processes;
1748 FETCH total_org_processes INTO l_total_org_processes;
1749 CLOSE total_org_processes;
1750 */
1751 l_total_org_processes := 0;
1752 ELSE
1753 l_org_processes_certified := 0;
1754 l_total_org_processes := 0;
1755 END IF;
1756
1757
1758 OPEN certification_result;
1759 FETCH certification_result INTO l_cert_opinion_id;
1760 CLOSE certification_result;
1761
1762 OPEN last_evaluation;
1763 FETCH last_evaluation INTO l_eval_opinion_id;
1764 CLOSE last_evaluation;
1765
1766 OPEN unmitigated_risks;
1767 FETCH unmitigated_risks INTO l_unmitigated_risks;
1768 CLOSE unmitigated_risks;
1769
1770 OPEN ineffective_controls;
1771 FETCH ineffective_controls INTO l_ineffective_controls;
1772 CLOSE ineffective_controls;
1773
1774 BEGIN
1775 l_open_findings := amw_findings_pkg.calculate_open_findings (
1776 'AMW_PROJ_FINDING',
1777 'PROJ_ORG_PROC', p_process_id,
1778 'PROJ_ORG', p_organization_id,
1779 null, null,
1780 null, null,
1781 null, null );
1782 EXCEPTION
1783 WHEN OTHERS THEN
1784 null;
1785 END;
1786
1787
1788 UPDATE AMW_FIN_PROCESS_EVAL_SUM
1789 SET CERT_OPINION_ID = l_cert_opinion_id,
1790 EVAL_OPINION_ID = l_eval_opinion_id,
1791 UNMITIGATED_RISKS = l_unmitigated_risks,
1792 INEFFECTIVE_CONTROLS = l_ineffective_controls,
1793 NUMBER_OF_SUB_PROCS_CERTIFIED = l_sub_processes_certified,
1794 TOTAL_NUMBER_OF_SUB_PROCS = l_total_sub_processes,
1795 SUB_PROCS_CERTIFIED_PRCNT = round((l_sub_processes_certified/decode(nvl(l_total_sub_processes,0),0,1,l_total_sub_processes) *100),0),
1796 NUMBER_OF_ORG_PROCS_CERTIFIED = l_org_processes_certified,
1797 TOTAL_NUMBER_OF_ORG_PROCS = l_total_org_processes,
1798 ORG_PROCS_CERTIFIED_PRCNT = round((l_org_processes_certified/decode(nvl(l_total_org_processes,0),0,1,l_total_org_processes) *100),0),
1799 OPEN_FINDINGS = l_open_findings,
1800 LAST_UPDATE_DATE = sysdate,
1801 LAST_UPDATED_BY = FND_GLOBAL.USER_ID,
1802 LAST_UPDATE_LOGIN = FND_GLOBAL.USER_ID
1803 WHERE fin_certification_id = p_certification_id
1804 AND organization_id = p_organization_id
1805 AND process_id = p_process_id;
1806
1807 IF (SQL%NOTFOUND) THEN
1808 INSERT INTO AMW_FIN_PROCESS_EVAL_SUM(
1809 FIN_CERTIFICATION_ID,
1810 PROCESS_ID,
1811 ORGANIZATION_ID,
1812 CERT_OPINION_ID,
1813 EVAL_OPINION_ID,
1814 UNMITIGATED_RISKS,
1815 INEFFECTIVE_CONTROLS,
1816 UNMITIGATED_RISKS_PRCNT,
1817 INEFFECTIVE_CONTROLS_PRCNT,
1818 TOTAL_NUMBER_OF_SUB_PROCS,
1819 NUMBER_OF_SUB_PROCS_CERTIFIED,
1820 SUB_PROCS_CERTIFIED_PRCNT,
1821 TOTAL_NUMBER_OF_ORG_PROCS,
1822 NUMBER_OF_ORG_PROCS_CERTIFIED,
1823 ORG_PROCS_CERTIFIED_PRCNT,
1824 OPEN_FINDINGS,
1825 ACCOUNT_PROCESS_FLAG,
1826 CREATED_BY,
1827 CREATION_DATE,
1828 LAST_UPDATE_DATE,
1829 LAST_UPDATED_BY,
1830 LAST_UPDATE_LOGIN)
1831 SELECT p_certification_id,
1832 p_process_id,
1833 p_organization_id,
1834 l_cert_opinion_id,
1835 l_eval_opinion_id,
1836 l_unmitigated_risks,
1837 l_ineffective_controls,
1838 null,
1839 null,
1840 l_total_sub_processes,
1841 l_sub_processes_certified,
1842 round((l_sub_processes_certified/decode(nvl(l_total_sub_processes,0),0,1,l_total_sub_processes) *100),0),
1843 l_total_org_processes,
1844 l_org_processes_certified,
1845 round((l_org_processes_certified/decode(nvl(l_total_org_processes,0),0,1,l_total_org_processes) *100),0),
1846 l_open_findings,
1847 p_account_process_flag,
1848 FND_GLOBAL.USER_ID,
1849 SYSDATE,
1850 SYSDATE,
1851 FND_GLOBAL.USER_ID,
1852 FND_GLOBAL.USER_ID
1853 FROM DUAL;
1854 END IF;
1855
1856
1857 EXCEPTION WHEN OTHERS THEN
1858 fnd_file.put_line (fnd_file.LOG, SUBSTR ('Unexpected Error in Populate_Fin_Process_Eval_Sum'
1859 || SUBSTR (SQLERRM, 1, 100), 1, 200));
1860 END Populate_Fin_Process_Eval_Sum;
1861
1862 PROCEDURE Populate_All_Fin_Proc_Eval_Sum(
1863 errbuf OUT NOCOPY VARCHAR2,
1864 retcode OUT NOCOPY VARCHAR2,
1865 p_certification_id IN NUMBER
1866 )
1867 IS
1868
1869 -- select all processes in scope for the certification
1870 CURSOR c_cert IS
1871 SELECT cert.CERTIFICATION_ID, period.start_date
1872 FROM AMW_CERTIFICATION_B cert, AMW_GL_PERIODS_V period
1873 WHERE cert.object_type = 'FIN_STMT' and cert.certification_period_name = period.period_name
1874 AND cert.certification_period_set_name = period.period_set_name
1875 and cert.CERTIFICATION_STATUS in ('ACTIVE', 'DRAFT');
1876
1877 l_api_name CONSTANT VARCHAR2(30) := 'Populate_All_Fin_Proc_Eval_Sum';
1878 l_certification_id number;
1879
1880
1881 l_return_status VARCHAR2(32767);
1882 l_msg_count NUMBER;
1883 l_msg_data VARCHAR2(32767);
1884
1885 BEGIN
1886
1887 SAVEPOINT Populate_All_Fin_Proc_Eval_Sum;
1888 fnd_file.put_line(fnd_file.LOG, 'start populate_all_fin_proc_eval_sum:'||to_char(sysdate, 'hh:mi:ss dd-mon-rrrr'));
1889 fnd_file.put_line(fnd_file.LOG, 'p_certification_id = :' || p_certification_id);
1890
1891 -- Initialize API return status to SUCCESS
1892 l_return_status := FND_API.G_RET_STS_SUCCESS;
1893
1894 l_certification_id := p_certification_id;
1895
1896 IF p_certification_id IS NOT NULL THEN
1897
1898 -- AMW_FINSTMT_CERT_BES_PKG.reset_amw_fin_cert_eval_sum(p_certification_id => l_certification_id) ;
1899 --AMW_FINSTMT_CERT_BES_PKG.reset_amw_fin_proc_eval_sum(p_certification_id => l_certification_id);
1900 --AMW_FINSTMT_CERT_BES_PKG.reset_amw_fin_org_eval_sum(p_certification_id => l_certification_id);
1901 --AMW_FINSTMT_CERT_BES_PKG.reset_amw_cert_dashboard_sum(p_certification_id => l_certification_id);
1902 --AMW_FINSTMT_CERT_BES_PKG.reset_fin_all(p_certification_id => l_certification_id);
1903 amw_fin_coso_views_pvt.DELETE_ROWS(x_fin_certification_id => l_certification_id);
1904
1905 AMW_FINSTMT_CERT_BES_PKG.Master_Fin_Proc_Eval_Sum
1906 (p_certification_id => l_certification_id,
1907 x_return_status => l_return_status,
1908 x_msg_count => l_msg_count,
1909 x_msg_data => l_msg_data);
1910
1911
1912 ELSE
1913 FOR cert_rec IN c_cert LOOP
1914 exit when c_cert%notfound;
1915 --AMW_FINSTMT_CERT_BES_PKG.reset_amw_fin_cert_eval_sum(p_certification_id => cert_rec.certification_id) ;
1916 --AMW_FINSTMT_CERT_BES_PKG.reset_amw_fin_proc_eval_sum(p_certification_id => cert_rec.certification_id);
1917 --AMW_FINSTMT_CERT_BES_PKG.reset_amw_fin_org_eval_sum(p_certification_id => cert_rec.certification_id);
1918 --AMW_FINSTMT_CERT_BES_PKG.reset_amw_cert_dashboard_sum(p_certification_id => cert_rec.certification_id);
1919 --AMW_FINSTMT_CERT_BES_PKG.reset_fin_all(p_certification_id => cert_rec.certification_id);
1920 amw_fin_coso_views_pvt.DELETE_ROWS(x_fin_certification_id => cert_rec.certification_id);
1921
1922 AMW_FINSTMT_CERT_BES_PKG.Master_Fin_Proc_Eval_Sum
1923 (p_certification_id => cert_rec.certification_id,
1924 x_return_status => l_return_status,
1925 x_msg_count => l_msg_count,
1926 x_msg_data => l_msg_data);
1927
1928 END LOOP;
1929
1930 END IF;
1931
1932
1933 /***05.25.2006 npanandi: bug 5250100 test***/
1934 if(AMW_FINSTMT_CERT_BES_PKG.G_ORG_ERROR = 'Y')then
1935 retcode := '1'; /**2 = EXCEPTION, 1 = WARNING, 0 = SUCCESS**/
1936 errbuf := 'Check out the Organizations';
1937 end if;
1938 /***05.25.2006 npanandi: bug 5250100 test ends***/
1939
1940
1941 EXCEPTION
1942 WHEN NO_DATA_FOUND THEN
1943 fnd_file.put_line (fnd_file.LOG, SUBSTR ('No data found in AMW_FINSTMT_CERT_PVT.Populate_All_Fin_Process_Eval_Sum'
1944 || SUBSTR (SQLERRM, 1, 100), 1, 200));
1945 WHEN OTHERS THEN
1946 fnd_file.put_line (fnd_file.LOG, SUBSTR ('Unexpected Error in AMW_FINSTMT_CERT_PVT.Populate_All_Fin_Proc_Eval_Sum'
1947 || SUBSTR (SQLERRM, 1, 100), 1, 200));
1948 ROLLBACK TO Populate_All_Fin_Proc_Eval_Sum;
1949 FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME, l_api_name);
1950 FND_MSG_PUB.Count_And_Get(
1951 p_encoded => FND_API.G_FALSE,
1952 p_count => l_msg_count,
1953 p_data => l_msg_data);
1954
1955 errbuf := SUBSTR (SQLERRM, 1, 2000) ;
1956 retcode := FND_API.G_RET_STS_UNEXP_ERROR;
1957
1958 END Populate_All_Fin_Proc_Eval_Sum;
1959
1960
1961 /********* USED IN THE CONCURRENT PROGRAM BEFORE BUSSINESS EVENT ******************
1962 PROCEDURE Populate_All_Fin_Proc_Eval_Sum(
1963 errbuf OUT NOCOPY VARCHAR2,
1964 retcode OUT NOCOPY VARCHAR2,
1965 p_certification_id IN NUMBER
1966 )
1967 IS
1968
1969 CURSOR c_cert IS
1970 SELECT cert.certification_id, period.start_date,period.end_date
1971 FROM AMW_CERTIFICATION_B cert,
1972 AMW_GL_PERIODS_V period
1973 WHERE cert.certification_period_name = period.period_name
1974 AND cert.certification_period_set_name = period.period_set_name
1975 AND cert.object_type='FIN_STMT'
1976 AND cert.certification_status in ('ACTIVE','DRAFT');
1977
1978 CURSOR c_period_dates IS
1979 SELECT period.start_date,period.end_date
1980 FROM AMW_CERTIFICATION_B cert,
1981 AMW_GL_PERIODS_V period
1982 WHERE cert.certification_period_name = period.period_name
1983 AND cert.certification_period_set_name = period.period_set_name
1984 AND cert.certification_id = p_certification_id;
1985
1986 -- select all the processes based on the certification_id
1987 CURSOR c_process(p_cert_id NUMBER) IS
1988 SELECT distinct aa.pk1 process_organization_id,po.process_id,po.organization_id
1989 FROM AMW_ACCT_ASSOCIATIONS aa,
1990 AMW_FIN_ITEMS_KEY_ACC fika,
1991 AMW_PROCESS_ORGANIZATION po,
1992 AMW_CERTIFICATION_B cert
1993 WHERE aa.object_type = 'PROCESS_ORG'
1994 AND aa.pk1 = po.process_organization_id
1995 AND aa.natural_account_id in
1996
1997 -- (select acc.natural_account_id
1998 -- from AMW_FIN_KEY_ACCOUNTS_B acc
1999 -- START WITH acc.natural_account_id = fika.natural_account_id
2000 -- and acc.account_group_id = fika.account_group_id
2001 -- CONNECT BY PRIOR acc.natural_account_id = acc.parent_natural_account_id
2002 -- and PRIOR acc.account_group_id = acc.account_group_id)
2003
2004 ( select distinct acc.child_natural_account_id
2005 from AMW_FIN_KEY_ACCT_FLAT acc
2006 where acc.parent_natural_account_id = fika.natural_account_id
2007 and acc.account_group_id = fika.account_group_id
2008 union
2009 select distinct acc.natural_account_id
2010 from amw_fin_key_accounts_b acc
2011 where acc.natural_account_id = fika.natural_account_id
2012 and acc.account_group_id = fika.account_group_id
2013 )
2014
2015 AND fika.statement_group_id = cert.statement_group_id
2016 AND fika.financial_statement_id = cert.financial_statement_id
2017 AND cert.certification_id = p_cert_id;
2018
2019 --Select all the child processes .
2020 CURSOR c_child_processes(p_proc_id NUMBER, p_org_id NUMBER) IS
2021 SELECT distinct child_process_id
2022 FROM AMW_PROCESS_ORG_RELATIONS
2023 START WITH parent_process_id = p_proc_id
2024 AND organization_id = p_org_id
2025 CONNECT BY PRIOR child_process_id = parent_process_id
2026 AND PRIOR organization_id = organization_id;
2027
2028 -- org process certified
2029 CURSOR org_processes_certified(p_cert_id NUMBER,p_process_id NUMBER) IS
2030 SELECT count(distinct aov.pk3_value)
2031 FROM AMW_OPINIONS_V aov
2032 WHERE aov.object_name = 'AMW_ORG_PROCESS'
2033 AND aov.opinion_type_code = 'CERTIFICATION'
2034 AND aov.pk3_value <> NVL(fnd_profile.value('AMW_GLOBAL_ORG_ID'),-999)
2035 AND aov.pk1_value = p_process_id
2036 AND aov.pk3_value in (select distinct evalsum.organization_id
2037 from amw_fin_process_eval_sum evalsum
2038 where evalsum.fin_certification_id = p_cert_id
2039 and evalsum.process_id=p_process_id)
2040 AND aov.pk2_value in (select proc_cert_Id from AMW_FIN_PROC_CERT_RELAN
2041 where fin_stmt_cert_id = p_cert_id);
2042
2043 CURSOR total_org_processes(p_cert_id NUMBER,p_process_id NUMBER) IS
2044 select count(distinct evalsum.organization_id)
2045 from amw_fin_process_eval_sum evalsum
2046 where evalsum.fin_certification_id = p_cert_id
2047 and evalsum.process_id=p_process_id
2048 and evalsum.organization_id <>
2049 NVL(fnd_profile.value('AMW_GLOBAL_ORG_ID'),-999);
2050
2051 --Begin variant process
2052
2053 CURSOR var_procs(p_cert_id NUMBER) IS
2054 SELECT fin_certification_id,organization_id,process_id
2055 FROM AMW_FIN_PROCESS_EVAL_SUM
2056 WHERE fin_certification_id = p_cert_id
2057 AND organization_id = NVL(fnd_profile.value('AMW_GLOBAL_ORG_ID'),-999);
2058
2059 CURSOR org_var_processes_certified(p_cert_id NUMBER,p_start_date DATE,p_end_date DATE,p_process_id NUMBER) IS
2060 select count(1) from
2061 (SELECT distinct aov.pk3_value,aov.pk1_value
2062 FROM AMW_OPINIONS_V aov
2063 WHERE aov.object_name = 'AMW_ORG_PROCESS'
2064 AND aov.opinion_type_code = 'CERTIFICATION'
2065 --AND aov.pk3_value <> NVL(fnd_profile.value('AMW_GLOBAL_ORG_ID'),-999)
2066 --AND aov.authored_date >= p_start_date
2067 --AND aov.authored_date <= p_end_date
2068 AND aov.pk2_value in (
2069 select proc_cert_Id from AMW_FIN_PROC_CERT_RELAN
2070 where fin_stmt_cert_id = p_cert_id)
2071 AND aov.pk1_value in (SELECT varproc.process_id
2072 FROM AMW_PROCESS varproc
2073 WHERE varproc.standard_variation = p_process_id
2074 AND varproc.standard_process_flag = 'N'
2075 AND varproc.process_id in (select distinct evalsum.process_id
2076 from amw_fin_process_eval_sum evalsum
2077 where evalsum.fin_certification_id = p_cert_id)));
2078
2079
2080 CURSOR total_org_var_processes(p_cert_id NUMBER,p_process_id NUMBER) IS
2081 select count(1) from
2082 (select distinct evalsum.organization_id,evalsum.process_id
2083 from amw_fin_process_eval_sum evalsum
2084 where evalsum.fin_certification_id = p_cert_id
2085 and evalsum.process_id in (select varproc.process_id
2086 FROM AMW_PROCESS varproc
2087 WHERE varproc.standard_variation = p_process_id
2088 AND varproc.standard_process_flag = 'N'));
2089 -- end variant process
2090
2091 l_start_date DATE;
2092 l_end_date DATE;
2093 l_org_var_processes_certified NUMBER;
2094 l_org_processes_certified NUMBER;
2095 l_total_org_var_processes NUMBER;
2096 l_total_org_processes NUMBER;
2097
2098 BEGIN
2099 fnd_file.put_line (fnd_file.LOG, 'Certification_Id:'||p_certification_id);
2100
2101 IF p_certification_id IS NOT NULL THEN
2102
2103 DELETE from AMW_FIN_PROCESS_EVAL_SUM
2104 WHERE fin_certification_id = p_certification_id;
2105
2106 OPEN c_period_dates;
2107 FETCH c_period_dates INTO l_start_date,l_end_date;
2108 CLOSE c_period_dates;
2109
2110 FOR process_rec IN c_process(p_certification_id) LOOP
2111 Populate_Fin_Process_Eval_Sum(p_certification_id,l_start_date,l_end_date,process_rec.process_organization_id,
2112 process_rec.process_id,process_rec.organization_id,'Y');
2113 --Populate data for child processes
2114 FOR child_rec IN c_child_processes(process_rec.process_id,process_rec.organization_id) LOOP
2115 Populate_Fin_Process_Eval_Sum(p_certification_id,l_start_date,l_end_date,process_rec.process_organization_id,
2116 child_rec.child_process_id,process_rec.organization_id,'N');
2117 END LOOP;
2118 END LOOP;
2119
2120 -- Handle varient processes
2121 FOR var_rec IN var_procs(p_certification_id) LOOP
2122
2123 OPEN org_var_processes_certified(var_rec.fin_certification_id,l_start_date,l_end_date,var_rec.process_id);
2124 FETCH org_var_processes_certified INTO l_org_var_processes_certified;
2125 CLOSE org_var_processes_certified;
2126
2127 OPEN org_processes_certified(var_rec.fin_certification_id,var_rec.process_id);
2128 FETCH org_processes_certified INTO l_org_processes_certified;
2129 CLOSE org_processes_certified;
2130
2131 l_org_processes_certified := l_org_processes_certified+
2132 l_org_var_processes_certified;
2133
2134 OPEN total_org_var_processes(var_rec.fin_certification_id,var_rec.process_id);
2135 FETCH total_org_var_processes INTO l_total_org_var_processes;
2136 CLOSE total_org_var_processes;
2137
2138 OPEN total_org_processes(var_rec.fin_certification_id,var_rec.process_id);
2139 FETCH total_org_processes INTO l_total_org_processes;
2140 CLOSE total_org_processes;
2141
2142 l_total_org_processes := l_total_org_processes+
2143 l_total_org_var_processes;
2144
2145 UPDATE AMW_FIN_PROCESS_EVAL_SUM
2146 SET TOTAL_NUMBER_OF_ORG_PROCS = l_total_org_processes,
2147 NUMBER_OF_ORG_PROCS_CERTIFIED = l_org_processes_certified,
2148 ORG_PROCS_CERTIFIED_PRCNT =
2149 round(((l_org_processes_certified/decode(l_total_org_processes,0,1,l_total_org_processes)) *100),0)
2150 WHERE FIN_CERTIFICATION_ID = var_rec.fin_certification_id
2151 AND ORGANIZATION_ID = var_rec.organization_id
2152 AND PROCESS_ID = var_rec.process_id;
2153
2154 END LOOP;
2155
2156
2157 COMMIT;
2158 ELSE
2159 FOR cert_rec IN c_cert LOOP
2160
2161 DELETE from AMW_FIN_PROCESS_EVAL_SUM
2162 WHERE fin_certification_id = cert_rec.certification_id;
2163
2164 FOR process_rec IN c_process(cert_rec.certification_id) LOOP
2165 Populate_Fin_Process_Eval_Sum(cert_rec.certification_id,cert_rec.start_date,cert_rec.end_date,process_rec.process_organization_id,
2166 process_rec.process_id,process_rec.organization_id,'Y');
2167 --Populate data for child processes
2168 FOR child_rec IN c_child_processes(process_rec.process_id,process_rec.organization_id) LOOP
2169 Populate_Fin_Process_Eval_Sum(cert_rec.certification_id,cert_rec.start_date,cert_rec.end_date,process_rec.process_organization_id,
2170 child_rec.child_process_id,process_rec.organization_id,'N');
2171 END LOOP;
2172 END LOOP;
2173
2174 -- Handle varient processes
2175 FOR var_rec IN var_procs(cert_rec.certification_id) LOOP
2176
2177 OPEN org_var_processes_certified(var_rec.fin_certification_id,l_start_date,l_end_date,var_rec.process_id);
2178 FETCH org_var_processes_certified INTO l_org_var_processes_certified;
2179 CLOSE org_var_processes_certified;
2180
2181 OPEN org_processes_certified(var_rec.fin_certification_id,var_rec.process_id);
2182 FETCH org_processes_certified INTO l_org_processes_certified;
2183 CLOSE org_processes_certified;
2184 l_org_processes_certified := l_org_processes_certified+
2185 l_org_var_processes_certified;
2186
2187 OPEN total_org_var_processes(var_rec.fin_certification_id,var_rec.process_id);
2188 FETCH total_org_var_processes INTO l_total_org_var_processes;
2189 CLOSE total_org_var_processes;
2190
2191 OPEN total_org_processes(var_rec.fin_certification_id,var_rec.process_id);
2192 FETCH total_org_processes INTO l_total_org_processes;
2193 CLOSE total_org_processes;
2194 l_total_org_processes := l_total_org_processes+
2195 l_total_org_var_processes;
2196
2197 UPDATE AMW_FIN_PROCESS_EVAL_SUM
2198 SET TOTAL_NUMBER_OF_ORG_PROCS = l_total_org_processes,
2199 NUMBER_OF_ORG_PROCS_CERTIFIED = l_org_processes_certified,
2200 ORG_PROCS_CERTIFIED_PRCNT =
2201 round(((l_org_processes_certified/decode(l_total_org_processes,0,1,l_total_org_processes)) *100),0)
2202 WHERE FIN_CERTIFICATION_ID = var_rec.fin_certification_id
2203 AND ORGANIZATION_ID = var_rec.organization_id
2204 AND PROCESS_ID = var_rec.process_id;
2205
2206 END LOOP;
2207
2208 COMMIT;
2209 END LOOP;
2210 END IF;
2211
2212 EXCEPTION
2213 WHEN NO_DATA_FOUND THEN
2214 fnd_file.put_line (fnd_file.LOG, SUBSTR ('No data found in Populate_All_Fin_Process_Eval_Sum'
2215 || SUBSTR (SQLERRM, 1, 100), 1, 200));
2216 WHEN OTHERS THEN
2217 fnd_file.put_line (fnd_file.LOG, SUBSTR ('Unexpected Error in Populate_All_Fin_Process_Eval_Sum'
2218 || SUBSTR (SQLERRM, 1, 100), 1, 200));
2219 errbuf := SQLERRM;
2220 retcode := FND_API.G_RET_STS_UNEXP_ERROR;
2221 END Populate_All_Fin_Proc_Eval_Sum;
2222
2223 ***********************************************************************/
2224
2225
2226 /********implementation before bussiness event takes place since amw.d ************/
2227 PROCEDURE Populate_Fin_Org_Eval_Sum(
2228 p_certification_id IN NUMBER,
2229 p_start_date IN DATE,
2230 p_end_date IN DATE,
2231 p_organization_id IN NUMBER
2232 )
2233 IS
2234 CURSOR last_evaluation IS
2235 SELECT aov.opinion_id
2236 FROM AMW_OPINIONS_V aov
2237 WHERE aov.object_name = 'AMW_ORGANIZATION'
2238 AND aov.opinion_type_code = 'EVALUATION'
2239 AND aov.pk1_value = p_organization_id
2240 AND aov.authored_date = (select max(aov2.authored_date)
2241 from AMW_OPINIONS_V aov2
2242 where aov2.object_opinion_type_id = aov.object_opinion_type_id
2243 and aov2.pk1_value = aov.pk1_value);
2244
2245 /*
2246 CURSOR proc_pending_cert IS
2247 SELECT count(distinct apo.process_id)
2248 FROM AMW_ACCT_ASSOCIATIONS aa,
2249 AMW_FIN_ITEMS_KEY_ACC fika,
2250 AMW_CERTIFICATION_B cert,
2251 AMW_PROCESS_ORGANIZATION apo,
2252 AMW_PROCESS_ORGANIZATION apo2
2253 WHERE aa.object_type = 'PROCESS_ORG'
2254 AND apo2.process_organization_id = aa.pk1
2255 AND (apo.process_id, apo.organization_id) in
2256 (select child_process_id, organization_id
2257 from Amw_Process_Org_Relations
2258 start with child_process_id = apo2.process_id
2259 and organization_id = apo2.organization_Id
2260 CONNECT BY PRIOR child_process_id = parent_process_id
2261 and PRIOR organization_id = organization_id)
2262 AND aa.natural_account_id in
2263
2264 -- (select acc.natural_account_id
2265 -- from AMW_FIN_KEY_ACCOUNTS_B acc
2266 -- START WITH acc.natural_account_id = fika.natural_account_id
2267 -- and acc.account_group_id = fika.account_group_id
2268 -- CONNECT BY PRIOR acc.natural_account_id = acc.parent_natural_account_id
2269 -- and PRIOR acc.account_group_id = acc.account_group_id)
2270
2271 ( select distinct acc.child_natural_account_id
2272 from AMW_FIN_KEY_ACCT_FLAT acc
2273 where acc.parent_natural_account_id = fika.natural_account_id
2274 and acc.account_group_id = fika.account_group_id
2275 union
2276 select distinct acc.natural_account_id
2277 from amw_fin_key_accounts_b acc
2278 where acc.natural_account_id = fika.natural_account_id
2279 and acc.account_group_id = fika.account_group_id
2280 )
2281 AND fika.statement_group_id = cert.statement_group_id
2282 AND fika.financial_statement_id = cert.financial_statement_id
2283 AND cert.certification_id = p_certification_id
2284 AND apo.organization_id = p_organization_id
2285 AND not exists (SELECT 'Y'
2286 FROM AMW_OPINIONS_V aov
2287 WHERE aov.object_name = 'AMW_ORG_PROCESS'
2288 AND aov.opinion_type_code = 'CERTIFICATION'
2289 AND aov.pk3_value = p_organization_id
2290 AND aov.pk1_value = apo.process_id
2291 AND aov.authored_date >= p_start_date
2292 AND aov.authored_date <= p_end_date);
2293 */
2294 CURSOR total_num_of_proc IS
2295 SELECT count(distinct hier.parent_child_id)
2296 FROM AMW_ACCT_ASSOCIATIONS aa,
2297 AMW_PROCESS_ORGANIZATION po,
2298 (select process_id, organization_id, parent_child_id, up_down_ind
2299 from Amw_Org_Hierarchy_Denorm hier
2300 union select process_id, organization_id, process_id, 'D'
2301 from amw_process_organization) hier
2302 WHERE aa.object_type = 'PROCESS_ORG'
2303 AND po.process_organization_id = aa.pk1
2304 AND hier.organization_id = po.organization_id
2305 AND hier.process_id = po.process_id
2306 AND hier.up_down_ind = 'D'
2307 AND aa.natural_account_id in
2308
2309 -- (select acc.natural_account_id
2310 -- from AMW_FIN_KEY_ACCOUNTS_B acc
2311 -- START WITH ((acc.natural_account_id, acc.account_group_id) in
2312 -- (select fika.natural_account_id, fika.account_group_id
2313 -- from AMW_FIN_ITEMS_KEY_ACC fika,
2314 -- AMW_CERTIFICATION_B cert
2315 -- where fika.statement_group_id = cert.statement_group_id
2316 -- AND fika.financial_statement_id = cert.financial_statement_id
2317 -- AND cert.certification_id = p_certification_id))
2318 -- CONNECT BY PRIOR acc.natural_account_id = acc.parent_natural_account_id
2319 -- and PRIOR acc.account_group_id = acc.account_group_id)
2320
2321 ( select distinct acc.child_natural_account_id
2322 from amw_fin_key_acct_flat acc
2323 where ( acc.parent_natural_account_id, acc.account_group_id ) in
2324 ( select natural_account_id, account_group_id
2325 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC fika
2326 where cert.certification_id = p_certification_id
2327 and cert.statement_group_id = fika.statement_group_id
2328 and cert.financial_statement_id = fika.FINANCIAL_STATEMENT_ID
2329 )
2330 union
2331 select distinct acc.natural_account_id
2332 from amw_fin_key_accounts_b acc
2333 where ( acc.natural_account_id, acc.account_group_id ) in
2334 ( select natural_account_id, account_group_id
2335 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC fika
2336 where cert.certification_id = p_certification_id
2337 and cert.statement_group_id = fika.statement_group_id
2338 and cert.financial_statement_id = fika.FINANCIAL_STATEMENT_ID
2339 )
2340 )
2341
2342 AND po.organization_id = p_organization_id;
2343
2344
2345 CURSOR proc_with_issue IS
2346 SELECT count(distinct hier.parent_child_id)
2347 FROM AMW_ACCT_ASSOCIATIONS aa,
2348 AMW_PROCESS_ORGANIZATION po,
2349 (select process_id, organization_id, parent_child_id, up_down_ind
2350 from Amw_Org_Hierarchy_Denorm hier
2351 union select process_id, organization_id, process_id, 'D'
2352 from amw_process_organization) hier,
2353 AMW_OPINIONS_V aov
2354 WHERE aa.object_type = 'PROCESS_ORG'
2355 AND po.process_organization_id = aa.pk1
2356 AND hier.organization_id = po.organization_id
2357 AND hier.process_id = po.process_id
2358 AND hier.up_down_ind = 'D'
2359 AND aa.natural_account_id in
2360
2361 -- (select acc.natural_account_id
2362 -- from AMW_FIN_KEY_ACCOUNTS_B acc
2363 -- START WITH ((acc.natural_account_id, acc.account_group_id) in
2364 -- (select fika.natural_account_id, fika.account_group_id
2365 -- from AMW_FIN_ITEMS_KEY_ACC fika,
2366 -- AMW_CERTIFICATION_B cert
2367 -- where fika.statement_group_id = cert.statement_group_id
2368 -- AND fika.financial_statement_id = cert.financial_statement_id
2369 -- AND cert.certification_id = p_certification_id))
2370 -- CONNECT BY PRIOR acc.natural_account_id = acc.parent_natural_account_id
2371 -- and PRIOR acc.account_group_id = acc.account_group_id)
2372
2373 ( select distinct acc.child_natural_account_id
2374 from amw_fin_key_acct_flat acc
2375 where ( acc.parent_natural_account_id, acc.account_group_id ) in
2376 ( select natural_account_id, account_group_id
2377 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC fika
2378 where cert.certification_id = p_certification_id
2379 and cert.statement_group_id = fika.statement_group_id
2380 and cert.financial_statement_id = fika.FINANCIAL_STATEMENT_ID
2381 )
2382 union
2383 select distinct acc.natural_account_id
2384 from amw_fin_key_accounts_b acc
2385 where ( acc.natural_account_id, acc.account_group_id ) in
2386 ( select natural_account_id, account_group_id
2387 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC fika
2388 where cert.certification_id = p_certification_id
2389 and cert.statement_group_id = fika.statement_group_id
2390 and cert.financial_statement_id = fika.FINANCIAL_STATEMENT_ID
2391 )
2392 )
2393
2394 AND po.organization_id = p_organization_id
2395 AND aov.object_name = 'AMW_ORG_PROCESS'
2396 AND aov.opinion_type_code = 'CERTIFICATION'
2397 AND aov.pk3_value = p_organization_id
2398 AND aov.pk2_value in (select proc_cert_Id from AMW_FIN_PROC_CERT_RELAN
2399 where fin_stmt_cert_id = p_certification_id)
2400 AND aov.pk1_value = hier.parent_child_id
2401 AND aov.authored_date = (select max(aov2.authored_date)
2402 from AMW_OPINIONS_V aov2
2403 where aov2.object_opinion_type_id
2404 = aov.object_opinion_type_id
2405 and aov2.pk3_value = aov.pk3_value
2406 AND aov2.pk2_value in
2407 (select proc_cert_Id from AMW_FIN_PROC_CERT_RELAN
2408 w where fin_stmt_cert_id = p_certification_id)
2409 and aov2.pk1_value = aov.pk1_value)
2410 AND aov.audit_result_code <> 'EFFECTIVE';
2411
2412
2413 CURSOR proc_without_issue IS
2414 SELECT count(distinct hier.parent_child_id)
2415 FROM AMW_ACCT_ASSOCIATIONS aa,
2416 AMW_PROCESS_ORGANIZATION po,
2417 (select process_id, organization_id, parent_child_id, up_down_ind
2418 from Amw_Org_Hierarchy_Denorm hier
2419 union select process_id, organization_id, process_id, 'D'
2420 from amw_process_organization) hier,
2421 AMW_OPINIONS_V aov
2422 WHERE aa.object_type = 'PROCESS_ORG'
2423 AND po.process_organization_id = aa.pk1
2424 AND hier.organization_id = po.organization_id
2425 AND hier.process_id = po.process_id
2426 AND hier.up_down_ind = 'D'
2427 AND aa.natural_account_id in
2428
2429 -- (select acc.natural_account_id
2430 -- from AMW_FIN_KEY_ACCOUNTS_B acc
2431 -- START WITH ((acc.natural_account_id, acc.account_group_id) in
2432 -- (select fika.natural_account_id, fika.account_group_id
2433 -- from AMW_FIN_ITEMS_KEY_ACC fika,
2434 -- AMW_CERTIFICATION_B cert
2435 -- where fika.statement_group_id = cert.statement_group_id
2436 -- AND fika.financial_statement_id = cert.financial_statement_id
2437 -- AND cert.certification_id = p_certification_id))
2438 -- CONNECT BY PRIOR acc.natural_account_id = acc.parent_natural_account_id
2439 -- and PRIOR acc.account_group_id = acc.account_group_id)
2440
2441 ( select distinct acc.child_natural_account_id
2442 from amw_fin_key_acct_flat acc
2443 where ( acc.parent_natural_account_id, acc.account_group_id ) in
2444 ( select natural_account_id, account_group_id
2445 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC fika
2446 where cert.certification_id = p_certification_id
2447 and cert.statement_group_id = fika.statement_group_id
2448 and cert.financial_statement_id = fika.FINANCIAL_STATEMENT_ID
2449 )
2450 union
2451 select distinct acc.natural_account_id
2452 from amw_fin_key_accounts_b acc
2453 where ( acc.natural_account_id, acc.account_group_id ) in
2454 ( select natural_account_id, account_group_id
2455 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC fika
2456 where cert.certification_id = p_certification_id
2457 and cert.statement_group_id = fika.statement_group_id
2458 and cert.financial_statement_id = fika.FINANCIAL_STATEMENT_ID
2459 )
2460 )
2461
2462 AND po.organization_id = p_organization_id
2463 AND aov.object_name = 'AMW_ORG_PROCESS'
2464 AND aov.opinion_type_code = 'CERTIFICATION'
2465 AND aov.pk3_value = p_organization_id
2466 AND aov.pk2_value in (select proc_cert_Id from AMW_FIN_PROC_CERT_RELAN
2467 where fin_stmt_cert_id = p_certification_id)
2468 AND aov.pk1_value = hier.parent_child_id
2469 AND aov.authored_date = (select max(aov2.authored_date)
2470 from AMW_OPINIONS_V aov2
2471 where aov2.object_opinion_type_id
2472 = aov.object_opinion_type_id
2473 and aov2.pk3_value = aov.pk3_value
2474 AND aov2.pk2_value in
2475 (select proc_cert_Id from AMW_FIN_PROC_CERT_RELAN
2476 w where fin_stmt_cert_id = p_certification_id)
2477 and aov2.pk1_value = aov.pk1_value)
2478 AND aov.audit_result_code = 'EFFECTIVE';
2479
2480 CURSOR proc_with_ineff_ctrl IS
2481 SELECT count(distinct hier.parent_child_id)
2482 FROM AMW_ACCT_ASSOCIATIONS aa,
2483 AMW_PROCESS_ORGANIZATION po,
2484 (select process_id, organization_id, parent_child_id, up_down_ind
2485 from Amw_Org_Hierarchy_Denorm hier
2486 union select process_id, organization_id, process_id, 'D'
2487 from amw_process_organization) hier,
2488 AMW_OPINIONS_V aov
2489 WHERE aa.object_type = 'PROCESS_ORG'
2490 AND po.process_organization_id = aa.pk1
2491 AND hier.organization_id = po.organization_id
2492 AND hier.process_id = po.process_id
2493 AND hier.up_down_ind = 'D'
2494 AND aa.natural_account_id in
2495
2496 -- (select acc.natural_account_id
2497 -- from AMW_FIN_KEY_ACCOUNTS_B acc
2498 -- START WITH ((acc.natural_account_id, acc.account_group_id) in
2499 -- (select fika.natural_account_id, fika.account_group_id
2500 -- from AMW_FIN_ITEMS_KEY_ACC fika,
2501 -- AMW_CERTIFICATION_B cert
2502 -- where fika.statement_group_id = cert.statement_group_id
2503 -- AND fika.financial_statement_id = cert.financial_statement_id
2504 -- AND cert.certification_id = p_certification_id))
2505 -- CONNECT BY PRIOR acc.natural_account_id = acc.parent_natural_account_id
2506 -- and PRIOR acc.account_group_id = acc.account_group_id)
2507
2508 ( select distinct acc.child_natural_account_id
2509 from amw_fin_key_acct_flat acc
2510 where ( acc.parent_natural_account_id, acc.account_group_id ) in
2511 ( select natural_account_id, account_group_id
2512 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC fika
2513 where cert.certification_id = p_certification_id
2514 and cert.statement_group_id = fika.statement_group_id
2515 and cert.financial_statement_id = fika.FINANCIAL_STATEMENT_ID
2516 )
2517 union
2518 select distinct acc.natural_account_id
2519 from amw_fin_key_accounts_b acc
2520 where ( acc.natural_account_id, acc.account_group_id ) in
2521 ( select natural_account_id, account_group_id
2522 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC fika
2523 where cert.certification_id = p_certification_id
2524 and cert.statement_group_id = fika.statement_group_id
2525 and cert.financial_statement_id = fika.FINANCIAL_STATEMENT_ID
2526 )
2527 )
2528
2529 AND po.organization_id = p_organization_id
2530 AND aov.object_name = 'AMW_ORG_PROCESS'
2531 AND aov.opinion_type_code = 'EVALUATION'
2532 AND aov.pk3_value = hier.organization_id
2533 AND aov.pk1_value = hier.parent_child_id
2534 AND aov.authored_date =
2535 (select max(aov2.authored_date)
2536 from AMW_OPINIONS_V aov2
2537 where aov2.object_opinion_type_id = aov.object_opinion_type_id
2538 and aov2.pk3_value = aov.pk3_value
2539 and aov2.pk1_value = aov.pk1_value)
2540 AND aov.audit_result_code <> 'EFFECTIVE';
2541
2542 CURSOR unmitigated_risks IS
2543 SELECT count(distinct ara.risk_association_id)
2544 FROM AMW_ACCT_ASSOCIATIONS aa,
2545 AMW_PROCESS_ORGANIZATION po,
2546 (select process_id, organization_id, parent_child_id, up_down_ind
2547 from Amw_Org_Hierarchy_Denorm hier
2548 union select process_id, organization_id, process_id, 'D'
2549 from amw_process_organization) hier,
2550 AMW_PROCESS_ORGANIZATION po2,
2551 AMW_RISK_ASSOCIATIONS ara,
2552 AMW_OPINIONS_V aov
2553 WHERE aa.object_type = 'PROCESS_ORG'
2554 AND po.process_organization_id = aa.pk1
2555 AND hier.organization_id = po.organization_id
2556 AND hier.process_id = po.process_id
2557 AND hier.up_down_ind = 'D'
2558 AND aa.natural_account_id in
2559
2560 -- (select acc.natural_account_id
2561 -- from AMW_FIN_KEY_ACCOUNTS_B acc
2562 -- START WITH ((acc.natural_account_id, acc.account_group_id) in
2563 -- (select fika.natural_account_id, fika.account_group_id
2564 -- from AMW_FIN_ITEMS_KEY_ACC fika,
2565 -- AMW_CERTIFICATION_B cert
2566 -- where fika.statement_group_id = cert.statement_group_id
2567 -- AND fika.financial_statement_id = cert.financial_statement_id
2568 -- AND cert.certification_id = p_certification_id))
2569 -- CONNECT BY PRIOR acc.natural_account_id = acc.parent_natural_account_id
2570 -- and PRIOR acc.account_group_id = acc.account_group_id)
2571
2572 ( select distinct acc.child_natural_account_id
2573 from amw_fin_key_acct_flat acc
2574 where ( acc.parent_natural_account_id, acc.account_group_id ) in
2575 ( select natural_account_id, account_group_id
2576 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC fika
2577 where cert.certification_id = p_certification_id
2578 and cert.statement_group_id = fika.statement_group_id
2579 and cert.financial_statement_id = fika.FINANCIAL_STATEMENT_ID
2580 )
2581 union
2582 select distinct acc.natural_account_id
2583 from amw_fin_key_accounts_b acc
2584 where ( acc.natural_account_id, acc.account_group_id ) in
2585 ( select natural_account_id, account_group_id
2586 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC fika
2587 where cert.certification_id = p_certification_id
2588 and cert.statement_group_id = fika.statement_group_id
2589 and cert.financial_statement_id = fika.FINANCIAL_STATEMENT_ID
2590 )
2591 )
2592
2593 AND po.organization_id = p_organization_id
2594 AND po2.process_id = hier.parent_child_id
2595 AND po2.organization_id = hier.organization_id
2596 AND ara.object_type = 'PROCESS_ORG'
2597 AND ara.pk1 = po2.process_organization_id
2598 AND aov.object_name = 'AMW_ORG_PROCESS_RISK'
2599 AND aov.opinion_type_code = 'EVALUATION'
2600 AND aov.pk3_value = po2.organization_id
2601 AND aov.pk4_value = po2.process_id
2602 AND aov.pk1_value = ara.risk_id
2603 AND aov.authored_date = (select max(aov2.authored_date)
2604 from AMW_OPINIONS_V aov2
2605 where aov2.object_opinion_type_id = aov.object_opinion_type_id
2606 and aov2.pk4_value = aov.pk4_value
2607 and aov2.pk3_value = aov.pk3_value
2608 and aov2.pk1_value = aov.pk1_value)
2609 AND aov.audit_result_code <> 'EFFECTIVE';
2610
2611 CURSOR total_risks IS
2612 SELECT count(distinct ara.risk_association_id)
2613 FROM AMW_ACCT_ASSOCIATIONS aa,
2614 AMW_PROCESS_ORGANIZATION po,
2615 (select process_id, organization_id, parent_child_id, up_down_ind
2616 from Amw_Org_Hierarchy_Denorm hier
2617 union select process_id, organization_id, process_id, 'D'
2618 from amw_process_organization) hier,
2619 AMW_PROCESS_ORGANIZATION po2,
2620 AMW_RISK_ASSOCIATIONS ara
2621 WHERE aa.object_type = 'PROCESS_ORG'
2622 AND po.process_organization_id = aa.pk1
2623 AND hier.organization_id = po.organization_id
2624 AND hier.process_id = po.process_id
2625 AND hier.up_down_ind = 'D'
2626 AND aa.natural_account_id in
2627 -- (select acc.natural_account_id
2628 -- from AMW_FIN_KEY_ACCOUNTS_B acc
2629 -- START WITH ((acc.natural_account_id, acc.account_group_id) in
2630 -- (select fika.natural_account_id, fika.account_group_id
2631 -- from AMW_FIN_ITEMS_KEY_ACC fika,
2632 -- AMW_CERTIFICATION_B cert
2633 -- where fika.statement_group_id = cert.statement_group_id
2634 -- AND fika.financial_statement_id = cert.financial_statement_id
2635 -- AND cert.certification_id = p_certification_id))
2636 -- CONNECT BY PRIOR acc.natural_account_id = acc.parent_natural_account_id
2637 -- and PRIOR acc.account_group_id = acc.account_group_id)
2638
2639 ( select distinct acc.child_natural_account_id
2640 from amw_fin_key_acct_flat acc
2641 where ( acc.parent_natural_account_id, acc.account_group_id ) in
2642 ( select natural_account_id, account_group_id
2643 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC fika
2644 where cert.certification_id = p_certification_id
2645 and cert.statement_group_id = fika.statement_group_id
2646 and cert.financial_statement_id = fika.FINANCIAL_STATEMENT_ID
2647 )
2648 union
2649 select distinct acc.natural_account_id
2650 from amw_fin_key_accounts_b acc
2651 where ( acc.natural_account_id, acc.account_group_id ) in
2652 ( select natural_account_id, account_group_id
2653 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC fika
2654 where cert.certification_id = p_certification_id
2655 and cert.statement_group_id = fika.statement_group_id
2656 and cert.financial_statement_id = fika.FINANCIAL_STATEMENT_ID
2657 )
2658 )
2659
2660 AND po.organization_id = p_organization_id
2661 AND po2.process_id = hier.parent_child_id
2662 AND po2.organization_id = hier.organization_id
2663 AND ara.object_type = 'PROCESS_ORG'
2664 AND ara.pk1 = po2.process_organization_id;
2665
2666
2667 CURSOR ineffective_controls IS
2668 SELECT count(distinct aca.control_id)
2669 FROM AMW_ACCT_ASSOCIATIONS aa,
2670 AMW_PROCESS_ORGANIZATION po,
2671 (select process_id, organization_id, parent_child_id, up_down_ind
2672 from Amw_Org_Hierarchy_Denorm hier
2673 union select process_id, organization_id, process_id, 'D'
2674 from amw_process_organization) hier,
2675 AMW_PROCESS_ORGANIZATION po2,
2676 AMW_RISK_ASSOCIATIONS ara,
2677 AMW_CONTROL_ASSOCIATIONS aca ,
2678 AMW_OPINIONS_V aov
2679 WHERE aa.object_type = 'PROCESS_ORG'
2680 AND po.process_organization_id = aa.pk1
2681 AND hier.organization_id = po.organization_id
2682 AND hier.process_id = po.process_id
2683 AND hier.up_down_ind = 'D'
2684 AND aa.natural_account_id in
2685
2686 -- (select acc.natural_account_id
2687 -- from AMW_FIN_KEY_ACCOUNTS_B acc
2688 -- START WITH ((acc.natural_account_id, acc.account_group_id) in
2689 -- (select fika.natural_account_id, fika.account_group_id
2690 -- from AMW_FIN_ITEMS_KEY_ACC fika,
2691 -- AMW_CERTIFICATION_B cert
2692 -- where fika.statement_group_id = cert.statement_group_id
2693 -- AND fika.financial_statement_id = cert.financial_statement_id
2694 -- AND cert.certification_id = p_certification_id))
2695 -- CONNECT BY PRIOR acc.natural_account_id = acc.parent_natural_account_id
2696 -- and PRIOR acc.account_group_id = acc.account_group_id)
2697
2698 ( select distinct acc.child_natural_account_id
2699 from amw_fin_key_acct_flat acc
2700 where ( acc.parent_natural_account_id, acc.account_group_id ) in
2701 ( select natural_account_id, account_group_id
2702 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC fika
2703 where cert.certification_id = p_certification_id
2704 and cert.statement_group_id = fika.statement_group_id
2705 and cert.financial_statement_id = fika.FINANCIAL_STATEMENT_ID
2706 )
2707 union
2708 select distinct acc.natural_account_id
2709 from amw_fin_key_accounts_b acc
2710 where ( acc.natural_account_id, acc.account_group_id ) in
2711 ( select natural_account_id, account_group_id
2712 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC fika
2713 where cert.certification_id = p_certification_id
2714 and cert.statement_group_id = fika.statement_group_id
2715 and cert.financial_statement_id = fika.FINANCIAL_STATEMENT_ID
2716 )
2717 )
2718
2719 AND po.organization_id = p_organization_id
2720 AND po2.process_id = hier.parent_child_id
2721 AND po2.organization_id = hier.organization_id
2722 AND ara.object_type = 'PROCESS_ORG'
2723 AND ara.pk1 = po2.process_organization_id
2724 AND aca.object_type = 'RISK_ORG'
2725 AND aca.pk1 = ara.risk_association_id
2726 AND aov.object_name = 'AMW_ORG_CONTROL'
2727 AND aov.opinion_type_code = 'EVALUATION'
2728 AND aov.pk3_value = po2.organization_id
2729 AND aov.pk1_value = aca.control_id
2730 AND aov.authored_date = (select max(aov2.authored_date)
2731 from AMW_OPINIONS_V aov2
2732 where aov2.object_opinion_type_id = aov.object_opinion_type_id
2733 and aov2.pk3_value = aov.pk3_value
2734 and aov2.pk1_value = aov.pk1_value)
2735 AND aov.audit_result_code <> 'EFFECTIVE';
2736
2737
2738 CURSOR total_controls IS
2739 SELECT count(distinct aca.control_id)
2740 FROM AMW_ACCT_ASSOCIATIONS aa,
2741 AMW_PROCESS_ORGANIZATION po,
2742 (select process_id, organization_id, parent_child_id, up_down_ind
2743 from Amw_Org_Hierarchy_Denorm hier
2744 union select process_id, organization_id, process_id, 'D'
2745 from amw_process_organization) hier,
2746 AMW_PROCESS_ORGANIZATION po2,
2747 AMW_RISK_ASSOCIATIONS ara,
2748 AMW_CONTROL_ASSOCIATIONS aca
2749 WHERE aa.object_type = 'PROCESS_ORG'
2750 AND po.process_organization_id = aa.pk1
2751 AND hier.organization_id = po.organization_id
2752 AND hier.process_id = po.process_id
2753 AND hier.up_down_ind = 'D'
2754 AND aa.natural_account_id in
2755 -- (select acc.natural_account_id
2756 -- from AMW_FIN_KEY_ACCOUNTS_B acc
2757 -- START WITH ((acc.natural_account_id, acc.account_group_id) in
2758 -- (select fika.natural_account_id, fika.account_group_id
2759 -- from AMW_FIN_ITEMS_KEY_ACC fika,
2760 -- AMW_CERTIFICATION_B cert
2761 -- where fika.statement_group_id = cert.statement_group_id
2762 -- AND fika.financial_statement_id = cert.financial_statement_id
2763 -- AND cert.certification_id = p_certification_id))
2764 -- CONNECT BY PRIOR acc.natural_account_id = acc.parent_natural_account_id
2765 -- and PRIOR acc.account_group_id = acc.account_group_id)
2766
2767 ( select distinct acc.child_natural_account_id
2768 from amw_fin_key_acct_flat acc
2769 where ( acc.parent_natural_account_id, acc.account_group_id ) in
2770 ( select natural_account_id, account_group_id
2771 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC fika
2772 where cert.certification_id = p_certification_id
2773 and cert.statement_group_id = fika.statement_group_id
2774 and cert.financial_statement_id = fika.FINANCIAL_STATEMENT_ID
2775 )
2776 union
2777 select distinct acc.natural_account_id
2778 from amw_fin_key_accounts_b acc
2779 where ( acc.natural_account_id, acc.account_group_id ) in
2780 ( select natural_account_id, account_group_id
2781 from amw_certification_b cert, AMW_FIN_ITEMS_KEY_ACC fika
2782 where cert.certification_id = p_certification_id
2783 and cert.statement_group_id = fika.statement_group_id
2784 and cert.financial_statement_id = fika.FINANCIAL_STATEMENT_ID
2785 )
2786 )
2787
2788 AND po.organization_id = p_organization_id
2789 AND po2.process_id = hier.parent_child_id
2790 AND po2.organization_id = hier.organization_id
2791 AND ara.object_type = 'PROCESS_ORG'
2792 AND ara.pk1 = po2.process_organization_id
2793 AND aca.object_type = 'RISK_ORG'
2794 AND aca.pk1 = ara.risk_association_id;
2795
2796 CURSOR c_org IS
2797 SELECT subsidiary_valueset, company_code, lob_valueset, lob_code
2798 FROM amw_audit_units_v
2799 WHERE organization_id = p_organization_id;
2800
2801 l_eval_opinion_id NUMBER;
2802 l_proc_pending_cert NUMBER;
2803 l_total_num_of_procs NUMBER;
2804 l_proc_with_issue NUMBER;
2805 l_proc_without_issue NUMBER;
2806 l_proc_certified NUMBER;
2807 l_proc_with_ineff_ctrl NUMBER;
2808 l_unmitigated_risks NUMBER;
2809 l_risks NUMBER;
2810 l_ineff_controls NUMBER;
2811 l_controls NUMBER;
2812 l_open_findings NUMBER;
2813 l_sub_vs VARCHAR2(150);
2814 l_lob_vs VARCHAR2(150);
2815 l_sub_code VARCHAR2(150);
2816 l_lob_code VARCHAR2(150);
2817 BEGIN
2818
2819 fnd_file.put_line (fnd_file.LOG, 'p_certification_id='||to_char(p_certification_id));
2820 fnd_file.put_line(fnd_file.LOG, 'p_organization_id='||to_char(p_organization_id));
2821 fnd_file.put_line(fnd_file.LOG, 'before last_evaludation:'||to_char(sysdate, 'hh:mi:ss dd-mon-rrrr'));
2822
2823 OPEN last_evaluation;
2824 FETCH last_evaluation INTO l_eval_opinion_id;
2825 CLOSE last_evaluation;
2826 fnd_file.put_line(fnd_file.LOG, 'after last_evaludation:'||to_char(sysdate, 'hh:mi:ss dd-mon-rrrr'));
2827
2828 /*
2829 OPEN proc_pending_cert;
2830 FETCH proc_pending_cert INTO l_proc_pending_cert;
2831 CLOSE proc_pending_cert;
2832 fnd_file.put_line(fnd_file.LOG, 'after proc_pending_cert:'||to_char(sysdate, 'hh:mi:ss dd-mon-rrrr'));
2833 */
2834
2835 OPEN total_num_of_proc;
2836 FETCH total_num_of_proc INTO l_total_num_of_procs;
2837 CLOSE total_num_of_proc;
2838 fnd_file.put_line(fnd_file.LOG, 'after total_num_of_proc:'||to_char(sysdate, 'hh:mi:ss dd-mon-rrrr'));
2839
2840 OPEN proc_with_issue;
2841 FETCH proc_with_issue INTO l_proc_with_issue;
2842 CLOSE proc_with_issue;
2843 fnd_file.put_line(fnd_file.LOG, 'after proc_with_issue:'||to_char(sysdate, 'hh:mi:ss dd-mon-rrrr'));
2844
2845 OPEN proc_without_issue;
2846 FETCH proc_without_issue INTO l_proc_without_issue;
2847 CLOSE proc_without_issue;
2848 fnd_file.put_line(fnd_file.LOG, 'after proc_without_issue:'||to_char(sysdate, 'hh:mi:ss dd-mon-rrrr'));
2849
2850 l_proc_certified := l_proc_with_issue+l_proc_without_issue;
2851 l_proc_pending_cert := l_total_num_of_procs-l_proc_certified;
2852
2853 OPEN proc_with_ineff_ctrl;
2854 FETCH proc_with_ineff_ctrl INTO l_proc_with_ineff_ctrl;
2855 CLOSE proc_with_ineff_ctrl;
2856 fnd_file.put_line(fnd_file.LOG, 'after proc_with_ineff_ctrl:'||to_char(sysdate, 'hh:mi:ss dd-mon-rrrr'));
2857
2858 OPEN unmitigated_risks;
2859 FETCH unmitigated_risks INTO l_unmitigated_risks;
2860 CLOSE unmitigated_risks;
2861 fnd_file.put_line(fnd_file.LOG, 'after unmitigated:'||to_char(sysdate, 'hh:mi:ss dd-mon-rrrr'));
2862
2863 OPEN total_risks;
2864 FETCH total_risks INTO l_risks;
2865 CLOSE total_risks;
2866 fnd_file.put_line(fnd_file.LOG, 'after total_risks:'||to_char(sysdate, 'hh:mi:ss dd-mon-rrrr'));
2867
2868 OPEN ineffective_controls;
2869 FETCH ineffective_controls INTO l_ineff_controls;
2870 CLOSE ineffective_controls;
2871 fnd_file.put_line(fnd_file.LOG, 'after ineffective_controls:'||to_char(sysdate, 'hh:mi:ss dd-mon-rrrr'));
2872
2873 OPEN total_controls;
2874 FETCH total_controls INTO l_controls;
2875 CLOSE total_controls;
2876 fnd_file.put_line(fnd_file.LOG, 'after total_controls:'||to_char(sysdate, 'hh:mi:ss dd-mon-rrrr'));
2877
2878 OPEN c_org;
2879 FETCH c_org INTO l_sub_vs, l_sub_code, l_lob_vs, l_lob_code;
2880 CLOSE c_org;
2881 fnd_file.put_line(fnd_file.LOG, 'after c_org:'||to_char(sysdate, 'hh:mi:ss dd-mon-rrrr'));
2882
2883 BEGIN
2884 l_open_findings := amw_findings_pkg.calculate_open_findings (
2885 'AMW_PROJ_FINDING',
2886 'PROJ_ORG', p_organization_id,
2887 null, null,
2888 null, null,
2889 null, null,
2890 null, null );
2891 EXCEPTION
2892 WHEN OTHERS THEN
2893 null;
2894 END;
2895 fnd_file.put_line(fnd_file.LOG, 'after open_findings:'||to_char(sysdate, 'hh:mi:ss dd-mon-rrrr'));
2896
2897 UPDATE AMW_FIN_ORG_EVAL_SUM
2898 SET EVAL_OPINION_ID = l_eval_opinion_id,
2899 PROC_PENDING_CERTIFICATION = l_proc_pending_cert,
2900 TOTAL_NUMBER_OF_PROCS = l_total_num_of_procs,
2901 PROC_CERTIFIED_WITH_ISSUES = l_proc_with_issue,
2902 PROC_VERIFIED = l_proc_certified,
2903 PROC_WITH_INEFFECTIVE_CONTROLS = l_proc_with_ineff_ctrl,
2904 UNMITIGATED_RISKS = l_unmitigated_risks,
2905 RISKS_VERIFIED = l_risks,
2906 INEFFECTIVE_CONTROLS = l_ineff_controls,
2907 CONTROLS_VERIFIED = l_controls,
2908 PROC_PENDING_CERT_PRCNT =
2909 round(l_proc_pending_cert/decode(l_total_num_of_procs, 0,1,l_total_num_of_procs),2)*100,
2910 PROCESSES_WITH_ISSUES_PRCNT =
2911 round(l_proc_with_issue/decode(l_total_num_of_procs, 0,1,l_total_num_of_procs),2)*100,
2912 PROC_WITH_INEFF_CONTROLS_PRCNT =
2913 round(l_proc_with_ineff_ctrl/decode(l_total_num_of_procs, 0,1,l_total_num_of_procs),2)*100,
2914 UNMITIGATED_RISKS_PRCNT = round(l_unmitigated_risks/decode(l_risks,0,1,l_risks), 2)*100,
2915 INEFFECTIVE_CONTROLS_PRCNT = round(l_ineff_controls/decode(l_controls,0,1,l_controls), 2)*100,
2916 OPEN_FINDINGS = l_open_findings,
2917 LAST_UPDATE_DATE = sysdate,
2918 LAST_UPDATED_BY = FND_GLOBAL.USER_ID,
2919 LAST_UPDATE_LOGIN = FND_GLOBAL.USER_ID,
2920 OBJECT_VERSION_NUMBER = OBJECT_VERSION_NUMBER+1,
2921 SUBSIDIARY_VS = l_sub_vs,
2922 SUBSIDIARY_CODE = l_sub_code,
2923 LOB_VS = l_lob_vs,
2924 LOB_CODE = l_lob_code
2925 WHERE fin_certification_id = p_certification_id
2926 AND organization_id = p_organization_id;
2927
2928
2929
2930 IF (SQL%NOTFOUND) THEN
2931 INSERT INTO AMW_FIN_ORG_EVAL_SUM(
2932 FIN_CERTIFICATION_ID,
2933 ORGANIZATION_ID,
2934 EVAL_OPINION_ID,
2935 PROC_PENDING_CERTIFICATION,
2936 TOTAL_NUMBER_OF_PROCS,
2937 PROC_CERTIFIED_WITH_ISSUES,
2938 PROC_VERIFIED,
2939 PROC_WITH_INEFFECTIVE_CONTROLS,
2940 UNMITIGATED_RISKS,
2941 RISKS_VERIFIED,
2942 INEFFECTIVE_CONTROLS,
2943 CONTROLS_VERIFIED,
2944 PROC_PENDING_CERT_PRCNT,
2945 PROCESSES_WITH_ISSUES_PRCNT,
2946 PROC_WITH_INEFF_CONTROLS_PRCNT,
2947 UNMITIGATED_RISKS_PRCNT,
2948 INEFFECTIVE_CONTROLS_PRCNT,
2949 OPEN_FINDINGS,
2950 CREATED_BY,
2951 CREATION_DATE,
2952 LAST_UPDATED_BY,
2953 LAST_UPDATE_DATE,
2954 LAST_UPDATE_LOGIN,
2955 OBJECT_VERSION_NUMBER,
2956 SUBSIDIARY_VS,
2957 SUBSIDIARY_CODE,
2958 LOB_VS,
2959 LOB_CODE)
2960 SELECT p_certification_id,
2961 p_organization_id,
2962 l_eval_opinion_id,
2963 l_proc_pending_cert,
2964 l_total_num_of_procs,
2965 l_proc_with_issue,
2966 l_proc_certified,
2967 l_proc_with_ineff_ctrl,
2968 l_unmitigated_risks,
2969 l_risks,
2970 l_ineff_controls,
2971 l_controls,
2972 round(l_proc_pending_cert/decode(l_total_num_of_procs, 0,1,l_total_num_of_procs),2)*100,
2973 round(l_proc_with_issue/decode(l_total_num_of_procs, 0,1,l_total_num_of_procs),2)*100,
2974 round(l_proc_with_ineff_ctrl/decode(l_total_num_of_procs, 0,1,l_total_num_of_procs),2)*100,
2975 round(l_unmitigated_risks/decode(l_risks,0,1,l_risks), 2)*100,
2976 round(l_ineff_controls/decode(l_controls,0,1,l_controls), 2)*100,
2977 l_open_findings,
2978 FND_GLOBAL.USER_ID,
2979 SYSDATE,
2980 FND_GLOBAL.USER_ID,
2981 SYSDATE,
2982 FND_GLOBAL.USER_ID,
2983 1,
2984 l_sub_vs,
2985 l_sub_code,
2986 l_lob_vs,
2987 l_lob_code
2988 FROM DUAL;
2989 END IF;
2990
2991 commit;
2992 EXCEPTION WHEN OTHERS THEN
2993 fnd_file.put_line (fnd_file.LOG, SUBSTR ('Unexpected Error in Populate_Fin_Org_Eval_Sum'
2994 || SUBSTR (SQLERRM, 1, 100), 1, 200));
2995 END Populate_Fin_Org_Eval_Sum;
2996
2997
2998
2999 /*********************OBSOLATED. USED IN CONCURRENT PROGRAM BEFORE BES AMW.D ******************
3000 PROCEDURE Populate_All_Fin_Org_Eval_Sum(
3001 errbuf OUT NOCOPY VARCHAR2,
3002 retcode OUT NOCOPY VARCHAR2,
3003 p_certification_id IN NUMBER
3004 )
3005 IS
3006
3007 CURSOR c_cert IS
3008 SELECT cert.certification_id, period.start_date, period.end_date
3009 FROM AMW_CERTIFICATION_B cert,
3010 AMW_GL_PERIODS_V period
3011 WHERE cert.certification_period_name = period.period_name
3012 AND cert.certification_period_set_name = period.period_set_name
3013 AND cert.object_type='FIN_STMT'
3014 AND cert.certification_status in ('ACTIVE','DRAFT');
3015
3016
3017 CURSOR c_period_date IS
3018 SELECT period.start_date, period.end_date
3019 FROM AMW_CERTIFICATION_B cert,
3020 AMW_GL_PERIODS_V period
3021 WHERE cert.certification_period_name = period.period_name
3022 AND cert.certification_period_set_name = period.period_set_name
3023 AND cert.certification_id = p_certification_id;
3024
3025 -- select all the processes based on the certification_id
3026 CURSOR c_org(p_cert_id NUMBER) IS
3027 SELECT distinct po.organization_id
3028 FROM AMW_ACCT_ASSOCIATIONS aa,
3029 AMW_FIN_ITEMS_KEY_ACC fika,
3030 AMW_PROCESS_ORGANIZATION po,
3031 AMW_CERTIFICATION_B cert
3032 WHERE aa.object_type = 'PROCESS_ORG'
3033 AND aa.pk1 = po.process_organization_id
3034 AND aa.natural_account_id in
3035
3036 -- (select acc.natural_account_id
3037 -- from AMW_FIN_KEY_ACCOUNTS_B acc
3038 -- START WITH acc.natural_account_id = fika.natural_account_id
3039 -- and acc.account_group_id = fika.account_group_id
3040 -- CONNECT BY PRIOR acc.natural_account_id = acc.parent_natural_account_id
3041 -- and PRIOR acc.account_group_id = acc.account_group_id)
3042
3043 ( select distinct acc.child_natural_account_id
3044 from AMW_FIN_KEY_ACCT_FLAT acc
3045 where acc.parent_natural_account_id = fika.natural_account_id
3046 and acc.account_group_id = fika.account_group_id
3047 union
3048 select distinct acc.natural_account_id
3049 from amw_fin_key_accounts_b acc
3050 where acc.natural_account_id = fika.natural_account_id
3051 and acc.account_group_id = fika.account_group_id
3052 )
3053
3054 AND fika.statement_group_id = cert.statement_group_id
3055 AND fika.financial_statement_id = cert.financial_statement_id
3056 AND cert.certification_id = p_cert_id;
3057
3058 l_start_date DATE;
3059 l_end_date DATE;
3060
3061 BEGIN
3062 fnd_file.put_line (fnd_file.LOG, 'Certification_Id:'||p_certification_id);
3063
3064 IF p_certification_id IS NOT NULL THEN
3065 OPEN c_period_date;
3066 FETCH c_period_date INTO l_start_date, l_end_date;
3067 CLOSE c_period_date;
3068
3069 DELETE from AMW_FIN_ORG_EVAL_SUM orgevalsum
3070 where FIN_CERTIFICATION_ID = p_certification_id
3071 and not exists
3072 (SELECT 'Y'
3073 FROM AMW_ACCT_ASSOCIATIONS aa,
3074 AMW_FIN_ITEMS_KEY_ACC fika,
3075 AMW_PROCESS_ORGANIZATION po,
3076 AMW_CERTIFICATION_B cert
3077 WHERE aa.object_type = 'PROCESS_ORG'
3078 AND aa.pk1 = po.process_organization_id
3079 AND aa.natural_account_id in
3080
3081 -- (select acc.natural_account_id
3082 -- from AMW_FIN_KEY_ACCOUNTS_B acc
3083 -- START WITH acc.natural_account_id = fika.natural_account_id
3084 -- and acc.account_group_id = fika.account_group_id
3085 -- CONNECT BY PRIOR acc.natural_account_id = acc.parent_natural_account_id
3086 -- and PRIOR acc.account_group_id = acc.account_group_id)
3087
3088 ( select distinct acc.child_natural_account_id
3089 from AMW_FIN_KEY_ACCT_FLAT acc
3090 where acc.parent_natural_account_id = fika.natural_account_id
3091 and acc.account_group_id = fika.account_group_id
3092 union
3093 select distinct acc.natural_account_id
3094 from amw_fin_key_accounts_b acc
3095 where acc.natural_account_id = fika.natural_account_id
3096 and acc.account_group_id = fika.account_group_id
3097 )
3098 AND fika.statement_group_id = cert.statement_group_id
3099 AND fika.financial_statement_id = cert.financial_statement_id
3100 AND cert.certification_id = p_certification_id
3101 AND po.organization_id = orgevalsum.organization_id);
3102
3103 FOR org_rec IN c_org(p_certification_id) LOOP
3104 Populate_Fin_Org_Eval_Sum(p_certification_id, l_start_date,
3105 l_end_date, org_rec.organization_id);
3106 END LOOP;
3107 ELSE
3108 DELETE from AMW_FIN_ORG_EVAL_SUM orgevalsum
3109 where not exists
3110 (SELECT 'Y'
3111 FROM AMW_ACCT_ASSOCIATIONS aa,
3112 AMW_FIN_ITEMS_KEY_ACC fika,
3113 AMW_PROCESS_ORGANIZATION po,
3114 AMW_CERTIFICATION_B cert
3115 WHERE aa.object_type = 'PROCESS_ORG'
3116 AND aa.pk1 = po.process_organization_id
3117 AND aa.natural_account_id = fika.natural_account_id
3118 AND fika.statement_group_id = cert.statement_group_id
3119 AND fika.financial_statement_id = cert.financial_statement_id
3120 AND cert.certification_status in ('ACTIVE','DRAFT')
3121 AND cert.certification_id = orgevalsum.fin_certification_id
3122 AND po.organization_id = orgevalsum.organization_id);
3123
3124 FOR cert_rec IN c_cert LOOP
3125 FOR org_rec IN c_org(cert_rec.certification_id) LOOP
3126 Populate_Fin_Org_Eval_Sum(cert_rec.certification_id,
3127 cert_rec.start_date, cert_rec.end_date, org_rec.organization_id);
3128 END LOOP;
3129 END LOOP;
3130 END IF;
3131
3132 EXCEPTION
3133 WHEN OTHERS THEN
3134 fnd_file.put_line (fnd_file.LOG, SUBSTR ('Unexpected Error in Populate_All_Fin_Org_Eval_Sum'
3135 || SUBSTR (SQLERRM, 1, 100), 1, 200));
3136 errbuf := SQLERRM;
3137 retcode := FND_API.G_RET_STS_UNEXP_ERROR;
3138 END Populate_All_Fin_Org_Eval_Sum;
3139
3140 ********************************************/
3141
3142
3143 /**************************************OBSOLATED. USED IN THE CONCURRENT PROGRAM BEFORE BES AMW.D *******/
3144 /*****----------- Code Added by Krishnan --------------------------------------------------------
3145 PROCEDURE build_amw_fin_cert_eval_sum(errbuf OUT NOCOPY VARCHAR2,retcode OUT NOCOPY VARCHAR2, P_CERTIFICATION_ID in number)
3146 is
3147 begin
3148 declare
3149
3150 M_CERTIFICATION_ID NUMBER := 0;
3151 M_FINANCIAL_STATEMENT_ID NUMBER := 0;
3152 M_STATEMENT_GROUP_ID NUMBER := 0;
3153 M_OBJECT_TYPE varchar2(25) := null;
3154 param_cert_id number := P_CERTIFICATION_ID ;
3155
3156 M_START_DATE DATE;
3157 M_END_DATE DATE;
3158
3159 -- variables for totals
3160 M_PROC_PENDING_CERTIFICATION number :=0;
3161 M_TOTAL_NUMBER_OF_PROCESSES number :=0;
3162 M_PROC_CERTIFIED_WITH_ISSUES number :=0;
3163 M_PROC_VERIFIED number :=0;
3164 M_org_with_ineffective_ctrls number :=0;
3165 M_org_certified number :=0;
3166 M_proc_with_ineffective_ctrls number :=0;
3167 M_unmitigated_risks number :=0;
3168 M_risks_verified number :=0;
3169 M_ineffective_controls number :=0;
3170 M_controls_verified number :=0;
3171 M_open_issues number :=0;
3172 M_PRO_PENDING_CERT_PRCNT number :=0;
3173 M_PROCESSES_WITH_ISSUES_PRCNT number :=0;
3174 M_ORG_WITH_INEFF_CTRLS_PRCNT number :=0;
3175 M_PROC_WITH_INEFF_CTRLS_PRCNT number :=0;
3176 M_UNMITIGATED_RISKS_PRCNT number :=0;
3177 M_INEFFECTIVE_CONTROLS_PRCNT number :=0;
3178 M_PROCS_FOR_CERT_DONE number :=0;
3179 m_org_evaluated number :=0;
3180 T_PROC_PENDING_CERTIFICATION number :=0;
3181 T_TOTAL_NUMBER_OF_PROCESSES number :=0;
3182 T_PROC_CERTIFIED_WITH_ISSUES number :=0;
3183 T_PROC_VERIFIED number :=0;
3184 T_org_with_ineffective_ctrls number :=0;
3185 T_org_certified number :=0;
3186 T_proc_with_ineffective_ctrls number :=0;
3187 T_unmitigated_risks number :=0;
3188 T_risks_verified number :=0;
3189 T_ineffective_controls number :=0;
3190 T_controls_verified number :=0;
3191 T_open_issues number :=0;
3192 T_PRO_PENDING_CERT_PRCNT number :=0;
3193 T_PROCESSES_WITH_ISSUES_PRCNT number :=0;
3194 T_ORG_WITH_INEFF_CTRLS_PRCNT number :=0;
3195 T_PROC_WITH_INEFF_CTRLS_PRCNT number :=0;
3196 T_UNMITIGATED_RISKS_PRCNT number :=0;
3197 T_INEFFECTIVE_CONTROLS_PRCNT number :=0;
3198
3199
3200
3201
3202 cursor Get_Cert_for_processing
3203 is
3204 select
3205 certifcationVL.CERTIFICATION_ID ,
3206 certifcationVL.FINANCIAL_STATEMENT_ID,
3207 certifcationVL.STATEMENT_GROUP_ID
3208 FROM
3209 AMW_CERTIFICATION_vl certifcationVL
3210 where
3211 certifcationVL.OBJECT_TYPE='FIN_STMT'
3212 and certifcationVL.CERTIFICATION_STATUS in ('ACTIVE', 'DRAFT');
3213
3214 cursor Get_Only_One_Cert
3215 is
3216 select
3217 certifcationVL.CERTIFICATION_ID ,
3218 certifcationVL.FINANCIAL_STATEMENT_ID,
3219 certifcationVL.STATEMENT_GROUP_ID
3220 FROM
3221 AMW_CERTIFICATION_vl certifcationVL
3222 where
3223 certifcationVL.OBJECT_TYPE='FIN_STMT'
3224 and certifcationVL.CERTIFICATION_ID = P_CERTIFICATION_ID;
3225
3226
3227 begin
3228
3229 g_errbuf := null;
3230 g_retcode := '0';
3231
3232 reset_amw_fin_cert_eval_sum(p_certification_id => param_cert_id ); -- reset all existing computed values to 0
3233
3234
3235 if P_CERTIFICATION_ID is null then
3236 for certifications in Get_Cert_for_processing
3237 loop
3238
3239 exit when Get_Cert_for_processing%notfound;
3240
3241 M_CERTIFICATION_ID := certifications.CERTIFICATION_ID ;
3242 M_FINANCIAL_STATEMENT_ID := certifications.FINANCIAL_STATEMENT_ID;
3243 M_STATEMENT_GROUP_ID := certifications.STATEMENT_GROUP_ID;
3244 M_OBJECT_TYPE := 'FINANCIAL STATEMENT';
3245
3246 AMW_FINSTMT_CERT_PVT.GetGLPeriodfor_FinCertEvalSum(
3247 P_Certification_ID => M_CERTIFICATION_ID ,
3248 P_start_date => M_START_DATE,
3249 P_end_date => M_END_DATE);
3250
3251
3252 AMW_FINSTMT_CERT_PVT.compute_values_for_eval_sum
3253 (P_CERTIFICATION_ID => M_CERTIFICATION_ID,
3254 P_FINANCIAL_STATEMENT_ID => M_FINANCIAL_STATEMENT_ID ,
3255 P_STATEMENT_GROUP_ID => M_STATEMENT_GROUP_ID ,
3256 -- P_PARENT_FIN_ITEM_ID => null,
3257 P_ACCOUNT_ID => null,
3258 P_ACCOUNT_GROUP_ID => null,
3259 P_FINANCIAL_ITEM_ID => null,
3260 P_OBJECT_TYPE => 'FINANCIAL STATEMENT',
3261 P_PROC_PENDING_CERTIFICATION =>
3262 M_PROC_PENDING_CERTIFICATION ,
3263 P_TOTAL_NUMBER_OF_PROCESSES =>
3264 M_TOTAL_NUMBER_OF_PROCESSES ,
3265 P_PROC_CERTIFIED_WITH_ISSUES =>
3266 M_PROC_CERTIFIED_WITH_ISSUES ,
3267 P_PROC_VERIFIED =>
3268 M_PROC_VERIFIED ,
3269 P_org_with_ineffective_ctrls =>
3270 M_org_with_ineffective_ctrls ,
3271 P_org_certified =>
3272 M_org_certified ,
3273 P_proc_with_ineffective_ctrls =>
3274 M_proc_with_ineffective_ctrls,
3275 P_unmitigated_risks =>
3276 M_unmitigated_risks ,
3277 P_risks_verified =>
3278 M_risks_verified ,
3279 P_ineffective_controls =>
3280 M_ineffective_controls ,
3281 P_controls_verified =>
3282 M_controls_verified ,
3283 P_open_issues =>
3284 M_open_issues ,
3285 P_PRO_PENDING_CERT_PRCNT =>
3286 M_PRO_PENDING_CERT_PRCNT ,
3287 P_PROCESSES_WITH_ISSUES_PRCNT =>
3288 M_PROCESSES_WITH_ISSUES_PRCNT,
3289 P_ORG_WITH_INEFF_CTRLS_PRCNT =>
3290 M_ORG_WITH_INEFF_CTRLS_PRCNT ,
3291 P_PROC_WITH_INEFF_CTRLS_PRCNT =>
3292 M_PROC_WITH_INEFF_CTRLS_PRCNT,
3293 P_UNMITIGATED_RISKS_PRCNT =>
3294 M_UNMITIGATED_RISKS_PRCNT ,
3295 P_INEFFECTIVE_CONTROLS_PRCNT =>
3296 M_INEFFECTIVE_CONTROLS_PRCNT,
3297 P_START_DATE => M_START_DATE ,
3298 P_END_DATE => M_END_DATE,
3299 p_PROCS_FOR_CERT_DONE => M_PROCS_FOR_CERT_DONE ,
3300 p_org_evaluated => M_org_evaluated );
3301
3302
3303 end loop; -- end of main loop
3304 else
3305 for certifications in Get_Only_One_Cert
3306 loop
3307
3308 exit when Get_Only_One_Cert%notfound;
3309
3310 M_CERTIFICATION_ID := certifications.CERTIFICATION_ID ;
3311 M_FINANCIAL_STATEMENT_ID := certifications.FINANCIAL_STATEMENT_ID;
3312 M_STATEMENT_GROUP_ID := certifications.STATEMENT_GROUP_ID;
3313 M_OBJECT_TYPE := 'FINANCIAL STATEMENT';
3314
3315 AMW_FINSTMT_CERT_PVT.GetGLPeriodfor_FinCertEvalSum(
3316 P_Certification_ID => M_CERTIFICATION_ID ,
3317 P_start_date => M_START_DATE,
3318 P_end_date => M_END_DATE);
3319
3320
3321
3322 AMW_FINSTMT_CERT_PVT.compute_values_for_eval_sum
3323 (P_CERTIFICATION_ID => M_CERTIFICATION_ID,
3324 P_FINANCIAL_STATEMENT_ID => M_FINANCIAL_STATEMENT_ID ,
3325 P_STATEMENT_GROUP_ID => M_STATEMENT_GROUP_ID ,
3326 -- P_PARENT_FIN_ITEM_ID => null,
3327 P_ACCOUNT_ID => null,
3328 P_ACCOUNT_GROUP_ID => null,
3329 P_FINANCIAL_ITEM_ID => null,
3330 P_OBJECT_TYPE => 'FINANCIAL STATEMENT',
3331 P_PROC_PENDING_CERTIFICATION =>
3332 M_PROC_PENDING_CERTIFICATION ,
3333 P_TOTAL_NUMBER_OF_PROCESSES =>
3334 M_TOTAL_NUMBER_OF_PROCESSES ,
3335 P_PROC_CERTIFIED_WITH_ISSUES =>
3336 M_PROC_CERTIFIED_WITH_ISSUES ,
3337 P_PROC_VERIFIED =>
3338 M_PROC_VERIFIED ,
3339 P_org_with_ineffective_ctrls =>
3340 M_org_with_ineffective_ctrls ,
3341 P_org_certified =>
3342 M_org_certified ,
3343 P_proc_with_ineffective_ctrls =>
3344 M_proc_with_ineffective_ctrls,
3345 P_unmitigated_risks =>
3346 M_unmitigated_risks ,
3347 P_risks_verified =>
3348 M_risks_verified ,
3349 P_ineffective_controls =>
3350 M_ineffective_controls ,
3351 P_controls_verified =>
3352 M_controls_verified ,
3353 P_open_issues =>
3354 M_open_issues ,
3355 P_PRO_PENDING_CERT_PRCNT =>
3356 M_PRO_PENDING_CERT_PRCNT ,
3357 P_PROCESSES_WITH_ISSUES_PRCNT =>
3358 M_PROCESSES_WITH_ISSUES_PRCNT,
3359 P_ORG_WITH_INEFF_CTRLS_PRCNT =>
3360 M_ORG_WITH_INEFF_CTRLS_PRCNT ,
3361 P_PROC_WITH_INEFF_CTRLS_PRCNT =>
3362 M_PROC_WITH_INEFF_CTRLS_PRCNT,
3363 P_UNMITIGATED_RISKS_PRCNT =>
3364 M_UNMITIGATED_RISKS_PRCNT ,
3365 P_INEFFECTIVE_CONTROLS_PRCNT =>
3366 M_INEFFECTIVE_CONTROLS_PRCNT,
3367 P_START_DATE => M_START_DATE ,
3368 P_END_DATE => M_END_DATE,
3369 p_PROCS_FOR_CERT_DONE => M_PROCS_FOR_CERT_DONE ,
3370 p_org_evaluated => M_org_evaluated );
3371
3372 end loop; -- end of main loop
3373
3374
3375 end if;
3376 end;
3377 errbuf := g_errbuf ;
3378 retcode := g_retcode;
3379
3380 END build_amw_fin_cert_eval_sum;
3381
3382 ****************************************/
3383
3384 ----------------------------- ********************************** ----------------------
3385 PROCEDURE reset_amw_fin_cert_eval_sum(p_certification_id in number)
3386 is
3387 begin
3388 if p_certification_id is not null then
3389 update amw_fin_cert_eval_sum
3390 set
3391 PROC_PENDING_CERTIFICATION = 0,
3392 TOTAL_NUMBER_OF_PROCESSES =0,
3393 PROC_CERTIFIED_WITH_ISSUES =0,
3394 --PROC_VERIFIED =0 ,
3395 PROCS_FOR_CERT_DONE =0 ,
3396 proc_evaluated =0 ,
3397 org_with_ineffective_controls =0,
3398 --org_certified =0,
3399 orgs_FOR_CERT_DONE =0,
3400 orgs_evaluated =0,
3401 proc_with_ineffective_controls =0,
3402 unmitigated_risks =0,
3403 risks_verified =0,
3404 ineffective_controls =0,
3405 controls_verified =0,
3406 open_issues =0,
3407 PRO_PENDING_CERT_PRCNT =0,
3408 PROCESSES_WITH_ISSUES_PRCNT =0,
3409 ORG_WITH_INEFF_CONTROLS_PRCNT =0,
3410 PROC_WITH_INEFF_CONTROLS_PRCNT =0,
3411 UNMITIGATED_RISKS_PRCNT =0,
3412 INEFFECTIVE_CONTROLS_PRCNT =0,
3413 total_number_of_risks = 0,
3414 total_number_of_ctrls = 0,
3415 total_number_of_orgs = 0
3416 WHERE fin_certification_id = p_certification_id;
3417 else
3418 update amw_fin_cert_eval_sum
3419 set
3420 PROC_PENDING_CERTIFICATION = 0,
3421 TOTAL_NUMBER_OF_PROCESSES =0,
3422 PROC_CERTIFIED_WITH_ISSUES =0,
3423 --PROC_VERIFIED =0 ,
3424 PROCS_FOR_CERT_DONE =0 ,
3425 proc_evaluated =0 ,
3426 org_with_ineffective_controls =0,
3427 -- org_certified =0,
3428 orgs_FOR_CERT_DONE =0,
3429 orgs_evaluated =0,
3430 proc_with_ineffective_controls =0,
3431 unmitigated_risks =0,
3432 risks_verified =0,
3433 ineffective_controls =0,
3434 controls_verified =0,
3435 open_issues =0,
3436 PRO_PENDING_CERT_PRCNT =0,
3437 PROCESSES_WITH_ISSUES_PRCNT =0,
3438 ORG_WITH_INEFF_CONTROLS_PRCNT =0,
3439 PROC_WITH_INEFF_CONTROLS_PRCNT =0,
3440 UNMITIGATED_RISKS_PRCNT =0,
3441 INEFFECTIVE_CONTROLS_PRCNT =0,
3442 total_number_of_risks = 0,
3443 total_number_of_ctrls = 0,
3444 total_number_of_orgs = 0
3445 WHERE fin_certification_id IN
3446 (select
3447 certifcationVL.CERTIFICATION_ID
3448 FROM AMW_CERTIFICATION_vl certifcationVL
3449 where
3450 certifcationVL.OBJECT_TYPE='FIN_STMT'
3451 and certifcationVL.CERTIFICATION_STATUS in ('ACTIVE', 'DRAFT'));
3452
3453 end if;
3454
3455 END reset_amw_fin_cert_eval_sum;
3456
3457 ----------------------------- ********************************** ----------------------
3458 Procedure compute_values_for_eval_sum(P_CERTIFICATION_ID IN NUMBER,
3459 P_FINANCIAL_STATEMENT_ID in number, P_STATEMENT_GROUP_ID in number,
3460 --P_PARENT_FIN_ITEM_ID NUMBER,
3461 P_ACCOUNT_ID in NUMBER, P_ACCOUNT_GROUP_ID in number, P_FINANCIAL_ITEM_ID in number,
3462 P_OBJECT_TYPE in varchar2 , P_PROC_PENDING_CERTIFICATION out NOCOPY number,
3463 P_TOTAL_NUMBER_OF_PROCESSES out NOCOPY number, P_PROC_CERTIFIED_WITH_ISSUES out NOCOPY number,
3464 P_PROC_VERIFIED out NOCOPY number, P_org_with_ineffective_ctrls out NOCOPY number,
3465 P_org_certified out NOCOPY number, P_proc_with_ineffective_ctrls out NOCOPY number,
3466 P_unmitigated_risks out NOCOPY number, P_risks_verified out NOCOPY number,
3467 P_ineffective_controls out NOCOPY number, P_controls_verified out NOCOPY number,
3468 P_open_issues out NOCOPY number, P_PRO_PENDING_CERT_PRCNT out NOCOPY number,
3469 P_PROCESSES_WITH_ISSUES_PRCNT out NOCOPY number, P_ORG_WITH_INEFF_CTRLS_PRCNT out NOCOPY number,
3470 P_PROC_WITH_INEFF_CTRLS_PRCNT out NOCOPY number, P_UNMITIGATED_RISKS_PRCNT out NOCOPY number,
3471 P_INEFFECTIVE_CONTROLS_PRCNT out NOCOPY number, P_START_DATE IN DATE ,
3472 P_END_DATE IN DATE, P_PROCS_FOR_CERT_DONE out NOCOPY NUMBER, p_org_evaluated out NOCOPY NUMBER) is
3473
3474
3475 /* P_FINANCIAL_STATEMENT_ID in number, P_STATEMENT_GROUP_ID in number,
3476 --P_PARENT_FIN_ITEM_ID NUMBER,
3477 P_ACCOUNT_ID in NUMBER, P_ACCOUNT_GROUP_ID in number, P_FINANCIAL_ITEM_ID in number,
3478 P_OBJECT_TYPE in varchar2 , P_PROC_PENDING_CERTIFICATION in out NOCOPY number,
3479 P_TOTAL_NUMBER_OF_PROCESSES in out NOCOPY number, P_PROC_CERTIFIED_WITH_ISSUES in out NOCOPY number,
3480 P_PROC_VERIFIED in out NOCOPY number, P_org_with_ineffective_ctrls in out NOCOPY number,
3481 P_org_certified in out NOCOPY number, P_proc_with_ineffective_ctrls in out NOCOPY number,
3482 P_unmitigated_risks in out NOCOPY number, P_risks_verified in out NOCOPY number,
3483 P_ineffective_controls in out NOCOPY number, P_controls_verified in out NOCOPY number,
3484 P_open_issues in out NOCOPY number, P_PRO_PENDING_CERT_PRCNT in out NOCOPY number,
3485 P_PROCESSES_WITH_ISSUES_PRCNT in out NOCOPY number, P_ORG_WITH_INEFF_CTRLS_PRCNT in out NOCOPY number,
3486 P_PROC_WITH_INEFF_CTRLS_PRCNT in out NOCOPY number, P_UNMITIGATED_RISKS_PRCNT in out NOCOPY number,
3487 P_INEFFECTIVE_CONTROLS_PRCNT in out NOCOPY number, P_START_DATE IN DATE ,
3488 P_END_DATE IN DATE, P_PROCS_FOR_CERT_DONE in out NUMBER, p_org_evaluated in out NUMBER) is*/
3489
3490 begin
3491 declare
3492
3493
3494 M_CERTIFICATION_ID NUMBER := 0;
3495 M_START_DATE DATE ;
3496 M_END_DATE DATE ;
3497
3498 M_FINANCIAL_STATEMENT_ID NUMBER := 0;
3499 M_STATEMENT_GROUP_ID NUMBER := 0;
3500 M_OBJECT_TYPE varchar2(25) := null;
3501 M_ACCOUNT_GROUP_ID NUMBER := 0;
3502 M_NATURAL_ACCOUNT_ID NUMBER := 0;
3503 M_NATURAL_ACCOUNT_ID_2 NUMBER := 0;
3504 M_FINANCIAL_ITEM_ID NUMBER := 0;
3505
3506 -- variables for totals
3507 M_PROC_PENDING_CERTIFICATION number :=0;
3508 M_TOTAL_NUMBER_OF_PROCESSES number :=0;
3509 M_PROC_CERTIFIED_WITH_ISSUES number :=0;
3510 M_PROC_VERIFIED number :=0;
3511 M_org_with_ineffective_ctrls number :=0;
3512 M_org_certified number :=0;
3513 M_proc_with_ineffective_ctrls number :=0;
3514 M_unmitigated_risks number :=0;
3515 M_risks_verified number :=0;
3516 M_ineffective_controls number :=0;
3517 M_controls_verified number :=0;
3518 M_open_issues number :=0;
3519
3520 M_PRO_PENDING_CERT_PRCNT number :=0;
3521 M_PROCESSES_WITH_ISSUES_PRCNT number :=0;
3522 M_ORG_WITH_INEFF_CTRLS_PRCNT number :=0;
3523 M_PROC_WITH_INEFF_CTRLS_PRCNT number :=0;
3524 M_UNMITIGATED_RISKS_PRCNT number :=0;
3525 M_INEFFECTIVE_CONTROLS_PRCNT number :=0;
3526 M_PROCS_FOR_CERT_DONE number :=0;
3527 M_org_evaluated number :=0;
3528
3529 T_PROC_PENDING_CERTIFICATION number :=0;
3530 T_TOTAL_NUMBER_OF_PROCESSES number :=0;
3531 T_PROC_CERTIFIED_WITH_ISSUES number :=0;
3532 T_PROC_VERIFIED number :=0;
3533 T_org_with_ineffective_ctrls number :=0;
3534 T_org_certified number :=0;
3535 T_proc_with_ineffective_ctrls number :=0;
3536 T_unmitigated_risks number :=0;
3537 T_risks_verified number :=0;
3538 T_ineffective_controls number :=0;
3539 T_controls_verified number :=0;
3540 T_open_issues number :=0;
3541 T_PRO_PENDING_CERT_PRCNT number :=0;
3542 T_PROCESSES_WITH_ISSUES_PRCNT number :=0;
3543 T_ORG_WITH_INEFF_CTRLS_PRCNT number :=0;
3544 T_PROC_WITH_INEFF_CTRLS_PRCNT number :=0;
3545 T_UNMITIGATED_RISKS_PRCNT number :=0;
3546 T_INEFFECTIVE_CONTROLS_PRCNT number :=0;
3547
3548
3549
3550 -- CURRSOR TO GET ONLY THE TOP LEVEL FINANCIAL ITEMS WHICH HAS NO PARENT
3551 cursor Get_toplevel_fin_items is
3552 select
3553 STATEMENT_GROUP_ID,
3554 FINANCIAL_STATEMENT_ID,
3555 FINANCIAL_ITEM_ID
3556 from
3557 AMW_FIN_STMNT_ITEMS_B
3558 where
3559 STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
3560 and FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
3561 and PARENT_FINANCIAL_ITEM_ID is null;
3562
3563 -- CURRSOR TO GET ONLY THE FINANCIAL ITEMS WHICH HAS A PARENT
3564
3565 cursor Get_child_fin_items
3566 --(PAR_PARENT_FIN_ITEM_ID NUMBER)
3567 is
3568 select
3569 STATEMENT_GROUP_ID,
3570 FINANCIAL_STATEMENT_ID,
3571 FINANCIAL_ITEM_ID,
3572 PARENT_FINANCIAL_ITEM_ID
3573 from
3574 AMW_FIN_STMNT_ITEMS_B
3575 where
3576 STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
3577 and FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
3578 and PARENT_FINANCIAL_ITEM_ID = P_FINANCIAL_ITEM_ID ;
3579
3580
3581 -- CURRSOR TO GET ONLY THE ACOUNTS THOSE ARE DIRECTLY ASSOCIATED TO A FINANCIAL ITEM
3582 -- The Accounts (which could be a Child of another account) whose parents are not linked to a financial item need to be selected
3583 -- Accounts (with a parent natural account) whose parents are attached to a financial items shoudl not be selected here
3584
3585 cursor Get_fin_accs is
3586 select
3587 STATEMENT_GROUP_ID,
3588 ACCOUNT_GROUP_ID,
3589 FINANCIAL_STATEMENT_ID,
3590 FINANCIAL_ITEM_ID,
3591 NATURAL_ACCOUNT_ID
3592 from
3593 AMW_FIN_ITEMS_KEY_ACC finitemAcc
3594 where
3595 STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
3596 and FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
3597 and FINANCIAL_ITEM_ID = P_FINANCIAL_ITEM_ID
3598 and not exists
3599 -- make sure that children accounts whose parents are also attached to a financial item are not selected
3600 -- again, as we will select them in next union
3601 (
3602 Select
3603 KeyAccChild2.ACCOUNT_GROUP_ID ,
3604 KeyAccChild2.NATURAL_ACCOUNT_ID,
3605 KeyAccChild2.PARENT_NATURAL_ACCOUNT_ID,
3606 KeyAccChild2.NATURAL_ACCOUNT_VALUE
3607 From
3608 AMW_FIN_KEY_ACCOUNTS_B KeyAccChild2,
3609 AMW_FIN_ITEMS_KEY_ACC finitemAcc2
3610 Where
3611 (KeyAccChild2.PARENT_NATURAL_ACCOUNT_ID is not null)
3612 and KeyAccChild2.ACCOUNT_GROUP_ID = finitemAcc.ACCOUNT_GROUP_ID
3613 AND KeyAccChild2.NATURAL_ACCOUNT_ID = finitemAcc.NATURAL_ACCOUNT_ID
3614 AND KeyAccChild2.PARENT_NATURAL_ACCOUNT_ID = finitemAcc2.NATURAL_ACCOUNT_ID
3615 and KeyAccChild2.ACCOUNT_GROUP_ID = finitemAcc2.ACCOUNT_GROUP_ID
3616 ------------------- ADDED THE REST OF CRITERIA TO CHECK THE MASTER ACCOUT EXISTS FOR THE SAME STATEMENT AND ITEM
3617 and finitemAcc2.STATEMENT_GROUP_ID = finitemAcc.STATEMENT_GROUP_ID
3618 and finitemAcc2.FINANCIAL_STATEMENT_ID = finitemAcc.FINANCIAL_STATEMENT_ID
3619 and finitemAcc2.FINANCIAL_ITEM_ID = finitemAcc.FINANCIAL_ITEM_ID
3620 )
3621 ;
3622
3623
3624 /* ---- NOT USED ------- Commented as the Child whose parents are not linked to a financial item was not treated
3625 --- differently from those whose parents also are attached to financial items
3626 cursor Get_fin_accs is
3627 select
3628 STATEMENT_GROUP_ID,
3629 ACCOUNT_GROUP_ID,
3630 FINANCIAL_STATEMENT_ID,
3631 FINANCIAL_ITEM_ID,
3632 NATURAL_ACCOUNT_ID
3633 from
3634 AMW_FIN_ITEMS_KEY_ACC
3635 where
3636 STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
3637 and FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
3638 and FINANCIAL_ITEM_ID = P_FINANCIAL_ITEM_ID ;
3639 */
3640
3641 -- CURRSOR TO GET ONLY THE ACCOUNTS THOSE ARE CHILDREN TO AN ACCOUNT WHICH INTRUN IS ASSOCIATED TO A FINANCIAL ITEM
3642
3643 cursor Get_sub_accs
3644 --(PAR_ACCOUNT_ID NUMBER, PAR_ACCOUNT_GROUP_ID NUMBER)
3645 is
3646 select
3647 ACCOUNT_GROUP_ID,
3648 NATURAL_ACCOUNT_ID
3649 from
3650 AMW_FIN_KEY_ACCOUNTS_B
3651 where
3652 PARENT_NATURAL_ACCOUNT_ID = P_ACCOUNT_ID
3653 and ACCOUNT_GROUP_ID = P_ACCOUNT_GROUP_ID;
3654
3655
3656 begin
3657 -- THE NEXT 3 VARIABLES (M_CERTIFICATION_ID , M_START_DATE AND M_END_DATE) ARE EACH TIME
3658 -- PASSED TO ITS CORRESPONDING PARAMETER AND STORED BACK AS THIS PROC
3659 -- IS CALLED IN RECURSIVE MODE AND DO NOT WANT TO REQUERY TO GET THESE INFORMATION
3660 M_CERTIFICATION_ID := P_CERTIFICATION_ID ;
3661 M_START_DATE := P_START_DATE ;
3662 M_END_DATE := P_END_DATE ;
3663
3664 if P_OBJECT_TYPE = 'FINANCIAL STATEMENT' then
3665
3666 for statement_items in Get_toplevel_fin_items
3667 loop
3668 exit when Get_toplevel_fin_items%notfound;
3669 M_STATEMENT_GROUP_ID := statement_items.STATEMENT_GROUP_ID;
3670 M_FINANCIAL_STATEMENT_ID := statement_items.FINANCIAL_STATEMENT_ID;
3671 M_FINANCIAL_ITEM_ID := statement_items.FINANCIAL_ITEM_ID;
3672
3673 g_user_id := fnd_global.user_id;
3674 g_login_id := fnd_global.conc_login_id;
3675
3676 AMW_FINSTMT_CERT_PVT.compute_values_for_eval_sum
3677 (P_CERTIFICATION_ID => M_CERTIFICATION_ID,
3678 P_FINANCIAL_STATEMENT_ID => M_FINANCIAL_STATEMENT_ID ,
3679 P_STATEMENT_GROUP_ID => M_STATEMENT_GROUP_ID ,
3680 -- P_PARENT_FIN_ITEM_ID => null,
3681 P_ACCOUNT_ID => null,
3682 P_ACCOUNT_GROUP_ID => null,
3683 P_FINANCIAL_ITEM_ID => M_FINANCIAL_ITEM_ID,
3684 P_OBJECT_TYPE => 'FINANCIAL ITEM',
3685 P_PROC_PENDING_CERTIFICATION =>
3686 M_PROC_PENDING_CERTIFICATION ,
3687 P_TOTAL_NUMBER_OF_PROCESSES =>
3688 M_TOTAL_NUMBER_OF_PROCESSES ,
3689 P_PROC_CERTIFIED_WITH_ISSUES =>
3690 M_PROC_CERTIFIED_WITH_ISSUES ,
3691 P_PROC_VERIFIED =>
3692 M_PROC_VERIFIED ,
3693 P_org_with_ineffective_ctrls =>
3694 M_org_with_ineffective_ctrls ,
3695 P_org_certified =>
3696 M_org_certified ,
3697 P_proc_with_ineffective_ctrls =>
3698 M_proc_with_ineffective_ctrls,
3699 P_unmitigated_risks =>
3700 M_unmitigated_risks ,
3701 P_risks_verified =>
3702 M_risks_verified ,
3703 P_ineffective_controls =>
3704 M_ineffective_controls ,
3705 P_controls_verified =>
3706 M_controls_verified ,
3707 P_open_issues =>
3708 M_open_issues ,
3709 P_PRO_PENDING_CERT_PRCNT =>
3710 M_PRO_PENDING_CERT_PRCNT ,
3711 P_PROCESSES_WITH_ISSUES_PRCNT =>
3712 M_PROCESSES_WITH_ISSUES_PRCNT,
3713 P_ORG_WITH_INEFF_CTRLS_PRCNT =>
3714 M_ORG_WITH_INEFF_CTRLS_PRCNT ,
3715 P_PROC_WITH_INEFF_CTRLS_PRCNT =>
3716 M_PROC_WITH_INEFF_CTRLS_PRCNT,
3717 P_UNMITIGATED_RISKS_PRCNT =>
3718 M_UNMITIGATED_RISKS_PRCNT ,
3719 P_INEFFECTIVE_CONTROLS_PRCNT =>
3720 M_INEFFECTIVE_CONTROLS_PRCNT,
3721 P_START_DATE => M_START_DATE ,
3722 P_END_DATE => M_END_DATE,
3723 p_PROCS_FOR_CERT_DONE => M_PROCS_FOR_CERT_DONE ,
3724 p_org_evaluated => M_org_evaluated );
3725
3726
3727 if (m_TOTAL_NUMBER_OF_PROCESSES is not null and m_TOTAL_NUMBER_OF_PROCESSES <> 0) then
3728 M_PRO_PENDING_CERT_PRCNT := (m_PROC_PENDING_CERTIFICATION / m_TOTAL_NUMBER_OF_PROCESSES) * 100 ;
3729 end if;
3730
3731 /* if (m_PROCS_FOR_CERT_DONE is not null and m_PROCS_FOR_CERT_DONE <> 0) then
3732 M_PROCESSES_WITH_ISSUES_PRCNT := (m_PROC_CERTIFIED_WITH_ISSUES / m_PROCS_FOR_CERT_DONE ) * 100 ;
3733 end if; */
3734
3735 if (m_TOTAL_NUMBER_OF_PROCESSES is not null and m_TOTAL_NUMBER_OF_PROCESSES <> 0) then
3736 M_PROCESSES_WITH_ISSUES_PRCNT := (m_PROC_CERTIFIED_WITH_ISSUES / m_TOTAL_NUMBER_OF_PROCESSES) * 100 ;
3737 end if;
3738
3739
3740 if (m_org_evaluated is not null and m_org_evaluated <> 0) then
3741 M_ORG_WITH_INEFF_CTRLS_PRCNT := (m_org_with_ineffective_ctrls / m_org_evaluated) * 100;
3742 end if;
3743
3744 /* --if (m_PROC_VERIFIED is not null and m_PROC_VERIFIED <> 0) then
3745 M_PROC_WITH_INEFF_CTRLS_PRCNT := (m_proc_with_ineffective_ctrls / m_PROC_VERIFIED) * 100 ;
3746 end if; */
3747
3748 if (m_TOTAL_NUMBER_OF_PROCESSES is not null and m_TOTAL_NUMBER_OF_PROCESSES <> 0) then
3749 M_PROC_WITH_INEFF_CTRLS_PRCNT := (m_proc_with_ineffective_ctrls / m_TOTAL_NUMBER_OF_PROCESSES) * 100 ;
3750 end if;
3751
3752 if (m_risks_verified is not null and m_risks_verified <> 0) then
3753 M_UNMITIGATED_RISKS_PRCNT := (m_unmitigated_risks / m_risks_verified) * 100;
3754 end if;
3755 if (m_controls_verified is not null and m_controls_verified <> 0) then
3756 M_INEFFECTIVE_CONTROLS_PRCNT := (m_ineffective_controls / m_controls_verified) * 100;
3757 end if;
3758
3759
3760 -- insert a fin item record
3761 AMW_FINSTMT_CERT_PVT.insert_fin_cert_eval_sum(
3762 X_FIN_CERTIFICATION_ID => M_CERTIFICATION_ID,
3763 X_FINANCIAL_STATEMENT_ID => M_FINANCIAL_STATEMENT_ID,
3764 X_FINANCIAL_ITEM_ID => M_FINANCIAL_ITEM_ID,
3765 X_ACCOUNT_GROUP_ID => NULL ,
3766 X_NATURAL_ACCOUNT_ID => NULL,
3767 X_OBJECT_TYPE => 'FINANCIAL ITEM',
3768 X_PROC_PENDING_CERTIFICATION => M_PROC_PENDING_CERTIFICATION,
3769 X_TOTAL_NUMBER_OF_PROCESSES => M_TOTAL_NUMBER_OF_PROCESSES,
3770 X_PROC_CERTIFIED_WITH_ISSUES => M_PROC_CERTIFIED_WITH_ISSUES,
3771 --X_PROC_VERIFIED => M_PROC_VERIFIED,
3772 X_PROCS_FOR_CERT_DONE => M_PROCS_FOR_CERT_DONE,
3773 x_proc_evaluated => M_PROC_VERIFIED,
3774 X_ORG_WITH_INEFFECTIVE_CTRLS => M_org_with_ineffective_ctrls,
3775 -- X_ORG_CERTIFIED => M_org_certified,
3776 x_orgs_FOR_CERT_DONE => M_org_certified,
3777 x_orgs_evaluated => M_org_evaluated,
3778 X_PROC_WITH_INEFFECTIVE_CTRLS => M_proc_with_ineffective_ctrls,
3779 X_UNMITIGATED_RISKS => M_unmitigated_risks,
3780 X_RISKS_VERIFIED => M_risks_verified,
3781 X_INEFFECTIVE_CONTROLS => M_ineffective_controls,
3782 X_CONTROLS_VERIFIED => M_controls_verified,
3783 X_OPEN_ISSUES => M_open_issues,
3784 X_PRO_PENDING_CERT_PRCNT => M_PRO_PENDING_CERT_PRCNT,
3785 X_PROCESSES_WITH_ISSUES_PRCNT => M_PROCESSES_WITH_ISSUES_PRCNT,
3786 X_ORG_WITH_INEFF_CTRLS_PRCNT => M_ORG_WITH_INEFF_CTRLS_PRCNT,
3787 X_PROC_WITH_INEFF_CTRLS_PRCNT => M_PROC_WITH_INEFF_CTRLS_PRCNT,
3788 X_UNMITIGATED_RISKS_PRCNT => M_UNMITIGATED_RISKS_PRCNT,
3789 X_INEFFECTIVE_CTRLS_PRCNT => M_INEFFECTIVE_CONTROLS_PRCNT,
3790 X_OBJ_CONTEXT => NULL,
3791 X_CREATED_BY => g_user_id,
3792 X_CREATION_DATE => SYSDATE,
3793 X_LAST_UPDATED_BY => g_user_id,
3794 X_LAST_UPDATE_DATE => SYSDATE,
3795 X_LAST_UPDATE_LOGIN => g_login_id,
3796 X_SECURITY_GROUP_ID => NULL,
3797 X_OBJECT_VERSION_NUMBER => NULL);
3798
3799
3800 end loop;
3801 elsif P_OBJECT_TYPE = 'FINANCIAL ITEM' then
3802
3803 M_FINANCIAL_STATEMENT_ID := P_FINANCIAL_STATEMENT_ID ;
3804 M_STATEMENT_GROUP_ID := P_STATEMENT_GROUP_ID;
3805 M_FINANCIAL_ITEM_ID := P_FINANCIAL_ITEM_ID ;
3806
3807 GetTotalProcesses_for_finitem(
3808 P_STATEMENT_GROUP_ID => M_STATEMENT_GROUP_ID,
3809 P_FINANCIAL_STATEMENT_ID => M_FINANCIAL_STATEMENT_ID ,
3810 P_FINANCIAL_ITEM_ID => M_FINANCIAL_ITEM_ID ,
3811 P_TOTAL_NUMBER_OF_PROCESSES => M_TOTAL_NUMBER_OF_PROCESSES);
3812
3813 IF (M_TOTAL_NUMBER_OF_PROCESSES IS NOT NULL OR
3814 M_TOTAL_NUMBER_OF_PROCESSES <> 0)
3815 THEN
3816
3817 CountProcsCertRecorded_finitem(
3818 P_STATEMENT_GROUP_ID => M_STATEMENT_GROUP_ID,
3819 P_FINANCIAL_STATEMENT_ID => M_FINANCIAL_STATEMENT_ID ,
3820 P_FINANCIAL_ITEM_ID => M_FINANCIAL_ITEM_ID ,
3821 P_PROCS_IN_CERTIFICATION => M_PROCS_FOR_CERT_DONE
3822 , p_start_date => M_START_DATE
3823 , p_end_date => M_END_DATE
3824 , p_fin_cert_id => M_CERTIFICATION_ID) ;
3825
3826
3827 CountProcsEvaluated_finitem(
3828 P_STATEMENT_GROUP_ID => M_STATEMENT_GROUP_ID,
3829 P_FINANCIAL_STATEMENT_ID => M_FINANCIAL_STATEMENT_ID ,
3830 P_FINANCIAL_ITEM_ID => M_FINANCIAL_ITEM_ID ,
3831 P_PROCS_EVALUATED => M_PROC_VERIFIED
3832 , p_start_date => M_START_DATE
3833 , p_end_date => M_END_DATE) ;
3834
3835
3836 M_PROC_PENDING_CERTIFICATION := M_TOTAL_NUMBER_OF_PROCESSES - M_PROCS_FOR_CERT_DONE ;
3837
3838 CountProcswithIssues_finitem(
3839 P_STATEMENT_GROUP_ID => M_STATEMENT_GROUP_ID,
3840 P_FINANCIAL_STATEMENT_ID => M_FINANCIAL_STATEMENT_ID ,
3841 P_FINANCIAL_ITEM_ID => M_FINANCIAL_ITEM_ID ,
3842 P_PROC_CERTIFIED_WITH_ISSUES => M_PROC_CERTIFIED_WITH_ISSUES
3843 , p_start_date => M_START_DATE
3844 , p_end_date => M_END_DATE
3845 , p_fin_cert_id => M_CERTIFICATION_ID) ;
3846
3847 CountOrgsIneffCtrl_finitem(
3848 P_STATEMENT_GROUP_ID => M_STATEMENT_GROUP_ID,
3849 P_FINANCIAL_STATEMENT_ID => M_FINANCIAL_STATEMENT_ID ,
3850 P_FINANCIAL_ITEM_ID => M_FINANCIAL_ITEM_ID ,
3851 P_org_with_ineffective_ctrls =>M_org_with_ineffective_ctrls
3852 , p_start_date => M_START_DATE
3853 , p_end_date => M_END_DATE) ;
3854
3855 CountOrgsEvaluated_finitem(
3856 P_STATEMENT_GROUP_ID => M_STATEMENT_GROUP_ID,
3857 P_FINANCIAL_STATEMENT_ID => M_FINANCIAL_STATEMENT_ID ,
3858 P_FINANCIAL_ITEM_ID => M_FINANCIAL_ITEM_ID ,
3859 P_org_evaluated => M_org_evaluated
3860 , p_start_date => M_START_DATE
3861 , p_end_date => M_END_DATE) ;
3862
3863
3864 /* CountOrgswithIssues_Accounts(P_NATURAL_ACCOUNT_ID in number,
3865 ? P_org_cert_with_issues OUT Number,
3866 p_start_date in date, p_end_date in date) ;
3867 */
3868
3869 CountOrgsCertified_finitem(
3870 P_STATEMENT_GROUP_ID => M_STATEMENT_GROUP_ID,
3871 P_FINANCIAL_STATEMENT_ID => M_FINANCIAL_STATEMENT_ID ,
3872 P_FINANCIAL_ITEM_ID => M_FINANCIAL_ITEM_ID ,
3873 P_org_certified =>M_org_certified
3874 , p_start_date => M_START_DATE
3875 , p_end_date => M_END_DATE) ;
3876
3877 CountProcsIneffCtrl_finitem(
3878 P_STATEMENT_GROUP_ID => M_STATEMENT_GROUP_ID,
3879 P_FINANCIAL_STATEMENT_ID => M_FINANCIAL_STATEMENT_ID ,
3880 P_FINANCIAL_ITEM_ID => M_FINANCIAL_ITEM_ID ,
3881 P_proc_with_ineffective_ctrls => M_proc_with_ineffective_ctrls
3882 , p_start_date => M_START_DATE
3883 , p_end_date => M_END_DATE) ;
3884
3885 CountIneffectiveCtrls_finitem(
3886 P_STATEMENT_GROUP_ID => M_STATEMENT_GROUP_ID,
3887 P_FINANCIAL_STATEMENT_ID => M_FINANCIAL_STATEMENT_ID ,
3888 P_FINANCIAL_ITEM_ID => M_FINANCIAL_ITEM_ID ,
3889 p_ineffective_controls => M_ineffective_controls
3890 , p_start_date => M_START_DATE
3891 , p_end_date => M_END_DATE) ;
3892
3893 CountUnmittigatedRisk_finitem(
3894 P_STATEMENT_GROUP_ID => M_STATEMENT_GROUP_ID,
3895 P_FINANCIAL_STATEMENT_ID => M_FINANCIAL_STATEMENT_ID ,
3896 P_FINANCIAL_ITEM_ID => M_FINANCIAL_ITEM_ID ,
3897 p_unmitigated_risks => M_unmitigated_risks
3898 , p_start_date => M_START_DATE
3899 , p_end_date => M_END_DATE) ;
3900
3901 CountRisksVerified_finitem(
3902 P_STATEMENT_GROUP_ID => M_STATEMENT_GROUP_ID,
3903 P_FINANCIAL_STATEMENT_ID => M_FINANCIAL_STATEMENT_ID ,
3904 P_FINANCIAL_ITEM_ID => M_FINANCIAL_ITEM_ID ,
3905 p_risks_verified => M_risks_verified
3906 , p_start_date => M_START_DATE
3907 , p_end_date => M_END_DATE) ;
3908
3909 CountControlsVerified_finitem(
3910 P_STATEMENT_GROUP_ID => M_STATEMENT_GROUP_ID,
3911 P_FINANCIAL_STATEMENT_ID => M_FINANCIAL_STATEMENT_ID ,
3912 P_FINANCIAL_ITEM_ID => M_FINANCIAL_ITEM_ID ,
3913 p_controls_verified => M_controls_verified
3914 , p_start_date => M_START_DATE
3915 , p_end_date => M_END_DATE) ;
3916
3917
3918 P_PROC_PENDING_CERTIFICATION := NVL(M_PROC_PENDING_CERTIFICATION,0);
3919 P_TOTAL_NUMBER_OF_PROCESSES := NVL(M_TOTAL_NUMBER_OF_PROCESSES,0) ;
3920 P_PROC_CERTIFIED_WITH_ISSUES := NVL(M_PROC_CERTIFIED_WITH_ISSUES,0) ;
3921 P_PROC_VERIFIED := NVL(M_PROC_VERIFIED,0) ;
3922 P_org_with_ineffective_ctrls := NVL(M_org_with_ineffective_ctrls,0);
3923 P_org_certified := NVL(M_org_certified,0) ;
3924 P_proc_with_ineffective_ctrls := NVL(M_proc_with_ineffective_ctrls,0) ;
3925 P_unmitigated_risks := NVL(M_unmitigated_risks,0) ;
3926 P_risks_verified := NVL(M_risks_verified,0) ;
3927 P_ineffective_controls := NVL(M_ineffective_controls,0) ;
3928 P_controls_verified := NVL(M_controls_verified,0) ;
3929 P_open_issues := NVL(M_open_issues,0) ;
3930 P_PROCS_FOR_CERT_DONE := nvl(m_PROCS_FOR_CERT_DONE,0);
3931 p_org_evaluated := NVL(M_org_evaluated,0) ;
3932
3933
3934
3935
3936
3937 for stmnt_child_items in Get_child_fin_items
3938 loop
3939 exit when Get_child_fin_items%notfound;
3940 M_STATEMENT_GROUP_ID := stmnt_child_items.STATEMENT_GROUP_ID;
3941 M_FINANCIAL_STATEMENT_ID := stmnt_child_items.FINANCIAL_STATEMENT_ID;
3942 M_FINANCIAL_ITEM_ID := stmnt_child_items.FINANCIAL_ITEM_ID;
3943
3944
3945 AMW_FINSTMT_CERT_PVT.compute_values_for_eval_sum
3946 (P_CERTIFICATION_ID => M_CERTIFICATION_ID,
3947 P_FINANCIAL_STATEMENT_ID => M_FINANCIAL_STATEMENT_ID ,
3948 P_STATEMENT_GROUP_ID => M_STATEMENT_GROUP_ID ,
3949 --P_PARENT_FIN_ITEM_ID => null;
3950 P_ACCOUNT_ID => null,
3951 P_ACCOUNT_GROUP_ID => null,
3952 P_FINANCIAL_ITEM_ID => M_FINANCIAL_ITEM_ID,
3953 P_OBJECT_TYPE => 'FINANCIAL ITEM',
3954 P_PROC_PENDING_CERTIFICATION =>
3955 M_PROC_PENDING_CERTIFICATION ,
3956 P_TOTAL_NUMBER_OF_PROCESSES =>
3957 M_TOTAL_NUMBER_OF_PROCESSES ,
3958 P_PROC_CERTIFIED_WITH_ISSUES =>
3959 M_PROC_CERTIFIED_WITH_ISSUES ,
3960 P_PROC_VERIFIED =>
3961 M_PROC_VERIFIED ,
3962 P_org_with_ineffective_ctrls =>
3963 M_org_with_ineffective_ctrls ,
3964 P_org_certified =>
3965 M_org_certified ,
3966 P_proc_with_ineffective_ctrls =>
3967 M_proc_with_ineffective_ctrls,
3968 P_unmitigated_risks =>
3969 M_unmitigated_risks ,
3970 P_risks_verified =>
3971 M_risks_verified ,
3972 P_ineffective_controls =>
3973 M_ineffective_controls ,
3974 P_controls_verified =>
3975 M_controls_verified ,
3976 P_open_issues =>
3977 M_open_issues ,
3978 P_PRO_PENDING_CERT_PRCNT =>
3979 M_PRO_PENDING_CERT_PRCNT ,
3980 P_PROCESSES_WITH_ISSUES_PRCNT =>
3981 M_PROCESSES_WITH_ISSUES_PRCNT,
3982 P_ORG_WITH_INEFF_CTRLS_PRCNT =>
3983 M_ORG_WITH_INEFF_CTRLS_PRCNT ,
3984 P_PROC_WITH_INEFF_CTRLS_PRCNT =>
3985 M_PROC_WITH_INEFF_CTRLS_PRCNT,
3986 P_UNMITIGATED_RISKS_PRCNT =>
3987 M_UNMITIGATED_RISKS_PRCNT ,
3988 P_INEFFECTIVE_CONTROLS_PRCNT =>
3989 M_INEFFECTIVE_CONTROLS_PRCNT,
3990 P_START_DATE => M_START_DATE ,
3991 P_END_DATE => M_END_DATE,
3992 p_PROCS_FOR_CERT_DONE => M_PROCS_FOR_CERT_DONE ,
3993 p_org_evaluated => M_org_evaluated );
3994
3995
3996
3997 if (m_TOTAL_NUMBER_OF_PROCESSES is not null and m_TOTAL_NUMBER_OF_PROCESSES <> 0) then
3998 M_PRO_PENDING_CERT_PRCNT := (m_PROC_PENDING_CERTIFICATION / m_TOTAL_NUMBER_OF_PROCESSES) * 100 ;
3999 end if;
4000
4001 /*if (m_PROCS_FOR_CERT_DONE is not null and m_PROCS_FOR_CERT_DONE <> 0) then
4002 M_PROCESSES_WITH_ISSUES_PRCNT := (m_PROC_CERTIFIED_WITH_ISSUES / m_PROCS_FOR_CERT_DONE ) * 100 ;
4003 end if;*/
4004
4005 if (m_TOTAL_NUMBER_OF_PROCESSES is not null and m_TOTAL_NUMBER_OF_PROCESSES <> 0) then
4006 M_PROCESSES_WITH_ISSUES_PRCNT := (m_PROC_CERTIFIED_WITH_ISSUES / m_TOTAL_NUMBER_OF_PROCESSES) * 100 ;
4007 end if;
4008
4009 if (m_org_evaluated is not null and m_org_evaluated <> 0) then
4010 M_ORG_WITH_INEFF_CTRLS_PRCNT := (m_org_with_ineffective_ctrls / m_org_evaluated) * 100;
4011 end if;
4012
4013 /* if (m_PROC_VERIFIED is not null and m_PROC_VERIFIED <> 0) then
4014 M_PROC_WITH_INEFF_CTRLS_PRCNT := (m_proc_with_ineffective_ctrls / m_PROC_VERIFIED) * 100 ;
4015 end if; */
4016
4017 if (m_TOTAL_NUMBER_OF_PROCESSES is not null and m_TOTAL_NUMBER_OF_PROCESSES <> 0) then
4018 M_PROC_WITH_INEFF_CTRLS_PRCNT := (m_proc_with_ineffective_ctrls / m_TOTAL_NUMBER_OF_PROCESSES) * 100 ;
4019 end if;
4020
4021
4022 if (m_risks_verified is not null and m_risks_verified <> 0) then
4023 M_UNMITIGATED_RISKS_PRCNT := (m_unmitigated_risks / m_risks_verified) * 100;
4024 end if;
4025 if (m_controls_verified is not null and m_controls_verified <> 0) then
4026 M_INEFFECTIVE_CONTROLS_PRCNT := (m_ineffective_controls / m_controls_verified) * 100;
4027 end if;
4028
4029
4030
4031 -- insert a financial item record which will take care of the child financial items
4032 AMW_FINSTMT_CERT_PVT.insert_fin_cert_eval_sum(
4033 X_FIN_CERTIFICATION_ID => M_CERTIFICATION_ID,
4034 X_FINANCIAL_STATEMENT_ID => M_FINANCIAL_STATEMENT_ID,
4035 X_FINANCIAL_ITEM_ID => M_FINANCIAL_ITEM_ID,
4036 X_ACCOUNT_GROUP_ID => NULL,
4037 X_NATURAL_ACCOUNT_ID => NULL,
4038 X_OBJECT_TYPE => 'FINANCIAL ITEM',
4039 X_PROC_PENDING_CERTIFICATION => M_PROC_PENDING_CERTIFICATION,
4040 X_TOTAL_NUMBER_OF_PROCESSES => M_TOTAL_NUMBER_OF_PROCESSES,
4041 X_PROC_CERTIFIED_WITH_ISSUES => M_PROC_CERTIFIED_WITH_ISSUES,
4042 -- X_PROC_VERIFIED => M_PROC_VERIFIED,
4043 X_PROCS_FOR_CERT_DONE => M_PROCS_FOR_CERT_DONE,
4044 x_proc_evaluated => M_PROC_VERIFIED,
4045 X_ORG_WITH_INEFFECTIVE_CTRLS => M_org_with_ineffective_ctrls,
4046 -- X_ORG_CERTIFIED => M_org_certified,
4047 x_orgs_FOR_CERT_DONE => M_org_certified,
4048 x_orgs_evaluated => M_org_evaluated,
4049 X_PROC_WITH_INEFFECTIVE_CTRLS => M_proc_with_ineffective_ctrls,
4050 X_UNMITIGATED_RISKS => M_unmitigated_risks,
4051 X_RISKS_VERIFIED => M_risks_verified,
4052 X_INEFFECTIVE_CONTROLS => M_ineffective_controls,
4053 X_CONTROLS_VERIFIED => M_controls_verified,
4054 X_OPEN_ISSUES => M_open_issues,
4055 X_PRO_PENDING_CERT_PRCNT => M_PRO_PENDING_CERT_PRCNT,
4056 X_PROCESSES_WITH_ISSUES_PRCNT => M_PROCESSES_WITH_ISSUES_PRCNT,
4057 X_ORG_WITH_INEFF_CTRLS_PRCNT => M_ORG_WITH_INEFF_CTRLS_PRCNT,
4058 X_PROC_WITH_INEFF_CTRLS_PRCNT => M_PROC_WITH_INEFF_CTRLS_PRCNT,
4059 X_UNMITIGATED_RISKS_PRCNT => M_UNMITIGATED_RISKS_PRCNT,
4060 X_INEFFECTIVE_CTRLS_PRCNT => M_INEFFECTIVE_CONTROLS_PRCNT,
4061 X_OBJ_CONTEXT => NULL,
4062 X_CREATED_BY => g_user_id,
4063 X_CREATION_DATE => SYSDATE,
4064 X_LAST_UPDATED_BY => g_user_id,
4065 X_LAST_UPDATE_DATE => SYSDATE,
4066 X_LAST_UPDATE_LOGIN => g_login_id,
4067 X_SECURITY_GROUP_ID => NULL,
4068 X_OBJECT_VERSION_NUMBER => NULL);
4069
4070
4071
4072 end loop;
4073
4074
4075 for stmnt_accs in Get_fin_accs
4076 loop
4077 exit when Get_fin_accs%notfound;
4078
4079 M_STATEMENT_GROUP_ID := stmnt_accs.STATEMENT_GROUP_ID;
4080 M_FINANCIAL_STATEMENT_ID := stmnt_accs.FINANCIAL_STATEMENT_ID;
4081 M_FINANCIAL_ITEM_ID := stmnt_accs.FINANCIAL_ITEM_ID;
4082 M_ACCOUNT_GROUP_ID := stmnt_accs.ACCOUNT_GROUP_ID;
4083 M_NATURAL_ACCOUNT_ID := stmnt_accs.NATURAL_ACCOUNT_ID;
4084
4085 AMW_FINSTMT_CERT_PVT.compute_values_for_eval_sum
4086 (P_CERTIFICATION_ID => M_CERTIFICATION_ID,
4087 P_FINANCIAL_STATEMENT_ID => M_FINANCIAL_STATEMENT_ID ,
4088 P_STATEMENT_GROUP_ID => M_STATEMENT_GROUP_ID ,
4089 --P_PARENT_FIN_ITEM_ID => null;
4090 P_ACCOUNT_ID => M_NATURAL_ACCOUNT_ID ,
4091 P_ACCOUNT_GROUP_ID => M_ACCOUNT_GROUP_ID ,
4092 P_FINANCIAL_ITEM_ID => M_FINANCIAL_ITEM_ID,
4093 P_OBJECT_TYPE => 'ACCOUNT',
4094 P_PROC_PENDING_CERTIFICATION =>
4095 M_PROC_PENDING_CERTIFICATION ,
4096 P_TOTAL_NUMBER_OF_PROCESSES =>
4097 M_TOTAL_NUMBER_OF_PROCESSES ,
4098 P_PROC_CERTIFIED_WITH_ISSUES =>
4099 M_PROC_CERTIFIED_WITH_ISSUES ,
4100 P_PROC_VERIFIED =>
4101 M_PROC_VERIFIED ,
4102 P_org_with_ineffective_ctrls =>
4103 M_org_with_ineffective_ctrls ,
4104 P_org_certified =>
4105 M_org_certified ,
4106 P_proc_with_ineffective_ctrls =>
4107 M_proc_with_ineffective_ctrls,
4108 P_unmitigated_risks =>
4109 M_unmitigated_risks ,
4110 P_risks_verified =>
4111 M_risks_verified ,
4112 P_ineffective_controls =>
4113 M_ineffective_controls ,
4114 P_controls_verified =>
4115 M_controls_verified ,
4116 P_open_issues =>
4117 M_open_issues ,
4118 P_PRO_PENDING_CERT_PRCNT =>
4119 M_PRO_PENDING_CERT_PRCNT ,
4120 P_PROCESSES_WITH_ISSUES_PRCNT =>
4121 M_PROCESSES_WITH_ISSUES_PRCNT,
4122 P_ORG_WITH_INEFF_CTRLS_PRCNT =>
4123 M_ORG_WITH_INEFF_CTRLS_PRCNT ,
4124 P_PROC_WITH_INEFF_CTRLS_PRCNT =>
4125 M_PROC_WITH_INEFF_CTRLS_PRCNT,
4126 P_UNMITIGATED_RISKS_PRCNT =>
4127 M_UNMITIGATED_RISKS_PRCNT ,
4128 P_INEFFECTIVE_CONTROLS_PRCNT =>
4129 M_INEFFECTIVE_CONTROLS_PRCNT,
4130 P_START_DATE => M_START_DATE ,
4131 P_END_DATE => M_END_DATE,
4132 p_PROCS_FOR_CERT_DONE => M_PROCS_FOR_CERT_DONE ,
4133 p_org_evaluated => M_org_evaluated );
4134
4135
4136
4137 if (m_TOTAL_NUMBER_OF_PROCESSES is not null and m_TOTAL_NUMBER_OF_PROCESSES <> 0) then
4138 M_PRO_PENDING_CERT_PRCNT := (m_PROC_PENDING_CERTIFICATION / m_TOTAL_NUMBER_OF_PROCESSES) * 100 ;
4139 end if;
4140
4141 /* if (m_PROCS_FOR_CERT_DONE is not null and m_PROCS_FOR_CERT_DONE <> 0) then
4142 M_PROCESSES_WITH_ISSUES_PRCNT := (m_PROC_CERTIFIED_WITH_ISSUES / m_PROCS_FOR_CERT_DONE ) * 100 ;
4143 end if; */
4144
4145 if (m_TOTAL_NUMBER_OF_PROCESSES is not null and m_TOTAL_NUMBER_OF_PROCESSES <> 0) then
4146 M_PROCESSES_WITH_ISSUES_PRCNT := (m_PROC_CERTIFIED_WITH_ISSUES / m_TOTAL_NUMBER_OF_PROCESSES) * 100 ;
4147 end if;
4148
4149
4150 if (m_org_evaluated is not null and m_org_evaluated <> 0) then
4151 M_ORG_WITH_INEFF_CTRLS_PRCNT := (m_org_with_ineffective_ctrls / m_org_evaluated) * 100;
4152 end if;
4153
4154 /*if (m_PROC_VERIFIED is not null and m_PROC_VERIFIED <> 0) then
4155 M_PROC_WITH_INEFF_CTRLS_PRCNT := (m_proc_with_ineffective_ctrls / m_PROC_VERIFIED) * 100 ;
4156 end if; */
4157
4158 if (m_TOTAL_NUMBER_OF_PROCESSES is not null and m_TOTAL_NUMBER_OF_PROCESSES <> 0) then
4159 M_PROC_WITH_INEFF_CTRLS_PRCNT := (m_proc_with_ineffective_ctrls / m_TOTAL_NUMBER_OF_PROCESSES ) * 100 ;
4160 end if;
4161
4162 if (m_risks_verified is not null and m_risks_verified <> 0) then
4163 M_UNMITIGATED_RISKS_PRCNT := (m_unmitigated_risks / m_risks_verified) * 100;
4164 end if;
4165 if (m_controls_verified is not null and m_controls_verified <> 0) then
4166 M_INEFFECTIVE_CONTROLS_PRCNT := (m_ineffective_controls / m_controls_verified) * 100;
4167 end if;
4168
4169 -- insert a KEY ACCOUNT record
4170
4171 AMW_FINSTMT_CERT_PVT.insert_fin_cert_eval_sum(
4172 X_FIN_CERTIFICATION_ID => M_CERTIFICATION_ID,
4173 X_FINANCIAL_STATEMENT_ID => M_FINANCIAL_STATEMENT_ID,
4174 X_FINANCIAL_ITEM_ID => M_FINANCIAL_ITEM_ID,
4175 X_ACCOUNT_GROUP_ID => M_ACCOUNT_GROUP_ID ,
4176 X_NATURAL_ACCOUNT_ID => M_NATURAL_ACCOUNT_ID,
4177 X_OBJECT_TYPE => 'ACCOUNT',
4178 X_PROC_PENDING_CERTIFICATION => M_PROC_PENDING_CERTIFICATION,
4179 X_TOTAL_NUMBER_OF_PROCESSES => M_TOTAL_NUMBER_OF_PROCESSES,
4180 X_PROC_CERTIFIED_WITH_ISSUES => M_PROC_CERTIFIED_WITH_ISSUES,
4181 -- X_PROC_VERIFIED => M_PROC_VERIFIED,
4182 X_PROCS_FOR_CERT_DONE => M_PROCS_FOR_CERT_DONE,
4183 x_proc_evaluated => M_PROC_VERIFIED,
4184 X_ORG_WITH_INEFFECTIVE_CTRLS => M_org_with_ineffective_ctrls,
4185 -- X_ORG_CERTIFIED => M_org_certified,
4186 x_orgs_FOR_CERT_DONE => M_org_certified,
4187 x_orgs_evaluated => M_org_evaluated,
4188 X_PROC_WITH_INEFFECTIVE_CTRLS => M_proc_with_ineffective_ctrls,
4189 X_UNMITIGATED_RISKS => M_unmitigated_risks,
4190 X_RISKS_VERIFIED => M_risks_verified,
4191 X_INEFFECTIVE_CONTROLS => M_ineffective_controls,
4192 X_CONTROLS_VERIFIED => M_controls_verified,
4193 X_OPEN_ISSUES => M_open_issues,
4194 X_PRO_PENDING_CERT_PRCNT => M_PRO_PENDING_CERT_PRCNT,
4195 X_PROCESSES_WITH_ISSUES_PRCNT => M_PROCESSES_WITH_ISSUES_PRCNT,
4196 X_ORG_WITH_INEFF_CTRLS_PRCNT => M_ORG_WITH_INEFF_CTRLS_PRCNT,
4197 X_PROC_WITH_INEFF_CTRLS_PRCNT => M_PROC_WITH_INEFF_CTRLS_PRCNT,
4198 X_UNMITIGATED_RISKS_PRCNT => M_UNMITIGATED_RISKS_PRCNT,
4199 X_INEFFECTIVE_CTRLS_PRCNT => M_INEFFECTIVE_CONTROLS_PRCNT,
4200 X_OBJ_CONTEXT => NULL,
4201 X_CREATED_BY => g_user_id,
4202 X_CREATION_DATE => SYSDATE,
4203 X_LAST_UPDATED_BY => g_user_id,
4204 X_LAST_UPDATE_DATE => SYSDATE,
4205 X_LAST_UPDATE_LOGIN => g_login_id,
4206 X_SECURITY_GROUP_ID => NULL,
4207 X_OBJECT_VERSION_NUMBER => NULL);
4208
4209 end loop;
4210
4211
4212 END IF;--If condition to check if M_TOTAL_NUMBER_OF_PROCESSES is = 0 or null
4213
4214 elsif P_OBJECT_TYPE = 'ACCOUNT' then
4215
4216 M_NATURAL_ACCOUNT_ID := P_ACCOUNT_ID ;
4217 M_ACCOUNT_GROUP_ID := P_ACCOUNT_GROUP_ID ;
4218
4219 GetTotalProcesses_for_account(
4220 P_NATURAL_ACCOUNT_ID => M_NATURAL_ACCOUNT_ID,
4221 P_account_group_id => M_ACCOUNT_GROUP_ID ,
4222 P_TOTAL_NUMBER_OF_PROCESSES => M_TOTAL_NUMBER_OF_PROCESSES);
4223
4224 IF (M_TOTAL_NUMBER_OF_PROCESSES IS NOT NULL OR
4225 M_TOTAL_NUMBER_OF_PROCESSES <> 0)
4226
4227 THEN
4228
4229 CountProcsCertRecorded_Accnts(
4230 P_NATURAL_ACCOUNT_ID => M_NATURAL_ACCOUNT_ID,
4231 P_account_group_id => M_ACCOUNT_GROUP_ID ,
4232 P_PROCS_IN_CERTIFICATION => M_PROCS_FOR_CERT_DONE
4233 , p_start_date => M_START_DATE
4234 , p_end_date => M_END_DATE
4235 , p_fin_cert_id => M_CERTIFICATION_ID) ;
4236
4237 CountProcsEvaluated_Accnts(
4238 P_NATURAL_ACCOUNT_ID => M_NATURAL_ACCOUNT_ID,
4239 P_account_group_id => M_ACCOUNT_GROUP_ID ,
4240 P_PROCS_EVALUATED => M_PROC_VERIFIED
4241 , p_start_date => M_START_DATE
4242 , p_end_date => M_END_DATE) ;
4243
4244 M_PROC_PENDING_CERTIFICATION := M_TOTAL_NUMBER_OF_PROCESSES - M_PROCS_FOR_CERT_DONE ;
4245
4246 CountProcswithIssues_Accounts(P_NATURAL_ACCOUNT_ID => M_NATURAL_ACCOUNT_ID,
4247 P_account_group_id => M_ACCOUNT_GROUP_ID ,
4248 P_PROC_CERTIFIED_WITH_ISSUES => M_PROC_CERTIFIED_WITH_ISSUES
4249 , p_start_date => M_START_DATE
4250 , p_end_date => M_END_DATE
4251 , p_fin_cert_id => M_CERTIFICATION_ID) ;
4252
4253 CountOrgsIneffCtrl_Accounts(P_NATURAL_ACCOUNT_ID => M_NATURAL_ACCOUNT_ID,
4254 P_account_group_id => M_ACCOUNT_GROUP_ID ,
4255 P_org_with_ineffective_ctrls =>M_org_with_ineffective_ctrls
4256 , p_start_date => M_START_DATE
4257 , p_end_date => M_END_DATE) ;
4258
4259 CountOrgsEvaluated_accounts(P_NATURAL_ACCOUNT_ID => M_NATURAL_ACCOUNT_ID,
4260 P_account_group_id => M_ACCOUNT_GROUP_ID ,
4261 P_org_evaluated => M_org_evaluated
4262 , p_start_date => M_START_DATE
4263 , p_end_date => M_END_DATE) ;
4264
4265
4266 /* CountOrgswithIssues_Accounts(P_NATURAL_ACCOUNT_ID in number,
4267 ? P_org_cert_with_issues OUT Number,
4268 p_start_date in date, p_end_date in date) ;
4269 */
4270
4271 CountOrgsCertified_accounts(P_NATURAL_ACCOUNT_ID => M_NATURAL_ACCOUNT_ID,
4272 P_account_group_id => M_ACCOUNT_GROUP_ID ,
4273 P_org_certified =>M_org_certified
4274 , p_start_date => M_START_DATE
4275 , p_end_date => M_END_DATE) ;
4276
4277 CountProcsIneffCtrl_accounts(P_NATURAL_ACCOUNT_ID => M_NATURAL_ACCOUNT_ID,
4278 P_account_group_id => M_ACCOUNT_GROUP_ID ,
4279 P_proc_with_ineffective_ctrls => M_proc_with_ineffective_ctrls
4280 , p_start_date => M_START_DATE
4281 , p_end_date => M_END_DATE) ;
4282
4283 CountIneffectiveCtrls_account(P_NATURAL_ACCOUNT_ID => M_NATURAL_ACCOUNT_ID,
4284 P_account_group_id => M_ACCOUNT_GROUP_ID ,
4285 p_ineffective_controls =>M_ineffective_controls
4286 , p_start_date => M_START_DATE
4287 , p_end_date => M_END_DATE) ;
4288
4289 CountUnmittigatedRisk_account(P_NATURAL_ACCOUNT_ID => M_NATURAL_ACCOUNT_ID,
4290 P_account_group_id => M_ACCOUNT_GROUP_ID ,
4291 p_unmitigated_risks =>M_unmitigated_risks
4292 , p_start_date => M_START_DATE
4293 , p_end_date => M_END_DATE) ;
4294
4295 CountRisksVerified_account(P_NATURAL_ACCOUNT_ID => M_NATURAL_ACCOUNT_ID,
4296 P_account_group_id => M_ACCOUNT_GROUP_ID ,
4297 p_risks_verified =>M_risks_verified
4298 , p_start_date => M_START_DATE
4299 , p_end_date => M_END_DATE) ;
4300
4301 CountControlsVerified_account(P_NATURAL_ACCOUNT_ID => M_NATURAL_ACCOUNT_ID,
4302 P_account_group_id => M_ACCOUNT_GROUP_ID ,
4303 p_controls_verified =>M_controls_verified
4304 , p_start_date => M_START_DATE
4305 , p_end_date => M_END_DATE) ;
4306
4307
4308 P_PROC_PENDING_CERTIFICATION := NVL(M_PROC_PENDING_CERTIFICATION,0);
4309 P_TOTAL_NUMBER_OF_PROCESSES := NVL(M_TOTAL_NUMBER_OF_PROCESSES,0) ;
4310 P_PROC_CERTIFIED_WITH_ISSUES := NVL(M_PROC_CERTIFIED_WITH_ISSUES,0) ;
4311 P_PROC_VERIFIED := NVL(M_PROC_VERIFIED,0) ;
4312 P_org_with_ineffective_ctrls := NVL(M_org_with_ineffective_ctrls,0);
4313 P_org_certified := NVL(M_org_certified,0) ;
4314 P_proc_with_ineffective_ctrls := NVL(M_proc_with_ineffective_ctrls,0) ;
4315 P_unmitigated_risks := NVL(M_unmitigated_risks,0) ;
4316 P_risks_verified := NVL(M_risks_verified,0) ;
4317 P_ineffective_controls := NVL(M_ineffective_controls,0) ;
4318 P_controls_verified := NVL(M_controls_verified,0) ;
4319 P_open_issues := NVL(M_open_issues,0) ;
4320 P_PROCS_FOR_CERT_DONE := nvl(m_PROCS_FOR_CERT_DONE,0);
4321 p_org_evaluated := NVL(M_org_evaluated,0) ;
4322
4323
4324
4325
4326
4327 for stmnt_child_accs in Get_sub_accs
4328 loop
4329 exit when Get_sub_accs%notfound;
4330
4331 M_STATEMENT_GROUP_ID := P_STATEMENT_GROUP_ID ;
4332 M_FINANCIAL_STATEMENT_ID := P_FINANCIAL_STATEMENT_ID ;
4333 M_FINANCIAL_ITEM_ID := P_FINANCIAL_ITEM_ID;
4334 M_ACCOUNT_GROUP_ID := stmnt_child_accs.ACCOUNT_GROUP_ID;
4335 M_NATURAL_ACCOUNT_ID_2 := stmnt_child_accs.NATURAL_ACCOUNT_ID;
4336
4337 AMW_FINSTMT_CERT_PVT.compute_values_for_eval_sum
4338 (P_CERTIFICATION_ID => M_CERTIFICATION_ID,
4339 P_FINANCIAL_STATEMENT_ID => M_FINANCIAL_STATEMENT_ID ,
4340 P_STATEMENT_GROUP_ID => M_STATEMENT_GROUP_ID ,
4341 --P_PARENT_FIN_ITEM_ID => null;
4342 P_ACCOUNT_ID => M_NATURAL_ACCOUNT_ID_2 ,
4343 P_ACCOUNT_GROUP_ID => M_ACCOUNT_GROUP_ID ,
4344 P_FINANCIAL_ITEM_ID => M_FINANCIAL_ITEM_ID,
4345 P_OBJECT_TYPE => 'ACCOUNT',
4346 P_PROC_PENDING_CERTIFICATION =>
4347 M_PROC_PENDING_CERTIFICATION ,
4348 P_TOTAL_NUMBER_OF_PROCESSES =>
4349 M_TOTAL_NUMBER_OF_PROCESSES ,
4350 P_PROC_CERTIFIED_WITH_ISSUES =>
4351 M_PROC_CERTIFIED_WITH_ISSUES ,
4352 P_PROC_VERIFIED =>
4353 M_PROC_VERIFIED ,
4354 P_org_with_ineffective_ctrls =>
4355 M_org_with_ineffective_ctrls ,
4356 P_org_certified =>
4357 M_org_certified ,
4358 P_proc_with_ineffective_ctrls =>
4359 M_proc_with_ineffective_ctrls,
4360 P_unmitigated_risks =>
4361 M_unmitigated_risks ,
4362 P_risks_verified =>
4363 M_risks_verified ,
4364 P_ineffective_controls =>
4365 M_ineffective_controls ,
4366 P_controls_verified =>
4367 M_controls_verified ,
4368 P_open_issues =>
4369 M_open_issues ,
4370 P_PRO_PENDING_CERT_PRCNT =>
4371 M_PRO_PENDING_CERT_PRCNT ,
4372 P_PROCESSES_WITH_ISSUES_PRCNT =>
4373 M_PROCESSES_WITH_ISSUES_PRCNT,
4374 P_ORG_WITH_INEFF_CTRLS_PRCNT =>
4375 M_ORG_WITH_INEFF_CTRLS_PRCNT ,
4376 P_PROC_WITH_INEFF_CTRLS_PRCNT =>
4377 M_PROC_WITH_INEFF_CTRLS_PRCNT,
4378 P_UNMITIGATED_RISKS_PRCNT =>
4379 M_UNMITIGATED_RISKS_PRCNT ,
4380 P_INEFFECTIVE_CONTROLS_PRCNT =>
4381 M_INEFFECTIVE_CONTROLS_PRCNT,
4382 P_START_DATE => M_START_DATE ,
4383 P_END_DATE => M_END_DATE,
4384 p_PROCS_FOR_CERT_DONE => M_PROCS_FOR_CERT_DONE ,
4385 p_org_evaluated => M_org_evaluated );
4386
4387
4388 if (m_TOTAL_NUMBER_OF_PROCESSES is not null and m_TOTAL_NUMBER_OF_PROCESSES <> 0) then
4389 M_PRO_PENDING_CERT_PRCNT := (m_PROC_PENDING_CERTIFICATION / m_TOTAL_NUMBER_OF_PROCESSES) * 100 ;
4390 end if;
4391
4392 /* if (m_PROCS_FOR_CERT_DONE is not null and m_PROCS_FOR_CERT_DONE <> 0) then
4393 M_PROCESSES_WITH_ISSUES_PRCNT := (m_PROC_CERTIFIED_WITH_ISSUES / m_PROCS_FOR_CERT_DONE ) * 100 ;
4394 end if; */
4395
4396 if (m_TOTAL_NUMBER_OF_PROCESSES is not null and m_TOTAL_NUMBER_OF_PROCESSES <> 0) then
4397 M_PROCESSES_WITH_ISSUES_PRCNT := (m_PROC_CERTIFIED_WITH_ISSUES / m_TOTAL_NUMBER_OF_PROCESSES) * 100 ;
4398 end if;
4399
4400 if (m_org_evaluated is not null and m_org_evaluated <> 0) then
4401 M_ORG_WITH_INEFF_CTRLS_PRCNT := (m_org_with_ineffective_ctrls / m_org_evaluated) * 100;
4402 end if;
4403
4404 /* if (m_PROC_VERIFIED is not null and m_PROC_VERIFIED <> 0) then
4405 M_PROC_WITH_INEFF_CTRLS_PRCNT := (m_proc_with_ineffective_ctrls / m_PROC_VERIFIED) * 100 ;
4406 end if;*/
4407
4408 if (m_TOTAL_NUMBER_OF_PROCESSES is not null and m_TOTAL_NUMBER_OF_PROCESSES <> 0) then
4409 M_PROC_WITH_INEFF_CTRLS_PRCNT := (m_proc_with_ineffective_ctrls / m_TOTAL_NUMBER_OF_PROCESSES ) * 100 ;
4410 end if;
4411
4412 if (m_risks_verified is not null and m_risks_verified <> 0) then
4413 M_UNMITIGATED_RISKS_PRCNT := (m_unmitigated_risks / m_risks_verified) * 100;
4414 end if;
4415 if (m_controls_verified is not null and m_controls_verified <> 0) then
4416 M_INEFFECTIVE_CONTROLS_PRCNT := (m_ineffective_controls / m_controls_verified) * 100;
4417 end if;
4418
4419 -- insert a KEY ACCOUNT record which will take care of all child accounts
4420
4421 AMW_FINSTMT_CERT_PVT.insert_fin_cert_eval_sum(
4422 X_FIN_CERTIFICATION_ID => M_CERTIFICATION_ID,
4423 X_FINANCIAL_STATEMENT_ID => M_FINANCIAL_STATEMENT_ID,
4424 X_FINANCIAL_ITEM_ID => M_FINANCIAL_ITEM_ID,
4425 X_ACCOUNT_GROUP_ID => M_ACCOUNT_GROUP_ID ,
4426 X_NATURAL_ACCOUNT_ID => M_NATURAL_ACCOUNT_ID_2,
4427 X_OBJECT_TYPE => 'ACCOUNT',
4428 X_PROC_PENDING_CERTIFICATION => M_PROC_PENDING_CERTIFICATION,
4429 X_TOTAL_NUMBER_OF_PROCESSES => M_TOTAL_NUMBER_OF_PROCESSES,
4430 X_PROC_CERTIFIED_WITH_ISSUES => M_PROC_CERTIFIED_WITH_ISSUES,
4431 -- X_PROC_VERIFIED => M_PROC_VERIFIED,
4432 X_PROCS_FOR_CERT_DONE => M_PROCS_FOR_CERT_DONE,
4433 x_proc_evaluated => M_PROC_VERIFIED,
4434 X_ORG_WITH_INEFFECTIVE_CTRLS => M_org_with_ineffective_ctrls,
4435 --X_ORG_CERTIFIED => M_org_certified,
4436 x_orgs_FOR_CERT_DONE => M_org_certified,
4437 x_orgs_evaluated => M_org_evaluated,
4438 X_PROC_WITH_INEFFECTIVE_CTRLS => M_proc_with_ineffective_ctrls,
4439 X_UNMITIGATED_RISKS => M_unmitigated_risks,
4440 X_RISKS_VERIFIED => M_risks_verified,
4441 X_INEFFECTIVE_CONTROLS => M_ineffective_controls,
4442 X_CONTROLS_VERIFIED => M_controls_verified,
4443 X_OPEN_ISSUES => M_open_issues,
4444 X_PRO_PENDING_CERT_PRCNT => M_PRO_PENDING_CERT_PRCNT,
4445 X_PROCESSES_WITH_ISSUES_PRCNT => M_PROCESSES_WITH_ISSUES_PRCNT,
4446 X_ORG_WITH_INEFF_CTRLS_PRCNT => M_ORG_WITH_INEFF_CTRLS_PRCNT,
4447 X_PROC_WITH_INEFF_CTRLS_PRCNT => M_PROC_WITH_INEFF_CTRLS_PRCNT,
4448 X_UNMITIGATED_RISKS_PRCNT => M_UNMITIGATED_RISKS_PRCNT,
4449 X_INEFFECTIVE_CTRLS_PRCNT => M_INEFFECTIVE_CONTROLS_PRCNT,
4450 X_OBJ_CONTEXT => NULL,
4451 X_CREATED_BY => g_user_id,
4452 X_CREATION_DATE => SYSDATE,
4453 X_LAST_UPDATED_BY => g_user_id,
4454 X_LAST_UPDATE_DATE => SYSDATE,
4455 X_LAST_UPDATE_LOGIN => g_login_id,
4456 X_SECURITY_GROUP_ID => NULL,
4457 X_OBJECT_VERSION_NUMBER => NULL);
4458
4459
4460
4461 end loop;
4462
4463 END IF;--If condition to check if M_TOTAL_NUMBER_OF_PROCESSES is = 0 or null
4464
4465 end if;
4466
4467 end;
4468 EXCEPTION WHEN OTHERS THEN
4469 fnd_file.put_line(fnd_file.LOG, SUBSTR (SQLERRM, 1, 2000));
4470 --dbms_output.put_line(SQLERRM);
4471 g_errbuf := SUBSTR (SQLERRM, 1, 2000) ;
4472 g_retcode := '2';
4473
4474 RAISE ;
4475 RETURN;
4476
4477
4478 END compute_values_for_eval_sum;
4479 ----------------------------- ********************************** ----------------------
4480 procedure insert_fin_cert_eval_sum(
4481 X_FIN_CERTIFICATION_ID IN NUMBER,
4482 X_FINANCIAL_STATEMENT_ID IN NUMBER,
4483 X_FINANCIAL_ITEM_ID IN NUMBER,
4484 X_ACCOUNT_GROUP_ID IN NUMBER,
4485 X_NATURAL_ACCOUNT_ID IN NUMBER,
4486 X_OBJECT_TYPE IN VARCHAR,
4487 X_PROC_PENDING_CERTIFICATION IN NUMBER,
4488 X_TOTAL_NUMBER_OF_PROCESSES IN NUMBER,
4489 X_PROC_CERTIFIED_WITH_ISSUES IN NUMBER,
4490 X_PROCS_FOR_CERT_DONE IN NUMBER,
4491 x_proc_evaluated IN NUMBER,
4492 X_ORG_WITH_INEFFECTIVE_CTRLS IN NUMBER,
4493 -- X_ORG_CERTIFIED IN NUMBER,
4494 x_orgs_FOR_CERT_DONE IN NUMBER,
4495 x_orgs_evaluated IN NUMBER,
4496 X_PROC_WITH_INEFFECTIVE_CTRLS IN NUMBER,
4497 X_UNMITIGATED_RISKS IN NUMBER,
4498 X_RISKS_VERIFIED IN NUMBER,
4499 X_INEFFECTIVE_CONTROLS IN NUMBER,
4500 X_CONTROLS_VERIFIED IN NUMBER,
4501 X_OPEN_ISSUES IN NUMBER,
4502 X_PRO_PENDING_CERT_PRCNT IN NUMBER,
4503 X_PROCESSES_WITH_ISSUES_PRCNT IN NUMBER,
4504 X_ORG_WITH_INEFF_CTRLS_PRCNT IN NUMBER,
4505 X_PROC_WITH_INEFF_CTRLS_PRCNT IN NUMBER,
4506 X_UNMITIGATED_RISKS_PRCNT IN NUMBER,
4507 X_INEFFECTIVE_CTRLS_PRCNT IN NUMBER,
4508 X_OBJ_CONTEXT IN NUMBER,
4509 X_CREATED_BY IN NUMBER,
4510 X_CREATION_DATE IN DATE,
4511 X_LAST_UPDATED_BY IN NUMBER,
4512 X_LAST_UPDATE_DATE IN DATE,
4513 X_LAST_UPDATE_LOGIN IN NUMBER,
4514 X_SECURITY_GROUP_ID IN NUMBER,
4515 X_OBJECT_VERSION_NUMBER IN NUMBER
4516 )
4517 IS begin
4518
4519 DECLARE
4520 M_COUNT NUMBER := 0;
4521 begin
4522 SELECT COUNT(1) INTO M_COUNT FROM amw_fin_cert_eval_sum
4523 WHERE FIN_CERTIFICATION_ID = X_FIN_CERTIFICATION_ID
4524 AND FINANCIAL_STATEMENT_ID = X_FINANCIAL_STATEMENT_ID
4525 AND NVL(FINANCIAL_ITEM_ID,0) = NVL(X_FINANCIAL_ITEM_ID,0)
4526 AND NVL(NATURAL_ACCOUNT_ID,0) = NVL(X_NATURAL_ACCOUNT_ID,0)
4527 AND NVL(ACCOUNT_GROUP_ID,0) = NVL(X_ACCOUNT_GROUP_ID,0)
4528 AND OBJECT_TYPE = X_OBJECT_TYPE;
4529
4530
4531 IF (M_COUNT is null or M_COUNT = 0) then
4532 insert into amw_fin_cert_eval_sum(
4533 FIN_CERTIFICATION_ID ,
4534 FINANCIAL_STATEMENT_ID ,
4535 FINANCIAL_ITEM_ID ,
4536 NATURAL_ACCOUNT_ID ,
4537 ACCOUNT_GROUP_ID ,
4538 OBJECT_TYPE ,
4539 PROC_PENDING_CERTIFICATION ,
4540 TOTAL_NUMBER_OF_PROCESSES ,
4541 PROC_CERTIFIED_WITH_ISSUES ,
4542 PROCS_FOR_CERT_DONE ,
4543 proc_evaluated ,
4544 ORG_WITH_INEFFECTIVE_CONTROLS ,
4545 orgs_FOR_CERT_DONE ,
4546 --org_certified ,
4547 orgs_evaluated ,
4548 PROC_WITH_INEFFECTIVE_CONTROLS ,
4549 UNMITIGATED_RISKS ,
4550 RISKS_VERIFIED ,
4551 INEFFECTIVE_CONTROLS ,
4552 CONTROLS_VERIFIED ,
4553 OPEN_ISSUES ,
4554 PRO_PENDING_CERT_PRCNT ,
4555 PROCESSES_WITH_ISSUES_PRCNT ,
4556 ORG_WITH_INEFF_CONTROLS_PRCNT ,
4557 PROC_WITH_INEFF_CONTROLS_PRCNT ,
4558 UNMITIGATED_RISKS_PRCNT ,
4559 INEFFECTIVE_CONTROLS_PRCNT ,
4560 OBJ_CONTEXT ,
4561 CREATED_BY ,
4562 CREATION_DATE ,
4563 LAST_UPDATED_BY ,
4564 LAST_UPDATE_DATE ,
4565 LAST_UPDATE_LOGIN ,
4566 SECURITY_GROUP_ID ,
4567 OBJECT_VERSION_NUMBER )
4568 values
4569 (
4570 X_FIN_CERTIFICATION_ID,
4571 X_FINANCIAL_STATEMENT_ID,
4572 X_FINANCIAL_ITEM_ID ,
4573 X_NATURAL_ACCOUNT_ID ,
4574 X_ACCOUNT_GROUP_ID ,
4575 X_OBJECT_TYPE ,
4576 X_PROC_PENDING_CERTIFICATION,
4577 X_TOTAL_NUMBER_OF_PROCESSES ,
4578 X_PROC_CERTIFIED_WITH_ISSUES,
4579 X_TOTAL_NUMBER_OF_PROCESSES ,
4580 -- X_PROCS_FOR_CERT_DONE -- was replaced by total processes,
4581 X_TOTAL_NUMBER_OF_PROCESSES , --x_proc_evaluated was commented as the denominator
4582 --for Proc with Ineffective Ctrl became total processes
4583 --x_proc_evaluated ,
4584 -- X_PROC_VERIFIED not used ,
4585 X_ORG_WITH_INEFFECTIVE_CTRLS,
4586 --X_ORG_CERTIFIED ,
4587 x_orgs_FOR_CERT_DONE ,
4588 x_orgs_evaluated ,
4589 X_PROC_WITH_INEFFECTIVE_CTRLS,
4590 X_UNMITIGATED_RISKS ,
4591 X_RISKS_VERIFIED ,
4592 X_INEFFECTIVE_CONTROLS ,
4593 X_CONTROLS_VERIFIED ,
4594 X_OPEN_ISSUES ,
4595 round(X_PRO_PENDING_CERT_PRCNT) ,
4596 round(X_PROCESSES_WITH_ISSUES_PRCNT),
4597 round(X_ORG_WITH_INEFF_CTRLS_PRCNT) ,
4598 round(X_PROC_WITH_INEFF_CTRLS_PRCNT),
4599 round(X_UNMITIGATED_RISKS_PRCNT) ,
4600 round(X_INEFFECTIVE_CTRLS_PRCNT) ,
4601 X_OBJ_CONTEXT ,
4602 X_CREATED_BY ,
4603 X_CREATION_DATE ,
4604 X_LAST_UPDATED_BY ,
4605 X_LAST_UPDATE_DATE ,
4606 X_LAST_UPDATE_LOGIN ,
4607 X_SECURITY_GROUP_ID ,
4608 X_OBJECT_VERSION_NUMBER
4609 );
4610
4611 else -- update
4612
4613 update amw_fin_cert_eval_sum set
4614 FIN_CERTIFICATION_ID
4615 = X_FIN_CERTIFICATION_ID,
4616 FINANCIAL_STATEMENT_ID
4617 = X_FINANCIAL_STATEMENT_ID,
4618 FINANCIAL_ITEM_ID
4619 = X_FINANCIAL_ITEM_ID ,
4620 NATURAL_ACCOUNT_ID
4621 = X_NATURAL_ACCOUNT_ID,
4622 ACCOUNT_GROUP_ID
4623 = X_ACCOUNT_GROUP_ID ,
4624 OBJECT_TYPE
4625 = X_OBJECT_TYPE ,
4626 PROC_PENDING_CERTIFICATION
4627 = X_PROC_PENDING_CERTIFICATION,
4628 TOTAL_NUMBER_OF_PROCESSES
4629 = X_TOTAL_NUMBER_OF_PROCESSES,
4630 PROC_CERTIFIED_WITH_ISSUES
4631 = X_PROC_CERTIFIED_WITH_ISSUES,
4632 PROCS_FOR_CERT_DONE
4633 = X_TOTAL_NUMBER_OF_PROCESSES ,
4634 -- X_PROCS_FOR_CERT_DONE -- was replaced by total processes,
4635 -- = X_PROCS_FOR_CERT_DONE ,
4636 proc_evaluated
4637 = X_TOTAL_NUMBER_OF_PROCESSES , --x_proc_evaluated was commented as the denominator
4638 --for Proc with Ineffective Ctrl became total processes
4639 ----- = X_proc_evaluated ,
4640 ORG_WITH_INEFFECTIVE_CONTROLS
4641 = X_ORG_WITH_INEFFECTIVE_CTRLS,
4642 orgs_FOR_CERT_DONE
4643 = X_orgs_FOR_CERT_DONE ,
4644 orgs_evaluated
4645 = X_orgs_evaluated ,
4646 PROC_WITH_INEFFECTIVE_CONTROLS
4647 = X_PROC_WITH_INEFFECTIVE_CTRLS,
4648 UNMITIGATED_RISKS
4649 = X_UNMITIGATED_RISKS ,
4650 RISKS_VERIFIED
4651 = X_RISKS_VERIFIED ,
4652 INEFFECTIVE_CONTROLS
4653 = X_INEFFECTIVE_CONTROLS,
4654 CONTROLS_VERIFIED
4655 = X_CONTROLS_VERIFIED ,
4656 OPEN_ISSUES
4657 = X_OPEN_ISSUES ,
4658 PRO_PENDING_CERT_PRCNT
4659 = round(X_PRO_PENDING_CERT_PRCNT),
4660 PROCESSES_WITH_ISSUES_PRCNT
4661 = round(X_PROCESSES_WITH_ISSUES_PRCNT),
4662 ORG_WITH_INEFF_CONTROLS_PRCNT
4663 = round(X_ORG_WITH_INEFF_CTRLS_PRCNT) ,
4664 PROC_WITH_INEFF_CONTROLS_PRCNT
4665 = round(X_PROC_WITH_INEFF_CTRLS_PRCNT),
4666 UNMITIGATED_RISKS_PRCNT
4667 = round(X_UNMITIGATED_RISKS_PRCNT) ,
4668 INEFFECTIVE_CONTROLS_PRCNT
4669 = round(X_INEFFECTIVE_CTRLS_PRCNT) ,
4670 OBJ_CONTEXT
4671 = X_OBJ_CONTEXT ,
4672 CREATED_BY
4673 = X_CREATED_BY ,
4674 CREATION_DATE
4675 = X_CREATION_DATE ,
4676 LAST_UPDATED_BY
4677 = X_LAST_UPDATED_BY ,
4678 LAST_UPDATE_DATE
4679 = X_LAST_UPDATE_DATE ,
4680 LAST_UPDATE_LOGIN
4681 = X_LAST_UPDATE_LOGIN ,
4682 SECURITY_GROUP_ID
4683 = X_SECURITY_GROUP_ID ,
4684 OBJECT_VERSION_NUMBER
4685 = X_OBJECT_VERSION_NUMBER
4686 WHERE FIN_CERTIFICATION_ID = X_FIN_CERTIFICATION_ID
4687 AND FINANCIAL_STATEMENT_ID = X_FINANCIAL_STATEMENT_ID
4688 AND NVL(FINANCIAL_ITEM_ID,0) = NVL(X_FINANCIAL_ITEM_ID,0)
4689 AND NVL(NATURAL_ACCOUNT_ID,0) = NVL(X_NATURAL_ACCOUNT_ID,0)
4690 AND NVL(ACCOUNT_GROUP_ID,0) = NVL(X_ACCOUNT_GROUP_ID,0)
4691 AND OBJECT_TYPE = X_OBJECT_TYPE;
4692 end if;
4693 end;
4694 EXCEPTION WHEN OTHERS THEN
4695 fnd_file.put_line(fnd_file.LOG, SUBSTR (SQLERRM, 1, 2000));
4696 -- dbms_output.put_line(SQLERRM);
4697 g_errbuf := SUBSTR (SQLERRM, 1, 2000) ;
4698 g_retcode := '2';
4699
4700 RAISE ;
4701 RETURN;
4702
4703
4704 END insert_fin_cert_eval_sum;
4705 --------------------------------------- ******************************** ----------------------------
4706 Procedure GetGLPeriodfor_FinCertEvalSum(P_Certification_ID in number, P_start_date out NOCOPY date, P_end_date out NOCOPY date)
4707 is
4708 begin
4709 Select
4710 GL_PERIODS.START_DATE ,
4711 GL_PERIODS.END_DATE
4712 into P_start_date, P_end_Date
4713 from
4714 AMW_CERTIFICATION_VL CERTIFICATION,
4715 amw_gl_periods_v GL_PERIODS
4716 WHERE
4717 GL_PERIODS.PERIOD_NAME = CERTIFICATION.CERTIFICATION_PERIOD_NAME
4718 AND GL_PERIODS.PERIOD_SET_NAME = CERTIFICATION.CERTIFICATION_PERIOD_SET_NAME
4719 and CERTIFICATION.OBJECT_TYPE='FIN_STMT'
4720 AND CERTIFICATION.CERTIFICATION_ID = P_Certification_ID;
4721 -- AND GL_PERIODS.PERIOD_SET_NAME = fnd_profile.value('AMW_CALENDAR') ;
4722
4723 EXCEPTION
4724 WHEN NO_DATA_FOUND
4725 THEN
4726 fnd_file.put_line(fnd_file.LOG, SUBSTR (SQLERRM, 1, 2000));
4727
4728 g_errbuf := SUBSTR (SQLERRM, 1, 2000) ;
4729 g_retcode := '2';
4730
4731 RAISE ;
4732 RETURN;
4733
4734 WHEN OTHERS then
4735
4736 fnd_file.put_line(fnd_file.LOG, SUBSTR (SQLERRM, 1, 2000));
4737 -- dbms_output.put_line(SQLERRM);
4738 g_errbuf := SUBSTR (SQLERRM, 1, 2000) ;
4739 g_retcode := '2';
4740
4741 RAISE ;
4742 RETURN;
4743
4744 END GetGLPeriodfor_FinCertEvalSum;
4745
4746 --------------------------------------- ******************************** ----------------------------
4747 Procedure GetTotalProcesses_for_account(P_NATURAL_ACCOUNT_ID in number, P_account_group_id in number,
4748 P_TOTAL_NUMBER_OF_PROCESSES OUT NOCOPY number)
4749
4750 ---- ********************************* Modified on 1/31/04 by knair ---------------------------------
4751 -- Based on the Natural Account ID Passed Computes total number of all the Processes and the child-processes of these
4752 --- Processes that are associated to that Natural Account and its sub-accounts
4753 ---***************************************************************************************************
4754 is
4755 begin
4756 declare
4757 m_Total_Number_of_Processes number := 0;
4758 begin
4759
4760 Select
4761 Count(1) into P_TOTAL_NUMBER_OF_PROCESSES from
4762 (select distinct procRln.ORGANIZATION_ID ,procRln.CHILD_PROCESS_ID from Amw_Process_Org_Relations procRln
4763 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
4764 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
4765 Amw_acct_associations AccProcs where AccProcs .object_type = 'PROCESS_ORG' and
4766 AccProcs .pk1= orgprocess2.PROCESS_ORGANIZATION_ID
4767 and AccProcs.natural_account_id in
4768 --(select
4769 -- distinct(acc.natural_account_id)
4770 -- from AMW_FIN_KEY_ACCOUNTS_B acc
4771 -- START WITH acc.natural_account_id = P_NATURAL_ACCOUNT_ID
4772 -- and acc.account_group_id = P_account_group_id
4773 --CONNECT BY PRIOR
4774 -- acc.natural_account_id = acc.parent_natural_account_id
4775 -- and PRIOR
4776 --acc.account_group_id = acc.account_group_id)
4777
4778 ( select distinct acc.child_natural_account_id
4779 from AMW_FIN_KEY_ACCT_FLAT acc
4780 where acc.parent_natural_account_id = p_natural_account_id
4781 and acc.account_group_id = p_account_group_id
4782 union
4783 select distinct acc.natural_account_id
4784 from amw_fin_key_accounts_b acc
4785 where acc.natural_account_id = p_natural_account_id
4786 and acc.account_group_id = p_account_group_id
4787 )
4788
4789 ))
4790 CONNECT BY PRIOR
4791 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
4792 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID);
4793
4794 end;
4795 end GetTotalProcesses_for_account;
4796 -------------------------------------------- *********************** --------------------------------
4797 Procedure CountProcsCertRecorded_Accnts(P_NATURAL_ACCOUNT_ID in number, P_account_group_id in number,
4798 P_PROCS_IN_CERTIFICATION OUT NOCOPY Number,
4799 p_start_date in date, p_end_date in date, p_fin_cert_id in number)
4800
4801 is
4802 begin
4803
4804 --******************* Last Modified on 1/31/04 by knair *********************************************
4805 -- Based on the Natural Account ID Passed Computed the Number Processes and the child-processes of
4806 -- these Processes, for which Certifications (which are associated to the current Financial Certification,
4807 -- was recorded , that are associated to that Natural Account and its sub-accounts
4808 --***************************************************************************************************
4809 Select
4810 count(1) into P_PROCS_IN_CERTIFICATION
4811 from
4812 (
4813 Select distinct orgprocess.PROCESS_ID, orgprocess.ORGANIZATION_ID
4814 FROM
4815 AMW_OPINIONS_V opinion,
4816 AMW_OPINION_TYPES_B opiniontype,
4817 FND_OBJECTS fndobject,
4818 AMW_OBJECT_OPINION_TYPES objectopiniontype,
4819 amw_process_org_basicinfo_v orgprocess
4820 WHERE
4821 opinion.OBJECT_OPINION_TYPE_ID = objectopiniontype.OBJECT_OPINION_TYPE_ID AND
4822 opiniontype.OPINION_TYPE_ID = objectopiniontype.OPINION_TYPE_ID AND
4823 opiniontype.OPINION_TYPE_CODE = 'CERTIFICATION' AND
4824 fndobject.OBJECT_ID = objectopiniontype.OBJECT_ID AND
4825 fndobject.obj_name = 'AMW_ORG_PROCESS'
4826 and opinion.PK2_VALUE in (select PROC_CERT_ID from AMW_FIN_PROC_CERT_RELAN where FIN_STMT_CERT_ID = p_fin_cert_id)
4827 and (opinion.PK3_VALUE = orgprocess.ORGANIZATION_ID
4828 and opinion.PK1_VALUE = orgprocess.PROCESS_ID)
4829 and ( orgprocess.ORGANIZATION_ID , orgprocess.PROCESS_ID )
4830 in
4831 (select procRln.ORGANIZATION_ID ,procRln.CHILD_PROCESS_ID from Amw_Process_Org_Relations procRln
4832 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
4833 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
4834 Amw_acct_associations AccProcs where AccProcs .object_type = 'PROCESS_ORG' and
4835 AccProcs .pk1= orgprocess2.PROCESS_ORGANIZATION_ID
4836 and AccProcs.natural_account_id in
4837 -- (select
4838 -- distinct(acc.natural_account_id)
4839 -- from AMW_FIN_KEY_ACCOUNTS_B acc
4840 -- START WITH acc.natural_account_id = P_NATURAL_ACCOUNT_ID
4841 -- and acc.account_group_id = P_account_group_id
4842 --CONNECT BY PRIOR
4843 -- acc.natural_account_id = acc.parent_natural_account_id
4844 -- and PRIOR
4845 --acc.account_group_id = acc.account_group_id)
4846
4847 ( select distinct acc.child_natural_account_id
4848 from AMW_FIN_KEY_ACCT_FLAT acc
4849 where acc.parent_natural_account_id = p_natural_account_id
4850 and acc.account_group_id = p_account_group_id
4851 union
4852 select distinct acc.natural_account_id
4853 from amw_fin_key_accounts_b acc
4854 where acc.natural_account_id = p_natural_account_id
4855 and acc.account_group_id = p_account_group_id
4856 )
4857
4858 ))
4859 CONNECT BY PRIOR
4860 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
4861 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID)
4862 );
4863
4864 END CountProcsCertRecorded_Accnts;
4865
4866 -------------------------------------------- *********************** --------------------------------
4867 Procedure CountProcswithIssues_Accounts(P_NATURAL_ACCOUNT_ID in number, P_account_group_id in number, P_PROC_CERTIFIED_WITH_ISSUES OUT NOCOPY Number,
4868 p_start_date in date, p_end_date in date, p_fin_cert_id in number) is
4869
4870 --******************* Last Modified on 1/31/04 by knair ---------------------------------------
4871 -- Based on the Natural Account ID Passed Computed the Number Processes and the child-processes
4872 -- of these Processes, for which Certifications (the certification that are associated to the financial
4873 --- certification) with a Not Effective type result was recorded during
4874 -- the given period, that are associated to that Natural Account and its sub-accounts
4875 --************************************************************************************************
4876
4877 begin
4878 Select
4879 count(1) INTO P_PROC_CERTIFIED_WITH_ISSUES
4880 from
4881 (
4882 Select distinct orgprocess.PROCESS_ID, orgprocess.ORGANIZATION_ID
4883 FROM
4884 AMW_OPINIONS_V opinion,
4885 AMW_OPINION_TYPES_B opiniontype,
4886 FND_OBJECTS fndobject,
4887 AMW_OBJECT_OPINION_TYPES objectopiniontype,
4888 amw_process_org_basicinfo_v orgprocess
4889 WHERE
4890 (opinion.AUTHORED_DATE in
4891 (Select
4892 MAX(opinion2.AUTHORED_DATE)
4893 from
4894 AMW_OPINIONS_V opinion2
4895 where
4896 opinion.OBJECT_OPINION_TYPE_ID = opinion2.OBJECT_OPINION_TYPE_ID
4897 and opinion2.PK2_VALUE in
4898 (select PROC_CERT_ID from AMW_FIN_PROC_CERT_RELAN where FIN_STMT_CERT_ID = p_fin_cert_id) and
4899 opinion2.PK1_VALUE = opinion.PK1_VALUE and
4900 opinion2.PK3_VALUE = opinion.PK3_VALUE
4901 ) AND
4902 opinion.OBJECT_OPINION_TYPE_ID = objectopiniontype.OBJECT_OPINION_TYPE_ID AND
4903 opiniontype.OPINION_TYPE_ID = objectopiniontype.OPINION_TYPE_ID AND
4904 opiniontype.OPINION_TYPE_CODE = 'CERTIFICATION' AND
4905 fndobject.OBJECT_ID = objectopiniontype.OBJECT_ID AND
4906 fndobject.obj_name = 'AMW_ORG_PROCESS' and
4907 opinion.audit_result_CODE <> 'EFFECTIVE')
4908 and opinion.PK2_VALUE in
4909 (select PROC_CERT_ID from AMW_FIN_PROC_CERT_RELAN where FIN_STMT_CERT_ID = p_fin_cert_id)
4910 and (opinion.PK3_VALUE = orgprocess.ORGANIZATION_ID
4911 and opinion.PK1_VALUE = orgprocess.PROCESS_ID)
4912 and ( orgprocess.ORGANIZATION_ID , orgprocess.PROCESS_ID )
4913 in
4914 (select procRln.ORGANIZATION_ID ,procRln.CHILD_PROCESS_ID from Amw_Process_Org_Relations procRln
4915 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
4916 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
4917 Amw_acct_associations AccProcs where AccProcs .object_type = 'PROCESS_ORG' and
4918 AccProcs .pk1= orgprocess2.PROCESS_ORGANIZATION_ID
4919 and AccProcs.natural_account_id in
4920 -- (select
4921 -- distinct(acc.natural_account_id)
4922 -- from AMW_FIN_KEY_ACCOUNTS_B acc
4923 -- START WITH acc.natural_account_id = P_NATURAL_ACCOUNT_ID
4924 -- and acc.account_group_id = P_account_group_id
4925 --CONNECT BY PRIOR
4926 -- acc.natural_account_id = acc.parent_natural_account_id
4927 -- and PRIOR
4928 --acc.account_group_id = acc.account_group_id)
4929
4930 ( select distinct acc.child_natural_account_id
4931 from AMW_FIN_KEY_ACCT_FLAT acc
4932 where acc.parent_natural_account_id = p_natural_account_id
4933 and acc.account_group_id = p_account_group_id
4934 union
4935 select distinct acc.natural_account_id
4936 from amw_fin_key_accounts_b acc
4937 where acc.natural_account_id = p_natural_account_id
4938 and acc.account_group_id = p_account_group_id
4939 )
4940
4941 ))
4942 CONNECT BY PRIOR
4943 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
4944 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID)
4945 );
4946
4947 END CountProcswithIssues_Accounts;
4948
4949 -------------------------------------------- *********************** --------------------------------
4950 Procedure CountOrgsIneffCtrl_Accounts(P_NATURAL_ACCOUNT_ID in number,P_account_group_id in number,P_org_with_ineffective_ctrls OUT NOCOPY Number,
4951 p_start_date in date, p_end_date in date) is
4952
4953 --******************* Last Modified on 1/31/04 by knair ---------------------------------------
4954 -- Based on the Natural Account ID Passed Computes the Organization, for which a Evaluation
4955 -- (Means Not Effective Result) was recorded during the given period, that are associated to that
4956 -- Natural Account and its sub-accounts
4957 --******************* ****************************************************************************
4958
4959 begin
4960 Select
4961 count(1) into P_org_with_ineffective_ctrls
4962 from (
4963 select distinct orgprocess.ORGANIZATION_ID
4964 FROM
4965 AMW_OPINIONS_V opinion,
4966 AMW_OPINION_TYPES_B opiniontype,
4967 FND_OBJECTS fndobject,
4968 AMW_OBJECT_OPINION_TYPES objectopiniontype,
4969 amw_process_org_basicinfo_v orgprocess
4970 WHERE
4971 (opinion.AUTHORED_DATE in
4972 (Select
4973 MAX(opinion2.AUTHORED_DATE)
4974 from
4975 AMW_OPINIONS_V opinion2
4976 where
4977 opinion.OBJECT_OPINION_TYPE_ID = opinion2.OBJECT_OPINION_TYPE_ID AND
4978 opinion2.PK1_VALUE = opinion.PK1_VALUE
4979 --- Commented chekcing whether the opinion date falls within the period as
4980 --- per discussion with Say and Bastin on 2/9/04
4981 ---AND
4982 ---- opinion2.AUTHORED_DATE >= p_start_date and
4983 -- opinion2.AUTHORED_DATE <= p_end_date
4984 ) AND
4985 opinion.OBJECT_OPINION_TYPE_ID = objectopiniontype.OBJECT_OPINION_TYPE_ID AND
4986 opiniontype.OPINION_TYPE_ID = objectopiniontype.OPINION_TYPE_ID AND
4987 opiniontype.OPINION_TYPE_CODE = 'EVALUATION' AND
4988 fndobject.OBJECT_ID = objectopiniontype.OBJECT_ID AND
4989 fndobject.obj_name = 'AMW_ORGANIZATION'
4990 and opinion.audit_result_CODE <> 'EFFECTIVE'
4991 )
4992 and opinion.PK1_VALUE = orgprocess.ORGANIZATION_ID
4993 and orgprocess.ORGANIZATION_ID
4994 in
4995 (select procRln.ORGANIZATION_ID from Amw_Process_Org_Relations procRln
4996 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
4997 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
4998 Amw_acct_associations AccProcs where AccProcs .object_type = 'PROCESS_ORG' and
4999 AccProcs .pk1= orgprocess2.PROCESS_ORGANIZATION_ID
5000 and AccProcs.natural_account_id in
5001 -- (select
5002 -- distinct(acc.natural_account_id)
5003 -- from AMW_FIN_KEY_ACCOUNTS_B acc
5004 -- START WITH acc.natural_account_id = P_NATURAL_ACCOUNT_ID
5005 -- and acc.account_group_id = P_account_group_id
5006 --CONNECT BY PRIOR
5007 -- acc.natural_account_id = acc.parent_natural_account_id
5008 -- and PRIOR
5009 --acc.account_group_id = acc.account_group_id)
5010
5011 ( select distinct acc.child_natural_account_id
5012 from AMW_FIN_KEY_ACCT_FLAT acc
5013 where acc.parent_natural_account_id = p_natural_account_id
5014 and acc.account_group_id = p_account_group_id
5015 union
5016 select distinct acc.natural_account_id
5017 from amw_fin_key_accounts_b acc
5018 where acc.natural_account_id = p_natural_account_id
5019 and acc.account_group_id = p_account_group_id
5020 )
5021
5022 ))
5023 CONNECT BY PRIOR
5024 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
5025 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID)
5026 );
5027 End CountOrgsIneffCtrl_Accounts;
5028 --------------------------------------- ********************************--------------------------------------
5029 Procedure CountOrgswithIssues_Accounts(P_NATURAL_ACCOUNT_ID in number, P_account_group_id in number, P_org_cert_with_issues OUT NOCOPY Number,
5030 p_start_date in date, p_end_date in date) is
5031
5032 --******************* Last Modified on 1/31/04 by knair ---------------------------------------
5033 -- Based on the Natural Account ID Passed Computes the Organization, for which a Certification with Not
5034 -- Effective result was recorded during the given period, that are associated to that
5035 -- Natural Account and its sub-accounts
5036 --******************* ****************************************************************************
5037
5038 begin
5039 Select
5040 count(1) into P_org_cert_with_issues
5041 from
5042 (
5043 select distinct orgprocess.ORGANIZATION_ID
5044 FROM
5045 AMW_OPINIONS_V opinion,
5046 AMW_OPINION_TYPES_B opiniontype,
5047 FND_OBJECTS fndobject,
5048 AMW_OBJECT_OPINION_TYPES objectopiniontype,
5049 amw_process_org_basicinfo_v orgprocess
5050 WHERE
5051 (opinion.AUTHORED_DATE in
5052 (Select
5053 MAX(opinion2.AUTHORED_DATE)
5054 from
5055 AMW_OPINIONS_V opinion2
5056 where
5057 opinion.OBJECT_OPINION_TYPE_ID = opinion2.OBJECT_OPINION_TYPE_ID AND
5058 opinion2.PK1_VALUE = opinion.PK1_VALUE AND
5059 opinion2.AUTHORED_DATE >= p_start_date and
5060 opinion2.AUTHORED_DATE <= p_end_date
5061 ) AND
5062 opinion.OBJECT_OPINION_TYPE_ID = objectopiniontype.OBJECT_OPINION_TYPE_ID AND
5063 opiniontype.OPINION_TYPE_ID = objectopiniontype.OPINION_TYPE_ID AND
5064 opiniontype.OPINION_TYPE_CODE = 'CERTIFICATION' AND
5065 fndobject.OBJECT_ID = objectopiniontype.OBJECT_ID AND
5066 fndobject.obj_name = 'AMW_ORGANIZATION'
5067 and opinion.audit_result_CODE <> 'EFFECTIVE'
5068 )
5069 and opinion.PK1_VALUE = orgprocess.ORGANIZATION_ID
5070 and orgprocess.ORGANIZATION_ID
5071 in
5072 (select procRln.ORGANIZATION_ID from Amw_Process_Org_Relations procRln
5073 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
5074 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
5075 Amw_acct_associations AccProcs where AccProcs .object_type = 'PROCESS_ORG' and
5076 AccProcs .pk1= orgprocess2.PROCESS_ORGANIZATION_ID
5077 and AccProcs.natural_account_id in
5078 -- (select
5079 -- distinct(acc.natural_account_id)
5080 -- from AMW_FIN_KEY_ACCOUNTS_B acc
5081 -- START WITH acc.natural_account_id = P_NATURAL_ACCOUNT_ID
5082 -- and acc.account_group_id = P_account_group_id
5083 --CONNECT BY PRIOR
5084 -- acc.natural_account_id = acc.parent_natural_account_id
5085 -- and PRIOR
5086 --acc.account_group_id = acc.account_group_id)
5087
5088 ( select distinct acc.child_natural_account_id
5089 from AMW_FIN_KEY_ACCT_FLAT acc
5090 where acc.parent_natural_account_id = p_natural_account_id
5091 and acc.account_group_id = p_account_group_id
5092 union
5093 select distinct acc.natural_account_id
5094 from amw_fin_key_accounts_b acc
5095 where acc.natural_account_id = p_natural_account_id
5096 and acc.account_group_id = p_account_group_id
5097 )
5098
5099 ))
5100 CONNECT BY PRIOR
5101 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
5102 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID)
5103 );
5104
5105 END CountOrgswithIssues_Accounts;
5106
5107 -------------------------------------- ******************************* --------------------------------------
5108 Procedure CountOrgsCertified_accounts(P_NATURAL_ACCOUNT_ID in number, P_account_group_id in number, P_org_certified OUT NOCOPY Number,
5109 p_start_date in date, p_end_date in date) is
5110
5111 --******************* Last Modified on 1/31/04 by knair ---------------------------------------
5112 -- Based on the Natural Account ID Passed Computes the Organization, for which a Certification
5113 -- was recorded during the given period (do not check result as it is the total number of orgs for which
5114 -- a certification was recorded, that are associated to that Natural Account and its sub-accounts
5115 --******************* ****************************************************************************
5116
5117
5118 begin
5119 Select
5120 count(1) into P_org_certified
5121 from
5122 (
5123 select distinct orgprocess.ORGANIZATION_ID
5124 FROM
5125 AMW_OPINIONS_V opinion,
5126 AMW_OPINION_TYPES_B opiniontype,
5127 FND_OBJECTS fndobject,
5128 AMW_OBJECT_OPINION_TYPES objectopiniontype,
5129 amw_process_org_basicinfo_v orgprocess
5130 WHERE
5131 (opinion.AUTHORED_DATE in
5132 (Select
5133 MAX(opinion2.AUTHORED_DATE)
5134 from
5135 AMW_OPINIONS_V opinion2
5136 where
5137 opinion.OBJECT_OPINION_TYPE_ID = opinion2.OBJECT_OPINION_TYPE_ID AND
5138 opinion2.PK1_VALUE = opinion.PK1_VALUE AND
5139 opinion2.AUTHORED_DATE >= p_start_date and
5140 opinion2.AUTHORED_DATE <= p_end_date
5141 ) AND
5142 opinion.OBJECT_OPINION_TYPE_ID = objectopiniontype.OBJECT_OPINION_TYPE_ID AND
5143 opiniontype.OPINION_TYPE_ID = objectopiniontype.OPINION_TYPE_ID AND
5144 opiniontype.OPINION_TYPE_CODE = 'CERTIFICATION' AND
5145 fndobject.OBJECT_ID = objectopiniontype.OBJECT_ID AND
5146 fndobject.obj_name = 'AMW_ORGANIZATION'
5147 )
5148 and opinion.PK1_VALUE = orgprocess.ORGANIZATION_ID
5149 and orgprocess.ORGANIZATION_ID
5150 in
5151 (select procRln.ORGANIZATION_ID from Amw_Process_Org_Relations procRln
5152 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
5153 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
5154 Amw_acct_associations AccProcs where AccProcs .object_type = 'PROCESS_ORG' and
5155 AccProcs .pk1= orgprocess2.PROCESS_ORGANIZATION_ID
5156 and AccProcs.natural_account_id in
5157 -- (select
5158 -- distinct(acc.natural_account_id)
5159 -- from AMW_FIN_KEY_ACCOUNTS_B acc
5160 -- START WITH acc.natural_account_id = P_NATURAL_ACCOUNT_ID
5161 -- and acc.account_group_id = P_account_group_id
5162 --CONNECT BY PRIOR
5163 -- acc.natural_account_id = acc.parent_natural_account_id
5164 -- and PRIOR
5165 --acc.account_group_id = acc.account_group_id)
5166
5167 ( select distinct acc.child_natural_account_id
5168 from AMW_FIN_KEY_ACCT_FLAT acc
5169 where acc.parent_natural_account_id = p_natural_account_id
5170 and acc.account_group_id = p_account_group_id
5171 union
5172 select distinct acc.natural_account_id
5173 from amw_fin_key_accounts_b acc
5174 where acc.natural_account_id = p_natural_account_id
5175 and acc.account_group_id = p_account_group_id
5176 )
5177
5178 ))
5179 CONNECT BY PRIOR
5180 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
5181 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID)
5182 );
5183
5184 END CountOrgsCertified_accounts;
5185 -------------------------------------- ******************************* --------------------------------------
5186 Procedure CountOrgsEvaluated_accounts(P_NATURAL_ACCOUNT_ID in number, P_account_group_id in number, P_org_evaluated OUT NOCOPY Number,
5187 p_start_date in date, p_end_date in date) is
5188
5189 --******************* Last Modified on 1/31/04 by knair ---------------------------------------
5190 -- the total number of orgs for which
5191 -- are associated to that Natural Account and its sub-accounts
5192 --******************* ****************************************************************************
5193 begin
5194
5195 Select
5196 Count(1)
5197 into P_org_evaluated
5198 from
5199 (select distinct procRln.ORGANIZATION_ID from Amw_Process_Org_Relations procRln
5200 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
5201 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
5202 Amw_acct_associations AccProcs where AccProcs .object_type = 'PROCESS_ORG' and
5203 AccProcs .pk1= orgprocess2.PROCESS_ORGANIZATION_ID
5204 and AccProcs.natural_account_id in
5205 -- (select
5206 -- distinct(acc.natural_account_id)
5207 -- from AMW_FIN_KEY_ACCOUNTS_B acc
5208 -- START WITH acc.natural_account_id = P_NATURAL_ACCOUNT_ID
5209 -- and acc.account_group_id = P_account_group_id
5210 --CONNECT BY PRIOR
5211 -- acc.natural_account_id = acc.parent_natural_account_id
5212 -- and PRIOR
5213 --acc.account_group_id = acc.account_group_id)
5214
5215 ( select distinct acc.child_natural_account_id
5216 from AMW_FIN_KEY_ACCT_FLAT acc
5217 where acc.parent_natural_account_id = p_natural_account_id
5218 and acc.account_group_id = p_account_group_id
5219 union
5220 select distinct acc.natural_account_id
5221 from amw_fin_key_accounts_b acc
5222 where acc.natural_account_id = p_natural_account_id
5223 and acc.account_group_id = p_account_group_id
5224 )
5225
5226 ))
5227 CONNECT BY PRIOR
5228 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
5229 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID);
5230
5231 /*---
5232 commented as the Denominbator for the "Org with Ineffective Control" columns is no longer the Total Orgs for which
5233 an evluation is made but it is the Total Orgs Attached to the Processes which in trun attached to the accounts
5234
5235 Select
5236 count(1) into P_org_evaluated
5237 from
5238 (
5239 select distinct orgprocess.ORGANIZATION_ID
5240 FROM
5241 AMW_OPINIONS_V opinion,
5242 AMW_OPINION_TYPES_B opiniontype,
5243 FND_OBJECTS fndobject,
5244 AMW_OBJECT_OPINION_TYPES objectopiniontype,
5245 amw_process_org_basicinfo_v orgprocess
5246 WHERE
5247 (opinion.AUTHORED_DATE in
5248 (Select
5249 MAX(opinion2.AUTHORED_DATE)
5250 from
5251 AMW_OPINIONS_V opinion2
5252 where
5253 opinion.OBJECT_OPINION_TYPE_ID = opinion2.OBJECT_OPINION_TYPE_ID AND
5254 opinion2.PK1_VALUE = opinion.PK1_VALUE AND
5255 ----- **** opinion2.AUTHORED_DATE >= p_start_date and
5256 opinion2.AUTHORED_DATE <= p_end_date
5257 ) AND
5258 opinion.OBJECT_OPINION_TYPE_ID = objectopiniontype.OBJECT_OPINION_TYPE_ID AND
5259 opiniontype.OPINION_TYPE_ID = objectopiniontype.OPINION_TYPE_ID AND
5260 opiniontype.OPINION_TYPE_CODE = 'EVALUATION' AND
5261 fndobject.OBJECT_ID = objectopiniontype.OBJECT_ID AND
5262 fndobject.obj_name = 'AMW_ORGANIZATION'
5263 )
5264 and opinion.PK1_VALUE = orgprocess.ORGANIZATION_ID
5265 and orgprocess.ORGANIZATION_ID
5266 in
5267 (select procRln.ORGANIZATION_ID from Amw_Process_Org_Relations procRln
5268 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
5269 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
5270 Amw_acct_associations AccProcs where AccProcs .object_type = 'PROCESS_ORG' and
5271 AccProcs .pk1= orgprocess2.PROCESS_ORGANIZATION_ID
5272 and AccProcs.natural_account_id in
5273 -- (select
5274 -- distinct(acc.natural_account_id)
5275 -- from AMW_FIN_KEY_ACCOUNTS_B acc
5276 -- START WITH acc.natural_account_id = P_NATURAL_ACCOUNT_ID
5277 -- and acc.account_group_id = P_account_group_id
5278 --CONNECT BY PRIOR
5279 -- acc.natural_account_id = acc.parent_natural_account_id
5280 -- and PRIOR
5281 --acc.account_group_id = acc.account_group_id)
5282
5283 ( select distinct acc.child_natural_account_id
5284 from AMW_FIN_KEY_ACCT_FLAT acc
5285 where acc.parent_natural_account_id = p_natural_account_id
5286 and acc.account_group_id = p_account_group_id
5287 union
5288 select distinct acc.natural_account_id
5289 from amw_fin_key_accounts_b acc
5290 where acc.natural_account_id = p_natural_account_id
5291 and acc.account_group_id = p_account_group_id
5292 )
5293
5294 ))
5295 CONNECT BY PRIOR
5296 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
5297 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID)
5298 );
5299 --------------------------------*/
5300
5301 END CountOrgsEvaluated_accounts;
5302 --------------------------------------- ******************************* -------------------------------------
5303 Procedure CountProcsIneffCtrl_accounts(P_NATURAL_ACCOUNT_ID in number, P_account_group_id in number,
5304 P_proc_with_ineffective_ctrls OUT NOCOPY Number,
5305 p_start_date in date, p_end_date in date) is
5306
5307 --******************* Last Modified on 1/31/04 by knair ---------------------------------------
5308 -- Based on the Natural Account ID Passed Computes the Processes and its subprocesses, for which a Evaluation
5309 -- (Means Not Effective Result) was recorded during the given period, that are associated to that
5310 -- Natural Account and its sub-accounts
5311 --******************* ****************************************************************************
5312
5313
5314 begin
5315
5316 Select
5317 count(1) into P_proc_with_ineffective_ctrls
5318 from (
5319 Select distinct orgprocess.PROCESS_ID, orgprocess.ORGANIZATION_ID
5320 FROM
5321 AMW_OPINIONS_V opinion,
5322 AMW_OPINION_TYPES_B opiniontype,
5323 FND_OBJECTS fndobject,
5324 AMW_OBJECT_OPINION_TYPES objectopiniontype,
5325 amw_process_org_basicinfo_v orgprocess
5326 WHERE
5327 (opinion.AUTHORED_DATE in
5328 (Select
5329 MAX(opinion2.AUTHORED_DATE)
5330 from
5331 AMW_OPINIONS_V opinion2
5332 where
5333 opinion.OBJECT_OPINION_TYPE_ID = opinion2.OBJECT_OPINION_TYPE_ID and
5334 opinion2.PK1_VALUE = opinion.PK1_VALUE and
5335 opinion2.PK3_VALUE = opinion.PK3_VALUE
5336 --- Commented chekcing whether the opinion date falls within the period as
5337 --- per discussion with Say and Bastin on 2/9/04
5338 -- AND
5339 --- ********opinion2.AUTHORED_DATE >= p_start_date and
5340 -- opinion2.AUTHORED_DATE <= p_end_date
5341 ) AND
5342 opinion.OBJECT_OPINION_TYPE_ID = objectopiniontype.OBJECT_OPINION_TYPE_ID AND
5343 opiniontype.OPINION_TYPE_ID = objectopiniontype.OPINION_TYPE_ID AND
5344 opiniontype.OPINION_TYPE_CODE = 'EVALUATION' AND
5345 fndobject.OBJECT_ID = objectopiniontype.OBJECT_ID AND
5346 fndobject.obj_name = 'AMW_ORG_PROCESS' and
5347 opinion.audit_result_CODE <> 'EFFECTIVE'
5348 )
5349 and (opinion.PK3_VALUE = orgprocess.ORGANIZATION_ID
5350 and opinion.PK1_VALUE = orgprocess.PROCESS_ID)
5351 and ( orgprocess.ORGANIZATION_ID , orgprocess.PROCESS_ID )
5352 in
5353 (select procRln.ORGANIZATION_ID ,procRln.CHILD_PROCESS_ID from Amw_Process_Org_Relations procRln
5354 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
5355 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
5356 Amw_acct_associations AccProcs where AccProcs .object_type = 'PROCESS_ORG' and
5357 AccProcs .pk1= orgprocess2.PROCESS_ORGANIZATION_ID
5358 and AccProcs.natural_account_id in
5359 -- (select
5360 -- distinct(acc.natural_account_id)
5361 -- from AMW_FIN_KEY_ACCOUNTS_B acc
5362 -- START WITH acc.natural_account_id = P_NATURAL_ACCOUNT_ID
5363 -- and acc.account_group_id = P_account_group_id
5364 --CONNECT BY PRIOR
5365 -- acc.natural_account_id = acc.parent_natural_account_id
5366 -- and PRIOR
5367 --acc.account_group_id = acc.account_group_id)
5368
5369 ( select distinct acc.child_natural_account_id
5370 from AMW_FIN_KEY_ACCT_FLAT acc
5371 where acc.parent_natural_account_id = p_natural_account_id
5372 and acc.account_group_id = p_account_group_id
5373 union
5374 select distinct acc.natural_account_id
5375 from amw_fin_key_accounts_b acc
5376 where acc.natural_account_id = p_natural_account_id
5377 and acc.account_group_id = p_account_group_id
5378 )
5379
5380 ))
5381 CONNECT BY PRIOR
5382 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
5383 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID)
5384 );
5385
5386 END CountProcsIneffCtrl_accounts;
5387 -------------------------------------------------------------------------------------------------------------------
5388 Procedure CountProcsEvaluated_Accnts(P_NATURAL_ACCOUNT_ID in number, P_account_group_id in number,
5389 P_PROCS_EVALUATED OUT NOCOPY Number, p_start_date in date, p_end_date in date)
5390
5391
5392 --******************* Last Modified on 1/31/04 by knair ---------------------------------------------------------
5393 -- Based on the Natural Account ID Passed Computed the Number Processes and the child-processes of these Processes,
5394 -- for which an Evaluation was recorded during the given period, that are associated to that Natural Account and
5395 -- its sub-accounts
5396 --****************************************************************************************************************
5397 is
5398 begin
5399 Select
5400 count(1) into P_PROCS_EVALUATED from
5401 (
5402 Select distinct orgprocess.PROCESS_ID, orgprocess.ORGANIZATION_ID
5403 FROM
5404 AMW_OPINIONS_V opinion,
5405 AMW_OPINION_TYPES_B opiniontype,
5406 FND_OBJECTS fndobject,
5407 AMW_OBJECT_OPINION_TYPES objectopiniontype,
5408 amw_process_org_basicinfo_v orgprocess
5409 WHERE
5410 (opinion.AUTHORED_DATE in
5411 (Select
5412 MAX(opinion2.AUTHORED_DATE)
5413 from
5414 AMW_OPINIONS_V opinion2
5415 where
5416 opinion.OBJECT_OPINION_TYPE_ID = opinion2.OBJECT_OPINION_TYPE_ID and
5417 opinion2.PK1_VALUE = opinion.PK1_VALUE and
5418 opinion2.PK3_VALUE = opinion.PK3_VALUE AND
5419 --- ****** opinion2.AUTHORED_DATE >= p_start_date and
5420 opinion2.AUTHORED_DATE <= p_end_date
5421 ) AND
5422 opinion.OBJECT_OPINION_TYPE_ID = objectopiniontype.OBJECT_OPINION_TYPE_ID AND
5423 opiniontype.OPINION_TYPE_ID = objectopiniontype.OPINION_TYPE_ID AND
5424 opiniontype.OPINION_TYPE_CODE = 'EVALUATION' AND
5425 fndobject.OBJECT_ID = objectopiniontype.OBJECT_ID AND
5426 fndobject.obj_name = 'AMW_ORG_PROCESS'
5427 --- *** RESULT IS IRRILEVENT FOR THIS COMPUTATION and opinion.audit_result_CODE <> 'EFFECTIVE'
5428 )
5429 and (opinion.PK3_VALUE = orgprocess.ORGANIZATION_ID
5430 and opinion.PK1_VALUE = orgprocess.PROCESS_ID)
5431 and ( orgprocess.ORGANIZATION_ID , orgprocess.PROCESS_ID )
5432 in
5433 (select procRln.ORGANIZATION_ID ,procRln.CHILD_PROCESS_ID from Amw_Process_Org_Relations procRln
5434 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
5435 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
5436 Amw_acct_associations AccProcs where AccProcs .object_type = 'PROCESS_ORG' and
5437 AccProcs .pk1= orgprocess2.PROCESS_ORGANIZATION_ID
5438 and AccProcs.natural_account_id in
5439 -- (select
5440 -- distinct(acc.natural_account_id)
5441 -- from AMW_FIN_KEY_ACCOUNTS_B acc
5442 -- START WITH acc.natural_account_id = P_NATURAL_ACCOUNT_ID
5443 -- and acc.account_group_id = P_account_group_id
5444 --CONNECT BY PRIOR
5445 -- acc.natural_account_id = acc.parent_natural_account_id and PRIOR
5446 --acc.account_group_id = acc.account_group_id)
5447
5448 ( select distinct acc.child_natural_account_id
5449 from AMW_FIN_KEY_ACCT_FLAT acc
5450 where acc.parent_natural_account_id = p_natural_account_id
5451 and acc.account_group_id = p_account_group_id
5452 union
5453 select distinct acc.natural_account_id
5454 from amw_fin_key_accounts_b acc
5455 where acc.natural_account_id = p_natural_account_id
5456 and acc.account_group_id = p_account_group_id
5457 )
5458
5459 ))
5460 CONNECT BY PRIOR
5461 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
5462 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID)
5463 );
5464
5465 END CountProcsEvaluated_Accnts;
5466 --------------------------------------- ********************************--------------------------------------
5467 Procedure CountIneffectiveCtrls_account(P_NATURAL_ACCOUNT_ID in number, P_account_group_id in number, p_ineffective_controls OUT NOCOPY Number,
5468 p_start_date in date, p_end_date in date) is
5469
5470 -- ******************************* last updated on 1/31/2004 by knair ********************************************--
5471 ---- Based on the Natural Account ID Passed Computed the Number of Controls , for which an Evaluation
5472 ---- was recorded as "Not Effective" during the given period, that are associated to that Natural Account
5473 ---- and its sub-accounts
5474 -- ****************************************************************************************************************--
5475
5476 begin
5477
5478 Select
5479 count(1) into p_ineffective_controls
5480 from (
5481 select distinct ctrlassoc.control_id, orgprocess.organization_id
5482 FROM
5483 AMW_OPINIONS_V opinion,
5484 AMW_OPINION_TYPES_B opiniontype,
5485 FND_OBJECTS fndobject,
5486 AMW_OBJECT_OPINION_TYPES objectopiniontype,
5487 amw_process_org_basicinfo_v orgprocess,
5488 amw_risk_associations riskassoc,
5489 amw_control_associations ctrlassoc
5490 WHERE
5491 (opinion.AUTHORED_DATE in
5492 (Select
5493 MAX(opinion2.AUTHORED_DATE)
5494 from
5495 AMW_OPINIONS_V opinion2
5496 where
5497 opinion.OBJECT_OPINION_TYPE_ID = opinion2.OBJECT_OPINION_TYPE_ID AND
5498 opinion2.PK1_VALUE = opinion.PK1_VALUE and
5499 opinion2.PK3_VALUE = opinion.PK3_VALUE
5500 ---AND
5501 --- Commented chekcing whether the opinion date falls within the period as
5502 --- per discussion with Say and Bastin on 2/9/04
5503 --- opinion2.AUTHORED_DATE >= p_start_date and
5504 ---opinion2.AUTHORED_DATE <= p_end_date
5505 )AND
5506 opinion.OBJECT_OPINION_TYPE_ID = objectopiniontype.OBJECT_OPINION_TYPE_ID AND
5507 opiniontype.OPINION_TYPE_ID = objectopiniontype.OPINION_TYPE_ID AND
5508 opiniontype.OPINION_TYPE_CODE = 'EVALUATION' AND
5509 fndobject.OBJECT_ID = objectopiniontype.OBJECT_ID AND
5510 fndobject.obj_name = 'AMW_ORG_CONTROL' and
5511 opinion.pk1_value = ctrlassoc.control_id
5512 and opinion.pk3_value = orgprocess.organization_id --??
5513 -- and opinion.pk4_value is null
5514 -- and opinion.pk5_value is null
5515 and orgprocess.process_organization_id = riskassoc.pk1
5516 and riskassoc.object_type = 'PROCESS_ORG'
5517 and riskassoc.risk_association_id = ctrlassoc.pk1
5518 and ctrlassoc.object_type = 'RISK_ORG'
5519 and opinion.audit_result_CODE <> 'EFFECTIVE')
5520 and opinion.pk3_value = orgprocess.ORGANIZATION_ID
5521 --and opinion.pk4_value = orgprocess.PROCESS_ID and
5522 and ( orgprocess.ORGANIZATION_ID , orgprocess.PROCESS_ID )
5523 in
5524 -- and ( opinion.pk4_value ) in
5525 (select procRln.ORGANIZATION_ID ,procRln.CHILD_PROCESS_ID from Amw_Process_Org_Relations procRln
5526 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
5527 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
5528 Amw_acct_associations AccProcs where AccProcs .object_type = 'PROCESS_ORG' and
5529 AccProcs .pk1= orgprocess2.PROCESS_ORGANIZATION_ID
5530 and AccProcs.natural_account_id in
5531 -- (select
5532 -- distinct(acc.natural_account_id)
5533 -- from AMW_FIN_KEY_ACCOUNTS_B acc
5534 -- START WITH acc.natural_account_id = P_NATURAL_ACCOUNT_ID
5535 -- and acc.account_group_id = P_account_group_id
5536 --CONNECT BY PRIOR
5537 -- acc.natural_account_id = acc.parent_natural_account_id
5538 -- and PRIOR
5539 --acc.account_group_id = acc.account_group_id)
5540
5541 ( select distinct acc.child_natural_account_id
5542 from AMW_FIN_KEY_ACCT_FLAT acc
5543 where acc.parent_natural_account_id = p_natural_account_id
5544 and acc.account_group_id = p_account_group_id
5545 union
5546 select distinct acc.natural_account_id
5547 from amw_fin_key_accounts_b acc
5548 where acc.natural_account_id = p_natural_account_id
5549 and acc.account_group_id = p_account_group_id
5550 )
5551
5552 ))
5553 CONNECT BY PRIOR
5554 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
5555 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID)
5556 );
5557 END CountIneffectiveCtrls_account;
5558 --------------------------------------- ********************************--------------------------------------
5559 Procedure CountUnmittigatedRisk_account(P_NATURAL_ACCOUNT_ID in number, P_account_group_id in number, p_unmitigated_risks OUT NOCOPY Number,
5560 p_start_date in date, p_end_date in date) is
5561
5562 -- ******************************* last updated on 1/31/2004 by knair ********************************************--
5563 -- This procedure, based on the Natural Account ID Passed, Computes the Number of Risks, for which an Evaluation
5564 -- was recorded during the given period with a value equal to "Not Effective", that are associated to that Natural
5565 -- Account and its sub-accounts
5566 -- ****************************************************************************************************************--
5567
5568 begin
5569
5570 Select
5571 count(1) into p_unmitigated_risks
5572 from (select distinct riskassoc.risk_id ,orgprocess.organization_id, orgprocess.Process_ID
5573 FROM
5574 AMW_OPINIONS_V opinion,
5575 AMW_OPINION_TYPES_B opiniontype,
5576 FND_OBJECTS fndobject,
5577 AMW_OBJECT_OPINION_TYPES objectopiniontype,
5578 amw_process_org_basicinfo_v orgprocess,
5579 amw_risk_associations riskassoc
5580 WHERE
5581 (opinion.AUTHORED_DATE in
5582 (Select
5583 MAX(opinion2.AUTHORED_DATE)
5584 from
5585 AMW_OPINIONS_V opinion2
5586 where
5587 opinion.OBJECT_OPINION_TYPE_ID = opinion2.OBJECT_OPINION_TYPE_ID AND
5588 opinion2.PK1_VALUE = opinion.PK1_VALUE and
5589 opinion2.PK3_VALUE = opinion.PK3_VALUE and
5590 opinion2.PK4_VALUE = opinion.PK4_VALUE
5591 --- Commented chekcing whether the opinion date falls within the period as
5592 --- per discussion with Say and Bastin on 2/9/04
5593 -- and
5594 -- opinion2.AUTHORED_DATE >= p_start_date and
5595 -- opinion2.AUTHORED_DATE <= p_end_date
5596 ) AND
5597 opinion.OBJECT_OPINION_TYPE_ID = objectopiniontype.OBJECT_OPINION_TYPE_ID AND
5598 opiniontype.OPINION_TYPE_ID = objectopiniontype.OPINION_TYPE_ID AND
5599 opiniontype.OPINION_TYPE_CODE = 'EVALUATION' AND
5600 fndobject.OBJECT_ID = objectopiniontype.OBJECT_ID AND
5601 fndobject.obj_name = 'AMW_ORG_PROCESS_RISK' and
5602 -- AccProcs .natural_account_id = P_NATURAL_ACCOUNT_ID and -- from procedure parameter
5603 opinion.pk1_value = riskassoc.risk_id
5604 --and opinion.pk3_value = orgprocess.organization_id
5605 -- and opinion.pk4_value = orgprocess.Process_ID
5606 and orgprocess.process_organization_id = riskassoc.pk1
5607 and riskassoc.object_type = 'PROCESS_ORG'
5608 and opinion.audit_result_CODE <> 'EFFECTIVE')
5609 -- and (opinion.pk3_value , opinion.pk4_value )
5610 and (opinion.pk3_value = orgprocess.ORGANIZATION_ID and opinion.pk4_value = orgprocess.PROCESS_ID ) and
5611 ( orgprocess.ORGANIZATION_ID , orgprocess.PROCESS_ID )
5612 in
5613 -- and ( opinion.pk4_value ) in
5614 (select procRln.ORGANIZATION_ID ,procRln.CHILD_PROCESS_ID from Amw_Process_Org_Relations procRln
5615 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
5616 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
5617 Amw_acct_associations AccProcs where AccProcs .object_type = 'PROCESS_ORG' and
5618 AccProcs .pk1= orgprocess2.PROCESS_ORGANIZATION_ID
5619 and AccProcs.natural_account_id in
5620 -- (select
5621 -- distinct(acc.natural_account_id)
5622 -- from AMW_FIN_KEY_ACCOUNTS_B acc
5623 -- START WITH acc.natural_account_id = P_NATURAL_ACCOUNT_ID
5624 -- and acc.account_group_id = P_account_group_id
5625 --CONNECT BY PRIOR
5626 -- acc.natural_account_id = acc.parent_natural_account_id
5627 -- and PRIOR
5628 --acc.account_group_id = acc.account_group_id)
5629
5630 ( select distinct acc.child_natural_account_id
5631 from AMW_FIN_KEY_ACCT_FLAT acc
5632 where acc.parent_natural_account_id = p_natural_account_id
5633 and acc.account_group_id = p_account_group_id
5634 union
5635 select distinct acc.natural_account_id
5636 from amw_fin_key_accounts_b acc
5637 where acc.natural_account_id = p_natural_account_id
5638 and acc.account_group_id = p_account_group_id
5639 )
5640
5641 ))
5642 CONNECT BY PRIOR
5643 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
5644 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID)
5645 );
5646
5647 END CountUnmittigatedRisk_account;
5648 --------------------------------------- ********************************--------------------------------------
5649 Procedure CountRisksVerified_account(P_NATURAL_ACCOUNT_ID in number, P_account_group_id in number, p_risks_verified OUT NOCOPY Number,
5650 p_start_date in date, p_end_date in date) is
5651
5652 -- ******************************* last updated on 1/31/2004 by knair ********************************************--
5653 -- This procedure, based on the Natural Account ID Passed, Computes the Number of Risks
5654 -- that are associated to that Natural Account and its sub-accounts
5655 -- ****************************************************************************************************************--
5656
5657
5658 begin
5659
5660 Select
5661 count(1) into p_risks_verified
5662 from (select distinct riskassoc.risk_id ,orgprocess.organization_id, orgprocess.Process_ID
5663 FROM
5664 amw_process_org_basicinfo_v orgprocess,
5665 amw_risk_associations riskassoc
5666 WHERE
5667 orgprocess.process_organization_id = riskassoc.pk1
5668 and riskassoc.object_type = 'PROCESS_ORG' AND
5669 ( orgprocess.ORGANIZATION_ID , orgprocess.PROCESS_ID )
5670 in
5671 (select procRln.ORGANIZATION_ID ,procRln.CHILD_PROCESS_ID from Amw_Process_Org_Relations procRln
5672 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
5673 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
5674 Amw_acct_associations AccProcs where AccProcs.object_type = 'PROCESS_ORG' and
5675 AccProcs .pk1= orgprocess2.PROCESS_ORGANIZATION_ID
5676 and AccProcs.natural_account_id in
5677 -- (select
5678 -- distinct(acc.natural_account_id)
5679 -- from AMW_FIN_KEY_ACCOUNTS_B acc
5680 -- START WITH acc.natural_account_id = P_NATURAL_ACCOUNT_ID
5681 -- and acc.account_group_id = P_account_group_id
5682 --CONNECT BY PRIOR
5683 -- acc.natural_account_id = acc.parent_natural_account_id
5684 -- and PRIOR
5685 --acc.account_group_id = acc.account_group_id)
5686
5687 ( select distinct acc.child_natural_account_id
5688 from AMW_FIN_KEY_ACCT_FLAT acc
5689 where acc.parent_natural_account_id = p_natural_account_id
5690 and acc.account_group_id = p_account_group_id
5691 union
5692 select distinct acc.natural_account_id
5693 from amw_fin_key_accounts_b acc
5694 where acc.natural_account_id = p_natural_account_id
5695 and acc.account_group_id = p_account_group_id
5696 )
5697
5698 ))
5699 CONNECT BY PRIOR
5700 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
5701 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID)
5702 );
5703
5704 /* -- commented as the Denominator for the "Unmitigated Risks" columns is no longer the Total Risk for which an evaluation
5705 is made but it is the Total Risk Attached to the Processe which in turn attached to the accounts
5706
5707 Select
5708 count(1) into p_risks_verified
5709 from (select distinct riskassoc.risk_id ,orgprocess.organization_id, orgprocess.Process_ID
5710 FROM
5711 AMW_OPINIONS_V opinion,
5712 AMW_OPINION_TYPES_B opiniontype,
5713 FND_OBJECTS fndobject,
5714 AMW_OBJECT_OPINION_TYPES objectopiniontype,
5715 amw_process_org_basicinfo_v orgprocess,
5716 amw_risk_associations riskassoc
5717 WHERE
5718 (opinion.AUTHORED_DATE in
5719 (Select
5720 MAX(opinion2.AUTHORED_DATE)
5721 from
5722 AMW_OPINIONS_V opinion2
5723 where
5724 opinion.OBJECT_OPINION_TYPE_ID = opinion2.OBJECT_OPINION_TYPE_ID AND
5725 opinion2.PK1_VALUE = opinion.PK1_VALUE and
5726 opinion2.PK3_VALUE = opinion.PK3_VALUE and
5727 opinion2.PK4_VALUE = opinion.PK4_VALUE
5728 and
5729 opinion2.AUTHORED_DATE >= p_start_date and
5730 opinion2.AUTHORED_DATE <= p_end_date
5731 ) AND
5732 opinion.OBJECT_OPINION_TYPE_ID = objectopiniontype.OBJECT_OPINION_TYPE_ID AND
5733 opiniontype.OPINION_TYPE_ID = objectopiniontype.OPINION_TYPE_ID AND
5734 opiniontype.OPINION_TYPE_CODE = 'EVALUATION' AND
5735 fndobject.OBJECT_ID = objectopiniontype.OBJECT_ID AND
5736 fndobject.obj_name = 'AMW_ORG_PROCESS_RISK' and
5737 -------- AccProcs .natural_account_id = P_NATURAL_ACCOUNT_ID and -- from procedure parameter
5738 opinion.pk1_value = riskassoc.risk_id
5739 --------and opinion.pk3_value = orgprocess.organization_id
5740 ------ and opinion.pk4_value = orgprocess.Process_ID
5741 and orgprocess.process_organization_id = riskassoc.pk1
5742 and riskassoc.object_type = 'PROCESS_ORG'
5743 )
5744 --- and (opinion.pk3_value , opinion.pk4_value )
5745 and (opinion.pk3_value = orgprocess.ORGANIZATION_ID and opinion.pk4_value = orgprocess.PROCESS_ID ) and
5746 ( orgprocess.ORGANIZATION_ID , orgprocess.PROCESS_ID )
5747 in
5748 -- and ( opinion.pk4_value ) in
5749 (select procRln.ORGANIZATION_ID ,procRln.CHILD_PROCESS_ID from Amw_Process_Org_Relations procRln
5750 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
5751 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
5752 Amw_acct_associations AccProcs where AccProcs .object_type = 'PROCESS_ORG' and
5753 AccProcs .pk1= orgprocess2.PROCESS_ORGANIZATION_ID
5754 and AccProcs.natural_account_id in
5755 -- (select
5756 -- distinct(acc.natural_account_id)
5757 -- from AMW_FIN_KEY_ACCOUNTS_B acc
5758 -- START WITH acc.natural_account_id = P_NATURAL_ACCOUNT_ID
5759 -- and acc.account_group_id = P_account_group_id
5760 --CONNECT BY PRIOR
5761 -- acc.natural_account_id = acc.parent_natural_account_id
5762 -- and PRIOR
5763 --acc.account_group_id = acc.account_group_id)
5764
5765 ( select distinct acc.child_natural_account_id
5766 from AMW_FIN_KEY_ACCT_FLAT acc
5767 where acc.parent_natural_account_id = p_natural_account_id
5768 and acc.account_group_id = p_account_group_id
5769 union
5770 select distinct acc.natural_account_id
5771 from amw_fin_key_accounts_b acc
5772 where acc.natural_account_id = p_natural_account_id
5773 and acc.account_group_id = p_account_group_id
5774 )
5775
5776 ))
5777 CONNECT BY PRIOR
5778 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
5779 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID)
5780 );
5781
5782 */
5783
5784 END CountRisksVerified_account;
5785 --------------------------------------- ********************************--------------------------------------
5786 Procedure CountControlsVerified_account(P_NATURAL_ACCOUNT_ID in number, P_account_group_id in number, p_controls_verified OUT NOCOPY Number,
5787 p_start_date in date, p_end_date in date) is
5788
5789 -- ******************************* last updated on 1/31/2004 by knair ********************************************--
5790 -- This procedure, based on the Natural Account ID Passed, Computes the Number of Controls, for which an Evaluation
5791 -- was recorded during the given period (do not consider the result of evaluation.. this total number of Controls
5792 -- which are evaluated), that are associated to that Natural Account and its sub-accounts
5793 -- ****************************************************************************************************************--
5794
5795
5796 begin
5797
5798 SELECT
5799 COUNT(1) into p_controls_verified
5800 FROM
5801 ( select distinct ctrlassoc.control_id, orgprocess.organization_id
5802 FROM
5803 amw_process_org_basicinfo_v orgprocess,
5804 amw_risk_associations riskassoc,
5805 amw_control_associations ctrlassoc
5806 WHERE
5807 orgprocess.process_organization_id = riskassoc.pk1
5808 and riskassoc.object_type = 'PROCESS_ORG'
5809 and riskassoc.risk_association_id = ctrlassoc.pk1
5810 and ctrlassoc.object_type = 'RISK_ORG'
5811 and ( orgprocess.ORGANIZATION_ID , orgprocess.PROCESS_ID )
5812 in
5813 (select procRln.ORGANIZATION_ID ,procRln.CHILD_PROCESS_ID from Amw_Process_Org_Relations procRln
5814 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
5815 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
5816 Amw_acct_associations AccProcs where AccProcs .object_type = 'PROCESS_ORG' and
5817 AccProcs .pk1= orgprocess2.PROCESS_ORGANIZATION_ID
5818 and AccProcs.natural_account_id in
5819 -- (select
5820 -- distinct(acc.natural_account_id)
5821 -- from AMW_FIN_KEY_ACCOUNTS_B acc
5822 -- START WITH acc.natural_account_id = P_NATURAL_ACCOUNT_ID
5823 -- and acc.account_group_id = P_account_group_id
5824 --CONNECT BY PRIOR
5825 -- acc.natural_account_id = acc.parent_natural_account_id
5826 -- and PRIOR
5827 --acc.account_group_id = acc.account_group_id)
5828
5829 ( select distinct acc.child_natural_account_id
5830 from AMW_FIN_KEY_ACCT_FLAT acc
5831 where acc.parent_natural_account_id = p_natural_account_id
5832 and acc.account_group_id = p_account_group_id
5833 union
5834 select distinct acc.natural_account_id
5835 from amw_fin_key_accounts_b acc
5836 where acc.natural_account_id = p_natural_account_id
5837 and acc.account_group_id = p_account_group_id
5838 )
5839
5840 ))
5841 CONNECT BY PRIOR
5842 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
5843 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID)
5844 );
5845
5846 /* -------------------------------------------------------
5847 -- commented as the Denominator for the "Ineffective Controls" columns is no longer the Total Controls for which an
5848 -- evaluation is made but it is the Total Risk Attached to the Processes which in turn attached to the accounts
5849
5850 SELECT
5851 COUNT(1) into p_controls_verified
5852 FROM
5853 (select distinct ctrlassoc.control_id, orgprocess.organization_id
5854 FROM
5855 AMW_OPINIONS_V opinion,
5856 AMW_OPINION_TYPES_B opiniontype,
5857 FND_OBJECTS fndobject,
5858 AMW_OBJECT_OPINION_TYPES objectopiniontype,
5859 amw_process_org_basicinfo_v orgprocess,
5860 amw_risk_associations riskassoc,
5861 amw_control_associations ctrlassoc
5862 WHERE
5863 (opinion.AUTHORED_DATE in
5864 (Select
5865 MAX(opinion2.AUTHORED_DATE)
5866 from
5867 AMW_OPINIONS_V opinion2
5868 where
5869 opinion.OBJECT_OPINION_TYPE_ID = opinion2.OBJECT_OPINION_TYPE_ID AND
5870 opinion2.PK1_VALUE = opinion.PK1_VALUE and
5871 opinion2.PK3_VALUE = opinion.PK3_VALUE AND
5872 opinion2.AUTHORED_DATE >= p_start_date and
5873 opinion2.AUTHORED_DATE <= p_end_date
5874 )AND
5875 opinion.OBJECT_OPINION_TYPE_ID = objectopiniontype.OBJECT_OPINION_TYPE_ID AND
5876 opiniontype.OPINION_TYPE_ID = objectopiniontype.OPINION_TYPE_ID AND
5877 opiniontype.OPINION_TYPE_CODE = 'EVALUATION' AND
5878 fndobject.OBJECT_ID = objectopiniontype.OBJECT_ID AND
5879 fndobject.obj_name = 'AMW_ORG_CONTROL' and
5880 opinion.pk1_value = ctrlassoc.control_id
5881 and opinion.pk3_value = orgprocess.organization_id --??
5882 -- and opinion.pk4_value is null
5883 -- and opinion.pk5_value is null
5884 and orgprocess.process_organization_id = riskassoc.pk1
5885 and riskassoc.object_type = 'PROCESS_ORG'
5886 and riskassoc.risk_association_id = ctrlassoc.pk1
5887 and ctrlassoc.object_type = 'RISK_ORG')
5888 and opinion.pk3_value = orgprocess.ORGANIZATION_ID
5889 --and opinion.pk4_value = orgprocess.PROCESS_ID and
5890 and ( orgprocess.ORGANIZATION_ID , orgprocess.PROCESS_ID )
5891 in
5892 -- and ( opinion.pk4_value ) in
5893 (select procRln.ORGANIZATION_ID ,procRln.CHILD_PROCESS_ID from Amw_Process_Org_Relations procRln
5894 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
5895 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
5896 Amw_acct_associations AccProcs where AccProcs .object_type = 'PROCESS_ORG' and
5897 AccProcs .pk1= orgprocess2.PROCESS_ORGANIZATION_ID
5898 and AccProcs.natural_account_id in
5899 -- (select
5900 -- distinct(acc.natural_account_id)
5901 -- from AMW_FIN_KEY_ACCOUNTS_B acc
5902 -- START WITH acc.natural_account_id = P_NATURAL_ACCOUNT_ID
5903 -- and acc.account_group_id = P_account_group_id
5904 --CONNECT BY PRIOR
5905 -- acc.natural_account_id = acc.parent_natural_account_id
5906 -- and PRIOR
5907 --acc.account_group_id = acc.account_group_id)
5908
5909 ( select distinct acc.child_natural_account_id
5910 from AMW_FIN_KEY_ACCT_FLAT acc
5911 where acc.parent_natural_account_id = p_natural_account_id
5912 and acc.account_group_id = p_account_group_id
5913 union
5914 select distinct acc.natural_account_id
5915 from amw_fin_key_accounts_b acc
5916 where acc.natural_account_id = p_natural_account_id
5917 and acc.account_group_id = p_account_group_id
5918 )
5919
5920 ))
5921 CONNECT BY
5922 PRIOR procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
5923 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID)
5924 );
5925 ------------------------------------------------------- */
5926
5927 End CountControlsVerified_account;
5928 --------------------------------------------------------------------------------------------------------------------
5929 Procedure GetTotalProcesses_for_finitem(P_STATEMENT_GROUP_ID in number, P_FINANCIAL_STATEMENT_ID in number,
5930 P_FINANCIAL_ITEM_ID in number , P_TOTAL_NUMBER_OF_PROCESSES OUT NOCOPY Number
5931 )
5932 --******************************** Last Updated 1/31/04 by knair ************************************---
5933 -- Based on the Natural Account ID Passed Computed all the Processes and the child-processes of these Processes
5934 -- that are associated to that Natural Account and its sub-accounts
5935 --******************************** ************************************************************************---
5936
5937 is begin
5938
5939 select COUNT(1) into P_TOTAL_NUMBER_OF_PROCESSES from (
5940 (select distinct procRln.ORGANIZATION_ID ,procRln.CHILD_PROCESS_ID from Amw_Process_Org_Relations procRln
5941 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
5942 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
5943 Amw_acct_associations AccProcs where AccProcs.object_type = 'PROCESS_ORG' and
5944 AccProcs.pk1= orgprocess2.PROCESS_ORGANIZATION_ID
5945 and AccProcs.natural_account_id in
5946 --(select distinct(acc.natural_account_id)
5947 -- from AMW_FIN_KEY_ACCOUNTS_B acc
5948 -- START WITH ( (acc.natural_account_id, acc.account_group_id) in
5949 -- (select finkeyacc.NATURAL_ACCOUNT_ID,finkeyacc.account_group_id from AMW_FIN_ITEMS_KEY_ACC finkeyacc
5950 --where
5951 -- finkeyacc.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
5952 -- and finkeyacc.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
5953 -- and finkeyacc.FINANCIAL_ITEM_ID IN (select
5954 -- distinct(stmtitem.FINANCIAL_ITEM_ID )
5955 -- from AMW_FIN_STMNT_ITEMS_B stmtitem
5956 -- START WITH (stmtitem.FINANCIAL_ITEM_ID = P_FINANCIAL_ITEM_ID
5957 -- and stmtitem.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
5958 -- and stmtitem.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
5959 -- )
5960 -- CONNECT BY PRIOR
5961 -- stmtitem.FINANCIAL_ITEM_ID = stmtitem.PARENT_FINANCIAL_ITEM_ID
5962 --and PRIOR stmtitem.STATEMENT_GROUP_ID = stmtitem.STATEMENT_GROUP_ID
5963 --and PRIOR stmtitem.FINANCIAL_STATEMENT_ID = stmtitem.FINANCIAL_STATEMENT_ID)
5964 --)
5965 --)
5966 -- CONNECT BY PRIOR
5967 --acc.natural_account_id = acc.parent_natural_account_id
5968 -- and PRIOR
5969 --acc.account_group_id = acc.account_group_id) -- end of acc
5970
5971 ( select distinct acc.child_natural_account_id
5972 from amw_fin_key_acct_flat acc
5973 where ( acc.parent_natural_account_id, acc.account_group_id ) in
5974 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
5975 from amw_fin_items_key_acc finkeyacc
5976 where finkeyacc.statement_group_id = p_statement_group_id
5977 and finkeyacc.financial_statement_id = p_financial_statement_id
5978 and finkeyacc.financial_item_id in
5979 ( select distinct item.child_financial_item_id
5980 from amw_fin_item_flat item
5981 where item.parent_financial_item_id = p_financial_item_id
5982 and item.statement_group_id = p_statement_group_id
5983 and item.financial_statement_id = p_financial_statement_id
5984 union
5985 select distinct item.financial_item_id
5986 from amw_fin_stmnt_items_b item
5987 where item.financial_item_id = p_financial_item_id
5988 and item.statement_group_id = p_statement_group_id
5989 and item.financial_statement_id = p_financial_statement_id
5990 )
5991 )
5992 union
5993 select distinct acc.natural_account_id
5994 from amw_fin_key_accounts_b acc
5995 where ( acc.natural_account_id, acc.account_group_id ) in
5996 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
5997 from amw_fin_items_key_acc finkeyacc
5998 where finkeyacc.statement_group_id = p_statement_group_id
5999 and finkeyacc.financial_statement_id = p_financial_statement_id
6000 and finkeyacc.financial_item_id in
6001 ( select distinct item.child_financial_item_id
6002 from amw_fin_item_flat item
6003 where item.parent_financial_item_id = p_financial_item_id
6004 and item.statement_group_id = p_statement_group_id
6005 and item.financial_statement_id = p_financial_statement_id
6006 union
6007 select distinct item.financial_item_id
6008 from amw_fin_stmnt_items_b item
6009 where item.financial_item_id = p_financial_item_id
6010 and item.statement_group_id = p_statement_group_id
6011 and item.financial_statement_id = p_financial_statement_id
6012 )
6013 )
6014 )
6015
6016 )
6017 )
6018 CONNECT BY PRIOR
6019 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
6020 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID)
6021 );
6022
6023 end GetTotalProcesses_for_finitem;
6024 --------------------------------------------------------------------------------------------------------------------
6025
6026 Procedure CountProcsCertRecorded_finitem(P_STATEMENT_GROUP_ID in number, P_FINANCIAL_STATEMENT_ID in number,
6027 P_FINANCIAL_ITEM_ID in number , P_PROCS_IN_CERTIFICATION OUT NOCOPY Number
6028 , p_start_date in DATE , p_end_date in DATE, p_fin_cert_id in number)
6029
6030 is begin
6031
6032 --******************************** Last Updated 1/31/04 by knair ************************************---
6033 -- Based on the Financial Item ID Passed Computed the Number Processes and the child-processes of these Processes,
6034 -- for which a Certifications (process certification that are associated to the financial certification)
6035 -- was recorded during the given period, that are associated to that Fincnail Items
6036 -- and Sub Finacial Items Natural Account and its sub-accounts
6037 ---**************************************************************************************************************
6038
6039 select count(1) into P_PROCS_IN_CERTIFICATION from (
6040 Select distinct orgprocess.PROCESS_ID, orgprocess.ORGANIZATION_ID
6041 FROM
6042 AMW_OPINIONS_V opinion,
6043 AMW_OPINION_TYPES_B opiniontype,
6044 FND_OBJECTS fndobject,
6045 AMW_OBJECT_OPINION_TYPES objectopiniontype,
6046 amw_process_org_basicinfo_v orgprocess
6047 WHERE
6048 opinion.OBJECT_OPINION_TYPE_ID = objectopiniontype.OBJECT_OPINION_TYPE_ID AND
6049 opiniontype.OPINION_TYPE_ID = objectopiniontype.OPINION_TYPE_ID AND
6050 opiniontype.OPINION_TYPE_CODE = 'CERTIFICATION' AND
6051 fndobject.OBJECT_ID = objectopiniontype.OBJECT_ID AND
6052 fndobject.obj_name = 'AMW_ORG_PROCESS'
6053 and opinion.PK2_VALUE in (select PROC_CERT_ID from AMW_FIN_PROC_CERT_RELAN where FIN_STMT_CERT_ID = p_fin_cert_id)
6054 and (opinion.PK3_VALUE = orgprocess.ORGANIZATION_ID
6055 and opinion.PK1_VALUE = orgprocess.PROCESS_ID)
6056 and ( orgprocess.ORGANIZATION_ID , orgprocess.PROCESS_ID )
6057 in
6058 (select procRln.ORGANIZATION_ID ,procRln.CHILD_PROCESS_ID from Amw_Process_Org_Relations procRln
6059 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
6060 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
6061 Amw_acct_associations AccProcs where AccProcs.object_type = 'PROCESS_ORG' and
6062 AccProcs.pk1= orgprocess2.PROCESS_ORGANIZATION_ID
6063 and AccProcs.natural_account_id in
6064
6065 --(select distinct(acc.natural_account_id)
6066 -- from AMW_FIN_KEY_ACCOUNTS_B acc
6067 -- START WITH ( (acc.natural_account_id, acc.account_group_id) in
6068 -- (select finkeyacc.NATURAL_ACCOUNT_ID,finkeyacc.account_group_id from AMW_FIN_ITEMS_KEY_ACC finkeyacc
6069 --where
6070 -- finkeyacc.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
6071 -- and finkeyacc.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
6072 -- and finkeyacc.FINANCIAL_ITEM_ID IN (select
6073 -- distinct(stmtitem.FINANCIAL_ITEM_ID )
6074 -- from AMW_FIN_STMNT_ITEMS_B stmtitem
6075 -- START WITH (stmtitem.FINANCIAL_ITEM_ID = P_FINANCIAL_ITEM_ID
6076 -- and stmtitem.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
6077 -- and stmtitem.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
6078 -- )
6079 -- CONNECT BY PRIOR
6080 -- stmtitem.FINANCIAL_ITEM_ID = stmtitem.PARENT_FINANCIAL_ITEM_ID
6081 --and PRIOR stmtitem.STATEMENT_GROUP_ID = stmtitem.STATEMENT_GROUP_ID
6082 --and PRIOR stmtitem.FINANCIAL_STATEMENT_ID = stmtitem.FINANCIAL_STATEMENT_ID)
6083 --)
6084 --)
6085 -- CONNECT BY PRIOR
6086 --acc.natural_account_id = acc.parent_natural_account_id
6087 -- and PRIOR
6088 --acc.account_group_id = acc.account_group_id) -- end of acc
6089
6090 ( select distinct acc.child_natural_account_id
6091 from amw_fin_key_acct_flat acc
6092 where ( acc.parent_natural_account_id, acc.account_group_id ) in
6093 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
6094 from amw_fin_items_key_acc finkeyacc
6095 where finkeyacc.statement_group_id = p_statement_group_id
6096 and finkeyacc.financial_statement_id = p_financial_statement_id
6097 and finkeyacc.financial_item_id in
6098 ( select distinct item.child_financial_item_id
6099 from amw_fin_item_flat item
6100 where item.parent_financial_item_id = p_financial_item_id
6101 and item.statement_group_id = p_statement_group_id
6102 and item.financial_statement_id = p_financial_statement_id
6103 union
6104 select distinct item.financial_item_id
6105 from amw_fin_stmnt_items_b item
6106 where item.financial_item_id = p_financial_item_id
6107 and item.statement_group_id = p_statement_group_id
6108 and item.financial_statement_id = p_financial_statement_id
6109 )
6110 )
6111 union
6112 select distinct acc.natural_account_id
6113 from amw_fin_key_accounts_b acc
6114 where ( acc.natural_account_id, acc.account_group_id ) in
6115 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
6116 from amw_fin_items_key_acc finkeyacc
6117 where finkeyacc.statement_group_id = p_statement_group_id
6118 and finkeyacc.financial_statement_id = p_financial_statement_id
6119 and finkeyacc.financial_item_id in
6120 ( select distinct item.child_financial_item_id
6121 from amw_fin_item_flat item
6122 where item.parent_financial_item_id = p_financial_item_id
6123 and item.statement_group_id = p_statement_group_id
6124 and item.financial_statement_id = p_financial_statement_id
6125 union
6126 select distinct item.financial_item_id
6127 from amw_fin_stmnt_items_b item
6128 where item.financial_item_id = p_financial_item_id
6129 and item.statement_group_id = p_statement_group_id
6130 and item.financial_statement_id = p_financial_statement_id
6131 )
6132 )
6133 )
6134
6135 )
6136 )
6137 --) --?
6138 CONNECT BY PRIOR
6139 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
6140 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID)
6141
6142 );
6143
6144
6145 end CountProcsCertRecorded_finitem;
6146
6147 --------------------------------------------------------------------------------------------------------------------
6148 Procedure CountProcsEvaluated_finitem(P_STATEMENT_GROUP_ID in number, P_FINANCIAL_STATEMENT_ID in number,
6149 P_FINANCIAL_ITEM_ID in number , P_PROCS_EVALUATED OUT NOCOPY Number
6150 , p_start_date in DATE , p_end_date in DATE)
6151
6152 --******************************** Last Updated 1/31/04 by knair ************************************---
6153 --Based on the Financial Item ID Passed Computed the Number Processes and the child-processes of these Processes,
6154 --for which an Evaluation was recorded during the given period, that are associated to that Finncial Items and Sub
6155 --Finacial Items Natural Account and its sub-accounts
6156 ---**************************************************************************************************************
6157
6158
6159 is begin
6160
6161 select count(1) into P_PROCS_EVALUATED from (
6162 Select distinct orgprocess.PROCESS_ID, orgprocess.ORGANIZATION_ID
6163 FROM
6164 AMW_OPINIONS_V opinion,
6165 AMW_OPINION_TYPES_B opiniontype,
6166 FND_OBJECTS fndobject,
6167 AMW_OBJECT_OPINION_TYPES objectopiniontype,
6168 amw_process_org_basicinfo_v orgprocess
6169 WHERE
6170 (opinion.AUTHORED_DATE in
6171 (Select
6172 MAX(opinion2.AUTHORED_DATE)
6173 from
6174 AMW_OPINIONS_V opinion2
6175 where
6176 opinion.OBJECT_OPINION_TYPE_ID = opinion2.OBJECT_OPINION_TYPE_ID and
6177 opinion2.PK1_VALUE = opinion.PK1_VALUE and
6178 opinion2.PK3_VALUE = opinion.PK3_VALUE
6179 --AND
6180 --opinion2.AUTHORED_DATE >= p_start_date
6181 --and
6182 --opinion2.AUTHORED_DATE <= p_end_date
6183 ) AND
6184 opinion.OBJECT_OPINION_TYPE_ID = objectopiniontype.OBJECT_OPINION_TYPE_ID AND
6185 opiniontype.OPINION_TYPE_ID = objectopiniontype.OPINION_TYPE_ID AND
6186 opiniontype.OPINION_TYPE_CODE = 'EVALUATION' AND
6187 fndobject.OBJECT_ID = objectopiniontype.OBJECT_ID AND
6188 fndobject.obj_name = 'AMW_ORG_PROCESS' and
6189 opinion.audit_result_CODE <> 'EFFECTIVE' )
6190 and (opinion.PK3_VALUE = orgprocess.ORGANIZATION_ID
6191 and opinion.PK1_VALUE = orgprocess.PROCESS_ID)
6192 and ( orgprocess.ORGANIZATION_ID , orgprocess.PROCESS_ID )
6193 in
6194 (select procRln.ORGANIZATION_ID ,procRln.CHILD_PROCESS_ID from Amw_Process_Org_Relations procRln
6195 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
6196 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
6197 Amw_acct_associations AccProcs where AccProcs.object_type = 'PROCESS_ORG' and
6198 AccProcs.pk1= orgprocess2.PROCESS_ORGANIZATION_ID
6199 and AccProcs.natural_account_id in
6200
6201 --(select distinct(acc.natural_account_id)
6202 -- from AMW_FIN_KEY_ACCOUNTS_B acc
6203 -- START WITH ( (acc.natural_account_id, acc.account_group_id) in
6204 -- (select finkeyacc.NATURAL_ACCOUNT_ID,finkeyacc.account_group_id from AMW_FIN_ITEMS_KEY_ACC finkeyacc
6205 --where
6206 -- finkeyacc.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
6207 -- and finkeyacc.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
6208 -- and finkeyacc.FINANCIAL_ITEM_ID IN (select
6209 -- distinct(stmtitem.FINANCIAL_ITEM_ID )
6210 -- from AMW_FIN_STMNT_ITEMS_B stmtitem
6211 -- START WITH (stmtitem.FINANCIAL_ITEM_ID = P_FINANCIAL_ITEM_ID
6212 -- and stmtitem.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
6213 -- and stmtitem.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
6214 -- )
6215 -- CONNECT BY PRIOR
6216 -- stmtitem.FINANCIAL_ITEM_ID = stmtitem.PARENT_FINANCIAL_ITEM_ID
6217 --and PRIOR stmtitem.STATEMENT_GROUP_ID = stmtitem.STATEMENT_GROUP_ID
6218 --and PRIOR stmtitem.FINANCIAL_STATEMENT_ID = stmtitem.FINANCIAL_STATEMENT_ID)
6219 --)
6220 --)
6221 -- CONNECT BY PRIOR
6222 --acc.natural_account_id = acc.parent_natural_account_id
6223 -- and PRIOR
6224 --acc.account_group_id = acc.account_group_id) -- end of acc
6225
6226 ( select distinct acc.child_natural_account_id
6227 from amw_fin_key_acct_flat acc
6228 where ( acc.parent_natural_account_id, acc.account_group_id ) in
6229 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
6230 from amw_fin_items_key_acc finkeyacc
6231 where finkeyacc.statement_group_id = p_statement_group_id
6232 and finkeyacc.financial_statement_id = p_financial_statement_id
6233 and finkeyacc.financial_item_id in
6234 ( select distinct item.child_financial_item_id
6235 from amw_fin_item_flat item
6236 where item.parent_financial_item_id = p_financial_item_id
6237 and item.statement_group_id = p_statement_group_id
6238 and item.financial_statement_id = p_financial_statement_id
6239 union
6240 select distinct item.financial_item_id
6241 from amw_fin_stmnt_items_b item
6242 where item.financial_item_id = p_financial_item_id
6243 and item.statement_group_id = p_statement_group_id
6244 and item.financial_statement_id = p_financial_statement_id
6245 )
6246 )
6247 union
6248 select distinct acc.natural_account_id
6249 from amw_fin_key_accounts_b acc
6250 where ( acc.natural_account_id, acc.account_group_id ) in
6251 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
6252 from amw_fin_items_key_acc finkeyacc
6253 where finkeyacc.statement_group_id = p_statement_group_id
6254 and finkeyacc.financial_statement_id = p_financial_statement_id
6255 and finkeyacc.financial_item_id in
6256 ( select distinct item.child_financial_item_id
6257 from amw_fin_item_flat item
6258 where item.parent_financial_item_id = p_financial_item_id
6259 and item.statement_group_id = p_statement_group_id
6260 and item.financial_statement_id = p_financial_statement_id
6261 union
6262 select distinct item.financial_item_id
6263 from amw_fin_stmnt_items_b item
6264 where item.financial_item_id = p_financial_item_id
6265 and item.statement_group_id = p_statement_group_id
6266 and item.financial_statement_id = p_financial_statement_id
6267 )
6268 )
6269 )
6270
6271 )
6272 )
6273 --) --?
6274 CONNECT BY PRIOR
6275 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
6276 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID)
6277
6278 );
6279
6280 end CountProcsEvaluated_finitem;
6281 --------------------------------------------------------------------------------------------------------------------
6282 Procedure CountProcswithIssues_finitem(P_STATEMENT_GROUP_ID in number, P_FINANCIAL_STATEMENT_ID in number,
6283 P_FINANCIAL_ITEM_ID in number , P_PROC_CERTIFIED_WITH_ISSUES OUT NOCOPY Number
6284 , p_start_date in DATE , p_end_date in DATE, p_fin_cert_id in number)
6285
6286 --******************************** Last Updated 1/31/04 by knair ************************************---
6287 -- Based on the Financial Item ID Passed Computed the Number Processes and the child-processes of these Processes
6288 -- for which a Certification (process certification that are associated to the financial certification)
6289 -- with Not Effective result was recorded, that are associated
6290 -- to that Financial Items and Sub Finacial Items Natural Account and its sub-accounts
6291 --------------------------------------------------------------------------------------------------------------------
6292
6293 is begin
6294
6295
6296 select count(1) into P_PROC_CERTIFIED_WITH_ISSUES from (
6297 Select distinct orgprocess.PROCESS_ID, orgprocess.ORGANIZATION_ID
6298 FROM
6299 AMW_OPINIONS_V opinion,
6300 AMW_OPINION_TYPES_B opiniontype,
6301 FND_OBJECTS fndobject,
6302 AMW_OBJECT_OPINION_TYPES objectopiniontype,
6303 amw_process_org_basicinfo_v orgprocess
6304 WHERE
6305 (opinion.AUTHORED_DATE in
6306 (Select
6307 MAX(opinion2.AUTHORED_DATE)
6308 from
6309 AMW_OPINIONS_V opinion2
6310 where
6311 opinion.OBJECT_OPINION_TYPE_ID = opinion2.OBJECT_OPINION_TYPE_ID
6312 and opinion2.PK2_VALUE in
6313 (select PROC_CERT_ID from AMW_FIN_PROC_CERT_RELAN where FIN_STMT_CERT_ID = p_fin_cert_id) and
6314 opinion2.PK1_VALUE = opinion.PK1_VALUE and
6315 opinion2.PK3_VALUE = opinion.PK3_VALUE ) AND
6316 opinion.OBJECT_OPINION_TYPE_ID = objectopiniontype.OBJECT_OPINION_TYPE_ID AND
6317 opiniontype.OPINION_TYPE_ID = objectopiniontype.OPINION_TYPE_ID AND
6318 opiniontype.OPINION_TYPE_CODE = 'CERTIFICATION' AND
6319 fndobject.OBJECT_ID = objectopiniontype.OBJECT_ID AND
6320 fndobject.obj_name = 'AMW_ORG_PROCESS' and
6321 opinion.audit_result_CODE <> 'EFFECTIVE')
6322 and opinion.PK2_VALUE in (select PROC_CERT_ID from AMW_FIN_PROC_CERT_RELAN where FIN_STMT_CERT_ID = p_fin_cert_id)
6323 and (opinion.PK3_VALUE = orgprocess.ORGANIZATION_ID
6324 and opinion.PK1_VALUE = orgprocess.PROCESS_ID)
6325 and ( orgprocess.ORGANIZATION_ID , orgprocess.PROCESS_ID )
6326 in
6327 (select procRln.ORGANIZATION_ID ,procRln.CHILD_PROCESS_ID from Amw_Process_Org_Relations procRln
6328 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
6329 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
6330 Amw_acct_associations AccProcs where AccProcs.object_type = 'PROCESS_ORG' and
6331 AccProcs.pk1= orgprocess2.PROCESS_ORGANIZATION_ID
6332 and AccProcs.natural_account_id in
6333
6334 --(select distinct(acc.natural_account_id)
6335 -- from AMW_FIN_KEY_ACCOUNTS_B acc
6336 -- START WITH ( (acc.natural_account_id, acc.account_group_id) in
6337 -- (select finkeyacc.NATURAL_ACCOUNT_ID,finkeyacc.account_group_id from AMW_FIN_ITEMS_KEY_ACC finkeyacc
6338 --where
6339 -- finkeyacc.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
6340 -- and finkeyacc.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
6341 -- and finkeyacc.FINANCIAL_ITEM_ID IN (select
6342 -- distinct(stmtitem.FINANCIAL_ITEM_ID )
6343 -- from AMW_FIN_STMNT_ITEMS_B stmtitem
6344 -- START WITH (stmtitem.FINANCIAL_ITEM_ID = P_FINANCIAL_ITEM_ID
6345 -- and stmtitem.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
6346 -- and stmtitem.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
6347 -- )
6348 -- CONNECT BY PRIOR
6349 -- stmtitem.FINANCIAL_ITEM_ID = stmtitem.PARENT_FINANCIAL_ITEM_ID
6350 --and PRIOR stmtitem.STATEMENT_GROUP_ID = stmtitem.STATEMENT_GROUP_ID
6351 --and PRIOR stmtitem.FINANCIAL_STATEMENT_ID = stmtitem.FINANCIAL_STATEMENT_ID)
6352 --)
6353 --)
6354 -- CONNECT BY PRIOR
6355 --acc.natural_account_id = acc.parent_natural_account_id
6356 -- and PRIOR
6357 --acc.account_group_id = acc.account_group_id) -- end of acc
6358
6359 ( select distinct acc.child_natural_account_id
6360 from amw_fin_key_acct_flat acc
6361 where ( acc.parent_natural_account_id, acc.account_group_id ) in
6362 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
6363 from amw_fin_items_key_acc finkeyacc
6364 where finkeyacc.statement_group_id = p_statement_group_id
6365 and finkeyacc.financial_statement_id = p_financial_statement_id
6366 and finkeyacc.financial_item_id in
6367 ( select distinct item.child_financial_item_id
6368 from amw_fin_item_flat item
6369 where item.parent_financial_item_id = p_financial_item_id
6370 and item.statement_group_id = p_statement_group_id
6371 and item.financial_statement_id = p_financial_statement_id
6372 union
6373 select distinct item.financial_item_id
6374 from amw_fin_stmnt_items_b item
6375 where item.financial_item_id = p_financial_item_id
6376 and item.statement_group_id = p_statement_group_id
6377 and item.financial_statement_id = p_financial_statement_id
6378 )
6379 )
6380 union
6381 select distinct acc.natural_account_id
6382 from amw_fin_key_accounts_b acc
6383 where ( acc.natural_account_id, acc.account_group_id ) in
6384 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
6385 from amw_fin_items_key_acc finkeyacc
6386 where finkeyacc.statement_group_id = p_statement_group_id
6387 and finkeyacc.financial_statement_id = p_financial_statement_id
6388 and finkeyacc.financial_item_id in
6389 ( select distinct item.child_financial_item_id
6390 from amw_fin_item_flat item
6391 where item.parent_financial_item_id = p_financial_item_id
6392 and item.statement_group_id = p_statement_group_id
6393 and item.financial_statement_id = p_financial_statement_id
6394 union
6395 select distinct item.financial_item_id
6396 from amw_fin_stmnt_items_b item
6397 where item.financial_item_id = p_financial_item_id
6398 and item.statement_group_id = p_statement_group_id
6399 and item.financial_statement_id = p_financial_statement_id
6400 )
6401 )
6402 )
6403
6404 )
6405 )
6406 --) --?
6407 CONNECT BY PRIOR
6408 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
6409 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID)
6410 );
6411
6412 end CountProcswithIssues_finitem;
6413
6414 --------------------------------------------------------------------------------------------------------------------
6415
6416
6417 Procedure CountOrgsIneffCtrl_finitem(P_STATEMENT_GROUP_ID in number, P_FINANCIAL_STATEMENT_ID in number,
6418 P_FINANCIAL_ITEM_ID in number , P_org_with_ineffective_ctrls OUT NOCOPY number
6419 , p_start_date in DATE , p_end_date in DATE)
6420
6421 --******************************** Last Updated 1/31/04 by knair *************************************************
6422 -- Based on the Finacial Item ID Passed Computes the Organization, for which a Evaluation (Not Effective Result)
6423 -- was recorded during the given period, that are associated to that Financial Items and Sub Finacial Items
6424 -- Natural Account and its sub-accounts
6425 --******************************************************************************************************************
6426 is begin
6427
6428 select count(1) into P_org_with_ineffective_ctrls from (
6429 select distinct orgprocess.ORGANIZATION_ID
6430 FROM
6431 AMW_OPINIONS_V opinion,
6432 AMW_OPINION_TYPES_B opiniontype,
6433 FND_OBJECTS fndobject,
6434 AMW_OBJECT_OPINION_TYPES objectopiniontype,
6435 amw_process_org_basicinfo_v orgprocess
6436 WHERE
6437 (opinion.AUTHORED_DATE in
6438 (Select
6439 MAX(opinion2.AUTHORED_DATE)
6440 from
6441 AMW_OPINIONS_V opinion2
6442 where
6443 opinion.OBJECT_OPINION_TYPE_ID = opinion2.OBJECT_OPINION_TYPE_ID AND
6444 opinion2.PK1_VALUE = opinion.PK1_VALUE
6445 --AND
6446 --opinion2.AUTHORED_DATE >= p_start_date
6447 --and
6448 --opinion2.AUTHORED_DATE <= p_end_date
6449 ) AND
6450 opinion.OBJECT_OPINION_TYPE_ID = objectopiniontype.OBJECT_OPINION_TYPE_ID AND
6451 opiniontype.OPINION_TYPE_ID = objectopiniontype.OPINION_TYPE_ID AND
6452 opiniontype.OPINION_TYPE_CODE = 'EVALUATION' AND
6453 fndobject.OBJECT_ID = objectopiniontype.OBJECT_ID AND
6454 fndobject.obj_name = 'AMW_ORGANIZATION' and
6455 opinion.audit_result_CODE <> 'EFFECTIVE'
6456 )
6457 and opinion.PK1_VALUE = orgprocess.ORGANIZATION_ID
6458 and orgprocess.ORGANIZATION_ID
6459 in
6460 -- ?
6461 (select procRln.ORGANIZATION_ID from Amw_Process_Org_Relations procRln
6462 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
6463 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
6464 Amw_acct_associations AccProcs where AccProcs.object_type = 'PROCESS_ORG' and
6465 AccProcs.pk1= orgprocess2.PROCESS_ORGANIZATION_ID
6466 and AccProcs.natural_account_id in
6467
6468 --(select distinct(acc.natural_account_id)
6469 -- from AMW_FIN_KEY_ACCOUNTS_B acc
6470 -- START WITH ( (acc.natural_account_id, acc.account_group_id) in
6471 -- (select finkeyacc.NATURAL_ACCOUNT_ID,finkeyacc.account_group_id from AMW_FIN_ITEMS_KEY_ACC finkeyacc
6472 --where
6473 -- finkeyacc.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
6474 -- and finkeyacc.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
6475 -- and finkeyacc.FINANCIAL_ITEM_ID IN (select
6476 -- distinct(stmtitem.FINANCIAL_ITEM_ID )
6477 -- from AMW_FIN_STMNT_ITEMS_B stmtitem
6478 -- START WITH (stmtitem.FINANCIAL_ITEM_ID = P_FINANCIAL_ITEM_ID
6479 -- and stmtitem.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
6480 -- and stmtitem.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
6481 -- )
6482 -- CONNECT BY PRIOR
6483 -- stmtitem.FINANCIAL_ITEM_ID = stmtitem.PARENT_FINANCIAL_ITEM_ID
6484 --and PRIOR stmtitem.STATEMENT_GROUP_ID = stmtitem.STATEMENT_GROUP_ID
6485 --and PRIOR stmtitem.FINANCIAL_STATEMENT_ID = stmtitem.FINANCIAL_STATEMENT_ID)
6486 --)
6487 --)
6488 -- CONNECT BY PRIOR
6489 --acc.natural_account_id = acc.parent_natural_account_id
6490 -- and PRIOR
6491 --acc.account_group_id = acc.account_group_id) -- end of acc
6492
6493 ( select distinct acc.child_natural_account_id
6494 from amw_fin_key_acct_flat acc
6495 where ( acc.parent_natural_account_id, acc.account_group_id ) in
6496 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
6497 from amw_fin_items_key_acc finkeyacc
6498 where finkeyacc.statement_group_id = p_statement_group_id
6499 and finkeyacc.financial_statement_id = p_financial_statement_id
6500 and finkeyacc.financial_item_id in
6501 ( select distinct item.child_financial_item_id
6502 from amw_fin_item_flat item
6503 where item.parent_financial_item_id = p_financial_item_id
6504 and item.statement_group_id = p_statement_group_id
6505 and item.financial_statement_id = p_financial_statement_id
6506 union
6507 select distinct item.financial_item_id
6508 from amw_fin_stmnt_items_b item
6509 where item.financial_item_id = p_financial_item_id
6510 and item.statement_group_id = p_statement_group_id
6511 and item.financial_statement_id = p_financial_statement_id
6512 )
6513 )
6514 union
6515 select distinct acc.natural_account_id
6516 from amw_fin_key_accounts_b acc
6517 where ( acc.natural_account_id, acc.account_group_id ) in
6518 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
6519 from amw_fin_items_key_acc finkeyacc
6520 where finkeyacc.statement_group_id = p_statement_group_id
6521 and finkeyacc.financial_statement_id = p_financial_statement_id
6522 and finkeyacc.financial_item_id in
6523 ( select distinct item.child_financial_item_id
6524 from amw_fin_item_flat item
6525 where item.parent_financial_item_id = p_financial_item_id
6526 and item.statement_group_id = p_statement_group_id
6527 and item.financial_statement_id = p_financial_statement_id
6528 union
6529 select distinct item.financial_item_id
6530 from amw_fin_stmnt_items_b item
6531 where item.financial_item_id = p_financial_item_id
6532 and item.statement_group_id = p_statement_group_id
6533 and item.financial_statement_id = p_financial_statement_id
6534 )
6535 )
6536 )
6537
6538 )
6539 )
6540 --) --?
6541 CONNECT BY PRIOR
6542 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
6543 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID)
6544
6545 );
6546
6547
6548 end CountOrgsIneffCtrl_finitem;
6549 --------------------------------------------------------------------------------------------------------------------
6550
6551 Procedure CountOrgsEvaluated_finitem(P_STATEMENT_GROUP_ID in number, P_FINANCIAL_STATEMENT_ID in number,
6552 P_FINANCIAL_ITEM_ID in number , P_org_evaluated OUT NOCOPY number
6553 , p_start_date in DATE , p_end_date in DATE)
6554
6555 --******************************** Last Updated 1/31/04 by knair ************************************---
6556 -- Based on the Financial Iem ID Passed Computed the Number Orgs, for which an Eavluation was recorded during
6557 -- the given period, that are associated to that Finncial Items and Sub Financial Items Natural Account and
6558 --its sub-accounts
6559 --------------------------------------------------------------------------------------------------------------
6560
6561
6562 is begin
6563
6564 select COUNT(1)
6565 into P_org_evaluated
6566 from (
6567 (select distinct procRln.ORGANIZATION_ID from Amw_Process_Org_Relations procRln
6568 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
6569 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
6570 Amw_acct_associations AccProcs where AccProcs.object_type = 'PROCESS_ORG' and
6571 AccProcs.pk1= orgprocess2.PROCESS_ORGANIZATION_ID
6572 and AccProcs.natural_account_id in
6573 --(select distinct(acc.natural_account_id)
6574 -- from AMW_FIN_KEY_ACCOUNTS_B acc
6575 -- START WITH ( (acc.natural_account_id, acc.account_group_id) in
6576 -- (select finkeyacc.NATURAL_ACCOUNT_ID,finkeyacc.account_group_id from AMW_FIN_ITEMS_KEY_ACC finkeyacc
6577 --where
6578 -- finkeyacc.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
6579 -- and finkeyacc.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
6580 -- and finkeyacc.FINANCIAL_ITEM_ID IN (select
6581 -- distinct(stmtitem.FINANCIAL_ITEM_ID )
6582 -- from AMW_FIN_STMNT_ITEMS_B stmtitem
6583 -- START WITH (stmtitem.FINANCIAL_ITEM_ID = P_FINANCIAL_ITEM_ID
6584 -- and stmtitem.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
6585 -- and stmtitem.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
6586 -- )
6587 -- CONNECT BY PRIOR
6588 -- stmtitem.FINANCIAL_ITEM_ID = stmtitem.PARENT_FINANCIAL_ITEM_ID
6589 --and PRIOR stmtitem.STATEMENT_GROUP_ID = stmtitem.STATEMENT_GROUP_ID
6590 --and PRIOR stmtitem.FINANCIAL_STATEMENT_ID = stmtitem.FINANCIAL_STATEMENT_ID)
6591 --)
6592 --)
6593 -- CONNECT BY PRIOR
6594 --acc.natural_account_id = acc.parent_natural_account_id
6595 -- and PRIOR
6596 --acc.account_group_id = acc.account_group_id) -- end of acc
6597
6598 ( select distinct acc.child_natural_account_id
6599 from amw_fin_key_acct_flat acc
6600 where ( acc.parent_natural_account_id, acc.account_group_id ) in
6601 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
6602 from amw_fin_items_key_acc finkeyacc
6603 where finkeyacc.statement_group_id = p_statement_group_id
6604 and finkeyacc.financial_statement_id = p_financial_statement_id
6605 and finkeyacc.financial_item_id in
6606 ( select distinct item.child_financial_item_id
6607 from amw_fin_item_flat item
6608 where item.parent_financial_item_id = p_financial_item_id
6609 and item.statement_group_id = p_statement_group_id
6610 and item.financial_statement_id = p_financial_statement_id
6611 union
6612 select distinct item.financial_item_id
6613 from amw_fin_stmnt_items_b item
6614 where item.financial_item_id = p_financial_item_id
6615 and item.statement_group_id = p_statement_group_id
6616 and item.financial_statement_id = p_financial_statement_id
6617 )
6618 )
6619 union
6620 select distinct acc.natural_account_id
6621 from amw_fin_key_accounts_b acc
6622 where ( acc.natural_account_id, acc.account_group_id ) in
6623 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
6624 from amw_fin_items_key_acc finkeyacc
6625 where finkeyacc.statement_group_id = p_statement_group_id
6626 and finkeyacc.financial_statement_id = p_financial_statement_id
6627 and finkeyacc.financial_item_id in
6628 ( select distinct item.child_financial_item_id
6629 from amw_fin_item_flat item
6630 where item.parent_financial_item_id = p_financial_item_id
6631 and item.statement_group_id = p_statement_group_id
6632 and item.financial_statement_id = p_financial_statement_id
6633 union
6634 select distinct item.financial_item_id
6635 from amw_fin_stmnt_items_b item
6636 where item.financial_item_id = p_financial_item_id
6637 and item.statement_group_id = p_statement_group_id
6638 and item.financial_statement_id = p_financial_statement_id
6639 )
6640 )
6641 )
6642
6643 )
6644 )
6645 CONNECT BY PRIOR
6646 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
6647 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID)
6648 );
6649
6650
6651
6652
6653
6654
6655
6656 /* ------------------------
6657 select count(1) into P_org_evaluated from (
6658 select distinct orgprocess.ORGANIZATION_ID
6659 FROM
6660 AMW_OPINIONS_V opinion,
6661 AMW_OPINION_TYPES_B opiniontype,
6662 FND_OBJECTS fndobject,
6663 AMW_OBJECT_OPINION_TYPES objectopiniontype,
6664 amw_process_org_basicinfo_v orgprocess
6665 WHERE
6666 (opinion.AUTHORED_DATE in
6667 (Select
6668 MAX(opinion2.AUTHORED_DATE)
6669 from
6670 AMW_OPINIONS_V opinion2
6671 where
6672 opinion.OBJECT_OPINION_TYPE_ID = opinion2.OBJECT_OPINION_TYPE_ID AND
6673 opinion2.PK1_VALUE = opinion.PK1_VALUE AND
6674 opinion2.AUTHORED_DATE >= p_start_date
6675 and
6676 opinion2.AUTHORED_DATE <= p_end_date
6677 ) AND
6678 opinion.OBJECT_OPINION_TYPE_ID = objectopiniontype.OBJECT_OPINION_TYPE_ID AND
6679 opiniontype.OPINION_TYPE_ID = objectopiniontype.OPINION_TYPE_ID AND
6680 opiniontype.OPINION_TYPE_CODE = 'EVALUATION' AND
6681 fndobject.OBJECT_ID = objectopiniontype.OBJECT_ID AND
6682 fndobject.obj_name = 'AMW_ORGANIZATION'
6683 )
6684 and opinion.PK1_VALUE = orgprocess.ORGANIZATION_ID
6685 and orgprocess.ORGANIZATION_ID
6686 in
6687 (select procRln.ORGANIZATION_ID from Amw_Process_Org_Relations procRln
6688 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
6689 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
6690 Amw_acct_associations AccProcs where AccProcs.object_type = 'PROCESS_ORG' and
6691 AccProcs.pk1= orgprocess2.PROCESS_ORGANIZATION_ID
6692 and AccProcs.natural_account_id in
6693 --(select distinct(acc.natural_account_id)
6694 -- from AMW_FIN_KEY_ACCOUNTS_B acc
6695 -- START WITH ( (acc.natural_account_id, acc.account_group_id) in
6696 -- (select finkeyacc.NATURAL_ACCOUNT_ID,finkeyacc.account_group_id from AMW_FIN_ITEMS_KEY_ACC finkeyacc
6697 --where
6698 -- finkeyacc.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
6699 -- and finkeyacc.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
6700 -- and finkeyacc.FINANCIAL_ITEM_ID IN (select
6701 -- distinct(stmtitem.FINANCIAL_ITEM_ID )
6702 -- from AMW_FIN_STMNT_ITEMS_B stmtitem
6703 -- START WITH (stmtitem.FINANCIAL_ITEM_ID = P_FINANCIAL_ITEM_ID
6704 -- and stmtitem.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
6705 -- and stmtitem.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
6706 -- )
6707 -- CONNECT BY PRIOR
6708 -- stmtitem.FINANCIAL_ITEM_ID = stmtitem.PARENT_FINANCIAL_ITEM_ID
6709 --and PRIOR stmtitem.STATEMENT_GROUP_ID = stmtitem.STATEMENT_GROUP_ID
6710 --and PRIOR stmtitem.FINANCIAL_STATEMENT_ID = stmtitem.FINANCIAL_STATEMENT_ID)
6711 --)
6712 --)
6713 -- CONNECT BY PRIOR
6714 --acc.natural_account_id = acc.parent_natural_account_id
6715 -- and PRIOR
6716 --acc.account_group_id = acc.account_group_id) -- end of acc
6717
6718 ( select distinct acc.child_natural_account_id
6719 from amw_fin_key_acct_flat acc
6720 where ( acc.parent_natural_account_id, acc.account_group_id ) in
6721 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
6722 from amw_fin_items_key_acc finkeyacc
6723 where finkeyacc.statement_group_id = p_statement_group_id
6724 and finkeyacc.financial_statement_id = p_financial_statement_id
6725 and finkeyacc.financial_item_id in
6726 ( select distinct item.child_financial_item_id
6727 from amw_fin_item_flat item
6728 where item.parent_financial_item_id = p_financial_item_id
6729 and item.statement_group_id = p_statement_group_id
6730 and item.financial_statement_id = p_financial_statement_id
6731 union
6732 select distinct item.financial_item_id
6733 from amw_fin_stmnt_items_b item
6734 where item.financial_item_id = p_financial_item_id
6735 and item.statement_group_id = p_statement_group_id
6736 and item.financial_statement_id = p_financial_statement_id
6737 )
6738 )
6739 union
6740 select distinct acc.natural_account_id
6741 from amw_fin_key_accounts_b acc
6742 where ( acc.natural_account_id, acc.account_group_id ) in
6743 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
6744 from amw_fin_items_key_acc finkeyacc
6745 where finkeyacc.statement_group_id = p_statement_group_id
6746 and finkeyacc.financial_statement_id = p_financial_statement_id
6747 and finkeyacc.financial_item_id in
6748 ( select distinct item.child_financial_item_id
6749 from amw_fin_item_flat item
6750 where item.parent_financial_item_id = p_financial_item_id
6751 and item.statement_group_id = p_statement_group_id
6752 and item.financial_statement_id = p_financial_statement_id
6753 union
6754 select distinct item.financial_item_id
6755 from amw_fin_stmnt_items_b item
6756 where item.financial_item_id = p_financial_item_id
6757 and item.statement_group_id = p_statement_group_id
6758 and item.financial_statement_id = p_financial_statement_id
6759 )
6760 )
6761 )
6762
6763 )
6764 )
6765 CONNECT BY PRIOR
6766 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
6767 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID)
6768 );
6769 ------------------------------*/
6770
6771 end CountOrgsEvaluated_finitem;
6772 --------------------------------------------------------------------------------------------------------------------
6773
6774 Procedure CountOrgsCertified_finitem(P_STATEMENT_GROUP_ID in number, P_FINANCIAL_STATEMENT_ID in number,
6775 P_FINANCIAL_ITEM_ID in number , P_org_certified OUT NOCOPY number
6776 , p_start_date in DATE , p_end_date in DATE)
6777
6778 --******************************** Last Updated 1/31/04 by knair ************************************---
6779 -- Based on the Financial Iem ID Passed Computed the Number Orgs, for which an Evlauation was recorded
6780 --during the given period, that are associated to that Finncial Items and Sub Finacial Items Natural Account
6781 -- and its sub-accounts
6782 --********************************************************************************************************
6783
6784 is begin
6785
6786 select count(1) into P_org_certified from (
6787 select
6788 distinct orgprocess.ORGANIZATION_ID
6789 FROM
6790 AMW_OPINIONS_V opinion,
6791 AMW_OPINION_TYPES_B opiniontype,
6792 FND_OBJECTS fndobject,
6793 AMW_OBJECT_OPINION_TYPES objectopiniontype,
6794 amw_process_org_basicinfo_v orgprocess
6795 WHERE
6796 (opinion.AUTHORED_DATE in
6797 (Select
6798 MAX(opinion2.AUTHORED_DATE)
6799 from
6800 AMW_OPINIONS_V opinion2
6801 where
6802 opinion.OBJECT_OPINION_TYPE_ID = opinion2.OBJECT_OPINION_TYPE_ID AND
6803 opinion2.PK1_VALUE = opinion.PK1_VALUE AND
6804 opinion2.AUTHORED_DATE >= p_start_date
6805 and
6806 opinion2.AUTHORED_DATE <= p_end_date
6807 ) AND
6808 opinion.OBJECT_OPINION_TYPE_ID = objectopiniontype.OBJECT_OPINION_TYPE_ID AND
6809 opiniontype.OPINION_TYPE_ID = objectopiniontype.OPINION_TYPE_ID AND
6810 opiniontype.OPINION_TYPE_CODE = 'CERTIFICATION' AND
6811 fndobject.OBJECT_ID = objectopiniontype.OBJECT_ID AND
6812 fndobject.obj_name = 'AMW_ORGANIZATION'
6813 )
6814 and opinion.PK1_VALUE = orgprocess.ORGANIZATION_ID
6815 and orgprocess.ORGANIZATION_ID
6816 in
6817 (select procRln.ORGANIZATION_ID from Amw_Process_Org_Relations procRln
6818 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
6819 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
6820 Amw_acct_associations AccProcs where AccProcs.object_type = 'PROCESS_ORG' and
6821 AccProcs.pk1= orgprocess2.PROCESS_ORGANIZATION_ID
6822 and AccProcs.natural_account_id in
6823 --(select distinct(acc.natural_account_id)
6824 -- from AMW_FIN_KEY_ACCOUNTS_B acc
6825 -- START WITH ( (acc.natural_account_id, acc.account_group_id) in
6826 -- (select finkeyacc.NATURAL_ACCOUNT_ID,finkeyacc.account_group_id from AMW_FIN_ITEMS_KEY_ACC finkeyacc
6827 --where
6828 -- finkeyacc.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
6829 -- and finkeyacc.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
6830 -- and finkeyacc.FINANCIAL_ITEM_ID IN (select
6831 -- distinct(stmtitem.FINANCIAL_ITEM_ID )
6832 -- from AMW_FIN_STMNT_ITEMS_B stmtitem
6833 -- START WITH (stmtitem.FINANCIAL_ITEM_ID = P_FINANCIAL_ITEM_ID
6834 -- and stmtitem.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
6835 -- and stmtitem.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
6836 -- )
6837 -- CONNECT BY PRIOR
6838 -- stmtitem.FINANCIAL_ITEM_ID = stmtitem.PARENT_FINANCIAL_ITEM_ID
6839 --and PRIOR stmtitem.STATEMENT_GROUP_ID = stmtitem.STATEMENT_GROUP_ID
6840 --and PRIOR stmtitem.FINANCIAL_STATEMENT_ID = stmtitem.FINANCIAL_STATEMENT_ID)
6841 --)
6842 --)
6843 -- CONNECT BY PRIOR
6844 --acc.natural_account_id = acc.parent_natural_account_id
6845 -- and PRIOR
6846 --acc.account_group_id = acc.account_group_id) -- end of acc
6847
6848 ( select distinct acc.child_natural_account_id
6849 from amw_fin_key_acct_flat acc
6850 where ( acc.parent_natural_account_id, acc.account_group_id ) in
6851 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
6852 from amw_fin_items_key_acc finkeyacc
6853 where finkeyacc.statement_group_id = p_statement_group_id
6854 and finkeyacc.financial_statement_id = p_financial_statement_id
6855 and finkeyacc.financial_item_id in
6856 ( select distinct item.child_financial_item_id
6857 from amw_fin_item_flat item
6858 where item.parent_financial_item_id = p_financial_item_id
6859 and item.statement_group_id = p_statement_group_id
6860 and item.financial_statement_id = p_financial_statement_id
6861 union
6862 select distinct item.financial_item_id
6863 from amw_fin_stmnt_items_b item
6864 where item.financial_item_id = p_financial_item_id
6865 and item.statement_group_id = p_statement_group_id
6866 and item.financial_statement_id = p_financial_statement_id
6867 )
6868 )
6869 union
6870 select distinct acc.natural_account_id
6871 from amw_fin_key_accounts_b acc
6872 where ( acc.natural_account_id, acc.account_group_id ) in
6873 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
6874 from amw_fin_items_key_acc finkeyacc
6875 where finkeyacc.statement_group_id = p_statement_group_id
6876 and finkeyacc.financial_statement_id = p_financial_statement_id
6877 and finkeyacc.financial_item_id in
6878 ( select distinct item.child_financial_item_id
6879 from amw_fin_item_flat item
6880 where item.parent_financial_item_id = p_financial_item_id
6881 and item.statement_group_id = p_statement_group_id
6882 and item.financial_statement_id = p_financial_statement_id
6883 union
6884 select distinct item.financial_item_id
6885 from amw_fin_stmnt_items_b item
6886 where item.financial_item_id = p_financial_item_id
6887 and item.statement_group_id = p_statement_group_id
6888 and item.financial_statement_id = p_financial_statement_id
6889 )
6890 )
6891 )
6892
6893 )
6894 )
6895 --) --?
6896 CONNECT BY PRIOR
6897 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
6898 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID)
6899 );
6900
6901 end CountOrgsCertified_finitem;
6902 --------------------------------------------------------------------------------------------------------------------
6903
6904 Procedure CountProcsIneffCtrl_finitem(P_STATEMENT_GROUP_ID in number, P_FINANCIAL_STATEMENT_ID in number,
6905 P_FINANCIAL_ITEM_ID in number , P_proc_with_ineffective_ctrls OUT NOCOPY number
6906 , p_start_date in DATE , p_end_date in DATE)
6907
6908 --******************************** Last Updated 1/31/04 by knair ************************************---
6909 -- Based on the Financial Item ID ID Passed Computed the Number Processes and the child-processes of these
6910 -- Processes, for which an Evaluation was recorded as not Effective during the given period, associated
6911 --to to that Financial Items and Sub Finacial Items that Natural Account and its sub-accounts
6912 --*****************************************************************************************************---
6913 is begin
6914
6915 select count(1) into P_proc_with_ineffective_ctrls from (
6916 Select distinct orgprocess.PROCESS_ID, orgprocess.ORGANIZATION_ID
6917 FROM
6918 AMW_OPINIONS_V opinion,
6919 AMW_OPINION_TYPES_B opiniontype,
6920 FND_OBJECTS fndobject,
6921 AMW_OBJECT_OPINION_TYPES objectopiniontype,
6922 amw_process_org_basicinfo_v orgprocess
6923 WHERE
6924 (opinion.AUTHORED_DATE in
6925 (Select
6926 MAX(opinion2.AUTHORED_DATE)
6927 from
6928 AMW_OPINIONS_V opinion2
6929 where
6930 opinion.OBJECT_OPINION_TYPE_ID = opinion2.OBJECT_OPINION_TYPE_ID and
6931 opinion2.PK1_VALUE = opinion.PK1_VALUE and
6932 opinion2.PK3_VALUE = opinion.PK3_VALUE
6933 --AND
6934 --opinion2.AUTHORED_DATE >= p_start_date
6935 --and
6936 -- opinion2.AUTHORED_DATE <= p_end_date
6937 ) AND
6938 opinion.OBJECT_OPINION_TYPE_ID = objectopiniontype.OBJECT_OPINION_TYPE_ID AND
6939 opiniontype.OPINION_TYPE_ID = objectopiniontype.OPINION_TYPE_ID AND
6940 opiniontype.OPINION_TYPE_CODE = 'EVALUATION' AND
6941 fndobject.OBJECT_ID = objectopiniontype.OBJECT_ID AND
6942 fndobject.obj_name = 'AMW_ORG_PROCESS'
6943 and opinion.audit_result_CODE <> 'EFFECTIVE'
6944 )
6945 and (opinion.PK3_VALUE = orgprocess.ORGANIZATION_ID
6946 and opinion.PK1_VALUE = orgprocess.PROCESS_ID)
6947 and ( orgprocess.ORGANIZATION_ID , orgprocess.PROCESS_ID )
6948 IN
6949 (select procRln.ORGANIZATION_ID ,procRln.CHILD_PROCESS_ID from Amw_Process_Org_Relations procRln
6950 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
6951 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
6952 Amw_acct_associations AccProcs where AccProcs.object_type = 'PROCESS_ORG' and
6953 AccProcs.pk1= orgprocess2.PROCESS_ORGANIZATION_ID
6954 and AccProcs.natural_account_id in
6955 --(select distinct(acc.natural_account_id)
6956 -- from AMW_FIN_KEY_ACCOUNTS_B acc
6957 -- START WITH ( (acc.natural_account_id, acc.account_group_id) in
6958 -- (select finkeyacc.NATURAL_ACCOUNT_ID,finkeyacc.account_group_id from AMW_FIN_ITEMS_KEY_ACC finkeyacc
6959 --where
6960 -- finkeyacc.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
6961 -- and finkeyacc.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
6962 -- and finkeyacc.FINANCIAL_ITEM_ID IN (select
6963 -- distinct(stmtitem.FINANCIAL_ITEM_ID )
6964 -- from AMW_FIN_STMNT_ITEMS_B stmtitem
6965 -- START WITH (stmtitem.FINANCIAL_ITEM_ID = P_FINANCIAL_ITEM_ID
6966 -- and stmtitem.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
6967 -- and stmtitem.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
6968 -- )
6969 -- CONNECT BY PRIOR
6970 -- stmtitem.FINANCIAL_ITEM_ID = stmtitem.PARENT_FINANCIAL_ITEM_ID
6971 --and PRIOR stmtitem.STATEMENT_GROUP_ID = stmtitem.STATEMENT_GROUP_ID
6972 --and PRIOR stmtitem.FINANCIAL_STATEMENT_ID = stmtitem.FINANCIAL_STATEMENT_ID)
6973 --)
6974 --)
6975 -- CONNECT BY PRIOR
6976 --acc.natural_account_id = acc.parent_natural_account_id
6977 -- and PRIOR
6978 --acc.account_group_id = acc.account_group_id) -- end of acc
6979
6980 ( select distinct acc.child_natural_account_id
6981 from amw_fin_key_acct_flat acc
6982 where ( acc.parent_natural_account_id, acc.account_group_id ) in
6983 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
6984 from amw_fin_items_key_acc finkeyacc
6985 where finkeyacc.statement_group_id = p_statement_group_id
6986 and finkeyacc.financial_statement_id = p_financial_statement_id
6987 and finkeyacc.financial_item_id in
6988 ( select distinct item.child_financial_item_id
6989 from amw_fin_item_flat item
6990 where item.parent_financial_item_id = p_financial_item_id
6991 and item.statement_group_id = p_statement_group_id
6992 and item.financial_statement_id = p_financial_statement_id
6993 union
6994 select distinct item.financial_item_id
6995 from amw_fin_stmnt_items_b item
6996 where item.financial_item_id = p_financial_item_id
6997 and item.statement_group_id = p_statement_group_id
6998 and item.financial_statement_id = p_financial_statement_id
6999 )
7000 )
7001 union
7002 select distinct acc.natural_account_id
7003 from amw_fin_key_accounts_b acc
7004 where ( acc.natural_account_id, acc.account_group_id ) in
7005 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
7006 from amw_fin_items_key_acc finkeyacc
7007 where finkeyacc.statement_group_id = p_statement_group_id
7008 and finkeyacc.financial_statement_id = p_financial_statement_id
7009 and finkeyacc.financial_item_id in
7010 ( select distinct item.child_financial_item_id
7011 from amw_fin_item_flat item
7012 where item.parent_financial_item_id = p_financial_item_id
7013 and item.statement_group_id = p_statement_group_id
7014 and item.financial_statement_id = p_financial_statement_id
7015 union
7016 select distinct item.financial_item_id
7017 from amw_fin_stmnt_items_b item
7018 where item.financial_item_id = p_financial_item_id
7019 and item.statement_group_id = p_statement_group_id
7020 and item.financial_statement_id = p_financial_statement_id
7021 )
7022 )
7023 )
7024
7025 )
7026 )
7027 --) --?
7028 CONNECT BY PRIOR
7029 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
7030 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID)
7031
7032 );
7033
7034 end CountProcsIneffCtrl_finitem;
7035 --------------------------------------------------------------------------------------------------------------------
7036
7037 Procedure CountIneffectiveCtrls_finitem(P_STATEMENT_GROUP_ID in number, P_FINANCIAL_STATEMENT_ID in number,
7038 P_FINANCIAL_ITEM_ID in number, p_ineffective_controls OUT NOCOPY number
7039 , p_start_date in DATE , p_end_date in DATE)
7040
7041 ------------------- Last updted on 1/31/04 by knair -----------------------------------------------
7042 -- Based on the Financial Item ID Passed Computed the Number of Controls , for which an
7043 -- Evaluation was recorded as "Not Effective" during the given period, that Financial Items and
7044 ---Sub Finacial Items that Natural Account and its sub-accounts
7045 --************************************************************************************************
7046 is begin
7047
7048
7049
7050 select count(1) into p_ineffective_controls from(
7051 select distinct ctrlassoc.control_id, orgprocess.organization_id
7052 FROM
7053 AMW_OPINIONS_V opinion,
7054 AMW_OPINION_TYPES_B opiniontype,
7055 FND_OBJECTS fndobject,
7056 AMW_OBJECT_OPINION_TYPES objectopiniontype,
7057 amw_process_org_basicinfo_v orgprocess,
7058 amw_risk_associations riskassoc,
7059 amw_control_associations ctrlassoc
7060 WHERE
7061 (opinion.AUTHORED_DATE in
7062 (Select
7063 MAX(opinion2.AUTHORED_DATE)
7064 from
7065 AMW_OPINIONS_V opinion2
7066 where
7067 opinion.OBJECT_OPINION_TYPE_ID = opinion2.OBJECT_OPINION_TYPE_ID AND
7068 opinion2.PK1_VALUE = opinion.PK1_VALUE and
7069 opinion2.PK3_VALUE = opinion.PK3_VALUE
7070
7071 --- Commented chekcing whether the opinion date falls within the period as
7072 --- per discussion with Say and Bastin on 2/9/04
7073
7074 --AND
7075 -- opinion2.AUTHORED_DATE >= p_start_date and
7076 -- opinion2.AUTHORED_DATE <= p_end_date
7077 ) AND
7078 opinion.OBJECT_OPINION_TYPE_ID = objectopiniontype.OBJECT_OPINION_TYPE_ID AND
7079 opiniontype.OPINION_TYPE_ID = objectopiniontype.OPINION_TYPE_ID AND
7080 opiniontype.OPINION_TYPE_CODE = 'EVALUATION' AND
7081 fndobject.OBJECT_ID = objectopiniontype.OBJECT_ID AND
7082 fndobject.obj_name = 'AMW_ORG_CONTROL' and
7083 -- AccProcs .natural_account_id = P_NATURAL_ACCOUNT_ID and -- from procedure parameter
7084 opinion.pk1_value = ctrlassoc.control_id
7085 and opinion.pk3_value = orgprocess.organization_id --??
7086 and orgprocess.process_organization_id = riskassoc.pk1
7087 and riskassoc.object_type = 'PROCESS_ORG'
7088 and riskassoc.risk_association_id = ctrlassoc.pk1
7089 and ctrlassoc.object_type = 'RISK_ORG'
7090 and opinion.audit_result_CODE <> 'EFFECTIVE')
7091 and opinion.pk3_value = orgprocess.ORGANIZATION_ID
7092 and (opinion.pk3_value = orgprocess.ORGANIZATION_ID)
7093 --and opinion.pk4_value = orgprocess.PROCESS_ID )
7094 and
7095 ( orgprocess.ORGANIZATION_ID , orgprocess.PROCESS_ID )
7096 in
7097 (select procRln.ORGANIZATION_ID ,procRln.CHILD_PROCESS_ID from Amw_Process_Org_Relations procRln
7098 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
7099 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
7100 Amw_acct_associations AccProcs where AccProcs.object_type = 'PROCESS_ORG' and
7101 AccProcs.pk1= orgprocess2.PROCESS_ORGANIZATION_ID
7102 and AccProcs.natural_account_id in
7103 --(select distinct(acc.natural_account_id)
7104 -- from AMW_FIN_KEY_ACCOUNTS_B acc
7105 -- START WITH ( (acc.natural_account_id, acc.account_group_id) in
7106 --- (select finkeyacc.NATURAL_ACCOUNT_ID,finkeyacc.account_group_id from AMW_FIN_ITEMS_KEY_ACC finkeyacc
7107 --where
7108 -- finkeyacc.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
7109 -- and finkeyacc.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
7110 -- and finkeyacc.FINANCIAL_ITEM_ID IN (select
7111 -- distinct(stmtitem.FINANCIAL_ITEM_ID )
7112 -- from AMW_FIN_STMNT_ITEMS_B stmtitem
7113 -- START WITH (stmtitem.FINANCIAL_ITEM_ID = P_FINANCIAL_ITEM_ID
7114 -- and stmtitem.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
7115 -- and stmtitem.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
7116 -- )
7117 -- CONNECT BY PRIOR
7118 -- stmtitem.FINANCIAL_ITEM_ID = stmtitem.PARENT_FINANCIAL_ITEM_ID
7119 --and PRIOR stmtitem.STATEMENT_GROUP_ID = stmtitem.STATEMENT_GROUP_ID
7120 --and PRIOR stmtitem.FINANCIAL_STATEMENT_ID = stmtitem.FINANCIAL_STATEMENT_ID)
7121 --)
7122 --)
7123 -- CONNECT BY PRIOR
7124 --acc.natural_account_id = acc.parent_natural_account_id
7125 -- and PRIOR
7126 --acc.account_group_id = acc.account_group_id) -- end of acc
7127
7128 ( select distinct acc.child_natural_account_id
7129 from amw_fin_key_acct_flat acc
7130 where ( acc.parent_natural_account_id, acc.account_group_id ) in
7131 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
7132 from amw_fin_items_key_acc finkeyacc
7133 where finkeyacc.statement_group_id = p_statement_group_id
7134 and finkeyacc.financial_statement_id = p_financial_statement_id
7135 and finkeyacc.financial_item_id in
7136 ( select distinct item.child_financial_item_id
7137 from amw_fin_item_flat item
7138 where item.parent_financial_item_id = p_financial_item_id
7139 and item.statement_group_id = p_statement_group_id
7140 and item.financial_statement_id = p_financial_statement_id
7141 union
7142 select distinct item.financial_item_id
7143 from amw_fin_stmnt_items_b item
7144 where item.financial_item_id = p_financial_item_id
7145 and item.statement_group_id = p_statement_group_id
7146 and item.financial_statement_id = p_financial_statement_id
7147 )
7148 )
7149 union
7150 select distinct acc.natural_account_id
7151 from amw_fin_key_accounts_b acc
7152 where ( acc.natural_account_id, acc.account_group_id ) in
7153 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
7154 from amw_fin_items_key_acc finkeyacc
7155 where finkeyacc.statement_group_id = p_statement_group_id
7156 and finkeyacc.financial_statement_id = p_financial_statement_id
7157 and finkeyacc.financial_item_id in
7158 ( select distinct item.child_financial_item_id
7159 from amw_fin_item_flat item
7160 where item.parent_financial_item_id = p_financial_item_id
7161 and item.statement_group_id = p_statement_group_id
7162 and item.financial_statement_id = p_financial_statement_id
7163 union
7164 select distinct item.financial_item_id
7165 from amw_fin_stmnt_items_b item
7166 where item.financial_item_id = p_financial_item_id
7167 and item.statement_group_id = p_statement_group_id
7168 and item.financial_statement_id = p_financial_statement_id
7169 )
7170 )
7171 )
7172
7173 )
7174 )
7175 --) --?
7176 CONNECT BY PRIOR
7177 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
7178 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID));
7179
7180
7181
7182
7183 end CountIneffectiveCtrls_finitem;
7184 --------------------------------------------------------------------------------------------------------------------
7185 Procedure CountUnmittigatedRisk_finitem(P_STATEMENT_GROUP_ID in number, P_FINANCIAL_STATEMENT_ID in number,
7186 P_FINANCIAL_ITEM_ID in number, p_unmitigated_risks OUT NOCOPY number
7187 , p_start_date in DATE , p_end_date in DATE)
7188 is begin
7189
7190 ---************************ Last Edited on 1/31/04 by knair **************************************
7191 -- Based on the Financial Item ID Passed Computed the Number of Risks, for which an Evaluation was
7192 -- recorded during the given period as "Not Effective", that Financial Items and Sub Finacial Items
7193 -- that Natural Account and its sub-accounts
7194 ---************************ ****************************************************************************
7195
7196 select count(1) into p_unmitigated_risks from (
7197 select distinct riskassoc.risk_id ,orgprocess.organization_id, orgprocess.Process_ID
7198 FROM
7199 AMW_OPINIONS_V opinion,
7200 AMW_OPINION_TYPES_B opiniontype,
7201 FND_OBJECTS fndobject,
7202 AMW_OBJECT_OPINION_TYPES objectopiniontype,
7203 amw_process_org_basicinfo_v orgprocess,
7204 amw_risk_associations riskassoc
7205 WHERE
7206 (opinion.AUTHORED_DATE in
7207 (Select
7208 MAX(opinion2.AUTHORED_DATE)
7209 from
7210 AMW_OPINIONS_V opinion2
7211 where
7212 opinion.OBJECT_OPINION_TYPE_ID = opinion2.OBJECT_OPINION_TYPE_ID AND
7213 opinion2.PK1_VALUE = opinion.PK1_VALUE and
7214 opinion2.PK3_VALUE = opinion.PK3_VALUE and
7215 opinion2.PK4_VALUE = opinion.PK4_VALUE
7216 --- Commented chekcing whether the opinion date falls within the period as
7217 --- per discussion with Say and Bastin on 2/9/04
7218 -- and
7219 -- opinion2.AUTHORED_DATE >= p_start_date and
7220 -- opinion2.AUTHORED_DATE <= p_end_date
7221 ) AND
7222 opinion.OBJECT_OPINION_TYPE_ID = objectopiniontype.OBJECT_OPINION_TYPE_ID AND
7223 opiniontype.OPINION_TYPE_ID = objectopiniontype.OPINION_TYPE_ID AND
7224 opiniontype.OPINION_TYPE_CODE = 'EVALUATION' AND
7225 fndobject.OBJECT_ID = objectopiniontype.OBJECT_ID AND
7226 fndobject.obj_name = 'AMW_ORG_PROCESS_RISK' and
7227 -- AccProcs .natural_account_id = P_NATURAL_ACCOUNT_ID and -- from procedure parameter
7228 opinion.pk1_value = riskassoc.risk_id
7229 --and opinion.pk3_value = orgprocess.organization_id
7230 -- and opinion.pk4_value = orgprocess.Process_ID
7231 and orgprocess.process_organization_id = riskassoc.pk1
7232 and riskassoc.object_type = 'PROCESS_ORG'
7233 and opinion.audit_result_CODE <> 'EFFECTIVE'
7234 )
7235 -- and (opinion.pk3_value , opinion.pk4_value )
7236 and (opinion.pk3_value = orgprocess.ORGANIZATION_ID and opinion.pk4_value = orgprocess.PROCESS_ID ) and
7237 ( orgprocess.ORGANIZATION_ID , orgprocess.PROCESS_ID )
7238 in
7239 (select procRln.ORGANIZATION_ID ,procRln.CHILD_PROCESS_ID from Amw_Process_Org_Relations procRln
7240 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
7241 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
7242 Amw_acct_associations AccProcs where AccProcs.object_type = 'PROCESS_ORG' and
7243 AccProcs.pk1= orgprocess2.PROCESS_ORGANIZATION_ID
7244 and AccProcs.natural_account_id in
7245
7246 --(select distinct(acc.natural_account_id)
7247 -- from AMW_FIN_KEY_ACCOUNTS_B acc
7248 -- START WITH ( (acc.natural_account_id, acc.account_group_id) in
7249 -- (select finkeyacc.NATURAL_ACCOUNT_ID,finkeyacc.account_group_id from AMW_FIN_ITEMS_KEY_ACC finkeyacc
7250 --where
7251 -- finkeyacc.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
7252 -- and finkeyacc.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
7253 -- and finkeyacc.FINANCIAL_ITEM_ID IN (select
7254 -- distinct(stmtitem.FINANCIAL_ITEM_ID )
7255 -- from AMW_FIN_STMNT_ITEMS_B stmtitem
7256 -- START WITH (stmtitem.FINANCIAL_ITEM_ID = P_FINANCIAL_ITEM_ID
7257 -- and stmtitem.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
7258 -- and stmtitem.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
7259 -- )
7260 -- CONNECT BY PRIOR
7261 -- stmtitem.FINANCIAL_ITEM_ID = stmtitem.PARENT_FINANCIAL_ITEM_ID
7262 --and PRIOR stmtitem.STATEMENT_GROUP_ID = stmtitem.STATEMENT_GROUP_ID
7263 --and PRIOR stmtitem.FINANCIAL_STATEMENT_ID = stmtitem.FINANCIAL_STATEMENT_ID)
7264 --)
7265 --)
7266 -- CONNECT BY PRIOR
7267 --acc.natural_account_id = acc.parent_natural_account_id
7268 -- and PRIOR
7269 --acc.account_group_id = acc.account_group_id) -- end of acc
7270
7271 ( select distinct acc.child_natural_account_id
7272 from amw_fin_key_acct_flat acc
7273 where ( acc.parent_natural_account_id, acc.account_group_id ) in
7274 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
7275 from amw_fin_items_key_acc finkeyacc
7276 where finkeyacc.statement_group_id = p_statement_group_id
7277 and finkeyacc.financial_statement_id = p_financial_statement_id
7278 and finkeyacc.financial_item_id in
7279 ( select distinct item.child_financial_item_id
7280 from amw_fin_item_flat item
7281 where item.parent_financial_item_id = p_financial_item_id
7282 and item.statement_group_id = p_statement_group_id
7283 and item.financial_statement_id = p_financial_statement_id
7284 union
7285 select distinct item.financial_item_id
7286 from amw_fin_stmnt_items_b item
7287 where item.financial_item_id = p_financial_item_id
7288 and item.statement_group_id = p_statement_group_id
7289 and item.financial_statement_id = p_financial_statement_id
7290 )
7291 )
7292 union
7293 select distinct acc.natural_account_id
7294 from amw_fin_key_accounts_b acc
7295 where ( acc.natural_account_id, acc.account_group_id ) in
7296 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
7297 from amw_fin_items_key_acc finkeyacc
7298 where finkeyacc.statement_group_id = p_statement_group_id
7299 and finkeyacc.financial_statement_id = p_financial_statement_id
7300 and finkeyacc.financial_item_id in
7301 ( select distinct item.child_financial_item_id
7302 from amw_fin_item_flat item
7303 where item.parent_financial_item_id = p_financial_item_id
7304 and item.statement_group_id = p_statement_group_id
7305 and item.financial_statement_id = p_financial_statement_id
7306 union
7307 select distinct item.financial_item_id
7308 from amw_fin_stmnt_items_b item
7309 where item.financial_item_id = p_financial_item_id
7310 and item.statement_group_id = p_statement_group_id
7311 and item.financial_statement_id = p_financial_statement_id
7312 )
7313 )
7314 )
7315
7316 )
7317 )
7318 CONNECT BY PRIOR
7319 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
7320 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID)
7321 );
7322
7323 end CountUnmittigatedRisk_finitem;
7324 --------------------------------------------------------------------------------------------------------------------
7325
7326 Procedure CountRisksVerified_finitem( P_STATEMENT_GROUP_ID in number, P_FINANCIAL_STATEMENT_ID in number,
7327 P_FINANCIAL_ITEM_ID in number, p_risks_verified OUT NOCOPY number
7328 , p_start_date in DATE , p_end_date in DATE)
7329
7330 ---************************ Last Edited on 1/31/04 by knair ******************************************************
7331 -- Based on the Financial Item ID Passed Computed the Number of Risks that Financial Items and Sub Finacial Items
7332 -- that Natural Account and its sub-accounts
7333 ---****************************************************************************************************************
7334
7335
7336 is begin
7337
7338 select count(1)
7339 into p_risks_verified
7340 from (
7341 select distinct riskassoc.risk_id ,orgprocess.organization_id, orgprocess.Process_ID
7342 FROM
7343 amw_process_org_basicinfo_v orgprocess,
7344 amw_risk_associations riskassoc
7345 WHERE
7346 orgprocess.process_organization_id = riskassoc.pk1
7347 and riskassoc.object_type = 'PROCESS_ORG'
7348 and (orgprocess.ORGANIZATION_ID , orgprocess.PROCESS_ID )
7349 in
7350 (select procRln.ORGANIZATION_ID ,procRln.CHILD_PROCESS_ID from Amw_Process_Org_Relations procRln
7351 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
7352 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
7353 Amw_acct_associations AccProcs where AccProcs.object_type = 'PROCESS_ORG' and
7354 AccProcs.pk1= orgprocess2.PROCESS_ORGANIZATION_ID
7355 and AccProcs.natural_account_id in
7356 --(select distinct(acc.natural_account_id)
7357 -- from AMW_FIN_KEY_ACCOUNTS_B acc
7358 -- START WITH ( (acc.natural_account_id, acc.account_group_id) in
7359 -- (select finkeyacc.NATURAL_ACCOUNT_ID,finkeyacc.account_group_id from AMW_FIN_ITEMS_KEY_ACC finkeyacc
7360 --where
7361 -- finkeyacc.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
7362 -- and finkeyacc.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
7363 -- and finkeyacc.FINANCIAL_ITEM_ID IN (select
7364 -- distinct(stmtitem.FINANCIAL_ITEM_ID )
7365 -- from AMW_FIN_STMNT_ITEMS_B stmtitem
7366 -- START WITH (stmtitem.FINANCIAL_ITEM_ID = P_FINANCIAL_ITEM_ID
7367 -- and stmtitem.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
7368 -- and stmtitem.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
7369 -- )
7370 -- CONNECT BY PRIOR
7371 -- stmtitem.FINANCIAL_ITEM_ID = stmtitem.PARENT_FINANCIAL_ITEM_ID
7372 --and PRIOR stmtitem.STATEMENT_GROUP_ID = stmtitem.STATEMENT_GROUP_ID
7373 --and PRIOR stmtitem.FINANCIAL_STATEMENT_ID = stmtitem.FINANCIAL_STATEMENT_ID)
7374 --)
7375 --)
7376 -- CONNECT BY PRIOR
7377 --acc.natural_account_id = acc.parent_natural_account_id
7378 -- and PRIOR
7379 --acc.account_group_id = acc.account_group_id) -- end of acc
7380
7381 ( select distinct acc.child_natural_account_id
7382 from amw_fin_key_acct_flat acc
7383 where ( acc.parent_natural_account_id, acc.account_group_id ) in
7384 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
7385 from amw_fin_items_key_acc finkeyacc
7386 where finkeyacc.statement_group_id = p_statement_group_id
7387 and finkeyacc.financial_statement_id = p_financial_statement_id
7388 and finkeyacc.financial_item_id in
7389 ( select distinct item.child_financial_item_id
7390 from amw_fin_item_flat item
7391 where item.parent_financial_item_id = p_financial_item_id
7392 and item.statement_group_id = p_statement_group_id
7393 and item.financial_statement_id = p_financial_statement_id
7394 union
7395 select distinct item.financial_item_id
7396 from amw_fin_stmnt_items_b item
7397 where item.financial_item_id = p_financial_item_id
7398 and item.statement_group_id = p_statement_group_id
7399 and item.financial_statement_id = p_financial_statement_id
7400 )
7401 )
7402 union
7403 select distinct acc.natural_account_id
7404 from amw_fin_key_accounts_b acc
7405 where ( acc.natural_account_id, acc.account_group_id ) in
7406 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
7407 from amw_fin_items_key_acc finkeyacc
7408 where finkeyacc.statement_group_id = p_statement_group_id
7409 and finkeyacc.financial_statement_id = p_financial_statement_id
7410 and finkeyacc.financial_item_id in
7411 ( select distinct item.child_financial_item_id
7412 from amw_fin_item_flat item
7413 where item.parent_financial_item_id = p_financial_item_id
7414 and item.statement_group_id = p_statement_group_id
7415 and item.financial_statement_id = p_financial_statement_id
7416 union
7417 select distinct item.financial_item_id
7418 from amw_fin_stmnt_items_b item
7419 where item.financial_item_id = p_financial_item_id
7420 and item.statement_group_id = p_statement_group_id
7421 and item.financial_statement_id = p_financial_statement_id
7422 )
7423 )
7424 )
7425
7426 )
7427 )
7428 CONNECT BY PRIOR
7429 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
7430 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID)
7431 );
7432
7433 /* -- commented as the Denominator for the "Unmitigated Risks" columns is no longer the Total Risk for which an evaluation
7434 is made but it is the Total Risk Attached to the Processe which in turn attached to the accounts
7435
7436 select count(1) into p_risks_verified from (
7437 select distinct riskassoc.risk_id ,orgprocess.organization_id, orgprocess.Process_ID
7438 FROM
7439 AMW_OPINIONS_V opinion,
7440 AMW_OPINION_TYPES_B opiniontype,
7441 FND_OBJECTS fndobject,
7442 AMW_OBJECT_OPINION_TYPES objectopiniontype,
7443 amw_process_org_basicinfo_v orgprocess,
7444 amw_risk_associations riskassoc
7445 WHERE
7446 (opinion.AUTHORED_DATE in
7447 (Select
7448 MAX(opinion2.AUTHORED_DATE)
7449 from
7450 AMW_OPINIONS_V opinion2
7451 where
7452 opinion.OBJECT_OPINION_TYPE_ID = opinion2.OBJECT_OPINION_TYPE_ID AND
7453 opinion2.PK1_VALUE = opinion.PK1_VALUE and
7454 opinion2.PK3_VALUE = opinion.PK3_VALUE and
7455 opinion2.PK4_VALUE = opinion.PK4_VALUE
7456 and
7457 opinion2.AUTHORED_DATE >= p_start_date and
7458 opinion2.AUTHORED_DATE <= p_end_date
7459 ) AND
7460 opinion.OBJECT_OPINION_TYPE_ID = objectopiniontype.OBJECT_OPINION_TYPE_ID AND
7461 opiniontype.OPINION_TYPE_ID = objectopiniontype.OPINION_TYPE_ID AND
7462 opiniontype.OPINION_TYPE_CODE = 'EVALUATION' AND
7463 fndobject.OBJECT_ID = objectopiniontype.OBJECT_ID AND
7464 fndobject.obj_name = 'AMW_ORG_PROCESS_RISK' and
7465 -- AccProcs .natural_account_id = P_NATURAL_ACCOUNT_ID and -- from procedure parameter
7466 opinion.pk1_value = riskassoc.risk_id
7467 --and opinion.pk3_value = orgprocess.organization_id
7468 -- and opinion.pk4_value = orgprocess.Process_ID
7469 and orgprocess.process_organization_id = riskassoc.pk1
7470 and riskassoc.object_type = 'PROCESS_ORG'
7471 )
7472 -- and (opinion.pk3_value , opinion.pk4_value )
7473 and (opinion.pk3_value = orgprocess.ORGANIZATION_ID and opinion.pk4_value = orgprocess.PROCESS_ID ) and
7474 ( orgprocess.ORGANIZATION_ID , orgprocess.PROCESS_ID )
7475 in
7476 (select procRln.ORGANIZATION_ID ,procRln.CHILD_PROCESS_ID from Amw_Process_Org_Relations procRln
7477 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
7478 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
7479 Amw_acct_associations AccProcs where AccProcs.object_type = 'PROCESS_ORG' and
7480 AccProcs.pk1= orgprocess2.PROCESS_ORGANIZATION_ID
7481 and AccProcs.natural_account_id in
7482
7483 --(select distinct(acc.natural_account_id)
7484 -- from AMW_FIN_KEY_ACCOUNTS_B acc
7485 -- START WITH ( (acc.natural_account_id, acc.account_group_id) in
7486 -- (select finkeyacc.NATURAL_ACCOUNT_ID,finkeyacc.account_group_id from AMW_FIN_ITEMS_KEY_ACC finkeyacc
7487 --where
7488 -- finkeyacc.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
7489 -- and finkeyacc.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
7490 -- and finkeyacc.FINANCIAL_ITEM_ID IN (select
7491 -- distinct(stmtitem.FINANCIAL_ITEM_ID )
7492 -- from AMW_FIN_STMNT_ITEMS_B stmtitem
7493 -- START WITH (stmtitem.FINANCIAL_ITEM_ID = P_FINANCIAL_ITEM_ID
7494 -- and stmtitem.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
7495 -- and stmtitem.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
7496 -- )
7497 -- CONNECT BY PRIOR
7498 -- stmtitem.FINANCIAL_ITEM_ID = stmtitem.PARENT_FINANCIAL_ITEM_ID
7499 --and PRIOR stmtitem.STATEMENT_GROUP_ID = stmtitem.STATEMENT_GROUP_ID
7500 --and PRIOR stmtitem.FINANCIAL_STATEMENT_ID = stmtitem.FINANCIAL_STATEMENT_ID)
7501 --)
7502 --)
7503 -- CONNECT BY PRIOR
7504 --acc.natural_account_id = acc.parent_natural_account_id
7505 -- and PRIOR
7506 --acc.account_group_id = acc.account_group_id) -- end of acc
7507
7508 ( select distinct acc.child_natural_account_id
7509 from amw_fin_key_acct_flat acc
7510 where ( acc.parent_natural_account_id, acc.account_group_id ) in
7511 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
7512 from amw_fin_items_key_acc finkeyacc
7513 where finkeyacc.statement_group_id = p_statement_group_id
7514 and finkeyacc.financial_statement_id = p_financial_statement_id
7515 and finkeyacc.financial_item_id in
7516 ( select distinct item.child_financial_item_id
7517 from amw_fin_item_flat item
7518 where item.parent_financial_item_id = p_financial_item_id
7519 and item.statement_group_id = p_statement_group_id
7520 and item.financial_statement_id = p_financial_statement_id
7521 union
7522 select distinct item.financial_item_id
7523 from amw_fin_stmnt_items_b item
7524 where item.financial_item_id = p_financial_item_id
7525 and item.statement_group_id = p_statement_group_id
7526 and item.financial_statement_id = p_financial_statement_id
7527 )
7528 )
7529 union
7530 select distinct acc.natural_account_id
7531 from amw_fin_key_accounts_b acc
7532 where ( acc.natural_account_id, acc.account_group_id ) in
7533 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
7534 from amw_fin_items_key_acc finkeyacc
7535 where finkeyacc.statement_group_id = p_statement_group_id
7536 and finkeyacc.financial_statement_id = p_financial_statement_id
7537 and finkeyacc.financial_item_id in
7538 ( select distinct item.child_financial_item_id
7539 from amw_fin_item_flat item
7540 where item.parent_financial_item_id = p_financial_item_id
7541 and item.statement_group_id = p_statement_group_id
7542 and item.financial_statement_id = p_financial_statement_id
7543 union
7544 select distinct item.financial_item_id
7545 from amw_fin_stmnt_items_b item
7546 where item.financial_item_id = p_financial_item_id
7547 and item.statement_group_id = p_statement_group_id
7548 and item.financial_statement_id = p_financial_statement_id
7549 )
7550 )
7551 )
7552
7553 )
7554 )
7555 CONNECT BY PRIOR
7556 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
7557 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID)
7558 );
7559
7560 --------------------------------------------------------------*/
7561
7562 end CountRisksVerified_finitem;
7563 --------------------------------------------------------------------------------------------------------------------
7564
7565
7566 Procedure CountControlsVerified_finitem(P_STATEMENT_GROUP_ID in number, P_FINANCIAL_STATEMENT_ID in number,
7567 P_FINANCIAL_ITEM_ID in number, p_controls_verified OUT NOCOPY number
7568 , p_start_date in DATE , p_end_date in DATE)
7569 is begin
7570
7571 ------------------- Last updted on 1/31/04 by knair -----------------------------------------------
7572 -- Based on the Financial Item ID Passed Computed the Number of Controls , for which an
7573 -- Evaluation was recorded during the given period (irrespective of what is the opinion result is as
7574 -- this is a total count of Controls which were evaluated), , that Financial Items and
7575 ---Sub Finacial Items that Natural Account and its sub-accounts
7576 --************************************************************************************************
7577
7578 select count(1)
7579 into p_controls_verified
7580 from (
7581 select distinct ctrlassoc.control_id, orgprocess.organization_id
7582 FROM
7583 amw_process_org_basicinfo_v orgprocess,
7584 amw_risk_associations riskassoc,
7585 amw_control_associations ctrlassoc
7586 WHERE
7587 orgprocess.process_organization_id = riskassoc.pk1
7588 and riskassoc.object_type = 'PROCESS_ORG'
7589 and riskassoc.risk_association_id = ctrlassoc.pk1
7590 and ctrlassoc.object_type = 'RISK_ORG'
7591 and
7592 ( orgprocess.ORGANIZATION_ID , orgprocess.PROCESS_ID )
7593 in
7594 (select procRln.ORGANIZATION_ID ,procRln.CHILD_PROCESS_ID from Amw_Process_Org_Relations procRln
7595 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
7596 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
7597 Amw_acct_associations AccProcs where AccProcs.object_type = 'PROCESS_ORG' and
7598 AccProcs.pk1= orgprocess2.PROCESS_ORGANIZATION_ID
7599 and AccProcs.natural_account_id in
7600 --(select distinct(acc.natural_account_id)
7601 -- from AMW_FIN_KEY_ACCOUNTS_B acc
7602 -- START WITH ( (acc.natural_account_id, acc.account_group_id) in
7603 -- (select finkeyacc.NATURAL_ACCOUNT_ID,finkeyacc.account_group_id from AMW_FIN_ITEMS_KEY_ACC finkeyacc
7604 --where
7605 -- finkeyacc.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
7606 -- and finkeyacc.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
7607 -- and finkeyacc.FINANCIAL_ITEM_ID IN (select
7608 -- distinct(stmtitem.FINANCIAL_ITEM_ID )
7609 -- from AMW_FIN_STMNT_ITEMS_B stmtitem
7610 -- START WITH (stmtitem.FINANCIAL_ITEM_ID = P_FINANCIAL_ITEM_ID
7611 -- and stmtitem.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
7612 -- and stmtitem.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
7613 -- )
7614 -- CONNECT BY PRIOR
7615 -- stmtitem.FINANCIAL_ITEM_ID = stmtitem.PARENT_FINANCIAL_ITEM_ID
7616 --and PRIOR stmtitem.STATEMENT_GROUP_ID = stmtitem.STATEMENT_GROUP_ID
7617 --and PRIOR stmtitem.FINANCIAL_STATEMENT_ID = stmtitem.FINANCIAL_STATEMENT_ID)
7618 --)
7619 --)
7620 -- CONNECT BY PRIOR
7621 --acc.natural_account_id = acc.parent_natural_account_id
7622 -- and PRIOR
7623 --acc.account_group_id = acc.account_group_id) -- end of acc
7624
7625 ( select distinct acc.child_natural_account_id
7626 from amw_fin_key_acct_flat acc
7627 where ( acc.parent_natural_account_id, acc.account_group_id ) in
7628 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
7629 from amw_fin_items_key_acc finkeyacc
7630 where finkeyacc.statement_group_id = p_statement_group_id
7631 and finkeyacc.financial_statement_id = p_financial_statement_id
7632 and finkeyacc.financial_item_id in
7633 ( select distinct item.child_financial_item_id
7634 from amw_fin_item_flat item
7635 where item.parent_financial_item_id = p_financial_item_id
7636 and item.statement_group_id = p_statement_group_id
7637 and item.financial_statement_id = p_financial_statement_id
7638 union
7639 select distinct item.financial_item_id
7640 from amw_fin_stmnt_items_b item
7641 where item.financial_item_id = p_financial_item_id
7642 and item.statement_group_id = p_statement_group_id
7643 and item.financial_statement_id = p_financial_statement_id
7644 )
7645 )
7646 union
7647 select distinct acc.natural_account_id
7648 from amw_fin_key_accounts_b acc
7649 where ( acc.natural_account_id, acc.account_group_id ) in
7650 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
7651 from amw_fin_items_key_acc finkeyacc
7652 where finkeyacc.statement_group_id = p_statement_group_id
7653 and finkeyacc.financial_statement_id = p_financial_statement_id
7654 and finkeyacc.financial_item_id in
7655 ( select distinct item.child_financial_item_id
7656 from amw_fin_item_flat item
7657 where item.parent_financial_item_id = p_financial_item_id
7658 and item.statement_group_id = p_statement_group_id
7659 and item.financial_statement_id = p_financial_statement_id
7660 union
7661 select distinct item.financial_item_id
7662 from amw_fin_stmnt_items_b item
7663 where item.financial_item_id = p_financial_item_id
7664 and item.statement_group_id = p_statement_group_id
7665 and item.financial_statement_id = p_financial_statement_id
7666 )
7667 )
7668 )
7669
7670 )
7671 )
7672 --) --?
7673 CONNECT BY PRIOR
7674 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
7675 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID));
7676
7677
7678 /* -- commented as the Denominator for the "Ineff Controls" columns is no longer the Total Controls for which an evaluation
7679 is made but it is the Total Controls that are Attached to the Process-risks which in turn attached to the accounts
7680
7681
7682 select count(1) into p_controls_verified from (
7683 select distinct ctrlassoc.control_id, orgprocess.organization_id
7684 FROM
7685 AMW_OPINIONS_V opinion,
7686 AMW_OPINION_TYPES_B opiniontype,
7687 FND_OBJECTS fndobject,
7688 AMW_OBJECT_OPINION_TYPES objectopiniontype,
7689 amw_process_org_basicinfo_v orgprocess,
7690 amw_risk_associations riskassoc,
7691 amw_control_associations ctrlassoc
7692 WHERE
7693 (opinion.AUTHORED_DATE in
7694 (Select
7695 MAX(opinion2.AUTHORED_DATE)
7696 from
7697 AMW_OPINIONS_V opinion2
7698 where
7699 opinion.OBJECT_OPINION_TYPE_ID = opinion2.OBJECT_OPINION_TYPE_ID AND
7700 opinion2.PK1_VALUE = opinion.PK1_VALUE and
7701 opinion2.PK3_VALUE = opinion.PK3_VALUE AND
7702 opinion2.AUTHORED_DATE >= p_start_date and
7703 opinion2.AUTHORED_DATE <= p_end_date
7704 ) AND
7705 opinion.OBJECT_OPINION_TYPE_ID = objectopiniontype.OBJECT_OPINION_TYPE_ID AND
7706 opiniontype.OPINION_TYPE_ID = objectopiniontype.OPINION_TYPE_ID AND
7707 opiniontype.OPINION_TYPE_CODE = 'EVALUATION' AND
7708 fndobject.OBJECT_ID = objectopiniontype.OBJECT_ID AND
7709 fndobject.obj_name = 'AMW_ORG_CONTROL' and
7710 -- AccProcs .natural_account_id = P_NATURAL_ACCOUNT_ID and -- from procedure parameter
7711 opinion.pk1_value = ctrlassoc.control_id
7712 and opinion.pk3_value = orgprocess.organization_id --??
7713 and orgprocess.process_organization_id = riskassoc.pk1
7714 and riskassoc.object_type = 'PROCESS_ORG'
7715 and riskassoc.risk_association_id = ctrlassoc.pk1
7716 and ctrlassoc.object_type = 'RISK_ORG'
7717 and opinion.audit_result_CODE <> 'EFFECTIVE')
7718 and opinion.pk3_value = orgprocess.ORGANIZATION_ID
7719 and (opinion.pk3_value = orgprocess.ORGANIZATION_ID)
7720 --and opinion.pk4_value = orgprocess.PROCESS_ID )
7721 and
7722 ( orgprocess.ORGANIZATION_ID , orgprocess.PROCESS_ID )
7723 in
7724 (select procRln.ORGANIZATION_ID ,procRln.CHILD_PROCESS_ID from Amw_Process_Org_Relations procRln
7725 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
7726 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
7727 Amw_acct_associations AccProcs where AccProcs.object_type = 'PROCESS_ORG' and
7728 AccProcs.pk1= orgprocess2.PROCESS_ORGANIZATION_ID
7729 and AccProcs.natural_account_id in
7730 --(select distinct(acc.natural_account_id)
7731 -- from AMW_FIN_KEY_ACCOUNTS_B acc
7732 -- START WITH ( (acc.natural_account_id, acc.account_group_id) in
7733 -- (select finkeyacc.NATURAL_ACCOUNT_ID,finkeyacc.account_group_id from AMW_FIN_ITEMS_KEY_ACC finkeyacc
7734 --where
7735 -- finkeyacc.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
7736 -- and finkeyacc.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
7737 -- and finkeyacc.FINANCIAL_ITEM_ID IN (select
7738 -- distinct(stmtitem.FINANCIAL_ITEM_ID )
7739 -- from AMW_FIN_STMNT_ITEMS_B stmtitem
7740 -- START WITH (stmtitem.FINANCIAL_ITEM_ID = P_FINANCIAL_ITEM_ID
7741 -- and stmtitem.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
7742 -- and stmtitem.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
7743 -- )
7744 -- CONNECT BY PRIOR
7745 -- stmtitem.FINANCIAL_ITEM_ID = stmtitem.PARENT_FINANCIAL_ITEM_ID
7746 --and PRIOR stmtitem.STATEMENT_GROUP_ID = stmtitem.STATEMENT_GROUP_ID
7747 --and PRIOR stmtitem.FINANCIAL_STATEMENT_ID = stmtitem.FINANCIAL_STATEMENT_ID)
7748 --)
7749 --)
7750 -- CONNECT BY PRIOR
7751 --acc.natural_account_id = acc.parent_natural_account_id
7752 -- and PRIOR
7753 --acc.account_group_id = acc.account_group_id) -- end of acc
7754
7755 ( select distinct acc.child_natural_account_id
7756 from amw_fin_key_acct_flat acc
7757 where ( acc.parent_natural_account_id, acc.account_group_id ) in
7758 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
7759 from amw_fin_items_key_acc finkeyacc
7760 where finkeyacc.statement_group_id = p_statement_group_id
7761 and finkeyacc.financial_statement_id = p_financial_statement_id
7762 and finkeyacc.financial_item_id in
7763 ( select distinct item.child_financial_item_id
7764 from amw_fin_item_flat item
7765 where item.parent_financial_item_id = p_financial_item_id
7766 and item.statement_group_id = p_statement_group_id
7767 and item.financial_statement_id = p_financial_statement_id
7768 union
7769 select distinct item.financial_item_id
7770 from amw_fin_stmnt_items_b item
7771 where item.financial_item_id = p_financial_item_id
7772 and item.statement_group_id = p_statement_group_id
7773 and item.financial_statement_id = p_financial_statement_id
7774 )
7775 )
7776 union
7777 select distinct acc.natural_account_id
7778 from amw_fin_key_accounts_b acc
7779 where ( acc.natural_account_id, acc.account_group_id ) in
7780 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
7781 from amw_fin_items_key_acc finkeyacc
7782 where finkeyacc.statement_group_id = p_statement_group_id
7783 and finkeyacc.financial_statement_id = p_financial_statement_id
7784 and finkeyacc.financial_item_id in
7785 ( select distinct item.child_financial_item_id
7786 from amw_fin_item_flat item
7787 where item.parent_financial_item_id = p_financial_item_id
7788 and item.statement_group_id = p_statement_group_id
7789 and item.financial_statement_id = p_financial_statement_id
7790 union
7791 select distinct item.financial_item_id
7792 from amw_fin_stmnt_items_b item
7793 where item.financial_item_id = p_financial_item_id
7794 and item.statement_group_id = p_statement_group_id
7795 and item.financial_statement_id = p_financial_statement_id
7796 )
7797 )
7798 )
7799
7800 )
7801 )
7802 --) --?
7803 CONNECT BY PRIOR
7804 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
7805 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID));
7806 ------------------------------------------------------------------------- */
7807
7808 end CountControlsVerified_finitem;
7809
7810 --------------------------------------------------------------------------------------------------------------------
7811 Procedure CountOrgswithIssues_finitem(P_STATEMENT_GROUP_ID in number, P_FINANCIAL_STATEMENT_ID in number,
7812 P_FINANCIAL_ITEM_ID in number, P_org_cert_with_issues OUT NOCOPY number
7813 , p_start_date in DATE , p_end_date in DATE)
7814
7815 --------------------------- Last updted on 1/31/04 by knair --------------------------------------------------
7816 --Based on the Financial Item ID Passed Computed the Number Orgs, for which a Certification with Not Effective
7817 -- result was recorded during the given period, that are associated to that Natural Account and its sub-accounts
7818 --**************************************************************************************************************
7819 is begin
7820 select count(1) into P_org_cert_with_issues from (
7821 select distinct orgprocess.ORGANIZATION_ID
7822 FROM
7823 AMW_OPINIONS_V opinion,
7824 AMW_OPINION_TYPES_B opiniontype,
7825 FND_OBJECTS fndobject,
7826 AMW_OBJECT_OPINION_TYPES objectopiniontype,
7827 amw_process_org_basicinfo_v orgprocess
7828 WHERE
7829 (opinion.AUTHORED_DATE in
7830 (Select
7831 MAX(opinion2.AUTHORED_DATE)
7832 from
7833 AMW_OPINIONS_V opinion2
7834 where
7835 opinion.OBJECT_OPINION_TYPE_ID = opinion2.OBJECT_OPINION_TYPE_ID AND
7836 opinion2.PK1_VALUE = opinion.PK1_VALUE AND
7837 opinion2.AUTHORED_DATE >= p_start_date
7838 and
7839 opinion2.AUTHORED_DATE <= p_end_date
7840 ) AND
7841 opinion.OBJECT_OPINION_TYPE_ID = objectopiniontype.OBJECT_OPINION_TYPE_ID AND
7842 opiniontype.OPINION_TYPE_ID = objectopiniontype.OPINION_TYPE_ID AND
7843 opiniontype.OPINION_TYPE_CODE = 'CERTIFICATION' AND
7844 fndobject.OBJECT_ID = objectopiniontype.OBJECT_ID AND
7845 fndobject.obj_name = 'AMW_ORGANIZATION'
7846 and opinion.audit_result_CODE <> 'EFFECTIVE'
7847 )
7848 and opinion.PK1_VALUE = orgprocess.ORGANIZATION_ID
7849 and orgprocess.ORGANIZATION_ID
7850 in
7851 (select procRln.ORGANIZATION_ID from Amw_Process_Org_Relations procRln
7852 START WITH ((procRln.CHILD_PROCESS_ID , procRln.ORGANIZATION_ID) in
7853 ( select orgprocess2.PROCESS_ID , orgprocess2.ORGANIZATION_ID from amw_process_org_basicinfo_v orgprocess2,
7854 Amw_acct_associations AccProcs where AccProcs.object_type = 'PROCESS_ORG' and
7855 AccProcs.pk1= orgprocess2.PROCESS_ORGANIZATION_ID
7856 and AccProcs.natural_account_id in
7857 --(select distinct(acc.natural_account_id)
7858 -- from AMW_FIN_KEY_ACCOUNTS_B acc
7859 -- START WITH ( (acc.natural_account_id, acc.account_group_id) in
7860 -- (select finkeyacc.NATURAL_ACCOUNT_ID,finkeyacc.account_group_id from AMW_FIN_ITEMS_KEY_ACC finkeyacc
7861 --where
7862 -- finkeyacc.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
7863 -- and finkeyacc.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
7864 -- and finkeyacc.FINANCIAL_ITEM_ID IN (select
7865 -- distinct(stmtitem.FINANCIAL_ITEM_ID )
7866 -- from AMW_FIN_STMNT_ITEMS_B stmtitem
7867 -- START WITH (stmtitem.FINANCIAL_ITEM_ID = P_FINANCIAL_ITEM_ID
7868 -- and stmtitem.STATEMENT_GROUP_ID = P_STATEMENT_GROUP_ID
7869 -- and stmtitem.FINANCIAL_STATEMENT_ID = P_FINANCIAL_STATEMENT_ID
7870 -- )
7871 -- CONNECT BY PRIOR
7872 -- stmtitem.FINANCIAL_ITEM_ID = stmtitem.PARENT_FINANCIAL_ITEM_ID
7873 --and PRIOR stmtitem.STATEMENT_GROUP_ID = stmtitem.STATEMENT_GROUP_ID
7874 --and PRIOR stmtitem.FINANCIAL_STATEMENT_ID = stmtitem.FINANCIAL_STATEMENT_ID)
7875 --)
7876 --)
7877 -- CONNECT BY PRIOR
7878 --acc.natural_account_id = acc.parent_natural_account_id
7879 -- and PRIOR
7880 --acc.account_group_id = acc.account_group_id) -- end of acc
7881
7882 ( select distinct acc.child_natural_account_id
7883 from amw_fin_key_acct_flat acc
7884 where ( acc.parent_natural_account_id, acc.account_group_id ) in
7885 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
7886 from amw_fin_items_key_acc finkeyacc
7887 where finkeyacc.statement_group_id = p_statement_group_id
7888 and finkeyacc.financial_statement_id = p_financial_statement_id
7889 and finkeyacc.financial_item_id in
7890 ( select distinct item.child_financial_item_id
7891 from amw_fin_item_flat item
7892 where item.parent_financial_item_id = p_financial_item_id
7893 and item.statement_group_id = p_statement_group_id
7894 and item.financial_statement_id = p_financial_statement_id
7895 union
7896 select distinct item.financial_item_id
7897 from amw_fin_stmnt_items_b item
7898 where item.financial_item_id = p_financial_item_id
7899 and item.statement_group_id = p_statement_group_id
7900 and item.financial_statement_id = p_financial_statement_id
7901 )
7902 )
7903 union
7904 select distinct acc.natural_account_id
7905 from amw_fin_key_accounts_b acc
7906 where ( acc.natural_account_id, acc.account_group_id ) in
7907 ( select finkeyacc.natural_account_id, finkeyacc.account_group_id
7908 from amw_fin_items_key_acc finkeyacc
7909 where finkeyacc.statement_group_id = p_statement_group_id
7910 and finkeyacc.financial_statement_id = p_financial_statement_id
7911 and finkeyacc.financial_item_id in
7912 ( select distinct item.child_financial_item_id
7913 from amw_fin_item_flat item
7914 where item.parent_financial_item_id = p_financial_item_id
7915 and item.statement_group_id = p_statement_group_id
7916 and item.financial_statement_id = p_financial_statement_id
7917 union
7918 select distinct item.financial_item_id
7919 from amw_fin_stmnt_items_b item
7920 where item.financial_item_id = p_financial_item_id
7921 and item.statement_group_id = p_statement_group_id
7922 and item.financial_statement_id = p_financial_statement_id
7923 )
7924 )
7925 )
7926
7927 )
7928 )
7929 --) --?
7930 CONNECT BY PRIOR
7931 procRln.ORGANIZATION_ID = procRln.ORGANIZATION_ID
7932 and PRIOR procRln.CHILD_PROCESS_ID = procRln.PARENT_PROCESS_ID)
7933 );
7934
7935 end CountOrgswithIssues_finitem;
7936
7937
7938 --------------------------------------- End of Block of Code Added by Krishnan ---------------------------------------
7939
7940 /*===========================================================================+
7941 | PROCEDURE |
7942 | Populate_Fin_Stmt_Cert_Sum |
7943 | |
7944 | DESCRIPTION |
7945 | This procedure is called by the concurrent program. |
7946 | This procedure will call 4 sub requests to synchronize the Financial |
7947 | Statement Certification Data. |
7948 | |
7949 | SCOPE - |
7950 | |
7951 | EXTERNAL PROCEDURES/FUNCTIONS ACCESSED - NONE |
7952 | |
7953 | |
7954 | ARGUMENTS : IN : |
7955 | p_certification_id : The Certification id
7956 | |
7957 | RETURNS : NONE |
7958 | |
7959 | NOTES |
7960 | |
7961 | MODIFICATION HISTORY - Created by yreddy - 03-FEB-2004 |
7962 | |
7963 +===========================================================================*/
7964 PROCEDURE Populate_Fin_Stmt_Cert_Sum(
7965 errbuf OUT NOCOPY VARCHAR2,
7966 retcode OUT NOCOPY VARCHAR2,
7967 p_certification_id IN NUMBER
7968 )
7969 IS
7970
7971 l_request_id NUMBER;
7972 l_msg VARCHAR2(2000);
7973 l_reqdata VARCHAR2(240);
7974
7975 BEGIN
7976 fnd_file.put_line (fnd_file.LOG,'Certification Id :' || p_certification_id);
7977
7978
7979
7980 l_reqdata := FND_CONC_GLOBAL.request_data;
7981 IF (l_reqdata is NOT NULL) THEN
7982 return;
7983 END IF;
7984 l_reqdata := 1;
7985
7986
7987 ---comment out because we have to obey a certain sequence to populate the summary tables in amw.d---
7988 --so remove 3 CM request and left one ----
7989 /* Sub Request for Process Summary */
7990 l_request_id := FND_REQUEST.SUBMIT_REQUEST('AMW',
7991 'FCPROSUM',
7992 null,
7993 null,
7994 TRUE,
7995 to_char(p_certification_id));
7996 IF l_request_id = 0 THEN
7997 l_msg:=FND_MESSAGE.GET;
7998 fnd_file.put_line (fnd_file.LOG,l_msg);
7999 ELSE
8000 fnd_file.put_line (fnd_file.LOG,'Submitted Request for Process Summary :' || l_request_id );
8001 END IF;
8002
8003 /*********************
8004 ----Sub Request for Financial Item Summary --
8005 l_request_id := FND_REQUEST.SUBMIT_REQUEST('AMW',
8006 'FSIEVLSUM',
8007 null,
8008 null,
8009 TRUE,
8010 to_char(p_certification_id));
8011 IF l_request_id = 0 THEN
8012 l_msg:=FND_MESSAGE.GET;
8013 fnd_file.put_line (fnd_file.LOG,l_msg);
8014 ELSE
8015 fnd_file.put_line (fnd_file.LOG,'Submitted Request for Financial Item Summary :' || l_request_id );
8016 END IF;
8017
8018
8019 ---Sub Request for Dashboard Summary --
8020 l_request_id := FND_REQUEST.SUBMIT_REQUEST('AMW',
8021 'FSDASHSUM',
8022 null,
8023 null,
8024 TRUE,
8025 to_char(p_certification_id));
8026 IF l_request_id = 0 THEN
8027 l_msg:=FND_MESSAGE.GET;
8028 fnd_file.put_line (fnd_file.LOG,l_msg);
8029 ELSE
8030 fnd_file.put_line (fnd_file.LOG,'Submitted Request for Dashboard Summary :' || l_request_id );
8031 END IF;
8032
8033
8034 ---Sub Request for Organization Summary ---
8035 l_request_id := FND_REQUEST.SUBMIT_REQUEST('AMW',
8036 'FCORGSUM',
8037 null,
8038 null,
8039 TRUE,
8040 to_char(p_certification_id));
8041 IF l_request_id = 0 THEN
8042 l_msg:=FND_MESSAGE.GET;
8043 fnd_file.put_line (fnd_file.LOG,l_msg);
8044 ELSE
8045 fnd_file.put_line (fnd_file.LOG,'Submitted Request for Organization Summary :' || l_request_id );
8046 END IF;
8047
8048 **********************/
8049
8050
8051
8052 FND_CONC_GLOBAL.set_req_globals(conc_status => 'PAUSED',
8053 request_data => l_reqdata);
8054 COMMIT;
8055
8056
8057 EXCEPTION
8058 WHEN OTHERS THEN
8059 fnd_file.put_line (fnd_file.LOG, SUBSTR ('Unexpected Error in Populate_Fin_Stmt_Cert_Sum'
8060 || SUBSTR (SQLERRM, 1, 100), 1, 200));
8061 errbuf := SQLERRM;
8062 retcode := FND_API.G_RET_STS_UNEXP_ERROR;
8063
8064 END Populate_Fin_Stmt_Cert_Sum;
8065
8066
8067
8068 END AMW_FINSTMT_CERT_PVT;