DBA Data[Home] [Help]

PACKAGE BODY: APPS.ECX_DEBUG

Source


1 PACKAGE BODY ECX_DEBUG AS
2 -- $Header: ECXDEBGB.pls 120.9.12020000.2 2013/03/21 11:21:25 jmaddila ship $
3 
4    g_split_threshold   PLS_INTEGER := 120;
5    g_depth             PLS_INTEGER := 0;
6 
7    pv_MsgParamSeparator     VARCHAR2(10)    := '#WF#';
8    pv_MsgParamSeparatorSize NUMBER  := LENGTH(pv_MsgParamSeparator);
9    pv_NameValueSeparator    VARCHAR2(10)    := '=';
10 
11    pv_CustMsgSeparator     VARCHAR2(20)    := '#CUST#';
12    pv_CustMsgSeparatorSize NUMBER  := LENGTH(pv_CustMsgSeparator);
13 
14    -- This variable is used to decide at what log level we finally write the BLOB into the fnd tables.
15    pv_LevelToLog  NUMBER;
16 
17    --This procedure will enable debug messages. ie.  the log file or the report
18    --file of the concurrent request will have detailed messages to help the user
19    --to trouble shoot the problems encountered
20    PROCEDURE enable_debug(i_level IN VARCHAR2 ) IS
21 
22       BEGIN
23        g_instlmode := wf_core.translate('WF_INSTALL');
24 
25          g_debug_level := i_level;
26          g_use_cmanager_flag := TRUE;
27          g_depth := 0;
28 	 g_procedure  := 2;
29 	 g_statement  := 3;
30 	 g_unexpected := 0;
31 	 g_procedureEnabled  := g_debug_level >= g_procedure;
32 	 g_statementEnabled   := g_debug_level >= g_statement;
33 	 g_unexpectedEnabled  := g_debug_level >= g_unexpected;
34 
35        IF g_instlmode = 'EMBEDDED' THEN
36 		 g_debug_level := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
37 		 g_procedure  := FND_LOG.LEVEL_PROCEDURE;
38 		 g_statement  := FND_LOG.LEVEL_STATEMENT;
39 		 g_unexpected := FND_LOG.LEVEL_UNEXPECTED;
40 		 g_procedureEnabled  := g_procedure >= g_debug_level;
41 		 g_statementEnabled  := g_statement >= g_debug_level;
42 		 g_unexpectedEnabled := g_unexpected >= g_debug_level;
43        END IF;
44 
45       END enable_debug;
46 
47    PROCEDURE enable_debug_new(
48       p_level     IN VARCHAR2 ) IS
49 
50       BEGIN
51         g_instlmode := wf_core.translate('WF_INSTALL');
52 
53          g_debug_level := p_level;
54          g_use_cmanager_flag := FALSE;
55          g_write_file_flag := FALSE;
56          g_depth := 0;
57 	 g_procedure  := 2;
58 	 g_statement  := 3;
59 	 g_unexpected := 0;
60 	 g_procedureEnabled   := g_debug_level >= g_procedure;
61 	 g_statementEnabled   := g_debug_level >= g_statement;
62 	 g_unexpectedEnabled  := g_debug_level >= g_unexpected;
63         IF g_instlmode = 'EMBEDDED' THEN
64            g_debug_level := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
65 	   g_procedure  := FND_LOG.LEVEL_PROCEDURE;
66 	   g_statement  := FND_LOG.LEVEL_STATEMENT;
67 	   g_unexpected := FND_LOG.LEVEL_UNEXPECTED;
68 	   g_procedureEnabled  := g_procedure >= g_debug_level;
69 	   g_statementEnabled  := g_statement >= g_debug_level;
70 	   g_unexpectedEnabled := g_unexpected >= g_debug_level;
71            pv_LevelToLog := fnd_log.g_current_runtime_level;
72        END IF;
73 
74       END enable_debug_new;
75 
76    PROCEDURE enable_debug_new(
77       p_level     IN VARCHAR2 ,
78       p_file_path IN VARCHAR2,
79       p_file_name IN VARCHAR2,
80       p_aflog_module_name IN VARCHAR2) IS
81 
82       BEGIN
83 
84          g_use_cmanager_flag := FALSE;
85          g_depth := 0;
86          IF NOT (g_write_file_flag) THEN
87             IF p_file_path IS NOT NULL AND
88                p_file_name IS NOT NULL THEN
89                g_write_file_flag := TRUE;
90                g_file_path := p_file_path;
91                g_file_name := p_file_name;
92 	       g_aflog_module_name := g_sqlprefix || p_aflog_module_name;
93             ELSE
94                g_write_file_flag := FALSE;
95             END IF;
96          END IF;
97 
98          g_debug_level := p_level;
99          g_procedure  := 2;
100 	 g_statement  := 3;
101 	 g_unexpected := 0;
102 	 g_procedureEnabled  := g_debug_level >= g_procedure;
103 	 g_statementEnabled   := g_debug_level >= g_statement;
104 	 g_unexpectedEnabled  := g_debug_level >= g_unexpected;
105 
106        g_instlmode := wf_core.translate('WF_INSTALL');
107        IF g_instlmode = 'EMBEDDED'  THEN
108            g_debug_level := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
109 	   g_procedure  := FND_LOG.LEVEL_PROCEDURE;
110 	   g_statement  := FND_LOG.LEVEL_STATEMENT;
111 	   g_unexpected := FND_LOG.LEVEL_UNEXPECTED;
112 	   g_procedureEnabled  := g_procedure >= g_debug_level;
113 	   g_statementEnabled  := g_statement >= g_debug_level;
114 	   g_unexpectedEnabled := g_unexpected >= g_debug_level;
115            ecx_utils.g_logfile := g_aflog_module_name;
116        	   pv_LevelToLog := fnd_log.g_current_runtime_level;
117        END IF;
118       END enable_debug_new;
119 
120    --This procedure will disable debug messages. i.e. the log file or the report
121    --file of the concurrent request will not have detailed debug messages
122    PROCEDURE disable_debug IS
123       BEGIN
124 --       IF g_instlmode = 'EMBEDDED' THEN
125            g_debug_level := 0;
126            g_procedureEnabled  := false;
127            g_statementEnabled  := false;
128            g_unexpectedEnabled := false;
129   --         return;
130 --       ELSE
131 --         g_debug_level := 0;
132          g_file_name := NULL;
133          g_aflog_module_name := NULL;
134          g_file_path := NULL;
135          g_message_stack.DELETE;
136          g_use_cmanager_flag := FALSE;
137          g_write_file_flag := FALSE;
138 --      END IF;
139       END disable_debug;
140 PROCEDURE module_enabled IS
141       l_standard_code  ecx_standards.standard_code%type;
142    begin
143     g_v_module_name:=rtrim(g_v_module_name,'.');
144     select  standard_code
145     into l_standard_code
146     from ecx_standards
147     where   standard_id = ecx_utils.g_standard_id
148     and     standard_type = 'XML';
149 if l_standard_code is not null then
150   g_v_module_name:=g_v_module_name||'.'||l_standard_code;
151 end if;
152 if ecx_utils.g_direction is not null then
153  g_v_module_name:=g_v_module_name||'.'||ecx_utils.g_direction;
154 end if;
155 if ecx_utils.g_transaction_type is not null then
156 g_v_module_name :=g_v_module_name||'.'||ecx_utils.g_transaction_type;
157 end if;
158 if ecx_utils.g_transaction_subtype is not null then
159 g_v_module_name :=g_v_module_name||'.'||ecx_utils.g_transaction_subtype;
160 end if;
161 if ecx_utils.g_document_id is not null then
162 g_v_module_name:=g_v_module_name||'.'||ecx_utils.g_document_id;
163 end if;
164 end;
165 
166 
167 PROCEDURE module_enabled(p_message_standard IN VARCHAR2 ,p_transaction_type IN VARCHAR2,p_transaction_subtype IN VARCHAR2,p_document_id IN VARCHAR2) IS
168    begin
169     g_v_module_name:=rtrim(g_v_module_name,'.');
170 if p_message_standard is not null then
171   g_v_module_name:=g_v_module_name||'.'||p_message_standard;
172 end if;
173    g_v_module_name :=g_v_module_name||'.'||'out';
174 if p_transaction_type is not null then
175   g_v_module_name :=g_v_module_name||'.'||p_transaction_type;
176 end if;
177 if p_transaction_subtype is not null then
178  g_v_module_name :=g_v_module_name||'.'||p_transaction_subtype;
179 end if;
180 if p_document_id is not null then
181  g_v_module_name:=g_v_module_name||'.'||p_document_id;
182 end if;
183 end;
184 PROCEDURE module_enabled(p_transaction_type IN VARCHAR2,p_transaction_subtype IN VARCHAR2,p_document_id IN VARCHAR2) IS
185    begin
186     g_v_module_name:=rtrim(g_v_module_name,'.');
187    g_v_module_name :=g_v_module_name||'.'||'trig';
188 if p_transaction_type is not null then
189   g_v_module_name :=g_v_module_name||'.'||p_transaction_type;
190 end if;
191 if p_transaction_subtype is not null then
192  g_v_module_name :=g_v_module_name||'.'||p_transaction_subtype;
193 end if;
194 if p_document_id is not null then
195  g_v_module_name:=g_v_module_name||'.'||p_document_id;
196 end if;
197 end;
198 
199    --This procedure will split the message into 80 character chunks and prints
200    --it to the log or report file.
201    PROCEDURE split(i_string IN VARCHAR2) IS
202 
203       stemp       VARCHAR2(32000);
204       nlength     PLS_INTEGER  := 1;
205       slength     PLS_INTEGER  := 0;
206       nmsg_count  PLS_INTEGER;
207 
208       BEGIN
209 
210          slength := LENGTH(i_string);
211          IF (slength > g_split_threshold) THEN
212             WHILE (LENGTH(i_string) >= nlength) LOOP
213                stemp := SUBSTRB(i_string,nlength,g_split_threshold);
214 
215                IF g_use_cmanager_flag THEN   --Use the Concurrent Manager
216 		  null;
217                ELSE                          --Don't use the Concurrent Manager
218                   nmsg_count := g_message_stack.COUNT + 1;
219                   g_message_stack(nmsg_count).message_text := indent_text(0) || stemp;
220                END IF;
221 
222                nlength := nlength + g_split_threshold;
223             END LOOP;
224          ELSE
225             IF g_use_cmanager_flag THEN   --Use the Concurrent Manager
226 	       null;
227             ELSE                          --Don't use the Concurrent Manager
228                nmsg_count := g_message_stack.COUNT + 1;
229                g_message_stack(nmsg_count).message_text := indent_text(0) || i_string;
230             END IF;
231          END IF;
232 
233       EXCEPTION
234          WHEN OTHERS THEN
235             setErrorInfo(2,
236                         30,
237                         ecx_utils.i_errbuf || '- ECX_DEBUG.SPLIT: ' || SQLERRM );
238             raise ecx_utils.program_exit;
239 
240       END split;
241 
242    --This procedure populates the stack table with the program name and the
243    --time it started processing.
244    PROCEDURE push(i_program_name IN VARCHAR2) IS
245 
246       nmsg_count  PLS_INTEGER;
247 
248       BEGIN
249 /*       IF g_instlmode = 'EMBEDDED' THEN
250          fnd_log.string(ecx_debug.g_procedure, g_sqlprefix ||i_program_name||'.begin','Enter '|| i_program_name);
251        ELSE*/
252             g_depth := g_depth + 1;
253             IF g_use_cmanager_flag THEN   --Use the Concurrent Manager
254 	       null;
255             ELSE                          --Don't use the Concurrent Manager
256                nmsg_count := g_message_stack.COUNT + 1;
257                g_message_stack(nmsg_count).message_text := indent_text(1) || 'Enter ' || UPPER(i_program_name);
258             END IF;
259 --         END IF;
260 
261       EXCEPTION
262          WHEN OTHERS THEN
263             setErrorInfo(2, 30, ecx_utils.i_errbuf || '- ECX_DEBUG.PUSH: ' || SQLERRM);
264             raise ecx_utils.program_exit;
265 
266       END push;
267 
268    --This procedure extracts data from the stack table and also provides the time
269    --a program took to complete processing.
270    PROCEDURE pop(i_program_name IN VARCHAR2) IS
271 
272       nmsg_count  PLS_INTEGER;
273 
274       BEGIN
275 /*       IF g_instlmode = 'EMBEDDED' THEN
276          fnd_log.string(ecx_debug.g_procedure, g_sqlprefix ||i_program_name||'.end','Exit '||i_program_name);
277        ELSE*/
278             IF g_use_cmanager_flag THEN   --Use the Concurrent Manager
279 	       null;
280             ELSE
281                nmsg_count := g_message_stack.COUNT + 1;
282                g_message_stack(nmsg_count).message_text := indent_text(1) || 'Exit ' || i_program_name;
283             END IF;
284             g_depth := g_depth - 1;
285 --         END IF;
286 
287       EXCEPTION
288          WHEN OTHERS THEN
289             setErrorInfo(2,30,ecx_utils.i_errbuf || ' ECX_DEBUG.POP: ' || SQLERRM);
290             raise ecx_utils.program_exit;
291 
292       END pop;
293 
294    --This function beautifies the output written to the log/report by adding the
295    --appropriate indentation.
296    FUNCTION indent_text(i_main IN PLS_INTEGER ) RETURN VARCHAR2 IS
297 
298       vtemp_space   VARCHAR2(500);
299 
300       BEGIN
301          vtemp_space := RPAD(' ',2 * (g_depth - 1),' ');
302 
303          IF i_main = 0 AND
304             g_depth > 0 THEN
305             vtemp_space := vtemp_space || '  ';
306          END IF;
307 
308          RETURN (vtemp_space);
309 
310       EXCEPTION
311          WHEN OTHERS THEN
312             setErrorInfo(2,30,ecx_utils.i_errbuf || ' ECX_DEBUG.INDENT_TEXT: ' || SQLERRM);
313             raise ecx_utils.program_exit;
314       END indent_text;
315 --This is an overloaded procedure to set the tokens and retrieve the
316    --message and print it to the appropriate log/report file.
317   --Stubbed versions of pl for bug 5055659
318   PROCEDURE pl(
319       i_level            IN   PLS_INTEGER ,
320       i_app_short_name   IN   VARCHAR2,
321       i_message_name     IN   VARCHAR2,
322       i_token1           IN   VARCHAR2 ,
323       i_value1           IN   VARCHAR2 ,
324       i_token2           IN   VARCHAR2 ,
325       i_value2           IN   VARCHAR2 ,
326       i_token3           IN   VARCHAR2 ,
327       i_value3           IN   VARCHAR2 ,
328       i_token4           IN   VARCHAR2 ,
329       i_value4           IN   VARCHAR2 ,
330       i_token5           IN   VARCHAR2 ,
331       i_value5           IN   VARCHAR2 ,
332       i_token6           IN   VARCHAR2 ,
333       i_value6           IN   VARCHAR2 ) IS
334 
335       nmsg_count  PLS_INTEGER;
336 
337       BEGIN
338          IF g_debug_level >= i_level THEN
339                 null;
340 
341             IF i_token1 IS NOT NULL AND
342                i_value1 IS NOT NULL THEN
343                 wf_core.token(i_token1,i_value1);
344 
345                IF i_token2 IS NOT NULL AND
346                   i_value2 IS NOT NULL THEN
347                   wf_core.token(i_token2,i_value2);
348 
349                   IF i_token3 IS NOT NULL AND
350                      i_value3 IS NOT NULL THEN
351                      wf_core.token(i_token3,i_value3);
352 
353                      IF i_token4 IS NOT NULL AND
354                       i_value4 IS NOT NULL THEN
355 wf_core.token(i_token4,i_value4);
356 
357                         IF i_token5 IS NOT NULL AND
358                            i_value5 IS NOT NULL THEN
359                            wf_core.token(i_token5,i_value5);
360 
361                            IF i_token6 IS NOT NULL AND
362                               i_value6 IS NOT NULL THEN
363                               wf_core.token(i_token5,i_value5);
364                            END IF; -- i_token6
365                         END IF; -- i_token5
366                      END IF; -- i_token4
370 
367                   END IF; -- i_token3
368                END IF; -- i_token2
369             END IF; -- i_token1
371             IF g_use_cmanager_flag THEN   --Use the Concurrent Manager
372                null;
373             ELSE                          --Don't use the Concurrent Manager
374                nmsg_count := g_message_stack.COUNT + 1;
375                g_message_stack(nmsg_count).message_text := indent_text(0) || wf_core.translate(i_message_name);
376             END IF;
377          END IF;
378 
379       EXCEPTION
380          WHEN OTHERS THEN
381             setErrorInfo(2,30,ecx_utils.i_errbuf || ' ECX_DEBUG.PL: ' || SQLERRM);
382             raise ecx_utils.program_exit;
383 
384       END pl;
385   --This is an overloaded procedure to split a message string into 132 character
386    --strings.
387    PROCEDURE pl(i_level IN PLS_INTEGER,i_string IN VARCHAR2) IS
388 
389       BEGIN
390          IF (g_debug_level >= i_level) THEN
391             split(i_string);
392          END IF;
393 
394       EXCEPTION
395          WHEN OTHERS THEN
396 setErrorInfo(2,30,ecx_utils.i_errbuf || ' ECX_DEBUG.PL: ' || SQLERRM);
397             raise ecx_utils.program_exit;
398 
399       END pl;
400 
401    --This is an overloaded procedure to concatenate a given variable name and
402    --the date value.
403    PROCEDURE pl(
404       i_level            IN   PLS_INTEGER,
405       i_variable_name    IN   VARCHAR2,
406       i_variable_value   IN   DATE) IS
407 
408       BEGIN
409          IF (g_debug_level >= i_level) THEN
410             split(i_variable_name || g_separator || TO_CHAR(i_variable_value,'DD-MON-YYYY HH24:MI:SS'));
411          END IF;
412 
413       EXCEPTION
414          WHEN OTHERS THEN
415             setErrorInfo(2,30,ecx_utils.i_errbuf || ' ECX_DEBUG.PL: ' || SQLERRM);
416             raise ecx_utils.program_exit;
417 
418       END pl;
419 --This is an overloaded procedure to concatenate a given variable name and
420    --the number value.
421    PROCEDURE pl(
422       i_level            IN   PLS_INTEGER,
423       i_variable_name    IN   VARCHAR2,
424       i_variable_value   IN   NUMBER) IS
425 
426       BEGIN
427          IF (g_debug_level >= i_level) THEN
428             split(i_variable_name || g_separator || TO_CHAR(i_variable_value));
429          END IF;
430 
431       EXCEPTION
432          WHEN OTHERS THEN
433             setErrorInfo(2,30,ecx_utils.i_errbuf || ' ECX_DEBUG.PL: ' || SQLERRM);
434             raise ecx_utils.program_exit;
435  END pl;
436    --This is an overloaded procedure to concatenate a given variable name and
437    --the string value.
438 /*commenting  this pl because it is conflicting with anothe overloaded version having the
439   arguments of the same datatype in the same order */
440    PROCEDURE pl(
441       i_level            IN   PLS_INTEGER,
442       i_variable_name    IN   VARCHAR2,
443       i_variable_value   IN   VARCHAR2) IS
444 
445       BEGIN
446          IF (g_debug_level >= i_level) THEN
447             split(i_variable_name || g_separator || i_variable_value);
448          END IF;
449 
450       EXCEPTION
451          WHEN OTHERS THEN
452             setErrorInfo(2,30,ecx_utils.i_errbuf || ' ECX_DEBUG.PL: ' || SQLERRM);
453             raise ecx_utils.program_exit;
454 
455       END pl;
456 /**Change required for Clob Support -- 2263729 ***/
457    --This is an overloaded procedure to concatenate a given variable name and
458    --the clob value.
459    PROCEDURE pl(
460       i_level            IN   PLS_INTEGER,
461       i_variable_name    IN   VARCHAR2,
462       i_variable_value   IN   CLOB) IS
463 
464       ctemp              varchar2(32767);
465       clength            pls_integer;
466       offset            pls_integer := 1;
467       g_varmaxlength     pls_integer := 1999;
468       BEGIN
469 
470          IF (g_debug_level >= i_level) THEN
471                clength := dbms_lob.getlength(i_variable_value);
472                while  clength >= offset LOOP
473                      ctemp :=  dbms_lob.substr(i_variable_value,g_varmaxlength,offset);
474  split(i_variable_name || g_separator ||ctemp);
475                      offset := offset + g_varmaxlength;
476                End Loop;
477          END IF;
478 
479       EXCEPTION
480          WHEN OTHERS THEN
481             setErrorInfo(2,30,ecx_utils.i_errbuf || ' ECX_DEBUG.PL: ' || SQLERRM);
482             raise ecx_utils.program_exit;
483 
484       END pl;
485 --This is an overloaded procedure to concatenate a given variable name and
486    --the boolean value.
487    PROCEDURE pl(
488       i_level            IN   PLS_INTEGER,
489       i_variable_name    IN   VARCHAR2,
490       i_variable_value   IN   BOOLEAN) IS
491 
492       vtemp   VARCHAR2(10) := 'FALSE';
493 
494       BEGIN
495          IF (g_debug_level >= i_level) THEN
496             IF (i_variable_value) THEN
497                vtemp := 'TRUE';
498             ELSE
499                vtemp := 'FALSE';
500             END IF;
501 
502             split(i_variable_name || g_separator || vtemp);
503         END IF;
504 
505       EXCEPTION
506          WHEN OTHERS THEN
507             setErrorInfo(2,30,ecx_utils.i_errbuf || ' ECX_DEBUG.PL: ' || SQLERRM);
508             raise ecx_utils.program_exit;
509 
510       END pl;
511 
512 
513    --This is an overloaded procedure to set the tokens and retrieve the
514    --message and print it to the appropriate log/report file.
515    PROCEDURE log(
516       i_level            IN   PLS_INTEGER ,
517       i_app_short_name   IN   VARCHAR2,
521       i_value1           IN   VARCHAR2 ,
518       i_message_name     IN   VARCHAR2,
519       i_program_name     IN   VARCHAR2,
520       i_token1           IN   VARCHAR2 ,
522       i_token2           IN   VARCHAR2 ,
523       i_value2           IN   VARCHAR2 ,
524       i_token3           IN   VARCHAR2 ,
525       i_value3           IN   VARCHAR2 ,
526       i_token4           IN   VARCHAR2 ,
527       i_value4           IN   VARCHAR2 ,
528       i_token5           IN   VARCHAR2 ,
529       i_value5           IN   VARCHAR2 ,
530       i_token6           IN   VARCHAR2 ,
531       i_value6           IN   VARCHAR2
532       ) IS
533 
534       nmsg_count  PLS_INTEGER;
535 
536       BEGIN
537 	if(i_level = g_unexpected and pv_LevelToLog<g_unexpected) then
538 	 pv_LevelToLog := g_unexpected;
539 	end if;
540 
541             IF i_token1 IS NOT NULL AND
542                i_value1 IS NOT NULL THEN
543         	wf_core.token(i_token1,i_value1);
544 
545                IF i_token2 IS NOT NULL AND
546                   i_value2 IS NOT NULL THEN
547         	  wf_core.token(i_token2,i_value2);
548 
549                   IF i_token3 IS NOT NULL AND
550                      i_value3 IS NOT NULL THEN
551         	     wf_core.token(i_token3,i_value3);
552 
553                      IF i_token4 IS NOT NULL AND
554                         i_value4 IS NOT NULL THEN
555         	        wf_core.token(i_token4,i_value4);
556 
557                         IF i_token5 IS NOT NULL AND
558                            i_value5 IS NOT NULL THEN
559         	           wf_core.token(i_token5,i_value5);
560 
561                            IF i_token6 IS NOT NULL AND
562                               i_value6 IS NOT NULL THEN
563         	              wf_core.token(i_token5,i_value5);
564                            END IF; -- i_token6
565                         END IF; -- i_token5
566                      END IF; -- i_token4
567                   END IF; -- i_token3
568                END IF; -- i_token2
569             END IF; -- i_token1
570 /*           IF g_instlmode = 'EMBEDDED' THEN
571                   fnd_log.string(i_level, g_sqlprefix ||i_program_name||'.'||i_message_name,
572 	                         wf_core.translate(i_message_name));
573            ELSE*/
574             IF g_use_cmanager_flag THEN   --Use the Concurrent Manager
575 	       null;
576             ELSE                          --Don't use the Concurrent Manager
577                nmsg_count := g_message_stack.COUNT + 1;
578                g_message_stack(nmsg_count).message_text := indent_text(0) || wf_core.translate(i_message_name);
579             END IF;
580 --         END IF;
581 
582       EXCEPTION
583          WHEN OTHERS THEN
584             setErrorInfo(2,30,ecx_utils.i_errbuf || ' ECX_DEBUG.LOG: ' || SQLERRM);
585             raise ecx_utils.program_exit;
586 
587       END log;
588 
589    --This is an overloaded procedure to split a message string into 132 character
590    --strings.
591    PROCEDURE log(i_level IN PLS_INTEGER,i_string IN VARCHAR2,
592                 i_program_name     IN   VARCHAR2) IS
593 
594       BEGIN
595 	if(i_level = g_unexpected and pv_LevelToLog<g_unexpected) then
596 	 pv_LevelToLog := g_unexpected;
597 	end if;
598 /*         IF g_instlmode = 'EMBEDDED' THEN
599 	    fnd_log.string(i_level, g_sqlprefix ||i_program_name,
600 	                   i_string);
601          ELSE */
602             split(i_string);
603 --         END IF;
604 
605       EXCEPTION
606          WHEN OTHERS THEN
607             setErrorInfo(2,30,ecx_utils.i_errbuf || ' ECX_DEBUG.LOG: ' || SQLERRM);
608             raise ecx_utils.program_exit;
609 
610       END log;
611 
612    --This is an overloaded procedure to concatenate a given variable name and
613    --the date value.
614    PROCEDURE log(
615       i_level            IN   PLS_INTEGER,
616       i_variable_name    IN   VARCHAR2,
617       i_variable_value   IN   DATE,
618       i_program_name     IN   VARCHAR2) IS
619 
620       BEGIN
621         if(i_level = g_unexpected and pv_LevelToLog<g_unexpected) then
622 	 pv_LevelToLog := g_unexpected;
623 	end if;
624 /*        IF g_instlmode = 'EMBEDDED' THEN
625          fnd_log.string(i_level, g_sqlprefix ||i_program_name||'.'||i_variable_name,
626 	                i_variable_name||g_separator||TO_CHAR(i_variable_value,'DD-MON-YYYY HH24:MI:SS'));
627         ELSE */
628          split(i_variable_name || g_separator ||
629                TO_CHAR(i_variable_value,'DD-MON-YYYY HH24:MI:SS'));
630 --         END IF;
631       EXCEPTION
632          WHEN OTHERS THEN
633             setErrorInfo(2,30,ecx_utils.i_errbuf || ' ECX_DEBUG.LOG: ' || SQLERRM);
634             raise ecx_utils.program_exit;
635 
636       END log;
637 
638    --This is an overloaded procedure to concatenate a given variable name and
639    --the number value.
640    PROCEDURE log(
641       i_level            IN   PLS_INTEGER,
642       i_variable_name    IN   VARCHAR2,
643       i_variable_value   IN   NUMBER,
644       i_program_name     IN   VARCHAR2) IS
645 
646       BEGIN
647         if(i_level = g_unexpected and pv_LevelToLog<g_unexpected) then
648 	 pv_LevelToLog := g_unexpected;
649 	end if;
650 /*        IF g_instlmode = 'EMBEDDED' THEN
651          fnd_log.string(i_level, g_sqlprefix ||i_program_name||'.'||i_variable_name,
652 	                i_variable_name || g_separator || TO_CHAR(i_variable_value));
653         ELSE */
654             split(i_variable_name || g_separator || TO_CHAR(i_variable_value));
655 --         END IF;
656 
657       EXCEPTION
658          WHEN OTHERS THEN
662       END log;
659             setErrorInfo(2,30,ecx_utils.i_errbuf || ' ECX_DEBUG.LOG: ' || SQLERRM);
660             raise ecx_utils.program_exit;
661 
663 
664    --This is an overloaded procedure to concatenate a given variable name and
665    --the string value.
666    PROCEDURE log(
667       i_level            IN   PLS_INTEGER,
668       i_variable_name    IN   VARCHAR2,
669       i_variable_value   IN   VARCHAR2,
670       i_program_name     IN   VARCHAR2) IS
671 
672       BEGIN
673         if(i_level = g_unexpected and pv_LevelToLog<g_unexpected) then
674 	 pv_LevelToLog := g_unexpected;
675 	end if;
676 /*        IF g_instlmode = 'EMBEDDED' THEN
677          fnd_log.string(i_level, g_sqlprefix ||i_program_name||'.'||i_variable_name,
678 	               i_variable_name || g_separator || i_variable_value);
679         ELSE */
680             split(i_variable_name || g_separator || i_variable_value);
681 --         END IF;
682 
683       EXCEPTION
684          WHEN OTHERS THEN
685             setErrorInfo(2,30,ecx_utils.i_errbuf || ' ECX_DEBUG.LOG: ' || SQLERRM);
686             raise ecx_utils.program_exit;
687 
688       END log;
689 
690      /**Change required for Clob Support -- 2263729 ***/
691    --This is an overloaded procedure to concatenate a given variable name and
692    --the clob value.
693    PROCEDURE log(
694       i_level            IN   PLS_INTEGER,
695       i_variable_name    IN   VARCHAR2,
696       i_variable_value   IN   CLOB,
697       i_program_name     IN   VARCHAR2) IS
698 
699       ctemp              varchar2(32767);
700       clength            pls_integer;
701       offset            pls_integer := 1;
702       g_varmaxlength     pls_integer := 1999;
703       BEGIN
704 	if(i_level = g_unexpected and pv_LevelToLog<g_unexpected) then
705 	 pv_LevelToLog := g_unexpected;
706 	end if;
707 /*        IF g_instlmode = 'EMBEDDED' THEN
708          return;
709         ELSE*/
710                clength := dbms_lob.getlength(i_variable_value);
711                while  clength >= offset LOOP
712                      ctemp :=  dbms_lob.substr(i_variable_value,g_varmaxlength,offset);
713                      split(i_variable_name || g_separator ||ctemp);
714                      offset := offset + g_varmaxlength;
715                End Loop;
716 --         END IF;
717 
718       EXCEPTION
719          WHEN OTHERS THEN
720             setErrorInfo(2,30,ecx_utils.i_errbuf || ' ECX_DEBUG.LOG: ' || SQLERRM);
721             raise ecx_utils.program_exit;
722 
723       END log;
724 
725    --This is an overloaded procedure to concatenate a given variable name and
726    --the boolean value.
727    PROCEDURE log(
728       i_level            IN   PLS_INTEGER,
729       i_variable_name    IN   VARCHAR2,
730       i_variable_value   IN   BOOLEAN,
731       i_program_name     IN   VARCHAR2) IS
732 
733       vtemp   VARCHAR2(10) := 'FALSE';
734 
735       BEGIN
736         if(i_level = g_unexpected and pv_LevelToLog<g_unexpected) then
737 	 pv_LevelToLog := g_unexpected;
738 	end if;
739             IF (i_variable_value) THEN
740                vtemp := 'TRUE';
741             ELSE
742                vtemp := 'FALSE';
743             END IF;
744 
745 /*         IF g_instlmode = 'EMBEDDED' THEN
746              fnd_log.string(i_level, g_sqlprefix ||i_program_name||'.'||i_variable_name,
747 	               i_variable_name || g_separator || vtemp);
748          ELSE */
749             split(i_variable_name || g_separator || vtemp);
750 --        END IF;
751 
752       EXCEPTION
753          WHEN OTHERS THEN
754             setErrorInfo(2,30,ecx_utils.i_errbuf || ' ECX_DEBUG.LOG: ' || SQLERRM);
755             raise ecx_utils.program_exit;
756 
757       END log;
758 
759 
760    PROCEDURE print_log IS
761       uFile_type              utl_file.file_type;
762 	attachment_id pls_integer;
763       BEGIN
764 /*      IF g_instlmode = 'EMBEDDED' THEN
765              return;
766       ELSE */
767 	/** Check for the Data in the buffer. If empty do not even open a file **/
768 	if g_message_stack.count = 0
769 	then
770 		return;
771 	elsif g_message_stack.count = 1
772 	then
773 		if g_message_stack(1).message_text is null
774 		then
775 			return;
776 		end if;
777 	end if;
778 
779          IF (g_write_file_flag) AND          --Write the file...
780 		    (NOT g_use_cmanager_flag) AND    --Concurrent Manager is not being used...
781 		    (g_file_path IS NOT NULL) AND    --Path is not NULL...
782 		    (g_file_name IS NOT NULL) THEN   --Name is not NULL...
783 		    --Open the table
784 		    if ( g_file_path is null or g_file_name is null )   then
785 			return;
786 		    else
787 			IF g_instlmode = 'EMBEDDED' THEN
788 				fnd_message.set_name('ecx', 'Log File');
789 				attachment_id := fnd_log.message_with_attachment(pv_LevelToLog, g_aflog_module_name, TRUE);
790 				if(attachment_id <> -1) then
791 					FOR loop_count IN 1..g_message_stack.COUNT LOOP
792 						fnd_log_attachment.writeln(attachment_id, RTRIM(g_message_stack(loop_count).message_text));
793 					END LOOP;
794 					fnd_log_attachment.close(attachment_id);
795 				end if;
796 			g_aflog_module_name:=null;
797 			else
798 				uFile_type := utl_file.fopen(g_file_path,g_file_name,'W');
799 				FOR loop_count IN 1..g_message_stack.COUNT LOOP
800 				utl_file.put_line(uFile_type,
801 					 RTRIM(g_message_stack(loop_count).message_text));
802 				END LOOP;
803 				utl_file.fclose(uFile_type);
804 		        end if;
805 		    end if;
806          END IF;
807       EXCEPTION
808          WHEN utl_file.write_error THEN
812             setErrorInfo(2,30,'ECX_UTL_WRITE_ERROR' || '- ECX_DEBUG.PRINT_LOG');
809             if (utl_file.is_open(uFile_type)) then
810                utl_file.fclose(uFile_type);
811             end if;
813             raise ecx_utils.program_exit;
814 
815          WHEN utl_file.invalid_path THEN
816             setErrorInfo(2,30,
817                          'ECX_UTL_INVALID_PATH' || ' - ECX_DEBUG.PRINT_LOG');
818             raise ecx_utils.program_exit;
819 
820          WHEN utl_file.invalid_operation THEN
821             setErrorInfo(2,30,
822                           'ECX_UTL_INVALID_OPERATION' || ' - ECX_DEBUG.PRINT_LOG');
823             raise ecx_utils.program_exit;
824 
825          WHEN OTHERS THEN
826             if (utl_file.is_open(uFile_type)) then
827                utl_file.fclose(uFile_type);
828             end if;
829             setErrorInfo(2,30,
830                          SQLERRM || ' - ECX_DEBUG.PRINT_LOG');
831             raise ecx_utils.program_exit;
832 
833       END print_log;
834 
835    PROCEDURE head(
836       p_output    OUT NOCOPY VARCHAR2,
837       p_lines     IN  PLS_INTEGER ,
838       p_delimiter IN  VARCHAR2    ) IS
839 
840       BEGIN
841          IF (g_use_cmanager_flag) THEN
842             p_output := NULL;
843 
844          ELSE
845             p_output := g_message_stack(1).message_text;
846 
847             FOR loop_count IN 2..p_lines LOOP
848                p_output := p_output || p_delimiter || g_message_stack(loop_count).message_text;
849             END LOOP;
850          END IF;
851       END head;
852 
853    PROCEDURE tail(
854       p_output    OUT NOCOPY VARCHAR2,
855       p_lines     IN  PLS_INTEGER ,
856       p_delimiter IN  VARCHAR2    ) IS
857 
858       nmsg_count  PLS_INTEGER;
859 
860       BEGIN
861          IF (g_use_cmanager_flag) THEN
862             p_output := NULL;
863          ELSE
864             nmsg_count := g_message_stack.COUNT;
865 
866             p_output := g_message_stack(nmsg_count - p_lines + 1).message_text;
867 
868             FOR loop_count IN (nmsg_count - p_lines + 2)..nmsg_count LOOP
869                p_output := p_output || p_delimiter || g_message_stack(loop_count).message_text;
870             END LOOP;
871          END IF;
872       END tail;
873 
874 
875    --This function sets the tokens and retrieves the translated message.
876 
877    FUNCTION getTranslatedMessage(
878       i_message_name     IN   VARCHAR2,
879       i_token1           IN   VARCHAR2 ,
880       i_value1           IN   VARCHAR2 ,
881       i_token2           IN   VARCHAR2 ,
882       i_value2           IN   VARCHAR2 ,
883       i_token3           IN   VARCHAR2 ,
884       i_value3           IN   VARCHAR2 ,
885       i_token4           IN   VARCHAR2 ,
886       i_value4           IN   VARCHAR2 ,
887       i_token5           IN   VARCHAR2 ,
888       i_value5           IN   VARCHAR2 ,
889       i_token6           IN   VARCHAR2 ,
890       i_value6           IN   VARCHAR2 ,
891       i_token7           IN   VARCHAR2 ,
892       i_value7           IN   VARCHAR2 ,
893       i_token8           IN   VARCHAR2 ,
894       i_value8           IN   VARCHAR2 ,
895       i_token9           IN   VARCHAR2 ,
896       i_value9           IN   VARCHAR2 ,
897       i_token10          IN   VARCHAR2 ,
898       i_value10          IN   VARCHAR2 ) return varchar2 IS
899 
900       BEGIN
901 
902        IF i_token1 IS NOT NULL THEN
903         wf_core.token(i_token1,i_value1);
904 
905         IF i_token2 IS NOT NULL THEN
906          wf_core.token(i_token2,i_value2);
907 
908          IF i_token3 IS NOT NULL THEN
909           wf_core.token(i_token3,i_value3);
910 
911           IF i_token4 IS NOT NULL THEN
912            wf_core.token(i_token4,i_value4);
913 
914            IF i_token5 IS NOT NULL THEN
915             wf_core.token(i_token5,i_value5);
916 
917             IF i_token6 IS NOT NULL THEN
918              wf_core.token(i_token6,i_value6);
919 
920              IF i_token7 IS NOT NULL THEN
921               wf_core.token(i_token7,i_value7);
922 
923               IF i_token8 IS NOT NULL THEN
924                wf_core.token(i_token8,i_value8);
925 
926                IF i_token9 IS NOT NULL THEN
927                 wf_core.token(i_token9,i_value9);
928 
929                 IF i_token10 IS NOT NULL THEN
930                  wf_core.token(i_token10,i_value10);
931                 END IF; -- i_token10
932                END IF; -- i_token9
933               END IF; -- i_token8
934              END IF; -- i_token7
935             END IF; -- i_token6
936            END IF; -- i_token5
937           END IF; -- i_token4
938          END IF; -- i_token3
939         END IF; -- i_token2
940        END IF; -- i_token1
941 
942             return wf_core.translate(i_message_name);
943 
944 
945       EXCEPTION
946          WHEN OTHERS THEN
947            return (i_message_name);
948       END getTranslatedMessage;
949 
950     /* sets ecx_utils.i_errbuf and the message parameters and values associated*/
951     /* with the message in ecx_utils.i_errbuf */
952     PROCEDURE setMessage(
953                         p_message_name in varchar2,
954                         p_token1       in varchar2,
955                         p_value1       in varchar2,
956                         p_token2       in varchar2,
957                         p_value2       in varchar2,
958                         p_token3       in varchar2,
959                         p_value3       in varchar2,
960                         p_token4       in varchar2,
964                         p_token6       in varchar2,
961                         p_value4       in varchar2,
962                         p_token5       in varchar2,
963                         p_value5       in varchar2,
965                         p_value6       in varchar2,
966                         p_token7       in varchar2,
967                         p_value7       in varchar2,
968                         p_token8       in varchar2,
969                         p_value8       in varchar2,
970                         p_token9       in varchar2,
971                         p_value9       in varchar2,
972                         p_token10      in varchar2,
973                         p_value10      in varchar2) is
974 
975    BEGIN
976         if (p_message_name is NULL) then
977                 return;
978         end if;
979 
980         if (ecx_utils.g_cust_msg_code is not null) then
981            ecx_utils.i_errbuf := ecx_utils.g_cust_msg_code || pv_CustMsgSeparator
982                                  || p_message_name;
983         else
984            ecx_utils.i_errbuf := p_message_name;
985 
986         end if;
987         ecx_utils.g_cust_msg_code := null;
988         ecx_utils.i_errparams := null;
989 
990         IF p_token1 IS NOT NULL THEN
991         ecx_utils.i_errparams := p_token1 || pv_NameValueSeparator ||
992                                  p_value1 || pv_MsgParamSeparator;
993 
994         IF p_token2 IS NOT NULL THEN
995         ecx_utils.i_errparams := ecx_utils.i_errparams ||
996                                  p_token2 || pv_NameValueSeparator ||
997                                  p_value2 || pv_MsgParamSeparator ;
998 
999          IF p_token3 IS NOT NULL THEN
1000          ecx_utils.i_errparams := ecx_utils.i_errparams ||
1001                                   p_token3 || pv_NameValueSeparator ||
1002                                   p_value3 || pv_MsgParamSeparator ;
1003 
1004           IF p_token4 IS NOT NULL THEN
1005            ecx_utils.i_errparams := ecx_utils.i_errparams ||
1006                                     p_token4 || pv_NameValueSeparator ||
1007                                     p_value4 || pv_MsgParamSeparator ;
1008 
1009            IF p_token5 IS NOT NULL THEN
1010             ecx_utils.i_errparams := ecx_utils.i_errparams ||
1011                                      p_token5 || pv_NameValueSeparator ||
1012                                      p_value5 || pv_MsgParamSeparator;
1013 
1014             IF p_token6 IS NOT NULL THEN
1015              ecx_utils.i_errparams := ecx_utils.i_errparams ||
1016                                       p_token6 || pv_NameValueSeparator ||
1017                                       p_value6 || pv_MsgParamSeparator;
1018              IF p_token7 IS NOT NULL THEN
1019               ecx_utils.i_errparams := ecx_utils.i_errparams ||
1020                                        p_token7 || pv_NameValueSeparator ||
1021                                        p_value7 || pv_MsgParamSeparator;
1022 
1023               IF p_token8 IS NOT NULL THEN
1024                ecx_utils.i_errparams := ecx_utils.i_errparams ||
1025                                         p_token8 || pv_NameValueSeparator ||
1026                                         p_value8 || pv_MsgParamSeparator ;
1027                IF p_token9 IS NOT NULL THEN
1028                 ecx_utils.i_errparams := ecx_utils.i_errparams ||
1029                                         p_token9 || pv_NameValueSeparator ||
1030                                         p_value9 || pv_MsgParamSeparator ;
1031 
1032                 IF p_token10 IS NOT NULL THEN
1033                  ecx_utils.i_errparams := ecx_utils.i_errparams ||
1034                                         p_token10 || pv_NameValueSeparator ||
1035                                         p_value10 || pv_MsgParamSeparator ;
1036                  END IF; -- p_token10
1037                END IF; -- p_token9
1038               END IF; -- p_token8
1039              END IF; -- p_token7
1040             END IF; -- p_token6
1041            END IF; -- p_token5
1042           END IF; -- p_token4
1043          END IF; -- p_token3
1044         END IF; -- p_token2
1045        END IF; -- p_token1
1046 
1047 
1048    EXCEPTION
1049     when others then
1050       ecx_utils.i_errbuf := p_message_name;
1051    END setMessage;
1052 
1053    PROCEDURE setErrorInfo(
1054                           p_error_code   in pls_integer,
1055                           p_error_type   in pls_integer,
1056                           p_errmsg_name  in varchar2,
1057                           p_token1       in varchar2,
1058                           p_value1       in varchar2,
1059                           p_token2       in varchar2,
1060                           p_value2       in varchar2,
1061                           p_token3       in varchar2,
1062                           p_value3       in varchar2,
1063                           p_token4       in varchar2,
1064                           p_value4       in varchar2,
1065                           p_token5       in varchar2,
1066                           p_value5       in varchar2,
1067                           p_token6       in varchar2,
1068                           p_value6       in varchar2,
1069                           p_token7       in varchar2,
1070                           p_value7       in varchar2,
1071                           p_token8       in varchar2,
1072                           p_value8       in varchar2,
1073                           p_token9       in varchar2,
1074                           p_value9       in varchar2,
1075                           p_token10      in varchar2,
1076                           p_value10      in varchar2)
1077     is
1078     BEGIN
1079       ecx_utils.i_ret_code := p_error_code;
1080       ecx_utils.error_type := p_error_type;
1081       setMessage(p_errmsg_name,p_token1, p_value1,
1085                  p_token8, p_value8, p_token9, p_value9,
1082                  p_token2, p_value2, p_token3, p_value3,
1083                  p_token4, p_value4, p_token5, p_value5,
1084                  p_token6, p_value6, p_token7, p_value7,
1086                  p_token10, p_value10);
1087     EXCEPTION
1088       when others then
1089         setErrorInfo(2,30,'ECX_ERROR_NOT_SET');
1090     END setErrorInfo;
1091 
1092 
1093     PROCEDURE parseErrorParams(
1094       p_message        in varchar2,
1095       p_message_params in varchar2,
1096       o_trans_msg      out nocopy varchar2)
1097     is
1098     l_temp_1        ecx_error_msgs.message_parameters%TYPE;
1099     l_temp_2        ecx_error_msgs.message_parameters%TYPE;
1100     l_name          ecx_error_msgs.message_parameters%TYPE;
1101     l_value         ecx_error_msgs.message_parameters%TYPE;
1102     l_offset        NUMBER;
1103     l_offset1       NUMBER;
1104     l_last_offset   NUMBER;
1105     l_custom_msg    boolean := false;
1106     l_product_code  varchar2(20);
1107     l_message       varchar2(2000) := null;
1108     l_message_code  varchar2(2000) := null;
1109 
1110     begin
1111        if ((p_message not like 'ECX%') and (p_message not like 'WF%')) then
1112           if(wf_core.translate('WF_INSTALL') = 'EMBEDDED') then
1113             l_product_code := substr(p_message, 1,
1114                                      (instr(p_message, pv_CustMsgSeparator) - 1));
1115             if l_product_code is null then
1116             o_trans_msg:=p_message;
1117             return;
1118             end if;
1119             l_custom_msg := true;
1120             l_message := substr(p_message,
1121                     instr(p_message, pv_CustMsgSeparator)+ pv_CustMsgSeparatorSize);
1122 
1123 	/* We are shipping spec for standalone */
1124 
1125 	/* bug 3348967 l_message should be substr to length 30 as second parameter of set_name procedure
1126 	is asssigned to a variable which is defined as varchar2(30) */
1127 	l_message_code := substr(l_message, 1,30);
1128             fnd_message.set_name(l_product_code, l_message_code);
1129           end if;
1130        end if;
1131 
1132        if p_message_params is not null then
1133                 -- p_errparame should be of format:
1134                 -- 'MAP_ID=25#WF#MAP_CODE=ECX_TEST#WF#'
1135                 l_last_offset := 1;
1136                 l_temp_1 := p_message_params;
1137 
1138                 for i in 1..10 loop
1139                   l_offset := INSTR (l_temp_1, pv_MsgParamSeparator, 1, i);
1140                   if (l_offset <> 0) then
1141                      l_temp_2 := substr (l_temp_1, l_last_offset,
1142                                          l_offset-l_last_offset);
1143                      l_offset1 := INSTR (l_temp_2, pv_NameValueSeparator);
1144                      if (l_offset1 <> 0) then
1145                          l_name := substr (l_temp_2, 1, l_offset1-1);
1146                          l_value := substr (l_temp_2, l_offset1+1);
1147                          if (l_custom_msg) then
1148                             fnd_message.set_token(l_name,l_value);
1149                          else
1150                             wf_core.token (l_name, l_value);
1151                          end if;
1152                      else
1153                          -- error, = missing between name, value
1154                          exit;
1155                      end if;
1156                      l_last_offset := l_offset+pv_MsgParamSeparatorSize;
1157                   else
1158                      -- No more tags
1159                      exit;
1160                   end if;
1161                 end loop;
1162         end if;
1163 
1164         if (l_custom_msg) then
1165            o_trans_msg := fnd_message.get();
1166 
1167            -- if the fnd_message.get returns the same as the message code
1168            -- passed in, then the message code is not defined in fnd
1169            -- messages and we have to return back the original
1170            -- message as the output.
1171            if o_trans_msg = l_message_code then
1172               o_trans_msg := l_message;
1173            end if;
1174         else
1175            o_trans_msg := wf_core.translate(p_message);
1176         end if;
1177     end parseErrorParams;
1178 
1179     FUNCTION getMessage(
1180       p_message_name     IN   VARCHAR2,
1181       p_message_params   IN   VARCHAR2
1182     ) return varchar2
1183      is
1184       l_message_text varchar2(4000) := null;
1185      begin
1186         parseErrorParams(p_message_name, p_message_params, l_message_text);
1187         return l_message_text;
1188      end getMessage;
1189 
1190      PROCEDURE getdebugLevels(
1191        l_statement OUT NOCOPY integer,
1192        l_procedure OUT NOCOPY integer
1193      )
1194      is
1195      begin
1196       l_statement := g_statement;
1197       l_procedure := g_procedure;
1198      end getdebugLevels;
1199 
1200      PROCEDURE print_debug_spool(p_debug_array IN ECX_DBG_ARRAY_TYPE)
1201      is
1202        l_array_val varchar2(2000);
1203        l_message varchar2(2000);
1204        l_temp varchar2(100);
1205        l_pgm_name varchar2(100);
1206        l_idx number;
1207        l_idx1 number;
1208      begin
1209        for i in 1 .. p_debug_array.count
1210        loop
1211          l_array_val := p_debug_array(i);
1212          l_idx := instr(l_array_val,'#');
1213          l_temp := substr(l_array_val,1,l_idx-1);
1214 	 if(l_temp = 'STMT') then
1215 	    l_idx := l_idx + 1;
1216 	    l_idx1 := instr(l_array_val,'#',1,2);
1217 	    l_pgm_name := substr(l_array_val,l_idx,(l_idx1-l_idx));
1218 	    l_idx1 := l_idx1 + 1;
1219 	    l_message := substr(l_array_val,l_idx1);
1220 	    log(g_statement,l_message,l_pgm_name);
1221 	 end if;
1222 	 if(l_temp = 'PUSH') then
1226 	 end if;
1223 	    l_idx := l_idx + 1;
1224 	    l_pgm_name := substr(l_array_val,l_idx);
1225 	    push(l_pgm_name);
1227 	 if(l_temp = 'POP') then
1228 	    l_idx := l_idx + 1;
1229 	    l_pgm_name := substr(l_array_val,l_idx);
1230 	    pop(l_pgm_name);
1231 	 end if;
1232        end loop;
1233     end print_debug_spool;
1234  /*
1235   *This procedure is to append given log messages to existing log (for given module name)
1236   *bug16442475
1237   */
1238  procedure log(p_module IN VARCHAR2,
1239 	p_msgs IN FND_TABLE_OF_VARCHAR2_4000)
1240  as
1241  l_attachment_id NUMBER;
1242  begin
1243   if p_msgs.COUNT = 0 then
1244     return;
1245   end if;
1246   if length(trim(p_module)) >0 then
1247     begin
1248       select log_sequence into l_attachment_id from  fnd_log_messages
1249       where module=p_module;
1250     exception
1251       when no_data_found then
1252         l_attachment_id := fnd_log.message_with_attachment(1, p_module, TRUE);
1253     end;
1254   end if;
1255   FOR loop_count IN 1..p_msgs.COUNT LOOP
1256     fnd_log_attachment.writeln(l_attachment_id, RTRIM(p_msgs(loop_count)));
1257   end loop;
1258   fnd_log_attachment.close(l_attachment_id);
1259  exception
1260  when others then
1261   null;--do nothing
1262  end log;
1263 END ECX_DEBUG;
1264 
1265