DBA Data[Home] [Help]

PACKAGE BODY: APPS.JTM_PROFILE_UTL_PKG

Source


1 PACKAGE BODY JTM_PROFILE_UTL_PKG AS
2 /* $Header: jtmpfutb.pls 120.1 2005/08/24 02:17:17 saradhak noship $ */
3 
4 G_PKG_NAME             CONSTANT VARCHAR2(30):='JTM_PROFILE_UTL_PKG';
5 G_APP_EABLE_PROF_NAME  CONSTANT VARCHAR2(30):='JTM_MOB_APPS_ENABLED';
6 
7 FUNCTION Get_app_level_profile_value(
8           p_profile_name in varchar2,
9           p_app_short_name in varchar2) return varchar2
10 IS
11      Cursor c_get_app_id is
12      select application_id
13      from fnd_application
14      where application_short_name = p_app_short_name;
15 
16      l_app_id number;
17      l_profile_value varchar2(200);
18 
19 BEGIN
20      open c_get_app_id;
21      fetch c_get_app_id into l_app_id;
22      if (c_get_app_id%notfound) then
23         close c_get_app_id;
24         return null;
25      end if;
26      close c_get_app_id;
27 
28      l_profile_value := fnd_profile.VALUE_SPECIFIC(
29           Name => p_profile_name, APPLICATION_ID => l_app_id);
30      return l_profile_value;
31 
32 EXCEPTION
33    WHEN OTHERS THEN
34        RETURN NULL;
35 END Get_app_level_profile_value;
36 
37 
38 FUNCTION Get_app_enable_flag( p_app_short_name IN varchar2 )
39     return varchar2 IS
40 
41    l_api_name             CONSTANT VARCHAR2(30) := 'GET_APPL_ENABLE_FLAG';
42    l_api_version          CONSTANT NUMBER := 1.0;
43    l_app_enable_flag      varchar2(20);
44 BEGIN
45      /* get the JTM profile value */
46      l_app_enable_flag := Get_app_level_profile_value(
47             G_APP_EABLE_PROF_NAME,'JTM' );
48 
49      if ( p_app_short_name = 'JTM' ) then
50          return l_app_enable_flag;
51      end if;
52 
53     /* If JTM profile is trun off, it also turns off other mobile appl profile*/
54      if ( l_app_enable_flag IS NULL OR l_app_enable_flag <> 'Y' ) then
55          return l_app_enable_flag;
56      end if;
57 
58      /* now profile value for JTM is Y. Get the requested value.*/
59      l_app_enable_flag := Get_app_level_profile_value(
60              G_APP_EABLE_PROF_NAME,
61              p_app_short_name );
62      return l_app_enable_flag;
63 
64 EXCEPTION
65    WHEN OTHERS THEN
66        RETURN NULL;
67 END Get_app_enable_flag;
68 
69 
70 FUNCTION Get_app_enable_flag(p_resp_id in number, p_app_id in number)
71 return varchar2 IS
72      l_app_enable_flag varchar2(20);
73 BEGIN
74      /* get the JTM profile value */
75      l_app_enable_flag := Get_app_level_profile_value(
76             G_APP_EABLE_PROF_NAME,'JTM' );
77 
78      /* If JTM profile is trun off, it also turns off other mobile appl profile*/
79      if ( l_app_enable_flag IS NULL OR l_app_enable_flag <> 'Y' ) then
80          return l_app_enable_flag;
81      end if;
82 
83      /* profile value for JTM is Y*/
84      l_app_enable_flag := fnd_profile.VALUE_SPECIFIC(
85          Name => G_APP_EABLE_PROF_NAME
86          ,APPLICATION_ID => p_app_id
87          ,RESPONSIBILITY_ID => p_resp_id);
88 
89      return l_app_enable_flag;
90 
91 EXCEPTION
92    WHEN OTHERS THEN
93        RETURN NULL;
94 END Get_app_enable_flag;
95 
96 
97 FUNCTION Get_enable_flag_at_resp(
98     p_resp_id in number,
99     p_app_short_name IN varchar2)
100 RETURN varchar2 IS
101      Cursor c_get_app_id is
102      select application_id
103      from fnd_application
104      where application_short_name = p_app_short_name;
105 
106      l_app_id number;
107      l_resp_id number := null;
108      l_app_enable_flag varchar2(20);
109 BEGIN
110      l_app_enable_flag := Get_app_level_profile_value(
111             G_APP_EABLE_PROF_NAME, 'JTM' );
112 
113      /* If JTM profile is trun off, it also turn off other mobile appl profile*/
114      if ( l_app_enable_flag IS NULL OR l_app_enable_flag <> 'Y' ) then
115          return l_app_enable_flag;
116      end if;
117 
118      /* now profile value for JTM is Y*/
119      open c_get_app_id;
120      fetch c_get_app_id into l_app_id;
121      if (c_get_app_id%notfound) then
122         close c_get_app_id;
123         return null;
124      end if;
125      close c_get_app_id;
126 
127      if (p_resp_id = fnd_api.g_miss_num) then
128         if (p_app_short_name = 'CSL' ) then
129            l_resp_id := 22916;
130         --elsif (p_app_short_name = 'CSM' ) then
131         --   l_resp_id := ?;
132         else /* for other applications */
133            l_resp_id := null;
134         end if;
135      else
136         l_resp_id := p_resp_id;
137      end if;
138 
139      l_app_enable_flag := fnd_profile.VALUE_SPECIFIC(
140          Name => G_APP_EABLE_PROF_NAME
141          ,APPLICATION_ID => l_app_id
142          ,RESPONSIBILITY_ID => l_resp_id);
143      return l_app_enable_flag;
144 
145 EXCEPTION
146    WHEN OTHERS THEN
147        RETURN NULL;
148 END Get_enable_flag_at_resp;
149 
150 FUNCTION Get_enable_flag_at_resp(
151     p_resp_key in VARCHAR2,
152     p_app_short_name IN varchar2) return varchar2
153 IS
154      Cursor c_get_resp_id (p_resp_key in varchar2) is
155      select responsibility_id
156      from fnd_responsibility
157      where responsibility_key = p_resp_key;
158 
159      l_resp_id number := null;
160      l_resp_key varchar2(80);
161      l_app_enable_flag varchar2(20);
162 BEGIN
163      if (p_resp_key IS NULL) then
164         if (p_app_short_name = 'CSL' ) then
165            l_resp_key := 'CSL_IMOBILE';
166         elsif ( p_app_short_name = 'CSM' ) then
167            l_resp_key := 'OMFS_PALM';
168         else /* for other applications */
169            l_resp_key := null;
170         end if;
171      else
172         l_resp_key := p_resp_key;
173      end if;
174 
175      open c_get_resp_id(l_resp_key);
176      fetch c_get_resp_id into l_resp_id;
177      if (c_get_resp_id%notfound) then
178         close c_get_resp_id;
179         --return null;
180      end if;
181      close c_get_resp_id;
182 
183      l_app_enable_flag := Get_enable_flag_at_resp
184            (l_resp_id, p_app_short_name);
185      return l_app_enable_flag;
186 
187 EXCEPTION
188    WHEN OTHERS THEN
189        RETURN NULL;
190 END Get_enable_flag_at_resp;
191 
192 
193 FUNCTION Get_enable_flag_at_resp(
194     p_app_short_name IN varchar2) return varchar2
195 IS
196      Cursor c_get_resp_id (p_resp_key in varchar2) is
197      select responsibility_id
198      from fnd_responsibility
199      where responsibility_key = p_resp_key;
200 
201      l_resp_id number := null;
202      l_resp_key varchar2(80);
203      l_app_enable_flag varchar2(20);
204 BEGIN
205      if (p_app_short_name = 'CSL' ) then
206         l_resp_key := 'CSL_IMOBILE';
207      elsif ( p_app_short_name = 'CSM' ) then
208         l_resp_key := 'OMFS_PALM';
209      else /* for other applications */
210         l_resp_key := null;
211      end if;
212 
213      open c_get_resp_id(l_resp_key);
214      fetch c_get_resp_id into l_resp_id;
215      if (c_get_resp_id%notfound) then
216         close c_get_resp_id;
217         --return null;
218      end if;
219      close c_get_resp_id;
220 
221      l_app_enable_flag := Get_enable_flag_at_resp
222            (l_resp_id, p_app_short_name);
223      return l_app_enable_flag;
224 
225 EXCEPTION
226    WHEN OTHERS THEN
227        RETURN NULL;
228 END Get_enable_flag_at_resp;
229 
230 
231 END JTM_PROFILE_UTL_PKG;