[Home] [Help]
PACKAGE BODY: APPS.OKS_RENEW_PVT
Source
1 Package Body OKS_RENEW_PVT AS
2 /* $Header: OKSRENWB.pls 120.3 2005/08/29 14:47:44 anjkumar ship $*/
3
4
5 PROCEDURE DEBUG_LOG(p_program_name IN VARCHAR2,
6 p_perf_msg IN VARCHAR2,
7 p_error_msg IN VARCHAR2,
8 p_path IN VARCHAR2) IS
9
10 l_msg_data VARCHAR2(2000);
11 l_msg_count NUMBER;
12 l_return_status VARCHAR2(1);
13
14 BEGIN
15
16 Debug_Log(p_program_name,
17 p_perf_msg,
18 p_error_msg,
19 p_path,
20 l_msg_data,
21 l_msg_count,
22 l_return_status);
23
24 END DEBUG_LOG;
25
26 /*
27 * This procedure will write the performace messages and/or error messages to a log file.
28 * The location of the log file depends on the first path in the value field of v$parameter.
29 * The name of the log file is ERM_l_session_id_FND_GLOBAL.user_id
30 */
31 Procedure Debug_Log(p_program_name IN VARCHAR2,
32 p_perf_msg IN VARCHAR2,
33 p_error_msg IN VARCHAR2,
34 p_path IN VARCHAR2,
35 x_msg_data OUT NOCOPY VARCHAR2,
36 x_msg_count OUT NOCOPY NUMBER,
37 x_return_status OUT NOCOPY VARCHAR2) IS
38
39 l_file_name VARCHAR2(200);
40 l_file_loc BFILE;
41 l_file_type utl_file.file_type;
42 l_location VARCHAR2(32000);
43 l_comma_loc NUMBER;
44 l_session_id NUMBER;
45 l_perf_msg VARCHAR2(32000) := p_program_name || ': ' || p_perf_msg;
46 l_error_msg VARCHAR2(32000) := p_error_msg;
47 l_end_time VARCHAR2(60);
48
49
50 cursor get_dir is
51 select value
52 from v$parameter
53 where name = 'utl_file_dir';
54
55 Begin
56 x_return_status := OKC_API.G_RET_STS_SUCCESS;
57
58 --anjkumar, for R12 nobody should use this procedure for loggin
59 --but for old modules that are still using this, make sure that this also
60 --writes to the standard fnd_log_messages table
61 IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
62 FND_LOG.string(FND_LOG.level_statement, nvl(p_program_name, 'oks.plsql.unknown'), p_perf_msg||' '||p_error_msg);
63 END IF;
64
65 l_end_time := to_char(sysdate, 'HH24:MI:SS AM');
66 l_perf_msg := l_perf_msg || ' ' || l_end_time;
67
68 If FND_PROFILE.VALUE('OKS_DEBUG') = 'Y' Then
69 l_session_id := Sys_Context('USERENV', 'SESSIONID');
70
71 --If l_perf_msg is null Then l_perf_msg := ''; End If;
72 If l_error_msg is null Then l_error_msg := ''; End If;
73
74 l_file_name := 'ERM_' || l_session_id || '_'
75 || FND_GLOBAL.user_id || '.out';
76
77 Open get_dir;
78 Fetch get_dir into l_location;
79 Close get_dir;
80
81 If l_location is not null Then
82 l_comma_loc := instr(l_location, ',');
83 If l_comma_loc <> 0 Then
84 l_location := substr(l_location, 1, l_comma_loc - 1);
85 End If;
86 End If;
87
88 If p_path is not null then
89 l_location := p_path;
90 End If;
91
92 l_file_type := utl_file.fopen(location => l_location,
93 filename => l_file_name,
94 open_mode => 'a');
95
96 utl_file.put_line(file => l_file_type,
97 buffer => l_perf_msg );
98
99 utl_file.put_line(file => l_file_type,
100 buffer => l_error_msg );
101
102 utl_file.fflush(file => l_file_type);
103 utl_file.fclose(l_file_type);
104 End If;
105
106 Exception
107 when utl_file.INVALID_PATH then
108 x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
109 x_msg_data := l_error_msg || ' Invalid Path';
110 x_msg_count:= 1;
111 OKC_API.set_message
112 (
113 G_APP_NAME,
114 G_UNEXPECTED_ERROR,
115 G_SQLCODE_TOKEN,
116 SQLCODE,
117 G_SQLERRM_TOKEN,
118 'Invalid path'
119 );
120 when utl_file.INVALID_OPERATION then
121 x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
122 x_msg_data := l_error_msg || ' Invalid operation';
123 x_msg_count:= 1;
124 OKC_API.set_message
125 (
126 G_APP_NAME,
127 G_UNEXPECTED_ERROR,
128 G_SQLCODE_TOKEN,
129 SQLCODE,
130 G_SQLERRM_TOKEN,
131 'Invalid operation'
132 );
133
134 when others then
135 x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
136 x_msg_data := l_error_msg || ' ' || SQLERRM;
137 x_msg_count:= 1;
138 OKC_API.set_message
139 (
140 G_APP_NAME,
141 G_UNEXPECTED_ERROR,
142 G_SQLCODE_TOKEN,
143 SQLCODE,
144 G_SQLERRM_TOKEN,
145 SQLERRM
146 );
147
148 End Debug_Log;
149
150
151
152 END OKS_RENEW_PVT;