[Home] [Help]
PACKAGE BODY: APPS.AMW_FINDINGS_PKG
Source
1 package body amw_findings_pkg as
2 /* $Header: amwfindb.pls 120.0 2005/05/31 19:49:54 appldev noship $ */
3
4 -------------------------------------------------------------------------
5 -- Function that calculates the number of open change objects for an AMW
6 -- objects.
7 -------------------------------------------------------------------------
8
9 function calculate_open_findings ( findings_category char,
10 self_entity_name char, self_pk1_value number,
11 parent1_entity_name char, parent1_pk1_value number,
12 parent2_entity_name char, parent2_pk1_value number,
13 parent3_entity_name char, parent3_pk1_value number,
14 parent4_entity_name char, parent4_pk1_value number )
15 return number is
16
17 ofcount number;
18
19 begin
20
21 select count ( ecs_self.change_id )
22 into ofcount
23 from eng_change_subjects ecs_self, eng_engineering_changes eec
24 where ecs_self.change_id = eec.change_id
25 and ecs_self.entity_name = self_entity_name
26 and ecs_self.pk1_value = self_pk1_value
27 and ecs_self.subject_level = 1
28
29 and eec.organization_id = -1
30 and eec.status_type = 1
31 and eec.change_mgmt_type_code = findings_category
32
33 and exists ( select change_id from eng_change_subjects ecs_par1
34 where ecs_par1.change_id = ecs_self.change_id
35 and ecs_par1.entity_name = nvl ( parent1_entity_name, self_entity_name )
36 and ecs_par1.pk1_value = nvl ( parent1_pk1_value, self_pk1_value )
37 and ecs_par1.subject_level = decode ( parent1_entity_name, NULL, 1, 2 ) )
38
39 and exists ( select change_id from eng_change_subjects ecs_par2
40 where ecs_par2.change_id = ecs_self.change_id
41 and ecs_par2.entity_name = nvl ( parent2_entity_name, self_entity_name )
42 and ecs_par2.pk1_value = nvl ( parent2_pk1_value, self_pk1_value )
43 and ecs_par2.subject_level = decode ( parent2_entity_name, NULL, 1, 3 ) )
44
45 and exists ( select change_id from eng_change_subjects ecs_par3
46 where ecs_par3.change_id = ecs_self.change_id
47 and ecs_par3.entity_name = nvl ( parent3_entity_name, self_entity_name )
48 and ecs_par3.pk1_value = nvl ( parent3_pk1_value, self_pk1_value )
49 and ecs_par3.subject_level = decode ( parent3_entity_name, NULL, 1, 4 ) )
50
51 and exists ( select change_id from eng_change_subjects ecs_par4
52 where ecs_par4.change_id = ecs_self.change_id
53 and ecs_par4.entity_name = nvl ( parent4_entity_name, self_entity_name )
54 and ecs_par4.pk1_value = nvl ( parent4_pk1_value, self_pk1_value )
55 and ecs_par4.subject_level = decode ( parent4_entity_name, NULL, 1, 5 ) );
56
57 return ofcount;
58
59 end calculate_open_findings;
60
61 -------------------------------------------------------------------------
62 -- Function to decide whether to show create button or not.
63 -- Returns 1 if ok to show create button, 0 otherwise.
64 -------------------------------------------------------------------------
65
66 function is_create_enabled
67 ( change_category char, org_id number, myprocess_id number )
68
69 return number is
70
71 respkey varchar2(100);
72
73 begin
74
75 -- Always show for disclosure committees because function security is in place.
76
77 if ( change_category = 'AMW_DISC_COMMITTEES' ) then
78 return 1;
79 end if;
80
81 -- Never show for remediation because we are disabling creation of remediation by itself.
82 -- Remediation can be created only from Finding summary page.
83
84 if ( change_category = 'AMW_REMEDIATION' ) then
85 return 0;
86 end if;
87
88 select responsibility_key
89 into respkey
90 from fnd_responsibility_vl
91 where responsibility_id = fnd_global.resp_id()
92 and application_id = fnd_global.resp_appl_id();
93
94 -- Always show for super user.
95
96 if ( respkey = 'AMW_SSW_NEW_RESP' ) then
97 return 1;
98 end if;
99
100 -- Findings.
101
102 if ( change_category = 'AMW_PROJ_FINDING' ) and
103 ( fnd_function.test ( 'AMW_CREATE_FINDINGS', 'Y' ) ) then
104 return 1;
105 end if;
106
107 -- Correction Requests.
108
109 if ( change_category = 'AMW_CORRECT_REQUESTS' ) and
110 ( fnd_function.test ( 'AMW_CREATE_CORRECTREQ', 'Y' ) ) then
111 return 1;
112 end if;
113
114 -- Issues.
115
116 if ( change_category = 'AMW_PROC_CERT_ISSUES' ) and
117 ( fnd_function.test ( 'AMW_CREATE_ISSUES', 'Y' ) ) then
118 return 1;
119 end if;
120
121 -- -- Owner based stuff.
122 --
123 -- if ( change_category = 'AMW_PROC_CERT_ISSUES' ) then
124 --
125 -- -- Allow to create if current user is the owner of process or manager of org.
126 --
127 -- if ( AMW_WF_HIERARCHY_PKG.hasOrgAccess ( fnd_global.user_id(), org_id ) = 1 ) then
128 -- return 1;
129 -- end if;
130 --
131 -- select count ( fnd_user.person_party_id )
132 -- into temp
133 -- from fnd_user, amw_process_all_vl proc, amw_proc_hierarchy_denorm aphd
134 -- where ( proc.process_id = myprocess_id
135 -- and proc.process_owner_id = fnd_user.person_party_id
136 -- and fnd_user.user_id = fnd_global.user_id()
137 -- )
138 -- or
139 -- (
140 -- aphd.process_id = myprocess_id
141 -- and aphd.up_down_ind = 'U'
142 -- and aphd.parent_child_id = proc.process_id
143 -- and proc.process_owner_id = fnd_user.person_party_id
144 -- and fnd_user.user_id = fnd_global.user_id()
145 -- );
146 --
147 -- if ( temp > 0 ) then
148 -- return 1;
149 -- end if;
150 --
151 -- end if;
152
153 return 0;
154
155 end is_create_enabled;
156
157 end amw_findings_pkg;