1 PACKAGE BODY FA_SRVR_MSG as
2 /* $Header: FASMESGB.pls 120.8 2009/03/27 08:24:40 bridgway ship $ */
3
4 g_log_statement_level NUMBER := FND_LOG.LEVEL_STATEMENT;
5 g_log_procedure_level NUMBER := FND_LOG.LEVEL_PROCEDURE;
6 g_log_event_level NUMBER := FND_LOG.LEVEL_EVENT ;
7 g_log_exception_level NUMBER := FND_LOG.LEVEL_EXCEPTION;
8 g_log_error_level NUMBER := FND_LOG.LEVEL_ERROR;
9 g_log_unexpected_level NUMBER := FND_LOG.LEVEL_UNEXPECTED;
10 g_log_runtime_level NUMBER := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
11
12 g_print_debug boolean := fa_cache_pkg.fa_print_debug;
13 g_release number := fa_cache_pkg.fazarel_release;
14
15 --
16 -- Procedure Init_Server_Message
17 --
18 PROCEDURE Init_Server_Message IS
19
20 l_release number;
21
22 BEGIN
23 fnd_msg_pub.initialize;
24
25 END init_server_message;
26
27
28 --
29 -- Procedure Reset_Server_Message
30 --
31 PROCEDURE Reset_Server_Message IS
32 BEGIN
33 fnd_msg_pub.initialize;
34
35 END Reset_Server_Message;
36
37
38 --
39 -- Procedure Add_SQL_Error
40 --
41 PROCEDURE Add_SQL_Error
42 ( calling_fn in varchar2,
43 p_log_level_rec in fa_api_types.log_level_rec_type default null) IS
44
45 BEGIN
46
47 -- reset the global FA_ERROR_LEVEL to 1
48 FA_SRVR_MSG.FA_ERROR_LEVEL := 1;
49
50 -- insert sql error for unexpected database error to stack
51 fnd_message.set_name('OFA','FA_SHARED_ORACLE_ERR');
52 fnd_message.set_token('ORACLE_ERR',SQLERRM);
53
54 if (g_release > 11 and
55 FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) then
56 FND_LOG.MESSAGE (FND_LOG.LEVEL_UNEXPECTED,'FA.PLSQL.'||calling_fn,FALSE);
57 end if;
58
59 fnd_msg_pub.add;
60
61 -- insert calling function name to the stack
62 add_message(calling_fn => calling_fn,
63 p_log_level_rec => p_log_level_rec);
64
65
66 END Add_SQL_Error;
67
68 --
69 -- Procedure Add_Message
70 --
71 PROCEDURE add_message
72 ( calling_fn in varchar2,
73 name in varchar2 := null,
74 token1 in varchar2 := null,
75 value1 in varchar2 := null,
76 token2 in varchar2 := null,
77 value2 in varchar2 := null,
78 token3 in varchar2 := null,
79 value3 in varchar2 := null,
80 token4 in varchar2 := null,
81 value4 in varchar2 := null,
82 token5 in varchar2 := null,
83 value5 in varchar2 := null,
84 translate in boolean := FALSE,
85 application in varchar2 := 'OFA',
86 p_log_level_rec in fa_api_types.log_level_rec_type default null,
87 p_message_level in number := FND_LOG.LEVEL_ERROR) IS
88
89 BEGIN
90
91 if name is not null then
92 fnd_message.set_name(application, name); --enhanced for cua
93 if (token1 is not null) then
94 fnd_message.set_token(token1, value1, translate);
95 end if;
96 if (token2 is not null) then
97 fnd_message.set_token(token2, value2, translate);
98 end if;
99 if (token3 is not null) then
100 fnd_message.set_token(token3, value3, translate);
101 end if;
102 if (token4 is not null) then
103 fnd_message.set_token(token4, value4, translate);
104 end if;
105 if (token5 is not null) then
106 fnd_message.set_token(token5, value5, translate);
107 end if;
108
109 if (g_release > 11 and
110 p_message_level >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) then
111 FND_LOG.MESSAGE (p_message_level,'FA.PLSQL.'||calling_fn,FALSE);
112 end if;
113
114 fnd_msg_pub.add;
115
116 elsif (calling_fn is not null ) then
117
118 if (g_release > 11 and
119 g_log_procedure_level >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) then
120
121 FND_LOG.STRING (g_log_procedure_level , 'FA.PLSQL.'||calling_fn,
122 'End of procedure');
123 end if;
124
125 -- insert calling function name to the stack if message level
126 -- equals to 1 or debug flag is set in profile
127 -- BMR: also check if the calling fn is null as we don't
128 -- want excessive/bogus errors when debug is enabled
129 -- when displaying a "success" message (bug2247611)
130
131 if (FA_SRVR_MSG.FA_ERROR_LEVEL = 1 or
132 g_log_procedure_level >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) then
133 fnd_message.set_name('OFA', 'FA_SHARED_ERROR_CALL');
134 fnd_message.set_token('CALLING_FN', calling_fn, translate);
135 fnd_msg_pub.add;
136 end if;
137
138 end if;
139
140 END add_message;
141
142 --
143 -- Prodedure Get_Message
144 --
145 PROCEDURE get_message
146 ( mesg_count in out nocopy number,
147 mesg1 in out nocopy varchar2,
148 mesg2 in out nocopy varchar2,
149 mesg3 in out nocopy varchar2,
150 mesg4 in out nocopy varchar2,
151 mesg5 in out nocopy varchar2,
152 mesg6 in out nocopy varchar2,
153 mesg7 in out nocopy varchar2
154 , p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) IS
155
156 BEGIN
157
158 mesg_count := fnd_msg_pub.count_msg;
159 mesg1 := substr(fnd_msg_pub.get(fnd_msg_pub.G_FIRST, fnd_api.G_FALSE), 1, 512);
160 mesg2 := substr(fnd_msg_pub.get(fnd_msg_pub.G_NEXT, fnd_api.G_FALSE), 1, 512);
161 mesg3 := substr(fnd_msg_pub.get(fnd_msg_pub.G_NEXT, fnd_api.G_FALSE), 1, 512);
162 mesg4 := substr(fnd_msg_pub.get(fnd_msg_pub.G_NEXT, fnd_api.G_FALSE), 1, 512);
163 mesg5 := substr(fnd_msg_pub.get(fnd_msg_pub.G_NEXT, fnd_api.G_FALSE), 1, 512);
164 mesg6 := substr(fnd_msg_pub.get(fnd_msg_pub.G_NEXT, fnd_api.G_FALSE), 1, 512);
165 mesg7 := substr(fnd_msg_pub.get(fnd_msg_pub.G_NEXT, fnd_api.G_FALSE), 1, 512);
166
167 END Get_Message;
168
169 --
170 -- Procedure Set_Message_Level
171 --
172 PROCEDURE Set_Message_Level (
173 message_level in number
174 , p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) IS
175
176 BEGIN
177
178 if (message_level is null) then
179 FA_ERROR_LEVEL := 1;
180 else
181 FA_ERROR_LEVEL := message_level;
182 end if;
183
184 END Set_Message_Level;
185
186
187 --
188 -- Procedure Dump_API_Messages
189 --
190 PROCEDURE Dump_API_Messages IS
191
192 mesg_count number;
193 temp_str varchar2(1000) := NULL;
194
195 BEGIN
196 mesg_count := fnd_msg_pub.count_msg;
197
198 if (mesg_count > 0) then
199 temp_str := fnd_msg_pub.get(fnd_msg_pub.G_FIRST, fnd_api.G_FALSE);
200
201 for I in 1..(mesg_count -1) loop
202
203 temp_str := fnd_msg_pub.get(fnd_msg_pub.G_NEXT, fnd_api.G_FALSE);
204
205 end loop;
206 else
207 null;
208 end if;
209
210 EXCEPTION
211 WHEN OTHERS THEN
212 null;
213
214 END Dump_API_Messages;
215
216 --
217 -- Procedure Write_Msg_Log
218 --
219 PROCEDURE Write_Msg_Log
220 ( msg_count in number,
221 msg_data in varchar2
222 , p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) IS
223
224 -- For test purpose, you may set h_coded to TRUE. Then messages will be
225 -- printed out in encoded format instead of translated format. This is useful
226 -- if you want to test the message, but if you have not registered your
227 -- message yet in the message dictionary.
228 -- Normally h_encoded should be set to FALSE.
229
230 h_encoded varchar2(1) := fnd_api.G_FALSE;
231 --h_encoded varchar(1):= fnd_api.G_TRUE;
232
233 BEGIN
234 if (msg_count <= 0) then
235 NULL;
236 else
237 fa_rx_conc_mesg_pkg.log(fnd_msg_pub.get(fnd_msg_pub.G_FIRST, h_encoded));
238 for i in 1..(msg_count-1) loop
239 fa_rx_conc_mesg_pkg.log(fnd_msg_pub.get(fnd_msg_pub.G_NEXT, h_encoded));
240 end loop;
241 end if;
242
243 END Write_Msg_Log;
244
245 END FA_SRVR_MSG;