1 PACKAGE BODY EC_DEBUG as
2 /* $Header: ECDEBUGB.pls 120.2 2005/09/28 11:13:11 arsriniv ship $ */
3
4 /* This procedure will enable debug messages. ie. the log file or the report
5 file of the concurrent request will have detailed messages to help the user
6 to trouble shoot the problems encountered */
7
8 PROCEDURE ENABLE_DEBUG
9 (
10 i_level IN VARCHAR2 DEFAULT 0
11 ) is
12
13 begin
14 G_debug_level := i_level;
15 end ENABLE_DEBUG;
16
17 /* This procedure will disable debug messages. ie. the log file or the report
18 file of the concurrent request will not have detailed debug messages */
19
20 PROCEDURE DISABLE_DEBUG is
21 begin
22 G_debug_level := 0;
23 G_program_stack.DELETE;
24 end DISABLE_DEBUG;
25
26
27 /* This procedure will split the message into 132 character chunks and prints
28 it to the log or report file. */
29
30 PROCEDURE SPLIT
31 (
32 i_string IN VARCHAR2
33 ) is
34
35 stemp VARCHAR2(80);
36 nlength NUMBER := 1;
37 begin
38 while(length(i_string) >= nlength)
39 loop
40 stemp := substrb(i_string, nlength, 80);
41 fnd_file.put_line(FND_FILE.LOG, INDENT_TEXT(0)||stemp);
42 nlength := (nlength + 80);
43 end loop;
44 exception
45 when others then
46 EC_DEBUG.PL(0,'EC','ECE_ERROR_CODE','ERROR_CODE',SQLCODE);
47 EC_DEBUG.PL(0,'EC','ECE_ERROR_MESSAGE','ERROR_MESSAGE',SQLERRM);
48 end SPLIT;
49
50 /* This procedure populates the stack table with the program name and the
51 time it started processing. */
52
53 PROCEDURE PUSH
54 (
55 i_program_name IN VARCHAR2
56 ) is
57 ntbl_count NUMBER;
58 begin
59
60 /* Bug 1853627 - Added the following check to suppress the debug message */
61
62 if G_debug_level >= 2 then
63 ntbl_count := G_program_stack.COUNT + 1;
64 G_program_stack(ntbl_count).program_name := upper(i_program_name);
65 G_program_stack(ntbl_count).timestamp := sysdate;
66 fnd_file.put_line(FND_FILE.LOG, INDENT_TEXT(1)|| 'Enter '||i_program_name||'->'||to_char(G_program_stack(ntbl_count).timestamp, 'DD-MON-YYYY HH24:MI:SS'));
67 end if;
68 exception
69 when others then
70 EC_DEBUG.PL(0,'EC','ECE_ERROR_CODE','ERROR_CODE',SQLCODE);
71 EC_DEBUG.PL(0,'EC','ECE_ERROR_MESSAGE','ERROR_MESSAGE',SQLERRM);
72 end PUSH;
73
74 /* This procedure extracts data from the stack table and also provides the time
75 a program took to complete processing. */
76
77 PROCEDURE POP
78 (
79 i_program_name IN VARCHAR2
80 ) is
81 nposition NUMBER;
82 ntime_taken NUMBER;
83 begin
84 /* Bug 1853627 - Added the following check to suppress the debug message */
85
86 if G_debug_level >= 2
87 then
88 FIND_POS(G_program_stack, i_program_name, nposition);
89 ntime_taken := (sysdate - G_program_stack(nposition).timestamp)*(24*60*60);
90 fnd_file.put_line(FND_FILE.LOG, INDENT_TEXT(1)|| 'Exit '||G_program_stack(nposition).program_name||'->'||to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS'));
91 fnd_file.put_line(FND_FILE.LOG, INDENT_TEXT(1)||'Time Taken '|| round(ntime_taken, 2) || ' seconds' );
92 G_program_stack.DELETE(nposition);
93 end if;
94 exception
95 when others then
96 EC_DEBUG.PL(0,'EC','ECE_ERROR_CODE','ERROR_CODE',SQLCODE);
97 EC_DEBUG.PL(0,'EC','ECE_ERROR_MESSAGE','ERROR_MESSAGE',SQLERRM);
98 end POP;
99
100 /* This function beautifies the output written to the log/report by adding the
101 appropriate indentation. */
102
103 FUNCTION INDENT_TEXT
104 (
105 i_main IN NUMBER DEFAULT 0
106 )
107 RETURN VARCHAR2 is
108 vtemp_space VARCHAR2(500);
109 begin
110 vtemp_space := rpad(' ', 2*(G_program_stack.COUNT - 1), ' ');
111 if i_main = 0 and G_program_stack.COUNT > 0 then
112 vtemp_space := vtemp_space || ' ';
113 end if;
114 return(vtemp_space);
115
116 exception
117 when others then
118 EC_DEBUG.PL(0,'EC','ECE_ERROR_CODE','ERROR_CODE',SQLCODE);
119 EC_DEBUG.PL(0,'EC','ECE_ERROR_MESSAGE','ERROR_MESSAGE',SQLERRM);
120 end INDENT_TEXT;
121
122 /* This is an overloaded procedure to set the tokens and retrieve the fnd
123 message and print it to the appropriate log/report file. */
124
125 PROCEDURE PL
126 (
127 i_level IN NUMBER default 0,
128 i_app_short_name IN VARCHAR2,
129 i_message_name IN VARCHAR2,
130 i_token1 IN VARCHAR2,
131 i_value1 IN VARCHAR2 DEFAULT NULL,
132 i_token2 IN VARCHAR2 DEFAULT NULL,
133 i_value2 IN VARCHAR2 DEFAULT NULL,
134 i_token3 IN VARCHAR2 DEFAULT NULL,
135 i_value3 IN VARCHAR2 DEFAULT NULL,
136 i_token4 IN VARCHAR2 DEFAULT NULL,
137 i_value4 IN VARCHAR2 DEFAULT NULL,
138 i_token5 IN VARCHAR2 DEFAULT NULL,
139 i_value5 IN VARCHAR2 DEFAULT NULL,
140 i_token6 IN VARCHAR2 DEFAULT NULL,
141 i_value6 IN VARCHAR2 DEFAULT NULL
142 ) is
143
144 begin
145
146 if G_debug_level >= i_level then
147 fnd_message.set_name(i_app_short_name,i_message_name);
148
149 if ( i_token1 is not null ) and ( i_value1 is not null ) then
150 fnd_message.set_token(i_token1,i_value1);
151 end if;
152 if ( i_token2 is not null ) and ( i_value2 is not null ) then
153 fnd_message.set_token(i_token2,i_value2);
154 end if;
155 if ( i_token3 is not null ) and ( i_value3 is not null ) then
156 fnd_message.set_token(i_token3,i_value3);
157 end if;
158 if ( i_token4 is not null ) and ( i_value4 is not null ) then
159 fnd_message.set_token(i_token4,i_value4);
160 end if;
161 if ( i_token5 is not null ) and ( i_value5 is not null ) then
162 fnd_message.set_token(i_token5,i_value5);
163 end if;
164 if ( i_token6 is not null ) and ( i_value6 is not null ) then
165 fnd_message.set_token(i_token6,i_value6);
166 end if;
167
168 fnd_file.put_line(FND_FILE.LOG, INDENT_TEXT(0)||fnd_message.get);
169 end if;
170
171 exception
172 when others then
173 EC_DEBUG.PL(0,'EC','ECE_ERROR_CODE','ERROR_CODE',SQLCODE);
174 EC_DEBUG.PL(0,'EC','ECE_ERROR_MESSAGE','ERROR_MESSAGE',SQLERRM);
175 END PL;
176
177 /* This is an overloaded procedure to split a message string into 132 character
178 strings. */
179
180 PROCEDURE PL
181 (
182 i_level IN NUMBER,
183 i_string IN VARCHAR2
184 ) is
185
186 begin
187 if ( G_debug_level >= i_level ) then
188 SPLIT(i_string);
189 end if;
190 exception
191 when others then
192 EC_DEBUG.PL(0,'EC','ECE_ERROR_CODE','ERROR_CODE',SQLCODE);
193 EC_DEBUG.PL(0,'EC','ECE_ERROR_MESSAGE','ERROR_MESSAGE',SQLERRM);
194 END PL;
195
196
197 /* This is an overloaded procedure to concatenate a given variable name and
198 the date value. */
199 PROCEDURE PL
200 (
201 i_level IN NUMBER,
202 i_variable_name IN VARCHAR2,
203 i_variable_value IN DATE
204 ) is
205
206 begin
207 if ( G_debug_level >= i_level ) then
208 SPLIT(i_variable_name || G_separator || to_char(i_variable_value,
209 'DD-MON-YYYY HH24:MI:SS'));
210 end if;
211 exception
212 when others then
213 EC_DEBUG.PL(0,'EC','ECE_ERROR_CODE','ERROR_CODE',SQLCODE);
214 EC_DEBUG.PL(0,'EC','ECE_ERROR_MESSAGE','ERROR_MESSAGE',SQLERRM);
215 end PL;
216
217 /* This is an overloaded procedure to concatenate a given variable name and
218 the number value. */
219
220 PROCEDURE PL
221 (
222 i_level IN NUMBER,
223 i_variable_name IN VARCHAR2,
224 i_variable_value IN NUMBER
225 ) is
226 begin
227 if ( G_debug_level >= i_level ) then
228 SPLIT(i_variable_name || G_separator || to_char(i_variable_value));
229 end if;
230 exception
231 when others then
232 EC_DEBUG.PL(0,'EC','ECE_ERROR_CODE','ERROR_CODE',SQLCODE);
233 EC_DEBUG.PL(0,'EC','ECE_ERROR_MESSAGE','ERROR_MESSAGE',SQLERRM);
234 end PL;
235
236 /* This is an overloaded procedure to concatenate a given variable name and
237 the string value. */
238
239 PROCEDURE PL
240 (
241 i_level IN NUMBER,
242 i_variable_name IN VARCHAR2,
243 i_variable_value IN VARCHAR2
244 ) is
245 begin
246 if ( G_debug_level >= i_level ) then
247 SPLIT(i_variable_name || G_separator || i_variable_value);
248 end if;
249 exception
250 when others then
251 EC_DEBUG.PL(0,'EC','ECE_ERROR_CODE','ERROR_CODE',SQLCODE);
252 EC_DEBUG.PL(0,'EC','ECE_ERROR_MESSAGE','ERROR_MESSAGE',SQLERRM);
253 end PL;
254
255 /* This is an overloaded procedure to concatenate a given variable name and
256 the boolean value. */
257
258 PROCEDURE PL
259 (
260 i_level IN NUMBER,
261 i_variable_name IN VARCHAR2,
262 i_variable_value IN BOOLEAN
263 ) is
264 vtemp VARCHAR2(10) := 'false';
265 begin
266 if ( G_debug_level >= i_level ) then
267 if ( i_variable_value ) then
268 vtemp := 'true';
269 else
270 vtemp := 'false';
271 end if;
272 SPLIT(i_variable_name || G_separator || vtemp);
273 end if;
274 exception
275 when others then
276 EC_DEBUG.PL(0,'EC','ECE_ERROR_CODE','ERROR_CODE',SQLCODE);
277 EC_DEBUG.PL(0,'EC','ECE_ERROR_MESSAGE','ERROR_MESSAGE',SQLERRM);
278 end PL;
279
280 /* This procedure finds a program_name in the stack table. */
281 PROCEDURE FIND_POS
282 (
283 i_stack_tbl IN pl_stack,
284 i_search_text IN varchar2,
285 o_position IN OUT NOCOPY NUMBER
286 )
287 IS
288 cIn_String VARCHAR2(1000) := UPPER(i_search_text);
289 nColumn_count NUMBER := i_stack_tbl.COUNT;
290 bFound BOOLEAN := FALSE;
291 PROG_NOT_FOUND EXCEPTION;
292 BEGIN
293 for loop_count in reverse 1..nColumn_count
294 loop
295 if (upper(i_stack_tbl(loop_count).PROGRAM_NAME) = cIn_String) then
296 o_position := loop_count;
297 bFound := TRUE;
298 exit;
299 end if;
300 end loop;
301 if not bFound then
302 raise PROG_NOT_FOUND;
303 end if;
304
305 EXCEPTION
306 WHEN PROG_NOT_FOUND THEN
307 EC_DEBUG.PL(0,'EC','ECE_PLSQL_PROG_NAME','PROG_NAME', 'cIn_string');
308 app_exception.raise_exception;
309
310 WHEN OTHERS THEN
314 app_exception.raise_exception;
311 EC_DEBUG.PL(0,'EC','ECE_PROGRAM_ERROR','PROGRESS_LEVEL','EC_DEBUG.FIND_POS');
312 EC_DEBUG.PL(0,'EC','ECE_ERROR_CODE','ERROR_CODE',SQLCODE);
313 EC_DEBUG.PL(0,'EC','ECE_ERROR_MESSAGE','ERROR_MESSAGE',SQLERRM);
315
316 END FIND_POS;
317
318 end EC_DEBUG;