DBA Data[Home] [Help]

PACKAGE BODY: APPS.JTF_DEBUG_PUB

Source


1 PACKAGE BODY JTF_DEBUG_PUB as
2 /* $Header: JTFPDBGB.pls 120.2 2005/10/17 04:22:40 vimohan ship $ */
3 -- Start of Comments
4 -- Package name     : JTF_DEBUG_PUB
5 -- Purpose          :
6 -- History          :
7 -- NOTE             :
8 -- End of Comments
9 
10 
11   G_PKG_NAME varchar2(100):= 'JTF_DEBUG_PUB';
12 
13   G_ICX_SESSION_ID NUMBER := NULL;
14 
15 ----------------------------------------------------------------------------
16   FUNCTION FormatNumber(parameter in varchar2, value in number)
17                         RETURN VARCHAR2 IS
18   l_value varchar2(240);
19   BEGIN
20     return (rpad(parameter,PAD_LENGTH)||'< '||nvl(to_char(value), 'NULL')||' >');
21   END;
22 
23 ----------------------------------------------------------------------------
24   FUNCTION FormatDate(parameter in varchar2, value in date) RETURN VARCHAR2 IS
25   BEGIN
26     return (rpad(parameter,PAD_LENGTH)||'< '||nvl(to_char(value),'NULL')||' >');
27   END;
28 
29 ----------------------------------------------------------------------------
30   FUNCTION FormatChar(parameter in varchar2, value in varchar2)
31                       RETURN VARCHAR2 IS
32   BEGIN
33     return (rpad(parameter,PAD_LENGTH)||'< '||nvl(value, 'NULL')||' >');
34   END;
35 
36 ----------------------------------------------------------------------------
37   FUNCTION FormatBoolean(parameter in varchar2, value in boolean)
38                          RETURN VARCHAR2 IS
39   BEGIN
40     return (rpad(parameter,PAD_LENGTH)||'< '||nvl(JTF_DBSTRING_UTILS.getBooleanString(value),'NULL')||' >');
41   END;
42 
43 ----------------------------------------------------------------------------
44   FUNCTION FormatIndent(parameter in varchar2) RETURN VARCHAR2 IS
45   BEGIN
46       return ('   '||parameter);
47   END;
48 
49 ----------------------------------------------------------------------------
50   /** Fuction getVersion returns the header information for this file */
51   FUNCTION getVersion RETURN VARCHAR2 IS
52   BEGIN
53     RETURN('$Header: JTFPDBGB.pls 120.2 2005/10/17 04:22:40 vimohan ship $');
54   END;
55 
56 ----------------------------------------------------------------------------
57   FUNCTION FormatSeperator RETURN VARCHAR2
58   IS
59   BEGIN
60     RETURN('-----------------------------------------------------------------');
61   END;
62 
63 
64 ---------------------------------------------------------------------------
65 /* this procedure handles all exceptions raised by utl_file
66  */
67 
68 procedure handle_utl_file_exceptions (exception_name in varchar2,
69                                       x_return_Status out nocopy varchar2,
70                                       x_msg_count out nocopy number,
71                                       x_msg_data out nocopy varchar2) is
72  CURSOR C_profile IS
73      select  user_profile_option_name
74      from   fnd_profile_options_vl
75      where  profile_option_name = 'UTL_FILE_LOG';
76 
77  l_profile_name varchar2(250);
78 begin
79    begin
80              OPEN C_profile;
81              FETCH C_profile into l_profile_name;
82              CLOSE C_profile;
83              l_profile_name := nvl(l_profile_name, 'UTL_FILE_LOG');
84 
85            exception
86             when others then
87              l_profile_name :=  'UTL_FILE_LOG';
88            end;
89             IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
90 		 FND_MESSAGE.Set_Name('JTF', 'JTF_DEBUG_ERROR1');
91 		 FND_MESSAGE.Set_Token('EXCEPTION_NAME',exception_name, FALSE);
92                  FND_MESSAGE.Set_Token('PROFILE_NAME',l_profile_name, FALSE);
93                  FND_MSG_PUB.ADD;
94  	    END IF;
95             JTF_DEBUG_PUB.HANDLE_EXCEPTIONS(
96 	          P_EXCEPTION_LEVEL => FND_MSG_PUB.G_MSG_LVL_ERROR
97                   ,P_MSG_COUNT => 1
98 		  ,X_MSG_COUNT => X_MSG_COUNT
99 		  ,X_MSG_DATA => X_MSG_DATA
100 		  ,X_RETURN_STATUS => X_RETURN_STATUS);
101 end handle_utl_file_exceptions;
102 
103 ----------------------------------------------------------------------------
104 /** set the global session ID  */
105    PROCEDURE  SET_ICX_SESSION_ID(
106                    p_sessionID   IN NUMBER) is
107    begin
108         G_ICX_SESSION_ID := p_sessionID;
109 
110    end SET_ICX_SESSION_ID;
111 ----------------------------------------------------------------------------
112    /*
113    **  Writes the message to the log file for the spec'd level and module
114    **  if logging is enabled for this level and module
115    */
116    PROCEDURE LOG_DEBUG(p_log_level IN NUMBER,
117                     p_module    IN VARCHAR2,
118                     p_message   IN VARCHAR2,
119                     p_icx_session_id IN NUMBER) is
120    PRAGMA AUTONOMOUS_TRANSACTION;
121    l_icx_session_id NUMBER;
122    begin
123       /* Setting icx_session_id to -1 if it is NULL */
124       /* Moved code *after* checking if logger is ON
125       if (p_icx_session_id is NULL) then
126          l_icx_session_id := -1;
127       else
128          l_icx_session_id := p_icx_session_id;
129       end if;
130       */
131       /* Bug #3468334 */
132       if FND_LOG.TEST (p_log_level, p_module) then
133         if (p_icx_session_id is NULL) then
134          l_icx_session_id := -1;
135         else
136          l_icx_session_id := p_icx_session_id;
137         end if;
138 
139 	if (p_log_level >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) then
140 	  FND_LOG.STRING(p_log_level, p_module, p_message);
141 	  COMMIT;
142 	end if;
143       end if;
144    end LOG_DEBUG;
145 
146    /*
147    **  Writes the message to the log file for the spec'd level and module
148    **  if logging is enabled for this level and module
149    **
150    **  Overloaded method which invokes the actual method with the value for ICX session ID
151    */
152    PROCEDURE LOG_DEBUG(p_log_level IN NUMBER,
153                     p_module    IN VARCHAR2,
154                     p_message   IN VARCHAR2) is
155    begin
156 
157    -- Invoking the actual method with global parameter
158    LOG_DEBUG( p_log_level, p_module, p_message, G_ICX_SESSION_ID );
159    end LOG_DEBUG;
160 
161    /*
162    **  Utility method to write specific kind of logging messages
163    */
164    PROCEDURE LOG_ENTERING_METHOD( p_module    IN VARCHAR2,
165                     p_message   IN VARCHAR2) is
166    begin
167 
168    -- Invoking the actual method with global parameter
169    /* Bug #3468334 */
170       if FND_LOG.TEST (FND_LOG.LEVEL_PROCEDURE, p_module) then
171 
172 	if (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) then
173 	  LOG_DEBUG( FND_LOG.LEVEL_PROCEDURE, p_module, 'Entered procedure : ' || p_message || ' at ' || SUBSTR(TO_CHAR(9999999999+DBMS_UTILITY.GET_TIME),5) , G_ICX_SESSION_ID );
174 	end if;
175    end if;
176    end LOG_ENTERING_METHOD;
177 
178    /*
179    **  Utility method to write specific kind of logging messages
180    */
181    PROCEDURE LOG_EXITING_METHOD( p_module    IN VARCHAR2,
182                     p_message   IN VARCHAR2) is
183    begin
184 
185    -- Invoking the actual method with global parameter
186       if FND_LOG.TEST (FND_LOG.LEVEL_PROCEDURE, p_module) then
187 
188 	if (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) then
189           LOG_DEBUG( FND_LOG.LEVEL_PROCEDURE, p_module, 'Exiting procedure : ' || p_message || ' at ' || SUBSTR(TO_CHAR(9999999999+DBMS_UTILITY.GET_TIME),5) , G_ICX_SESSION_ID );
190 	end if;
191 
192       end if;
193    end LOG_EXITING_METHOD;
194 
195    /*
196    **  Utility method to write specific kind of logging messages
197    */
198    PROCEDURE LOG_UNEXPECTED_ERROR( p_module    IN VARCHAR2,
199                     p_message   IN VARCHAR2) is
200    begin
201 
202    -- Invoking the actual method with global parameter
203    LOG_DEBUG( FND_LOG.LEVEL_UNEXPECTED, p_module,  p_message, G_ICX_SESSION_ID );
204    end LOG_UNEXPECTED_ERROR;
205 
206    /*
207    **  Utility method to write specific kind of logging messages
208    */
209    PROCEDURE LOG_PARAMETERS( p_module    IN VARCHAR2,
210                     p_message   IN VARCHAR2) is
211    begin
212 
213    -- Invoking the actual method with global parameter
214    LOG_DEBUG( FND_LOG.LEVEL_PROCEDURE, p_module,  p_message, G_ICX_SESSION_ID );
215    end LOG_PARAMETERS;
216 
217    /*
218    * A method to find out, if logging is on at the level of
219    * logging parameters
220    */
221 
222    FUNCTION IS_LOG_PARAMETERS_ON( p_module IN VARCHAR2) RETURN BOOLEAN IS
223 
224    BEGIN
225 
226    IF FND_LOG.TEST (FND_LOG.LEVEL_PROCEDURE, p_module) THEN
227    RETURN TRUE;
228    ELSE
229    RETURN FALSE;
230    END IF;
231    END IS_LOG_PARAMETERS_ON;
232 
233    /*
234    **  Utility method to write specific kind of logging messages
235    */
236    PROCEDURE LOG_EXCEPTION( p_module    IN VARCHAR2,
237                     p_message   IN VARCHAR2) is
238    begin
239 
240    -- Invoking the actual method with global parameter
241    LOG_DEBUG( FND_LOG.LEVEL_EXCEPTION, p_module,  p_message, G_ICX_SESSION_ID );
242    end LOG_EXCEPTION;
243 
244    /*
245    **  Utility method to write specific kind of logging messages
246    */
247    PROCEDURE LOG_EVENT( p_module    IN VARCHAR2,
248                     p_message   IN VARCHAR2) is
249    begin
250 
251    -- Invoking the actual method with global parameter
252    LOG_DEBUG( FND_LOG.LEVEL_EVENT, p_module,  p_message, G_ICX_SESSION_ID );
253    end LOG_EVENT;
254 
255    /*
256    **  Utility method to write specific kind of logging messages
257    */
258    PROCEDURE LOG_STATEMENT( p_module    IN VARCHAR2,
259                     p_message   IN VARCHAR2) is
260    begin
261 
262    -- Invoking the actual method with global parameter
263    LOG_DEBUG( FND_LOG.LEVEL_STATEMENT, p_module,  p_message, G_ICX_SESSION_ID );
264    end LOG_STATEMENT;
265 ----------------------------------------------------------------------------
266 /** returns filename if alteast one message has been written to it.
267     otherwise returns NULL */
268 
269    PROCEDURE  Debug(
270                    p_file_name   IN varchar2 := FND_API.G_MISS_CHAR,
271                    p_debug_tbl  IN  debug_tbl_type := G_MISS_DEBUG_TBL,
272                    p_module            IN  varchar2,
273                    x_path              OUT NOCOPY varchar2,
274                    x_filename          OUT NOCOPY varchar2,
275                    x_msg_count         OUT NOCOPY number,
276                    X_MSG_DATA        OUT NOCOPY VARCHAR2,
277 	           X_RETURN_STATUS   OUT NOCOPY VARCHAR2
278                   ) IS
279 
280     CURSOR C_log_message(p_session_id NUMBER, p_user_id NUMBER, p_module VARCHAR2, p_timestamp VARCHAR2) IS
281       SELECT message_text
282       FROM   fnd_log_messages
283       WHERE  module like p_module
284       AND    session_id = p_session_id
285       AND    user_id = p_user_id
286       AND    timestamp >= to_date(p_timestamp, 'DD-MM-YYYY HH24:MI:SS')
287       ORDER BY log_sequence;
288 
289   CURSOR C_current_time IS
290      SELECT to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS')
291      FROM dual;
292 
293      l_session_id NUMBER;
294      l_user_id    NUMBER ;
295      l_dir        VARCHAR2(2000);
296      l_filename   VARCHAR2(240);
297      l_filetype   UTL_FILE.file_type;
298      l_module     VARCHAR2(200);
299      l_buffer     VARCHAR2(4000);
300      l_profile_name VARCHAR2(240);
301      l_timestamp    VARCHAR2(240);
302      l_return     BOOLEAN := FALSE;
303   BEGIN
304 
305      X_Return_Status   :=  FND_API.G_RET_STS_SUCCESS;
306 
307      OPEN  C_current_time;
308      FETCH C_current_time into l_timestamp;
309      CLOSE C_current_time;
310 
311 
312   if((FND_LOG.LEVEL_EVENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)) then
313 
314      FOR i in 1..p_debug_tbl.count LOOP
315 
316      fnd_log.String(FND_LOG.LEVEL_EVENT, p_debug_tbl(i).module_name,
317                          p_debug_tbl(i).debug_message);
318      END LOOP;
319   end if;
320 
321      fnd_profile.get('UTL_FILE_LOG', l_dir);
322      if l_dir is null then
323         SELECT substr(value,1,instr(value,',',1,1)-1)
324         INTO   l_dir
325         FROM  v$parameter
326         WHERE name = 'utl_file_dir';
327         if l_dir is null then                  -- if there is only 1 directory
328            SELECT value
329            INTO l_dir
330            FROM v$parameter
331            WHERE name = 'utl_file_dir';
332         end if;
333 
334         --fnd_profile.put('UTL_FILE_LOG',l_dir);
335         if l_dir is null then
336             RAISE UTL_FILE.INVALID_PATH;
337         end if;
338       end if;
339 
340         SELECT  substr('l'|| substr(to_char(sysdate,'MI'),1,1)
341                  || lpad(jtf_Debug_s.nextval,6,'0'),1,8) || '.dbg'
342           into l_filename
343           from dual;
344 
345         l_filetype := UTL_FILE.fopen(location => l_dir,
346                                     filename => l_filename,
347                                     open_mode=> 'a');
348 
349         l_user_id := to_number(FND_PROFILE.VALUE( 'USER_ID'));
350         l_session_id := icx_sec.getsessioncookie();
351         if l_session_id is NULL then
352            l_session_id := -1;
353         end if;
354 
355         FOR i in C_log_message(l_session_id, l_user_id, p_module, l_timestamp) LOOP
356           l_return := TRUE; -- need to move this out of the loop
357           UTL_FILE.put_line(l_filetype, i.message_text);
358         END LOOP;
359 
360         UTL_FILE.fflush(l_filetype);
361         UTL_FILE.fclose(l_filetype);
362 
363         x_path     := l_dir;
364         if l_return then
365           x_filename := l_filename;
366         else
367           x_filename := NULL;
368         end if;
369 
370 
371    EXCEPTION
372           WHEN UTL_FILE.INVALID_PATH THEN
373            handle_utl_file_exceptions('INVALID PATH', x_return_Status, x_msg_count, x_msg_data);
374           WHEN UTL_FILE.INVALID_MODE THEN
375            handle_utl_file_exceptions('INVALID MODE', x_return_Status, x_msg_count, x_msg_data);
376           WHEN UTL_FILE.INVALID_FILEHANDLE THEN
377            handle_utl_file_exceptions('INVALID FILEHANDLE', x_return_Status, x_msg_count, x_msg_data);
378           WHEN UTL_FILE.INVALID_OPERATION THEN
379             handle_utl_file_exceptions('INVALID OPERATION', x_return_Status, x_msg_count, x_msg_data);
380           WHEN UTL_FILE.WRITE_ERROR THEN
381             handle_utl_file_exceptions('WRITE ERROR', x_return_Status, x_msg_count, x_msg_data);
382           WHEN UTL_FILE.INTERNAL_ERROR THEN
383             handle_utl_file_exceptions('INTERNAL ERROR', x_return_Status, x_msg_count, x_msg_data);
384           WHEN OTHERS THEN
385              JTF_DEBUG_PUB.HANDLE_EXCEPTIONS(
386                    P_API_NAME => NULL
387                   ,P_PKG_NAME => G_PKG_NAME
388 		  ,P_EXCEPTION_LEVEL => G_EXC_OTHERS
389                   ,P_SQLCODE  => SQLCODE
390                   ,P_SQLERRM  => SQLERRM
391                   ,P_MSG_COUNT => 0
392 		  ,X_MSG_COUNT => X_MSG_COUNT
393 		  ,X_MSG_DATA => X_MSG_DATA
394 		  ,X_RETURN_STATUS => X_RETURN_STATUS);
395 
396   END Debug;
397 
398 PROCEDURE Handle_Exceptions(
399                 P_API_NAME        IN  VARCHAR2 := FND_API.G_MISS_CHAR,
400                 P_PKG_NAME        IN  VARCHAR2 := FND_API.G_MISS_CHAR,
401                 P_EXCEPTION_LEVEL IN  NUMBER   := FND_API.G_MISS_NUM,
402                 P_SQLCODE         IN  NUMBER   DEFAULT NULL,
403                 P_SQLERRM         IN  VARCHAR2 DEFAULT NULL,
404                 P_MSG_COUNT       IN NUMBER := FND_API.G_MISS_NUM,
405                 P_LOG_LEVEL       IN  NUMBER   DEFAULT NULL,
406                 P_LOG_MODULE      IN  VARCHAR2 DEFAULT NULL,
407                 X_MSG_COUNT       OUT NOCOPY NUMBER,
408                 X_MSG_DATA        OUT NOCOPY VARCHAR2,
409 	        X_RETURN_STATUS   OUT NOCOPY VARCHAR2)
410 IS
411 l_api_name    VARCHAR2(30);
412 l_len_sqlerrm Number ;
413 i number := 1;
414 k number := 1;
415 l_msg_data VARCHAR2(2000);
416 l_msg_count number := 1;
417 
418 BEGIN
419     l_api_name := UPPER(p_api_name);
420 
421     if l_api_name <> FND_API.G_MISS_CHAR then
422       DBMS_TRANSACTION.ROLLBACK_SAVEPOINT(l_api_name);
423     end if;
424 
425     IF p_exception_level = FND_MSG_PUB.G_MSG_LVL_ERROR
426     THEN
427         x_return_status := FND_API.G_RET_STS_ERROR;
428         IF p_msg_count <> FND_API.G_MISS_NUM THEN
429             x_msg_count := p_msg_count;
430         ELSE
431           FND_MSG_PUB.Count_And_Get(
432             p_encoded =>  fnd_api.g_false,
433             p_count   =>  x_msg_count,
434             p_data    =>  x_msg_data);
435         END IF;
436     ELSIF p_exception_level = FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR
437     THEN
438         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
439          IF p_msg_count <> FND_API.G_MISS_NUM THEN
440             x_msg_count := p_msg_count;
441         ELSE
442           FND_MSG_PUB.Count_And_Get(
443             p_encoded =>  fnd_api.g_false,
444             p_count   =>  x_msg_count,
445             p_data    =>  x_msg_data);
446         END IF;
447     ELSIF p_exception_level = G_EXC_OTHERS
448     THEN
449         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
450 
451        /*   FND_MSG_PUB.Count_And_Get(
452             p_count   =>  l_msg_count,
453             p_data    =>  x_msg_data);
454        */
455         FND_MESSAGE.Set_Name('JTF', 'JTF_ERROR_RETURNED');
456         FND_MESSAGE.Set_token('PKG_NAME' , p_pkg_name);
457         FND_MESSAGE.Set_token('API_NAME' , p_api_name);
458         FND_MSG_PUB.ADD;
459         l_len_sqlerrm := Length(P_SQLERRM) ;
460            While l_len_sqlerrm >= i Loop
461              FND_MESSAGE.Set_Name('JTF', 'JTF_SQLERRM');
462              FND_MESSAGE.Set_token('ERR_TEXT' , substr(P_SQLERRM,i,240));
463              i := i + 240;
464              FND_MSG_PUB.ADD;
465              l_msg_count := l_msg_count + 1;
466           end loop;
467 
468         IF p_msg_count <> FND_API.G_MISS_NUM THEN
469             x_msg_count := p_msg_count + l_msg_count;
470                                         -- messages added by this API
471         ELSE
472           FND_MSG_PUB.Count_And_Get(
473             p_encoded =>  fnd_api.g_false,
474             p_count   =>  x_msg_count,
475             p_data    =>  x_msg_data);
476         END IF;
477     END IF;
478     -- Logging the error
479 
480     IF (P_LOG_LEVEL is not null ) AND (P_LOG_MODULE is not null) THEN
481        for k in 1 ..x_msg_count loop
482           l_msg_data := fnd_msg_pub.get( p_msg_index => k,
483                         p_encoded => 'F'
484                         );
485           LOG_DEBUG( P_LOG_LEVEL, P_LOG_MODULE, P_PKG_NAME || '.' || P_API_NAME || '-' || k || '-' || substr(l_msg_data,1,200) );
486         end loop;
487     END IF;
488 
489 END Handle_Exceptions;
490 
491 PROCEDURE Get_Messages (
492 p_message_count IN  NUMBER,
493 x_message_count OUT NOCOPY NUMBER,
494 x_msgs          OUT NOCOPY VARCHAR2)
495 IS
496       l_msg_list        VARCHAR2(2500) := '
497 ';  -- this should be more than 4000 so that it does not error out before
498     -- the limit is checked.
499       l_temp_msg        VARCHAR2(2000);
500       l_appl_short_name  VARCHAR2(20) ;
501       l_message_name    VARCHAR2(30) ;
502 
503       l_id              NUMBER;
504       l_message_num     NUMBER;
505 
506 	 l_msg_count       NUMBER;
507 	 l_msg_data        VARCHAR2(2000);
508      MSG_INDEX NUMBER := 1; -- index of the message that needs to be retrieved.
509 
510       Cursor Get_Appl_Id (x_short_name VARCHAR2) IS
511         SELECT  application_id
512         FROM    fnd_application_vl
513         WHERE   application_short_name = x_short_name;
514 
515       Cursor Get_Message_Num (x_msg VARCHAR2, x_id NUMBER, x_lang_id NUMBER) IS
516         SELECT  msg.message_number
517         FROM    fnd_new_messages msg, fnd_languages_vl lng
518         WHERE   msg.message_name = x_msg
519           and   msg.application_id = x_id
520           and   lng.LANGUAGE_CODE = msg.language_code
521           and   lng.language_id = x_lang_id;
522 BEGIN
523 
524       MSG_INDEX := FND_MSG_PUB.count_msg - p_message_count + 1;
525 
526       FOR l_count in 1..NVL(p_message_count,0) LOOP
527       --  l_temp_msg := fnd_msg_pub.get(fnd_msg_pub.g_next, fnd_api.g_true);
528         l_temp_msg := fnd_msg_pub.get(MSG_INDEX, fnd_api.g_true);
529         fnd_message.parse_encoded(l_temp_msg, l_appl_short_name, l_message_name);
530 
531         OPEN Get_Appl_Id (l_appl_short_name);
532         FETCH Get_Appl_Id into l_id;
533         CLOSE Get_Appl_Id;
534 
535         l_message_num := NULL;
536         IF l_id is not NULL THEN
537           OPEN Get_Message_Num (l_message_name, l_id,
538                         to_number(NVL(FND_PROFILE.Value('LANGUAGE'), '0')));
539           FETCH Get_Message_Num into l_message_num;
540           CLOSE Get_Message_Num;
541         END IF;
542 
543         l_temp_msg := fnd_msg_pub.get(fnd_msg_pub.g_previous, fnd_api.g_true);
544 
545         IF NVL(l_message_num, 0) <> 0 THEN
546           l_temp_msg := 'APP-' || to_char(l_message_num) || ': ';
547         ELSE
548           l_temp_msg := NULL;
549         END IF;
550 
551           l_msg_list := l_msg_list || l_temp_msg ||
552                        fnd_msg_pub.get(MSG_INDEX, fnd_api.g_false);
553     /*
554         IF l_count = 1 THEN
555           l_msg_list := l_msg_list || l_temp_msg ||
556                        fnd_msg_pub.get(fnd_msg_pub.g_first, fnd_api.g_false);
557         ELSE
558           l_msg_list := l_msg_list || l_temp_msg ||
559                         fnd_msg_pub.get(fnd_msg_pub.g_next, fnd_api.g_false);
560         END IF;
561     */
562 
563         l_msg_list := l_msg_list || '
564 ';
565 
566         x_message_count := l_count;
567         MSG_INDEX := MSG_INDEX + 1;
568 
569         EXIT WHEN length(l_msg_list) > 2000;
570       END LOOP;
571 
572       x_msgs := substr(l_msg_list, 0, 2000);
573 
574     -- delete all the messages that have been read
575     -- can do this when the message is read but i don't want to mess with
576     -- the index
577 
578        MSG_INDEX := FND_MSG_PUB.count_msg - p_message_count + 1;
579        for i in 1..x_message_count loop
580          fnd_msg_pub.delete_msg(MSG_INDEX);
581          MSG_INDEX := MSG_INDEX + 1;
582       end loop;
583 
584 END Get_Messages;
585 
586     /*
587     * This function will substitute a token for an invalid paramater
588     *
589     */
590 
591 FUNCTION GET_INVALID_PARAM_MSG (p_token_value IN VARCHAR2) RETURN VARCHAR2 IS
592 
593    BEGIN
594 
595    fnd_message.set_name('JTF','JTF-1013');
596    fnd_message.set_token('0', p_token_value);
597 
598    return fnd_message.get;
599 
600 END GET_INVALID_PARAM_MSG;
601 
602    /*
603     * This function will return the translatable message
604     *
605     */
606 
607     FUNCTION GET_MSG (p_message_name IN VARCHAR2) RETURN VARCHAR2 IS
608 
609     BEGIN
610     fnd_message.set_name('JTF',p_message_name);
611     return fnd_message.get;
612     END GET_MSG ;
613 
614 
615 End JTF_DEBUG_PUB;