1 PACKAGE BODY FND_APPS_MODE_UTIL AS
2 /* $Header: AFOAMAPMDB.pls 115.2 2004/09/02 19:26:26 rmohan noship $ */
3
4 ---Common Constants
5 PROFILE_APPS_MAINTENANCE_MODE CONSTANT VARCHAR2(100) := 'APPS_MAINTENANCE_MODE';
6
7
8
9 procedure fdebug(msg in varchar2);
10
11
12 /**
13 * This function will return current mode of the Application System.
14 **/
15 function GET_CURRENT_MODE return varchar2
16 is
17 retu varchar2(100);
18 begin
19 fnd_profile.get(PROFILE_APPS_MAINTENANCE_MODE, retu);
20 return retu;
21 end;
22
23
24
25 /**
26 * This function will return true if Application System is in Maintenance Mode
27 * else false
28 **/
29 function COMPARE_MODE(pExpectedMode varchar2) return boolean
30 is
31 retu boolean;
32 lCurrentMode varchar2(100);
33 begin
34 lCurrentMode := GET_CURRENT_MODE;
35 if(lCurrentMode = pExpectedMode) then
36 retu := true;
37 else
38 retu := false;
39 end if;
40 return retu;
41 end;
42
43 /**
44 * This function will return true if Application System is in Maintenance Mode
45 * else false
46 **/
47 function IS_IN_MAINTENANCE_MODE return boolean
48 is
49 begin
50 return COMPARE_MODE(MAINTENANCE_MODE);
51 end;
52
53
54 /**
55 * This function will return true if Application System is in Normal Mode
56 * else false.
57 **/
58 function IS_IN_NORMAL_MODE return boolean
59 is
60 begin
61 return COMPARE_MODE(NORMAL_MODE);
62 end;
63
64
65
66
67 /**
68 * It will set the Application System in pMode
69 * param pMode New Mode of the System.
70 * param pWFCode - Code to set in Workflow resource
71 * param retcode out type - values 0, 1
72 * 0 - Successful completion of procedure.
73 * errbuf will be null
74 * 1 - Error occurred and Application System mode is not changed.
75 * errbuf will have error message.
76 * param errbuf out type - If any error occurs it will have error message
77 * else null
78 **/
79 procedure SET_MODE (pMode varchar2, pWfCode varchar2, errbuf out NOCOPY varchar2,
80 retcode out NOCOPY number)
81 is
82 lretu boolean;
83 begin
84 lretu := FND_PROFILE.SAVE(PROFILE_APPS_MAINTENANCE_MODE, pMode, 'SITE');
85 if lretu = TRUE then
86 FND_PROFILE.put(PROFILE_APPS_MAINTENANCE_MODE, pMode);
87
88 -- For Workflow To Enable: (when leaving maintenance mode)
89 UPDATE wf_resources
90 SET text = pWfCode
91 WHERE type = 'WFTKN'
92 AND name = 'WF_SYSTEM_STATUS';
93 commit;
94 retcode := 0;
95 else
96 retcode := 1;
97 errbuf := 'FND_PROFILE.SAVE returned false';
98 end if;
99 exception
100 when others then
101 retcode := 1;
102 raise;
103 end;
104
105
106 /**
107 * It will set the Application System in Normal Mode.
108 * param retcode out type - values 0, 1
109 * 0 - Successful completion of procedure.
110 * errbuf will be null
111 * 1 - Error occurred and Application System mode is not changed.
112 * errbuf will have error message.
113 * param errbuf out type - If any error occurs it will have error message
114 * else null
115 **/
116 procedure SET_TO_NORMAL_MODE (retcode out NOCOPY number
117 , errbuf out NOCOPY varchar2)
118 is
119 begin
120 SET_MODE(NORMAL_MODE, 'ENABLED', errbuf, retcode);
121 end;
122
123 /**
124 * It will set the Application System in Maintenance Mode.
125 * param errbuf out type - If any error occurs it will have error message
126 * else null
127 * param retcode out type - values 0, 1
128 * 0 - Successful completion of procedure.
129 * errbuf will be null
130 * 1 - Error occurred and Application System mode is not changed.
131 * errbuf will have error message.
132 **/
133 procedure SET_TO_MAINTENANCE_MODE (retcode out NOCOPY number
134 , errbuf out NOCOPY varchar2)
135 is
136 begin
137 SET_MODE(MAINTENANCE_MODE, 'DISABLED', errbuf, retcode);
138 end;
139
140
141
142 /**
143 * Don't use this API
144 * It will set the Application System in pMode. If Profile Option doesn't
145 * exist, it will only change the setting for workflow event system.
146 * param pMode New Mode of the System.
147 * param pWFCode - Code to set in Workflow resource
148 * param retcode out type - values 0, 1
149 * 0 - Successful completion of procedure.
150 * errbuf will be null
151 * 1 - Error occurred and Application System mode is not changed.
152 * errbuf will have error message.
153 * param errbuf out type - If any error occurs it will have error message
154 * else null
155 **/
156 procedure SET_MODE_PATCH_MP11510(pMode varchar2, pWfCode varchar2
157 , errbuf out NOCOPY varchar2, retcode out NOCOPY number)
158 is
159 lretu boolean;
160 begin
161 -- For Workflow
162 UPDATE wf_resources
163 SET text = pWfCode
164 WHERE type = 'WFTKN'
165 AND name = 'WF_SYSTEM_STATUS';
166
167 lretu := FND_PROFILE.SAVE(PROFILE_APPS_MAINTENANCE_MODE, pMode, 'SITE');
168 if lretu = TRUE then
169 FND_PROFILE.put(PROFILE_APPS_MAINTENANCE_MODE, pMode);
170 end if;
171
172 commit;
173 retcode := 0;
174 exception
175 when others then
176 retcode := 1;
177 raise;
178 end;
179
180
181
182 /**
183 * Do not use this API because this APIS is for internal fnd usage
184 * to accmodate following cases during patching.
185 * If Instance doesn't have APPS_MAINTENANCE_MODE profile option
186 * still we want to disable the workflow event.
187 * If profile option exist it will be set to MAINT.
188 *
189 * It will set the Application System in Maintenance Mode.
190 * param retcode out type - values 0, 1.
191 * 0 - Successful completion of procedure.
192 * errbuf will be null
193 * 1 - Error occurred and Application System mode is not changed.
194 * errbuf will have error message.
195 * param errbuf out type - If any error occurs it will have error message
196 * else null
197 **/
198 procedure SET_MAINT_MODE_PATCH_MP11510(retcode out NOCOPY number
199 , errbuf out NOCOPY varchar2)
200 is
201 begin
202 SET_MODE_PATCH_MP11510(MAINTENANCE_MODE, 'DISABLED', errbuf, retcode);
203 end;
204
205
206 /**
207 * Do not use this API because this APIS is for internal fnd usage
208 * to accmodate following cases during patching.
209 * If Instance doesn't have APPS_MAINTENANCE_MODE profile option
210 * still we want to enable the workflow event.
211 * If profile option exist it will be set to NORMAL.
212 *
213 * It will set the Application System in Normal Mode.
214 * param retcode out type - values 0, 1.
215 * 0 - Successful completion of procedure.
216 * errbuf will be null
217 * 1 - Error occurred and Application System mode is not changed.
218 * errbuf will have error message.
219 * param errbuf out type - If any error occurs it will have error message
220 * else null
221 **/
222 procedure SET_NORMAL_MODE_PATCH_MP11510(retcode out NOCOPY number
223 , errbuf out NOCOPY varchar2)
224 is
225 begin
226 SET_MODE_PATCH_MP11510(NORMAL_MODE, 'ENABLED', errbuf, retcode);
227 end;
228
229
230
231
232 function toVarchar2(pBoolean boolean) return varchar2
233 is
234 retu varchar2(10);
235 begin
236 if(pBoolean = true) then
237 retu := 'TRUE';
238 else
239 retu := 'FALSE';
240 end if;
241 return retu;
242 end;
243
244 /**
245 * For Testing all API's
246 * After testing it will put the Apps mode in the original state.
247 **/
248 procedure TEST
249 is
250 lString varchar2(1000);
251 lExistingMode varchar2(1000);
252 lBolValue boolean;
253 retcode number;
254 errbuf varchar2(1000);
255 begin
256 fdebug('Testing: GET_CURRENT_MODE');
257 lExistingMode := GET_CURRENT_MODE;
258 fdebug('lString=' || lExistingMode);
259
260 fdebug('Testing: IS_IN_NORMAL_MODE');
261 lBolValue := IS_IN_NORMAL_MODE;
262 lString := toVarchar2(lBolValue);
263 fdebug('lString=' || lString);
264
265 fdebug('Testing: IS_IN_MAINTENANCE_MODE');
266 lBolValue := IS_IN_MAINTENANCE_MODE;
267 lString := toVarchar2(lBolValue);
268 fdebug('lString=' || lString);
269
270 fdebug('Testing: SET_TO_MAINTENANCE_MODE');
271 SET_TO_MAINTENANCE_MODE(retcode, errbuf);
272 lString := GET_CURRENT_MODE;
273 fdebug('lString=' || lString || 'retcode=' || to_char(retcode) || ' errbuf=' || errbuf);
274
275 fdebug('Testing: SET_TO_NORMAL_MODE');
276 SET_TO_NORMAL_MODE(retcode, errbuf);
277 lString := GET_CURRENT_MODE;
278 fdebug('lString=' || lString || 'retcode=' || to_char(retcode) || ' errbuf=' || errbuf);
279
280 fdebug('Test Done...Setting Back Profile to ' || lExistingMode);
281 lBolValue := FND_PROFILE.SAVE(PROFILE_APPS_MAINTENANCE_MODE, lExistingMode, 'SITE');
282 lString := GET_CURRENT_MODE;
283 fdebug('lString=' || lString);
284 end;
285
286
287
288
289 /**
290 * Debug method
291 **/
292
293 procedure fdebug(msg in varchar2)
294 IS
295 l_msg VARCHAR2(1000);
296 BEGIN
297 --l_msg := dbms_utility.get_time || ' ' || msg;
298 ---dbms_output.put_line(dbms_utility.get_time || ' ' || msg);
299 ---fnd_file.put_line( fnd_file.log, dbms_utility.get_time || ' ' || msg);
300 l_msg := 'm';
301 END fdebug;
302
303
304 END FND_APPS_MODE_UTIL;