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