1 PACKAGE BODY AMW_CONSTRAINT_PVT AS
2 /* $Header: amwvcstb.pls 120.32.12010000.1 2008/07/28 08:35:45 appldev ship $ */
3
4 -- ===============================================================
5 -- Package name
6 -- AMW_CONSTRAINT_PVT
7 -- Purpose
8 --
9 -- History
10 -- 11/12/2003 tsho Creates
11 -- 12/12/2003 tsho use static sql for database 8.1.7.4.0 with AMW.B
12 -- 04/30/2003 tsho enable dynamic sql in AMW.C with framework 5.10
13 -- 05/05/2004 tsho add Get_Functions and related getters
14 -- 01/06/2005 tsho consider Responsibility, User waivers in AMW.D
15 -- 05/13/2005 tsho introduce Cocurrent Program, Incomapatible Sets, Revalidation, (Role, GLOBAL Grant/USER Grant) in AMW.E
16 -- 12/01/2005 tsho add Purge_Violation_Before_Date (for bug 4673154)
17 -- 12/01/2005 psomanat For Perfomance Fix :
18 -- 1. Modified procedures Check_For_Func_Cst_ALL
19 -- Check_For_Func_Cst_ME,Check_For_Func_Cst_SET
20 -- Check_For_Resp_Cst_ALL,Check_For_Resp_Cst_ME
21 -- Check_For_Resp_Cst_SET,Populate_Ptnl_Access_List
22 -- Populate_Ptnl_Resps_For_Cst,Write_Func_To_Table_For_User
23 -- Write_Resp_To_Table_For_User,Write_Resp_Violat_to_table
24 -- Write_Resp_Violat_to_table_rvl
25 --
26 -- 2. Added Procedures Populate_User_Vio_For_Cst,
27 -- Populate_User_Vio_For_Vlt,PROCESS_MENU_TREE_DOWN_FOR_CST
28 -- ===============================================================
29
30
31 -- copy from FND_FUNCTION.G_BULK_COLLECTS_SUPPORTED (AFSCFNSB.pls 115.51 2003/08/01)
32 -- Bulk collects are a feature that will have the benefit of increasing
33 -- performance and hopefully reducing I/O reads on dev115
34 -- But the problem is they cause random failures in 8.1.6.1 databases
35 -- so we can't use them before 8.1.7.1. (due to database bug 1688232).
36 -- So we will detect the database version and set this flag to one of:
37 -- 'UNKNOWN'- Flag needs to be initialized by call to init routine
38 -- 'TRUE' - supported
39 -- 'FALSE'- unsupported
40 -- Once 8.1.7.1+ is required for all Apps customers then this hack
41 -- Can be gotten rid of, and this can be hardcoded to 'TRUE'
42 -- 2/03- TM- That time is now... we now require 8.1.7.1+.
43 G_BULK_COLLECTS_SUPPORTED VARCHAR2(30) := 'TRUE';
44
45
46 -- copy from FND_FUNCTION.C_MAX_MENU_ENTRIES (AFSCFNSB.pls 115.51 2003/08/01)
47 -- This constant is used for recursion detection in the fallback
48 -- runtime menu scan. We keep track of how many items are on the menu,
49 -- and assume if the number of entries on the current
50 -- menu is too high then it's caused by recursion.
51 C_MAX_MENU_ENTRIES CONSTANT pls_integer := 10000;
52
53
54 -- copy from FND_FUNCTION.P_LAST_RESP_ID (AFSCFNSB.pls 115.51 2003/08/01)
55 -- copy from FND_FUNCTION.P_LAST_RESP_APPL_ID (AFSCFNSB.pls 115.51 2003/08/01)
56 -- copy from FND_FUNCTION.P_LAST_MENU_ID (AFSCFNSB.pls 115.51 2003/08/01)
57 -- This simple cache will avoid the need to find which menu is on
58 -- the current responsibility with SQL every time. We just store
59 -- the menu around after we get it for the current resp.
60 P_LAST_RESP_ID NUMBER := -1;
61 P_LAST_RESP_APPL_ID NUMBER := -1;
62 P_LAST_MENU_ID NUMBER := -1;
63
64
65 -- store potential violation info (valid for one user against one constraint)
66 TYPE G_NUMBER_TABLE IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
67 TYPE G_DATE_TABLE IS TABLE OF DATE INDEX BY BINARY_INTEGER;
68 TYPE G_VARCHAR2_TABLE IS TABLE OF VARCHAR2(1) INDEX BY BINARY_INTEGER;
69 TYPE G_VARCHAR2_CODE_TABLE IS TABLE OF VARCHAR2(30) INDEX BY BINARY_INTEGER;
70 TYPE G_VARCHAR2_LONG_TABLE is table of VARCHAR2(320) INDEX BY BINARY_INTEGER;
71
72 TYPE G_VARCHAR2_TABLE_TYPE IS TABLE OF VARCHAR2(50) INDEX BY VARCHAR2(50);
73 TYPE G_NUMBER_TABLE_TYPE IS TABLE OF NUMBER INDEX BY VARCHAR2(50);
74 TYPE G_RESPVIO_RECORD IS RECORD(
75 Responsibility_id NUMBER(15),
76 application_id NUMBER(15),
77 Role_Name VARCHAR2(320),
78 Menu_id NUMBER,
79 Function_Id NUMBER,
80 Access_Given_Date DATE,
81 Access_Given_By_Id NUMBER(15),
82 Object_Type VARCHAR2(80),
83 group_code VARCHAR2(80),
84 prog_appl_id NUMBER(15)
85 );
86
87 TYPE G_RESPVIO_ENTRIES_TABLE IS TABLE OF G_RESPVIO_RECORD INDEX BY BINARY_INTEGER;
88 TYPE G_FUNC_TABLE IS TABLE OF G_RESPVIO_ENTRIES_TABLE INDEX BY BINARY_INTEGER;
89 TYPE G_RESPVIO_TABLE IS TABLE OF G_FUNC_TABLE INDEX BY VARCHAR2(30);
90
91 TYPE G_USERVIO_RECORD IS RECORD(
92 User_id NUMBER(15),
93 Role_Name VARCHAR2(320),
94 application_id NUMBER(15),
95 Responsibility_id NUMBER(15),
96 Menu_id NUMBER,
97 Function_Id NUMBER,
98 prog_appl_id NUMBER(15),
99 Access_Given_Date DATE,
100 Access_Given_By_Id NUMBER(15),
101 Object_Type VARCHAR2(80),
102 Waived VARCHAR2(1),
103 group_code VARCHAR2(80)
104 );
105
106 TYPE G_USERVIO_ENTRIES_TABLE IS TABLE OF G_USERVIO_RECORD INDEX BY BINARY_INTEGER;
107 TYPE G_FUNCS_TABLE IS TABLE OF G_USERVIO_ENTRIES_TABLE INDEX BY BINARY_INTEGER;
108 TYPE G_USERVIO_TABLE IS TABLE OF G_FUNCS_TABLE INDEX BY BINARY_INTEGER;
109
110 TYPE G_RESPS_TABLE IS TABLE OF G_USERVIO_ENTRIES_TABLE INDEX BY VARCHAR2(30);
111 TYPE G_USERESPVIO_TABLE IS TABLE OF G_RESPS_TABLE INDEX BY BINARY_INTEGER;
112 G_PV_COUNT NUMBER;
113 G_PV_FUNCTION_ID_LIST G_NUMBER_TABLE; -- Stores the FUNC or CP id
114 G_PV_MENU_ID_LIST G_NUMBER_TABLE;
115 G_PV_RESPONSIBILITY_ID_LIST G_NUMBER_TABLE;
116 G_PV_APPLICATION_ID_LIST G_NUMBER_TABLE;
117 G_PV_ACCESS_GIVEN_DATE_LIST G_DATE_TABLE;
118 G_PV_ACCESS_GIVEN_BY_LIST G_NUMBER_TABLE;
119 G_PV_GROUP_CODE_LIST G_VARCHAR2_CODE_TABLE;
120 -- 05.25.2006 : psomanat : Fix for bug 5214858
121 G_PV_PROGRAM_APPL_ID_LIST G_NUMBER_TABLE; -- Stores CP application Id
122 G_PV_OBJECT_TYPE_LIST G_VARCHAR2_CODE_TABLE; -- Stores Object Type
123 G_RESP_VIOLATIONS_LIST G_RESPVIO_TABLE;
124 G_UNEXCL_FUNC_ID_LIST G_NUMBER_TABLE_TYPE;
125 G_UNEXCL_GRP_CODE_LIST G_VARCHAR2_TABLE_TYPE;
126
127 G_PV_FUNCTION_ID NUMBER := NULL;
128 G_PV_MENU_ID NUMBER := NULL;
129 G_PV_RESPONSIBILITY_ID NUMBER := NULL;
130 G_PV_APPLICATION_ID NUMBER := NULL;
131 G_PV_ACCESS_GIVEN_DATE DATE := NULL;
132 G_PV_ACCESS_GIVEN_BY NUMBER := NULL;
133 G_PV_GROUP_CODE VARCHAR2(30) := NULL;
134
135 -- store the potential responsibilities(and corresponding application_id , menu_id) by specified constraint_rev_id
136 G_PNTL_RESP_ID_LIST G_NUMBER_TABLE;
137 G_PNTL_APPL_ID_LIST G_NUMBER_TABLE;
138 G_PNTL_MENU_ID_LIST G_NUMBER_TABLE;
139 G_PNTL_FUNCTION_ID_LIST G_NUMBER_TABLE;
140 G_PNTL_GRP_CODE_LIST G_NUMBER_TABLE;
141 G_PNTL_RESP_VIO_LIST G_RESPVIO_TABLE;
142
143 -- store the potential user id for one constraint
144 G_CST_USER_ID_LIST G_NUMBER_TABLE;
145 --05.17.2005 tsho: starting from AMW.E, store user_name in addition to user_id for use in G_AMW_USER_ROLES
146 G_CST_USER_NAME_LIST G_VARCHAR2_LONG_TABLE;
147
148 -- store the user potential violation
149 G_UPV_COUNT NUMBER;
150 G_UPV_FUNCTION_ID_LIST G_NUMBER_TABLE;
151 G_UPV_MENU_ID_LIST G_NUMBER_TABLE;
152 G_UPV_RESPONSIBILITY_ID_LIST G_NUMBER_TABLE;
153 G_UPV_APPLICATION_ID_LIST G_NUMBER_TABLE;
154 G_UPV_PROGRAM_APPL_ID_LIST G_NUMBER_TABLE;
155 G_UPV_ACCESS_GIVEN_DATE_LIST G_DATE_TABLE;
156 G_UPV_ACCESS_GIVEN_BY_LIST G_NUMBER_TABLE;
157 G_UPV_ROLE_NAME_LIST G_VARCHAR2_LONG_TABLE;
158 G_UPV_GROUP_CODE_LIST G_VARCHAR2_CODE_TABLE;
159 G_UPV_ENTRY_OBJECT_TYPE_LIST G_VARCHAR2_CODE_TABLE;
160 --psomanat : Fix for 5236356
161 G_USER_VIOLATIONS_LIST G_USERVIO_TABLE;
162 G_USER_RESP_VIO_LIST G_USERESPVIO_TABLE;
163 G_User_Waiver_List G_NUMBER_TABLE;
164 G_User_Violation_Id_list G_NUMBER_TABLE;
165
166 -- ===============================================================
167 -- Private Function name
168 -- BULK_COLLECTS_SUPPORTED
169 --
170 -- Purpose
171 -- This temporary routine determines whether bulk collects are supported.
172 -- See comments around G_BULK_COLLECTS_SUPPORTED above
173 --
174 -- Return
175 -- True := BULK COLLECTS SUPPORTED
176 -- False := BULK COLLECTS NOT SUPPORTED
177 --
178 -- Notes
179 -- copy from FND_FUNCTION.BULK_COLLECTS_SUPPORTED (AFSCFNSB.pls 115.51 2003/08/01)
180 -- since it's private function in FND_FUNCTION
181 --
182 -- ===============================================================
183 FUNCTION BULK_COLLECTS_SUPPORTED
184 RETURN boolean
185 IS
186
187 L_API_NAME CONSTANT VARCHAR2(30) := 'BULK_COLLECTS_SUPPORTED';
188 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
189
190 ver varchar2(255);
191
192 begin
193 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
194
195 begin
196 if (G_BULK_COLLECTS_SUPPORTED = 'TRUE') then
197 return TRUE;
198 elsif (G_BULK_COLLECTS_SUPPORTED = 'FALSE') then
199 return FALSE;
200 elsif (G_BULK_COLLECTS_SUPPORTED = 'UNKNOWN') then
201 -- 11.17.2003 tsho: return false if unknown
202 /*
203 select version
204 into ver
205 from v$instance
206 where rownum = 1;
207
208 if(ver >= '8.1.7.1.0') then
209 G_BULK_COLLECTS_SUPPORTED := 'TRUE';
210 return (TRUE);
211 else
212 G_BULK_COLLECTS_SUPPORTED := 'FALSE';
213 return (FALSE);
214 end if;
215 */
216 return (FALSE);
217 else
218 return (FALSE); /* Should never happen */
219 end if;
220 exception
221 when others then
222 return FALSE; /* Should never happen */
223 end;
224 end BULK_COLLECTS_SUPPORTED;
225
226 -- ===============================================================
227 -- Private Function name
228 -- PROCESS_MENU_TREE_DOWN_FOR_CST
229 --
230 -- Purpose
231 -- Plow through the menu tree, processing exclusions and figuring
232 -- out which functions are accessible.
233 --
234 --
235 -- Params
236 -- p_menu_id := menu_id
237 -- p_function_id := function to check for
238 --
239 -- Don't pass values for the following two params if you don't want
240 -- exclusions processed.
241 -- p_appl_id := application id of resp
242 -- p_resp_id := responsibility id
243 --
244 -- p_access_given_date := start_date of user resp (added for AMW)
245 -- p_access_given_by := created_by of user resp (added for AMW)
246 --
247 -- Return
248 -- True := function accessible
249 -- False := function not accessible
250 --
251 -- Notes
252 -- copy from FND_FUNCTION.PROCESS_MENU_TREE_DOWN_FOR_MN (AFSCFNSB.pls 115.51 2003/08/01)
253 -- and modify for AMW to use dynamic sql
254 --
258 -- 05.24.2005 tsho: AMW.E Incompatible Sets,
255 -- 12.21.2004 tsho: set default NULL for p_access_given_date, p_access_given_by
256 -- 12.21.2004 tsho: fix for performance bug 4036679
257 -- History
259 -- need to pass in amw_constraint_entries.group_code for each item
260 -- ===============================================================
261 FUNCTION PROCESS_MENU_TREE_DOWN_FOR_CST(
262 p_constraint_rev_id in number,
263 p_menu_id in number,
264 p_appl_id in number,
265 p_resp_id in number
266 ) RETURN boolean
267 IS
268
269 L_API_NAME CONSTANT VARCHAR2(30) := 'PROCESS_MENU_TREE_DOWN_FOR_MN';
270 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
271 l_sub_menu_id number;
272
273 /* Table to store the list of submenus that we are looking for */
274 MENULIST G_NUMBER_TABLE;
275
276 /* The table of exclusions. The index in is the action_id, and the */
277 /* value stored in each element is the rule_type.*/
278 EXCLUSIONS G_VARCHAR2_TABLE;
279
280 /* Returns from the bulk collect (fetches) */
281 TBL_MENU_ID G_NUMBER_TABLE;
282 TBL_ENT_SEQ G_NUMBER_TABLE;
283 TBL_FUNC_ID G_NUMBER_TABLE;
284 TBL_SUBMNU_ID G_NUMBER_TABLE;
285 TBL_GNT_FLG G_VARCHAR2_TABLE;
286 TBL_ACCESS_GIVEN_DATE G_DATE_TABLE; --05.25-2006 :psomanat : Fix for bug 5214858
287 TBL_ACCESS_GIVEN_BY G_NUMBER_TABLE; --05.25-2006 :psomanat : Fix for bug 5214858
288
289 TYPE exclCurTyp IS REF CURSOR;
290 excl_c exclCurTyp;
291 l_excl_rule_list G_VARCHAR2_CODE_TABLE;
292 l_excl_act_id_list G_NUMBER_TABLE;
293
294 l_excl_dynamic_sql VARCHAR2(200) :=
295 'SELECT RULE_TYPE, ACTION_ID '
296 ||' FROM '||G_AMW_RESP_FUNCTIONS
297 ||' WHERE application_id = :1 '
298 ||' AND responsibility_id = :2 ';
299
300
301 TYPE mnesCurTyp IS REF CURSOR;
302 get_mnes_c mnesCurTyp;
303 l_mnes_dynamic_sql VARCHAR2(200) :=
304 'SELECT MENU_ID, ENTRY_SEQUENCE, FUNCTION_ID, SUB_MENU_ID, GRANT_FLAG,CREATION_DATE,CREATED_BY '
305 ||' FROM '||G_AMW_MENU_ENTRIES
306 ||' WHERE menu_id = :1 ';
307
308 menulist_cur pls_integer;
309 menulist_size pls_integer;
310
311 entry_excluded boolean;
312 last_index pls_integer;
313 i number;
314 z number;
315
316 -- psomanat : 06:09:2006 : fix for bug 5256720
317 L_RESPVIO_ENTRIES G_RESPVIO_ENTRIES_TABLE;
318 L_FUNC_ID_LIST G_FUNC_TABLE;
319 counts number;
320 is_duplicate boolean;
321 listkey VARCHAR2(30) := NULL;
322 entry_unexcluded boolean;
323 unexclkey VARCHAR2(30) := NULL;
324 l_searched_func_id_list G_NUMBER_TABLE_TYPE;
325 l_group_code VARCHAR2(1):=null;
326
327
328 BEGIN
329
330 OPEN excl_c FOR l_excl_dynamic_sql USING
331 p_appl_id,
332 p_resp_id;
333 FETCH excl_c BULK COLLECT INTO l_excl_rule_list,l_excl_act_id_list;
334 CLOSE excl_c;
335
336 IF (l_excl_rule_list IS NOT NULL) AND (l_excl_rule_list.FIRST IS NOT NULL) THEN
337 FOR i in l_excl_rule_list.FIRST .. l_excl_rule_list.LAST
338 LOOP
339 EXCLUSIONS(l_excl_act_id_list(i)) := l_excl_rule_list(i);
340 END LOOP;
341 END IF;
342
343 -- releasing the memory
344 l_excl_rule_list.delete();
345 l_excl_act_id_list.delete();
346
347 -- Initialize menulist working list to parent menu
348 menulist_cur := 0;
349 menulist_size := 1;
350 menulist(0) := p_menu_id;
351
352 -- Continue processing until reach the end of list
353 WHILE (menulist_cur < menulist_size)
354 LOOP
355 -- Check if recursion limit exceeded
356 IF (menulist_cur > C_MAX_MENU_ENTRIES) THEN
357 /* If the function were accessible from this menu, then we should */
358 /* have found it before getting to this point, so we are confident */
359 /* that the function is not on this menu. */
360 RETURN FALSE;
361 END IF;
362
363 l_sub_menu_id := menulist(menulist_cur);
364
365 -- See whether the current menu is excluded or not.
366 entry_excluded := FALSE;
367 BEGIN
368 IF ((l_sub_menu_id IS NOT NULL) AND (exclusions(l_sub_menu_id) = 'M')) THEN
369 entry_excluded := TRUE;
370 END IF;
371 EXCEPTION
372 WHEN no_data_found THEN
373 null;
374 END;
375
376 IF (entry_excluded) THEN
377 last_index := 0; /* Indicate that no rows were returned */
378 ELSE
379 OPEN get_mnes_c FOR l_mnes_dynamic_sql USING l_sub_menu_id;
380 FETCH get_mnes_c
381 BULK COLLECT INTO tbl_menu_id,
382 tbl_ent_seq,
383 tbl_func_id,
384 tbl_submnu_id,
385 tbl_gnt_flg,
386 tbl_access_given_date,
387 tbl_access_given_by;
388 CLOSE get_mnes_c;
389
390 IF ((tbl_menu_id.FIRST is NULL) or (tbl_menu_id.FIRST IS NULL)) THEN
391 last_index := 0;
392 ELSE
393 last_index := tbl_menu_id.LAST;
394 END IF;
395 END IF;
396 -- Process each of the child entries fetched
400 if( (tbl_func_id(i) is not NULL)
397 FOR i in 1 .. last_index LOOP
398 entry_excluded := FALSE;
399 begin
401 and (exclusions(tbl_func_id(i)) = 'F')) then
402 entry_excluded := TRUE;
403
404 -- We store the excluded function_id in l_searched_func_id_list
405 -- we use this list to check if we have validated alll the
406 -- unexcluded incompatible funtions for a given responsibility
407 listkey :=tbl_func_id(i)||'@'||1;
408 IF G_UNEXCL_FUNC_ID_LIST.EXISTS(listkey) THEN
409 IF NOT l_searched_func_id_list.EXISTS(listkey) THEN
410 l_searched_func_id_list(listkey) :=tbl_func_id(i);
411 END IF;
412 END IF;
413 listkey :=tbl_func_id(i)||'@'||2;
414 IF G_UNEXCL_FUNC_ID_LIST.EXISTS(listkey) THEN
415 IF NOT l_searched_func_id_list.EXISTS(listkey) THEN
416 l_searched_func_id_list(listkey) :=tbl_func_id(i);
417 END IF;
418 END IF;
419 end if;
420 exception
421 when no_data_found then
422 null;
423 end;
424
425 if (not entry_excluded ) then
426 IF tbl_func_id(i) is not NULL THEN
427 entry_unexcluded := FALSE;
428 -- Check if this is a matching function. If so, return success.
429 listkey :=tbl_func_id(i)||'@'||1;
430 IF G_UNEXCL_FUNC_ID_LIST.EXISTS(listkey) THEN
431 entry_unexcluded := TRUE;
432 unexclkey :=listkey;
433 l_group_code:='1';
434 END IF;
435 listkey :=tbl_func_id(i)||'@'||2;
436 IF G_UNEXCL_FUNC_ID_LIST.EXISTS(listkey) THEN
437 entry_unexcluded := TRUE;
438 unexclkey :=listkey;
439 l_group_code:='2';
440 END IF;
441
442 IF (entry_unexcluded AND (tbl_gnt_flg(i) = 'Y')) THEN
443
444 -- We store the processed function_id in l_searched_func_id_list
445 -- we use this list to check if we have validated alll the
446 -- unexcluded incompatible funtions for a given responsibility
447 IF NOT l_searched_func_id_list.EXISTS(unexclkey) THEN
448 l_searched_func_id_list(unexclkey) :=tbl_func_id(i);
449 END IF;
450
451 L_FUNC_ID_LIST.delete();
452 L_RESPVIO_ENTRIES.delete();
453
454 -- To identify a responsibility we need application id and responsibility.
455 -- So the key is like application_id@responsibility_id
456 listkey := p_appl_id||'@'||p_resp_id;
457
458 -- Here we check if the responsibility allready exists in G_RESP_VIOLATIONS_LIST.
459 -- If Yes, we get the function list
460 -- check if the function list contains the FUNCTION ID refered by
461 -- tbl_func_id(i)
462 -- If yes, we get the responsibility violation plsql record and
463 -- add a new record to the existing records
464 -- End
465 -- Note : when any of the check fails, the corresponding NestedTable entry
466 -- or plsql entry is newly created and added to the main G_RESP_VIOLATIONS_LIST
467 IF (G_RESP_VIOLATIONS_LIST.EXISTS(listkey)) THEN
468 L_FUNC_ID_LIST := G_RESP_VIOLATIONS_LIST(listkey);
469 IF L_FUNC_ID_LIST.EXISTS(tbl_func_id(i)) THEN
470 L_RESPVIO_ENTRIES := L_FUNC_ID_LIST(tbl_func_id(i));
471 END IF;
472 END IF;
473
474 -- before adding a record to responsibility violation plsql record
475 -- we check if the current function tbl_func_id(i) detail is
476 -- available in the responsibility violation plsql records
477 is_duplicate := FALSE;
478 IF ((L_RESPVIO_ENTRIES IS NOT NULL) and (L_RESPVIO_ENTRIES.FIRST IS NOT NULL)) THEN
479 FOR j IN L_RESPVIO_ENTRIES.FIRST .. L_RESPVIO_ENTRIES.LAST
480 LOOP
481 IF L_RESPVIO_ENTRIES(j).Menu_id = tbl_menu_id(i) THEN
482 is_duplicate := TRUE;
483 EXIT;
484 END IF;
485 END LOOP;
486 END IF;
487
488 IF NOT is_duplicate THEN
489 counts := L_RESPVIO_ENTRIES.COUNT+1;
490 L_RESPVIO_ENTRIES(counts).application_id := p_appl_id;
494 L_RESPVIO_ENTRIES(counts).Access_Given_Date := TBL_ACCESS_GIVEN_DATE(i);
491 L_RESPVIO_ENTRIES(counts).Responsibility_id := p_resp_id;
492 L_RESPVIO_ENTRIES(counts).Menu_id := tbl_menu_id(i);
493 L_RESPVIO_ENTRIES(counts).Function_Id := tbl_func_id(i);
495 L_RESPVIO_ENTRIES(counts).Access_Given_By_Id := TBL_ACCESS_GIVEN_BY(i);
496 L_RESPVIO_ENTRIES(counts).Object_Type := 'FUNC';
497 L_RESPVIO_ENTRIES(counts).group_code := l_group_code;
498 L_RESPVIO_ENTRIES(counts).prog_appl_id := NULL;
499 L_RESPVIO_ENTRIES(counts).Role_Name := NULL;
500 L_FUNC_ID_LIST(tbl_func_id(i)) := L_RESPVIO_ENTRIES;
501 G_RESP_VIOLATIONS_LIST(listkey) := L_FUNC_ID_LIST;
502 END IF;
503
504 /*FND_FILE.put_line(fnd_file.log,'*****************');
505 FND_FILE.put_line(fnd_file.log,'Responsibility_id '||p_resp_id);
506 FND_FILE.put_line(fnd_file.log,'p_appl_id '||p_appl_id);
507 FND_FILE.put_line(fnd_file.log,'tbl_menu_id '||tbl_menu_id(i));
508 FND_FILE.put_line(fnd_file.log,'p_function_id '||tbl_func_id(i));
509 FND_FILE.put_line(fnd_file.log,'p_group_code '||l_group_code);
510 FND_FILE.put_line(fnd_file.log,'*****************');
511 FND_FILE.put_line(fnd_file.log,'tbl_func_id(i) '||tbl_func_id(i));
512 FND_FILE.put_line(fnd_file.log,'G_UNEXCL_FUNC_ID_LIST.COUNT'||G_UNEXCL_FUNC_ID_LIST.COUNT);
513 FND_FILE.put_line(fnd_file.log,'l_searched_func_id_list.COUNT'||l_searched_func_id_list.COUNT); */
514
515 -- When the unexcluded function count equals searched function count,
516 -- we have processed all the unexcluded function. So we need to stop
517 -- digging into the responsibility menu hierarchy
518 IF l_searched_func_id_list.COUNT = G_UNEXCL_FUNC_ID_LIST.COUNT THEN
519 RETURN TRUE;
520 END IF;
521 END IF;
522 END IF;
523 -- If this is a submenu, then add it to the end of the
524 -- working list for processing.
525 IF (tbl_submnu_id(i) IS NOT NULL) THEN
526 menulist(menulist_size) := tbl_submnu_id(i);
527 menulist_size := menulist_size + 1;
528 END IF;
529 END IF; -- End if not excluded
530 END LOOP; -- For loop processing child entries
531 -- Advance to next menu on working list
532 menulist_cur := menulist_cur + 1;
533 END LOOP;
534
535 -- We couldn't find the function anywhere, so it's not available
536 return FALSE;
537 END PROCESS_MENU_TREE_DOWN_FOR_CST;
538
539
540 -- ===============================================================
541 -- Private Function name
542 -- PROCESS_MENU_TREE_DOWN_FOR_MN
543 --
544 -- Purpose
545 -- Plow through the menu tree, processing exclusions and figuring
546 -- out which functions are accessible.
547 --
548 -- This routine processes the menu hierarchy and exclusion rules in PL/SQL
549 -- rather than in the database.
550 -- The basic algorithm of this routine is:
551 -- Populate the list of exclusions by selecting from FND_RESP_FUNCTIONS
552 -- menulist(1) = p_menu_id
553 -- while (elements on menulist)
554 -- {
555 -- Remove first element off menulist
556 -- if this menu is not excluded with a menu exclusion rule
557 -- {
558 -- Query all menu entry children of current menu
559 -- for (each child) loop
560 -- {
561 -- If it's excluded by a func exclusion rule, go on to the next one.
562 -- If we've got the function we're looking for,
563 -- and grant_flag = Y, we're done- return TRUE;
564 -- If it's got a sub_menu_id, add it to the end of menulist
565 -- to be processed
566 -- }
567 -- Move to next element on menulist
568 -- }
569 -- }
570 --
571 -- Params
572 -- p_menu_id := menu_id
573 -- p_function_id := function to check for
574 --
578 -- p_resp_id := responsibility id
575 -- Don't pass values for the following two params if you don't want
576 -- exclusions processed.
577 -- p_appl_id := application id of resp
579 --
580 -- p_access_given_date := start_date of user resp (added for AMW)
581 -- p_access_given_by := created_by of user resp (added for AMW)
582 --
583 -- Return
584 -- True := function accessible
585 -- False := function not accessible
586 --
587 -- Notes
588 -- copy from FND_FUNCTION.PROCESS_MENU_TREE_DOWN_FOR_MN (AFSCFNSB.pls 115.51 2003/08/01)
589 -- and modify for AMW to use dynamic sql
590 --
591 -- 12.21.2004 tsho: set default NULL for p_access_given_date, p_access_given_by
592 -- 12.21.2004 tsho: fix for performance bug 4036679
593 -- History
594 -- 05.24.2005 tsho: AMW.E Incompatible Sets,
595 -- need to pass in amw_constraint_entries.group_code for each item
596 -- ===============================================================
597 FUNCTION PROCESS_MENU_TREE_DOWN_FOR_MN(
598 p_menu_id in number,
599 p_function_id in number,
600 p_appl_id in number,
601 p_resp_id in number,
602 p_access_given_date in date := NULL,
603 p_access_given_by in number := NULL,
604 p_group_code in varchar2 := NULL
605 ) RETURN boolean
606 IS
607
608 L_API_NAME CONSTANT VARCHAR2(30) := 'PROCESS_MENU_TREE_DOWN_FOR_MN';
609 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
610
611 l_sub_menu_id number;
612
613 /* Table to store the list of submenus that we are looking for */
614 TYPE MENULIST_TYPE is table of NUMBER INDEX BY BINARY_INTEGER;
615 MENULIST MENULIST_TYPE;
616
617 TYPE NUMBER_TABLE_TYPE is table of NUMBER INDEX BY BINARY_INTEGER;
618 TYPE VARCHAR2_TABLE_TYPE is table of VARCHAR2(1) INDEX BY BINARY_INTEGER;
619
620 /* The table of exclusions. The index in is the action_id, and the */
621 /* value stored in each element is the rule_type.*/
622 EXCLUSIONS VARCHAR2_TABLE_TYPE;
623
624 /* Returns from the bulk collect (fetches) */
625 TBL_MENU_ID NUMBER_TABLE_TYPE;
626 TBL_ENT_SEQ NUMBER_TABLE_TYPE;
627 TBL_FUNC_ID NUMBER_TABLE_TYPE;
628 TBL_SUBMNU_ID NUMBER_TABLE_TYPE;
629 TBL_GNT_FLG VARCHAR2_TABLE_TYPE;
630 TBL_ACCESS_GIVEN_DATE G_DATE_TABLE; --05.25-2006 :psomanat : Fix for bug 5214858
631 TBL_ACCESS_GIVEN_BY NUMBER_TABLE_TYPE; --05.25-2006 :psomanat : Fix for bug 5214858
632
633 /* Cursor to get exclusions */
634 -- 11.12.2003 tsho: use dynamic sql for AMW
635 /*
636 cursor excl_c is
637 SELECT RULE_TYPE, ACTION_ID from fnd_resp_functions
638 where application_id = p_appl_id
639 and responsibility_id = p_resp_id;
640 */
641 -- 12.12.2003 tsho: use static sql for AMW for the time being
642 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
643 TYPE exclCurTyp IS REF CURSOR;
644 excl_c exclCurTyp;
645 l_excl_rule_type VARCHAR2(30);
646 l_excl_action_id NUMBER;
647 l_excl_dynamic_sql VARCHAR2(200) :=
648 'SELECT RULE_TYPE, ACTION_ID '
649 ||' FROM '||G_AMW_RESP_FUNCTIONS
650 ||' WHERE application_id = :1 '
651 ||' AND responsibility_id = :2 ';
652
653
654 /* Cursor to get menu entries on a particular menu.*/
655 -- 11.12.2003 tsho: use dynamic sql for AMW
656 /*
657 cursor get_mnes_c is
658 SELECT MENU_ID, ENTRY_SEQUENCE, FUNCTION_ID, SUB_MENU_ID, GRANT_FLAG
659 from fnd_menu_entries
660 where MENU_ID = l_sub_menu_id;
661 */
662 -- 12.12.2003 tsho: use static sql for AMW for the time being
663 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
664 TYPE mnesCurTyp IS REF CURSOR;
665 get_mnes_c mnesCurTyp;
666 l_mnes_menu_id NUMBER;
667 l_mnes_entry_sequence NUMBER;
668 l_mnes_function_id NUMBER;
669 l_mnes_sub_menu_id NUMBER;
670 l_mnes_grant_flag VARCHAR2(1);
671 -- 05.25.2006 : psomanat : Fix for bug 5214858
672 l_access_given_date DATE;
673 l_access_given_by NUMBER;
674 l_mnes_dynamic_sql VARCHAR2(200) :=
675 'SELECT MENU_ID, ENTRY_SEQUENCE, FUNCTION_ID, SUB_MENU_ID, GRANT_FLAG,CREATION_DATE,CREATED_BY '
676 ||' FROM '||G_AMW_MENU_ENTRIES
677 ||' WHERE menu_id = :1 ';
678
679 menulist_cur pls_integer;
680 menulist_size pls_integer;
681
682 entry_excluded boolean;
683 last_index pls_integer;
684 i number;
685 z number;
686
687 BEGIN
688 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
689
690 if(p_appl_id is not NULL) then
691 /* Select the list of exclusion rules into our cache */
692 -- 11.12.2003 tsho: use dynamic sql for AMW
693 /*
694 for excl_rec in excl_c loop
695 EXCLUSIONS(excl_rec.action_id) := excl_rec.rule_type;
696 end loop;
697 */
698 -- 12.12.2003 tsho: use static sql for AMW for the time being
699 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
700 OPEN excl_c FOR l_excl_dynamic_sql USING
701 p_appl_id,
702 p_resp_id;
703 LOOP
704 FETCH excl_c INTO l_excl_rule_type, l_excl_action_id;
705 EXIT WHEN excl_c%NOTFOUND;
706 EXCLUSIONS(l_excl_action_id) := l_excl_rule_type;
707 END LOOP;
711
708 CLOSE excl_c;
709
710 end if;
712
713 -- Initialize menulist working list to parent menu
714 menulist_cur := 0;
715 menulist_size := 1;
716 menulist(0) := p_menu_id;
717
718 -- Continue processing until reach the end of list
719 while (menulist_cur < menulist_size) loop
720 -- Check if recursion limit exceeded
721 if (menulist_cur > C_MAX_MENU_ENTRIES) then
722 /* If the function were accessible from this menu, then we should */
723 /* have found it before getting to this point, so we are confident */
724 /* that the function is not on this menu. */
725 return FALSE;
726 end if;
727
728 l_sub_menu_id := menulist(menulist_cur);
729
730 -- See whether the current menu is excluded or not.
731 entry_excluded := FALSE;
732 begin
733 if( (l_sub_menu_id is not NULL)
734 and (exclusions(l_sub_menu_id) = 'M')) then
735 entry_excluded := TRUE;
736 end if;
737 exception
738 when no_data_found then
739 null;
740 end;
741
742 if (entry_excluded) then
743 last_index := 0; /* Indicate that no rows were returned */
744 else
745 /* This menu isn't excluded, so find out whats entries are on it. */
746 if (BULK_COLLECTS_SUPPORTED) then
747 -- 11.12.2003 tsho: use dynamic sql for AMW
748 /*
749 open get_mnes_c;
750 */
751 -- 12.12.2003 tsho: use static sql for AMW for the time being
752 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
753 open get_mnes_c for l_mnes_dynamic_sql USING
754 l_sub_menu_id;
755
756 fetch get_mnes_c bulk collect into tbl_menu_id, tbl_ent_seq,
757 tbl_func_id, tbl_submnu_id, tbl_gnt_flg,TBL_ACCESS_GIVEN_DATE,TBL_ACCESS_GIVEN_BY;
758 close get_mnes_c;
759
760 -- See if we found any rows. If not set last_index to zero.
761 begin
762 if((tbl_menu_id.FIRST is NULL) or (tbl_menu_id.FIRST <> 1)) then
763 last_index := 0;
764 else
765 if (tbl_menu_id.FIRST is not NULL) then
766 last_index := tbl_menu_id.LAST;
767 else
768 last_index := 0;
769 end if;
770 end if;
771 exception
772 when others then
773 last_index := 0;
774 end;
775 else
776 z:= 0;
777
778 -- 11.12.2003 tsho: use dynamic sql for AMW
779 /*
780 for rec in get_mnes_c loop
781 z := z + 1;
782 tbl_menu_id(z) := rec.MENU_ID;
783 tbl_ent_seq(z) := rec.ENTRY_SEQUENCE;
784 tbl_func_id(z) := rec.FUNCTION_ID;
785 tbl_submnu_id (z):= rec.SUB_MENU_ID;
786 tbl_gnt_flg(z) := rec.GRANT_FLAG;
787 end loop;
788 */
789 -- 12.12.2003 tsho: use static sql for AMW for the time being
790 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
791 OPEN get_mnes_c FOR l_mnes_dynamic_sql USING
792 l_sub_menu_id;
793 LOOP
794 FETCH get_mnes_c INTO l_mnes_menu_id,
795 l_mnes_entry_sequence,
796 l_mnes_function_id,
797 l_mnes_sub_menu_id,
798 l_mnes_grant_flag,
799 l_access_given_date,
800 l_access_given_by;
801 EXIT WHEN get_mnes_c%NOTFOUND;
802 tbl_menu_id(z) := l_mnes_menu_id;
803 tbl_ent_seq(z) := l_mnes_entry_sequence;
804 tbl_func_id(z) := l_mnes_function_id;
805 tbl_submnu_id (z):= l_mnes_sub_menu_id;
806 tbl_gnt_flg(z) := l_mnes_grant_flag;
807 END LOOP;
808 CLOSE get_mnes_c;
809
810 last_index := z;
811 end if;
812
813
814 end if; /* entry_excluded */
815
816 -- Process each of the child entries fetched
817 for i in 1 .. last_index loop
818 -- Check if there is an exclusion rule for this entry
819 entry_excluded := FALSE;
823 entry_excluded := TRUE;
820 begin
821 if( (tbl_func_id(i) is not NULL)
822 and (exclusions(tbl_func_id(i)) = 'F')) then
824 end if;
825 exception
826 when no_data_found then
827 null;
828 end;
829
830 -- Skip this entry if it's excluded
831 if (not entry_excluded) then
832 -- Check if this is a matching function. If so, return success.
833 if( (tbl_func_id(i) = p_function_id)
834 and (tbl_gnt_flg(i) = 'Y'))
835 then
836 -- 12.21.2004 tsho: fix for performance bug 4036679, store in the global list directly
837 -- 11.14.2003 tsho: populate the global potential violation info
838 /*
839 G_PV_MENU_ID := tbl_menu_id(i);
840 G_PV_FUNCTION_ID := p_function_id;
841 G_PV_RESPONSIBILITY_ID := p_resp_id;
842 G_PV_ACCESS_GIVEN_DATE := p_access_given_date;
843 G_PV_ACCESS_GIVEN_BY := p_access_given_by;
844 FND_FILE.put_line(fnd_file.log,'inside '||L_API_NAME || ': ');
845 FND_FILE.put_line(fnd_file.log,'G_PV_RESPONSIBILITY_ID: '||G_PV_RESPONSIBILITY_ID);
846 FND_FILE.put_line(fnd_file.log,'G_PV_MENU_ID: '||G_PV_MENU_ID);
847 FND_FILE.put_line(fnd_file.log,'G_PV_FUNCTION_ID: '||G_PV_FUNCTION_ID);
848 */
849 G_PV_MENU_ID_LIST(G_PV_COUNT) := tbl_menu_id(i);
850 G_PV_FUNCTION_ID_LIST(G_PV_COUNT) := p_function_id;
851 G_PV_RESPONSIBILITY_ID_LIST(G_PV_COUNT) := p_resp_id;
852 G_PV_APPLICATION_ID_LIST(G_PV_COUNT) := p_appl_id;
853 G_PV_ACCESS_GIVEN_DATE_LIST(G_PV_COUNT) := TBL_ACCESS_GIVEN_DATE(i);
854 G_PV_ACCESS_GIVEN_BY_LIST(G_PV_COUNT) := TBL_ACCESS_GIVEN_BY(i);
855 G_PV_GROUP_CODE_LIST(G_PV_COUNT) := p_group_code; -- 05.24.2005 tsho: AMW.E Incompatible Sets
856 --05.25.06 : psomanat : Fix for bug 5214858
857 G_PV_PROGRAM_APPL_ID_LIST(G_PV_COUNT) := NULL;
858 G_PV_OBJECT_TYPE_LIST(G_PV_COUNT) := 'FUNC';
859 G_PV_COUNT := G_PV_COUNT +1;
860 return TRUE;
861 end if;
862
863 -- If this is a submenu, then add it to the end of the
864 -- working list for processing.
865 if (tbl_submnu_id(i) is not NULL) then
866 menulist(menulist_size) := tbl_submnu_id(i);
867 menulist_size := menulist_size + 1;
868 end if;
869 end if; -- End if not excluded
870 end loop; -- For loop processing child entries
871
872 -- Advance to next menu on working list
873 menulist_cur := menulist_cur + 1;
874 end loop;
875
876 -- We couldn't find the function anywhere, so it's not available
877 return FALSE;
878
879 END PROCESS_MENU_TREE_DOWN_FOR_MN;
880
881
882
883
884
885 -- ===============================================================
886 -- Private Function name
887 -- PROCESS_MENU_TREE_DOWN
888 --
889 -- Purpose
890 -- Plow through the menu tree, processing exclusions and figuring
891 -- out which functions are accessible.
892 --
893 -- Params
894 -- p_appl_id := application id of resp
895 -- p_resp_id := responsibility id of current user
896 -- p_function_id := function to check for
897 -- p_access_given_date := start_date of user resp (added for AMW)
898 -- p_access_given_by := created_by of user resp (added for AMW)
899 --
900 -- Return
901 -- True := function accessible
902 -- False := function not accessible
903 --
904 -- Notes
905 -- copy from FND_FUNCTION.PROCESS_MENU_TREE_DOWN (AFSCFNSB.pls 115.51 2003/08/01)
906 -- and modify for AMW to use dynamic sql
907 --
908 -- 12.21.2004 tsho: set default NULL for p_access_given_date, p_access_given_by
909 -- ===============================================================
910 FUNCTION PROCESS_MENU_TREE_DOWN (
911 p_appl_id in number,
912 p_resp_id in number,
913 p_function_id in number,
914 p_access_given_date in date := NULL,
915 p_access_given_by in number := NULL
916 ) RETURN boolean
917 IS
918 l_menu_id NUMBER;
919
920 L_API_NAME CONSTANT VARCHAR2(30) := 'PROCESS_MENU_TREE_DOWN';
921 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
922
923 -- 11.13.2003 tsho: use dynamic sql for AMW
924 -- 12.12.2003 tsho: use static sql for AMW for the time being
925 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
926 TYPE respCurTyp IS REF CURSOR;
927 resp_c respCurTyp;
928 l_resp_dynamic_sql VARCHAR2(200) :=
929 'SELECT menu_id '
930 ||' FROM '||G_AMW_RESPONSIBILITY
931 ||' WHERE responsibility_id = :1 '
932 ||' AND application_id = :2 ';
933
934 BEGIN
935 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
936
937 if ( (P_LAST_RESP_ID = p_resp_id)
938 and (P_LAST_RESP_APPL_ID = p_appl_id)) then
939 /* If the cache is valid just use the cache */
940 l_menu_id := P_LAST_MENU_ID;
941 else
942 /* Find the root menu for this responsibility */
943 begin
944
945 -- 11.13.2003 tsho: use dynamic sql for AMW
946 /*
947 select menu_id
948 into l_menu_id
952 */
949 from fnd_responsibility
950 where responsibility_id = p_resp_id
951 and application_id = p_appl_id;
953 -- 12.12.2003 tsho: use static sql for AMW for the time being
954 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
955 OPEN resp_c FOR l_resp_dynamic_sql USING
956 p_resp_id,
957 p_appl_id;
958 FETCH resp_c INTO l_menu_id;
959 CLOSE resp_c;
960
961
962 /* Store the new value in the cache */
963 P_LAST_RESP_ID := p_resp_id;
964 P_LAST_RESP_APPL_ID := p_appl_id;
965 P_LAST_MENU_ID := l_menu_id;
966 exception
967 when no_data_found then
968 /* No menu for this resp, so there can't be any functions */
969 return FALSE;
970 end;
971 end if;
972 return PROCESS_MENU_TREE_DOWN_FOR_MN(l_menu_id,
973 p_function_id,
974 p_appl_id,
975 p_resp_id,
976 p_access_given_date,
977 p_access_given_by);
978 END PROCESS_MENU_TREE_DOWN;
979
980
981
982
983
984 -- ===============================================================
985 -- Private Function name
986 -- TEST_ID_NO_GRANTS
987 --
988 -- Purpose
989 -- Test if function id is accessible under current responsibility.
990 -- Looks only at the menus on current resp, not any grants.
991 --
992 -- Params
993 -- function_id := function id to test
994 -- p_appl_id := application id of resp (added for AMW)
995 -- p_resp_id := responsibility id (added for AMW)
996 -- p_access_given_date := start_date of user resp (added for AMW)
997 -- p_access_given_by := created_by of user resp (added for AMW)
998 -- MAINTENANCE_MODE_SUPPORT := the value from the column in g_amw_form_functions
999 -- CONTEXT_DEPENDENCE := the value from the column in g_amw_form_functions
1000 -- TEST_MAINT_AVAILABILTY := 'Y' (default) means check if available for
1001 -- current value of profile APPS_MAINTENANCE_MODE
1002 -- 'N' means the caller is checking so it's
1003 -- unnecessary to check.
1004 --
1005 -- Return
1006 -- True := function accessible
1007 -- False := function not accessible
1008 --
1009 -- Notes
1010 -- copy from FND_FUNCTION.TEST_ID_NO_GRANTS (AFSCFNSB.pls 115.51 2003/08/01)
1011 -- and modify for AMW to use dynamic sql.
1012 --
1013 -- FND_FUNCTION.TEST_ID_NO_GRANTS calls FND_FUNCTION.IS_FUNCTION_ON_MENU,
1014 -- since FND_FUNCTION.IS_FUNCTION_ON_MENU will use table FND_COMPILED_MENU_FUNCTIONS,
1015 -- we won't have this compiled table for AMW, so we just use the uncompiled one
1016 -- (aka, call PROCESS_MENU_TREE_DOWN no matter what we have exclusions or not).
1017 --
1018 -- use FND_FUNCTION.AVAILABILITY(maintenance_mode_support) directly,
1019 -- since it's public function of FND_FUNCTION package and no need to modify for AMW.
1020 --
1021 -- ===============================================================
1022 FUNCTION TEST_ID_NO_GRANTS (
1023 function_id in number,
1024 p_appl_id in number,
1025 p_resp_id in number,
1026 p_access_given_date in date,
1027 p_access_given_by in number,
1028 MAINTENANCE_MODE_SUPPORT in varchar2,
1029 CONTEXT_DEPENDENCE in varchar2,
1030 TEST_MAINT_AVAILABILITY in varchar2
1031 ) RETURN boolean
1032 IS
1033
1034 L_API_NAME CONSTANT VARCHAR2(30) := 'TEST_ID_NO_GRANTS';
1035 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
1036
1037 l_function_id number;
1038 l_menu_id number;
1039 l_resp_id number;
1040 l_resp_appl_id number;
1041 result boolean;
1042 L_TEST_MAINT_AVAILABILITY boolean;
1043
1044 BEGIN
1045 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
1046
1047 l_function_id := function_id;
1048 l_resp_id := p_resp_id; -- 11.13.2003 thso: use passed-in
1049 l_resp_appl_id := p_appl_id; -- 11.13.2003 thso: use passed-in
1050
1051 if ( (TEST_MAINT_AVAILABILITY = 'Y')
1055 L_TEST_MAINT_AVAILABILITY := FALSE;
1052 OR (TEST_MAINT_AVAILABILITY is NULL)) then
1053 L_TEST_MAINT_AVAILABILITY := TRUE;
1054 else
1056 end if;
1057
1058 begin
1059 /* If we got here then there are exclusions, so don't use compiled */
1060 result := process_menu_tree_down(l_resp_appl_id,
1061 l_resp_id,
1062 l_function_id,
1063 p_access_given_date,
1064 p_access_given_by);
1065 if(result = FALSE) then
1066 return FALSE;
1067 else
1068 if(L_TEST_MAINT_AVAILABILITY) then
1069 if(FND_FUNCTION.AVAILABILITY(MAINTENANCE_MODE_SUPPORT) = 'Y') then
1070 return TRUE;
1071 else
1072 return FALSE;
1073 end if;
1074 else
1075 return TRUE;
1076 end if;
1077 end if;
1078
1079 exception
1080 when no_data_found then
1081 null;
1082 end;
1083
1084 END TEST_ID_NO_GRANTS;
1085
1086
1087
1088
1089 -- ===============================================================
1090 -- Private Function name
1091 -- TEST_INSTANCE_ID_MAINTMODE
1092 --
1093 -- Purpose
1094 -- Test if function id is accessible under current responsibility.
1095 -- Looks only at the menus on current resp, not any grants.
1096 --
1097 -- Params
1098 -- function_id := function id to test
1099 -- p_appl_id := application id of resp (added for AMW)
1100 -- p_resp_id := responsibility id (added for AMW)
1101 -- p_access_given_date := start_date of user resp (added for AMW)
1102 -- p_access_given_by := created_by of user resp (added for AMW)
1103 -- object_name := NULL
1104 -- instance_pk1_value := NULL
1105 -- instance_pk2_value := NULL
1106 -- instance_pk3_value := NULL
1107 -- instance_pk4_value := NULL
1108 -- instance_pk5_value := NULL
1109 -- user_name := NULL
1110 -- MAINTENANCE_MODE_SUPPORT := the value from the column in g_amw_form_functions
1111 -- CONTEXT_DEPENDENCE := the value from the column in g_amw_form_functions
1112 -- TEST_MAINT_AVAILABILTY := 'Y' (default) means check if available for
1113 -- current value of profile APPS_MAINTENANCE_MODE
1114 -- 'N' means the caller is checking so it's
1115 -- unnecessary to check.
1116 --
1117 -- Return
1118 -- True := function accessible
1119 -- False := function not accessible
1120 --
1121 -- Notes
1122 -- copy from FND_FUNCTION.TEST_INSTANCE_ID_MAINTMODE (AFSCFNSB.pls 115.51 2003/08/01)
1123 -- and modify for AMW to use dynamic sql.
1124 --
1125 -- since AMW constraint doesn't support data security (row base),
1126 -- but supports static function security (function base).
1127 -- Unlike in FND_FUNCTION.TEST_INSTANCE_ID_MAINTMODE,
1128 -- here the passed-in object_name should always be NULL
1129 -- and we won't check data security
1130 --
1131 -- use FND_FUNCTION.AVAILABILITY(maintenance_mode_support) directly,
1132 -- since it's public function of FND_FUNCTION package and no need to modify for AMW.
1133 --
1134 -- ===============================================================
1135 FUNCTION TEST_INSTANCE_ID_MAINTMODE (
1136 function_id IN NUMBER,
1137 p_appl_id IN NUMBER,
1138 p_resp_id IN NUMBER,
1139 p_access_given_date IN DATE,
1140 p_access_given_by IN NUMBER,
1141 object_name IN VARCHAR2,
1142 instance_pk1_value IN VARCHAR2,
1143 instance_pk2_value IN VARCHAR2,
1144 instance_pk3_value IN VARCHAR2,
1145 instance_pk4_value IN VARCHAR2,
1146 instance_pk5_value IN VARCHAR2,
1147 user_name IN VARCHAR2,
1148 MAINTENANCE_MODE_SUPPORT in varchar2,
1149 CONTEXT_DEPENDENCE in varchar2,
1150 TEST_MAINT_AVAILABILITY in varchar2
1151 ) RETURN boolean
1152 IS
1153 L_API_NAME CONSTANT VARCHAR2(30) := 'TEST_INSTANCE_ID_MAINTMODE';
1154 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
1155
1156 ret_val varchar2(1) := 'F';
1157 ret_bool boolean := FALSE;
1158 L_MAINTENANCE_MODE_SUPPORT varchar2(8) := MAINTENANCE_MODE_SUPPORT;
1159 L_CONTEXT_DEPENDENCE varchar2(8) := CONTEXT_DEPENDENCE;
1160
1161 BEGIN
1162 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
1163
1164 if (TEST_ID_NO_GRANTS(function_id,
1165 p_appl_id,
1166 p_resp_id,
1167 p_access_given_date,
1168 p_access_given_by,
1169 L_MAINTENANCE_MODE_SUPPORT,
1170 L_CONTEXT_DEPENDENCE,
1171 'N')) then
1172 ret_bool := TRUE;
1173 goto check_avail;
1174 end if;
1175
1176 if (object_name is not NULL) then
1177 -- 11.13.2003 tsho: ignore object_name, since AMW constraint doesn't support data security
1178 null;
1179 end if;
1180
1181 <<check_avail>>
1182 if (ret_bool = TRUE) then
1186 ret_bool := FALSE;
1183 if(FND_FUNCTION.AVAILABILITY(L_MAINTENANCE_MODE_SUPPORT) = 'Y') then
1184 ret_bool := TRUE;
1185 else
1187 end if;
1188 end if;
1189
1190 <<all_done>>
1191
1192 if (ret_bool) then
1193 return TRUE;
1194 else
1195 return FALSE;
1196 end if;
1197
1198 END TEST_INSTANCE_ID_MAINTMODE;
1199
1200
1201
1202
1203
1204 -- ===============================================================
1205 -- Private Function name
1206 -- TEST_ID
1207 --
1208 -- Purpose
1209 -- Test if function id is accessible under current responsibility.
1210 --
1211 -- Params
1212 -- function_id := function id to test
1213 -- p_appl_id := application id of resp (added for AMW)
1214 -- p_resp_id := responsibility id (added for AMW)
1215 -- p_access_given_date := start_date of user resp (added for AMW)
1216 -- p_access_given_by := created_by of user resp (added for AMW)
1217 --
1218 -- Return
1219 -- True := function accessible
1220 -- False := function not accessible
1221 --
1222 -- Notes
1223 -- copy from FND_FUNCTION.TEST_ID (AFSCFNSB.pls 115.51 2003/08/01)
1224 --
1225 -- ===============================================================
1226 function TEST_ID(
1227 function_id IN NUMBER,
1228 p_appl_id IN NUMBER,
1229 p_resp_id IN NUMBER,
1230 p_access_given_date IN DATE,
1231 p_access_given_by IN NUMBER
1232 ) RETURN boolean
1233 IS
1234
1235 L_API_NAME CONSTANT VARCHAR2(30) := 'TEST_ID';
1236 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
1237
1238 L_MAINTENANCE_MODE_SUPPORT varchar2(8);
1239 L_CONTEXT_DEPENDENCE varchar2(8);
1240 TEST_MAINT_AVAILABILITY varchar2(1) := 'Y';
1241 L_FUNCTION_ID NUMBER;
1242
1243 -- 11.13.2003 tsho: use dynamic sql for AMW
1244 -- 12.12.2003 tsho: use static sql for AMW for the time being
1245 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
1246 TYPE funcCurTyp IS REF CURSOR;
1247 func_c funcCurTyp;
1248 l_func_dynamic_sql VARCHAR2(200) :=
1249 'SELECT MAINTENANCE_MODE_SUPPORT, CONTEXT_DEPENDENCE '
1250 ||' FROM '||G_AMW_FORM_FUNCTIONS_VL
1251 ||' WHERE FUNCTION_ID = :1 ';
1252
1253 BEGIN
1254 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
1255 L_MAINTENANCE_MODE_SUPPORT := NULL;
1256 L_CONTEXT_DEPENDENCE := NULL;
1257 L_FUNCTION_ID := function_id;
1258
1259
1260 begin
1261 -- 12.12.2003 tsho: use static sql for AMW for the time being
1262 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
1263 OPEN func_c FOR l_func_dynamic_sql USING
1264 function_id;
1265 FETCH func_c INTO L_MAINTENANCE_MODE_SUPPORT,
1266 L_CONTEXT_DEPENDENCE;
1267 CLOSE func_c;
1268 /*
1269 SELECT MAINTENANCE_MODE_SUPPORT, CONTEXT_DEPENDENCE
1270 INTO L_MAINTENANCE_MODE_SUPPORT, L_CONTEXT_DEPENDENCE
1271 FROM FND_FORM_FUNCTIONS
1272 WHERE FUNCTION_ID = l_function_id;
1273 */
1274
1275 exception
1276 when no_data_found then
1277 return FALSE; /* Bad function id passed */
1278 when others then
1279 --FND_FILE.put_line(fnd_file.log,'other exception '||SQLERRM);
1280 raise;
1281 end;
1282
1283 return TEST_INSTANCE_ID_MAINTMODE(
1284 function_id => function_id,
1285 p_appl_id => p_appl_id,
1286 p_resp_id => p_resp_id,
1287 p_access_given_date => p_access_given_date,
1288 p_access_given_by => p_access_given_by,
1289 object_name => NULL,
1290 instance_pk1_value => NULL,
1291 instance_pk2_value => NULL,
1292 instance_pk3_value => NULL,
1293 instance_pk4_value => NULL,
1294 instance_pk5_value => NULL,
1295 user_name => NULL,
1296 MAINTENANCE_MODE_SUPPORT => L_MAINTENANCE_MODE_SUPPORT,
1297 CONTEXT_DEPENDENCE => L_CONTEXT_DEPENDENCE,
1298 TEST_MAINT_AVAILABILITY => TEST_MAINT_AVAILABILITY);
1299
1300 END TEST_ID;
1301
1302
1303
1304 -- ===============================================================
1305 -- Function name
1306 -- Get_Party_Id
1307 --
1308 -- Purpose
1309 -- get the party_id by specified user_id
1310 --
1311 -- Params
1312 -- p_user_id := specified user_id
1313 --
1314 -- ===============================================================
1315 Function Get_Party_Id (
1316 p_user_id IN NUMBER
1317 )
1318 Return NUMBER
1319 IS
1320
1321 L_API_NAME CONSTANT VARCHAR2(30) := 'Get_Party_Id';
1322 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
1323
1324 l_party_id NUMBER;
1325
1326 -- find all employees having corresponding user_id in g_amw_user
1327 -- 12.12.2003 tsho: use static sql for AMW for the time being
1328 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
1329 TYPE userCurTyp IS REF CURSOR;
1330 c_user_dynamic_sql userCurTyp;
1334 ||' WHERE u.user_id = :1 ';
1331 l_user_dynamic_sql VARCHAR2(200) :=
1332 'SELECT person_party_id '
1333 ||' FROM '||G_AMW_USER ||' u '
1335
1336 BEGIN
1337 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
1338 -- 12.12.2003 tsho: use static sql for AMW for the time being
1339 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
1340 OPEN c_user_dynamic_sql FOR l_user_dynamic_sql USING
1341 p_user_id;
1342 FETCH c_user_dynamic_sql INTO l_party_id;
1343 CLOSE c_user_dynamic_sql;
1344 /*
1345 SELECT person_party_id
1346 INTO l_party_id
1347 FROM FND_USER u
1348 WHERE u.user_id = p_user_id;
1349 */
1350
1351 RETURN l_party_id;
1352
1353 END Get_Party_Id;
1354
1355
1356 -- ===============================================================
1357 -- Procedure name
1358 -- Populate_User_Id_List
1359 --
1360 -- Purpose
1361 -- populate the global user id list
1362 --
1363 -- Notes
1364 -- 01.10.2005 tsho: Deprecated, use Populate_User_Id_List_For_Cst instead
1365 -- ===============================================================
1366 Procedure Populate_User_Id_List
1367 IS
1368
1369 L_API_NAME CONSTANT VARCHAR2(30) := 'Populate_User_Id_List';
1370 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
1371
1372 i NUMBER;
1373 l_user_id NUMBER;
1374
1375 -- find all employees having corresponding user_id in g_amw_user
1376 -- 12.12.2003 tsho: use static sql for AMW for the time being
1377 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
1378 TYPE userCurTyp IS REF CURSOR;
1379 c_user_dynamic_sql userCurTyp;
1380 l_user_dynamic_sql VARCHAR2(200) :=
1381 'SELECT user_id '
1382 ||' FROM amw_employees_current_v emp, '
1383 || G_AMW_USER ||' u '
1384 ||' WHERE emp.party_id = u.person_party_id ';
1385 /*
1386 cursor get_user_c is
1387 SELECT user_id
1388 FROM amw_employees_current_v emp,
1389 fnd_user u
1390 WHERE emp.party_id = u.person_party_id;
1391 */
1392
1393 BEGIN
1394 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
1395
1396 -- find all employees having corresponding user_id in g_amw_user
1397 IF (BULK_COLLECTS_SUPPORTED) THEN
1398 -- 12.12.2003 tsho: use static sql for AMW for the time being
1399 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
1400 OPEN c_user_dynamic_sql FOR l_user_dynamic_sql;
1401 FETCH c_user_dynamic_sql BULK COLLECT INTO G_USER_ID_LIST;
1402 CLOSE c_user_dynamic_sql;
1403 /*
1404 OPEN get_user_c;
1405 FETCH get_user_c BULK COLLECT INTO G_USER_ID_LIST;
1406 CLOSE get_user_c;
1407 */
1408
1409 ELSE
1410 -- no BULK_COLLECTS_SUPPORTED
1411 i := 0;
1412 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
1413 OPEN c_user_dynamic_sql FOR l_user_dynamic_sql;
1414 LOOP
1415 FETCH c_user_dynamic_sql INTO l_user_id;
1416 EXIT WHEN c_user_dynamic_sql%NOTFOUND;
1417 i := i+1;
1418 G_USER_ID_LIST(i) := l_user_id;
1419 END LOOP;
1420 CLOSE c_user_dynamic_sql;
1421 /*
1422 FOR rec in get_user_c LOOP
1423 i := i + 1;
1424 G_USER_ID_LIST(i) := rec.user_id;
1425 END LOOP;
1426 */
1427
1428 END IF; -- end of if: BULK_COLLECTS_SUPPORTED
1429
1430 END Populate_User_Id_List;
1431
1432 -- ===============================================================
1433 -- Procedure name
1434 -- Populate_User_Vio_For_Cst
1435 -- Purpose
1436 -- populate the global user id with the incompatible functions
1437 -- accessible by him for one constraint
1438 -- Params
1439 -- p_constraint_rev_id := specified constraint_rev_id
1440 -- p_type_code := specified constraint type code (default is NULL)
1441 -- History
1442 -- 06.30.2006 psomanat: created the procedure
1443 -- ===============================================================
1444 Procedure Populate_User_Vio_For_Cst(
1445 p_constraint_rev_id IN NUMBER,
1446 p_type_code IN VARCHAR2 := NULL
1447 )
1448 IS
1449
1450 L_API_NAME CONSTANT VARCHAR2(30) := 'Populate_User_Vio_For_Cst';
1451 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.1;
1452
1453 -- 01.06.2005 tsho: store the constraint type for this constraint
1454 l_type_code VARCHAR2(30) := p_type_code;
1455 -- 01.06.2005 tsho: find the constraint by specified constraint_rev_id
1456 CURSOR c_constraint (l_constraint_rev_id IN NUMBER) IS
1457 SELECT type_code
1458 FROM amw_constraints_b
1459 WHERE constraint_rev_id=l_constraint_rev_id;
1460
1461 TYPE userVioCurTyp IS REF CURSOR;
1462 c_user_vio_dynamic_sql userVioCurTyp;
1463
1464 -- Identify the roles, user/global grants accessible to a user
1465 -- which makes him a violating user
1466 l_user_role_dynamic_sql VARCHAR2(4000) :=
1467 ' SELECT gra.grantee_key role_name, '
1468 ||' gra.menu_id, '
1469 ||' ce.function_id, '
1470 ||' min(urasgn.start_date), '
1471 ||' ( SELECT asgn.created_by '
1475 ||' AND asgn.start_date = start_date '
1472 ||' FROM '||G_AMW_USER_ROLE_ASSIGNMENTS||' asgn '
1473 ||' WHERE asgn.user_name = usr.user_name '
1474 ||' AND asgn.role_name = role_name '
1476 ||' AND rownum=1 '
1477 ||' ) created_by, '
1478 ||' ''FUNC'' entry_object_type, '
1479 ||' usr.user_id, '
1480 ||' ce.group_code '
1481 ||' FROM '||G_AMW_GRANTS||' gra, '
1482 ||' '||G_AMW_COMPILED_MENU_FUNCTIONS||' cmf, '
1483 ||' AMW_CONSTRAINT_ENTRIES ce, '
1484 ||' '||G_AMW_USER_ROLE_ASSIGNMENTS||' urasgn, '
1485 ||' '||G_AMW_USER||' usr '
1486 ||' WHERE urasgn.user_name = usr.user_name '
1487 ||' AND (gra.grantee_orig_system = ''UMX'' OR gra.grantee_orig_system = ''FND_RESP'') '
1488 ||' AND urasgn.role_name = gra.GRANTEE_KEY '
1489 ||' AND gra.menu_id = cmf.menu_id '
1490 ||' AND cmf.function_id = ce.function_id '
1491 ||' AND (ce.object_type is null OR ce.object_type = ''FUNC'') '
1492 ||' AND ce.CONSTRAINT_REV_ID = :1 '
1493 ||' AND gra.INSTANCE_TYPE = ''GLOBAL'' '
1494 ||' AND gra.OBJECT_ID = -1 '
1495 ||' AND gra.GRANTEE_TYPE = ''GROUP'' '
1496 ||' AND gra.start_date <= sysdate '
1497 ||' AND (gra.end_date >= sysdate or gra.end_date is null) '
1498 ||' AND urasgn.start_date <= sysdate '
1499 ||' AND (urasgn.end_date >= sysdate or urasgn.end_date is null) '
1500 ||' AND usr.start_date <= sysdate '
1501 ||' AND (usr.end_date >= sysdate or usr.end_date is null) '
1502 ||' GROUP BY gra.grantee_key, gra.menu_id,ce.function_id,usr.user_name,usr.user_id,ce.group_code'
1503 ||' UNION ALL '
1504 ||' SELECT to_char(null) role_name, '
1505 ||' gra.menu_id, '
1506 ||' ce.function_id, '
1507 ||' gra.start_date, '
1508 ||' gra.created_by, '
1509 ||' ''FUNC'' entry_object_type, '
1510 ||' usr.user_id, '
1511 ||' ce.group_code '
1512 ||' FROM '||G_AMW_GRANTS||' gra, '
1513 ||' '||G_AMW_COMPILED_MENU_FUNCTIONS||' cmf, '
1514 ||' AMW_CONSTRAINT_ENTRIES ce, '
1515 ||' '||G_AMW_USER||' usr '
1516 ||' WHERE (( gra.GRANTEE_KEY = usr.user_name AND gra.GRANTEE_TYPE = ''USER'') '
1517 ||' OR (gra.GRANTEE_KEY = ''GLOBAL'' AND gra.GRANTEE_TYPE = ''GLOBAL'')) '
1518 ||' AND gra.menu_id = cmf.menu_id '
1519 ||' AND cmf.function_id = ce.function_id '
1520 ||' AND (ce.object_type is null OR ce.object_type = ''FUNC'') '
1521 ||' AND ce.CONSTRAINT_REV_ID = :2 '
1522 ||' AND gra.INSTANCE_TYPE = ''GLOBAL'' '
1523 ||' AND gra.OBJECT_ID = -1 '
1524 ||' AND gra.start_date <= sysdate '
1525 ||' AND (gra.end_date >= sysdate or gra.end_date is null) '
1526 ||' AND usr.start_date <= sysdate '
1527 ||' AND (usr.end_date >= sysdate or usr.end_date is null) ';
1528
1529 -- Identify the responsibilities accessible to a user
1530 -- which makes him a violating user
1531 l_user_func_cst_dynamic_sql VARCHAR2(9000) :=
1532 ' SELECT usr.user_id, '
1533 ||' appl.application_id, '
1534 ||' ur.role_orig_system_id, '
1535 ||' min(urasgn.start_date) start_date, '
1536 ||' ( select asgn.created_by '
1537 ||' from '||G_AMW_USER_ROLE_ASSIGNMENTS||' asgn '
1538 ||' where asgn.user_name = ur.user_name '
1539 ||' and asgn.role_name = ur.role_name '
1540 ||' and asgn.start_date = start_date '
1541 ||' and rownum=1 '
1542 ||' ) created_by, '
1543 ||' DECODE((select count(*) '
1544 ||' from amw_constraint_waivers_b '
1545 ||' where constraint_rev_id= :1 '
1546 ||' and object_type=''RESP'' '
1547 ||' and pk1 = ur.role_orig_system_id '
1548 ||' and pk2 = appl.application_id '
1549 ||' and start_date <= sysdate '
1550 ||' AND (end_date >= sysdate or end_date is null)),0,''N'',''Y'') waived_flag '
1551 ||' FROM WF_USER_ROLES ur, '
1552 ||' '||G_AMW_USER_ROLE_ASSIGNMENTS||' urasgn, '
1553 ||' '||G_AMW_USER||' usr, '
1554 ||' WF_LOCAL_ROLES rol, '
1555 ||' FND_APPLICATION_VL appl, '
1556 ||' '||G_AMW_RESPONSIBILITY||' resp, '
1557 ||' '||G_AMW_COMPILED_MENU_FUNCTIONS||' cmf, '
1558 ||' AMW_CONSTRAINT_ENTRIES ce '
1559 ||' WHERE ce.CONSTRAINT_REV_ID = :2 '
1560 ||' AND (ce.object_type is null OR ce.object_type = ''FUNC'') '
1561 ||' AND cmf.menu_id = resp.menu_id '
1562 ||' AND cmf.grant_flag = ''Y'' '
1563 ||' AND cmf.function_id = ce.function_id '
1564 ||' AND resp.start_date <= sysdate '
1565 ||' AND (resp.end_date >= sysdate or resp.end_date is null) '
1566 ||' AND ur.role_orig_system_id = resp.responsibility_id '
1567 ||' AND ur.role_orig_system = ''FND_RESP'' '
1568 ||' AND ur.role_name = rol.name '
1569 ||' AND ur.role_orig_system = rol.orig_system '
1570 ||' AND ur.role_orig_system_id = rol.orig_system_id '
1571 ||' AND ur.partition_id = rol.partition_id '
1572 ||' AND rol.start_date<= sysdate '
1573 ||' AND (rol.expiration_date IS NULL OR rol.expiration_date>=sysdate) '
1574 ||' AND rol.owner_tag=appl.application_short_name '
1575 ||' AND resp.application_id=appl.application_id '
1576 ||' AND ur.user_name = urasgn.user_name '
1577 ||' AND ur.role_name = urasgn.role_name '
1578 ||' AND urasgn.start_date <= sysdate '
1579 ||' AND (urasgn.end_date >= sysdate or urasgn.end_date is null) '
1583 ||' AND (usr.end_date >= sysdate or usr.end_date is null) '
1580 ||' AND ur.user_name=usr.user_name '
1581 ||' AND (ur.user_orig_system = ''FND_USR'' OR ur.user_orig_system = ''PER'') '
1582 ||' AND usr.start_date <= sysdate '
1584 ||' GROUP BY usr.user_id,ur.user_name,appl.application_id,ur.role_orig_system_id, ur.role_name '
1585 ||' UNION '
1586 ||' SELECT usr.user_id, '
1587 ||' appl.application_id, '
1588 ||' ur.role_orig_system_id, '
1589 ||' min(urasgn.start_date) start_date, '
1590 ||' ( select asgn.created_by '
1591 ||' from '||G_AMW_USER_ROLE_ASSIGNMENTS||' asgn '
1592 ||' where asgn.user_name = ur.user_name '
1593 ||' and asgn.role_name = ur.role_name '
1594 ||' and asgn.start_date = start_date '
1595 ||' and rownum=1 '
1596 ||' ) created_by, '
1597 ||' DECODE((select count(*) '
1598 ||' from amw_constraint_waivers_b '
1599 ||' where constraint_rev_id= :3 '
1600 ||' and object_type=''RESP'' '
1601 ||' and pk1 = ur.role_orig_system_id '
1602 ||' and pk2 = appl.application_id '
1603 ||' and start_date <= sysdate '
1604 ||' AND (end_date >= sysdate or end_date is null)),0,''N'',''Y'') waived_flag '
1605 ||' FROM WF_USER_ROLES ur, '
1606 ||' '||G_AMW_USER_ROLE_ASSIGNMENTS||' urasgn, '
1607 ||' '||G_AMW_USER||' usr, '
1608 ||' WF_LOCAL_ROLES rol, '
1609 ||' FND_APPLICATION_VL appl, '
1610 ||' '||G_AMW_RESPONSIBILITY||' RESP, '
1611 ||' '||G_AMW_REQUEST_GROUP_UNITS||' RGU, '
1612 ||' AMW_CONSTRAINT_ENTRIES ACE '
1613 ||' WHERE ACE.CONSTRAINT_REV_ID=:4 '
1614 ||' AND ACE.OBJECT_TYPE=''CP'' '
1615 ||' AND RESP.GROUP_APPLICATION_ID IS NOT NULL '
1616 ||' AND RESP.REQUEST_GROUP_ID IS NOT NULL '
1617 ||' AND RGU.APPLICATION_ID=RESP.GROUP_APPLICATION_ID '
1618 ||' AND RGU.REQUEST_GROUP_ID=RESP.REQUEST_GROUP_ID '
1619 ||' AND RGU.REQUEST_UNIT_TYPE = ''P'' '
1620 ||' AND RGU.UNIT_APPLICATION_ID=ACE.APPLICATION_ID '
1621 ||' AND RGU.REQUEST_UNIT_ID=ACE.FUNCTION_ID '
1622 ||' AND RESP.START_DATE<=SYSDATE '
1623 ||' AND (RESP.END_DATE>= SYSDATE or RESP.END_DATE IS NULL) '
1624 ||' AND ur.role_orig_system_id = resp.responsibility_id '
1625 ||' AND ur.role_orig_system = ''FND_RESP'' '
1626 ||' AND ur.role_name = rol.name '
1627 ||' AND ur.role_orig_system = rol.orig_system '
1628 ||' AND ur.role_orig_system_id = rol.orig_system_id '
1629 ||' AND ur.partition_id = rol.partition_id '
1630 ||' AND rol.start_date<= sysdate '
1631 ||' AND (rol.expiration_date IS NULL OR rol.expiration_date>=sysdate) '
1632 ||' AND rol.owner_tag = appl.application_short_name '
1633 ||' AND resp.application_id = appl.application_id '
1634 ||' AND ur.user_name = urasgn.user_name '
1635 ||' AND ur.role_name = urasgn.role_name '
1636 ||' AND urasgn.start_date <= sysdate '
1637 ||' AND (urasgn.end_date >= sysdate or urasgn.end_date is null) '
1638 ||' AND ur.user_name=usr.user_name '
1639 ||' AND (ur.user_orig_system = ''FND_USR'' OR ur.user_orig_system = ''PER'') '
1640 ||' AND usr.start_date <= sysdate '
1641 ||' AND (usr.end_date >= sysdate or usr.end_date is null) '
1642 ||' GROUP BY usr.user_id,ur.user_name,appl.application_id,ur.role_orig_system_id, ur.role_name ';
1643
1644 -- Identify the responsibilities accessible to a user
1645 -- which makes him a violating user
1646 l_user_resp_dynamic_sql VARCHAR2(4000) :=
1647 ' SELECT usr.user_id, '
1648 ||' appl.application_id, '
1649 ||' ur.role_orig_system_id, '
1650 ||' min(urasgn.start_date) start_date, '
1651 ||' ( select asgn.created_by '
1652 ||' from '||G_AMW_USER_ROLE_ASSIGNMENTS||' asgn '
1653 ||' where asgn.user_name = ur.user_name '
1654 ||' and asgn.role_name = ur.role_name '
1655 ||' and asgn.start_date = start_date '
1656 ||' and rownum=1 '
1657 ||' ) created_by ,'
1658 ||' ce.group_code '
1659 ||' FROM WF_USER_ROLES ur, '
1660 ||' '||G_AMW_USER_ROLE_ASSIGNMENTS||' urasgn, '
1661 ||' '||G_AMW_USER||' usr, '
1662 ||' WF_LOCAL_ROLES rol, '
1663 ||' FND_APPLICATION_VL appl, '
1664 ||' '||G_AMW_RESPONSIBILITY||' resp, '
1665 ||' AMW_CONSTRAINT_ENTRIES ce '
1666 ||' WHERE ce.CONSTRAINT_REV_ID = :1 '
1667 ||' AND ce.object_type = ''RESP'' '
1668 ||' AND ce.function_id = resp.responsibility_id '
1669 ||' AND ce.application_id = resp.application_id '
1670 ||' AND ur.role_orig_system_id = resp.responsibility_id '
1671 ||' AND ur.role_orig_system = ''FND_RESP'' '
1672 ||' AND ur.role_name = rol.name '
1673 ||' AND ur.role_orig_system = rol.orig_system '
1674 ||' AND ur.role_orig_system_id = rol.orig_system_id '
1675 ||' AND ur.partition_id = rol.partition_id '
1676 ||' AND rol.owner_tag = appl.application_short_name '
1677 ||' AND resp.application_id = appl.application_id '
1678 ||' AND ur.user_name = urasgn.user_name '
1679 ||' AND ur.role_name = urasgn.role_name '
1680 ||' AND ur.user_name = usr.user_name '
1681 ||' AND rol.start_date <= sysdate '
1682 ||' AND (rol.expiration_date IS NULL OR rol.expiration_date>=sysdate) '
1683 ||' AND resp.start_date <= sysdate '
1687 ||' AND usr.start_date <= sysdate '
1684 ||' AND (resp.end_date >= sysdate OR resp.end_date IS NULL) '
1685 ||' AND urasgn.start_date <= sysdate '
1686 ||' AND (urasgn.end_date >= sysdate OR urasgn.end_date IS NULL) '
1688 ||' AND (usr.end_date >= sysdate OR usr.end_date IS NULL) '
1689 ||' GROUP BY usr.user_id,ur.user_name,appl.application_id,ur.role_orig_system_id, ur.role_name,ce.group_code ';
1690
1691 -- psomanat : 06:09:2006 : fix for bug 5256720
1692 L_USERVIO_ENTRIES G_USERVIO_ENTRIES_TABLE;
1693 L_FUNC_ID_LIST G_FUNCS_TABLE;
1694 L_RESP_ID_LIST G_RESPS_TABLE;
1695 counts Number;
1696 listkey NUMBER(15);
1697 l_user_access_waived_resp_list G_VARCHAR2_TABLE;
1698
1699 L_RESPVIO_ENTRIES G_RESPVIO_ENTRIES_TABLE;
1700 L_RESP_FUNC_ID_LIST G_FUNC_TABLE;
1701 rListkey VARCHAR2(30) := NULL;
1702 flag boolean:=true;
1703 BEGIN
1704 -- FND_FILE.put_line(fnd_file.log,'Populate_User_Vio_For_Cst Began '||to_char(sysdate,'DD-MON-RRRR:HH24:MI:SS'));
1705
1706 IF (p_type_code IS NULL) THEN
1707 OPEN c_constraint(p_constraint_rev_id);
1708 FETCH c_constraint INTO l_type_code;
1709 CLOSE c_constraint;
1710 END IF; -- end of if: _type_code IS NULL
1711
1712 G_USER_VIOLATIONS_LIST.delete();
1713 G_USER_RESP_VIO_LIST.delete();
1714
1715 IF (substr(l_type_code,1,4) = 'RESP') THEN
1716
1717 -- Clearing the list
1718 G_CST_USER_ID_LIST.DELETE();
1719 G_UPV_APPLICATION_ID_LIST.DELETE();
1720 G_UPV_RESPONSIBILITY_ID_LIST.DELETE();
1721 G_UPV_ACCESS_GIVEN_DATE_LIST.DELETE();
1722 G_UPV_ACCESS_GIVEN_BY_LIST.DELETE();
1723 G_UPV_GROUP_CODE_LIST.DELETE();
1724
1725 -- For responsibility violation, we identify the responsibilities
1726 -- accessible to the user in the G_UPV_XXXXXX_LIST
1727 OPEN c_user_vio_dynamic_sql FOR l_user_resp_dynamic_sql USING
1728 p_constraint_rev_id;
1729 FETCH c_user_vio_dynamic_sql
1730 BULK COLLECT INTO G_CST_USER_ID_LIST,
1731 G_UPV_APPLICATION_ID_LIST,
1732 G_UPV_RESPONSIBILITY_ID_LIST,
1733 G_UPV_ACCESS_GIVEN_DATE_LIST,
1734 G_UPV_ACCESS_GIVEN_BY_LIST,
1735 G_UPV_GROUP_CODE_LIST;
1736 CLOSE c_user_vio_dynamic_sql;
1737
1738 -- A user can have n number of responsibilities associated to him
1739 -- We need to iterate over the G_UPV_XXXXXX_LIST to get the responsibilities
1740 -- assigned to the user.
1741 -- This will cause a performace issue
1742 -- So we store the G_UPV_XXXXXX_LIST nested tables data into a plsql data
1743 -- structure. The structure is like this
1744 -- User_id
1745 -- |______Responsibility_id
1746 -- |______Responsibility_id
1747 -- |______Responsibility_id
1748 --
1749
1750 IF (G_CST_USER_ID_LIST IS NOT NULL) AND (G_CST_USER_ID_LIST.FIRST IS NOT NULL) THEN
1751 FOR i in 1 .. G_CST_USER_ID_LIST.COUNT
1752 LOOP
1753 flag:=TRUE;
1754 listkey :=G_CST_USER_ID_LIST(i);
1755 rListkey :=G_UPV_APPLICATION_ID_LIST(i)||'@'||G_UPV_RESPONSIBILITY_ID_LIST(i);
1756
1757 L_RESP_ID_LIST.delete();
1758 L_USERVIO_ENTRIES.delete();
1759
1760 IF (G_USER_RESP_VIO_LIST.EXISTS(listkey)) THEN
1761 L_RESP_ID_LIST := G_USER_RESP_VIO_LIST(listkey);
1762 IF L_RESP_ID_LIST.EXISTS(rListkey) THEN
1763 L_USERVIO_ENTRIES := L_RESP_ID_LIST(rListkey);
1764 FOR l IN L_USERVIO_ENTRIES.FIRST .. L_USERVIO_ENTRIES.LAST
1765 LOOP
1766 IF ( L_USERVIO_ENTRIES(l).application_id = G_UPV_APPLICATION_ID_LIST(i) AND
1767 L_USERVIO_ENTRIES(l).Responsibility_id = G_UPV_RESPONSIBILITY_ID_LIST(i)) THEN
1768 flag:=FALSE;
1769 END IF;
1770 END LOOP;
1771 END IF;
1772 END IF;
1773 IF (flag) THEN
1774 counts := L_USERVIO_ENTRIES.COUNT+1;
1775 L_USERVIO_ENTRIES(counts).User_id := G_CST_USER_ID_LIST(i);
1776 L_USERVIO_ENTRIES(counts).Access_Given_Date := G_UPV_ACCESS_GIVEN_DATE_LIST(i);
1777 L_USERVIO_ENTRIES(counts).Access_Given_By_Id := G_UPV_ACCESS_GIVEN_BY_LIST(i);
1778 L_USERVIO_ENTRIES(counts).application_id := G_UPV_APPLICATION_ID_LIST(i);
1779 L_USERVIO_ENTRIES(counts).Responsibility_id := G_UPV_RESPONSIBILITY_ID_LIST(i);
1780 L_USERVIO_ENTRIES(counts).group_code := G_UPV_GROUP_CODE_LIST(i);
1781 L_USERVIO_ENTRIES(counts).Waived := NUll;
1782 L_USERVIO_ENTRIES(counts).Role_Name := NUll;
1783 L_USERVIO_ENTRIES(counts).Menu_id := NUll;
1784 L_USERVIO_ENTRIES(counts).Function_Id := NUll;
1785 L_USERVIO_ENTRIES(counts).Object_Type := NUll;
1786 L_USERVIO_ENTRIES(counts).prog_appl_id := NUll;
1787 L_RESP_ID_LIST(rListkey) := L_USERVIO_ENTRIES;
1788 G_USER_RESP_VIO_LIST(listkey) := L_RESP_ID_LIST;
1789 END IF;
1790 END LOOP;
1794 G_CST_USER_ID_LIST.DELETE();
1791 END IF;
1792
1793 -- Clearing the list
1795 G_UPV_APPLICATION_ID_LIST.DELETE();
1796 G_UPV_RESPONSIBILITY_ID_LIST.DELETE();
1797 G_UPV_ACCESS_GIVEN_DATE_LIST.DELETE();
1798 G_UPV_ACCESS_GIVEN_BY_LIST.DELETE();
1799 G_UPV_GROUP_CODE_LIST.DELETE();
1800 ELSE
1801 -- clear the list
1802 G_UPV_ROLE_NAME_LIST.delete();
1803 G_UPV_MENU_ID_LIST.delete();
1804 G_UPV_FUNCTION_ID_LIST.delete();
1805 G_UPV_ACCESS_GIVEN_DATE_LIST.delete();
1806 G_UPV_ACCESS_GIVEN_BY_LIST.delete();
1807 G_UPV_ENTRY_OBJECT_TYPE_LIST.delete();
1808 G_CST_USER_ID_LIST.delete();
1809 G_UPV_GROUP_CODE_LIST.delete();
1810
1811 -- A user can have n number of responsibilities associated to him
1812 -- We need to iterate over the G_UPV_XXXXXX_LIST to get the responsibilities
1813 -- assigned to the user. Then from the responsibility we need to
1814 -- get the incompatible functions accessible to the user.
1815 -- This will cause a performace issue
1816 -- So we store the G_UPV_XXXXXX_LIST nested tables and G_RESP_VIOLATIONS_LIST
1817 -- data into a plsql data structure.
1818 -- The structure is like this
1819 -- User_id
1820 -- |______Function_Id
1821 -- |______Function Detils group1
1822 -- |______Function Detils group2
1823 -- |______Function_Id
1824 -- |______Function Detils group1
1825 -- |______Function Detils group2
1826 -- |______Function_Id
1827 -- |______Function Detils group1
1828 -- |______Function Detils group2
1829 -- A function can be avilable in group 1 and group 2
1830 -- so we store both groups under function_id
1831
1832 -- First we get the user - roles,user - grants, global grants and
1833 -- populate the plsql data structure
1834 OPEN c_user_vio_dynamic_sql FOR l_user_role_dynamic_sql USING
1835 p_constraint_rev_id,
1836 p_constraint_rev_id;
1837 FETCH c_user_vio_dynamic_sql
1838 BULK COLLECT INTO G_UPV_ROLE_NAME_LIST,
1839 G_UPV_MENU_ID_LIST,
1840 G_UPV_FUNCTION_ID_LIST,
1841 G_UPV_ACCESS_GIVEN_DATE_LIST,
1842 G_UPV_ACCESS_GIVEN_BY_LIST,
1843 G_UPV_ENTRY_OBJECT_TYPE_LIST,
1844 G_CST_USER_ID_LIST,
1845 G_UPV_GROUP_CODE_LIST;
1846 CLOSE c_user_vio_dynamic_sql;
1847
1848 IF (G_CST_USER_ID_LIST IS NOT NULL) AND (G_CST_USER_ID_LIST.FIRST IS NOT NULL) THEN
1849 FOR i in 1 .. G_CST_USER_ID_LIST.COUNT
1850 LOOP
1851 flag:=TRUE;
1852 L_FUNC_ID_LIST.delete();
1853 L_USERVIO_ENTRIES.delete();
1854
1855 listkey :=G_CST_USER_ID_LIST(i);
1856 IF (G_USER_VIOLATIONS_LIST.EXISTS(listkey)) THEN
1857 L_FUNC_ID_LIST := G_USER_VIOLATIONS_LIST(listkey);
1858 IF L_FUNC_ID_LIST.EXISTS(G_UPV_FUNCTION_ID_LIST(i)) THEN
1859 L_USERVIO_ENTRIES := L_FUNC_ID_LIST(G_UPV_FUNCTION_ID_LIST(i));
1860 FOR l IN L_USERVIO_ENTRIES.FIRST .. L_USERVIO_ENTRIES.LAST
1861 LOOP
1862 IF ( L_USERVIO_ENTRIES(l).Role_Name = G_UPV_ROLE_NAME_LIST(i) AND
1863 L_USERVIO_ENTRIES(l).Menu_id = G_UPV_MENU_ID_LIST(i) AND
1864 L_USERVIO_ENTRIES(l).Function_Id = G_UPV_FUNCTION_ID_LIST(i)) THEN
1865 flag:=FALSE;
1866 END IF;
1867 END LOOP;
1868 END IF;
1869 END IF;
1870 IF (flag) THEN
1871 counts := L_USERVIO_ENTRIES.COUNT+1;
1872 L_USERVIO_ENTRIES(counts).User_id := G_CST_USER_ID_LIST(i);
1873 L_USERVIO_ENTRIES(counts).Role_Name := G_UPV_ROLE_NAME_LIST(i);
1874 L_USERVIO_ENTRIES(counts).Menu_id := G_UPV_MENU_ID_LIST(i);
1875 L_USERVIO_ENTRIES(counts).Function_Id := G_UPV_FUNCTION_ID_LIST(i);
1876 L_USERVIO_ENTRIES(counts).Access_Given_Date := G_UPV_ACCESS_GIVEN_DATE_LIST(i);
1877 L_USERVIO_ENTRIES(counts).Access_Given_By_Id := G_UPV_ACCESS_GIVEN_BY_LIST(i);
1878 L_USERVIO_ENTRIES(counts).Object_Type := 'FUNC';
1879 L_USERVIO_ENTRIES(counts).Waived := 'N';
1880 L_USERVIO_ENTRIES(counts).group_code := G_UPV_GROUP_CODE_LIST(i);
1881 L_USERVIO_ENTRIES(counts).prog_appl_id := NULL;
1882 L_USERVIO_ENTRIES(counts).application_id := NULL;
1883 L_USERVIO_ENTRIES(counts).Responsibility_id := NULL;
1884 L_FUNC_ID_LIST(G_UPV_FUNCTION_ID_LIST(i)) := L_USERVIO_ENTRIES;
1885 G_USER_VIOLATIONS_LIST(listkey) := L_FUNC_ID_LIST;
1886 END IF;
1887 END lOOP;
1888 END IF;
1889
1890 -- clear the list
1891 G_UPV_ROLE_NAME_LIST.delete();
1892 G_UPV_MENU_ID_LIST.delete();
1893 G_UPV_FUNCTION_ID_LIST.delete();
1894 G_UPV_ENTRY_OBJECT_TYPE_LIST.delete();
1895 G_UPV_GROUP_CODE_LIST.delete();
1899 G_UPV_ACCESS_GIVEN_DATE_LIST.delete();
1896 G_CST_USER_ID_LIST.delete();
1897 G_UPV_APPLICATION_ID_LIST.delete();
1898 G_UPV_RESPONSIBILITY_ID_LIST.delete();
1900 G_UPV_ACCESS_GIVEN_BY_LIST.delete();
1901 l_user_access_waived_resp_list.delete();
1902
1903 --Second User - responsbilities and populate the plsql data structure
1904 OPEN c_user_vio_dynamic_sql FOR l_user_func_cst_dynamic_sql USING
1905 p_constraint_rev_id,
1906 p_constraint_rev_id,
1907 p_constraint_rev_id,
1908 p_constraint_rev_id;
1909 FETCH c_user_vio_dynamic_sql
1910 BULK COLLECT INTO G_CST_USER_ID_LIST,
1911 G_UPV_APPLICATION_ID_LIST,
1912 G_UPV_RESPONSIBILITY_ID_LIST,
1913 G_UPV_ACCESS_GIVEN_DATE_LIST,
1914 G_UPV_ACCESS_GIVEN_BY_LIST,
1915 l_user_access_waived_resp_list;
1916 CLOSE c_user_vio_dynamic_sql;
1917
1918 IF (G_CST_USER_ID_LIST IS NOT NULL) AND (G_CST_USER_ID_LIST.FIRST IS NOT NULL) THEN
1919 FOR i in 1 .. G_CST_USER_ID_LIST.COUNT
1920 LOOP
1921 listkey :=G_CST_USER_ID_LIST(i);
1922 rListkey :=G_UPV_APPLICATION_ID_LIST(i)||'@'||G_UPV_RESPONSIBILITY_ID_LIST(i);
1923
1924 IF (G_RESP_VIOLATIONS_LIST.EXISTS(rListkey)) THEN
1925 L_RESP_FUNC_ID_LIST.delete();
1926 L_RESP_FUNC_ID_LIST := G_RESP_VIOLATIONS_LIST(rListkey);
1927 FOR j IN L_RESP_FUNC_ID_LIST.FIRST .. L_RESP_FUNC_ID_LIST.LAST
1928 LOOP
1929 IF L_RESP_FUNC_ID_LIST.EXISTS(j) THEN
1930 L_RESPVIO_ENTRIES.delete();
1931 L_RESPVIO_ENTRIES:=L_RESP_FUNC_ID_LIST(j);
1932 FOR k IN L_RESPVIO_ENTRIES.FIRST .. L_RESPVIO_ENTRIES.LAST
1933 LOOP
1934 flag:=TRUE;
1935 L_FUNC_ID_LIST.delete();
1936 L_USERVIO_ENTRIES.delete();
1937 IF (G_USER_VIOLATIONS_LIST.EXISTS(listkey)) THEN
1938 L_FUNC_ID_LIST := G_USER_VIOLATIONS_LIST(listkey);
1939 IF L_FUNC_ID_LIST.EXISTS(L_RESPVIO_ENTRIES(k).Function_Id) THEN
1940 L_USERVIO_ENTRIES := L_FUNC_ID_LIST(L_RESPVIO_ENTRIES(k).Function_Id);
1941 FOR l IN L_USERVIO_ENTRIES.FIRST .. L_USERVIO_ENTRIES.LAST
1942 LOOP
1943 IF (L_USERVIO_ENTRIES(l).Object_Type = 'FUNC' AND
1944 L_RESPVIO_ENTRIES(k).Object_Type = 'FUNC' AND
1945 L_USERVIO_ENTRIES(l).application_id = L_RESPVIO_ENTRIES(k).application_id AND
1946 L_USERVIO_ENTRIES(l).Responsibility_id = L_RESPVIO_ENTRIES(k).Responsibility_id AND
1947 L_USERVIO_ENTRIES(l).Menu_id = L_RESPVIO_ENTRIES(k).Menu_id ) THEN
1948 flag:=FALSE;
1949 END IF;
1950
1951 IF (L_USERVIO_ENTRIES(l).Object_Type = 'CP' AND
1952 L_RESPVIO_ENTRIES(k).Object_Type = 'CP' AND
1953 L_USERVIO_ENTRIES(l).application_id = L_RESPVIO_ENTRIES(k).application_id AND
1954 L_USERVIO_ENTRIES(l).Responsibility_id = L_RESPVIO_ENTRIES(k).Responsibility_id AND
1955 L_USERVIO_ENTRIES(l).Menu_id = L_RESPVIO_ENTRIES(k).Menu_id AND
1956 L_USERVIO_ENTRIES(l).prog_appl_id = L_RESPVIO_ENTRIES(k).prog_appl_id ) THEN
1957 flag:=FALSE;
1958 END IF;
1959 END LOOP;
1960 END IF;
1961 END IF;
1962 IF (flag)THEN
1963 counts := L_USERVIO_ENTRIES.COUNT+1;
1964 L_USERVIO_ENTRIES(counts).User_id := G_CST_USER_ID_LIST(i);
1965 L_USERVIO_ENTRIES(counts).Role_Name := NUll;
1966 L_USERVIO_ENTRIES(counts).Menu_id := L_RESPVIO_ENTRIES(k).Menu_id;
1967 L_USERVIO_ENTRIES(counts).Function_Id := L_RESPVIO_ENTRIES(k).Function_Id;
1968 L_USERVIO_ENTRIES(counts).Access_Given_Date := G_UPV_ACCESS_GIVEN_DATE_LIST(i);
1969 L_USERVIO_ENTRIES(counts).Access_Given_By_Id := G_UPV_ACCESS_GIVEN_BY_LIST(i);
1970 L_USERVIO_ENTRIES(counts).Object_Type := L_RESPVIO_ENTRIES(k).Object_Type;
1971 L_USERVIO_ENTRIES(counts).prog_appl_id := L_RESPVIO_ENTRIES(k).prog_appl_id;
1972 L_USERVIO_ENTRIES(counts).application_id := L_RESPVIO_ENTRIES(k).application_id;
1973 L_USERVIO_ENTRIES(counts).Responsibility_id := L_RESPVIO_ENTRIES(k).Responsibility_id;
1974 L_USERVIO_ENTRIES(counts).group_code := L_RESPVIO_ENTRIES(k).group_code;
1978 END IF;
1975 L_USERVIO_ENTRIES(counts).Waived := l_user_access_waived_resp_list(i);
1976 L_FUNC_ID_LIST(L_RESPVIO_ENTRIES(k).Function_Id):= L_USERVIO_ENTRIES;
1977 G_USER_VIOLATIONS_LIST(listkey) := L_FUNC_ID_LIST;
1979 END LOOP;
1980 END IF;
1981 END LOOP;
1982 END IF;
1983 END lOOP;
1984 END IF;
1985
1986 -- Clear the list
1987 G_CST_USER_ID_LIST.delete();
1988 G_UPV_APPLICATION_ID_LIST.delete();
1989 G_UPV_RESPONSIBILITY_ID_LIST.delete();
1990 G_UPV_ACCESS_GIVEN_DATE_LIST.delete();
1991 G_UPV_ACCESS_GIVEN_BY_LIST.delete();
1992 l_user_access_waived_resp_list.delete();
1993 END IF;
1994 -- FND_FILE.put_line(fnd_file.log,'Populate_User_Vio_For_Cst END '||to_char(sysdate,'DD-MON-RRRR:HH24:MI:SS'));
1995 END;
1996
1997 -- ===============================================================
1998 -- Procedure name
1999 -- Populate_User_Id_List_For_Cst
2000 -- Purpose
2001 -- populate the global user id list for one constraint (G_CST_USER_ID_LIST)
2002 -- Params
2003 -- p_constraint_rev_id := specified constraint_rev_id
2004 -- p_type_code := specified constraint type code (default is NULL)
2005 -- Notes
2006 -- p_type_code is introduced in AMW.D
2007 -- if p_type_code is null, then check the type_code of p_constraint_rev_id
2008 -- History
2009 -- 12.21.2004 tsho: fix for performance bug 4036679
2010 -- 01.06.2005 tsho: starting from AMW.D,
2011 -- consider Incompatible Responsibilities.
2012 -- consider Responsibility waivers, User waivers.
2013 -- not only check for employees, check for all users in G_AMW_USER
2014 -- 05.17.2005 tsho: starting from AMW.E,
2015 -- consider Role, GLOBAL Grant/USER Grant
2016 -- 05.25.2005 tsho: consider Concurrent Programs as constraint entries
2017 -- 06.30.2006 psomanat: Method Depricated. Use Populate_User_Vio_For_Cst
2018 -- ===============================================================
2019 Procedure Populate_User_Id_List_For_Cst(
2020 p_constraint_rev_id IN NUMBER,
2021 p_type_code IN VARCHAR2 := NULL
2022 )
2023 IS
2024
2025 L_API_NAME CONSTANT VARCHAR2(30) := 'Populate_User_Id_List_For_Cst';
2026 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.1;
2027
2028 -- 01.06.2005 tsho: store the constraint type for this constraint
2029 l_type_code VARCHAR2(30) := p_type_code;
2030
2031 -- 01.06.2005 tsho: find the constraint by specified constraint_rev_id
2032 CURSOR c_constraint (l_constraint_rev_id IN NUMBER) IS
2033 SELECT type_code
2034 FROM amw_constraints_b
2035 WHERE constraint_rev_id=l_constraint_rev_id;
2036
2037 i NUMBER;
2038 l_user_id NUMBER;
2039 l_user_name VARCHAR2(320);
2040
2041 -- enable dynamic sql in AMW.C with 5.10
2042 -- should only get user_id who has potential responsibilities
2043 TYPE userCurTyp IS REF CURSOR;
2044 c_user_dynamic_sql userCurTyp;
2045 -- 05.17.2005 tsho: starting from AMW.E, consider Role, GLOBAL Grant/USER Grant
2046 /*
2047 l_user_func_cst_dynamic_sql VARCHAR2(2000) :=
2048 'SELECT distinct ur.user_id '
2049 ||' FROM '||G_AMW_USER_RESP_GROUPS||' ur '
2050 ||' ,'||G_AMW_USER||' u '
2051 ||' WHERE ur.user_id = u.user_id '
2052 ||' AND ur.start_date <= sysdate AND (ur.end_date >= sysdate or ur.end_date is null) '
2053 ||' AND u.start_date <= sysdate AND (u.end_date >= sysdate or u.end_date is null) '
2054 ||' AND ur.responsibility_id in ( '
2055 ||' SELECT responsibility_id '
2056 ||' FROM '||G_AMW_RESPONSIBILITY
2057 ||' WHERE start_date <= sysdate AND (end_date >= sysdate or end_date is null) '
2058 ||' AND menu_id in ( '
2059 ||' SELECT menu_id '
2060 ||' FROM '||G_AMW_COMPILED_MENU_FUNCTIONS
2061 ||' WHERE grant_flag = ''Y'' '
2062 ||' AND function_id in ( '
2063 ||' SELECT constraintEntry.FUNCTION_ID '
2064 ||' FROM AMW_CONSTRAINT_ENTRIES constraintEntry '
2065 ||' WHERE constraintEntry.CONSTRAINT_REV_ID = :1 '
2066 ||' ) '
2067 ||' ) '
2068 ||' ) ';
2069 */
2070 l_user_func_cst_dynamic_sql VARCHAR2(4000) :=
2071 'SELECT u.user_id, u.user_name '
2072 ||' FROM '||G_AMW_USER||' u '
2073 ||' WHERE u.start_date <= sysdate AND (u.end_date >= sysdate or u.end_date is null) '
2074 ||' AND u.user_name in ( '
2075 ||' SELECT ur.user_name '
2076 ||' FROM '||G_AMW_USER_ROLES||' ur '
2077 ||' ,'||G_AMW_RESPONSIBILITY||' resp '
2078 ||' ,'||G_AMW_COMPILED_MENU_FUNCTIONS||' cmf '
2079 ||' ,AMW_CONSTRAINT_ENTRIES ce '
2080 ||' WHERE ur.role_orig_system = ''FND_RESP'' '
2081 ||' AND ur.role_orig_system_id = resp.responsibility_id '
2082 ||' AND resp.menu_id = cmf.menu_id '
2083 ||' AND cmf.function_id = ce.function_id AND (ce.object_type is null OR ce.object_type = ''FUNC'') '
2084 ||' AND cmf.grant_flag = ''Y'' '
2085 ||' AND ce.CONSTRAINT_REV_ID = :1 '
2089 ||' FROM '||G_AMW_USER_ROLES||' ur '
2086 ||' AND resp.start_date <= sysdate AND (resp.end_date >= sysdate or resp.end_date is null) '
2087 ||' UNION ALL '
2088 ||' SELECT ur.user_name '
2090 ||' ,'||G_AMW_RESPONSIBILITY||' resp '
2091 ||' ,'||G_AMW_REQUEST_GROUP_UNITS||' rgu '
2092 ||' ,AMW_CONSTRAINT_ENTRIES ce '
2093 ||' WHERE ur.role_orig_system = ''FND_RESP'' '
2094 ||' AND ur.role_orig_system_id = resp.responsibility_id '
2095 ||' AND resp.request_group_id = rgu.request_group_id '
2096 ||' AND rgu.request_unit_type = ''P'' '
2097 ||' AND rgu.request_unit_id = ce.function_id AND ce.object_type = ''CP'' '
2098 ||' AND ce.CONSTRAINT_REV_ID = :2 '
2099 ||' AND resp.start_date <= sysdate AND (resp.end_date >= sysdate or resp.end_date is null) '
2100 ||' UNION ALL '
2101 ||' SELECT ur.user_name '
2102 ||' FROM '||G_AMW_USER_ROLES||' ur '
2103 ||' ,'||G_AMW_GRANTS||' gra '
2104 ||' ,'||G_AMW_COMPILED_MENU_FUNCTIONS||' cmf '
2105 ||' ,AMW_CONSTRAINT_ENTRIES ce '
2106 ||' WHERE (ur.role_orig_system = ''UMX'' OR ur.role_orig_system = ''FND_RESP'') '
2107 ||' AND ur.ROLE_NAME = gra.GRANTEE_KEY '
2108 ||' AND gra.INSTANCE_TYPE = ''GLOBAL'' '
2109 ||' AND gra.OBJECT_ID = -1 '
2110 ||' AND gra.GRANTEE_TYPE = ''GROUP'' '
2111 ||' AND gra.menu_id = cmf.menu_id '
2112 ||' AND cmf.function_id = ce.function_id '
2113 ||' AND ce.CONSTRAINT_REV_ID = :3 '
2114 ||' AND gra.start_date <= sysdate AND (gra.end_date >= sysdate or gra.end_date is null) '
2115 ||' UNION ALL '
2116 ||' SELECT ur.user_name '
2117 ||' FROM '||G_AMW_USER_ROLES||' ur '
2118 ||' ,'||G_AMW_GRANTS||' gra '
2119 ||' ,'||G_AMW_COMPILED_MENU_FUNCTIONS||' cmf '
2120 ||' ,AMW_CONSTRAINT_ENTRIES ce '
2121 ||' WHERE ur.user_name = gra.GRANTEE_KEY '
2122 ||' AND gra.INSTANCE_TYPE = ''GLOBAL'' '
2123 ||' AND gra.OBJECT_ID = -1 '
2124 ||' AND gra.GRANTEE_TYPE = ''USER'' '
2125 ||' AND gra.menu_id = cmf.menu_id '
2126 ||' AND cmf.function_id = ce.function_id '
2127 ||' AND ce.CONSTRAINT_REV_ID = :4 '
2128 ||' AND gra.start_date <= sysdate AND (gra.end_date >= sysdate or gra.end_date is null) '
2129 ||' ) ';
2130
2131 l_user_resp_cst_dynamic_sql VARCHAR2(2000) :=
2132 'SELECT distinct ur.user_id, to_char(null) user_name '
2133 ||' FROM '||G_AMW_USER_RESP_GROUPS||' ur'
2134 ||' ,'||G_AMW_USER||' u'
2135 ||' WHERE ur.user_id = u.user_id '
2136 ||' AND ur.start_date <= sysdate AND (ur.end_date >= sysdate or ur.end_date is null) '
2137 ||' AND u.start_date <= sysdate AND (u.end_date >= sysdate or u.end_date is null) '
2138 ||' AND ur.responsibility_id in ( '
2139 ||' SELECT constraintEntry.FUNCTION_ID '
2140 ||' FROM AMW_CONSTRAINT_ENTRIES constraintEntry '
2141 ||' WHERE constraintEntry.CONSTRAINT_REV_ID = :1 '
2142 ||' ) ';
2143
2144
2145
2146 BEGIN
2147 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
2148
2149 -- 12.21.2004 tsho: fix for performance bug 4036679, G_USER_ID_LIST is valid for one constraint
2150 G_CST_USER_ID_LIST.DELETE();
2151
2152 --05.17.2005 tsho: starting from AMW.E, store user_name in addition to user_id for use in G_AMW_USER_ROLES
2153 G_CST_USER_NAME_LIST.DELETE();
2154
2155 -- 01.06.2005 tsho: if p_type_code is null, then check the type_code of p_constraint_rev_id
2156 IF (p_type_code IS NULL) THEN
2157 OPEN c_constraint(p_constraint_rev_id);
2158 FETCH c_constraint INTO l_type_code;
2159 CLOSE c_constraint;
2160 END IF; -- end of if: _type_code IS NULL
2161
2162 IF (substr(l_type_code,1,4) = 'RESP') THEN
2163 --FND_FILE.put_line(fnd_file.log,'ID List for RESP '||L_API_NAME);
2164 -- for constriant type : Responsibility
2165 IF (BULK_COLLECTS_SUPPORTED) THEN
2166 -- enable dynamic sql in AMW.C with 5.10
2167 OPEN c_user_dynamic_sql FOR l_user_resp_cst_dynamic_sql USING
2168 p_constraint_rev_id;
2169 FETCH c_user_dynamic_sql BULK COLLECT INTO G_CST_USER_ID_LIST, G_CST_USER_NAME_LIST;
2170 CLOSE c_user_dynamic_sql;
2171 ELSE
2172 -- no BULK_COLLECTS_SUPPORTED
2173 i := 0;
2174 -- enable dynamic sql in AMW.C with 5.10
2175 OPEN c_user_dynamic_sql FOR l_user_resp_cst_dynamic_sql USING
2176 p_constraint_rev_id;
2177 LOOP
2178 FETCH c_user_dynamic_sql INTO l_user_id, l_user_name;
2179 EXIT WHEN c_user_dynamic_sql%NOTFOUND;
2180 i := i+1;
2181 G_CST_USER_ID_LIST(i) := l_user_id;
2182 G_CST_USER_NAME_LIST(i) := l_user_name;
2183 END LOOP;
2184 CLOSE c_user_dynamic_sql;
2185 END IF; -- end of if: BULK_COLLECTS_SUPPORTED
2186
2187 ELSE
2188 --FND_FILE.put_line(fnd_file.log,'ID List for FUNC '||L_API_NAME);
2189 -- for constriant type : Function
2190 IF (BULK_COLLECTS_SUPPORTED) THEN
2191 OPEN c_user_dynamic_sql FOR l_user_func_cst_dynamic_sql USING
2192 p_constraint_rev_id, p_constraint_rev_id, p_constraint_rev_id, p_constraint_rev_id;
2193 FETCH c_user_dynamic_sql BULK COLLECT INTO G_CST_USER_ID_LIST, G_CST_USER_NAME_LIST;
2197 i := 0;
2194 CLOSE c_user_dynamic_sql;
2195 ELSE
2196 -- no BULK_COLLECTS_SUPPORTED
2198 -- enable dynamic sql in AMW.C with 5.10
2199 OPEN c_user_dynamic_sql FOR l_user_func_cst_dynamic_sql USING
2200 p_constraint_rev_id, p_constraint_rev_id, p_constraint_rev_id, p_constraint_rev_id;
2201 LOOP
2202 FETCH c_user_dynamic_sql INTO l_user_id, l_user_name;
2203 EXIT WHEN c_user_dynamic_sql%NOTFOUND;
2204 i := i+1;
2205 G_CST_USER_ID_LIST(i) := l_user_id;
2206 G_CST_USER_NAME_LIST(i) := l_user_name;
2207 END LOOP;
2208 CLOSE c_user_dynamic_sql;
2209 END IF; -- end of if: BULK_COLLECTS_SUPPORTED
2210
2211 END IF; --end of if: substr(l_type_code,1,4) = 'RESP'
2212 --FND_FILE.put_line(fnd_file.log,'Came out '||L_API_NAME);
2213
2214 END Populate_User_Id_List_For_Cst;
2215
2216
2217 -- ===============================================================
2218 -- Procedure name
2219 -- Populate_User_Vio_For_Vlt
2220 -- Purpose
2221 -- populate the global user id list for one violation (G_CST_USER_ID_LIST)
2222 -- Params
2223 -- p_violation_id := specified violation_id
2224 -- p_constraint_rev_id := specified constraint_rev_id
2225 -- p_type_code := Specified Object_Type
2226
2227 -- Notes
2228 -- Revalidation only check violations for existing violators for
2229 -- specified violation_id
2230 --
2231 -- History
2232 -- 05.20.2005 tsho: create for AMW.E Revalidation
2233 -- ===============================================================
2234 Procedure Populate_User_Vio_For_Vlt(
2235 p_violation_id IN NUMBER,
2236 p_constraint_rev_id IN NUMBER := NULL,
2237 p_type_code IN VARCHAR2 := NULL
2238 )
2239 IS
2240 -- 01.06.2005 tsho: store the constraint type for this constraint
2241 l_type_code VARCHAR2(30) := p_type_code;
2242
2243 -- 01.06.2005 tsho: find the constraint by specified constraint_rev_id
2244 CURSOR c_constraint (l_constraint_rev_id IN NUMBER) IS
2245 SELECT type_code
2246 FROM amw_constraints_b
2247 WHERE constraint_rev_id=l_constraint_rev_id;
2248
2249 TYPE userVioCurTyp IS REF CURSOR;
2250 c_user_vio_dynamic_sql userVioCurTyp;
2251
2252 -- get the roles,user/global grants accessible by existing violators
2253 l_user_role_dynamic_sql VARCHAR2(4000) :=
2254 ' SELECT gra.grantee_key role_name, '
2255 ||' gra.menu_id, '
2256 ||' ce.function_id, '
2257 ||' min(urasgn.start_date), '
2258 ||' ( SELECT asgn.created_by '
2259 ||' FROM '||G_AMW_USER_ROLE_ASSIGNMENTS||' asgn '
2260 ||' WHERE asgn.user_name = usr.user_name '
2261 ||' AND asgn.role_name = role_name '
2262 ||' AND asgn.start_date = start_date '
2263 ||' AND rownum=1 '
2264 ||' ) created_by, '
2265 ||' ''FUNC'' entry_object_type, '
2266 ||' usr.user_id ,'
2267 ||' ce.group_code '
2268 ||' FROM '||G_AMW_GRANTS||' gra, '
2269 ||' '||G_AMW_COMPILED_MENU_FUNCTIONS||' cmf, '
2270 ||' AMW_CONSTRAINT_ENTRIES ce, '
2271 ||' '||G_AMW_USER_ROLE_ASSIGNMENTS||' urasgn, '
2272 ||' '||G_AMW_USER||' usr, '
2273 ||' AMW_VIOLATION_USERS vu '
2274 ||' WHERE urasgn.user_name = usr.user_name '
2275 ||' AND (gra.grantee_orig_system = ''UMX'' OR gra.grantee_orig_system = ''FND_RESP'') '
2276 ||' AND urasgn.role_name = gra.GRANTEE_KEY '
2277 ||' AND gra.menu_id = cmf.menu_id '
2278 ||' AND cmf.function_id = ce.function_id '
2279 ||' AND (ce.object_type is null OR ce.object_type = ''FUNC'') '
2280 ||' AND ce.CONSTRAINT_REV_ID = :1 '
2281 ||' AND gra.INSTANCE_TYPE = ''GLOBAL'' '
2282 ||' AND gra.OBJECT_ID = -1 '
2283 ||' AND gra.GRANTEE_TYPE = ''GROUP'' '
2284 ||' AND gra.start_date <= sysdate '
2285 ||' AND (gra.end_date >= sysdate or gra.end_date is null) '
2286 ||' AND urasgn.start_date <= sysdate '
2287 ||' AND (urasgn.end_date >= sysdate or urasgn.end_date is null) '
2288 ||' AND usr.start_date <= sysdate '
2289 ||' AND (usr.end_date >= sysdate or usr.end_date is null) '
2290 ||' AND vu.violation_id =:2 '
2291 ||' AND vu.violated_by_id = usr.user_id '
2292 ||' GROUP BY gra.grantee_key, gra.menu_id,ce.function_id,usr.user_name,usr.user_id, ce.group_code '
2293 ||' UNION ALL '
2294 ||' SELECT to_char(null) role_name, '
2295 ||' gra.menu_id, '
2296 ||' ce.function_id, '
2297 ||' gra.start_date, '
2298 ||' gra.created_by, '
2299 ||' ''FUNC'' entry_object_type, '
2300 ||' usr.user_id ,'
2301 ||' ce.group_code '
2302 ||' FROM '||G_AMW_GRANTS||' gra, '
2303 ||' '||G_AMW_COMPILED_MENU_FUNCTIONS||' cmf, '
2304 ||' AMW_CONSTRAINT_ENTRIES ce, '
2305 ||' '||G_AMW_USER||' usr , '
2306 ||' AMW_VIOLATION_USERS vu '
2307 ||' WHERE (( gra.GRANTEE_KEY = usr.user_name AND gra.GRANTEE_TYPE = ''USER'') '
2308 ||' OR (gra.GRANTEE_KEY = ''GLOBAL'' AND gra.GRANTEE_TYPE = ''GLOBAL'')) '
2309 ||' AND gra.menu_id = cmf.menu_id '
2310 ||' AND cmf.function_id = ce.function_id '
2311 ||' AND (ce.object_type is null OR ce.object_type = ''FUNC'') '
2315 ||' AND gra.start_date <= sysdate '
2312 ||' AND ce.CONSTRAINT_REV_ID = :3 '
2313 ||' AND gra.INSTANCE_TYPE = ''GLOBAL'' '
2314 ||' AND gra.OBJECT_ID = -1 '
2316 ||' AND (gra.end_date >= sysdate or gra.end_date is null) '
2317 ||' AND usr.start_date <= sysdate '
2318 ||' AND (usr.end_date >= sysdate or usr.end_date is null) '
2319 ||' AND vu.violation_id =:4 '
2320 ||' AND vu.violated_by_id = usr.user_id ';
2321
2322 -- Identify the responsibilities accessible by existing violators
2323 l_user_func_cst_dynamic_sql VARCHAR2(9000) :=
2324 ' SELECT usr.user_id, '
2325 ||' appl.application_id, '
2326 ||' ur.role_orig_system_id, '
2327 ||' min(urasgn.start_date) start_date, '
2328 ||' ( select asgn.created_by '
2329 ||' from WF_USER_ROLE_ASSIGNMENTS asgn '
2330 ||' where asgn.user_name = ur.user_name '
2331 ||' and asgn.role_name = ur.role_name '
2332 ||' and asgn.start_date = start_date '
2333 ||' and rownum=1 '
2334 ||' ) created_by, '
2335 ||' DECODE((select count(*) '
2336 ||' from amw_constraint_waivers_b '
2337 ||' where constraint_rev_id= :1 '
2338 ||' and object_type=''RESP'' '
2339 ||' and pk1 = ur.role_orig_system_id '
2340 ||' and pk2 = appl.application_id '
2341 ||' and start_date <= sysdate '
2342 ||' AND (end_date >= sysdate or end_date is null)),0,''N'',''Y'') waived_flag '
2343 ||' FROM WF_USER_ROLES ur, '
2344 ||' WF_USER_ROLE_ASSIGNMENTS urasgn, '
2345 ||' FND_USER usr, '
2346 ||' WF_LOCAL_ROLES rol, '
2347 ||' FND_APPLICATION_VL appl, '
2348 ||' FND_RESPONSIBILITY resp, '
2349 ||' FND_COMPILED_MENU_FUNCTIONS cmf, '
2350 ||' AMW_CONSTRAINT_ENTRIES ce , '
2351 ||' AMW_VIOLATION_USERS vu '
2352 ||' WHERE ce.CONSTRAINT_REV_ID = :2 '
2353 ||' AND (ce.object_type is null OR ce.object_type = ''FUNC'') '
2354 ||' AND cmf.menu_id = resp.menu_id '
2355 ||' AND cmf.grant_flag = ''Y'' '
2356 ||' AND cmf.function_id = ce.function_id '
2357 ||' AND resp.start_date <= sysdate '
2358 ||' AND (resp.end_date >= sysdate or resp.end_date is null) '
2359 ||' AND ur.role_orig_system_id = resp.responsibility_id '
2360 ||' AND ur.role_orig_system = ''FND_RESP'' '
2361 ||' AND ur.role_name = rol.name '
2362 ||' AND ur.role_orig_system = rol.orig_system '
2363 ||' AND ur.role_orig_system_id = rol.orig_system_id '
2364 ||' AND ur.partition_id = rol.partition_id '
2365 ||' AND rol.start_date<= sysdate '
2366 ||' AND (rol.expiration_date IS NULL OR rol.expiration_date>=sysdate) '
2367 ||' AND rol.owner_tag=appl.application_short_name '
2368 ||' AND resp.application_id=appl.application_id '
2369 ||' AND ur.user_name = urasgn.user_name '
2370 ||' AND ur.role_name = urasgn.role_name '
2371 ||' AND (ur.user_orig_system = ''FND_USR'' OR ur.user_orig_system = ''PER'') '
2372 ||' AND urasgn.start_date <= sysdate '
2373 ||' AND (urasgn.end_date >= sysdate or urasgn.end_date is null) '
2374 ||' AND ur.user_name=usr.user_name '
2375 ||' AND usr.start_date <= sysdate '
2376 ||' AND (usr.end_date >= sysdate or usr.end_date is null) '
2377 ||' AND vu.violation_id =:3 '
2378 ||' AND vu.violated_by_id = usr.user_id '
2379 ||' GROUP BY usr.user_id,ur.user_name,appl.application_id,ur.role_orig_system_id, ur.role_name '
2380 ||' UNION '
2381 ||' SELECT usr.user_id, '
2382 ||' appl.application_id, '
2383 ||' ur.role_orig_system_id, '
2384 ||' min(urasgn.start_date) start_date, '
2385 ||' ( select asgn.created_by '
2386 ||' from WF_USER_ROLE_ASSIGNMENTS asgn '
2387 ||' where asgn.user_name = ur.user_name '
2388 ||' and asgn.role_name = ur.role_name '
2389 ||' and asgn.start_date = start_date '
2390 ||' and rownum=1 '
2391 ||' ) created_by, '
2392 ||' DECODE((select count(*) '
2393 ||' from amw_constraint_waivers_b '
2394 ||' where constraint_rev_id= :4 '
2395 ||' and object_type=''RESP'' '
2396 ||' and pk1 = ur.role_orig_system_id '
2397 ||' and pk2 = appl.application_id '
2398 ||' and start_date <= sysdate '
2399 ||' AND (end_date >= sysdate or end_date is null)),0,''N'',''Y'') waived_flag '
2400 ||' FROM WF_USER_ROLES ur, '
2401 ||' WF_USER_ROLE_ASSIGNMENTS urasgn, '
2402 ||' FND_USER usr, '
2403 ||' WF_LOCAL_ROLES rol, '
2404 ||' FND_APPLICATION_VL appl, '
2405 ||' FND_RESPONSIBILITY RESP, '
2406 ||' FND_REQUEST_GROUP_UNITS RGU, '
2407 ||' AMW_CONSTRAINT_ENTRIES ACE , '
2408 ||' AMW_VIOLATION_USERS vu '
2409 ||' WHERE ACE.CONSTRAINT_REV_ID=:5 '
2410 ||' AND ACE.OBJECT_TYPE=''CP'' '
2411 ||' AND RESP.GROUP_APPLICATION_ID IS NOT NULL '
2412 ||' AND RESP.REQUEST_GROUP_ID IS NOT NULL '
2413 ||' AND RGU.APPLICATION_ID=RESP.GROUP_APPLICATION_ID '
2414 ||' AND RGU.REQUEST_GROUP_ID=RESP.REQUEST_GROUP_ID '
2415 ||' AND RGU.REQUEST_UNIT_TYPE = ''P'' '
2416 ||' AND RGU.UNIT_APPLICATION_ID=ACE.APPLICATION_ID '
2417 ||' AND RGU.REQUEST_UNIT_ID=ACE.FUNCTION_ID '
2418 ||' AND RESP.START_DATE<=SYSDATE '
2419 ||' AND (RESP.END_DATE>= SYSDATE or RESP.END_DATE IS NULL) '
2420 ||' AND ur.role_orig_system_id = resp.responsibility_id '
2424 ||' AND ur.role_orig_system_id = rol.orig_system_id '
2421 ||' AND ur.role_orig_system = ''FND_RESP'' '
2422 ||' AND ur.role_name = rol.name '
2423 ||' AND ur.role_orig_system = rol.orig_system '
2425 ||' AND ur.partition_id = rol.partition_id '
2426 ||' AND rol.start_date<= sysdate '
2427 ||' AND (rol.expiration_date IS NULL OR rol.expiration_date>=sysdate) '
2428 ||' AND rol.owner_tag = appl.application_short_name '
2429 ||' AND resp.application_id = appl.application_id '
2430 ||' AND ur.user_name = urasgn.user_name '
2431 ||' AND ur.role_name = urasgn.role_name '
2432 ||' AND urasgn.start_date <= sysdate '
2433 ||' AND (urasgn.end_date >= sysdate or urasgn.end_date is null) '
2434 ||' AND ur.user_name=usr.user_name '
2435 ||' AND usr.start_date <= sysdate '
2436 ||' AND (usr.end_date >= sysdate or usr.end_date is null) '
2437 ||' AND vu.violation_id =:6 '
2438 ||' AND vu.violated_by_id = usr.user_id '
2439 ||' GROUP BY usr.user_id,ur.user_name,appl.application_id,ur.role_orig_system_id, ur.role_name ';
2440
2441 -- Identify the responsibilities accessible by existing violators
2442 l_user_resp_dynamic_sql VARCHAR2(4000) :=
2443 ' SELECT usr.user_id, '
2444 ||' appl.application_id, '
2445 ||' ur.role_orig_system_id, '
2446 ||' min(urasgn.start_date) start_date, '
2447 ||' ( select asgn.created_by '
2448 ||' from '||G_AMW_USER_ROLE_ASSIGNMENTS||' asgn '
2449 ||' where asgn.user_name = ur.user_name '
2450 ||' and asgn.role_name = ur.role_name '
2451 ||' and asgn.start_date = start_date '
2452 ||' and rownum=1 '
2453 ||' ) created_by ,'
2454 ||' ce.group_code '
2455 ||' FROM WF_USER_ROLES ur, '
2456 ||' '||G_AMW_USER_ROLE_ASSIGNMENTS||' urasgn, '
2457 ||' '||G_AMW_USER||' usr, '
2458 ||' WF_LOCAL_ROLES rol, '
2459 ||' FND_APPLICATION_VL appl, '
2460 ||' '||G_AMW_RESPONSIBILITY||' resp, '
2461 ||' AMW_CONSTRAINT_ENTRIES ce , '
2462 ||' AMW_VIOLATION_USERS vu '
2463 ||' WHERE ce.CONSTRAINT_REV_ID = :1 '
2464 ||' AND ce.object_type = ''RESP'' '
2465 ||' AND ce.function_id = resp.responsibility_id '
2466 ||' AND ce.application_id = resp.application_id '
2467 ||' AND ur.role_orig_system_id = resp.responsibility_id '
2468 ||' AND ur.role_orig_system = ''FND_RESP'' '
2469 ||' AND ur.role_name = rol.name '
2470 ||' AND ur.role_orig_system = rol.orig_system '
2471 ||' AND ur.role_orig_system_id = rol.orig_system_id '
2472 ||' AND ur.partition_id = rol.partition_id '
2473 ||' AND rol.owner_tag = appl.application_short_name '
2474 ||' AND resp.application_id = appl.application_id '
2475 ||' AND ur.user_name = urasgn.user_name '
2476 ||' AND ur.role_name = urasgn.role_name '
2477 ||' AND ur.user_name = usr.user_name '
2478 ||' AND (ur.user_orig_system = ''FND_USR'' OR ur.user_orig_system = ''PER'') '
2479 ||' AND rol.start_date <= sysdate '
2480 ||' AND (rol.expiration_date IS NULL OR rol.expiration_date>=sysdate) '
2481 ||' AND vu.violation_id =:2 '
2482 ||' AND vu.violated_by_id = usr.user_id '
2483 ||' AND resp.start_date <= sysdate '
2484 ||' AND (resp.end_date >= sysdate OR resp.end_date IS NULL) '
2485 ||' AND urasgn.start_date <= sysdate '
2486 ||' AND (urasgn.end_date >= sysdate OR urasgn.end_date IS NULL) '
2487 ||' AND usr.start_date <= sysdate '
2488 ||' AND (usr.end_date >= sysdate OR usr.end_date IS NULL) '
2489 ||' GROUP BY usr.user_id,ur.user_name,appl.application_id,ur.role_orig_system_id, ur.role_name,ce.group_code ';
2490
2491 -- psomanat : 06:09:2006 : fix for bug 5256720
2492 L_USERVIO_ENTRIES G_USERVIO_ENTRIES_TABLE;
2493 L_FUNC_ID_LIST G_FUNCS_TABLE;
2494 L_RESP_ID_LIST G_RESPS_TABLE;
2495
2496 counts Number;
2497 listkey NUMBER(15);
2498 l_user_access_waived_resp_list G_VARCHAR2_TABLE;
2499
2500 L_RESPVIO_ENTRIES G_RESPVIO_ENTRIES_TABLE;
2501 L_RESP_FUNC_ID_LIST G_FUNC_TABLE;
2502 rListkey VARCHAR2(30) := NULL;
2503 flag BOOLEAN := TRUE;
2504 BEGIN
2505
2506 -- FND_FILE.put_line(fnd_file.log,'Populate_User_Vio_For_Vlt Began '||to_char(sysdate,'DD-MON-RRRR:HH24:MI:SS'));
2507
2508 IF (p_violation_id IS NULL) THEN
2509 RETURN;
2510 END IF;
2511
2512 IF (p_type_code IS NULL) THEN
2513 OPEN c_constraint(p_constraint_rev_id);
2514 FETCH c_constraint INTO l_type_code;
2515 CLOSE c_constraint;
2516 END IF; -- end of if: _type_code IS NULL
2517
2518 G_USER_VIOLATIONS_LIST.delete();
2519 G_USER_RESP_VIO_LIST.delete();
2520
2521 IF (substr(l_type_code,1,4) = 'RESP') THEN
2522
2523 -- Clearing the List
2524 G_CST_USER_ID_LIST.Delete();
2525 G_UPV_APPLICATION_ID_LIST.Delete();
2526 G_UPV_RESPONSIBILITY_ID_LIST.Delete();
2527 G_UPV_ACCESS_GIVEN_DATE_LIST.Delete();
2528 G_UPV_ACCESS_GIVEN_BY_LIST.Delete();
2529 G_UPV_GROUP_CODE_LIST.Delete();
2530
2531 OPEN c_user_vio_dynamic_sql FOR l_user_resp_dynamic_sql USING
2532 p_constraint_rev_id,p_violation_id;
2533 FETCH c_user_vio_dynamic_sql
2534 BULK COLLECT INTO G_CST_USER_ID_LIST,
2535 G_UPV_APPLICATION_ID_LIST,
2536 G_UPV_RESPONSIBILITY_ID_LIST,
2540 CLOSE c_user_vio_dynamic_sql;
2537 G_UPV_ACCESS_GIVEN_DATE_LIST,
2538 G_UPV_ACCESS_GIVEN_BY_LIST,
2539 G_UPV_GROUP_CODE_LIST;
2541
2542 -- A user can have n number of responsibilities associated to him
2543 -- We need to iterate over the G_UPV_XXXXXX_LIST to get the responsibilities
2544 -- assigned to the user.
2545 -- This will cause a performace issue
2546 -- So we store the G_UPV_XXXXXX_LIST nested tables data into a plsql data
2547 -- structure. The structure is like this
2548 -- User_id
2549 -- |______Responsibility_id
2550 -- |______Responsibility_id
2551 -- |______Responsibility_id
2552 --
2553
2554 IF (G_CST_USER_ID_LIST IS NOT NULL) AND (G_CST_USER_ID_LIST.FIRST IS NOT NULL) THEN
2555 FOR i in 1 .. G_CST_USER_ID_LIST.COUNT
2556 LOOP
2557 flag := TRUE;
2558 listkey :=G_CST_USER_ID_LIST(i);
2559 rListkey :=G_UPV_APPLICATION_ID_LIST(i)||'@'||G_UPV_RESPONSIBILITY_ID_LIST(i);
2560
2561 L_RESP_ID_LIST.delete();
2562 L_USERVIO_ENTRIES.delete();
2563
2564 IF (G_USER_RESP_VIO_LIST.EXISTS(listkey)) THEN
2565 L_RESP_ID_LIST := G_USER_RESP_VIO_LIST(listkey);
2566 IF L_RESP_ID_LIST.EXISTS(rListkey) THEN
2567 L_USERVIO_ENTRIES := L_RESP_ID_LIST(rListkey);
2568 FOR l IN L_USERVIO_ENTRIES.FIRST .. L_USERVIO_ENTRIES.LAST
2569 LOOP
2570 IF ( L_USERVIO_ENTRIES(l).application_id = G_UPV_APPLICATION_ID_LIST(i) AND
2571 L_USERVIO_ENTRIES(l).Responsibility_id = G_UPV_RESPONSIBILITY_ID_LIST(i)) THEN
2572 flag:=FALSE;
2573 END IF;
2574 END LOOP;
2575 END IF;
2576 END IF;
2577 IF (flag) THEN
2578 counts := L_USERVIO_ENTRIES.COUNT+1;
2579 L_USERVIO_ENTRIES(counts).User_id := G_CST_USER_ID_LIST(i);
2580 L_USERVIO_ENTRIES(counts).Access_Given_Date := G_UPV_ACCESS_GIVEN_DATE_LIST(i);
2581 L_USERVIO_ENTRIES(counts).Access_Given_By_Id := G_UPV_ACCESS_GIVEN_BY_LIST(i);
2582 L_USERVIO_ENTRIES(counts).application_id := G_UPV_APPLICATION_ID_LIST(i);
2583 L_USERVIO_ENTRIES(counts).Responsibility_id := G_UPV_RESPONSIBILITY_ID_LIST(i);
2584 L_USERVIO_ENTRIES(counts).group_code := G_UPV_GROUP_CODE_LIST(i);
2585 L_USERVIO_ENTRIES(counts).Waived := NUll;
2586 L_USERVIO_ENTRIES(counts).Role_Name := NUll;
2587 L_USERVIO_ENTRIES(counts).Menu_id := NUll;
2588 L_USERVIO_ENTRIES(counts).Function_Id := NUll;
2589 L_USERVIO_ENTRIES(counts).Object_Type := NUll;
2590 L_USERVIO_ENTRIES(counts).prog_appl_id := NUll;
2591 L_RESP_ID_LIST(rListkey) := L_USERVIO_ENTRIES;
2592 G_USER_RESP_VIO_LIST(listkey) := L_RESP_ID_LIST;
2593 END IF;
2594 END LOOP;
2595 END IF;
2596 -- Clearing the List
2597 G_CST_USER_ID_LIST.Delete();
2598 G_UPV_APPLICATION_ID_LIST.Delete();
2599 G_UPV_RESPONSIBILITY_ID_LIST.Delete();
2600 G_UPV_ACCESS_GIVEN_DATE_LIST.Delete();
2601 G_UPV_ACCESS_GIVEN_BY_LIST.Delete();
2602 G_UPV_GROUP_CODE_LIST.Delete();
2603 ELSE
2604 -- Clearing the list
2605 G_UPV_ROLE_NAME_LIST.delete();
2606 G_UPV_MENU_ID_LIST.delete();
2607 G_UPV_FUNCTION_ID_LIST.delete();
2608 G_UPV_ACCESS_GIVEN_DATE_LIST.delete();
2609 G_UPV_ACCESS_GIVEN_BY_LIST.delete();
2610 G_UPV_ENTRY_OBJECT_TYPE_LIST.delete();
2611 G_CST_USER_ID_LIST.delete();
2612 G_UPV_GROUP_CODE_LIST.delete();
2613
2614 -- A user can have n number of responsibilities associated to him
2615 -- We need to iterate over the G_UPV_XXXXXX_LIST to get the responsibilities
2616 -- assigned to the user. Then from the responsibility we need to
2617 -- get the incompatible functions accessible to the user.
2618 -- This will cause a performace issue
2619 -- So we store the G_UPV_XXXXXX_LIST nested tables and G_RESP_VIOLATIONS_LIST
2620 -- data into a plsql data structure.
2621 -- The structure is like this
2622 -- User_id
2623 -- |______Function_Id
2624 -- |______Function Detils group1
2625 -- |______Function Detils group2
2626 -- |______Function_Id
2627 -- |______Function Detils group1
2628 -- |______Function Detils group2
2629 -- |______Function_Id
2630 -- |______Function Detils group1
2631 -- |______Function Detils group2
2632 -- A function can be avilable in group 1 and group 2
2633 -- so we store both groups under function_id
2634
2635 -- First we get the user - roles,user - grants, global grants and
2636 -- populate the plsql data structure
2637 OPEN c_user_vio_dynamic_sql FOR l_user_role_dynamic_sql USING
2638 p_constraint_rev_id,
2639 p_violation_id,
2640 p_constraint_rev_id,
2644 G_UPV_MENU_ID_LIST,
2641 p_violation_id;
2642 FETCH c_user_vio_dynamic_sql
2643 BULK COLLECT INTO G_UPV_ROLE_NAME_LIST,
2645 G_UPV_FUNCTION_ID_LIST,
2646 G_UPV_ACCESS_GIVEN_DATE_LIST,
2647 G_UPV_ACCESS_GIVEN_BY_LIST,
2648 G_UPV_ENTRY_OBJECT_TYPE_LIST,
2649 G_CST_USER_ID_LIST,
2650 G_UPV_GROUP_CODE_LIST;
2651 CLOSE c_user_vio_dynamic_sql;
2652
2653 IF (G_CST_USER_ID_LIST IS NOT NULL) AND (G_CST_USER_ID_LIST.FIRST IS NOT NULL) THEN
2654 FOR i in 1 .. G_CST_USER_ID_LIST.COUNT
2655 LOOP
2656 flag := TRUE;
2657 L_FUNC_ID_LIST.delete();
2658 L_USERVIO_ENTRIES.delete();
2659
2660 listkey :=G_CST_USER_ID_LIST(i);
2661 IF (G_USER_VIOLATIONS_LIST.EXISTS(listkey)) THEN
2662 L_FUNC_ID_LIST := G_USER_VIOLATIONS_LIST(listkey);
2663 IF L_FUNC_ID_LIST.EXISTS(G_UPV_FUNCTION_ID_LIST(i)) THEN
2664 L_USERVIO_ENTRIES := L_FUNC_ID_LIST(G_UPV_FUNCTION_ID_LIST(i));
2665 FOR l IN L_USERVIO_ENTRIES.FIRST .. L_USERVIO_ENTRIES.LAST
2666 LOOP
2667 IF ( L_USERVIO_ENTRIES(l).Role_Name = G_UPV_ROLE_NAME_LIST(i) AND
2668 L_USERVIO_ENTRIES(l).Menu_id = G_UPV_MENU_ID_LIST(i) AND
2669 L_USERVIO_ENTRIES(l).Function_Id = G_UPV_FUNCTION_ID_LIST(i)) THEN
2670 flag:=FALSE;
2671 END IF;
2672 END LOOP;
2673 END IF;
2674 END IF;
2675 IF (flag) THEN
2676 counts := L_USERVIO_ENTRIES.COUNT+1;
2677 L_USERVIO_ENTRIES(counts).User_id := G_CST_USER_ID_LIST(i);
2678 L_USERVIO_ENTRIES(counts).Role_Name := G_UPV_ROLE_NAME_LIST(i);
2679 L_USERVIO_ENTRIES(counts).Menu_id := G_UPV_MENU_ID_LIST(i);
2680 L_USERVIO_ENTRIES(counts).Function_Id := G_UPV_FUNCTION_ID_LIST(i);
2681 L_USERVIO_ENTRIES(counts).Access_Given_Date := G_UPV_ACCESS_GIVEN_DATE_LIST(i);
2682 L_USERVIO_ENTRIES(counts).Access_Given_By_Id := G_UPV_ACCESS_GIVEN_BY_LIST(i);
2683 L_USERVIO_ENTRIES(counts).Object_Type := 'FUNC';
2684 L_USERVIO_ENTRIES(counts).Waived := 'N';
2685 L_USERVIO_ENTRIES(counts).group_code := G_UPV_GROUP_CODE_LIST(i);
2686 L_USERVIO_ENTRIES(counts).prog_appl_id := NULL;
2687 L_USERVIO_ENTRIES(counts).application_id := NULL;
2688 L_USERVIO_ENTRIES(counts).Responsibility_id := NULL;
2689 L_FUNC_ID_LIST(G_UPV_FUNCTION_ID_LIST(i)) := L_USERVIO_ENTRIES;
2690 G_USER_VIOLATIONS_LIST(listkey) := L_FUNC_ID_LIST;
2691 END IF;
2692 END lOOP;
2693 END IF;
2694 -- Clearing the list
2695 G_UPV_ROLE_NAME_LIST.delete();
2696 G_UPV_MENU_ID_LIST.delete();
2697 G_UPV_FUNCTION_ID_LIST.delete();
2698 G_UPV_ENTRY_OBJECT_TYPE_LIST.delete();
2699 G_CST_USER_ID_LIST.delete();
2700 G_UPV_APPLICATION_ID_LIST.delete();
2701 G_UPV_RESPONSIBILITY_ID_LIST.delete();
2702 G_UPV_ACCESS_GIVEN_DATE_LIST.delete();
2703 G_UPV_ACCESS_GIVEN_BY_LIST.delete();
2704 l_user_access_waived_resp_list.delete();
2705 G_UPV_GROUP_CODE_LIST.delete();
2706
2707 --Second User - responsbilities and populate the plsql data structure
2708 OPEN c_user_vio_dynamic_sql FOR l_user_func_cst_dynamic_sql USING
2709 p_constraint_rev_id,
2710 p_constraint_rev_id,
2711 p_violation_id,
2712 p_constraint_rev_id,
2713 p_constraint_rev_id,
2714 p_violation_id;
2715 FETCH c_user_vio_dynamic_sql
2716 BULK COLLECT INTO G_CST_USER_ID_LIST,
2717 G_UPV_APPLICATION_ID_LIST,
2718 G_UPV_RESPONSIBILITY_ID_LIST,
2719 G_UPV_ACCESS_GIVEN_DATE_LIST,
2720 G_UPV_ACCESS_GIVEN_BY_LIST,
2721 l_user_access_waived_resp_list;
2722 CLOSE c_user_vio_dynamic_sql;
2723
2724 IF (G_CST_USER_ID_LIST IS NOT NULL) AND (G_CST_USER_ID_LIST.FIRST IS NOT NULL) THEN
2725 FOR i in 1 .. G_CST_USER_ID_LIST.COUNT
2726 LOOP
2727 listkey :=G_CST_USER_ID_LIST(i);
2728 rListkey :=G_UPV_APPLICATION_ID_LIST(i)||'@'||G_UPV_RESPONSIBILITY_ID_LIST(i);
2729
2730 IF (G_RESP_VIOLATIONS_LIST.EXISTS(rListkey)) THEN
2731 L_RESP_FUNC_ID_LIST.delete();
2732 L_RESP_FUNC_ID_LIST := G_RESP_VIOLATIONS_LIST(rListkey);
2733 FOR j IN L_RESP_FUNC_ID_LIST.FIRST .. L_RESP_FUNC_ID_LIST.LAST
2734 LOOP
2735 IF L_RESP_FUNC_ID_LIST.EXISTS(j) THEN
2736 L_RESPVIO_ENTRIES.delete();
2737 L_RESPVIO_ENTRIES:=L_RESP_FUNC_ID_LIST(j);
2738 FOR k IN L_RESPVIO_ENTRIES.FIRST .. L_RESPVIO_ENTRIES.LAST
2739 LOOP
2740 flag := TRUE;
2741 L_FUNC_ID_LIST.delete();
2742 L_USERVIO_ENTRIES.delete();
2746 L_USERVIO_ENTRIES := L_FUNC_ID_LIST(L_RESPVIO_ENTRIES(k).Function_Id);
2743 IF (G_USER_VIOLATIONS_LIST.EXISTS(listkey)) THEN
2744 L_FUNC_ID_LIST := G_USER_VIOLATIONS_LIST(listkey);
2745 IF L_FUNC_ID_LIST.EXISTS(L_RESPVIO_ENTRIES(k).Function_Id) THEN
2747 FOR l IN L_USERVIO_ENTRIES.FIRST .. L_USERVIO_ENTRIES.LAST
2748 LOOP
2749 IF (L_USERVIO_ENTRIES(l).Object_Type = 'FUNC' AND
2750 L_RESPVIO_ENTRIES(k).Object_Type = 'FUNC' AND
2751 L_USERVIO_ENTRIES(l).application_id = L_RESPVIO_ENTRIES(k).application_id AND
2752 L_USERVIO_ENTRIES(l).Responsibility_id = L_RESPVIO_ENTRIES(k).Responsibility_id AND
2753 L_USERVIO_ENTRIES(l).Menu_id = L_RESPVIO_ENTRIES(k).Menu_id ) THEN
2754 flag:=FALSE;
2755 END IF;
2756
2757 IF (L_USERVIO_ENTRIES(l).Object_Type = 'CP' AND
2758 L_RESPVIO_ENTRIES(k).Object_Type = 'CP' AND
2759 L_USERVIO_ENTRIES(l).application_id = L_RESPVIO_ENTRIES(k).application_id AND
2760 L_USERVIO_ENTRIES(l).Responsibility_id = L_RESPVIO_ENTRIES(k).Responsibility_id AND
2761 L_USERVIO_ENTRIES(l).Menu_id = L_RESPVIO_ENTRIES(k).Menu_id AND
2762 L_USERVIO_ENTRIES(l).prog_appl_id = L_RESPVIO_ENTRIES(k).prog_appl_id ) THEN
2763 flag:=FALSE;
2764 END IF;
2765 END LOOP;
2766 END IF;
2767 END IF;
2768 IF (flag) THEN
2769 counts := L_USERVIO_ENTRIES.COUNT+1;
2770 L_USERVIO_ENTRIES(counts).User_id := G_CST_USER_ID_LIST(i);
2771 L_USERVIO_ENTRIES(counts).Role_Name := NUll;
2772 L_USERVIO_ENTRIES(counts).Menu_id := L_RESPVIO_ENTRIES(k).Menu_id;
2773 L_USERVIO_ENTRIES(counts).Function_Id := L_RESPVIO_ENTRIES(k).Function_Id;
2774 L_USERVIO_ENTRIES(counts).Access_Given_Date := G_UPV_ACCESS_GIVEN_DATE_LIST(i);
2775 L_USERVIO_ENTRIES(counts).Access_Given_By_Id := G_UPV_ACCESS_GIVEN_BY_LIST(i);
2776 L_USERVIO_ENTRIES(counts).Object_Type := L_RESPVIO_ENTRIES(k).Object_Type;
2777 L_USERVIO_ENTRIES(counts).prog_appl_id := L_RESPVIO_ENTRIES(k).prog_appl_id;
2778 L_USERVIO_ENTRIES(counts).application_id := L_RESPVIO_ENTRIES(k).application_id;
2779 L_USERVIO_ENTRIES(counts).Responsibility_id := L_RESPVIO_ENTRIES(k).Responsibility_id;
2780 L_USERVIO_ENTRIES(counts).group_code := L_RESPVIO_ENTRIES(k).group_code;
2781 L_USERVIO_ENTRIES(counts).Waived := l_user_access_waived_resp_list(i);
2782 L_FUNC_ID_LIST(L_RESPVIO_ENTRIES(k).Function_Id):= L_USERVIO_ENTRIES;
2783 G_USER_VIOLATIONS_LIST(listkey) := L_FUNC_ID_LIST;
2784 END IF;
2785 END LOOP;
2786 END IF;
2787 END LOOP;
2788 END IF;
2789 END lOOP;
2790 END IF;
2791 END IF;
2792 -- FND_FILE.put_line(fnd_file.log,'Populate_User_Vio_For_Vlt End '||to_char(sysdate,'DD-MON-RRRR:HH24:MI:SS'));
2793 END;
2794
2795
2796 -- ===============================================================
2797 -- Procedure name
2798 -- Populate_User_Id_List_For_Vlt
2799 -- Purpose
2800 -- populate the global user id list for one violation (G_CST_USER_ID_LIST)
2801 -- Params
2802 -- p_violation_id := specified violation_id
2803 -- p_constraint_rev_id := specified constraint_rev_id
2804 -- Notes
2805 -- Revalidation only check violations for existing violators for specified violation_id
2806 --
2807 -- History
2808 -- 05.20.2005 tsho: create for AMW.E Revalidation
2809 -- 06.30.2006 psomanat: Method Depricated. Use Populate_User_Vio_For_Vlt
2810 -- ===============================================================
2811 Procedure Populate_User_Id_List_For_Vlt(
2812 p_violation_id IN NUMBER,
2813 p_constraint_rev_id IN NUMBER := NULL
2814 )
2815 IS
2816
2817 i NUMBER;
2818 l_user_id NUMBER;
2819 l_user_name VARCHAR2(320);
2820
2821 TYPE userCurTyp IS REF CURSOR;
2822 c_user_dynamic_sql userCurTyp;
2823
2824 l_user_reval_dynamic_sql VARCHAR2(200) :=
2825 'SELECT u.user_id, u.user_name '
2826 ||' FROM AMW_VIOLATION_USERS vu '
2827 ||' ,'||G_AMW_USER||' u '
2828 ||' WHERE vu.violation_id = :1 '
2829 ||' AND vu.violated_by_id = u.user_id ';
2830
2831 BEGIN
2832 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
2833
2834 -- fix for performance bug 4036679, G_USER_ID_LIST is valid for one constraint
2838 G_CST_USER_NAME_LIST.DELETE();
2835 G_CST_USER_ID_LIST.DELETE();
2836
2837 --05.17.2005 tsho: starting from AMW.E, store user_name in addition to user_id for use in G_AMW_USER_ROLES
2839
2840 IF (p_violation_id IS NOT NULL) THEN
2841 IF (BULK_COLLECTS_SUPPORTED) THEN
2842 OPEN c_user_dynamic_sql FOR l_user_reval_dynamic_sql USING
2843 p_violation_id;
2844 FETCH c_user_dynamic_sql BULK COLLECT INTO G_CST_USER_ID_LIST, G_CST_USER_NAME_LIST;
2845 CLOSE c_user_dynamic_sql;
2846 ELSE
2847 -- no BULK_COLLECTS_SUPPORTED
2848 i := 0;
2849 -- enable dynamic sql in AMW.C with 5.10
2850 OPEN c_user_dynamic_sql FOR l_user_reval_dynamic_sql USING
2851 p_violation_id;
2852 LOOP
2853 FETCH c_user_dynamic_sql INTO l_user_id, l_user_name;
2854 EXIT WHEN c_user_dynamic_sql%NOTFOUND;
2855 i := i+1;
2856 G_CST_USER_ID_LIST(i) := l_user_id;
2857 G_CST_USER_NAME_LIST(i) := l_user_name;
2858 END LOOP;
2859 CLOSE c_user_dynamic_sql;
2860 END IF; -- end of if: BULK_COLLECTS_SUPPORTED
2861 END IF; -- end of if: p_violation_id IS NOT NULL
2862
2863 END Populate_User_Id_List_For_Vlt;
2864
2865
2866
2867 -- ===============================================================
2868 -- Private Function name
2869 -- Create_Violation
2870 --
2871 -- Purpose
2872 -- create violation in AMW_VIOLATIONS
2873 -- against specified constraint
2874 --
2875 -- Params
2876 -- p_constraint_rev_id := specified constraint_rev_id
2877 --
2878 -- Notes
2879 --
2880 -- ===============================================================
2881 FUNCTION Create_Violation (
2882 p_constraint_rev_id IN NUMBER
2883 ) RETURN NUMBER
2884 IS
2885
2886 L_API_NAME CONSTANT VARCHAR2(30) := 'Create_Violation';
2887 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
2888
2889 -- store the violation_id getting from AMW_VIOLATION_S
2890 l_violation_id NUMBER := NULL;
2891 l_row_id VARCHAR2(32767); -- 11.17.2003 tsho: need to check out
2892
2893 -- store the request_id getting from FND_GLOBAL
2894 l_request_id NUMBER := FND_GLOBAL.CONC_REQUEST_ID;
2895
2896 -- get violation_id from AMW_VIOLATION_S
2897 CURSOR c_violation_id IS
2898 SELECT AMW_VIOLATION_S.NEXTVAL
2899 FROM dual;
2900
2901 BEGIN
2902 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
2903
2904 -- get violation_id from AMW_VIOLATION_S
2905 OPEN c_violation_id;
2906 FETCH c_violation_id INTO l_violation_id;
2907 CLOSE c_violation_id;
2908
2909 AMW_VIOLATIONS_PKG.insert_row(x_rowid => l_row_id,
2910 x_violation_id => l_violation_id,
2911 x_constraint_rev_id => p_constraint_rev_id,
2912 x_request_id => l_request_id,
2913 x_request_date => SYSDATE,
2914 x_requested_by_id => G_PARTY_ID,
2915 x_violator_num => NULL,
2916 x_status_code => 'NA',
2917 x_last_updated_by => G_USER_ID,
2918 x_last_update_date => SYSDATE,
2919 x_created_by => G_USER_ID,
2920 x_creation_date => SYSDATE,
2921 x_last_update_login => G_LOGIN_ID,
2922 x_security_group_id => G_SECURITY_GROUP_ID,
2923 x_object_version_number => 1);
2924
2925 --FND_FILE.put_line(fnd_file.log,'AMW_VIOLATIONS_PKG.insert_row: l_violation_id= '||l_violation_id);
2926
2927 RETURN l_violation_id;
2928 END Create_Violation;
2929
2930
2931
2932 -- ===============================================================
2933 -- Private Procedure name
2934 -- Update_Violation
2935 --
2936 -- Purpose
2937 -- update violation in AMW_VIOLATIONS
2938 -- against specified violation_id and its constraint_rev_id
2939 --
2940 -- Params
2941 -- p_violation_id := specified violation_id
2942 -- p_constraint_rev_id := specified constraint_rev_id
2943 --
2944 -- Notes
2945 -- this is to update the violator_num, status_code in AMW_VIOLATIONS
2946 -- based on the conclusion from AMW_VIOLATION_USERS
2947 --
2948 -- History
2949 -- 01.06.2005 tsho: starting from AMW.D, consider Waivers
2950 -- 05.20.2005 tsho: starting from AMW.E, consider Revalidation
2951 -- ===============================================================
2952 PROCEDURE Update_Violation (
2953 p_violation_id IN NUMBER,
2954 p_constraint_rev_id IN NUMBER,
2955 p_revalidate_flag IN VARCHAR2 := NULL
2956 )
2957 IS
2958
2959 L_API_NAME CONSTANT VARCHAR2(30) := 'Update_Violation';
2960 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
2961
2962 -- store the violator_num
2963 l_violator_num NUMBER := NULL;
2964 l_violator_num_aft_reval NUMBER := NULL;
2965 l_resp_violation_num NUMBER := NULL;
2966
2967 -- store the violation status (status_code), default is 'NA' (Not Applicable)
2971 l_reval_requested_by_id NUMBER := NULL;
2968 l_violation_status VARCHAR2(30) := 'NA';
2969 l_reval_request_id NUMBER := NULL;
2970 l_reval_request_date DATE := NULL;
2972
2973
2974
2975 -- 05.20.2005 tsho: store the request_id getting from FND_GLOBAL
2976 l_request_id NUMBER := FND_GLOBAL.CONC_REQUEST_ID;
2977
2978 -- get violator_num from AMW_VIOLATION_USERS
2979 -- 01.06.2005 tsho: starting from AMW.D, consider waivers
2980 CURSOR c_violator_num (l_violation_id IN NUMBER) IS
2981 SELECT count(*)
2982 FROM amw_violation_users
2983 WHERE violation_id = l_violation_id
2984 AND (waived_flag is NULL OR waived_flag <> 'Y');
2985
2986 -- 05.20.2005 tsho: get the num of violators after revalidating this violation
2987 CURSOR c_violator_num_aft_reval (l_violation_id IN NUMBER) IS
2988 SELECT count(*)
2989 FROM amw_violation_users
2990 WHERE violation_id = l_violation_id
2991 AND (waived_flag is NULL OR waived_flag <> 'Y')
2992 AND (corrected_flag is NULL OR corrected_flag <> 'Y');
2993
2994 CURSOR c_resp_violation_num (l_violation_id IN NUMBER) IS
2995 SELECT count(*)
2996 FROM amw_violation_resp
2997 WHERE violation_id = l_violation_id
2998 AND waived_flag = 'N'
2999 AND corrected_flag = 'N';
3000
3001 BEGIN
3002 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
3003
3004 OPEN c_violator_num(p_violation_id);
3005 FETCH c_violator_num INTO l_violator_num;
3006 CLOSE c_violator_num;
3007
3008 --05.20.2005 tsho: get the num of violators after revalidation
3009 OPEN c_violator_num_aft_reval(p_violation_id);
3010 FETCH c_violator_num_aft_reval INTO l_violator_num_aft_reval;
3011 CLOSE c_violator_num_aft_reval;
3012
3013 OPEN c_resp_violation_num(p_violation_id);
3014 FETCH c_resp_violation_num INTO l_resp_violation_num;
3015 CLOSE c_resp_violation_num;
3016 -- decide violation status based on violator_num
3017 -- if no violator, status_code is 'C' (Closed),
3018 -- if has violators when first running the check, status_code is 'O' (Open)
3019 -- if has violators when revalidating the violation, status_code is 'R' (Revalidated)
3020 IF (l_violator_num = 0 OR l_violator_num_aft_reval = 0) AND l_resp_violation_num = 0 THEN
3021 l_violation_status := 'C';
3022 ELSIF ( p_revalidate_flag IS NOT NULL
3023 AND p_revalidate_flag = 'Y'
3024 AND (l_violator_num_aft_reval > 0 or l_resp_violation_num > 0) ) THEN
3025 l_violation_status := 'R';
3026 ELSE
3027 l_violation_status := 'O';
3028 END IF;
3029
3030 -- 06.27.2005 tsho: only update reval columns if revalidate_flag is 'Y'
3031 IF (p_revalidate_flag = 'Y') THEN
3032 l_reval_request_id := l_request_id;
3033 l_reval_request_date := SYSDATE;
3034 l_reval_requested_by_id := G_PARTY_ID;
3035 END IF;
3036
3037 AMW_VIOLATIONS_PKG.update_row(x_violation_id => p_violation_id,
3038 x_constraint_rev_id => p_constraint_rev_id,
3039 x_violator_num => l_violator_num,
3040 x_status_code => l_violation_status,
3041 x_last_updated_by => G_USER_ID,
3042 x_last_update_date => SYSDATE,
3043 x_last_update_login => G_LOGIN_ID,
3044 x_security_group_id => G_SECURITY_GROUP_ID,
3045 x_object_version_number => 1,
3046 x_reval_request_id => l_reval_request_id, -- 05.20.2005 tsho: AMW.E revalidation
3047 x_reval_request_date => l_reval_request_date, -- 05.20.2005 tsho: AMW.E revalidation
3048 x_reval_requested_by_id => l_reval_requested_by_id -- 05.20.2005 tsho: AMW.E revalidation
3049 );
3050
3051 END Update_Violation;
3052
3053
3054 -- ===============================================================
3055 -- Private Procedure name
3056 -- Update_Violation_User
3057 --
3058 -- Purpose
3059 -- update user in AMW_VIOLATION_USERS
3060 -- against specified violation_id and violated_by_id
3061 --
3062 -- Params
3063 -- p_user_violation_id := specified user_violation_id
3064 -- p_violation_id := specified violation_id
3065 -- p_violated_by_id := specified violated_by_id
3066 -- p_corrected_flag := specified corrected_flag
3067 --
3068 -- Notes
3069 -- this is to update the corrected_flag in AMW_VIOLATION_USERS
3070 --
3071 -- History
3072 -- 05.23.2005 tsho: create for AMW.E Revalidation
3073 -- ===============================================================
3074 PROCEDURE Update_Violation_User (
3075 p_user_violation_id IN NUMBER := NULL,
3076 p_violation_id IN NUMBER,
3077 p_violated_by_id IN NUMBER,
3078 p_corrected_flag IN VARCHAR2 := NULL
3079 )
3080 IS
3081
3082 L_API_NAME CONSTANT VARCHAR2(30) := 'Update_Violation_User';
3083 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
3084
3085 -- store the user_violation_id
3086 l_user_violation_id NUMBER := NULL;
3087
3088 -- get user_violation_id from AMW_VIOLATION_USERS
3089 CURSOR c_user_violation_id (l_violation_id IN NUMBER, l_violated_by_id IN NUMBER) IS
3093 AND violated_by_id = l_violated_by_id;
3090 SELECT user_violation_id
3091 FROM amw_violation_users
3092 WHERE violation_id = l_violation_id
3094
3095 BEGIN
3096 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
3097
3098 IF (p_user_violation_id IS NULL) THEN
3099 BEGIN
3100 -- get user_violation_id from AMW_VIOLATION_USERS if not specified
3101 OPEN c_user_violation_id(p_violation_id, p_violated_by_id);
3102 FETCH c_user_violation_id INTO l_user_violation_id;
3103 CLOSE c_user_violation_id;
3104
3105 EXCEPTION
3106 WHEN no_data_found THEN
3107 IF c_user_violation_id%ISOPEN THEN
3108 CLOSE c_user_violation_id;
3109 END IF;
3110 --FND_FILE.put_line(fnd_file.log,'Error in cursor c_user_violation_id'||substr(SQLERRM, 1, 200));
3111 return;
3112 END;
3113 END IF;
3114
3115 AMW_VIOLATION_USERS_PKG.UPDATE_ROW (
3116 x_user_violation_id => l_user_violation_id,
3117 x_violation_id => p_violation_id,
3118 x_violated_by_id => p_violated_by_id,
3119 x_last_updated_by => G_USER_ID,
3120 x_last_update_date => SYSDATE,
3121 x_last_update_login => G_USER_ID,
3122 x_security_group_id => G_SECURITY_GROUP_ID,
3123 x_waived_flag => null,
3124 x_corrected_flag => p_corrected_flag);
3125 DELETE FROM AMW_VIOLAT_USER_ENTRIES
3126 WHERE USER_VIOLATION_ID=l_user_violation_id;
3127
3128 --FND_FILE.put_line(fnd_file.log,'Came out'||L_API_NAME);
3129 END Update_Violation_User;
3130
3131
3132 -- ===============================================================
3133 -- Private Procedure name
3134 -- Write_To_Table
3135 --
3136 -- Purpose
3137 -- Write global potential violation of specified user
3138 -- against specified constraint
3139 --
3140 -- Params
3141 -- p_constraint_rev_id := specified constraint_rev_id
3142 -- p_user_id := specified user_id
3143 --
3144 -- Notes
3145 -- when calling this procedure means it's gaurantee
3146 -- the specified user has violated the specified constraint
3147 --
3148 -- 01.10.2005 tsho: Deprecated,
3149 -- use Write_Func_To_Table_For_User or Write_Resp_To_Table_For_User instead
3150 -- History
3151 -- 05.17.2005 tsho: starting from AMW.E, add column: ROLE_NAME to AMW_VIOLAT_USER_ENTRIES
3152 -- ===============================================================
3153 Procedure Write_To_Table (
3154 p_violation_id IN NUMBER,
3155 p_constraint_rev_id IN NUMBER,
3156 p_user_id IN NUMBER
3157 )
3158 IS
3159
3160 L_API_NAME CONSTANT VARCHAR2(30) := 'Write_To_Table';
3161 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
3162
3163 i NUMBER;
3164 l_party_id NUMBER;
3165
3166 -- store the user_violation_id getting from AMW_USER_VIOLATION_S
3167 l_user_violation_id NUMBER;
3168 l_row_id VARCHAR2(32767); -- 11.17.2003 tsho: need to check out
3169
3170 -- get user_violation_id from AMW_USER_VIOLATION_S
3171 CURSOR c_user_violation_id IS
3172 SELECT AMW_USER_VIOLATION_S.NEXTVAL
3173 FROM dual;
3174
3175
3176
3177 -- find party_id with specified user_id
3178 -- 12.12.2003 tsho: use static sql for AMW for the time being
3179 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10, but due to bug 3348191, still comment this out
3180 /*
3181 TYPE userCurTyp IS REF CURSOR;
3182 c_user_dynamic_sql userCurTyp;
3183 l_user_dynamic_sql VARCHAR2(200) :=
3184 'SELECT person_party_id '
3185 ||' FROM '||G_AMW_USER
3186 ||' WHERE user_id = :1 ';
3187 */
3188
3189 BEGIN
3190 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
3191
3192 -- find party_id with specified user_id
3193 BEGIN
3194 -- 12.12.2003 tsho: use static sql for AMW for the time being
3195 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10, but due to bug 3348191, still comment this out
3196 /*
3197 OPEN c_user_dynamic_sql FOR l_user_dynamic_sql USING
3198 p_user_id;
3199 FETCH c_user_dynamic_sql INTO l_party_id;
3200 CLOSE c_user_dynamic_sql;
3201 */
3202 -- 01.02.2003 tsho: bug 3348191 - duplicated user shown
3203 -- because same party_id(person) maps to multiple user_id(login acct),
3204 -- thus store user_id directly rather party_id in AMW_VIOLATION_USERS
3205 /*
3206 SELECT person_party_id
3207 INTO l_party_id
3208 FROM FND_USER
3209 WHERE user_id = p_user_id;
3210 */
3211 l_party_id := p_user_id;
3212
3213 EXCEPTION
3214 WHEN no_data_found THEN
3215 null;
3216 END;
3217
3218 IF ((G_PV_FUNCTION_ID_LIST IS NULL) OR (G_PV_FUNCTION_ID_LIST.FIRST IS NULL)) THEN
3219 -- no potential violation for this user against this constraint
3220 -- don't create a record in AMW_VIOLATION_USERS
3221 RETURN;
3222 END IF;
3223
3224 -- get user_violation_id from AMW_USER_VIOLATION_S
3225 OPEN c_user_violation_id;
3226 FETCH c_user_violation_id INTO l_user_violation_id;
3227 CLOSE c_user_violation_id;
3228
3232 x_violated_by_id => l_party_id,
3229 AMW_VIOLATION_USERS_PKG.insert_row(x_rowid => l_row_id,
3230 x_user_violation_id => l_user_violation_id,
3231 x_violation_id => p_violation_id,
3233 x_last_updated_by => G_USER_ID,
3234 x_last_update_date => SYSDATE,
3235 x_created_by => G_USER_ID,
3236 x_creation_date => SYSDATE,
3237 x_last_update_login => G_LOGIN_ID,
3238 x_security_group_id => NULL);
3239
3240 --FND_FILE.put_line(fnd_file.log,'AMW_VIOLATION_USERS_PKG.insert_row: l_user_violation_id= '|| l_user_violation_id);
3241
3242 -- bulk insert to AMW_VIOLAT_USER_ENTRIES
3243 FORALL i IN 1 .. G_PV_FUNCTION_ID_LIST.COUNT
3244 INSERT INTO AMW_VIOLAT_USER_ENTRIES VALUES (
3245 SYSDATE, -- last_update_date
3246 G_USER_ID, -- last_updated_by
3247 G_LOGIN_ID, -- last_update_login
3248 SYSDATE, -- creation_date
3249 G_USER_ID, -- created_by
3250 NULL, -- security_group_id
3251 l_user_violation_id, -- user_violation_id
3252 G_PV_RESPONSIBILITY_ID_LIST(i), -- responsibility_id
3253 G_PV_MENU_ID_LIST(i), -- menu_id
3254 G_PV_FUNCTION_ID_LIST(i), -- function_id
3255 G_PV_ACCESS_GIVEN_DATE_LIST(i), -- access_given_date
3256 G_PV_ACCESS_GIVEN_BY_LIST(i), -- access_given_by_id
3257 NULL, -- role_name
3258 NULL, -- object_type
3259 G_PV_APPLICATION_ID_LIST(i), -- application_id
3260 null);
3261
3262
3263 END Write_To_Table;
3264
3265
3266
3267 -- ===============================================================
3268 -- Private Procedure name
3269 -- Clear_Potential_Value_List
3270 --
3271 -- Purpose
3272 -- to clear the global potential value list:
3273 -- G_PV_FUNCTION_ID_LIST
3274 -- G_PV_MENU_ID_LIST
3275 -- G_PV_RESPONSIBILITY_ID_LIST
3276 -- G_PV_ACCESS_GIVEN_DATE_LIST
3277 -- G_PV_ACCESS_GIVEN_BY_LIST
3278 --
3279 -- ===============================================================
3280 PROCEDURE Clear_Potential_Value_List
3281 IS
3282
3283 L_API_NAME CONSTANT VARCHAR2(30) := 'Clear_Potential_Value_List';
3284 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
3285
3286 BEGIN
3287 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
3288 G_PV_COUNT := 1;
3289 G_PV_FUNCTION_ID_LIST.DELETE();
3290 G_PV_MENU_ID_LIST.DELETE();
3291 G_PV_RESPONSIBILITY_ID_LIST.DELETE();
3292 G_PV_APPLICATION_ID_LIST.DELETE();
3293 G_PV_ACCESS_GIVEN_DATE_LIST.DELETE();
3294 G_PV_ACCESS_GIVEN_BY_LIST.DELETE();
3295 G_PV_GROUP_CODE_LIST.DELETE();
3296 G_PV_PROGRAM_APPL_ID_LIST.DELETE();
3297 G_PV_OBJECT_TYPE_LIST.DELETE();
3298
3299 END Clear_Potential_Value_List;
3300
3301
3302 -- ===============================================================
3303 -- Private Procedure name
3304 -- Clear_User_Potential_Value_List
3305 --
3306 -- Purpose
3307 -- to clear the global potential value list:
3308 -- G_UPV_FUNCTION_ID_LIST
3309 -- G_UPV_MENU_ID_LIST
3310 -- G_UPV_RESPONSIBILITY_ID_LIST
3311 -- G_UPV_ACCESS_GIVEN_DATE_LIST
3312 -- G_UPV_ACCESS_GIVEN_BY_LIST
3313 -- G_UPV_ROLE_NAME_LIST
3314 -- G_UPV_GROUP_CODE_LIST
3315 -- G_UPV_ENTRY_OBJECT_TYPE_LIST
3316 --
3317 -- History
3318 -- 05.17.2005 tsho: starting from AMW.E, add handle for G_UPV_ROLE_NAME_LIST, G_UPV_GROUP_CODE_LIST
3319 -- 05.25.2005 tsho: add handle for G_UPV_ENTRY_OBJECT_TYPE_LIST (consider Concurrent Programs as constraint entries)
3320 -- ===============================================================
3321 PROCEDURE Clear_Usr_Potential_Value_List
3322 IS
3323
3324 L_API_NAME CONSTANT VARCHAR2(30) := 'Clear_Usr_Potential_Value_List';
3325 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
3326
3327 BEGIN
3328 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
3329
3330 G_UPV_COUNT := 1;
3331 G_UPV_FUNCTION_ID_LIST.DELETE();
3332 G_UPV_MENU_ID_LIST.DELETE();
3333 G_UPV_RESPONSIBILITY_ID_LIST.DELETE();
3334 G_UPV_APPLICATION_ID_LIST.DELETE();
3335 G_UPV_PROGRAM_APPL_ID_LIST.delete();
3336 G_UPV_ACCESS_GIVEN_DATE_LIST.DELETE();
3337 G_UPV_ACCESS_GIVEN_BY_LIST.DELETE();
3338 G_UPV_ROLE_NAME_LIST.DELETE();
3339 G_UPV_GROUP_CODE_LIST.DELETE();
3340 G_UPV_ENTRY_OBJECT_TYPE_LIST.DELETE();
3341
3342 END Clear_Usr_Potential_Value_List;
3343
3344
3348 -- Check_For_Constraint_ALL
3345
3346 -- ===============================================================
3347 -- Private Procedure name
3349 --
3350 -- Purpose
3351 -- for constraint type = 'ALL or None' (type_code = 'ALL')
3352 -- check violation for specified constraint
3353 -- this is private procedure,
3354 -- should not call this procedure directly
3355 --
3356 -- Params
3357 -- p_constraint_rev_id := specified constraint_rev_id
3358 --
3359 -- Notes
3360 -- 01.10.2005 tsho: Deprecated, use Check_For_Func_Cst_ALL instead
3361 -- ===============================================================
3362 PROCEDURE Check_For_Constraint_ALL (
3363 p_constraint_rev_id IN NUMBER,
3364 p_violation_id IN NUMBER
3365 )
3366 IS
3367
3368 L_API_NAME CONSTANT VARCHAR2(30) := 'Check_For_Constraint_ALL';
3369 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
3370
3371
3372 -- store the tmp count for g_user_id_list
3373 i NUMBER;
3374
3375 -- store the tmp count for l_functions
3376 j NUMBER;
3377
3378 -- store the tmp count for l_functions
3379 k NUMBER;
3380
3381 -- store the tmp count for l_user_resp_id_list
3382 m NUMBER;
3383
3384 -- store the test_id result
3385 l_test_id_result BOOLEAN;
3386
3387 -- store the access right
3388 l_accessible BOOLEAN;
3389
3390 -- store how many incompatible functions he can access so far
3391 l_access_function_count NUMBER;
3392
3393
3394 TYPE NumberTable IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
3395 TYPE DateTable IS TABLE OF DATE INDEX BY BINARY_INTEGER;
3396
3397 -- find the constraint entries(incompatible functions) by specified constraint_rev_id
3398 l_function_id_list NumberTable;
3399 l_constraint_function_id NUMBER;
3400 CURSOR c_constraint_entries (l_constraint_rev_id IN NUMBER) IS
3401 SELECT function_id
3402 FROM amw_constraint_entries
3403 WHERE constraint_rev_id=l_constraint_rev_id;
3404
3405
3406 -- find the responsibilities by specified user_id
3407 l_user_resp_id_list NumberTable;
3408 l_user_resp_id NUMBER;
3409
3410 -- find the responsibility app ids by specified user_id
3411 l_user_resp_app_id_list NumberTable;
3412 l_user_resp_app_id NUMBER;
3413
3414 -- find the access_given_dates (start_date from G_AMW_USER_RESP_GROUPS) by specified user_id
3415 l_user_resp_start_date_list DateTable;
3416 l_user_resp_start_date DATE;
3417
3418 -- find the access_given_by ids (created_by from G_AMW_USER_RESP_GROUPS) by specified user_id
3419 l_user_resp_created_by_list NumberTable;
3420 l_user_resp_created_by NUMBER;
3421
3422 -- 12.12.2003 tsho: use static sql for AMW for the time being
3423 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
3424 TYPE respCurTyp IS REF CURSOR;
3425 user_resp_c respCurTyp;
3426 -- 04.07.2005 tsho: bug 4145922, cosider hierarchical role assignment
3427 /*
3428 l_user_resp_dynamic_sql VARCHAR2(200) :=
3429 'SELECT responsibility_id, responsibility_application_id, start_date, created_by '
3430 ||' FROM '||G_AMW_USER_RESP_GROUPS
3431 ||' WHERE user_id = :1 and (end_date >= sysdate or end_date is null)';
3432 */
3433 l_user_resp_dynamic_sql VARCHAR2(2000) :=
3434 'SELECT outer.responsibility_id, outer.responsibility_application_id, outer.start_date, outer.created_by '
3435 ||' FROM '||G_AMW_USER_RESP_GROUPS ||' outer '
3436 ||' WHERE outer.start_date = ('
3437 ||' SELECT min(innter.start_date) '
3438 ||' FROM '||G_AMW_USER_RESP_GROUPS ||' inner '
3439 ||' WHERE inner.user_id = :1 '
3440 ||' AND inner.responsibility_id = outer.responsibility_id '
3441 ||' AND inner.responsibility_application_id = outer.responsibility_application_id '
3442 ||' AND inner.start_date <= sysdate AND (inner.end_date >= sysdate or inner.end_date is null) '
3443 ||' )';
3444 /*
3445 cursor get_user_resp_c(l_user_id IN NUMBER) is
3446 SELECT responsibility_id,
3447 responsibility_application_id,
3448 start_date,
3449 created_by
3450 from FND_USER_RESP_GROUPS
3451 where user_id = l_user_id
3452 and (end_date >= sysdate or end_date is null);
3453 */
3454
3455 BEGIN
3456 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
3457
3458 -- if no users in g_user_id_list, then no need to go further to check constraint
3459 IF ((G_USER_ID_LIST IS NULL) OR (G_USER_ID_LIST.FIRST IS NULL)) THEN
3460 RETURN;
3461 END IF;
3462
3463
3464 IF (p_constraint_rev_id IS NOT NULL) THEN
3465 -- find the constraint entries(incompatible functions) by specified constraint_rev_id
3466 IF (BULK_COLLECTS_SUPPORTED) THEN
3467 OPEN c_constraint_entries (p_constraint_rev_id);
3468 FETCH c_constraint_entries BULK COLLECT INTO l_function_id_list;
3469 CLOSE c_constraint_entries;
3470 ELSE
3471 -- no BULK_COLLECTS_SUPPORTED
3472 j := 0;
3473 OPEN c_constraint_entries (p_constraint_rev_id);
3474 LOOP
3475 FETCH c_constraint_entries INTO l_constraint_function_id;
3476 EXIT WHEN c_constraint_entries%NOTFOUND;
3477 j := j+1;
3478 l_function_id_list(j) := l_constraint_function_id;
3479 END LOOP;
3483
3480 CLOSE c_constraint_entries;
3481 END IF; -- end of if: BULK_COLLECTS_SUPPORTED
3482
3484 -- passed-in p_constraint_rev_id doesn't have at least 2 incompatible functions defined
3485 IF (l_function_id_list.COUNT < 2) THEN
3486 RETURN;
3487 END IF;
3488
3489
3490 -- constraint type is 'All or None'
3491 BEGIN
3492 -- for each user
3493 FOR i IN 1 .. G_USER_ID_LIST.COUNT
3494 LOOP
3495 --FND_FILE.put_line(fnd_file.log,'******* G_USER_ID_LIST('||i||') '||G_USER_ID_LIST(i)||' ******');
3496 -- clear potential violation info (valid for one user against one constraint)
3497 Clear_Potential_Value_List ();
3498
3499 -- get user(usre i)'s responsibilities
3500 IF (BULK_COLLECTS_SUPPORTED) THEN
3501 -- 12.12.2003 tsho: use static sql for AMW for the time being
3502 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
3503 OPEN user_resp_c FOR l_user_resp_dynamic_sql USING
3504 G_USER_ID_LIST(i);
3505 FETCH user_resp_c BULK COLLECT INTO l_user_resp_id_list,
3506 l_user_resp_app_id_list,
3507 l_user_resp_start_date_list,
3508 l_user_resp_created_by_list;
3509 CLOSE user_resp_c;
3510 /*
3511 SELECT responsibility_id,
3512 responsibility_application_id,
3513 start_date,
3514 created_by
3515 BULK COLLECT INTO l_user_resp_id_list,
3516 l_user_resp_app_id_list,
3517 l_user_resp_start_date_list,
3518 l_user_resp_created_by_list
3519 FROM FND_USER_RESP_GROUPS
3520 WHERE user_id = G_USER_ID_LIST(i)
3521 AND (end_date >= sysdate or end_date is null);
3522 */
3523
3524 ELSE
3525 -- no BULK_COLLECTS_SUPPORTED
3526 j := 0;
3527 -- 12.12.2003 tsho: use static sql for AMW for the time being
3528 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
3529 OPEN user_resp_c FOR l_user_resp_dynamic_sql USING
3530 G_USER_ID_LIST(i);
3531 LOOP
3532 FETCH user_resp_c INTO l_user_resp_id,
3533 l_user_resp_app_id,
3534 l_user_resp_start_date,
3535 l_user_resp_created_by;
3536 EXIT WHEN user_resp_c%NOTFOUND;
3537 j := j+1;
3538 l_user_resp_id_list(j) := l_user_resp_id;
3539 l_user_resp_app_id_list(j) := l_user_resp_app_id;
3540 l_user_resp_start_date_list(j) := l_user_resp_start_date;
3541 l_user_resp_created_by_list(j) := l_user_resp_created_by;
3542 END LOOP;
3543 CLOSE user_resp_c;
3544 /*
3545 for rec in get_user_resp_c(G_USER_ID_LIST(i)) loop
3546 j := j + 1;
3547 l_user_resp_id_list(j) := rec.responsibility_id;
3548 l_user_resp_app_id_list(j) := rec.responsibility_application_id;
3549 l_user_resp_start_date_list(j) := rec.start_date;
3550 l_user_resp_created_by_list(j) := rec.created_by;
3551 end loop;
3552 */
3553 END IF; -- end of if: BULK_COLLECTS_SUPPORTED
3554
3555
3556 -- check if he(user i) has access to function k
3557 l_access_function_count := 0;
3558 -- 05.07.2004 tsho, bug 3616058, only one function shown under user as violation, move l_accessible := FALSE to be inside of funciton Loop
3559 --l_accessible := FALSE;
3560 FOR k IN 1 .. l_function_id_list.COUNT
3561 LOOP
3565 --FND_FILE.put_line(fnd_file.log,'----------- l_function_id_list('||k||') '||l_function_id_list(k)||' --------');
3562 -- 05.07.2004 tsho, bug 3616058, only one function shown under user as violation, move l_accessible := FALSE to be inside of funciton Loop
3563 l_accessible := FALSE;
3564
3566 -- test function id under user(user i)'s all responsibilities
3567 -- l_accessible will become TRUE as long as at least one of his responsibility can access this function
3568 FOR m IN 1 .. l_user_resp_id_list.COUNT
3569 LOOP
3570 --FND_FILE.put_line(fnd_file.log,'............. l_user_resp_id_list('||m||') '||l_user_resp_id_list(m)||' .........');
3571 l_test_id_result := TEST_ID(function_id => l_function_id_list(k),
3572 p_appl_id => l_user_resp_app_id_list(m),
3573 p_resp_id => l_user_resp_id_list(m),
3574 p_access_given_date => l_user_resp_start_date_list(m),
3575 p_access_given_by => l_user_resp_created_by_list(m));
3576 l_accessible := l_accessible OR l_test_id_result;
3577 IF (l_test_id_result) THEN
3578 --FND_FILE.put_line(fnd_file.log,'............. l_test_id_result = TRUE ');
3579 -- if TEST_ID result(final decision) has access right to function k under responsibility m,
3580 --FND_FILE.put_line(fnd_file.log,'............. G_PV_COUNT = '||G_PV_COUNT);
3581 G_PV_FUNCTION_ID_LIST(G_PV_COUNT) := G_PV_FUNCTION_ID;
3582 G_PV_MENU_ID_LIST(G_PV_COUNT) := G_PV_MENU_ID;
3583 G_PV_RESPONSIBILITY_ID_LIST(G_PV_COUNT) := G_PV_RESPONSIBILITY_ID;
3584 G_PV_ACCESS_GIVEN_DATE_LIST(G_PV_COUNT) := G_PV_ACCESS_GIVEN_DATE;
3585 G_PV_ACCESS_GIVEN_BY_LIST(G_PV_COUNT) := G_PV_ACCESS_GIVEN_BY;
3586 --FND_FILE.put_line(fnd_file.log,'............. G_PV_FUNCTION_ID_LIST(G_PV_FUNCTION_ID_LIST.COUNT) = '||G_PV_FUNCTION_ID_LIST(G_PV_FUNCTION_ID_LIST.COUNT));
3587 G_PV_COUNT := G_PV_COUNT +1;
3588 END IF;
3589 END LOOP; -- end of loop: l_user_resp_id_list
3590
3591 IF (NOT l_accessible) THEN
3592 -- in 'ALL' constraint type,
3593 -- if he(user i) doesn't have access(after check for all his responsibilities) to one function,
3594 -- then he doesn't violat this constraint. exit to check for next user(user i+1)
3595 --FND_FILE.put_line(fnd_file.log,'............. l_accessible = FALSE ');
3596 EXIT;
3597 ELSE
3598 --FND_FILE.put_line(fnd_file.log,'............. l_accessible = TRUE ');
3599 l_access_function_count := l_access_function_count+1;
3600 END IF;
3601
3602 END LOOP; -- end of loop: l_function_id_list
3603
3604 IF (l_access_function_count < l_function_id_list.COUNT) THEN
3605 -- user(user i) doesn't have access rights to all the incompatible functions defined in this constraint,
3606 -- it's garuanteed he doesn't violate this constraint
3607 --FND_FILE.put_line(fnd_file.log,'............. l_access_function_count < '||l_function_id_list.COUNT);
3608 null;
3609 ELSE
3610 -- write potential violation info to table
3611 --FND_FILE.put_line(fnd_file.log,'............. l_access_function_count >= '||l_function_id_list.COUNT);
3612 Write_To_Table(p_violation_id, p_constraint_rev_id, G_USER_ID_LIST(i));
3613 END IF;
3614
3615 END LOOP; -- end of loop: G_USER_ID_LIST
3616
3617 EXCEPTION
3618 WHEN others THEN
3619 --FND_FILE.put_line(fnd_file.log,'............. exception ...........');
3620 RAISE;
3621 END;
3622
3623 END IF; -- end of if: p_constraint_rev_id IS NOT NULL
3624
3625 END Check_For_Constraint_ALL;
3626
3627
3628
3629
3630
3631 -- ===============================================================
3632 -- Private Procedure name
3633 -- Check_For_Constraint_ME
3634 --
3635 -- Purpose
3636 -- for constraint type = 'Mutual Exclusive' (type_code = 'ME')
3637 -- check violation for specified constraint
3638 -- this is private procedure,
3639 -- should not call this procedure directly
3640 --
3641 -- Params
3642 -- p_constraint_rev_id := specified constraint_rev_id
3643 --
3644 -- Notes
3645 -- 01.10.2005 tsho: Deprecated, use Check_For_Func_Cst_ME instead
3646 -- ===============================================================
3647 PROCEDURE Check_For_Constraint_ME (
3648 p_constraint_rev_id IN NUMBER,
3649 p_violation_id IN NUMBER
3650 )
3651 IS
3652
3653 L_API_NAME CONSTANT VARCHAR2(30) := 'Check_For_Constraint_ME';
3654 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
3655
3656 -- store the tmp count for g_user_id_list
3657 i NUMBER;
3658
3659 -- store the tmp count for l_functions
3660 j NUMBER;
3661
3662 -- store the tmp count for l_functions
3666 m NUMBER;
3663 k NUMBER;
3664
3665 -- store the tmp count for l_user_resp_id_list
3667
3668 -- store the test_id result
3669 l_test_id_result BOOLEAN;
3670
3671 -- store the access right
3672 l_accessible BOOLEAN;
3673
3674 -- store how many incompatible functions he can access so far
3675 l_access_function_count NUMBER;
3676
3677
3678 TYPE NumberTable IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
3679 TYPE DateTable IS TABLE OF DATE INDEX BY BINARY_INTEGER;
3680
3681 -- find the constraint entries(incompatible functions) by specified constraint_rev_id
3682 l_function_id_list NumberTable;
3683 l_constraint_function_id NUMBER;
3684 CURSOR c_constraint_entries (l_constraint_rev_id IN NUMBER) IS
3685 SELECT function_id
3686 FROM amw_constraint_entries
3687 WHERE constraint_rev_id=l_constraint_rev_id;
3688
3689
3690 -- find the responsibilities by specified user_id
3691 l_user_resp_id_list NumberTable;
3692 l_user_resp_id NUMBER;
3693
3694 -- find the responsibility app ids by specified user_id
3695 l_user_resp_app_id_list NumberTable;
3696 l_user_resp_app_id NUMBER;
3697
3698 -- find the access_given_dates (start_date from G_AMW_USER_RESP_GROUPS) by specified user_id
3699 l_user_resp_start_date_list DateTable;
3700 l_user_resp_start_date DATE;
3701
3702 -- find the access_given_by ids (created_by from G_AMW_USER_RESP_GROUPS) by specified user_id
3703 l_user_resp_created_by_list NumberTable;
3704 l_user_resp_created_by NUMBER;
3705
3706 -- 12.12.2003 tsho: use static sql for AMW for the time being
3707 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
3708 TYPE respCurTyp IS REF CURSOR;
3709 user_resp_c respCurTyp;
3710 -- 04.07.2005 tsho: bug 4145922, cosider hierarchical role assignment
3711 /*
3712 l_user_resp_dynamic_sql VARCHAR2(200) :=
3713 'SELECT responsibility_id, responsibility_application_id, start_date, created_by '
3714 ||' FROM '||G_AMW_USER_RESP_GROUPS
3715 ||' WHERE user_id = :1 and (end_date >= sysdate or end_date is null)';
3716 */
3717 l_user_resp_dynamic_sql VARCHAR2(2000) :=
3718 'SELECT outer.responsibility_id, outer.responsibility_application_id, outer.start_date, outer.created_by '
3719 ||' FROM '||G_AMW_USER_RESP_GROUPS ||' outer '
3720 ||' WHERE outer.start_date = ('
3721 ||' SELECT min(innter.start_date) '
3722 ||' FROM '||G_AMW_USER_RESP_GROUPS ||' inner '
3723 ||' WHERE inner.user_id = :1 '
3724 ||' AND inner.responsibility_id = outer.responsibility_id '
3725 ||' AND inner.responsibility_application_id = outer.responsibility_application_id '
3726 ||' AND inner.start_date <= sysdate AND (inner.end_date >= sysdate or inner.end_date is null) '
3727 ||' )';
3728 /*
3729 cursor get_user_resp_c(l_user_id IN NUMBER) is
3730 SELECT responsibility_id,
3731 responsibility_application_id,
3732 start_date,
3733 created_by
3734 from FND_USER_RESP_GROUPS
3735 where user_id = l_user_id
3736 and (end_date >= sysdate or end_date is null);
3737 */
3738
3739 BEGIN
3740 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
3741
3742 -- if no users in g_user_id_list, then no need to go further to check constraint
3743 IF ((G_USER_ID_LIST IS NULL) OR (G_USER_ID_LIST.FIRST IS NULL)) THEN
3744 RETURN;
3745 END IF;
3746
3747
3748 IF (p_constraint_rev_id IS NOT NULL) THEN
3749 -- find the constraint entries(incompatible functions) by specified constraint_rev_id
3750 IF (BULK_COLLECTS_SUPPORTED) THEN
3751 OPEN c_constraint_entries (p_constraint_rev_id);
3752 FETCH c_constraint_entries BULK COLLECT INTO l_function_id_list;
3753 CLOSE c_constraint_entries;
3754 ELSE
3755 -- no BULK_COLLECTS_SUPPORTED
3756 j := 0;
3757 OPEN c_constraint_entries (p_constraint_rev_id);
3758 LOOP
3759 FETCH c_constraint_entries INTO l_constraint_function_id;
3760 EXIT WHEN c_constraint_entries%NOTFOUND;
3761 j := j+1;
3762 l_function_id_list(j) := l_constraint_function_id;
3763 END LOOP;
3764 CLOSE c_constraint_entries;
3765 END IF; -- end of if: BULK_COLLECTS_SUPPORTED
3766
3767
3768 -- passed-in p_constraint_rev_id doesn't have at least 2 incompatible functions defined
3769 IF (l_function_id_list.COUNT < 2) THEN
3770 RETURN;
3771 END IF;
3772
3773
3774 -- constraint type is 'All or None'
3775 BEGIN
3776 -- for each user
3777 FOR i IN 1 .. G_USER_ID_LIST.COUNT
3778 LOOP
3779 -- clear potential violation info (valid for one user against one constraint)
3780 Clear_Potential_Value_List ();
3781
3782 -- get user(usre i)'s responsibilities
3783 IF (BULK_COLLECTS_SUPPORTED) THEN
3784 -- 12.12.2003 tsho: use static sql for AMW for the time being
3785 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
3786 OPEN user_resp_c FOR l_user_resp_dynamic_sql USING
3787 G_USER_ID_LIST(i);
3788 FETCH user_resp_c BULK COLLECT INTO l_user_resp_id_list,
3792 CLOSE user_resp_c;
3789 l_user_resp_app_id_list,
3790 l_user_resp_start_date_list,
3791 l_user_resp_created_by_list;
3793 /*
3794 SELECT responsibility_id,
3795 responsibility_application_id,
3796 start_date,
3797 created_by
3798 BULK COLLECT INTO l_user_resp_id_list,
3799 l_user_resp_app_id_list,
3800 l_user_resp_start_date_list,
3801 l_user_resp_created_by_list
3802 FROM FND_USER_RESP_GROUPS
3803 WHERE user_id = G_USER_ID_LIST(i)
3804 AND (end_date >= sysdate or end_date is null);
3805 */
3806
3807 ELSE
3808 -- no BULK_COLLECTS_SUPPORTED
3809 j := 0;
3810 -- 12.12.2003 tsho: use static sql for AMW for the time being
3811 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
3812 OPEN user_resp_c FOR l_user_resp_dynamic_sql USING
3813 G_USER_ID_LIST(i);
3814 LOOP
3815 FETCH user_resp_c INTO l_user_resp_id,
3816 l_user_resp_app_id,
3817 l_user_resp_start_date,
3818 l_user_resp_created_by;
3819 EXIT WHEN user_resp_c%NOTFOUND;
3820 j := j+1;
3821 l_user_resp_id_list(j) := l_user_resp_id;
3822 l_user_resp_app_id_list(j) := l_user_resp_app_id;
3823 l_user_resp_start_date_list(j) := l_user_resp_start_date;
3824 l_user_resp_created_by_list(j) := l_user_resp_created_by;
3825 END LOOP;
3826 CLOSE user_resp_c;
3827 /*
3828 for rec in get_user_resp_c(G_USER_ID_LIST(i)) loop
3829 j := j + 1;
3830 l_user_resp_id_list(j) := rec.responsibility_id;
3831 l_user_resp_app_id_list(j) := rec.responsibility_application_id;
3832 l_user_resp_start_date_list(j) := rec.start_date;
3833 l_user_resp_created_by_list(j) := rec.created_by;
3834 end loop;
3835 */
3836
3837 END IF; -- end of if: BULK_COLLECTS_SUPPORTED
3838
3839
3840 -- check if he(user i) has access to function k
3841 l_access_function_count := 0;
3842 -- 05.07.2004 tsho, bug 3616058, only one function shown under user as violation, move l_accessible := FALSE to be inside of funciton Loop
3843 --l_accessible := FALSE;
3844 FOR k IN 1 .. l_function_id_list.COUNT
3845 LOOP
3846 -- 05.07.2004 tsho, bug 3616058, only one function shown under user as violation, move l_accessible := FALSE to be inside of funciton Loop
3847 l_accessible := FALSE;
3848
3849 -- test function id under user(user i)'s all responsibilities
3850 -- l_accessible will become TRUE as long as at least one of his responsibility can access this function
3851 FOR m IN 1 .. l_user_resp_id_list.COUNT
3852 LOOP
3853 l_test_id_result := TEST_ID(function_id => l_function_id_list(k),
3854 p_appl_id => l_user_resp_app_id_list(m),
3855 p_resp_id => l_user_resp_id_list(m),
3856 p_access_given_date => l_user_resp_start_date_list(m),
3857 p_access_given_by => l_user_resp_created_by_list(m));
3858 l_accessible := l_accessible OR l_test_id_result;
3859
3860 IF (l_test_id_result) THEN
3861 -- if TEST_ID result(final decision) has access right to function k under responsibility m,
3862 G_PV_FUNCTION_ID_LIST(G_PV_COUNT) := G_PV_FUNCTION_ID;
3863 G_PV_MENU_ID_LIST(G_PV_COUNT) := G_PV_MENU_ID;
3864 G_PV_RESPONSIBILITY_ID_LIST(G_PV_COUNT) := G_PV_RESPONSIBILITY_ID;
3865 G_PV_ACCESS_GIVEN_DATE_LIST(G_PV_COUNT) := G_PV_ACCESS_GIVEN_DATE;
3866 G_PV_ACCESS_GIVEN_BY_LIST(G_PV_COUNT) := G_PV_ACCESS_GIVEN_BY;
3867 --FND_FILE.put_line(fnd_file.log,'............. G_PV_FUNCTION_ID_LIST(G_PV_FUNCTION_ID_LIST.COUNT) = '||G_PV_FUNCTION_ID_LIST(G_PV_FUNCTION_ID_LIST.COUNT));
3868 G_PV_COUNT := G_PV_COUNT +1;
3869 END IF;
3870
3871 END LOOP; -- end of loop: l_user_resp_id_list
3872
3873 IF (l_accessible) THEN
3874 -- in 'ME' constraint type,
3875 -- for each function(function k), after check for all his(user i) responsibilities,
3876 -- if l_accessible=TRUE, add 1 to l_access_function_count
3877 -- the user(user i) violates this constraint if l_access_function_count >= 2
3878 l_access_function_count := l_access_function_count+1;
3879 END IF;
3880
3884 -- now it's gauranteed user i has violated this constraint
3881 END LOOP; -- end of loop: l_function_id_list
3882
3883 IF (l_access_function_count >= 2) THEN
3885 -- write potential violation info to table
3886 Write_To_Table(p_violation_id, p_constraint_rev_id, G_USER_ID_LIST(i));
3887 ELSE
3888 null; -- now it's gauranteed user i doesn't violate this constraint
3889 END IF;
3890
3891 END LOOP; -- end of loop: G_USER_ID_LIST
3892
3893 EXCEPTION
3894 WHEN others THEN
3895 NULL;
3896 END;
3897
3898 END IF; -- end of if: p_constraint_rev_id IS NOT NULL
3899
3900 END Check_For_Constraint_ME;
3901
3902
3903 -- ===============================================================
3904 -- Function name
3905 -- Populate_Ptnl_Resps_For_Cst
3906 -- Purpose
3907 -- populate the global potential responsibility id list by specified constraint_rev_id,
3908 -- populate the global corresponding application id list
3909 -- Params
3910 -- p_constraint_rev_id := specified constraint_rev_id
3911 --
3912 -- Notes
3913 -- 12.21.2004 tsho: fix for performance bug 4036679
3914 -- the returned potential responsibility id list includes the responsibility
3915 -- which contains those functions excluded from it.
3916 -- (ie, exclusion is not considered here)
3917 -- History
3918 -- 05.25.2005 tsho: starting from AMW.E,consider Concurrent Programs as constraint entries
3919 -- ===============================================================
3920 Procedure Populate_Ptnl_Resps_For_Cst (
3921 p_constraint_rev_id IN NUMBER
3922 )
3923 IS
3924
3925 L_API_NAME CONSTANT VARCHAR2(30) := 'Populate_Ptnl_Resps_For_Cst';
3926 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
3927
3928 l_resp_id NUMBER;
3929 l_appl_id NUMBER;
3930 l_menu_id NUMBER;
3931
3932 -- store the tmp count for l_resp_id_list
3933 j NUMBER;
3934
3935 -- enable dynamic sql in AMW.C with 5.10
3936 TYPE respCurTyp IS REF CURSOR;
3937 resp_c respCurTyp;
3938
3939 -- This query fetches the reponsibilities that have access to the incompatible functions only.
3940 l_resp_dynamic_sql VARCHAR2(2000) :=
3941 'SELECT DISTINCT resp.responsibility_id, '
3942 ||' resp.application_id, '
3943 ||' resp.menu_id, '
3944 ||' ce.function_id, '
3945 ||' ce.group_code '
3946 ||' FROM AMW_CONSTRAINT_ENTRIES ce, '
3947 ||' '||G_AMW_COMPILED_MENU_FUNCTIONS||' cmf, '
3948 ||' '||G_AMW_RESPONSIBILITY||' resp '
3949 ||' WHERE ce.CONSTRAINT_REV_ID = :1 '
3950 ||' AND (ce.OBJECT_TYPE is null OR ce.OBJECT_TYPE = ''FUNC'') '
3951 ||' AND cmf.function_id=ce.FUNCTION_ID '
3952 ||' AND cmf.grant_flag = ''Y'' '
3953 ||' AND resp.menu_id = cmf.menu_id '
3954 ||' AND resp.start_date <= sysdate '
3955 ||' AND (resp.end_date >= sysdate or resp.end_date is null) ';
3956
3957 listkey VARCHAR2(30):=NULL;
3958 L_FUNC_ID_LIST G_FUNC_TABLE;
3959 L_RESPVIO_ENTRIES G_RESPVIO_ENTRIES_TABLE;
3960 counts NUMBER;
3961
3962
3963 BEGIN
3964 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
3965
3966 -- clear global potential responsiblity id list and corresponding applicaiton id, menu id list (valid for one constraint)
3967 G_PNTL_RESP_ID_LIST.DELETE();
3968 G_PNTL_APPL_ID_LIST.DELETE();
3969 G_PNTL_MENU_ID_LIST.DELETE();
3970 G_PNTL_FUNCTION_ID_LIST.DELETE();
3971 G_PNTL_GRP_CODE_LIST.DELETE();
3972 G_PNTL_RESP_VIO_LIST.DELETE();
3973
3974 OPEN resp_c FOR l_resp_dynamic_sql USING
3975 p_constraint_rev_id;
3976 FETCH resp_c
3977 BULK COLLECT INTO G_PNTL_RESP_ID_LIST,
3978 G_PNTL_APPL_ID_LIST,
3979 G_PNTL_MENU_ID_LIST,
3980 G_PNTL_FUNCTION_ID_LIST,
3981 G_PNTL_GRP_CODE_LIST;
3982 CLOSE resp_c;
3983
3984 -- psomanat : 06:09:2006 : fix for bug 5256720
3985 -- The resultset of the above query is fetched into individual List.
3986 -- A responsibility can have more than one incompatible function.
3987 -- We need to verify if the incompatible function is excluded by function exclusion
3988 -- or menu exclusion.
3989 -- The Populate_Ptnl_Access_List,PROCESS_MENU_TREE_DOWN_FOR_MN proceedures of
3990 -- amwvcstb.pls 120.23 version takes each incompatible function individaully
3991 -- and checks if the function is excluded via function or menu exclusion.This
3992 -- makes the process very slow.
3993 -- To make the process fast, we collect the incompatible functions accessable
3994 -- via a responsibility in a plsql data structure and collectively check
3995 -- if the incompatible functions are excluded via function or menu exclusion
3996 -- from the responsibility.
3997 -- The PLSQL Data Structure is like this
3998 -- Responsibility
3999 -- |______Function_Id
4000 -- | |________Function Details Record
4001 -- | |________Function Details Record
4002 -- |
4003 -- |______Function_Id
4004 -- | |________Function Details Record
4008 -- | |________Function Details Record
4005 -- | |________Function Details Record
4006 -- |______Function_Id
4007 -- | |________Function Details Record
4009 --
4010 --
4011 -- So a responsibility can have n number of function ids.
4012 -- A responsibility is identified by application_id and responsibility_id
4013 -- So we use application_id@responsibility_id as key for the Responsibility
4014 -- Nested table.
4015 -- A function can be from set 1 and set 2. The each incompatible function
4016 -- detail is stored as a plsql record under the function id.
4017 IF ((G_PNTL_RESP_ID_LIST IS NOT NULL) AND (G_PNTL_RESP_ID_LIST.FIRST IS NOT NULL)) THEN
4018 FOR i in G_PNTL_RESP_ID_LIST.FIRST .. G_PNTL_RESP_ID_LIST.LAST
4019 LOOP
4020 L_FUNC_ID_LIST.DELETE();
4021 L_RESPVIO_ENTRIES.DELETE();
4022
4023 listkey := G_PNTL_APPL_ID_LIST(i)||'@'||G_PNTL_RESP_ID_LIST(i);
4024 IF G_PNTL_RESP_VIO_LIST.EXISTS(listkey) THEN
4025 L_FUNC_ID_LIST := G_PNTL_RESP_VIO_LIST(listkey);
4026 IF L_FUNC_ID_LIST.EXISTS(G_PNTL_FUNCTION_ID_LIST(i)) THEN
4027 L_RESPVIO_ENTRIES := L_FUNC_ID_LIST(G_PNTL_FUNCTION_ID_LIST(i));
4028 END IF;
4029 END IF;
4030
4031 counts := L_RESPVIO_ENTRIES.COUNT+1;
4032 L_RESPVIO_ENTRIES(counts).application_id := G_PNTL_APPL_ID_LIST(i);
4033 L_RESPVIO_ENTRIES(counts).Responsibility_id := G_PNTL_RESP_ID_LIST(i);
4034 L_RESPVIO_ENTRIES(counts).Function_Id := G_PNTL_FUNCTION_ID_LIST(i);
4035 L_RESPVIO_ENTRIES(counts).group_code := G_PNTL_GRP_CODE_LIST(i);
4036 L_RESPVIO_ENTRIES(counts).Menu_id := G_PNTL_MENU_ID_LIST(i);
4037 L_RESPVIO_ENTRIES(counts).Access_Given_Date := NULL;
4038 L_RESPVIO_ENTRIES(counts).Access_Given_By_Id := NULL;
4039 L_RESPVIO_ENTRIES(counts).Object_Type := NULL;
4040 L_RESPVIO_ENTRIES(counts).prog_appl_id := NULL;
4041 L_RESPVIO_ENTRIES(counts).Role_Name := NULL;
4042 L_FUNC_ID_LIST(G_PNTL_FUNCTION_ID_LIST(i)) := L_RESPVIO_ENTRIES;
4043 G_PNTL_RESP_VIO_LIST(listkey) := L_FUNC_ID_LIST;
4044 END LOOP;
4045 END IF;
4046
4047 -- Clearing the List
4048 G_PNTL_RESP_ID_LIST.DELETE();
4049 G_PNTL_APPL_ID_LIST.DELETE();
4050 G_PNTL_MENU_ID_LIST.DELETE();
4051 G_PNTL_FUNCTION_ID_LIST.DELETE();
4052 G_PNTL_GRP_CODE_LIST.DELETE();
4053 END Populate_Ptnl_Resps_For_Cst;
4054
4055
4056
4057 -- ===============================================================
4058 -- Procedure name
4059 -- Populate_Ptnl_Access_List
4060 --
4061 -- Purpose
4062 -- populate the global potential responsibility id list
4063 -- populate the global potential menu id list
4064 -- populate the global potential function id list
4065 --
4066 -- Notes
4067 -- 12.21.2004 tsho: fix for performance bug 4036679
4068 -- History
4069 -- 05.24.2005 tsho: AMW.E Incompatible Sets,
4070 -- need to record amw_constraint_entries.group_code for each item
4071 -- 05.25.2005 tsho: consider Concurrent Programs as constraint entries
4072 -- ===============================================================
4073 Procedure Populate_Ptnl_Access_List (
4074 p_constraint_rev_id IN NUMBER
4075 )
4076 IS
4077
4078 L_API_NAME CONSTANT VARCHAR2(30) := 'Populate_Ptnl_Access_List';
4079 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
4080
4081 -- store the access right
4082 l_accessible BOOLEAN;
4083
4084 TYPE cpRespCurTyp IS REF CURSOR;
4085 cp_resp_c cpRespCurTyp;
4086
4087 -- This query identifies the responsibilities having access to the concurrent program
4088 -- defined as incompatible function in a constraint
4089 l_cp_resp_dynamic_sql VARCHAR2(2000) :=
4090 ' SELECT RESP.APPLICATION_ID, '
4091 ||' RESP.RESPONSIBILITY_ID, '
4092 ||' RESP.REQUEST_GROUP_ID MENU_ID, '
4093 ||' ACE.FUNCTION_ID, '
4094 ||' ACE.OBJECT_TYPE, '
4095 ||' ACE.APPLICATION_ID, '
4096 ||' ACE.GROUP_CODE, '
4097 ||' RGU.CREATION_DATE ACCESS_GIVEN_DATE, '
4098 ||' RGU.CREATED_BY ACCESS_GIVEN_BY '
4099 ||' FROM '||G_AMW_RESPONSIBILITY||' RESP, '
4100 ||' '||G_AMW_REQUEST_GROUP_UNITS||' RGU, '
4101 ||' AMW_CONSTRAINT_ENTRIES ACE '
4102 ||' WHERE RESP.GROUP_APPLICATION_ID IS NOT NULL '
4103 ||' AND RESP.REQUEST_GROUP_ID IS NOT NULL '
4104 ||' AND RGU.REQUEST_UNIT_TYPE = ''P'' '
4105 ||' AND ACE.OBJECT_TYPE=''CP'' '
4106 ||' AND ACE.CONSTRAINT_REV_ID=:1 '
4107 ||' AND RESP.GROUP_APPLICATION_ID=RGU.APPLICATION_ID '
4108 ||' AND RESP.REQUEST_GROUP_ID=RGU.REQUEST_GROUP_ID '
4109 ||' AND RGU.UNIT_APPLICATION_ID=ACE.APPLICATION_ID '
4110 ||' AND RGU.REQUEST_UNIT_ID=ACE.FUNCTION_ID '
4111 ||' AND RESP.START_DATE<=SYSDATE AND (RESP.END_DATE>= SYSDATE or RESP.END_DATE IS NULL) '
4112 ||' UNION ALL '
4113 ||' SELECT RESP.APPLICATION_ID, '
4114 ||' RESP.RESPONSIBILITY_ID, '
4115 ||' RESP.REQUEST_GROUP_ID MENU_ID, '
4116 ||' ACE.FUNCTION_ID, '
4117 ||' ACE.OBJECT_TYPE, '
4118 ||' ACE.APPLICATION_ID, '
4122 ||' FROM '||G_AMW_RESPONSIBILITY||' RESP , '
4119 ||' ACE.GROUP_CODE, '
4120 ||' RGU.CREATION_DATE ACCESS_GIVEN_DATE, '
4121 ||' RGU.CREATED_BY ACCESS_GIVEN_BY '
4123 ||' '||G_AMW_REQUEST_GROUP_UNITS||' RGU, '
4124 ||' AMW_CONSTRAINT_ENTRIES ACE, '
4125 ||' '||G_AMW_CONCURRENT_PROGRAMS_VL||' CON '
4126 ||' WHERE RESP.GROUP_APPLICATION_ID IS NOT NULL '
4127 ||' AND RESP.REQUEST_GROUP_ID IS NOT NULL '
4128 ||' AND RGU.REQUEST_UNIT_TYPE = ''A'' '
4129 ||' AND ACE.OBJECT_TYPE=''CP'' '
4130 ||' AND ACE.CONSTRAINT_REV_ID=:2 '
4131 ||' AND RESP.GROUP_APPLICATION_ID=RGU.APPLICATION_ID '
4132 ||' AND RESP.REQUEST_GROUP_ID=RGU.REQUEST_GROUP_ID '
4133 ||' AND RGU.UNIT_APPLICATION_ID=ACE.APPLICATION_ID '
4134 ||' AND RGU.REQUEST_UNIT_ID=ACE.APPLICATION_ID '
4135 ||' AND RGU.UNIT_APPLICATION_ID=CON.APPLICATION_ID '
4136 ||' AND CON.CONCURRENT_PROGRAM_ID = ACE.FUNCTION_ID '
4137 ||' AND RESP.START_DATE<=SYSDATE AND (RESP.END_DATE>= SYSDATE or RESP.END_DATE IS NULL)' ;
4138
4139 -- enable dynamic sql in AMW.C with 5.10
4140 TYPE exclFuncCurTyp IS REF CURSOR;
4141 excl_func_c exclFuncCurTyp;
4142 -- This Query gets all the function exclusions for a given responsibility.
4143 l_excl_func_dynamic_sql VARCHAR2(1000) :=
4144 'SELECT action_id '
4145 ||' FROM '||G_AMW_RESP_FUNCTIONS
4146 ||' WHERE application_id = :1 '
4147 ||' AND responsibility_id = :2 '
4148 ||' AND rule_type = ''F'' ';
4149
4150 -- psomanat : 06:09:2006 : fix for bug 5256720
4151 L_RESPVIO_ENTRIES G_RESPVIO_ENTRIES_TABLE;
4152 L_FUNC_ID_LIST G_FUNC_TABLE;
4153 counts Number;
4154 lkey VARCHAR2(30) := NULL;
4155 listkey VARCHAR2(30) := NULL;
4156 l_excl_func_id_list G_NUMBER_TABLE;
4157 l_excl_func_list G_NUMBER_TABLE;
4158 l_resp_id NUMBER;
4159 l_appl_id NUMBER;
4160 l_menu_id NUMBER;
4161
4162 BEGIN
4163 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
4164 --FND_FILE.put_line(fnd_file.log,'Populate_Ptnl_Access_List Began '||to_char(sysdate,'DD-MON-RRRR:HH24:MI:SS'));
4165
4166 -- psomanat : 06:09:2006 : fix for bug 5256720
4167 G_RESP_VIOLATIONS_LIST.delete();
4168 l_accessible := FALSE;
4169
4170 -- psomanat : 06:09:2006 : fix for bug 5256720
4171 IF (p_constraint_rev_id IS NULL) THEN
4172 Return;
4173 END IF;
4174
4175 -- populate global potential responsibility id and corresponding application id list for this constraint_rev_id
4176 Populate_Ptnl_Resps_For_Cst(p_constraint_rev_id => p_constraint_rev_id);
4177
4178 -- clear potential violation info (valid for one constraint)
4179 Clear_Potential_Value_List();
4180
4181 -- FND_FILE.put_line(fnd_file.log,'cp_resp_c Began '||to_char(sysdate,'DD-MON-RRRR:HH24:MI:SS'));
4182 -- Identify the Responsibilities having access to the concurrent
4183 -- program specified as incompatible function in the constraint.
4184 OPEN cp_resp_c FOR l_cp_resp_dynamic_sql USING p_constraint_rev_id,p_constraint_rev_id;
4185 FETCH cp_resp_c
4186 BULK COLLECT INTO G_PV_APPLICATION_ID_LIST,
4187 G_PV_RESPONSIBILITY_ID_LIST,
4188 G_PV_MENU_ID_LIST,
4189 G_PV_FUNCTION_ID_LIST,
4190 G_PV_OBJECT_TYPE_LIST,
4191 G_PV_PROGRAM_APPL_ID_LIST,
4192 G_PV_GROUP_CODE_LIST,
4193 G_PV_ACCESS_GIVEN_DATE_LIST,
4194 G_PV_ACCESS_GIVEN_BY_LIST;
4195 CLOSE cp_resp_c;
4196
4197 -- psomanat : 06:09:2006 : fix for bug 5256720
4198 -- The resultset of the above query is fetched into individual Nested Table.
4199 -- A responsibility can have access to more than one incompatible function.
4200 -- The Check_For_Func_Cst_XXXXX proceedures of amwvcstb.pls 120.23 version
4201 -- uses these individual nested table to identify the functions accessible
4202 -- by a responsibility. To do this it iterate over the G_PV_RESPONSIBILITY_ID_LIST
4203 -- to check if the responsibility exist and if it exists , it checks the
4204 -- G_PV_FUNCTION_ID_LIST to get the incompatible function.
4205 -- This process consumes lot of time.
4206 --
4207 -- So in order to avoide this unneccessary looping we store the date from
4208 -- the individual list into a PLSQL Data Structure is like this
4209 -- Responsibility
4210 -- |______Function_Id
4211 -- | |________Function Details Record
4212 -- | |________Function Details Record
4213 -- |
4214 -- |______Function_Id
4215 -- | |________Function Details Record
4216 -- | |________Function Details Record
4217 -- |______Function_Id
4218 -- | |________Function Details Record
4219 -- | |________Function Details Record
4220 --
4221 --
4222 -- So a responsibility can have n number of function ids.
4223 -- A responsibility is identified by application_id and responsibility_id
4224 -- So we use application_id@responsibility_id as key for the Responsibility
4225 -- Nested table.
4226 -- The each incompatible function detail is stored as a plsql record under
4227 -- the function id.
4228 -- The advantages of plsql data structure are
4232 -- 3. The same data structure is used in mutiple proceedures, so we
4229 -- 1. Now the responsibility id + application id acts as an index to
4230 -- get all the incompatible functions
4231 -- 2. The unneccesary looping is avoided
4233 -- reduce the time take to get the required data by just passing the
4234 -- required keys.
4235 IF (G_PV_RESPONSIBILITY_ID_LIST IS NOT NULL) AND (G_PV_RESPONSIBILITY_ID_LIST.FIRST IS NOT NULL) THEN
4236 FOR i in 1 .. G_PV_RESPONSIBILITY_ID_LIST.COUNT
4237 LOOP
4238 L_FUNC_ID_LIST.delete();
4239 L_RESPVIO_ENTRIES.delete();
4240
4241 -- To identify a responsibility we need application id and responsibility.
4242 -- So the key is like application_id@responsibility_id
4243 listkey :=G_PV_APPLICATION_ID_LIST(i)||'@'||G_PV_RESPONSIBILITY_ID_LIST(i);
4244
4245 -- Here we check if the responsibility allready exists in G_RESP_VIOLATIONS_LIST.
4246 -- If Yes, we get the function list
4247 -- check if the function list contains the concurrent program id refered by
4248 -- G_PV_FUNCTION_ID_LIST(i)
4249 -- If yes, we get the responsibility violation plsql record and
4250 -- add a new record to the existing records
4251 -- End
4252 -- Note : when any of the check fails, the corresponding NestedTable entry
4253 -- or plsql entry is newly created and added to the main G_RESP_VIOLATIONS_LIST
4254 IF (G_RESP_VIOLATIONS_LIST.EXISTS(listkey)) THEN
4255 L_FUNC_ID_LIST := G_RESP_VIOLATIONS_LIST(listkey);
4256 IF L_FUNC_ID_LIST.EXISTS(G_PV_FUNCTION_ID_LIST(i)) THEN
4257 L_RESPVIO_ENTRIES := L_FUNC_ID_LIST(G_PV_FUNCTION_ID_LIST(i));
4258 END IF;
4259 END IF;
4260
4261 counts := L_RESPVIO_ENTRIES.COUNT+1;
4262 L_RESPVIO_ENTRIES(counts).application_id := G_PV_APPLICATION_ID_LIST(i);
4263 L_RESPVIO_ENTRIES(counts).Responsibility_id := G_PV_RESPONSIBILITY_ID_LIST(i);
4264 L_RESPVIO_ENTRIES(counts).Menu_id := G_PV_MENU_ID_LIST(i);
4265 L_RESPVIO_ENTRIES(counts).Function_Id := G_PV_FUNCTION_ID_LIST(i);
4266 L_RESPVIO_ENTRIES(counts).Access_Given_Date := G_PV_ACCESS_GIVEN_DATE_LIST(i);
4267 L_RESPVIO_ENTRIES(counts).Access_Given_By_Id := G_PV_ACCESS_GIVEN_BY_LIST(i);
4268 L_RESPVIO_ENTRIES(counts).Object_Type := 'CP';
4269 L_RESPVIO_ENTRIES(counts).group_code := G_PV_GROUP_CODE_LIST(i);
4270 L_RESPVIO_ENTRIES(counts).prog_appl_id := G_PV_PROGRAM_APPL_ID_LIST(i);
4271 L_RESPVIO_ENTRIES(counts).Role_Name := NULL;
4272 L_FUNC_ID_LIST(G_PV_FUNCTION_ID_LIST(i)) := L_RESPVIO_ENTRIES;
4273 G_RESP_VIOLATIONS_LIST(listkey) := L_FUNC_ID_LIST;
4274 END lOOP; -- End of FOR i in 1 .. G_PV_RESPONSIBILITY_ID_LIST.COUNT
4275 END IF;
4276 --FND_FILE.put_line(fnd_file.log,'cp_resp_c End '||to_char(sysdate,'DD-MON-RRRR:HH24:MI:SS'));
4277
4278 -- Releasing the used memory
4279 Clear_Potential_Value_List();
4280
4281 --FND_FILE.put_line(fnd_file.log,'Potential Reposnibility Start '||to_char(sysdate,'DD-MON-RRRR:HH24:MI:SS'));
4282
4283
4284 -- psomanat : 06:09:2006 : fix for bug 5256720
4285 -- In amwvcstb.pls 120.23 version, we use the following logic
4286 -- for each incomptible function ...
4287 -- for each responsibility ...
4288 -- Check if the current function is excluded via function or menu
4289 -- exclusion
4290 -- end
4291 -- end
4292 --
4293 -- So for each incompatible function we dig into the responsibility menu
4294 -- hierarchy once to see if the function is exclude via menu exclusion.
4295 --
4296 -- When the incompatible function is not accessible by the responsibility,
4297 -- we are unnecessaryly digging into the entire responsibility menu hierarchy.
4298 --
4299 -- Even if a responsibility is having access to more than incompatible function,
4300 -- we dig into the entire responsibility menu hierarchy once for each incompatible
4301 -- function. So we are doing the same operation once for each function
4302 --
4303 -- So i have modified the logic as follows
4304 -- When we identify the responsibilities having access to the incompatible functions,
4305 -- we seggregate the responsibility in a data structure like
4306 -- Responsibility
4307 -- |______Function_Id
4308 -- | |________Function Details Record
4309 -- | |________Function Details Record
4310 -- |
4311 -- |______Function_Id
4312 -- | |________Function Details Record
4313 -- | |________Function Details Record
4314 -- |______Function_Id
4315 -- | |________Function Details Record
4316 -- | |________Function Details Record
4317 --
4318 --
4319 --
4320 -- So now i know the functions a responsibility have access to.
4321 -- So i iterate over the responsibility menu hierarchy once and in this
4322 -- iteration itself i check if the incompatible functions accessible
4323 -- to the responsibility is excluded via menu exclusion.I check only
4327 -- The process completes quicker than the earlier
4324 -- functions accessible to the responsibility (Not all) and when iam done
4325 -- verifing these function, i come out of the PROCESS_MENU_TREE_DOWN_FOR_CST
4326 -- procedure
4328 listkey :=G_PNTL_RESP_VIO_LIST.FIRST;
4329 WHILE listkey IS NOT NULL
4330 LOOP
4331 -- Clearing the list
4332 G_UNEXCL_FUNC_ID_LIST.delete();
4333 G_UNEXCL_GRP_CODE_LIST.delete();
4334 l_excl_func_list.delete();
4335 l_excl_func_id_list.delete();
4336 L_FUNC_ID_LIST.delete();
4337 L_RESPVIO_ENTRIES.delete();
4338
4339 L_FUNC_ID_LIST := G_PNTL_RESP_VIO_LIST(listkey);
4340 L_RESPVIO_ENTRIES := L_FUNC_ID_LIST(L_FUNC_ID_LIST.FIRST);
4341 l_appl_id := L_RESPVIO_ENTRIES(1).application_id;
4342 l_resp_id := L_RESPVIO_ENTRIES(1).Responsibility_id;
4343 l_menu_id := L_RESPVIO_ENTRIES(1).Menu_id;
4344
4345 /*FND_FILE.put_line(fnd_file.log,'l_appl_id '||l_appl_id);
4346 FND_FILE.put_line(fnd_file.log,'l_resp_id '||l_resp_id);
4347 FND_FILE.put_line(fnd_file.log,'l_menu_id '||l_menu_id); */
4348
4349 OPEN excl_func_c FOR l_excl_func_dynamic_sql USING
4350 l_appl_id, l_resp_id;
4351 FETCH excl_func_c BULK COLLECT INTO l_excl_func_id_list;
4352 CLOSE excl_func_c;
4353
4354 IF ((l_excl_func_id_list IS NOT NULL) and (l_excl_func_id_list.FIRST IS NOT NULL)) THEN
4355
4356 -- l_excl_func_id_list holds the excluded function list.
4357 -- To check if a incompatible function is excluded i need to loop
4358 -- through l_excl_func_id_list .
4359 -- But looping once for each incompatible function will be time consuming
4360 -- So i put the l_excl_func_id_list data in a associative array and then
4361 -- fetch the data using function id as index from l_excl_func_list
4362 FOR j IN l_excl_func_id_list.FIRST .. l_excl_func_id_list.LAST
4363 LOOP
4364 l_excl_func_list(l_excl_func_id_list(j)):=l_excl_func_id_list(j);
4365 END LOOP;
4366
4367 -- We populate the unexcluded incompatible function details in G_UNEXCL_FUNC_ID_LIST
4368 -- G_UNEXCL_GRP_CODE_LIST
4369 -- L_FUNC_ID_LIST contains all the incompatible functions accessible
4370 -- by a responsibility
4371 -- we check if the function is excluded via function exclusion
4372 -- if no, then we put the function in unexcluded list G_UNEXCL_XXXXX
4373 -- A function can be from Set 1 or set 2, So we use Function_id@set
4374 -- as key for G_UNEXCL_XXXXX
4375 FOR j IN L_FUNC_ID_LIST.FIRST .. L_FUNC_ID_LIST.LAST
4376 LOOP
4377 IF L_FUNC_ID_LIST.EXISTS(j) THEN
4378 IF (NOT l_excl_func_list.exists(j)) THEN
4379 L_RESPVIO_ENTRIES := L_FUNC_ID_LIST(j);
4380 FOR k in L_RESPVIO_ENTRIES.FIRST .. L_RESPVIO_ENTRIES.LAST
4381 LOOP
4382 lkey := L_RESPVIO_ENTRIES(k).Function_Id||'@'||L_RESPVIO_ENTRIES(k).group_code;
4383 G_UNEXCL_FUNC_ID_LIST(lkey) := L_RESPVIO_ENTRIES(k).Function_Id;
4384 G_UNEXCL_GRP_CODE_LIST(lkey):= L_RESPVIO_ENTRIES(k).group_code;
4385 END LOOP;
4386 END IF;
4387 END IF;
4388 END LOOP;
4389 ELSE
4390 -- None of the incompatible functions are excluded
4391
4392 -- We populate the unexcluded incompatible function details in G_UNEXCL_FUNC_ID_LIST
4393 -- G_UNEXCL_GRP_CODE_LIST
4394 -- L_FUNC_ID_LIST contains all the incompatible functions accessible
4395 -- by a responsibility
4396 -- A function can be from Set 1 or set 2, So we use Function_id@set
4397 -- as key for G_UNEXCL_XXXXX
4398 FOR j IN L_FUNC_ID_LIST.FIRST .. L_FUNC_ID_LIST.LAST
4399 LOOP
4400 IF L_FUNC_ID_LIST.EXISTS(j) THEN
4401 L_RESPVIO_ENTRIES := L_FUNC_ID_LIST(j);
4402 FOR k in L_RESPVIO_ENTRIES.FIRST .. L_RESPVIO_ENTRIES.LAST
4403 LOOP
4404 lkey := L_RESPVIO_ENTRIES(k).Function_Id||'@'||L_RESPVIO_ENTRIES(k).group_code;
4405 G_UNEXCL_FUNC_ID_LIST(lkey) := L_RESPVIO_ENTRIES(k).Function_Id;
4406 G_UNEXCL_GRP_CODE_LIST(lkey):= L_RESPVIO_ENTRIES(k).group_code;
4407 END LOOP;
4408 END IF;
4409 END LOOP;
4410 END IF;
4411
4412 /*FND_FILE.put_line(fnd_file.log,'*************************');
4413 lkey :=G_UNEXCL_FUNC_ID_LIST.FIRST;
4414 WHILE lkey IS NOT NULL
4415 LOOP
4416 FND_FILE.put_line(fnd_file.log,G_UNEXCL_FUNC_ID_LIST(lkey));
4417 lkey:=G_UNEXCL_FUNC_ID_LIST.NEXT(lkey);
4418 end loop;
4419 FND_FILE.put_line(fnd_file.log,'*************************');*/
4420
4421 -- we need to dig into the responsibility menu hierarchy when we have
4422 -- atleast one unexcluded incompatible function
4423 IF G_UNEXCL_FUNC_ID_LIST.FIRST IS NOT NULL THEN
4424 l_accessible := PROCESS_MENU_TREE_DOWN_FOR_CST(
4425 p_constraint_rev_id => p_constraint_rev_id,
4426 p_menu_id => l_menu_id,
4427 p_appl_id => l_appl_id,
4431 END LOOP; -- end of loop: l_ptnl_resps_id_list
4428 p_resp_id => l_resp_id);
4429 END IF;
4430 listkey:=G_PNTL_RESP_VIO_LIST.NEXT(listkey);
4432
4433 -- Deleteing the G_PNTL_RESP_VIO_LIST as we don't require it any more
4434 G_PNTL_RESP_VIO_LIST.delete();
4435 G_UNEXCL_FUNC_ID_LIST.delete();
4436 G_UNEXCL_GRP_CODE_LIST.delete();
4437
4438 --FND_FILE.put_line(fnd_file.log,'Potential Reposnibility End '||to_char(sysdate,'DD-MON-RRRR:HH24:MI:SS'));
4439
4440 /*
4441 -- Display the responsibility
4442 listkey :=G_RESP_VIOLATIONS_LIST.FIRST;
4443 WHILE listkey IS NOT NULL
4444 LOOP
4445 FND_FILE.put_line(fnd_file.log,'*********************************************************');
4446 FND_FILE.put_line(fnd_file.log,' Responsibility_id '||listkey);
4447 L_FUNC_ID_LIST:=G_RESP_VIOLATIONS_LIST(listkey);
4448 FOR j IN L_FUNC_ID_LIST.FIRST .. L_FUNC_ID_LIST.LAST
4449 LOOP
4450 IF L_FUNC_ID_LIST.EXISTS(j) THEN
4451 L_RESPVIO_ENTRIES:=L_FUNC_ID_LIST(j);
4452 FOR k IN L_RESPVIO_ENTRIES.FIRST .. L_RESPVIO_ENTRIES.LAST
4453 LOOP
4454 -- FND_FILE.put_line(fnd_file.log,'Responsibility_id '||L_RESPVIO_ENTRIES(k).Responsibility_id);
4455 -- FND_FILE.put_line(fnd_file.log,'application_id '||L_RESPVIO_ENTRIES(k).application_id);
4456 FND_FILE.put_line(fnd_file.log,' Menu_id '||L_RESPVIO_ENTRIES(k).Menu_id);
4457 FND_FILE.put_line(fnd_file.log,' Function_Id '||L_RESPVIO_ENTRIES(k).Function_Id);
4458 FND_FILE.put_line(fnd_file.log,' Object_Type '||L_RESPVIO_ENTRIES(k).Object_Type);
4459 FND_FILE.put_line(fnd_file.log,' group_code '||L_RESPVIO_ENTRIES(k).group_code);
4460 FND_FILE.put_line(fnd_file.log,' ');
4461 END LOOP;
4462 END IF;
4463 END LOOP;
4464 FND_FILE.put_line(fnd_file.log,'*********************************************************');
4465 listkey:=G_RESP_VIOLATIONS_LIST.NEXT(listkey);
4466 END LOOP;
4467 */
4468 --FND_FILE.put_line(fnd_file.log,'Comming out of '||L_API_NAME);
4469 -- FND_FILE.put_line(fnd_file.log,'Populate_Ptnl_Access_List End '||to_char(sysdate,'DD-MON-RRRR:HH24:MI:SS'));
4470 END Populate_Ptnl_Access_List;
4471
4472 -- ===============================================================
4473 -- Private Procedure name
4474 -- Write_Func_To_Table_For_User
4475 --
4476 -- Purpose
4477 -- Write global potential violation of specified user
4478 -- against specified constraint
4479 --
4480 -- Params
4481 -- p_constraint_rev_id := specified constraint_rev_id
4482 -- p_user_id := specified user_id
4483 --
4484 -- Notes
4485 -- when calling this procedure means it's gaurantee
4486 -- the specified user has violated the specified constraint
4487 --
4488 -- History
4489 -- 05.17.2005 tsho: starting from AMW.E, consider Role, GLOBAL Grant/USER Grant
4490 -- 05.23.2005 tsho: starting from AMW.E, Revalidation
4491 -- ===============================================================
4492 Procedure Write_Func_To_Table_For_User (
4493 p_violation_id IN NUMBER,
4494 p_constraint_rev_id IN NUMBER,
4495 p_user_id IN NUMBER,
4496 p_is_user_wavied IN VARCHAR2,
4497 p_revalidate_flag IN VARCHAR2 := NULL
4498 )
4499 IS
4500 L_API_NAME CONSTANT VARCHAR2(30) := 'Write_Func_To_Table_For_User';
4501 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
4502
4503 -- ptulasi : 18/02/2008
4504 -- bug : 6722113 : Added below cursor to get waived of responsibilities in
4505 -- this constraint
4506 CURSOR c_resp_waived (l_constraint_rev_id IN NUMBER) IS
4507 SELECT PK1,PK2
4508 FROM amw_constraint_waivers_b
4509 WHERE constraint_rev_id = l_constraint_rev_id
4510 AND object_type = 'RESP'
4511 AND start_date <= sysdate AND (end_date >= sysdate or end_date is null);
4512
4513 i NUMBER;
4514 idx NUMBER;
4515 l_party_id NUMBER;
4516
4517 -- store the user_violation_id getting from AMW_USER_VIOLATION_S
4518 l_user_violation_id NUMBER;
4519 l_row_id ROWID;
4520
4521 -- ptulasi : 18/02/2008
4522 -- bug : 6722113 : Added below plsql tables to store waived of responsibilities
4523 l_waiv_resp_id_list G_NUMBER_TABLE;
4524 l_waiv_resp_appl_id_list G_NUMBER_TABLE;
4525 l_waived_resp_appl_list G_NUMBER_TABLE_TYPE;
4526 listkey VARCHAR2(250);
4527
4528 -- get user_violation_id from AMW_USER_VIOLATION_S
4529 CURSOR c_user_violation_id IS
4530 SELECT AMW_USER_VIOLATION_S.NEXTVAL
4531 FROM dual;
4532
4533 l_is_user_waived VARCHAR2(1);
4534 L_USERVIO_ENTRIES G_USERVIO_ENTRIES_TABLE;
4535 L_FUNC_ID_LIST G_FUNCS_TABLE;
4536 BEGIN
4537 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
4538 l_is_user_waived := p_is_user_wavied;
4539
4540 -- find party_id with specified user_id
4541 BEGIN
4545 l_party_id := p_user_id;
4542 -- 01.02.2003 tsho: bug 3348191 - duplicated user shown
4543 -- because same party_id(person) maps to multiple user_id(login acct),
4544 -- thus store user_id directly rather party_id in AMW_VIOLATION_USERS
4546
4547 EXCEPTION
4548 WHEN no_data_found THEN
4549 null;
4550 END;
4551
4552 -- ptulasi : 18/02/2008
4553 -- bug : 6722113 : Added below code to not to display waived of responsibilities in
4554 -- the violation report
4555 -- Get the responsibilities marked as waiver for the current constraint in individual
4556 -- nested table.
4557 OPEN c_resp_waived (p_constraint_rev_id);
4558 FETCH c_resp_waived BULK COLLECT INTO l_waiv_resp_id_list,l_waiv_resp_appl_id_list;
4559 CLOSE c_resp_waived;
4560 IF (l_waiv_resp_id_list IS NOT NULL) AND (l_waiv_resp_id_list.FIRST IS NOT NULL) THEN
4561 FOR i IN l_waiv_resp_id_list.FIRST ..l_waiv_resp_id_list.LAST
4562 LOOP
4563 listkey:=l_waiv_resp_appl_id_list(i)||'@'||l_waiv_resp_id_list(i);
4564 l_waived_resp_appl_list(listkey):=l_waiv_resp_id_list(i);
4565 END LOOP;
4566 END IF;
4567
4568 IF (p_revalidate_flag IS NOT NULL AND p_revalidate_flag = 'Y') THEN
4569 IF (G_User_Violation_Id_list.exists(p_user_id)) THEN
4570 l_user_violation_id :=G_User_Violation_Id_list(p_user_id);
4571 DELETE FROM AMW_VIOLAT_USER_ENTRIES
4572 WHERE USER_VIOLATION_ID =l_user_violation_id;
4573
4574 -- ptulasi : 18-02-2008
4575 -- bug : 6689589 : If a responsibility violating the constraint is end dated, the staus for the
4576 -- user having this responsibility only should be shown as closed. But this is not happening. This is
4577 -- because the corrected_flag for the user is not set to yes. The query used to fetch the user and his
4578 -- responsibilities will not fetch the end dated responsibilities. So no action is taken against the
4579 -- user having responsibilities which violate the constraint.
4580 -- Updated the corrected_flag of all the violating users to yes. For the violating users,
4581 -- the corrected_flag will be set to no.
4582 UPDATE AMW_VIOLATION_USERS SET CORRECTED_FLAG = 'N'
4583 WHERE USER_VIOLATION_ID = l_user_violation_id;
4584 -- ptulasi : 18/02/2008
4585 -- bug : 6722113 : Added below condition to not to display waived of responsibilities in
4586 -- the violation report users tab
4587 IF l_is_user_waived = 'Y' THEN
4588 UPDATE AMW_VIOLATION_USERS SET WAIVED_FLAG = 'Y'
4589 WHERE USER_VIOLATION_ID = l_user_violation_id;
4590 END IF;
4591 END IF;
4592 ELSE
4593
4594 IF (G_User_Waiver_List.exists(p_user_id))THEN
4595 l_is_user_waived := 'Y';
4596 END IF;
4597
4598 -- get user_violation_id from AMW_USER_VIOLATION_S
4599 OPEN c_user_violation_id;
4600 FETCH c_user_violation_id INTO l_user_violation_id;
4601 CLOSE c_user_violation_id;
4602
4603 AMW_VIOLATION_USERS_PKG.insert_row(x_rowid => l_row_id,
4604 x_user_violation_id => l_user_violation_id,
4605 x_violation_id => p_violation_id,
4606 x_violated_by_id => l_party_id,
4607 x_last_updated_by => G_USER_ID,
4608 x_last_update_date => SYSDATE,
4609 x_created_by => G_USER_ID,
4610 x_creation_date => SYSDATE,
4611 x_last_update_login => G_LOGIN_ID,
4612 x_security_group_id => NULL,
4613 x_waived_flag => l_is_user_waived);
4614
4615 END IF; -- end of if: p_revalidate_flag IS NOT NULL
4616
4617 L_FUNC_ID_LIST:=G_USER_VIOLATIONS_LIST(p_user_id);
4618 FOR j IN L_FUNC_ID_LIST.FIRST .. L_FUNC_ID_LIST.LAST
4619 LOOP
4620 IF L_FUNC_ID_LIST.EXISTS(j) THEN
4621 L_USERVIO_ENTRIES:=L_FUNC_ID_LIST(j);
4622 FOR k IN L_USERVIO_ENTRIES.FIRST .. L_USERVIO_ENTRIES.LAST
4623 LOOP
4624 -- ptulasi : 18/02/2008
4625 -- bug : 6722113 : Added below condition to not to display waived of responsibilities in
4626 -- the violation report
4627 listkey := L_USERVIO_ENTRIES(k).application_id||'@'||L_USERVIO_ENTRIES(k).Responsibility_id;
4628 IF (((l_is_user_waived IS NULL OR l_is_user_waived <> 'Y')
4629 AND (NOT l_waived_resp_appl_list.exists(listkey))) OR (l_is_user_waived = 'Y')) THEN
4630 INSERT INTO AMW_VIOLAT_USER_ENTRIES(
4631 LAST_UPDATE_DATE,
4632 LAST_UPDATED_BY,
4633 LAST_UPDATE_LOGIN,
4634 CREATION_DATE,
4635 CREATED_BY,
4636 SECURITY_GROUP_ID,
4637 USER_VIOLATION_ID,
4638 RESPONSIBILITY_ID,
4639 MENU_ID,
4640 FUNCTION_ID,
4641 ACCESS_GIVEN_DATE,
4642 ACCESS_GIVEN_BY_ID,
4643 ROLE_NAME,
4644 OBJECT_TYPE,
4645 APPLICATION_ID,
4646 PROGRAM_APPLICATION_ID)
4650 G_LOGIN_ID, -- last_update_login
4647 VALUES (
4648 SYSDATE, -- last_update_date
4649 G_USER_ID, -- last_updated_by
4651 SYSDATE, -- creation_date
4652 G_USER_ID, -- created_by
4653 NULL, -- security_group_id
4654 l_user_violation_id, -- user_violation_id
4655 L_USERVIO_ENTRIES(k).Responsibility_id ,-- responsibility_id
4656 L_USERVIO_ENTRIES(k).Menu_id, -- menu_id
4657 L_USERVIO_ENTRIES(k).Function_Id , -- function_id
4658 L_USERVIO_ENTRIES(k).Access_Given_Date, -- access_given_date
4659 L_USERVIO_ENTRIES(k).Access_Given_By_Id,-- access_given_by_id
4660 L_USERVIO_ENTRIES(k).Role_Name, -- role_name
4661 L_USERVIO_ENTRIES(k).Object_Type, -- object_type
4662 L_USERVIO_ENTRIES(k).application_id , -- application_id
4663 L_USERVIO_ENTRIES(k).prog_appl_id ); -- program application id
4664 END IF;
4665 END LOOP;
4666 END IF;
4667 END LOOP;
4668 END Write_Func_To_Table_For_User;
4669
4670
4671 -- ===============================================================
4672 -- Private Procedure name
4673 -- Write_Resp_To_Table_For_User
4674 --
4675 -- Purpose
4676 -- Write global potential violation of specified user
4677 -- against specified constraint
4678 --
4679 -- Params
4680 -- p_constraint_rev_id := specified constraint_rev_id
4681 -- p_user_id := specified user_id
4682 --
4683 -- Notes
4684 -- when calling this procedure means it's gaurantee
4685 -- the specified user has violated the specified constraint
4686 --
4687 -- History
4688 -- 05.17.2005 tsho: starting from AMW.E, add column: ROLE_NAME to AMW_VIOLAT_USER_ENTRIES
4689 -- 05.23.2005 tsho: starting from AMW.E, Revalidation
4690 -- ===============================================================
4691 Procedure Write_Resp_To_Table_For_User (
4692 p_violation_id IN NUMBER,
4693 p_constraint_rev_id IN NUMBER,
4694 p_user_id IN NUMBER,
4695 p_revalidate_flag IN VARCHAR2 := NULL
4696 )
4697 IS
4698 L_API_NAME CONSTANT VARCHAR2(30) := 'Write_Resp_To_Table_For_User';
4699 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
4700
4701 i NUMBER;
4702 idx NUMBER;
4703 l_party_id NUMBER;
4704
4705 -- store the user_violation_id getting from AMW_USER_VIOLATION_S
4706 l_user_violation_id NUMBER;
4707 l_row_id ROWID;
4708
4709 l_is_user_waived VARCHAR2(1);
4710 L_USERVIO_ENTRIES G_USERVIO_ENTRIES_TABLE;
4711 L_RESP_ID_LIST G_RESPS_TABLE;
4712 listkey VARCHAR2(30) := NULL;
4713
4714 -- get user_violation_id from AMW_USER_VIOLATION_S
4715 CURSOR c_user_violation_id IS
4716 SELECT AMW_USER_VIOLATION_S.NEXTVAL
4717 FROM dual;
4718 BEGIN
4719 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
4720 l_is_user_waived := NULL;
4721
4722 -- find party_id with specified user_id
4723 BEGIN
4724 -- 01.02.2003 tsho: bug 3348191 - duplicated user shown
4725 -- because same party_id(person) maps to multiple user_id(login acct),
4726 -- thus store user_id directly rather party_id in AMW_VIOLATION_USERS
4727 l_party_id := p_user_id;
4728
4729 EXCEPTION
4730 WHEN no_data_found THEN
4731 null;
4732 END;
4733
4734 IF (p_revalidate_flag IS NOT NULL AND p_revalidate_flag = 'Y') THEN
4735 IF (G_User_Violation_Id_list.exists(p_user_id)) THEN
4736 l_user_violation_id :=G_User_Violation_Id_list(p_user_id);
4737 DELETE FROM AMW_VIOLAT_USER_ENTRIES
4738 WHERE USER_VIOLATION_ID = l_user_violation_id;
4739
4740 -- ptulasi : 18-02-2008
4741 -- bug : 6689589 : If a responsibility violating the constraint is end dated, the staus for the
4742 -- user having this responsibility only should be shown as closed. But this is not happening. This is
4743 -- because the corrected_flag for the user is not set to yes. The query used to fetch the user and his
4744 -- responsibilities will not fetch the end dated responsibilities. So no action is taken against the
4745 -- user having responsibilities which violate the constraint.
4746 -- Updated the corrected_flag of all the violating users to yes. For the violating users,
4747 -- the corrected_flag will be set to no.
4748 UPDATE AMW_VIOLATION_USERS SET CORRECTED_FLAG = 'N'
4749 WHERE USER_VIOLATION_ID = l_user_violation_id;
4750
4751 END IF;
4752
4753 ELSE
4754 IF (G_User_Waiver_List.exists(p_user_id))THEN
4755 l_is_user_waived := 'Y';
4756 END IF;
4757
4761 CLOSE c_user_violation_id;
4758 -- get user_violation_id from AMW_USER_VIOLATION_S
4759 OPEN c_user_violation_id;
4760 FETCH c_user_violation_id INTO l_user_violation_id;
4762
4763 AMW_VIOLATION_USERS_PKG.insert_row(x_rowid => l_row_id,
4764 x_user_violation_id => l_user_violation_id,
4765 x_violation_id => p_violation_id,
4766 x_violated_by_id => l_party_id,
4767 x_last_updated_by => G_USER_ID,
4768 x_last_update_date => SYSDATE,
4769 x_created_by => G_USER_ID,
4770 x_creation_date => SYSDATE,
4771 x_last_update_login => G_LOGIN_ID,
4772 x_security_group_id => NULL,
4773 x_waived_flag => l_is_user_waived);
4774 END IF; -- end of if: p_revalidate_flag IS NOT NULL
4775
4776 L_RESP_ID_LIST:=G_USER_RESP_VIO_LIST(p_user_id);
4777
4778 listkey :=L_RESP_ID_LIST.FIRST;
4779 WHILE listkey IS NOT NULL
4780 LOOP
4781 L_USERVIO_ENTRIES:=L_RESP_ID_LIST(listkey);
4782 FOR k IN L_USERVIO_ENTRIES.FIRST .. L_USERVIO_ENTRIES.LAST
4783 LOOP
4784 INSERT INTO AMW_VIOLAT_USER_ENTRIES(
4785 LAST_UPDATE_DATE,
4786 LAST_UPDATED_BY,
4787 LAST_UPDATE_LOGIN,
4788 CREATION_DATE,
4789 CREATED_BY,
4790 SECURITY_GROUP_ID,
4791 USER_VIOLATION_ID,
4792 RESPONSIBILITY_ID,
4793 MENU_ID,
4794 FUNCTION_ID,
4795 ACCESS_GIVEN_DATE,
4796 ACCESS_GIVEN_BY_ID,
4797 ROLE_NAME,
4798 OBJECT_TYPE,
4799 APPLICATION_ID,
4800 PROGRAM_APPLICATION_ID)
4801 VALUES (
4802 SYSDATE, -- last_update_date
4803 G_USER_ID, -- last_updated_by
4804 G_LOGIN_ID, -- last_update_login
4805 SYSDATE, -- creation_date
4806 G_USER_ID, -- created_by
4807 NULL, -- security_group_id
4808 l_user_violation_id, -- user_violation_id
4809 L_USERVIO_ENTRIES(k).Responsibility_id ,-- responsibility_id
4810 NULL, -- menu_id
4811 NULL, -- function_id
4812 L_USERVIO_ENTRIES(k).Access_Given_Date, -- access_given_date
4813 L_USERVIO_ENTRIES(k).Access_Given_By_Id,-- access_given_by_id
4814 NULL, -- role_name
4815 'RESP', -- object_type
4816 L_USERVIO_ENTRIES(k).application_id, -- application_id
4817 NULL); -- program application id
4818 END LOOP;
4819 listkey:=L_RESP_ID_LIST.NEXT(listkey);
4820 END LOOP;
4821 END Write_Resp_To_Table_For_User;
4822
4823 -- ===============================================================
4824 -- Private Procedure name
4825 -- Wtite_Resp_Violat_to_table
4826 --
4827 -- Purpose
4828 -- Write the violating responsibility to the Table
4829 -- AMW_Violation_RESP,AMW_VIOLAT_RESP_ENTRIES
4830 --
4831 -- Params
4832 -- p_violation_id := specified violation id
4833 -- p_constraint_rev_id := specified constraint_rev_id
4834 -- p_type_code := specified constraint object type
4835 -- Notes
4836 --
4837 -- History
4838 -- ===============================================================
4839
4840 Procedure Write_Resp_Violat_to_table (
4841 p_violation_id IN NUMBER,
4842 p_constraint_rev_id IN NUMBER,
4843 p_type_code IN VARCHAR2
4844 )
4845 IS
4846
4847 CURSOR c_constraint_entries (l_constraint_rev_id IN NUMBER) IS
4848 SELECT function_id,object_type,group_code
4849 FROM amw_constraint_entries
4850 WHERE constraint_rev_id=l_constraint_rev_id;
4851
4852 CURSOR c_resp_violation_id IS
4853 SELECT AMW_VIOLATION_RESP_S.NEXTVAL
4854 FROM dual;
4855
4856 CURSOR c_resp_waived (l_constraint_rev_id IN NUMBER) IS
4857 SELECT PK1,PK2
4858 FROM amw_constraint_waivers_b
4859 WHERE constraint_rev_id = l_constraint_rev_id
4860 AND object_type = 'RESP'
4861 AND start_date <= sysdate AND (end_date >= sysdate or end_date is null);
4862
4863 TYPE NumberTable IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
4864
4865 l_constraint_function_id NUMBER;
4866 l_resp_violation_id NUMBER;
4867 l_is_resp_waived VARCHAR2(1);
4868 l_is_resp_waived_count NUMBER;
4872 l_waived_resp_appl_list G_NUMBER_TABLE_TYPE;
4869 l_function_id_list G_NUMBER_TABLE;
4870 l_waiv_resp_id_list G_NUMBER_TABLE;
4871 l_waiv_resp_appl_id_list G_NUMBER_TABLE;
4873
4874 L_OBJECT_TYPE_LIST G_VARCHAR2_CODE_TABLE;
4875 L_GROUP_CODE_LIST G_VARCHAR2_CODE_TABLE;
4876 L_AVAILABLE_GROUP_CODE_LIST G_VARCHAR2_CODE_TABLE;
4877 L_RESPVIO_ENTRIES G_RESPVIO_ENTRIES_TABLE;
4878
4879 L_API_NAME CONSTANT VARCHAR2(30) := 'Wtite_Resp_Violat_to_table';
4880 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
4881
4882 -- psomanat : 06:09:2006 : fix for bug 5256720
4883 L_FUNC_ID_LIST G_FUNC_TABLE;
4884 counts Number;
4885 listkey VARCHAR2(30) := NULL;
4886 BEGIN
4887 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
4888 --FND_FILE.put_line(fnd_file.log,'Wtite_Resp_Violat_to_table start '||to_char(sysdate,'DD-MON-RRRR:HH24:MI:SS'));
4889
4890 IF (G_RESP_VIOLATIONS_LIST.COUNT = 0) THEN
4891 RETURN;
4892 END IF;
4893
4894 -- Collect all the constraint entries details
4895 OPEN c_constraint_entries (p_constraint_rev_id);
4896 FETCH c_constraint_entries BULK COLLECT INTO l_function_id_list,L_OBJECT_TYPE_LIST,L_GROUP_CODE_LIST;
4897 CLOSE c_constraint_entries;
4898
4899 -- Get the responsibilities marked as waiver for the current constraint in individual
4900 -- nested table.
4901 -- To identify a responsibility in the nested table we need to iterate over it.
4902 -- This will be time consuming
4903 -- So we store the details in an associative array with application_id@responsbility_id
4904 -- as key. Now given a responsibility and application id we can easily find out if
4905 -- the responsibility is waived or not .
4906 OPEN c_resp_waived (p_constraint_rev_id);
4907 FETCH c_resp_waived BULK COLLECT INTO l_waiv_resp_id_list,l_waiv_resp_appl_id_list;
4908 CLOSE c_resp_waived;
4909
4910 IF (l_waiv_resp_id_list IS NOT NULL) AND (l_waiv_resp_id_list.FIRST IS NOT NULL) THEN
4911 FOR i IN l_waiv_resp_id_list.FIRST ..l_waiv_resp_id_list.LAST
4912 LOOP
4913 listkey:=l_waiv_resp_appl_id_list(i)||'@'||l_waiv_resp_id_list(i);
4914 l_waived_resp_appl_list(listkey):=l_waiv_resp_id_list(i);
4915 END LOOP;
4916 END IF;
4917
4918 -- Logic :
4919 -- G_RESP_VIOLATIONS_LIST holds the responsibilities and the incompatible functions
4920 -- accessible from it
4921 -- Here we identify if the responsibility violates a constraint. The check
4922 -- is based on the object type
4923 -- If the object type = ALL , we check if the responsibility have access to all
4924 -- incompatible function
4925 -- If the Object type = ME, we check if the responsibility have access to atleast
4926 -- 2 incompatible function
4927 -- If the Object type = Set, we check if the responsibility have access to atleast
4928 -- 1 incompatible function from each group
4929 -- During this process we populate 2 tables AMW_VIOLATION_RESP,AMW_VIOLAT_RESP_ENTRIES
4930 -- We put responibility specific details in AMW_VIOLATION_RESP and
4931 -- the functions accessible to a responsibility in AMW_VIOLAT_RESP_ENTRIES
4932 listkey :=G_RESP_VIOLATIONS_LIST.FIRST;
4933 WHILE listkey IS NOT NULL
4934 LOOP
4935 L_RESPVIO_ENTRIES.DELETE();
4936 L_FUNC_ID_LIST.DELETE();
4937
4938 L_FUNC_ID_LIST :=G_RESP_VIOLATIONS_LIST(listkey);
4939
4940 IF p_type_code = 'ALL' AND L_FUNC_ID_LIST.COUNT = l_function_id_list.COUNT THEN
4941
4942 OPEN c_resp_violation_id;
4943 FETCH c_resp_violation_id INTO l_resp_violation_id;
4944 CLOSE c_resp_violation_id;
4945
4946 l_is_resp_waived :='N';
4947 l_is_resp_waived_count := 0;
4948
4949 L_RESPVIO_ENTRIES:=L_FUNC_ID_LIST(L_FUNC_ID_LIST.FIRST);
4950 IF (NOT l_waived_resp_appl_list.exists(listkey)) THEN
4951
4952 /*FND_FILE.put_line(fnd_file.log,'***************Responsibility Violation All************* ');
4953 FND_FILE.put_line(fnd_file.log,' RESP_VIOLATION_ID :'||l_resp_violation_id);
4954 FND_FILE.put_line(fnd_file.log,' VIOLATION_ID :'||P_VIOLATION_ID);
4955 FND_FILE.put_line(fnd_file.log,' RESPONSIBILITY_ID :'||L_RESPVIO_ENTRIES(1).Responsibility_id);
4956 FND_FILE.put_line(fnd_file.log,' APPLICATION_ID :'||L_RESPVIO_ENTRIES(1).application_id);
4957 FND_FILE.put_line(fnd_file.log,' WAIVED_FLAG :'||l_is_resp_waived);
4958 FND_FILE.put_line(fnd_file.log,' CORRECTED_FLAG :'||'N');*/
4959 INSERT INTO AMW_VIOLATION_RESP(
4960 RESP_VIOLATION_ID,
4961 VIOLATION_ID,
4962 RESPONSIBILITY_ID,
4963 APPLICATION_ID,
4964 ROLE_NAME,
4965 WAIVED_FLAG,
4966 CORRECTED_FLAG,
4967 LAST_UPDATE_DATE,
4968 LAST_UPDATED_BY,
4969 LAST_UPDATE_LOGIN,
4970 CREATION_DATE,
4971 CREATED_BY,
4972 SECURITY_GROUP_ID
4973 )
4974 VALUES(
4975 l_resp_violation_id,
4976 P_VIOLATION_ID,
4977 L_RESPVIO_ENTRIES(1).Responsibility_id,
4978 L_RESPVIO_ENTRIES(1).application_id,
4979 null,
4980 l_is_resp_waived,
4981 'N',
4985 sysdate,
4982 sysdate,
4983 G_USER_ID,
4984 G_LOGIN_ID,
4986 G_USER_ID,
4987 null
4988 );
4989
4990 FOR j IN L_FUNC_ID_LIST.FIRST .. L_FUNC_ID_LIST.LAST
4991 LOOP
4992 IF L_FUNC_ID_LIST.EXISTS(j) then
4993 L_RESPVIO_ENTRIES:=L_FUNC_ID_LIST(j);
4994
4995 --FND_FILE.put_line(fnd_file.log,'---------------- Responsibility Violation Entries -----------');
4996 FOR k IN L_RESPVIO_ENTRIES.FIRST .. L_RESPVIO_ENTRIES.LAST
4997 LOOP
4998 /* FND_FILE.put_line(fnd_file.log,' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
4999 FND_FILE.put_line(fnd_file.log,' RESP_VIOLATION_ID :'||l_resp_violation_id);
5000 FND_FILE.put_line(fnd_file.log,' MENU_ID :'||L_RESPVIO_ENTRIES(k).Menu_Id);
5001 FND_FILE.put_line(fnd_file.log,' FUNCTION_ID :'||L_RESPVIO_ENTRIES(k).Function_id);
5002 FND_FILE.put_line(fnd_file.log,' ACCESS_GIVEN_DATE :'||L_RESPVIO_ENTRIES(k).Access_Given_Date);
5003 FND_FILE.put_line(fnd_file.log,' ACCESS_GIVEN_BY_ID :'||L_RESPVIO_ENTRIES(k).Access_Given_By_Id);
5004 FND_FILE.put_line(fnd_file.log,' OBJECT_TYPE :'||L_RESPVIO_ENTRIES(k).Object_type);
5005 FND_FILE.put_line(fnd_file.log,' APPLICATION_ID :'||L_RESPVIO_ENTRIES(k).prog_appl_id);
5006 FND_FILE.put_line(fnd_file.log,' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'); */
5007
5008 INSERT INTO AMW_VIOLAT_RESP_ENTRIES(
5009 VIOLAT_RESP_ENTRY_ID,
5010 RESP_VIOLATION_ID,
5011 MENU_ID,
5012 FUNCTION_ID,
5013 ACCESS_GIVEN_DATE,
5014 ACCESS_GIVEN_BY_ID,
5015 OBJECT_TYPE,
5016 LAST_UPDATE_DATE,
5017 LAST_UPDATED_BY,
5018 LAST_UPDATE_LOGIN,
5019 CREATION_DATE,
5020 CREATED_BY,
5021 SECURITY_GROUP_ID,
5022 APPLICATION_ID
5023 )
5024 VALUES(
5025 AMW_VIOLAT_RESP_ENTRIES_S.NEXTVAL,
5026 l_resp_violation_id,
5027 L_RESPVIO_ENTRIES(k).Menu_Id,
5028 L_RESPVIO_ENTRIES(k).Function_id,
5029 L_RESPVIO_ENTRIES(k).Access_Given_Date,
5030 L_RESPVIO_ENTRIES(k).Access_Given_By_Id,
5031 L_RESPVIO_ENTRIES(k).Object_type,
5032 sysdate,
5033 G_USER_ID,
5034 G_LOGIN_ID,
5035 sysdate,
5036 G_USER_ID,
5037 NULL,
5038 L_RESPVIO_ENTRIES(k).prog_appl_id
5039 );
5040 END LOOP;
5041 END IF;
5042 END LOOP;
5043 END IF;
5044 ELSIF p_type_code = 'ME' AND L_FUNC_ID_LIST.COUNT >= 2 THEN
5045
5046
5047 --dbms_output.put_line('In ME');
5048 OPEN c_resp_violation_id;
5049 FETCH c_resp_violation_id INTO l_resp_violation_id;
5050 CLOSE c_resp_violation_id;
5051
5052 L_RESPVIO_ENTRIES:=L_FUNC_ID_LIST(L_FUNC_ID_LIST.FIRST);
5053
5054 l_is_resp_waived :='N';
5055 l_is_resp_waived_count:= 0;
5056
5057
5058 IF (NOT l_waived_resp_appl_list.exists(listkey)) THEN
5059 /*FND_FILE.put_line(fnd_file.log,'***************Responsibility Violation ME************* ');
5060 FND_FILE.put_line(fnd_file.log,' RESP_VIOLATION_ID :'||l_resp_violation_id);
5061 FND_FILE.put_line(fnd_file.log,' VIOLATION_ID :'||P_VIOLATION_ID);
5062 FND_FILE.put_line(fnd_file.log,' RESPONSIBILITY_ID :'||L_RESPVIO_ENTRIES(1).Responsibility_id);
5063 FND_FILE.put_line(fnd_file.log,' APPLICATION_ID :'||L_RESPVIO_ENTRIES(1).application_id);
5064 FND_FILE.put_line(fnd_file.log,' WAIVED_FLAG :'||l_is_resp_waived);
5065 FND_FILE.put_line(fnd_file.log,' CORRECTED_FLAG :'||'N'); */
5066
5067 INSERT INTO AMW_VIOLATION_RESP(
5068 RESP_VIOLATION_ID,
5069 VIOLATION_ID,
5070 RESPONSIBILITY_ID,
5071 APPLICATION_ID,
5072 ROLE_NAME,
5073 WAIVED_FLAG,
5074 CORRECTED_FLAG,
5075 LAST_UPDATE_DATE,
5076 LAST_UPDATED_BY,
5077 LAST_UPDATE_LOGIN,
5078 CREATION_DATE,
5079 CREATED_BY,
5080 SECURITY_GROUP_ID
5081 )
5082 VALUES(
5083 l_resp_violation_id,
5084 P_VIOLATION_ID,
5085 L_RESPVIO_ENTRIES(1).Responsibility_id,
5086 L_RESPVIO_ENTRIES(1).application_id,
5087 null,
5088 l_is_resp_waived,
5089 'N',
5090 sysdate,
5091 G_USER_ID,
5092 G_LOGIN_ID,
5093 sysdate,
5094 G_USER_ID,
5095 null
5096 );
5097
5098 FOR j IN L_FUNC_ID_LIST.FIRST .. L_FUNC_ID_LIST.LAST
5099 LOOP
5100 IF L_FUNC_ID_LIST.EXISTS(j) then
5101 L_RESPVIO_ENTRIES:=L_FUNC_ID_LIST(j);
5102 --FND_FILE.put_line(fnd_file.log,'---------------- Responsibility Violation Entries -----------');
5103 FOR k IN L_RESPVIO_ENTRIES.FIRST .. L_RESPVIO_ENTRIES.LAST
5104 LOOP
5105 /*FND_FILE.put_line(fnd_file.log,' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
5106 FND_FILE.put_line(fnd_file.log,' RESP_VIOLATION_ID :'||l_resp_violation_id);
5107 FND_FILE.put_line(fnd_file.log,' MENU_ID :'||L_RESPVIO_ENTRIES(k).Menu_Id);
5108 FND_FILE.put_line(fnd_file.log,' FUNCTION_ID :'||L_RESPVIO_ENTRIES(k).Function_id);
5109 FND_FILE.put_line(fnd_file.log,' ACCESS_GIVEN_DATE :'||L_RESPVIO_ENTRIES(k).Access_Given_Date);
5110 FND_FILE.put_line(fnd_file.log,' ACCESS_GIVEN_BY_ID :'||L_RESPVIO_ENTRIES(k).Access_Given_By_Id);
5111 FND_FILE.put_line(fnd_file.log,' OBJECT_TYPE :'||L_RESPVIO_ENTRIES(k).Object_type);
5112 FND_FILE.put_line(fnd_file.log,' APPLICATION_ID :'||L_RESPVIO_ENTRIES(k).prog_appl_id);
5113 FND_FILE.put_line(fnd_file.log,' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'); */
5114
5115 INSERT INTO AMW_VIOLAT_RESP_ENTRIES(
5116 VIOLAT_RESP_ENTRY_ID,
5117 resp_violation_id,
5118 MENU_ID,
5119 FUNCTION_ID,
5120 ACCESS_GIVEN_DATE,
5121 ACCESS_GIVEN_BY_ID,
5122 OBJECT_TYPE,
5123 LAST_UPDATE_DATE,
5124 LAST_UPDATED_BY,
5125 LAST_UPDATE_LOGIN,
5126 CREATION_DATE,
5127 CREATED_BY,
5128 SECURITY_GROUP_ID,
5129 APPLICATION_ID
5130 )
5131 VALUES(
5132 AMW_VIOLAT_RESP_ENTRIES_S.NEXTVAL,
5133 l_resp_violation_id,
5134 L_RESPVIO_ENTRIES(k).Menu_Id,
5135 L_RESPVIO_ENTRIES(k).Function_id,
5136 L_RESPVIO_ENTRIES(k).Access_Given_Date,
5137 L_RESPVIO_ENTRIES(k).Access_Given_By_Id,
5138 L_RESPVIO_ENTRIES(k).Object_type,
5139 sysdate,
5140 G_USER_ID,
5141 G_LOGIN_ID,
5142 sysdate,
5143 G_USER_ID,
5144 NULL,
5145 L_RESPVIO_ENTRIES(k).prog_appl_id );
5146 END LOOP;
5147 END IF;
5148 END LOOP;
5149 END IF;
5150 ELSIF p_type_code = 'SET' THEN
5151
5152 L_AVAILABLE_GROUP_CODE_LIST.delete();
5153
5154 FOR j IN L_FUNC_ID_LIST.FIRST .. L_FUNC_ID_LIST.LAST
5155 LOOP
5156 IF L_FUNC_ID_LIST.EXISTS(j) then
5157 L_RESPVIO_ENTRIES:=L_FUNC_ID_LIST(j);
5158 FOR k IN L_RESPVIO_ENTRIES.FIRST .. L_RESPVIO_ENTRIES.LAST
5159 LOOP
5163 END IF;
5160 L_AVAILABLE_GROUP_CODE_LIST(L_RESPVIO_ENTRIES(k).group_code):= L_RESPVIO_ENTRIES(k).group_code;
5161 IF L_AVAILABLE_GROUP_CODE_LIST.COUNT >=2 THEN
5162 EXIT;
5164 END LOOP;
5165 END IF;
5166 END LOOP;
5167
5168 IF (L_AVAILABLE_GROUP_CODE_LIST.COUNT)>=2 THEN
5169
5170 OPEN c_resp_violation_id;
5171 FETCH c_resp_violation_id INTO l_resp_violation_id;
5172 CLOSE c_resp_violation_id;
5173
5174 L_RESPVIO_ENTRIES:=L_FUNC_ID_LIST(L_FUNC_ID_LIST.FIRST);
5175
5176 l_is_resp_waived := 'N';
5177 l_is_resp_waived_count:= 0;
5178
5179 IF (NOT l_waived_resp_appl_list.exists(listkey)) THEN
5180 /* FND_FILE.put_line(fnd_file.log,'***************Responsibility Violation SET************* ');
5181 FND_FILE.put_line(fnd_file.log,' RESP_VIOLATION_ID :'||l_resp_violation_id);
5182 FND_FILE.put_line(fnd_file.log,' VIOLATION_ID :'||P_VIOLATION_ID);
5183 FND_FILE.put_line(fnd_file.log,' RESPONSIBILITY_ID :'||L_RESPVIO_ENTRIES(1).Responsibility_id);
5184 FND_FILE.put_line(fnd_file.log,' APPLICATION_ID :'||L_RESPVIO_ENTRIES(1).application_id);
5185 FND_FILE.put_line(fnd_file.log,' WAIVED_FLAG :'||l_is_resp_waived);
5186 FND_FILE.put_line(fnd_file.log,' CORRECTED_FLAG :'||'N');*/
5187
5188 INSERT INTO AMW_VIOLATION_RESP(
5189 RESP_VIOLATION_ID,
5190 VIOLATION_ID,
5191 RESPONSIBILITY_ID,
5192 APPLICATION_ID,
5193 ROLE_NAME,
5194 WAIVED_FLAG,
5195 CORRECTED_FLAG,
5196 LAST_UPDATE_DATE,
5197 LAST_UPDATED_BY,
5198 LAST_UPDATE_LOGIN,
5199 CREATION_DATE,
5200 CREATED_BY,
5201 SECURITY_GROUP_ID
5202 )
5203 VALUES(
5204 l_resp_violation_id,
5205 P_VIOLATION_ID,
5206 L_RESPVIO_ENTRIES(1).Responsibility_id,
5207 L_RESPVIO_ENTRIES(1).application_id,
5208 null,
5209 l_is_resp_waived,
5210 'N',
5211 sysdate,
5212 G_USER_ID,
5213 G_LOGIN_ID,
5214 sysdate,
5215 G_USER_ID,
5216 null
5217 );
5218
5219 FOR j IN L_FUNC_ID_LIST.FIRST .. L_FUNC_ID_LIST.LAST
5220 LOOP
5221 IF L_FUNC_ID_LIST.EXISTS(j) then
5222 L_RESPVIO_ENTRIES:=L_FUNC_ID_LIST(j);
5223 --FND_FILE.put_line(fnd_file.log,'---------------- Responsibility Violation Entries -----------');
5224
5225 FOR k IN L_RESPVIO_ENTRIES.FIRST .. L_RESPVIO_ENTRIES.LAST
5226 LOOP
5227 /* FND_FILE.put_line(fnd_file.log,' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
5228 FND_FILE.put_line(fnd_file.log,' RESP_VIOLATION_ID :'||l_resp_violation_id);
5229 FND_FILE.put_line(fnd_file.log,' MENU_ID :'||L_RESPVIO_ENTRIES(k).Menu_Id);
5230 FND_FILE.put_line(fnd_file.log,' FUNCTION_ID :'||L_RESPVIO_ENTRIES(k).Function_id);
5231 FND_FILE.put_line(fnd_file.log,' ACCESS_GIVEN_DATE :'||L_RESPVIO_ENTRIES(k).Access_Given_Date);
5232 FND_FILE.put_line(fnd_file.log,' ACCESS_GIVEN_BY_ID :'||L_RESPVIO_ENTRIES(k).Access_Given_By_Id);
5233 FND_FILE.put_line(fnd_file.log,' OBJECT_TYPE :'||L_RESPVIO_ENTRIES(k).Object_type);
5234 FND_FILE.put_line(fnd_file.log,' APPLICATION_ID :'||L_RESPVIO_ENTRIES(k).prog_appl_id);
5235 FND_FILE.put_line(fnd_file.log,' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');*/
5236
5237 INSERT INTO AMW_VIOLAT_RESP_ENTRIES(
5238 VIOLAT_RESP_ENTRY_ID,
5239 RESP_VIOLATION_ID,
5240 MENU_ID,
5241 FUNCTION_ID,
5242 ACCESS_GIVEN_DATE,
5243 ACCESS_GIVEN_BY_ID,
5244 OBJECT_TYPE,
5245 LAST_UPDATE_DATE,
5246 LAST_UPDATED_BY,
5247 LAST_UPDATE_LOGIN,
5248 CREATION_DATE,
5249 CREATED_BY,
5250 SECURITY_GROUP_ID,
5251 APPLICATION_ID
5252 )
5253 VALUES(
5254 AMW_VIOLAT_RESP_ENTRIES_S.NEXTVAL,
5255 l_resp_violation_id,
5256 L_RESPVIO_ENTRIES(k).Menu_Id,
5260 L_RESPVIO_ENTRIES(k).Object_type,
5257 L_RESPVIO_ENTRIES(k).Function_id,
5258 L_RESPVIO_ENTRIES(k).Access_Given_Date,
5259 L_RESPVIO_ENTRIES(k).Access_Given_By_Id,
5261 sysdate,
5262 G_USER_ID,
5263 G_LOGIN_ID,
5264 sysdate,
5265 G_USER_ID,
5266 NULL,
5267 L_RESPVIO_ENTRIES(k).prog_appl_id
5268 );
5269 END LOOP;
5270 END IF;
5271 END LOOP;
5272 END IF;
5273 END IF;
5274 END IF;
5275 listkey:=G_RESP_VIOLATIONS_LIST.NEXT(listkey);
5276 END LOOP;
5277 --FND_FILE.put_line(fnd_file.log,'Came out '||L_API_NAME);
5278 --FND_FILE.put_line(fnd_file.log,'Wtite_Resp_Violat_to_table end '||to_char(sysdate,'DD-MON-RRRR:HH24:MI:SS'));
5279 END;
5280
5281 -- ===============================================================
5282 -- Private Procedure name
5283 -- Wtite_Resp_Violat_to_table_rvl
5284 --
5285 -- Purpose
5286 -- revalidates the violating responsibility to the Table
5287 -- AMW_Violation_RESP,AMW_VIOLAT_RESP_ENTRIES
5288 --
5289 -- Params
5290 -- p_violation_id := specified violation id
5291 -- p_constraint_rev_id := specified constraint_rev_id
5292 -- p_type_code := specified constraint object type
5293 --
5294 -- Notes
5295 --
5296 -- History
5297 -- ===============================================================
5298
5299 Procedure Write_Resp_Violat_to_table_rvl (
5300 p_violation_id IN NUMBER,
5301 p_constraint_rev_id IN NUMBER,
5302 p_type_code IN VARCHAR2
5303 )
5304 IS
5305
5306 CURSOR c_constraint_entries (l_constraint_rev_id IN NUMBER) IS
5307 SELECT function_id,object_type,group_code
5308 FROM amw_constraint_entries
5309 WHERE constraint_rev_id=l_constraint_rev_id;
5310
5311 CURSOR c_resp_violation_id IS
5312 SELECT AMW_VIOLATION_RESP_S.NEXTVAL
5313 FROM dual;
5314
5315 CURSOR c_resp_waived (l_constraint_rev_id IN NUMBER) IS
5316 SELECT PK1,PK2
5317 FROM amw_constraint_waivers_b
5318 WHERE constraint_rev_id = l_constraint_rev_id
5319 AND object_type = 'RESP'
5320 AND start_date <= sysdate AND (end_date >= sysdate or end_date is null);
5321
5322 CURSOR c_existing_resp_violation (l_violation_id IN NUMBER) IS
5323 SELECT APPLICATION_ID,RESPONSIBILITY_ID,RESP_VIOLATION_ID
5324 FROM AMW_VIOLATION_RESP
5325 WHERE violation_id=l_violation_id;
5326
5327
5328 l_constraint_function_id NUMBER;
5329 l_resp_violation_id NUMBER;
5330 l_is_resp_waived VARCHAR2(1);
5331 l_is_resp_waived_count NUMBER;
5332
5333 l_waiv_resp_id_list G_NUMBER_TABLE;
5334 l_waiv_resp_appl_id_list G_NUMBER_TABLE;
5335 l_waived_resp_appl_list G_NUMBER_TABLE_TYPE;
5336 L_FUNCTION_ID_LIST G_NUMBER_TABLE;
5337 L_EXISTING_RESP_ID_LIST G_NUMBER_TABLE;
5338 L_EXISTING_APPL_ID_LIST G_NUMBER_TABLE;
5339 L_EXISTING_RESP_VIO_ID_LIST G_NUMBER_TABLE;
5340
5341 L_OBJECT_TYPE_LIST G_VARCHAR2_CODE_TABLE;
5342 L_GROUP_CODE_LIST G_VARCHAR2_CODE_TABLE;
5343 L_AVAILABLE_GROUP_CODE_LIST G_VARCHAR2_CODE_TABLE;
5344 L_RESPVIO_ENTRIES G_RESPVIO_ENTRIES_TABLE;
5345
5346 -- psomanat : 06:09:2006 : fix for bug 5256720
5347 L_FUNC_ID_LIST G_FUNC_TABLE;
5348 counts Number;
5349 listkey VARCHAR2(30) := NULL;
5350 BEGIN
5351 --FND_FILE.put_line(fnd_file.log,'Wtite_Resp_Violat_to_table_rvl start '||to_char(sysdate,'DD-MON-RRRR:HH24:MI:SS'));
5352
5353 -- Logic :
5354 -- Check if the G_RESP_VIOLATIONS_LIST count is equal to 0
5355 -- If yes ,
5356 -- Then all the rsponsibility violations have been resolved.So we
5357 -- set the CORRECTED_FLAG= 'Y' for all responsibility violation
5358 -- If No,
5359 -- Get the existing responsibility violation
5360 -- For each exisitng responsibility violation
5361 -- Check if the responsibility is present in G_RESP_VIOLATIONS_LIST
5362 -- If Yes,
5363 -- Check if this responsibility is waived
5364 -- If yes,
5365 -- Set the CORRECTED_FLAG= 'Y' for the responsibility
5366 -- If No,
5367 -- Check if the responsibility still violates the constraint
5368 -- If No,
5369 -- Set the CORRECTED_FLAG= 'Y' for the responsibility
5370 -- If Yes,
5371 -- Populate the incompatible functions accessible to
5372 -- responsibilities in AMW_VIOLAT_RESP_ENTRIES
5373 -- If No,
5374 -- Set the CORRECTED_FLAG= 'Y' for the responsibility
5375 IF (G_RESP_VIOLATIONS_LIST.COUNT = 0) THEN
5376
5377 UPDATE AMW_VIOLATION_RESP
5378 SET CORRECTED_FLAG ='Y'
5382 WHERE RESP_VIOLATION_ID IN (SELECT RESP_VIOLATION_ID FROM AMW_VIOLATION_RESP WHERE VIOLATION_ID=p_violation_id);
5379 WHERE VIOLATION_ID=p_violation_id;
5380
5381 DELETE FROM AMW_VIOLAT_RESP_ENTRIES
5383
5384 RETURN;
5385 ELSE
5386
5387 OPEN c_existing_resp_violation (p_violation_id);
5388 FETCH c_existing_resp_violation
5389 BULK COLLECT INTO L_EXISTING_APPL_ID_LIST,
5390 L_EXISTING_RESP_ID_LIST,
5391 L_EXISTING_RESP_VIO_ID_LIST;
5392 CLOSE c_existing_resp_violation;
5393
5394 IF L_EXISTING_RESP_ID_LIST.COUNT = 0 THEN
5395 RETURN;
5396 END IF;
5397
5398 OPEN c_constraint_entries (p_constraint_rev_id);
5399 FETCH c_constraint_entries BULK COLLECT INTO L_FUNCTION_ID_LIST,L_OBJECT_TYPE_LIST,L_GROUP_CODE_LIST;
5400 CLOSE c_constraint_entries;
5401
5402 OPEN c_resp_waived (p_constraint_rev_id);
5403 FETCH c_resp_waived BULK COLLECT INTO l_waiv_resp_id_list,l_waiv_resp_appl_id_list;
5404 CLOSE c_resp_waived;
5405
5406 -- Put the waived responsibility in a associative array with
5407 -- application_id@responsibility_id as the key
5408 -- This will help us to identify the resposnibility waiver quickly as
5409 -- we need not iterate over the nested tables l_waiv_resp_id_list and
5410 -- l_waiv_resp_appl_id_list to check if the responsbility waiver exist or not
5411 IF (l_waiv_resp_id_list IS NOT NULL) AND (l_waiv_resp_id_list.FIRST IS NOT NULL) THEN
5412 FOR i IN l_waiv_resp_id_list.FIRST ..l_waiv_resp_id_list.LAST
5413 LOOP
5414 listkey:=l_waiv_resp_appl_id_list(i)||'@'||l_waiv_resp_id_list(i);
5415 l_waived_resp_appl_list(listkey):=l_waiv_resp_id_list(i);
5416 END LOOP;
5417 END IF;
5418
5419 FOR i in L_EXISTING_RESP_ID_LIST.first .. L_EXISTING_RESP_ID_LIST.last
5420 LOOP
5421 listkey:=L_EXISTING_APPL_ID_LIST(i)||'@'||L_EXISTING_RESP_ID_LIST(i);
5422 IF G_RESP_VIOLATIONS_LIST.EXISTS(listkey) THEN
5423
5424 DELETE FROM AMW_VIOLAT_RESP_ENTRIES
5425 WHERE RESP_VIOLATION_ID =L_EXISTING_RESP_VIO_ID_LIST(i);
5426
5427 IF (l_waived_resp_appl_list.exists(listkey)) THEN
5428 UPDATE AMW_VIOLATION_RESP
5429 SET CORRECTED_FLAG ='Y'
5430 WHERE VIOLATION_ID = p_violation_id
5431 AND RESPONSIBILITY_ID = l_existing_resp_id_list(i)
5432 AND APPLICATION_ID = l_existing_appl_id_list(i);
5433 ELSE
5434 L_RESPVIO_ENTRIES.DELETE();
5435 L_FUNC_ID_LIST.DELETE();
5436
5437 L_FUNC_ID_LIST := G_RESP_VIOLATIONS_LIST(listkey);
5438
5439 IF (p_type_code = 'ALL' AND L_FUNC_ID_LIST.COUNT = l_function_id_list.COUNT) THEN
5440 FOR j IN L_FUNC_ID_LIST.FIRST .. L_FUNC_ID_LIST.LAST
5441 LOOP
5442 IF L_FUNC_ID_LIST.EXISTS(j) THEN
5443 L_RESPVIO_ENTRIES:=L_FUNC_ID_LIST(j);
5444 FOR k IN L_RESPVIO_ENTRIES.FIRST .. L_RESPVIO_ENTRIES.LAST
5445 LOOP
5446 INSERT INTO AMW_VIOLAT_RESP_ENTRIES(
5447 VIOLAT_RESP_ENTRY_ID,
5448 RESP_VIOLATION_ID,
5449 MENU_ID,
5450 FUNCTION_ID,
5451 ACCESS_GIVEN_DATE,
5452 ACCESS_GIVEN_BY_ID,
5453 OBJECT_TYPE,
5454 LAST_UPDATE_DATE,
5455 LAST_UPDATED_BY,
5456 LAST_UPDATE_LOGIN,
5457 CREATION_DATE,
5458 CREATED_BY,
5459 SECURITY_GROUP_ID,
5460 APPLICATION_ID
5461 )
5462 VALUES(
5463 AMW_VIOLAT_RESP_ENTRIES_S.NEXTVAL,
5464 L_EXISTING_RESP_VIO_ID_LIST(i),
5465 L_RESPVIO_ENTRIES(k).Menu_Id,
5466 L_RESPVIO_ENTRIES(k).Function_id,
5467 L_RESPVIO_ENTRIES(k).Access_Given_Date,
5468 L_RESPVIO_ENTRIES(k).Access_Given_By_Id,
5469 L_RESPVIO_ENTRIES(k).Object_type,
5470 sysdate,
5471 G_USER_ID,
5472 G_LOGIN_ID,
5473 sysdate,
5474 G_USER_ID,
5478 END LOOP;
5475 NULL,
5476 L_RESPVIO_ENTRIES(k).prog_appl_id
5477 );
5479 END IF;
5480 END LOOP;
5481 ELSIF p_type_code = 'ME' AND L_FUNC_ID_LIST.COUNT >= 2 THEN
5482 FOR j IN L_FUNC_ID_LIST.FIRST .. L_FUNC_ID_LIST.LAST
5483 LOOP
5484 IF L_FUNC_ID_LIST.EXISTS(j) then
5485 L_RESPVIO_ENTRIES:=L_FUNC_ID_LIST(j);
5486 FOR k IN L_RESPVIO_ENTRIES.FIRST .. L_RESPVIO_ENTRIES.LAST
5487 LOOP
5488
5489 INSERT INTO AMW_VIOLAT_RESP_ENTRIES(
5490 VIOLAT_RESP_ENTRY_ID,
5491 resp_violation_id,
5492 MENU_ID,
5493 FUNCTION_ID,
5494 ACCESS_GIVEN_DATE,
5495 ACCESS_GIVEN_BY_ID,
5496 OBJECT_TYPE,
5497 LAST_UPDATE_DATE,
5498 LAST_UPDATED_BY,
5499 LAST_UPDATE_LOGIN,
5500 CREATION_DATE,
5501 CREATED_BY,
5502 SECURITY_GROUP_ID,
5503 APPLICATION_ID
5504 )
5505 VALUES(
5506 AMW_VIOLAT_RESP_ENTRIES_S.NEXTVAL,
5507 L_EXISTING_RESP_VIO_ID_LIST(i),
5508 L_RESPVIO_ENTRIES(k).Menu_Id,
5509 L_RESPVIO_ENTRIES(k).Function_id,
5510 L_RESPVIO_ENTRIES(k).Access_Given_Date,
5511 L_RESPVIO_ENTRIES(k).Access_Given_By_Id,
5512 L_RESPVIO_ENTRIES(k).Object_type,
5513 sysdate,
5514 G_USER_ID,
5515 G_LOGIN_ID,
5516 sysdate,
5517 G_USER_ID,
5518 NULL,
5519 L_RESPVIO_ENTRIES(k).prog_appl_id
5520 );
5521 END LOOP;
5522 END IF;
5523 END LOOP;
5524 ELSIF p_type_code = 'SET' THEN
5525 L_AVAILABLE_GROUP_CODE_LIST.delete();
5526
5527 FOR j IN L_FUNC_ID_LIST.FIRST .. L_FUNC_ID_LIST.LAST
5528 LOOP
5529 IF L_FUNC_ID_LIST.EXISTS(j) then
5530 L_RESPVIO_ENTRIES:=L_FUNC_ID_LIST(j);
5531 FOR k IN L_RESPVIO_ENTRIES.FIRST .. L_RESPVIO_ENTRIES.LAST
5532 LOOP
5533 L_AVAILABLE_GROUP_CODE_LIST(L_RESPVIO_ENTRIES(k).group_code):= L_RESPVIO_ENTRIES(k).group_code;
5534 IF L_AVAILABLE_GROUP_CODE_LIST.COUNT >=2 THEN
5535 EXIT;
5536 END IF;
5537 END LOOP;
5538 END IF;
5539 END LOOP;
5540
5541
5542 IF (L_AVAILABLE_GROUP_CODE_LIST.COUNT)>=2 THEN
5543
5544 FOR j IN L_FUNC_ID_LIST.FIRST .. L_FUNC_ID_LIST.LAST
5548 FOR k IN L_RESPVIO_ENTRIES.FIRST .. L_RESPVIO_ENTRIES.LAST
5545 LOOP
5546 IF L_FUNC_ID_LIST.EXISTS(j) then
5547 L_RESPVIO_ENTRIES:=L_FUNC_ID_LIST(j);
5549 LOOP
5550 INSERT INTO AMW_VIOLAT_RESP_ENTRIES(
5551 VIOLAT_RESP_ENTRY_ID,
5552 RESP_VIOLATION_ID,
5553 MENU_ID,
5554 FUNCTION_ID,
5555 ACCESS_GIVEN_DATE,
5556 ACCESS_GIVEN_BY_ID,
5557 OBJECT_TYPE,
5558 LAST_UPDATE_DATE,
5559 LAST_UPDATED_BY,
5560 LAST_UPDATE_LOGIN,
5561 CREATION_DATE,
5562 CREATED_BY,
5563 SECURITY_GROUP_ID,
5564 APPLICATION_ID
5565 )
5566 VALUES(
5567 AMW_VIOLAT_RESP_ENTRIES_S.NEXTVAL,
5568 L_EXISTING_RESP_VIO_ID_LIST(i),
5569 L_RESPVIO_ENTRIES(k).Menu_Id,
5570 L_RESPVIO_ENTRIES(k).Function_id,
5571 L_RESPVIO_ENTRIES(k).Access_Given_Date,
5572 L_RESPVIO_ENTRIES(k).Access_Given_By_Id,
5573 L_RESPVIO_ENTRIES(k).Object_type,
5574 sysdate,
5575 G_USER_ID,
5576 G_LOGIN_ID,
5577 sysdate,
5578 G_USER_ID,
5579 NULL,
5580 L_RESPVIO_ENTRIES(k).prog_appl_id
5581 );
5582 END LOOP;
5583 END IF;
5584 END LOOP;
5585 ELSE
5586 -- The responsbility does not have atleast one incompatible
5587 -- functions from both the group
5588 -- So it does not violates the constraint
5589 UPDATE AMW_VIOLATION_RESP
5590 SET CORRECTED_FLAG = 'Y'
5591 WHERE VIOLATION_ID = p_violation_id
5595 END IF;
5592 AND RESPONSIBILITY_ID = l_existing_resp_id_list(i)
5593 AND APPLICATION_ID = l_existing_appl_id_list(i);
5594 END IF;
5596 -- we check if the responsibility still violates the constraint
5597 -- we check this for object_type = ALL or ME
5598 IF (p_type_code = 'ALL' AND L_FUNC_ID_LIST.COUNT <> l_function_id_list.COUNT) OR
5599 (p_type_code = 'ME' AND L_FUNC_ID_LIST.COUNT <= 1) THEN
5600 UPDATE AMW_VIOLATION_RESP
5601 SET CORRECTED_FLAG ='Y'
5602 WHERE VIOLATION_ID = p_violation_id
5603 AND RESPONSIBILITY_ID = l_existing_resp_id_list(i)
5604 AND APPLICATION_ID = l_existing_appl_id_list(i);
5605 END IF;
5606 END IF;
5607 ELSE
5608 UPDATE AMW_VIOLATION_RESP
5609 SET CORRECTED_FLAG = 'Y'
5610 WHERE VIOLATION_ID = p_violation_id
5611 AND RESPONSIBILITY_ID = l_existing_resp_id_list(i)
5612 AND APPLICATION_ID = l_existing_appl_id_list(i);
5613 END IF;
5614 END LOOP;
5615 END IF;
5616 --FND_FILE.put_line(fnd_file.log,'Wtite_Resp_Violat_to_table_rvl end '||to_char(sysdate,'DD-MON-RRRR:HH24:MI:SS'));
5617 END;
5618
5619 -- ===============================================================
5620 -- Private Procedure name
5621 -- Check_For_Func_Cst_ALL
5622 --
5623 -- Purpose
5624 -- for constraint type = 'Function: ALL or None' (type_code = 'ALL')
5625 -- check violation for specified constraint
5626 -- this is private procedure,
5627 -- should not call this procedure directly
5628 --
5629 -- Params
5630 -- p_constraint_rev_id := specified constraint_rev_id
5631 --
5632 -- Notes
5633 --
5634 -- History
5635 -- 01.06.2005 tsho: starting from AMW.D, params changed for Populate_User_Id_List_For_Cst
5636 -- 05.17.2005 tsho: starting from AMW.E, consider Role, GLOBAL Grant/USER Grant
5637 -- 05.25.2005 tsho: consider Concurrent Programs as constraint entries
5638 -- ===============================================================
5639 PROCEDURE Check_For_Func_Cst_ALL (
5640 p_constraint_rev_id IN NUMBER,
5641 p_violation_id IN NUMBER,
5642 p_type_code IN VARCHAR2,
5643 p_revalidate_flag IN VARCHAR2 := NULL
5644 )
5645 IS
5646
5647 L_API_NAME CONSTANT VARCHAR2(30) := 'Check_For_Func_Cst_ALL';
5648 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
5649
5650
5651 -- find the number of constraint entries(incompatible functions) by specified constraint_rev_id
5652 l_constraint_function_count NUMBER;
5653 CURSOR c_constraint_entries_count (l_constraint_rev_id IN NUMBER) IS
5654 SELECT count(*)
5655 FROM amw_constraint_entries
5656 WHERE constraint_rev_id=l_constraint_rev_id;
5657
5658 CURSOR c_valid_user_waivers (l_constraint_rev_id IN NUMBER) IS
5659 SELECT PK1
5660 FROM amw_constraint_waivers_b
5661 WHERE constraint_rev_id = l_constraint_rev_id
5662 AND object_type = 'USER'
5663 AND start_date <= sysdate AND (end_date >= sysdate or end_date is null);
5664
5665 CURSOR c_original_user_violation_id (l_violation_id IN NUMBER) IS
5666 SELECT violated_by_id,user_violation_id
5667 FROM amw_violation_users
5668 WHERE violation_id = l_violation_id;
5669
5670 l_user_access_func_list G_NUMBER_TABLE;
5671 l_user_access_func_nowaiv_list G_NUMBER_TABLE;
5672 l_waive_user_id NUMBER;
5673 l_user_violation_id NUMBER;
5674 l_user_id NUMBER;
5675
5676 L_USERVIO_ENTRIES G_USERVIO_ENTRIES_TABLE;
5677 L_FUNC_ID_LIST G_FUNCS_TABLE;
5678
5679 BEGIN
5680
5681 IF ((p_constraint_rev_id IS NULL) AND (p_type_code IS NULL)) THEN
5682 Return;
5683 END IF;
5684
5685 -- find the number of constraint entries(incompatible functions) by specified constraint_rev_id
5686 OPEN c_constraint_entries_count (p_constraint_rev_id);
5687 FETCH c_constraint_entries_count INTO l_constraint_function_count;
5688 CLOSE c_constraint_entries_count;
5689
5690 -- Identify the Responsibilities having access to atleast one incompatible function
5694 -- Identify the Responsibilities having access to the incompatible functions
5691 -- The incompatible function should not be excluded via function or menu exclusion
5692 Populate_Ptnl_Access_List(p_constraint_rev_id => p_constraint_rev_id);
5693
5695 -- as per the constraint object type.
5696 IF p_revalidate_flag IS NULL THEN
5697 Write_Resp_Violat_to_table(p_violation_id,p_constraint_rev_id,p_type_code);
5698 ELSE
5699 Write_Resp_Violat_to_table_rvl(p_violation_id,p_constraint_rev_id,p_type_code);
5700 END IF;
5701
5702 -- Identify the users having access to the incompatible functions.
5703 -- We identify the Responsibilities,Roles,Grants assigned to a user
5704 -- making him a violating user
5705 IF (p_revalidate_flag IS NOT NULL AND p_revalidate_flag = 'Y') THEN
5706 Populate_User_Vio_For_Vlt(p_violation_id => p_violation_id,
5707 p_constraint_rev_id => p_constraint_rev_id,
5708 p_type_code => p_type_code);
5709 ELSE
5710 Populate_User_Vio_For_Cst(p_constraint_rev_id => p_constraint_rev_id,
5711 p_type_code => p_type_code);
5712 END IF;
5713
5714 --FND_FILE.put_line(fnd_file.log,'Populate user violation Began '||to_char(sysdate,'DD-MON-RRRR:HH24:MI:SS'));
5715
5716 IF (p_revalidate_flag IS NOT NULL AND p_revalidate_flag = 'Y') THEN
5717
5718 -- When we revalidate a Constraint violation, we identify the existing
5719 -- violating users and store their corresponding user violation id
5720 -- in a associative array for performance.
5721 -- Now we can get the User violation id for a user by using the user id
5722 -- as key on G_User_Violation_Id_list
5723 G_User_Violation_Id_list.DELETE();
5724 OPEN c_original_user_violation_id(p_violation_id);
5725 LOOP
5726 FETCH c_original_user_violation_id INTO l_user_id,l_user_violation_id;
5727 EXIT WHEN c_original_user_violation_id%NOTFOUND;
5728 G_User_Violation_Id_list(l_user_id):=l_user_violation_id;
5729 END LOOP;
5730 CLOSE c_original_user_violation_id;
5731 ELSE
5732
5733 -- We store the users marked as user waiver for the current constraint
5734 -- in a associative array for performamce.
5735 -- Now we can identify if a user is waived or not by checking if
5736 -- the user is in the G_User_Waiver_List associative array. we use the
5737 -- user id as index key
5738 G_User_Waiver_List.DELETE();
5739 OPEN c_valid_user_waivers(p_constraint_rev_id);
5740 LOOP
5741 FETCH c_valid_user_waivers INTO l_waive_user_id;
5742 EXIT WHEN c_valid_user_waivers%NOTFOUND;
5743 G_User_Waiver_List(l_waive_user_id):=l_waive_user_id;
5744 END LOOP;
5745 CLOSE c_valid_user_waivers;
5746 END IF;
5747
5748 -- Logic :
5749 -- G_USER_VIOLATIONS_LIST contains the user having access to atleast one
5750 -- of the incompatible function via responsibilities,role or grants
5751 -- assigned to him.
5752 -- We check if the users has accesss to all the incompatible functions,
5753 -- if yes we mark him as violating user.
5754 IF (G_USER_VIOLATIONS_LIST IS NOT NULL) AND (G_USER_VIOLATIONS_LIST.FIRST IS NOT NULL) THEN
5755 FOR i in G_USER_VIOLATIONS_LIST.FIRST .. G_USER_VIOLATIONS_LIST.LAST
5756 LOOP
5757 IF G_USER_VIOLATIONS_LIST.EXISTS(i) THEN
5758 l_user_access_func_list.DELETE();
5759 l_user_access_func_nowaiv_list.DELETE();
5760 L_FUNC_ID_LIST:=G_USER_VIOLATIONS_LIST(i);
5761 FOR j IN L_FUNC_ID_LIST.FIRST .. L_FUNC_ID_LIST.LAST
5762 LOOP
5763 IF L_FUNC_ID_LIST.EXISTS(j) THEN
5764 L_USERVIO_ENTRIES:=L_FUNC_ID_LIST(j);
5765 FOR k IN L_USERVIO_ENTRIES.FIRST .. L_USERVIO_ENTRIES.LAST
5766 LOOP
5767 l_user_access_func_list(L_USERVIO_ENTRIES(k).Function_Id):=L_USERVIO_ENTRIES(k).Function_Id;
5768 IF L_USERVIO_ENTRIES(k).Waived = 'N' THEN
5769 l_user_access_func_nowaiv_list(L_USERVIO_ENTRIES(k).Function_Id):=L_USERVIO_ENTRIES(k).Function_Id;
5770 END IF;
5771 END LOOP;
5772 END IF;
5773 END LOOP;
5774 IF (l_user_access_func_list.COUNT = l_constraint_function_count) THEN
5775 IF (l_user_access_func_nowaiv_list.COUNT = l_constraint_function_count) THEN
5776 Write_Func_To_Table_For_User(p_violation_id, p_constraint_rev_id,i, NULL, p_revalidate_flag);
5777 ELSE
5778 Write_Func_To_Table_For_User(p_violation_id, p_constraint_rev_id,i,'Y', p_revalidate_flag);
5779 END IF;
5780 ELSE
5781 IF (p_revalidate_flag IS NOT NULL AND p_revalidate_flag = 'Y') THEN
5782 Update_Violation_User (
5783 p_user_violation_id => NULL,
5784 p_violation_id => p_violation_id,
5785 p_violated_by_id => i,
5786 p_corrected_flag => 'Y');
5787 END IF;
5788 END IF;
5789 END IF;
5790 END LOOP;
5791 END IF;
5792 --FND_FILE.put_line(fnd_file.log,'comming out of api '||L_API_NAME);
5793 END Check_For_Func_Cst_ALL;
5794
5798 -- Check_For_Func_Cst_ME
5795
5796 -- ===============================================================
5797 -- Private Procedure name
5799 --
5800 -- Purpose
5801 -- for constraint type = 'Function: Mutuallly Exclusive' (type_code = 'ME')
5802 -- check violation for specified constraint
5803 -- this is private procedure,
5804 -- should not call this procedure directly
5805 --
5806 -- Params
5807 -- p_constraint_rev_id := specified constraint_rev_id
5808 --
5809 -- Notes
5810 --
5811 -- History
5812 -- 01.06.2005 tsho: starting from AMW.D, params changed for Populate_User_Id_List_For_Cst
5813 -- 05.17.2005 tsho: starting from AMW.E, consider Role, GLOBAL Grant/USER Grant
5814 -- 05.25.2005 tsho: consider Concurrent Programs as constraint entries
5815 -- ===============================================================
5816 PROCEDURE Check_For_Func_Cst_ME (
5817 p_constraint_rev_id IN NUMBER,
5818 p_violation_id IN NUMBER,
5819 p_type_code IN VARCHAR2,
5820 p_revalidate_flag IN VARCHAR2 := NULL
5821 )
5822 IS
5823 L_API_NAME CONSTANT VARCHAR2(30) := 'Check_For_Func_Cst_ME';
5824 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
5825
5826 CURSOR c_valid_user_waivers (l_constraint_rev_id IN NUMBER) IS
5827 SELECT PK1
5828 FROM amw_constraint_waivers_b
5829 WHERE constraint_rev_id = l_constraint_rev_id
5830 AND object_type = 'USER'
5831 AND start_date <= sysdate AND (end_date >= sysdate or end_date is null);
5832
5833 CURSOR c_original_user_violation_id (l_violation_id IN NUMBER) IS
5834 SELECT violated_by_id,user_violation_id
5835 FROM amw_violation_users
5836 WHERE violation_id = l_violation_id;
5837
5838 l_user_access_func_list G_NUMBER_TABLE;
5839 l_user_access_func_nowaiv_list G_NUMBER_TABLE;
5840 l_waive_user_id NUMBER;
5841 l_user_violation_id NUMBER;
5842 l_user_id NUMBER;
5843
5844 L_USERVIO_ENTRIES G_USERVIO_ENTRIES_TABLE;
5845 L_FUNC_ID_LIST G_FUNCS_TABLE;
5846 BEGIN
5847 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
5848
5849 IF ((p_constraint_rev_id IS NULL) AND (p_type_code IS NULL)) THEN
5850 Return;
5851 END IF;
5852
5853 -- Identify the Responsibilities having access to atleast one incompatible function
5854 -- The incompatible function should not be excluded via function or menu exclusion
5855 Populate_Ptnl_Access_List(p_constraint_rev_id => p_constraint_rev_id);
5856
5857 -- Identify the Responsibilities having access to the incompatible functions
5858 -- as per the constraint object type.
5859 IF p_revalidate_flag IS NULL THEN
5860 Write_Resp_Violat_to_table(p_violation_id,p_constraint_rev_id,p_type_code);
5861 ELSE
5862 Write_Resp_Violat_to_table_rvl(p_violation_id,p_constraint_rev_id,p_type_code);
5863 END IF;
5864
5865 -- Identify the users having access to the incompatible functions.
5866 -- We identify the Responsibilities,Roles,Grants assigned to a user
5867 -- making him a violating user
5868 IF (p_revalidate_flag IS NOT NULL AND p_revalidate_flag = 'Y') THEN
5869 Populate_User_Vio_For_Vlt(p_violation_id => p_violation_id,
5870 p_constraint_rev_id => p_constraint_rev_id,
5871 p_type_code => p_type_code);
5872 ELSE
5873 Populate_User_Vio_For_Cst(p_constraint_rev_id => p_constraint_rev_id,
5874 p_type_code => p_type_code);
5875 END IF;
5876
5877 --FND_FILE.put_line(fnd_file.log,'Populate user violation Began '||to_char(sysdate,'DD-MON-RRRR:HH24:MI:SS'));
5878
5879 IF (p_revalidate_flag IS NOT NULL AND p_revalidate_flag = 'Y') THEN
5880
5881 -- When we revalidate a Constraint violation, we identify the existing
5882 -- violating users and store their corresponding user violation id
5883 -- in a associative array for performance.
5884 -- Now we can get the User violation id for a user by using the user id
5885 -- as key on G_User_Violation_Id_list
5886 G_User_Violation_Id_list.DELETE();
5887 OPEN c_original_user_violation_id(p_violation_id);
5888 LOOP
5889 FETCH c_original_user_violation_id INTO l_user_id,l_user_violation_id;
5890 EXIT WHEN c_original_user_violation_id%NOTFOUND;
5891 G_User_Violation_Id_list(l_user_id):=l_user_violation_id;
5892 END LOOP;
5893 CLOSE c_original_user_violation_id;
5894 ELSE
5895
5896 -- We store the users marked as user waiver for the current constraint
5897 -- in a associative array for performamce.
5898 -- Now we can identify if a user is waived or not by checking if
5899 -- the user is in the G_User_Waiver_List associative array. we use the
5900 -- user id as index key
5901 G_User_Waiver_List.DELETE();
5902 OPEN c_valid_user_waivers(p_constraint_rev_id);
5903 LOOP
5904 FETCH c_valid_user_waivers INTO l_waive_user_id;
5905 EXIT WHEN c_valid_user_waivers%NOTFOUND;
5906 G_User_Waiver_List(l_waive_user_id):=l_waive_user_id;
5907 END LOOP;
5908 CLOSE c_valid_user_waivers;
5909 END IF;
5910
5911 -- Logic :
5912 -- G_USER_VIOLATIONS_LIST contains the user having access to atleast one
5916 -- if yes we mark him as violating user.
5913 -- of the incompatible function via responsibilities,role or grants
5914 -- assigned to him.
5915 -- We check if the users has access to atleast 2 incompatible functions,
5917 IF (G_USER_VIOLATIONS_LIST IS NOT NULL) AND (G_USER_VIOLATIONS_LIST.FIRST IS NOT NULL) THEN
5918 FOR i in G_USER_VIOLATIONS_LIST.FIRST .. G_USER_VIOLATIONS_LIST.LAST
5919 LOOP
5920 IF G_USER_VIOLATIONS_LIST.EXISTS(i) THEN
5921 l_user_access_func_list.DELETE();
5922 l_user_access_func_nowaiv_list.DELETE();
5923 L_FUNC_ID_LIST:=G_USER_VIOLATIONS_LIST(i);
5924 FOR j IN L_FUNC_ID_LIST.FIRST .. L_FUNC_ID_LIST.LAST
5925 LOOP
5926 IF L_FUNC_ID_LIST.EXISTS(j) THEN
5927 L_USERVIO_ENTRIES:=L_FUNC_ID_LIST(j);
5928 FOR k IN L_USERVIO_ENTRIES.FIRST .. L_USERVIO_ENTRIES.LAST
5929 LOOP
5930 l_user_access_func_list(L_USERVIO_ENTRIES(k).Function_Id):=L_USERVIO_ENTRIES(k).Function_Id;
5931 IF L_USERVIO_ENTRIES(k).Waived = 'N' THEN
5932 l_user_access_func_nowaiv_list(L_USERVIO_ENTRIES(k).Function_Id):=L_USERVIO_ENTRIES(k).Function_Id;
5933 END IF;
5934 END LOOP;
5935 END IF;
5936 END LOOP;
5937 IF (l_user_access_func_list.COUNT >= 2) THEN
5938 IF (l_user_access_func_nowaiv_list.COUNT >= 2) THEN
5939 Write_Func_To_Table_For_User(p_violation_id, p_constraint_rev_id,i, NULL, p_revalidate_flag);
5940 ELSE
5941 Write_Func_To_Table_For_User(p_violation_id, p_constraint_rev_id,i,'Y', p_revalidate_flag);
5942 END IF;
5943 ELSE
5944 IF (p_revalidate_flag IS NOT NULL AND p_revalidate_flag = 'Y') THEN
5945 Update_Violation_User (
5946 p_user_violation_id => NULL,
5947 p_violation_id => p_violation_id,
5948 p_violated_by_id => i,
5949 p_corrected_flag => 'Y');
5950 END IF;
5951 END IF;
5952 END IF;
5953 END LOOP;
5954 END IF;
5955
5956 --FND_FILE.put_line(fnd_file.log,'Populate user violation End '||to_char(sysdate,'DD-MON-RRRR:HH24:MI:SS'));
5957 END Check_For_Func_Cst_ME;
5958
5959
5960 -- ===============================================================
5961 -- Private Procedure name
5962 -- Check_For_Func_Cst_SET
5963 --
5964 -- Purpose
5965 -- for constraint type = 'Function: Incompatible Sets' (type_code = 'SET')
5966 -- check violation for specified constraint
5967 -- this is private procedure,
5968 -- should not call this procedure directly
5969 --
5970 -- Params
5971 -- p_constraint_rev_id := specified constraint_rev_id
5972 --
5973 -- Notes
5974 --
5975 -- History
5976 -- 05.13.2005 tsho: create for AMW.E
5977 -- 05.25.2005 tsho: consider Concurrent Programs as constraint entries
5978 -- ===============================================================
5979 PROCEDURE Check_For_Func_Cst_SET (
5980 p_constraint_rev_id IN NUMBER,
5981 p_violation_id IN NUMBER,
5982 p_type_code IN VARCHAR2,
5983 p_revalidate_flag IN VARCHAR2 := NULL
5984 )
5985 IS
5986
5987 L_API_NAME CONSTANT VARCHAR2(30) := 'Check_For_Func_Cst_SET';
5988 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
5989
5990 CURSOR c_valid_user_waivers (l_constraint_rev_id IN NUMBER) IS
5991 SELECT PK1
5992 FROM amw_constraint_waivers_b
5993 WHERE constraint_rev_id = l_constraint_rev_id
5994 AND object_type = 'USER'
5995 AND start_date <= sysdate AND (end_date >= sysdate or end_date is null);
5996
5997 CURSOR c_original_user_violation_id (l_violation_id IN NUMBER) IS
5998 SELECT violated_by_id,user_violation_id
5999 FROM amw_violation_users
6000 WHERE violation_id = l_violation_id;
6001
6002 l_user_access_func_list G_NUMBER_TABLE;
6003 l_user_access_func_nowaiv_list G_NUMBER_TABLE;
6004 l_waive_user_id NUMBER;
6005 l_user_violation_id NUMBER;
6006 l_user_id NUMBER;
6007
6008 -- 05.24.2005 tsho: store those group_code of accessible functions by an user
6009 l_user_access_grp_list G_VARCHAR2_CODE_TABLE;
6010 l_user_access_grp_nowaiv_list G_VARCHAR2_CODE_TABLE;
6011
6012 L_USERVIO_ENTRIES G_USERVIO_ENTRIES_TABLE;
6013 L_FUNC_ID_LIST G_FUNCS_TABLE;
6014
6015 BEGIN
6016 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
6017
6018 IF ((p_constraint_rev_id IS NULL) AND (p_type_code IS NULL)) THEN
6019 Return;
6020 END IF;
6021
6022 -- Identify the Responsibilities having access to atleast one incompatible function
6023 -- The incompatible function should not be excluded via function or menu exclusion
6024 Populate_Ptnl_Access_List(p_constraint_rev_id => p_constraint_rev_id);
6025
6026 -- Identify the Responsibilities having access to the incompatible functions
6027 -- as per the constraint object type.
6028 IF p_revalidate_flag IS NULL THEN
6032 END IF;
6029 Write_Resp_Violat_to_table(p_violation_id,p_constraint_rev_id,p_type_code);
6030 ELSE
6031 Write_Resp_Violat_to_table_rvl(p_violation_id,p_constraint_rev_id,p_type_code);
6033
6034 -- Identify the users having access to the incompatible functions.
6035 -- We identify the Responsibilities,Roles,Grants assigned to a user
6036 -- making him a violating user
6037 IF (p_revalidate_flag IS NOT NULL AND p_revalidate_flag = 'Y') THEN
6038 Populate_User_Vio_For_Vlt(p_violation_id => p_violation_id,
6039 p_constraint_rev_id => p_constraint_rev_id,
6040 p_type_code => p_type_code);
6041 ELSE
6042 Populate_User_Vio_For_Cst(p_constraint_rev_id => p_constraint_rev_id,
6043 p_type_code => p_type_code);
6044 END IF;
6045
6046 --FND_FILE.put_line(fnd_file.log,'Populate user violation Began '||to_char(sysdate,'DD-MON-RRRR:HH24:MI:SS'));
6047
6048 IF (p_revalidate_flag IS NOT NULL AND p_revalidate_flag = 'Y') THEN
6049
6050 -- When we revalidate a Constraint violation, we identify the existing
6051 -- violating users and store their corresponding user violation id
6052 -- in a associative array for performance.
6053 -- Now we can get the User violation id for a user by using the user id
6054 -- as key on G_User_Violation_Id_list
6055 G_User_Violation_Id_list.DELETE();
6056 OPEN c_original_user_violation_id(p_violation_id);
6057 LOOP
6058 FETCH c_original_user_violation_id INTO l_user_id,l_user_violation_id;
6059 EXIT WHEN c_original_user_violation_id%NOTFOUND;
6060 G_User_Violation_Id_list(l_user_id):=l_user_violation_id;
6061 END LOOP;
6062 CLOSE c_original_user_violation_id;
6063 ELSE
6064
6065 -- We store the users marked as user waiver for the current constraint
6066 -- in a associative array for performamce.
6067 -- Now we can identify if a user is waived or not by checking if
6068 -- the user is in the G_User_Waiver_List associative array. we use the
6069 -- user id as index key
6070 G_User_Waiver_List.DELETE();
6071 OPEN c_valid_user_waivers(p_constraint_rev_id);
6072 LOOP
6073 FETCH c_valid_user_waivers INTO l_waive_user_id;
6074 EXIT WHEN c_valid_user_waivers%NOTFOUND;
6075 G_User_Waiver_List(l_waive_user_id):=l_waive_user_id;
6076 END LOOP;
6077 CLOSE c_valid_user_waivers;
6078 END IF;
6079
6080 -- Logic :
6081 -- G_USER_VIOLATIONS_LIST contains the user having access to atleast one
6082 -- of the incompatible function via responsibilities,role or grants
6083 -- assigned to him.
6084 -- We check if the users has access to atleast one incompatible functions
6085 -- from each group, if yes we mark him as violating user.
6086 IF (G_USER_VIOLATIONS_LIST IS NOT NULL) AND (G_USER_VIOLATIONS_LIST.FIRST IS NOT NULL) THEN
6087 FOR i in G_USER_VIOLATIONS_LIST.FIRST .. G_USER_VIOLATIONS_LIST.LAST
6088 LOOP
6089 IF G_USER_VIOLATIONS_LIST.EXISTS(i) THEN
6090 l_user_access_grp_list.DELETE();
6091 l_user_access_grp_nowaiv_list.DELETE();
6092 L_FUNC_ID_LIST:=G_USER_VIOLATIONS_LIST(i);
6093 FOR j IN L_FUNC_ID_LIST.FIRST .. L_FUNC_ID_LIST.LAST
6094 LOOP
6095 IF L_FUNC_ID_LIST.EXISTS(j) THEN
6096 L_USERVIO_ENTRIES:=L_FUNC_ID_LIST(j);
6097 FOR k IN L_USERVIO_ENTRIES.FIRST .. L_USERVIO_ENTRIES.LAST
6098 LOOP
6099 l_user_access_grp_list(L_USERVIO_ENTRIES(k).group_code):=L_USERVIO_ENTRIES(k).group_code;
6100 IF L_USERVIO_ENTRIES(k).Waived = 'N' THEN
6101 l_user_access_grp_nowaiv_list(L_USERVIO_ENTRIES(k).group_code):=L_USERVIO_ENTRIES(k).group_code;
6102 END IF;
6103 END LOOP;
6104 END IF;
6105 END LOOP;
6106 IF (l_user_access_grp_list.COUNT >= 2) THEN
6107 IF (l_user_access_grp_nowaiv_list.COUNT >= 2) THEN
6108 Write_Func_To_Table_For_User(p_violation_id, p_constraint_rev_id,i, NULL, p_revalidate_flag);
6109 ELSE
6110 Write_Func_To_Table_For_User(p_violation_id, p_constraint_rev_id,i,'Y', p_revalidate_flag);
6111 END IF;
6112 ELSE
6113 IF (p_revalidate_flag IS NOT NULL AND p_revalidate_flag = 'Y') THEN
6114 Update_Violation_User (
6115 p_user_violation_id => NULL,
6116 p_violation_id => p_violation_id,
6117 p_violated_by_id => i,
6118 p_corrected_flag => 'Y');
6119 END IF;
6120 END IF;
6121 END IF;
6122 END LOOP;
6123 END IF;
6124 --FND_FILE.put_line(fnd_file.log,'Populate user violation End '||to_char(sysdate,'DD-MON-RRRR:HH24:MI:SS'));
6125 --FND_FILE.put_line(fnd_file.log,'Commit Out '||L_API_NAME);
6126 END Check_For_Func_Cst_SET;
6127
6128
6129 -- ===============================================================
6130 -- Private Procedure name
6131 -- Check_For_Resp_Cst_ALL
6132 --
6133 -- Purpose
6137 -- should not call this procedure directly
6134 -- for constraint type = 'Responsibility: ALL or None' (type_code = 'RESPALL')
6135 -- check violation for specified constraint
6136 -- this is private procedure,
6138 --
6139 -- Params
6140 -- p_constraint_rev_id := specified constraint_rev_id
6141 --
6142 -- Notes
6143 --
6144 -- History
6145 -- 01.06.2005 tsho: starting from AMW.D,
6146 -- consider Incompatible Responsibilities.
6147 -- ===============================================================
6148 PROCEDURE Check_For_Resp_Cst_ALL (
6149 p_constraint_rev_id IN NUMBER,
6150 p_violation_id IN NUMBER,
6151 p_type_code IN VARCHAR2,
6152 p_revalidate_flag IN VARCHAR2 := NULL
6153 )
6154 IS
6155
6156 L_API_NAME CONSTANT VARCHAR2(30) := 'Check_For_Resp_Cst_ALL';
6157 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
6158
6159 -- store how many incompatible responsibilities he can access so far
6160 l_access_resp_count NUMBER;
6161 -- find the number of constraint entries(incompatible responsibilities) by specified constraint_rev_id
6162 l_constraint_resp_count NUMBER;
6163 CURSOR c_constraint_entries_count (l_constraint_rev_id IN NUMBER) IS
6164 SELECT count(*)
6165 FROM amw_constraint_entries
6166 WHERE constraint_rev_id=l_constraint_rev_id;
6167
6168 CURSOR c_valid_user_waivers (l_constraint_rev_id IN NUMBER) IS
6169 SELECT PK1
6170 FROM amw_constraint_waivers_b
6171 WHERE constraint_rev_id = l_constraint_rev_id
6172 AND object_type = 'USER'
6173 AND start_date <= sysdate AND (end_date >= sysdate or end_date is null);
6174
6175 CURSOR c_original_user_violation_id (l_violation_id IN NUMBER) IS
6176 SELECT violated_by_id,user_violation_id
6177 FROM amw_violation_users
6178 WHERE violation_id = l_violation_id;
6179
6180 L_RESP_ID_LIST G_RESPS_TABLE;
6181 l_waive_user_id NUMBER;
6182 l_user_violation_id NUMBER;
6183 l_user_id NUMBER;
6184
6185 BEGIN
6186 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
6187
6188 IF ((p_constraint_rev_id IS NULL) AND (p_type_code IS NULL)) THEN
6189 Return;
6190 END IF;
6191
6192 OPEN c_constraint_entries_count (p_constraint_rev_id);
6193 FETCH c_constraint_entries_count INTO l_constraint_resp_count;
6194 CLOSE c_constraint_entries_count;
6195
6196 IF (p_revalidate_flag IS NOT NULL AND p_revalidate_flag = 'Y') THEN
6197 Populate_User_Vio_For_Vlt(p_violation_id => p_violation_id,
6198 p_constraint_rev_id => p_constraint_rev_id,
6199 p_type_code => p_type_code);
6200 ELSE
6201 Populate_User_Vio_For_Cst(p_constraint_rev_id => p_constraint_rev_id,
6202 p_type_code => p_type_code);
6203 END IF;
6204
6205 IF (p_revalidate_flag IS NOT NULL AND p_revalidate_flag = 'Y') THEN
6206
6207 -- When we revalidate a Constraint violation, we identify the existing
6208 -- violating users and store their corresponding user violation id
6209 -- in a associative array for performance.
6210 -- Now we can get the User violation id for a user by using the user id
6211 -- as key on G_User_Violation_Id_list
6212 G_User_Violation_Id_list.DELETE();
6213 OPEN c_original_user_violation_id(p_violation_id);
6214 LOOP
6215 FETCH c_original_user_violation_id INTO l_user_id,l_user_violation_id;
6216 EXIT WHEN c_original_user_violation_id%NOTFOUND;
6217 G_User_Violation_Id_list(l_user_id):=l_user_violation_id;
6218 END LOOP;
6219 CLOSE c_original_user_violation_id;
6220 ELSE
6221
6222 -- We store the users marked as user waiver for the current constraint
6223 -- in a associative array for performamce.
6224 -- Now we can identify if a user is waived or not by checking if
6225 -- the user is in the G_User_Waiver_List associative array. we use the
6226 -- user id as index key
6227 G_User_Waiver_List.DELETE();
6228 OPEN c_valid_user_waivers(p_constraint_rev_id);
6229 LOOP
6230 FETCH c_valid_user_waivers INTO l_waive_user_id;
6231 EXIT WHEN c_valid_user_waivers%NOTFOUND;
6232 G_User_Waiver_List(l_waive_user_id):=l_waive_user_id;
6233 END LOOP;
6234 CLOSE c_valid_user_waivers;
6235 END IF;
6236
6237 -- Logic :
6238 -- G_USER_RESP_VIO_LIST contains incompatible responsibilities
6239 -- accessible to Users
6240 -- We check if the users has access all incompatible responsibilities
6241 -- if yes we mark him as violating user.
6242 IF (G_USER_RESP_VIO_LIST IS NOT NULL) AND (G_USER_RESP_VIO_LIST.FIRST IS NOT NULL) THEN
6243 FOR i in G_USER_RESP_VIO_LIST.FIRST .. G_USER_RESP_VIO_LIST.LAST
6244 LOOP
6245 IF G_USER_RESP_VIO_LIST.EXISTS(i) THEN
6246 L_RESP_ID_LIST:=G_USER_RESP_VIO_LIST(i);
6247
6248 IF (L_RESP_ID_LIST.COUNT = l_constraint_resp_count) THEN
6249 Write_Resp_To_Table_For_User(p_violation_id, p_constraint_rev_id, i, p_revalidate_flag);
6250 ELSE
6254 Update_Violation_User (
6251 -- 05.23.2005 tsho: user doesn't violate this constraint
6252 -- if this check is for revalidation (ie, p_revalidate_flag = 'Y'), update the corrected_flag to 'Y' for this user
6253 IF (p_revalidate_flag IS NOT NULL AND p_revalidate_flag = 'Y') THEN
6255 p_user_violation_id => NULL,
6256 p_violation_id => p_violation_id,
6257 p_violated_by_id => i,
6258 p_corrected_flag => 'Y');
6259 END IF; -- end of if: p_revalidate_flag
6260 END IF; -- end of if: G_UPV_RESPONSIBILITY_ID_LIST.COUNT >= 2
6261 END IF;
6262 END LOOP;
6263 END IF;
6264 --FND_FILE.put_line(fnd_file.log,'out '||L_API_NAME);
6265 END Check_For_Resp_Cst_ALL;
6266
6267
6268 -- ===============================================================
6269 -- Private Procedure name
6270 -- Check_For_Resp_Cst_ME
6271 --
6272 -- Purpose
6273 -- for constraint type = 'Responsibility: Mutuallly Exclusive' (type_code = 'RESPME')
6274 -- check violation for specified constraint
6275 -- this is private procedure,
6276 -- should not call this procedure directly
6277 --
6278 -- Params
6279 -- p_constraint_rev_id := specified constraint_rev_id
6280 --
6281 -- Notes
6282 --
6283 -- History
6284 -- 01.06.2005 tsho: starting from AMW.D,
6285 -- consider Incompatible Responsibilities.
6286 -- ===============================================================
6287 PROCEDURE Check_For_Resp_Cst_ME (
6288 p_constraint_rev_id IN NUMBER,
6289 p_violation_id IN NUMBER,
6290 p_type_code IN VARCHAR2,
6291 p_revalidate_flag IN VARCHAR2 := NULL
6292 )
6293 IS
6294
6295 L_API_NAME CONSTANT VARCHAR2(30) := 'Check_For_Resp_Cst_ME';
6296 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
6297
6298 CURSOR c_valid_user_waivers (l_constraint_rev_id IN NUMBER) IS
6299 SELECT PK1
6300 FROM amw_constraint_waivers_b
6301 WHERE constraint_rev_id = l_constraint_rev_id
6302 AND object_type = 'USER'
6303 AND start_date <= sysdate AND (end_date >= sysdate or end_date is null);
6304
6305 CURSOR c_original_user_violation_id (l_violation_id IN NUMBER) IS
6306 SELECT violated_by_id,user_violation_id
6307 FROM amw_violation_users
6308 WHERE violation_id = l_violation_id;
6309
6310 L_RESP_ID_LIST G_RESPS_TABLE;
6311 l_waive_user_id NUMBER;
6312 l_user_violation_id NUMBER;
6313 l_user_id NUMBER;
6314
6315 BEGIN
6316 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
6317
6318 IF ((p_constraint_rev_id IS NULL) AND (p_type_code IS NULL)) THEN
6319 Return;
6320 END IF;
6321
6322 IF (p_revalidate_flag IS NOT NULL AND p_revalidate_flag = 'Y') THEN
6323 Populate_User_Vio_For_Vlt(p_violation_id => p_violation_id,
6324 p_constraint_rev_id => p_constraint_rev_id,
6325 p_type_code => p_type_code);
6326 ELSE
6327 Populate_User_Vio_For_Cst(p_constraint_rev_id => p_constraint_rev_id,
6328 p_type_code => p_type_code);
6329 END IF;
6330
6331 IF (p_revalidate_flag IS NOT NULL AND p_revalidate_flag = 'Y') THEN
6332
6333 -- When we revalidate a Constraint violation, we identify the existing
6334 -- violating users and store their corresponding user violation id
6335 -- in a associative array for performance.
6336 -- Now we can get the User violation id for a user by using the user id
6337 -- as key on G_User_Violation_Id_list
6338 G_User_Violation_Id_list.DELETE();
6339 OPEN c_original_user_violation_id(p_violation_id);
6340 LOOP
6341 FETCH c_original_user_violation_id INTO l_user_id,l_user_violation_id;
6342 EXIT WHEN c_original_user_violation_id%NOTFOUND;
6343 G_User_Violation_Id_list(l_user_id):=l_user_violation_id;
6344 END LOOP;
6345 CLOSE c_original_user_violation_id;
6346 ELSE
6347
6348 -- We store the users marked as user waiver for the current constraint
6349 -- in a associative array for performamce.
6350 -- Now we can identify if a user is waived or not by checking if
6351 -- the user is in the G_User_Waiver_List associative array. we use the
6352 -- user id as index key
6353 G_User_Waiver_List.DELETE();
6354 OPEN c_valid_user_waivers(p_constraint_rev_id);
6355 LOOP
6356 FETCH c_valid_user_waivers INTO l_waive_user_id;
6357 EXIT WHEN c_valid_user_waivers%NOTFOUND;
6358 G_User_Waiver_List(l_waive_user_id):=l_waive_user_id;
6359 END LOOP;
6360 CLOSE c_valid_user_waivers;
6361 END IF;
6362
6363 -- Logic :
6364 -- G_USER_RESP_VIO_LIST contains incompatible responsibilities
6365 -- accessible to Users
6366 -- We check if the users has access to atleast one incompatible responsibilities
6367 -- if yes we mark him as violating user.
6371 IF G_USER_RESP_VIO_LIST.EXISTS(i) THEN
6368 IF (G_USER_RESP_VIO_LIST IS NOT NULL) AND (G_USER_RESP_VIO_LIST.FIRST IS NOT NULL) THEN
6369 FOR i in G_USER_RESP_VIO_LIST.FIRST .. G_USER_RESP_VIO_LIST.LAST
6370 LOOP
6372 L_RESP_ID_LIST:=G_USER_RESP_VIO_LIST(i);
6373 IF (L_RESP_ID_LIST.COUNT >= 2) THEN
6374 Write_Resp_To_Table_For_User(p_violation_id, p_constraint_rev_id, i, p_revalidate_flag);
6375 ELSE
6376 -- 05.23.2005 tsho: user doesn't violate this constraint
6377 -- if this check is for revalidation (ie, p_revalidate_flag = 'Y'), update the corrected_flag to 'Y' for this user
6378 IF (p_revalidate_flag IS NOT NULL AND p_revalidate_flag = 'Y') THEN
6379 Update_Violation_User (
6380 p_user_violation_id => NULL,
6381 p_violation_id => p_violation_id,
6382 p_violated_by_id => i,
6383 p_corrected_flag => 'Y');
6384 END IF; -- end of if: p_revalidate_flag
6385 END IF; -- end of if: G_UPV_RESPONSIBILITY_ID_LIST.COUNT >= 2
6386 END IF;
6387 END LOOP;
6388 END IF;
6389 END Check_For_Resp_Cst_ME;
6390
6391
6392 -- ===============================================================
6393 -- Private Procedure name
6394 -- Check_For_Resp_Cst_SET
6395 --
6396 -- Purpose
6397 -- for constraint type = 'Responsibility: Incompatible Sets' (type_code = 'RESPSET')
6398 -- check violation for specified constraint
6399 -- this is private procedure,
6400 -- should not call this procedure directly
6401 --
6402 -- Params
6403 -- p_constraint_rev_id := specified constraint_rev_id
6404 --
6405 -- Notes
6406 --
6407 -- History
6408 -- 05.13.2005 tsho: create for AMW.E
6409 -- ===============================================================
6410 PROCEDURE Check_For_Resp_Cst_SET (
6411 p_constraint_rev_id IN NUMBER,
6412 p_violation_id IN NUMBER,
6413 p_type_code IN VARCHAR2,
6414 p_revalidate_flag IN VARCHAR2 := NULL
6415 )
6416 IS
6417
6418 L_API_NAME CONSTANT VARCHAR2(30) := 'Check_For_Resp_Cst_SET';
6419 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
6420 -- store how many incompatible responsibilities he can access so far
6421 l_access_resp_count NUMBER;
6422
6423 -- 05.24.2005 tsho: store those group_code of accessible functions by an user
6424 l_user_access_grp_list G_VARCHAR2_CODE_TABLE;
6425
6426
6427 L_USERVIO_ENTRIES G_USERVIO_ENTRIES_TABLE;
6428 L_RESP_ID_LIST G_RESPS_TABLE;
6429 l_waive_user_id NUMBER;
6430 l_user_violation_id NUMBER;
6431 l_user_id NUMBER;
6432 listkey VARCHAR2(30) := NULL;
6433
6434 CURSOR c_valid_user_waivers (l_constraint_rev_id IN NUMBER) IS
6435 SELECT PK1
6436 FROM amw_constraint_waivers_b
6437 WHERE constraint_rev_id = l_constraint_rev_id
6438 AND object_type = 'USER'
6439 AND start_date <= sysdate AND (end_date >= sysdate or end_date is null);
6440
6441 CURSOR c_original_user_violation_id (l_violation_id IN NUMBER) IS
6442 SELECT violated_by_id,user_violation_id
6443 FROM amw_violation_users
6444 WHERE violation_id = l_violation_id;
6445
6446 BEGIN
6447 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
6448
6449 IF ((p_constraint_rev_id IS NULL) AND (p_type_code IS NULL)) THEN
6450 Return;
6451 END IF;
6452
6453 IF (p_revalidate_flag IS NOT NULL AND p_revalidate_flag = 'Y') THEN
6454 Populate_User_Vio_For_Vlt(p_violation_id => p_violation_id,
6455 p_constraint_rev_id => p_constraint_rev_id,
6456 p_type_code => p_type_code);
6457 ELSE
6458 Populate_User_Vio_For_Cst(p_constraint_rev_id => p_constraint_rev_id,
6459 p_type_code => p_type_code);
6460 END IF;
6461
6462 IF (p_revalidate_flag IS NOT NULL AND p_revalidate_flag = 'Y') THEN
6463
6464 -- When we revalidate a Constraint violation, we identify the existing
6465 -- violating users and store their corresponding user violation id
6466 -- in a associative array for performance.
6467 -- Now we can get the User violation id for a user by using the user id
6468 -- as key on G_User_Violation_Id_list
6469 G_User_Violation_Id_list.DELETE();
6470 OPEN c_original_user_violation_id(p_violation_id);
6471 LOOP
6472 FETCH c_original_user_violation_id INTO l_user_id,l_user_violation_id;
6473 EXIT WHEN c_original_user_violation_id%NOTFOUND;
6474 G_User_Violation_Id_list(l_user_id):=l_user_violation_id;
6475 END LOOP;
6476 CLOSE c_original_user_violation_id;
6477 ELSE
6478
6479 -- We store the users marked as user waiver for the current constraint
6480 -- in a associative array for performamce.
6481 -- Now we can identify if a user is waived or not by checking if
6482 -- the user is in the G_User_Waiver_List associative array. we use the
6483 -- user id as index key
6487 FETCH c_valid_user_waivers INTO l_waive_user_id;
6484 G_User_Waiver_List.DELETE();
6485 OPEN c_valid_user_waivers(p_constraint_rev_id);
6486 LOOP
6488 EXIT WHEN c_valid_user_waivers%NOTFOUND;
6489 G_User_Waiver_List(l_waive_user_id):=l_waive_user_id;
6490 END LOOP;
6491 CLOSE c_valid_user_waivers;
6492 END IF;
6493
6494 -- Logic :
6495 -- G_USER_RESP_VIO_LIST contains incompatible responsibilities
6496 -- accessible to Users
6497 -- We check if the users has access to atleast one incompatible responsibilities
6498 -- from each group
6499 -- if yes we mark him as violating user.
6500 IF (G_USER_RESP_VIO_LIST IS NOT NULL) AND (G_USER_RESP_VIO_LIST.FIRST IS NOT NULL) THEN
6501 FOR i in G_USER_RESP_VIO_LIST.FIRST .. G_USER_RESP_VIO_LIST.LAST
6502 LOOP
6503 IF G_USER_RESP_VIO_LIST.EXISTS(i) THEN
6504 l_user_access_grp_list.DELETE();
6505 L_RESP_ID_LIST:=G_USER_RESP_VIO_LIST(i);
6506 listkey :=L_RESP_ID_LIST.FIRST;
6507 WHILE listkey IS NOT NULL
6508 LOOP
6509 L_USERVIO_ENTRIES:=L_RESP_ID_LIST(listkey);
6510 FOR k IN L_USERVIO_ENTRIES.FIRST .. L_USERVIO_ENTRIES.LAST
6511 LOOP
6512 l_user_access_grp_list(L_USERVIO_ENTRIES(k).group_code):=L_USERVIO_ENTRIES(k).group_code;
6513 END LOOP;
6514 listkey:=L_RESP_ID_LIST.NEXT(listkey);
6515 END LOOP;
6516 IF (l_user_access_grp_list.COUNT >= 2) THEN
6517 Write_Resp_To_Table_For_User(p_violation_id, p_constraint_rev_id, i, p_revalidate_flag);
6518 ELSE
6519 -- 05.23.2005 tsho: user doesn't violate this constraint
6520 -- if this check is for revalidation (ie, p_revalidate_flag = 'Y'), update the corrected_flag to 'Y' for this user
6521 IF (p_revalidate_flag IS NOT NULL AND p_revalidate_flag = 'Y') THEN
6522 Update_Violation_User (
6523 p_user_violation_id => NULL,
6524 p_violation_id => p_violation_id,
6525 p_violated_by_id => i,
6526 p_corrected_flag => 'Y');
6527 END IF; -- end of if: p_revalidate_flag
6528 END IF; -- end of if: G_UPV_RESPONSIBILITY_ID_LIST.COUNT >= 2
6529 END IF;
6530 END LOOP;
6531 END IF;
6532 --FND_FILE.put_line(fnd_file.log,'Comming Out'||L_API_NAME);
6533 END Check_For_Resp_Cst_SET;
6534
6535
6536 -- ===============================================================
6537 -- Private Procedure name
6538 -- Check_Violation_For_Constraint
6539 --
6540 -- Purpose
6541 -- check violation for specified constraint
6542 -- this is private procedure,
6543 -- should not call this procedure directly
6544 --
6545 -- Params
6546 -- p_constraint_rev_id := specified constraint_rev_id
6547 -- p_type_code := the type_code(constraint type) of specified constraint_rev_id
6548 --
6549 -- Notes
6550 -- if at calling time, already know the type_code(constraint type),
6551 -- then don't need to search for type_code against AMW_CONSTRAINTS_B again.
6552 --
6553 -- what if the specified constraint is not a valid constraint?
6554 --
6555 -- 12.21.2004 tsho: fix for performance bug 4036679
6556 -- ===============================================================
6557 PROCEDURE Check_Violation_For_Constraint (
6558 p_constraint_rev_id IN NUMBER,
6559 p_type_code IN VARCHAR2 := NULL
6560 )
6561 IS
6562
6563 L_API_NAME CONSTANT VARCHAR2(30) := 'Check_Violation_For_Constraint';
6564 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.1;
6565
6566 -- store the violation_id getting from Create_Violation
6567 l_violation_id NUMBER := NULL;
6568
6569 -- store the constraint type for this constraint
6570 l_type_code VARCHAR2(30) := p_type_code;
6571
6572 -- find the constraint by specified constraint_rev_id
6573 CURSOR c_constraint (l_constraint_rev_id IN NUMBER) IS
6574 SELECT constraint_rev_id,
6575 start_date,
6576 end_date,
6577 type_code
6578 FROM amw_constraints_b
6579 WHERE constraint_rev_id=l_constraint_rev_id;
6580 l_constraint c_constraint%ROWTYPE;
6581
6582
6583 BEGIN
6584 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
6585
6586 -- create vilation record for specified constriant in AMW_VIOLATIONS
6587 l_violation_id := Create_Violation(p_constraint_rev_id);
6588 IF (l_violation_id IS NULL) THEN
6589 -- create violation in AMW_VIOLATIONS is not successful
6590 RETURN;
6591 END IF;
6592
6593 --FND_FILE.put_line(fnd_file.log,'Violation Id '||l_violation_id);
6594
6595 -- 12.21.2004 tsho: fix for performance bug 4036679
6596 /*
6597 -- if no users in g_user_id_list, then no need to go further to check constraint
6598 IF ((G_USER_ID_LIST IS NULL) OR (G_USER_ID_LIST.FIRST IS NULL)) THEN
6599 RETURN;
6600 END IF;
6601 */
6602
6603 IF (p_constraint_rev_id IS NOT NULL) THEN
6607 OPEN c_constraint(p_constraint_rev_id);
6604 -- no passed-in type_code, need to search for constraint type
6605 IF (l_type_code IS NULL) THEN
6606 BEGIN
6608 FETCH c_constraint INTO l_constraint;
6609 CLOSE c_constraint;
6610 l_type_code := l_constraint.type_code;
6611 EXCEPTION
6612 -- passed-in p_constraint_rev_id not found
6613 WHEN no_data_found THEN
6614 IF c_constraint%ISOPEN THEN
6615 CLOSE c_constraint;
6616 END IF;
6617 --FND_FILE.put_line(fnd_file.log,'passed-in p_constraint_rev_id not found');
6618 RETURN;
6619 END;
6620 END IF; -- end of if: l_type_code IS NULL
6621
6622 -- check violation depends on different constraint type
6623 IF (l_type_code = 'ALL') THEN
6624 -- Check_For_Constraint_ALL(p_constraint_rev_id, l_violation_id);
6625 Check_For_Func_Cst_ALL(p_constraint_rev_id, l_violation_id, l_type_code);
6626 ELSIF (l_type_code = 'ME') THEN
6627 -- Check_For_Constraint_ME(p_constraint_rev_id, l_violation_id);
6628 Check_For_Func_Cst_ME(p_constraint_rev_id, l_violation_id, l_type_code);
6629 ELSIF (l_type_code = 'SET') THEN
6630 Check_For_Func_Cst_SET(p_constraint_rev_id, l_violation_id, l_type_code);
6631 ELSIF (l_type_code = 'RESPALL') THEN
6632 Check_For_Resp_Cst_ALL(p_constraint_rev_id, l_violation_id, l_type_code);
6633 ELSIF (l_type_code = 'RESPME') THEN
6634 Check_For_Resp_Cst_ME(p_constraint_rev_id, l_violation_id, l_type_code);
6635 ELSIF (l_type_code = 'RESPSET') THEN
6636 Check_For_Resp_Cst_SET(p_constraint_rev_id, l_violation_id, l_type_code);
6637 END IF; -- end of if: l_type_code = 'ALL'
6638
6639
6640
6641 END IF; -- end of if: p_constraint_rev_id IS NOT NULL
6642
6643 -- update violation(violator_num, status) for this constriant by specified l_violation_id
6644 Update_Violation(p_violation_id => l_violation_id,
6645 p_constraint_rev_id => p_constraint_rev_id);
6646
6647 -- commit for each constraint, in order to prevent the rollback segment too big
6648 COMMIT;
6649 --FND_FILE.put_line(fnd_file.log,'Came Out '||L_API_NAME);
6650 END Check_Violation_For_Constraint;
6651
6652
6653 -- ===============================================================
6654 -- Procedure name
6655 -- Check_Violation_By_Name
6656 --
6657 -- Purpose
6658 -- This Concurrent Program Executable checks the constraint
6659 -- violation for Constraint Name Starting with p_constraint_name%.
6660 --
6661 -- Params
6662 -- p_constraint_name : Constraint Name Starting With
6663 --
6664 --
6665 -- Notes
6666 -- 18.05.2006 psomanat: created
6667 -- ===============================================================
6668 PROCEDURE Check_Violation_By_Name(
6669 errbuf OUT NOCOPY VARCHAR2,
6670 retcode OUT NOCOPY VARCHAR2,
6671 p_constraint_name IN VARCHAR2:= NULL
6672 )
6673 IS
6674 CURSOR c_all_valid_constraints IS
6675 SELECT CONSTRAINT_REV_ID,
6676 TYPE_CODE
6677 FROM AMW_CONSTRAINTS_VL
6678 WHERE START_DATE <= SYSDATE AND (END_DATE IS NULL OR END_DATE>=SYSDATE )
6679 AND LOWER(CONSTRAINT_NAME) LIKE LOWER(p_constraint_name||'%');
6680
6681 l_all_valid_constraints c_all_valid_constraints%ROWTYPE;
6682
6683 BEGIN
6684 -- get party_id for G_USER_ID
6685 G_PARTY_ID := Get_Party_Id(G_USER_ID);
6686
6687 --FND_FILE.put_line(fnd_file.log,'inside api Check_Violation_By_Name');
6688 OPEN c_all_valid_constraints;
6689 LOOP
6690 FETCH c_all_valid_constraints INTO l_all_valid_constraints;
6691 EXIT WHEN c_all_valid_constraints%NOTFOUND;
6692 --FND_FILE.put_line(fnd_file.log,'Violation Check For : '||l_all_valid_constraints.constraint_rev_id);
6693 --FND_FILE.put_line(fnd_file.log,'Violation Check For : '||l_all_valid_constraints.type_code);
6694 Check_Violation_For_Constraint (p_constraint_rev_id => l_all_valid_constraints.constraint_rev_id,
6695 p_type_code => l_all_valid_constraints.type_code);
6696 END LOOP;
6697 CLOSE c_all_valid_constraints;
6698 END;
6699
6700 -- ===============================================================
6701 -- Procedure name
6702 -- Check_Violation
6703 --
6704 -- Purpose
6705 -- to check violations for constraint
6706 --
6707 -- Params
6708 -- p_check_all_constraint_flag := 'Y' or 'N' (default to 'N')
6709 -- p_constraint_set
6710 -- p_constraint_rev_id1
6711 -- p_constraint_rev_id2
6712 -- p_constraint_rev_id3
6713 -- p_constraint_rev_id4
6714 --
6715 -- Notes
6716 -- If 'Y' is passed-in as p_check_all_constraint_flag,
6717 -- will run violation check for
6718 -- every valid constraint
6719 -- (valid means the current time is between constraint's START_DATE and END_DATE)
6720 -- and ignore the passed-in p_constraint_rev_id.
6721 --
6722 --
6723 -- If 'N' is passed-in as p_check_all_constraint_flag,
6724 -- then check the passed-in p_constraint_rev_id
6725 -- currently only support up to four specified constraints
6726 -- p_constraint_rev_id1....p_constraint_rev_id4
6727 --
6728 -- 12.21.2004 tsho: fix for performance bug 4036679
6729 -- ===============================================================
6730 PROCEDURE Check_Violation(
6731 errbuf OUT NOCOPY VARCHAR2,
6732 retcode OUT NOCOPY VARCHAR2,
6733 p_check_all_constraint_flag IN VARCHAR2 := 'N',
6734 p_constraint_set IN VARCHAR2 := NULL,
6735 p_constraint_rev_id1 IN NUMBER := NULL,
6736 p_constraint_rev_id2 IN NUMBER := NULL,
6737 p_constraint_rev_id3 IN NUMBER := NULL,
6738 p_constraint_rev_id4 IN NUMBER := NULL
6739 )
6740 IS
6741 L_API_NAME CONSTANT VARCHAR2(30) := 'Check_Violation';
6742 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
6743
6744
6745 l_stmt_str VARCHAR2(200) := 'SELECT USER_NAME FROM '||G_AMW_USER;
6746 l_name VARCHAR2(240);
6747 TYPE EmpCurTyp IS REF CURSOR;
6748 cur EmpCurTyp;
6749
6750
6751 -- find all valid constraints
6752 CURSOR c_all_valid_constraints IS
6753 SELECT constraint_rev_id,
6754 type_code
6755 FROM amw_constraints_b
6756 WHERE start_date <= sysdate AND (end_date IS NULL OR end_date >= sysdate);
6757 l_all_valid_constraints c_all_valid_constraints%ROWTYPE;
6758
6759 CURSOR c_constraint_set_details IS
6760 SELECT a.constraint_rev_id,
6761 a.type_code
6762 FROM amw_constraints_b a,
6763 amw_constraint_set_details cs
6764 WHERE cs.constraint_set_code = p_constraint_set
6765 AND cs.constraint_id = a.constraint_id;
6766 l_constraint_set_details c_constraint_set_details%ROWTYPE;
6767
6768 BEGIN
6769 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
6770
6771 -- 12.21.2004 tsho: fix for performance bug 4036679
6772 /*
6773 -- populate global G_USER_ID_LIST, this should be one time work.
6774 IF (G_USER_ID_LIST IS NULL) THEN
6775 Populate_User_Id_List;
6776 END IF;
6777 */
6778
6779 -- get party_id for G_USER_ID
6780 G_PARTY_ID := Get_Party_Id(G_USER_ID);
6781
6782
6783 IF p_check_all_constraint_flag = 'Y' THEN
6784 -- check all constraints
6785 --FND_FILE.put_line(fnd_file.log,'Check Violation for all constraint');
6786 OPEN c_all_valid_constraints;
6787 LOOP
6788 FETCH c_all_valid_constraints INTO l_all_valid_constraints;
6789 EXIT WHEN c_all_valid_constraints%NOTFOUND;
6790 --FND_FILE.put_line(fnd_file.log,'Start Violation Check for Constraint Rev Id :'||l_all_valid_constraints.constraint_rev_id);
6791 --FND_FILE.put_line(fnd_file.log,'Type Code :'|| l_all_valid_constraints.type_code);
6792 Check_Violation_For_Constraint (p_constraint_rev_id => l_all_valid_constraints.constraint_rev_id,
6793 p_type_code => l_all_valid_constraints.type_code);
6794 --FND_FILE.put_line(fnd_file.log,'Completed Violation Check for Constraint Rev Id :'||l_all_valid_constraints.constraint_rev_id);
6795 END LOOP;
6796 CLOSE c_all_valid_constraints;
6797
6798 ELSE
6799 IF (p_constraint_set IS NOT NULL) THEN
6800 --FND_FILE.put_line(fnd_file.log,'Start Violation Check for Constraint Set');
6801 OPEN c_constraint_set_details;
6802 LOOP
6803 FETCH c_constraint_set_details INTO l_constraint_set_details;
6804 EXIT WHEN c_constraint_set_details%NOTFOUND;
6805
6806 if (l_constraint_set_details.constraint_rev_id not in
6807 (nvl(p_constraint_rev_id1,-1),
6808 nvl(p_constraint_rev_id2,-1),
6809 nvl(p_constraint_rev_id3,-1),
6810 nvl(p_constraint_rev_id4,-1)
6811 )) then
6812
6816 p_type_code => l_constraint_set_details.type_code);
6813 --FND_FILE.put_line(fnd_file.log,'Start Violation Check for Constraint Rev Id :'||l_constraint_set_details.constraint_rev_id);
6814 --FND_FILE.put_line(fnd_file.log,'Type Code :'|| l_constraint_set_details.type_code);
6815 Check_Violation_For_Constraint (p_constraint_rev_id => l_constraint_set_details.constraint_rev_id,
6817 --FND_FILE.put_line(fnd_file.log,'Completed Violation Check for Constraint Rev Id :'||l_constraint_set_details.constraint_rev_id);
6818 end if;
6819 END LOOP;
6820 CLOSE c_constraint_set_details;
6821 END IF;
6822
6823 -- check specified constraint
6824 IF p_constraint_rev_id1 IS NOT NULL THEN
6825 --FND_FILE.put_line(fnd_file.log,'Start Violation Check for Constraint Rev Id :'||p_constraint_rev_id1);
6826 Check_Violation_For_Constraint(p_constraint_rev_id => p_constraint_rev_id1);
6827 --FND_FILE.put_line(fnd_file.log,'Completed Violation Check for Constraint Rev Id :'||p_constraint_rev_id1);
6828 END IF;
6829 IF p_constraint_rev_id2 IS NOT NULL THEN
6830 --FND_FILE.put_line(fnd_file.log,'Start Violation Check for Constraint Rev Id :'||p_constraint_rev_id2);
6831 Check_Violation_For_Constraint(p_constraint_rev_id => p_constraint_rev_id2);
6832 --FND_FILE.put_line(fnd_file.log,'Completed Violation Check for Constraint Rev Id :'||p_constraint_rev_id2);
6833 END IF;
6834 IF p_constraint_rev_id3 IS NOT NULL THEN
6835 --FND_FILE.put_line(fnd_file.log,'Start Violation Check for Constraint Rev Id :'||p_constraint_rev_id3);
6836 Check_Violation_For_Constraint(p_constraint_rev_id => p_constraint_rev_id3);
6837 --FND_FILE.put_line(fnd_file.log,'Completed Violation Check for Constraint Rev Id :'||p_constraint_rev_id3);
6838 END IF;
6839 IF p_constraint_rev_id4 IS NOT NULL THEN
6840 --FND_FILE.put_line(fnd_file.log,'Start Violation Check for Constraint Rev Id :'||p_constraint_rev_id4);
6841 Check_Violation_For_Constraint(p_constraint_rev_id => p_constraint_rev_id4);
6842 --FND_FILE.put_line(fnd_file.log,'Completed Violation Check for Constraint Rev Id :'||p_constraint_rev_id4);
6843 END IF;
6844
6845 END IF;
6846
6847 End Check_Violation;
6848
6849
6850
6851 -- ===============================================================
6852 -- Procedure name
6853 -- Revalidate_Violation
6854 -- Purpose
6855 -- to revalidate existing violators of specified violation report
6856 --
6857 -- Params
6858 -- p_violation_id
6859 --
6860 -- Notes
6861 -- this only checks violations for existing violators (against this constraint),
6862 -- don't consider if any other users violate this constraint or not.
6863 -- History
6864 -- 05.20.2005 tsho: create for AMW.E
6865 -- ===============================================================
6866 PROCEDURE Revalidate_Violation(
6867 errbuf OUT NOCOPY VARCHAR2,
6868 retcode OUT NOCOPY VARCHAR2,
6869 p_violation_id IN NUMBER := NULL
6870 )
6871 IS
6872 L_API_NAME CONSTANT VARCHAR2(30) := 'Revalidate_Violation';
6873 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
6874
6875 -- find the constraint related to this violation
6876 CURSOR c_constraint(l_violation_id IN NUMBER) IS
6877 SELECT cst.constraint_rev_id
6878 ,cst.type_code
6879 FROM amw_constraints_b cst
6880 ,amw_violations v
6881 WHERE v.violation_id = l_violation_id
6882 AND v.constraint_rev_id = cst.constraint_rev_id;
6883 l_constraint c_constraint%ROWTYPE;
6884
6885 BEGIN
6886 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
6887
6888 -- get party_id for G_USER_ID
6889 G_PARTY_ID := Get_Party_Id(G_USER_ID);
6890
6891 IF p_violation_id IS NOT NULL THEN
6892 OPEN c_constraint (p_violation_id);
6893 FETCH c_constraint INTO l_constraint;
6894 CLOSE c_constraint;
6895
6896 -- ptulasi : 18-02-2008
6897 -- bug : 6689589 : If a responsibility violating the constraint is end dated, the staus for the
6898 -- user having this responsibility only should be shown as closed. But this is not happening. This is
6899 -- because the corrected_flag for the user is not set to yes. The query used to fetch the user and his
6900 -- responsibilities will not fetch the end dated responsibilities. So no action is taken against the
6901 -- user having responsibilities which violate the constraint.
6902 -- Updated the corrected_flag of all the violating users to yes. For the violating users,
6903 -- the corrected_flag will be set to no.
6904 UPDATE AMW_VIOLATION_USERS
6905 SET CORRECTED_FLAG = 'Y'
6906 WHERE VIOLATION_ID = p_violation_id;
6907
6908 IF (l_constraint.constraint_rev_id IS NOT NULL AND l_constraint.type_code IS NOT NULL) THEN
6909 -- revalidate violation depends on different constraint type
6910 IF (l_constraint.type_code = 'ALL') THEN
6911 Check_For_Func_Cst_ALL(l_constraint.constraint_rev_id, p_violation_id, l_constraint.type_code, 'Y');
6912 ELSIF (l_constraint.type_code = 'ME') THEN
6913 Check_For_Func_Cst_ME(l_constraint.constraint_rev_id, p_violation_id, l_constraint.type_code, 'Y');
6914 ELSIF (l_constraint.type_code = 'SET') THEN
6915 Check_For_Func_Cst_SET(l_constraint.constraint_rev_id, p_violation_id, l_constraint.type_code, 'Y');
6916 ELSIF (l_constraint.type_code = 'RESPALL') THEN
6917 Check_For_Resp_Cst_ALL(l_constraint.constraint_rev_id, p_violation_id, l_constraint.type_code, 'Y');
6918 ELSIF (l_constraint.type_code = 'RESPME') THEN
6919 Check_For_Resp_Cst_ME(l_constraint.constraint_rev_id, p_violation_id, l_constraint.type_code, 'Y');
6920 ELSIF (l_constraint.type_code = 'RESPSET') THEN
6921 Check_For_Resp_Cst_SET(l_constraint.constraint_rev_id, p_violation_id, l_constraint.type_code, 'Y');
6922 END IF; -- end of if: l_type_code = 'ALL'
6923
6924 END IF; -- end of if: l_constraint.constraint_rev_id IS NOT NULL
6925 END IF; -- end of if: p_violation_id IS NOT NULL
6926
6927 -- update violation(violator_num, status) for this constriant by specified l_violation_id
6928 Update_Violation(p_violation_id => p_violation_id,
6929 p_constraint_rev_id => l_constraint.constraint_rev_id,
6930 p_revalidate_flag => 'Y');
6931
6932 -- commit for each constraint, in order to prevent the rollback segment too big
6933 COMMIT;
6934
6935 End Revalidate_Violation;
6936
6937
6938 -- ===============================================================
6939 -- Function name
6940 -- Get_Resps_By_Appl
6941 --
6942 -- Purpose
6943 -- get the responsibility by specified applicaiton_id,
6944 -- Params
6945 -- p_appl_id := specified application_id
6946 --
6947 -- ===============================================================
6948 Procedure Get_Resps_By_Appl (
6949 p_appl_id IN NUMBER,
6950 x_resp_list OUT NOCOPY VARCHAR2,
6951 x_menu_list OUT NOCOPY VARCHAR2,
6952 x_return_status OUT NOCOPY VARCHAR2,
6953 x_msg_count OUT NOCOPY NUMBER,
6954 x_msg_data OUT NOCOPY VARCHAR2
6955 )
6956 IS
6957
6958 L_API_NAME CONSTANT VARCHAR2(30) := 'Get_Resps_By_Appl';
6959 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
6960
6961 -- find the responsibilities by specified app_id
6962 l_resp_id_list G_NUMBER_TABLE;
6963 l_resp_id NUMBER;
6964
6965 -- find the responsibility menu ids by specified app_id
6966 l_menu_id_list G_NUMBER_TABLE;
6967 l_menu_id NUMBER;
6968
6969 -- store the tmp count for l_resp_id_list
6970 j NUMBER;
6971
6972 -- store the tmp count for l_resp_id_list
6973 k NUMBER;
6974
6975 -- 12.12.2003 tsho: use static sql for AMW for the time being
6976 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
6977 TYPE respCurTyp IS REF CURSOR;
6978 resp_c respCurTyp;
6979 l_resp_dynamic_sql VARCHAR2(200) :=
6980 'SELECT responsibility_id, menu_id '
6981 ||' FROM '||G_AMW_RESPONSIBILITY
6982 ||' WHERE application_id = :1 ';
6983 /*
6984 cursor get_resp_c(l_appl_id IN NUMBER) is
6985 SELECT responsibility_id,
6986 menu_id
6987 from FND_RESPONSIBILITY
6988 where application_id = l_appl_id;
6989 */
6990
6991 BEGIN
6992 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
6993
6994 IF (p_appl_id IS NOT NULL) THEN
6995 -- get user(usre i)'s responsibilities
6996 IF (BULK_COLLECTS_SUPPORTED) THEN
6997 -- 12.12.2003 tsho: use static sql for AMW for the time being
6998 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
6999 OPEN resp_c FOR l_resp_dynamic_sql USING
7000 p_appl_id;
7001 FETCH resp_c BULK COLLECT INTO l_resp_id_list,
7002 l_menu_id_list;
7003 CLOSE resp_c;
7004 /*
7005 SELECT responsibility_id,
7006 menu_id
7007 BULK COLLECT INTO l_resp_id_list,
7008 l_menu_id_list
7009 FROM FND_RESPONSIBILITY
7010 WHERE application_id = p_appl_id;
7011 */
7012
7013 ELSE
7014 -- no BULK_COLLECTS_SUPPORTED
7015 j := 0;
7016 -- 12.12.2003 tsho: use static sql for AMW for the time being
7017 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
7018 OPEN resp_c FOR l_resp_dynamic_sql USING
7019 p_appl_id;
7020 LOOP
7021 FETCH resp_c INTO l_resp_id,
7022 l_menu_id;
7023 EXIT WHEN resp_c%NOTFOUND;
7024 j := j+1;
7025 l_resp_id_list(j) := l_resp_id;
7026 l_menu_id_list(j) := l_menu_id;
7027 END LOOP;
7028 CLOSE resp_c;
7029 /*
7030 for rec in get_resp_c(p_appl_id) loop
7031 j := j + 1;
7032 l_resp_id_list(j) := rec.responsibility_id;
7033 l_menu_id_list(j) := rec.menu_id;
7034 end loop;
7035 */
7036 END IF; -- end of if: BULK_COLLECTS_SUPPORTED
7037
7038 END IF; -- end of if: p_appl_id is not NULL
7039
7040 FOR K IN 1 .. l_resp_id_list.count
7041 LOOP
7042 x_resp_list := x_resp_list || ',' || l_resp_id_list(K);
7043 x_menu_list := x_menu_list || ',' || l_menu_id_list(K);
7044 END LOOP;
7045
7046 x_resp_list := rtrim(ltrim(x_resp_list,','),',');
7047 x_menu_list := rtrim(ltrim(x_menu_list,','),',');
7048
7049 END Get_Resps_By_Appl;
7050
7051
7052
7053 -- ===============================================================
7054 -- Function name
7055 -- Get_Functions_By_Appl
7056 -- Purpose
7057 -- get the available functions by specified applicaiton_id,
7058 -- Params
7059 -- p_appl_id := specified application_id
7060 --
7061 -- ===============================================================
7062 Function Get_Functions_By_Appl (
7063 p_appl_id IN NUMBER
7064 )
7065 Return VARCHAR2
7066 IS
7067
7068 L_API_NAME CONSTANT VARCHAR2(30) := 'Get_Functions_By_Appl';
7069 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
7070
7071 L_FUNCTION_ID_LIST G_NUMBER_TABLE;
7072
7073 -- 05.10 2004 tsho: store available function id
7074 l_available_function_list VARCHAR2(32767) := '';
7075
7076 -- 05.10 2004 tsho: store available function id under specific responsibility
7077 l_resp_function_list VARCHAR2(32767) := '';
7078
7079 -- find the responsibilities by specified app_id
7080 l_resp_id_list G_NUMBER_TABLE;
7081 l_resp_id NUMBER;
7082
7083 -- find the responsibility menu ids by specified app_id
7084 l_menu_id_list G_NUMBER_TABLE;
7085 l_menu_id NUMBER;
7086
7087 -- store the tmp count for l_resp_id_list
7088 j NUMBER;
7089
7090 -- store the tmp count for l_resp_id_list
7091 k NUMBER;
7092
7093 -- 12.12.2003 tsho: use static sql for AMW for the time being
7094 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
7095 TYPE respCurTyp IS REF CURSOR;
7096 resp_c respCurTyp;
7097 l_resp_dynamic_sql VARCHAR2(200) :=
7098 'SELECT responsibility_id, menu_id '
7099 ||' FROM '||G_AMW_RESPONSIBILITY
7100 ||' WHERE application_id = :1 ';
7101 /*
7102 cursor get_resp_c(l_appl_id IN NUMBER) is
7103 SELECT responsibility_id,
7104 menu_id
7105 from FND_RESPONSIBILITY
7106 where application_id = l_appl_id;
7107 */
7108
7109 BEGIN
7110 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
7111
7112 IF (p_appl_id IS NOT NULL) THEN
7113 -- get user(usre i)'s responsibilities
7114 IF (BULK_COLLECTS_SUPPORTED) THEN
7115 -- 12.12.2003 tsho: use static sql for AMW for the time being
7116 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
7117 OPEN resp_c FOR l_resp_dynamic_sql USING
7118 p_appl_id;
7119 FETCH resp_c BULK COLLECT INTO l_resp_id_list,
7120 l_menu_id_list;
7121 CLOSE resp_c;
7122 /*
7123 SELECT responsibility_id,
7124 menu_id
7125 BULK COLLECT INTO l_resp_id_list,
7126 l_menu_id_list
7127 FROM FND_RESPONSIBILITY
7128 WHERE application_id = p_appl_id;
7129 */
7130
7131 ELSE
7132 -- no BULK_COLLECTS_SUPPORTED
7133 j := 0;
7134 -- 12.12.2003 tsho: use static sql for AMW for the time being
7135 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
7136 OPEN resp_c FOR l_resp_dynamic_sql USING
7137 p_appl_id;
7138 LOOP
7139 FETCH resp_c INTO l_resp_id,
7140 l_menu_id;
7141 EXIT WHEN resp_c%NOTFOUND;
7142 j := j+1;
7143 l_resp_id_list(j) := l_resp_id;
7144 l_menu_id_list(j) := l_menu_id;
7145 END LOOP;
7146 CLOSE resp_c;
7147 /*
7148 for rec in get_resp_c(p_appl_id) loop
7149 j := j + 1;
7150 l_resp_id_list(j) := rec.responsibility_id;
7151 l_menu_id_list(j) := rec.menu_id;
7152 end loop;
7153 */
7154 END IF; -- end of if: BULK_COLLECTS_SUPPORTED
7155
7156 END IF; -- end of if: p_appl_id is not NULL
7157
7158
7159 FOR K IN 1 .. l_resp_id_list.count
7160 LOOP
7161 l_resp_function_list := Get_Functions_By_Resp(p_appl_id => p_appl_id,
7162 p_resp_id => l_resp_id_list(K),
7163 p_menu_id => l_menu_id_list(K));
7164 l_available_function_list := l_available_function_list||','||l_resp_function_list;
7165 END LOOP;
7166
7167 RETURN l_available_function_list;
7168
7169 END Get_Functions_By_Appl;
7170
7171
7172
7173
7174 -- ===============================================================
7175 -- Function name
7176 -- Get_Functions_By_Resp
7177 --
7178 -- Purpose
7179 -- get the available functions by specified resp_id,
7180 -- Params
7181 -- p_appl_id := specified application_id
7182 -- p_resp_id := specified responsibility_id
7183 -- p_menu_id := specified menu_id
7184 -- Notes
7185 -- this Function is modified from PROCESS_MENU_TREE_DOWN_MN,
7186 -- Instead of checking specific function_id, check all the
7187 -- available functions under specific responsibility_id
7188 --
7189 -- ===============================================================
7190 Function Get_Functions_By_Resp (
7191 p_appl_id IN NUMBER,
7192 p_resp_id IN NUMBER,
7193 p_menu_id IN NUMBER
7194 )
7195 Return VARCHAR2
7196 IS
7197
7198 L_API_NAME CONSTANT VARCHAR2(30) := 'Get_Functions_By_Resp';
7199 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
7200
7201 -- 05.10 2004 tsho: store available function id
7202 l_available_function_list VARCHAR2(32767) := '';
7203
7204 l_sub_menu_id number;
7205
7206 /* Table to store the list of submenus that we are looking for */
7210 TYPE NUMBER_TABLE_TYPE is table of NUMBER INDEX BY BINARY_INTEGER;
7207 TYPE MENULIST_TYPE is table of NUMBER INDEX BY BINARY_INTEGER;
7208 MENULIST MENULIST_TYPE;
7209
7211 TYPE VARCHAR2_TABLE_TYPE is table of VARCHAR2(1) INDEX BY BINARY_INTEGER;
7212
7213 /* The table of exclusions. The index in is the action_id, and the */
7214 /* value stored in each element is the rule_type.*/
7215 EXCLUSIONS VARCHAR2_TABLE_TYPE;
7216
7217 /* Returns from the bulk collect (fetches) */
7218 TBL_MENU_ID NUMBER_TABLE_TYPE;
7219 TBL_ENT_SEQ NUMBER_TABLE_TYPE;
7220 TBL_FUNC_ID NUMBER_TABLE_TYPE;
7221 TBL_SUBMNU_ID NUMBER_TABLE_TYPE;
7222 TBL_GNT_FLG VARCHAR2_TABLE_TYPE;
7223
7224
7225 /* Cursor to get exclusions */
7226 -- 11.12.2003 tsho: use dynamic sql for AMW
7227 /*
7228 cursor excl_c is
7229 SELECT RULE_TYPE, ACTION_ID from fnd_resp_functions
7230 where application_id = p_appl_id
7231 and responsibility_id = p_resp_id;
7232 */
7233 -- 12.12.2003 tsho: use static sql for AMW for the time being
7234 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
7235 TYPE exclCurTyp IS REF CURSOR;
7236 excl_c exclCurTyp;
7237 l_excl_rule_type VARCHAR2(30);
7238 l_excl_action_id NUMBER;
7239 l_excl_dynamic_sql VARCHAR2(200) :=
7240 'SELECT RULE_TYPE, ACTION_ID '
7241 ||' FROM '||G_AMW_RESP_FUNCTIONS
7242 ||' WHERE application_id = :1 '
7243 ||' AND responsibility_id = :2 ';
7244
7245
7246 /* Cursor to get menu entries on a particular menu.*/
7247 -- 11.12.2003 tsho: use dynamic sql for AMW
7248 /*
7249 cursor get_mnes_c is
7250 SELECT MENU_ID, ENTRY_SEQUENCE, FUNCTION_ID, SUB_MENU_ID, GRANT_FLAG
7251 from fnd_menu_entries
7252 where MENU_ID = l_sub_menu_id;
7253 */
7254 -- 12.12.2003 tsho: use static sql for AMW for the time being
7255 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
7256 TYPE mnesCurTyp IS REF CURSOR;
7257 get_mnes_c mnesCurTyp;
7258 l_mnes_menu_id NUMBER;
7259 l_mnes_entry_sequence NUMBER;
7260 l_mnes_function_id NUMBER;
7261 l_mnes_sub_menu_id NUMBER;
7262 l_mnes_grant_flag VARCHAR2(1);
7263 l_mnes_dynamic_sql VARCHAR2(200) :=
7264 'SELECT MENU_ID, ENTRY_SEQUENCE, FUNCTION_ID, SUB_MENU_ID, GRANT_FLAG '
7265 ||' FROM '||G_AMW_MENU_ENTRIES
7266 ||' WHERE menu_id = :1 ';
7267
7268 menulist_cur pls_integer;
7269 menulist_size pls_integer;
7270
7271 entry_excluded boolean;
7272 last_index pls_integer;
7273 i number;
7274 z number;
7275
7276 BEGIN
7277 --FND_FILE.put_line(fnd_file.log,'inside api '||L_API_NAME);
7278
7279 if(p_appl_id is not NULL) then
7280 /* Select the list of exclusion rules into our cache */
7281 -- 11.12.2003 tsho: use dynamic sql for AMW
7282 /*
7283 for excl_rec in excl_c loop
7284 EXCLUSIONS(excl_rec.action_id) := excl_rec.rule_type;
7285 end loop;
7286 */
7287 -- 12.12.2003 tsho: use static sql for AMW for the time being
7288 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
7289 OPEN excl_c FOR l_excl_dynamic_sql USING
7290 p_appl_id,
7291 p_resp_id;
7292 LOOP
7293 FETCH excl_c INTO l_excl_rule_type, l_excl_action_id;
7294 EXIT WHEN excl_c%NOTFOUND;
7295 EXCLUSIONS(l_excl_action_id) := l_excl_rule_type;
7296 END LOOP;
7297 CLOSE excl_c;
7298
7299 end if;
7300
7301
7302 -- Initialize menulist working list to parent menu
7303 menulist_cur := 0;
7304 menulist_size := 1;
7305 menulist(0) := p_menu_id;
7306
7307 -- Continue processing until reach the end of list
7308 while (menulist_cur < menulist_size) loop
7309 -- Check if recursion limit exceeded
7310 if (menulist_cur > C_MAX_MENU_ENTRIES) then
7311 /* If the function were accessible from this menu, then we should */
7312 /* have found it before getting to this point, so we are confident */
7313 /* that the function is not on this menu. */
7314 return l_available_function_list;
7315 end if;
7316
7317 l_sub_menu_id := menulist(menulist_cur);
7318
7319 -- See whether the current menu is excluded or not.
7320 entry_excluded := FALSE;
7321 begin
7322 if( (l_sub_menu_id is not NULL)
7323 and (exclusions(l_sub_menu_id) = 'M')) then
7324 entry_excluded := TRUE;
7325 end if;
7326 exception
7327 when no_data_found then
7328 null;
7329 end;
7330
7331 if (entry_excluded) then
7332 last_index := 0; /* Indicate that no rows were returned */
7333 else
7334 /* This menu isn't excluded, so find out whats entries are on it. */
7335 if (BULK_COLLECTS_SUPPORTED) then
7336 -- 11.12.2003 tsho: use dynamic sql for AMW
7337 /*
7338 open get_mnes_c;
7339 */
7340 -- 12.12.2003 tsho: use static sql for AMW for the time being
7341 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
7342 open get_mnes_c for l_mnes_dynamic_sql USING
7343 l_sub_menu_id;
7344
7345 fetch get_mnes_c bulk collect into tbl_menu_id, tbl_ent_seq,
7346 tbl_func_id, tbl_submnu_id, tbl_gnt_flg;
7347 close get_mnes_c;
7351 if((tbl_menu_id.FIRST is NULL) or (tbl_menu_id.FIRST <> 1)) then
7348
7349 -- See if we found any rows. If not set last_index to zero.
7350 begin
7352 last_index := 0;
7353 else
7354 if (tbl_menu_id.FIRST is not NULL) then
7355 last_index := tbl_menu_id.LAST;
7356 else
7357 last_index := 0;
7358 end if;
7359 end if;
7360 exception
7361 when others then
7362 last_index := 0;
7363 end;
7364 else
7365 z:= 0;
7366
7367 -- 11.12.2003 tsho: use dynamic sql for AMW
7368 /*
7369 for rec in get_mnes_c loop
7370 z := z + 1;
7371 tbl_menu_id(z) := rec.MENU_ID;
7372 tbl_ent_seq(z) := rec.ENTRY_SEQUENCE;
7373 tbl_func_id(z) := rec.FUNCTION_ID;
7374 tbl_submnu_id (z):= rec.SUB_MENU_ID;
7375 tbl_gnt_flg(z) := rec.GRANT_FLAG;
7376 end loop;
7377 */
7378 -- 12.12.2003 tsho: use static sql for AMW for the time being
7379 -- 04.30.2004 tsho: enable dynamic sql in AMW.C with 5.10
7380 OPEN get_mnes_c FOR l_mnes_dynamic_sql USING
7381 l_sub_menu_id;
7382 LOOP
7383 FETCH get_mnes_c INTO l_mnes_menu_id,
7384 l_mnes_entry_sequence,
7385 l_mnes_function_id,
7386 l_mnes_sub_menu_id,
7387 l_mnes_grant_flag;
7388 EXIT WHEN get_mnes_c%NOTFOUND;
7389 tbl_menu_id(z) := l_mnes_menu_id;
7390 tbl_ent_seq(z) := l_mnes_entry_sequence;
7391 tbl_func_id(z) := l_mnes_function_id;
7392 tbl_submnu_id (z):= l_mnes_sub_menu_id;
7393 tbl_gnt_flg(z) := l_mnes_grant_flag;
7394 END LOOP;
7395 CLOSE get_mnes_c;
7396
7397 last_index := z;
7398 end if;
7399
7400
7401 end if; /* entry_excluded */
7402
7403 -- Process each of the child entries fetched
7404 for i in 1 .. last_index loop
7405 -- Check if there is an exclusion rule for this entry
7406 entry_excluded := FALSE;
7407 begin
7408 if( (tbl_func_id(i) is not NULL)
7409 and (exclusions(tbl_func_id(i)) = 'F')) then
7410 entry_excluded := TRUE;
7411 end if;
7412 exception
7413 when no_data_found then
7414 null;
7415 end;
7416
7417 -- Skip this entry if it's excluded
7418 if (not entry_excluded) then
7419 if((tbl_gnt_flg(i) = 'Y') AND (tbl_func_id(i) is not NULL) ) then
7420 l_available_function_list := l_available_function_list || ',' || tbl_func_id(i);
7421 end if;
7422
7423 -- If this is a submenu, then add it to the end of the
7424 -- working list for processing.
7425 if (tbl_submnu_id(i) is not NULL) then
7426 menulist(menulist_size) := tbl_submnu_id(i);
7427 menulist_size := menulist_size + 1;
7428 end if;
7429 end if; -- End if not excluded
7430 end loop; -- For loop processing child entries
7431
7432 -- Advance to next menu on working list
7433 menulist_cur := menulist_cur + 1;
7434 end loop;
7435
7436 -- We couldn't find the function anywhere, so it's not available
7437 return rtrim(ltrim(l_available_function_list,','),',');
7438
7439 END Get_Functions_By_Resp;
7440
7441
7442
7443 -- ===============================================================
7444 -- Procedure name
7445 -- Purge_Violation_Before_Date
7446 -- Purpose
7447 -- to clear violation history before the specified date
7448 -- Params
7449 -- p_delopt
7450 -- p_date
7451 -- Notes
7452 -- p_delopt can have one of the two values
7453 -- ALLCSTVIO - All Constraint Violations
7454 -- INVALCSTVIO - Invalid Constraint Violations
7455 -- p_date will have passed-in date
7456 --
7457 -- With "ALL Constraint Violations", we will delete all the constraint
7458 -- violations created before the specified date.
7459 -- With "Invalid Constraint violations", we will delete all the invalid
7460 -- constraint violations created before the specified date. deleted.
7461 --
7462 -- History
7463 -- 12.01.2005 tsho create (related to customer requirement: bug 4673154)
7464 -- 12.14.2006 psomanat Added delete statements for amw_violation_resp and amw_violat_resp_entries
7465 -- 03.14.2007 psomanat Added parameter p_delopt
7466 -- ===============================================================
7467 PROCEDURE Purge_Violation_Before_Date (
7468 errbuf OUT NOCOPY VARCHAR2,
7469 retcode OUT NOCOPY VARCHAR2,
7470 p_delopt IN VARCHAR2 := NULL,
7471 p_date IN VARCHAR2 := NULL
7472 ) IS
7473 L_API_NAME CONSTANT VARCHAR2(30) := 'Purge_Violation_Before_Date';
7474 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
7475 l_date DATE;
7476 BEGIN
7477 FND_FILE.put_line(fnd_file.log,'Passed-in Delete Option is: '||p_delopt);
7478 FND_FILE.put_line(fnd_file.log,'Passed-in date is: '||p_date);
7479
7483 l_date := trunc(sysdate) + 1;
7480 IF p_date IS NOT NULL THEN
7481 l_date := trunc(to_date(p_date,'YYYY/MM/DD HH24:MI:SS')) + 1;
7482 ELSE
7484 END IF;
7485 FND_FILE.put_line(fnd_file.log,'will delete violation history prior(<) to : '||l_date);
7486
7487 FND_FILE.put_line(fnd_file.log,'Delete Constraint Violation Start');
7488 IF p_delopt = 'ALLCSTVIO' THEN
7489 DELETE FROM amw_violat_resp_entries
7490 WHERE creation_date < l_date;
7491
7492 DELETE FROM amw_violation_resp
7493 WHERE creation_date < l_date;
7494
7495 DELETE FROM amw_violat_user_entries
7496 WHERE creation_date < l_date;
7497
7498 DELETE FROM amw_violation_users
7499 WHERE creation_date < l_date;
7500
7501 DELETE FROM amw_violations
7502 WHERE creation_date < l_date;
7503
7504 ELSE
7505
7506 DELETE FROM amw_violat_resp_entries
7507 WHERE resp_violation_id IN (
7508 SELECT resp_violation_id
7509 FROM amw_violation_resp
7510 WHERE violation_id IN (
7511 SELECT violation_id
7512 FROM amw_violations
7513 WHERE status_code = 'NA'
7514 AND creation_date < l_date));
7515
7516
7517 DELETE FROM amw_violation_resp
7518 WHERE violation_id IN (
7519 SELECT violation_id
7520 FROM amw_violations
7521 WHERE status_code = 'NA'
7522 AND creation_date < l_date);
7523
7524 DELETE FROM amw_violat_user_entries
7525 WHERE user_violation_id IN (
7526 SELECT user_violation_id
7527 FROM amw_violation_users
7528 WHERE violation_id IN (
7529 SELECT violation_id
7530 FROM amw_violations
7531 WHERE status_code = 'NA'
7532 AND creation_date < l_date ));
7533
7534 DELETE FROM amw_violation_users
7535 WHERE violation_id IN (
7536 SELECT violation_id
7537 FROM amw_violations
7538 WHERE status_code = 'NA'
7539 AND creation_date < l_date );
7540
7541 DELETE FROM amw_violations
7542 WHERE status_code = 'NA'
7543 AND creation_date < l_date ;
7544
7545 END IF;
7546 COMMIT;
7547
7548 FND_FILE.put_line(fnd_file.log,'Delete Constraint Violation END');
7549
7550 END Purge_Violation_Before_Date;
7551
7552 -- ----------------------------------------------------------------------
7553
7554 END AMW_CONSTRAINT_PVT;