DBA Data[Home] [Help]

PACKAGE BODY: APPS.CS_MESSAGES_PKG

Source


1 PACKAGE BODY CS_MESSAGES_PKG AS
2 /* $Header: csmesgb.pls 120.3 2006/01/19 22:15:01 varnaray noship $   */
3 -- ------------------------------------------------------------------------
4 -- Send_Message
5 --   Call the Workflow Notification API to send the message and insert a
6 --   new record into CS_MESSAGES.
7 -- ------------------------------------------------------------------------
8 
9   PROCEDURE Send_Message (
10 		p_source_object_type	IN	VARCHAR2,
11 		p_source_obj_type_code  IN	VARCHAR2,
12 		p_source_object_int_id	IN	NUMBER,
13 		p_source_object_ext_id	IN	VARCHAR2,
14 		p_sender		IN	VARCHAR2,
15 		p_sender_role		IN	VARCHAR2    DEFAULT NULL,
16 		p_receiver		IN	VARCHAR2,
17 		p_receiver_role		IN	VARCHAR2,
18 		p_priority		IN	VARCHAR2,
19 		p_expand_roles		IN	VARCHAR2,
20 		p_action_type		IN	VARCHAR2    DEFAULT NULL,
21 		p_action_code		IN	VARCHAR2    DEFAULT NULL,
22 		p_confirmation		IN	VARCHAR2,
23 		p_message		IN	VARCHAR2    DEFAULT NULL,
24 		p_function_name		IN	VARCHAR2    DEFAULT NULL,
25 		p_function_params	IN	VARCHAR2    DEFAULT NULL ) IS
26 
27     l_message_id	NUMBER;
28     l_notification_id	NUMBER;
29     l_ntf_group_id	NUMBER;
30     l_source_obj_ext_id	VARCHAR2(200);
31     l_user_id		NUMBER;
32     l_login_id		NUMBER;
33     l_priority		VARCHAR2(30);
34 
35     l_priority_number	NUMBER;
36 
37     CURSOR l_msgid_csr IS
38       SELECT cs_messages_s.NEXTVAL
39         FROM dual;
40 
41     CURSOR l_ntf_csr IS
42       SELECT ntf.notification_id
43         FROM wf_notifications ntf
44        WHERE ntf.group_id = l_ntf_group_id;
45 
46     CURSOR l_priority_csr IS
47       SELECT meaning
48         FROM cs_lookups
49        WHERE lookup_type = 'MESSAGE_PRIORITY'
50          AND lookup_code = p_priority;
51 
52     -- --------------------------------------------------------------------
53     -- SetAttributes
54     --   Subprocedure used to set the message attibutes that are common to
55     --   all the different types of messages
56     -- --------------------------------------------------------------------
57 
58     PROCEDURE SetAttributes(	p_nid		IN	NUMBER,
59                                 p_priority      IN      VARCHAR2,
60 				p_ext_id	IN	VARCHAR2  DEFAULT NULL ) IS
61     BEGIN
62       WF_NOTIFICATION.SetAttrText(
63 			nid		=>	p_nid,
64 			aname		=>	'OBJECT_ID',
65 			avalue		=>	p_ext_id );
66 
67       WF_NOTIFICATION.SetAttrText(
68 			nid		=>	p_nid,
69 			aname		=>	'OBJECT_TYPE',
70 			avalue		=>	p_source_object_type );
71 
72       WF_NOTIFICATION.SetAttrText(
73 			nid		=>	p_nid,
74 			aname		=>	'SENDER',
75 			avalue		=>	p_sender );
76 
77       WF_NOTIFICATION.SetAttrText(
78 			nid		=>	p_nid,
79 			aname		=>	'MESSAGE_TEXT',
80 			avalue		=>	p_message );
81 
82       WF_NOTIFICATION.SetAttrText(
83 			nid		=>	p_nid,
84 			aname		=>	'PRIORITY',
85 			avalue		=>	p_priority );
86 
87       WF_NOTIFICATION.SetAttrText(
88 			nid		=>	p_nid,
89 			aname		=>	'OBJECT_FORM',
90 			avalue		=>	p_function_name||':'||p_function_params );
91 
92       WF_NOTIFICATION.SetAttrText(
93                         nid             =>      p_nid,
94                         aname           =>      '#FROM_ROLE',
95                         avalue          =>      p_sender_role);
96 
97 
98       -- Fix for bug 2122488--
99       Wf_Notification.Denormalize_Notification(p_nid);
100 
101     END SetAttributes;
102 
103 
104   BEGIN
105     -- --------------------------------------------------------------------
106     -- Begin of procedure Send_Message
107     -- --------------------------------------------------------------------
108 
109     -- Get the message ID from the sequence
110     OPEN l_msgid_csr;
111     FETCH l_msgid_csr INTO l_message_id;
112     CLOSE l_msgid_csr;
113 
114     --
115     -- Attach a '#' character to the object ID if it's not NULL
116     --
117     IF (p_source_object_ext_id IS NOT NULL) THEN
118       l_source_obj_ext_id := '#'||p_source_object_ext_id;
119     ELSE
120       l_source_obj_ext_id := NULL;
121     END IF;
122 
123     -- Get the priority value
124     OPEN l_priority_csr;
125     FETCH l_priority_csr INTO l_priority;
126     CLOSE l_priority_csr;
127 
128     -- Set priority Number for message.
129     -- High (1-49), Medium (50), Low (51-99).
130     -- We set arbitrarily : High=25, Medium=50, and Low=75
131     IF (p_priority = 'HIGH') THEN
132       l_priority_number := 25;
133     ELSIF (p_priority = 'MED') THEN
134       l_priority_number := 50;
135     ELSE
136       l_priority_number := 75;
137     END IF;
138 
139 
140     --
141     -- First check to see if an action is being requested
142     --
143     IF (p_action_type IS NULL) THEN
144       --
145       -- No Action requested.  We'll be sending an FYI message
146       -- Now check and see if expand roles is requested
147       --
148       IF (p_expand_roles = 'N') THEN
149 
150         -- Do not expand roles, just call the Send API
151         l_ntf_group_id := WF_NOTIFICATION.Send(
152 			role		=>	p_receiver_role,
153 			msg_type	=>	'CS_MSGS',
154 			msg_name	=>	'FYI_MESSAGE',
155 			due_date	=>	NULL,
156 			callback	=>	'CS_MESSAGES_PKG.NOTIFICATION_CALLBACK',
157 			context		=>	to_char(l_message_id),
158 			send_comment	=>	NULL,
159 			priority        =>      l_priority_number );
160 
161       ELSE
162 
163         -- Expand Roles requested, call the SendGroup API instead
164         l_ntf_group_id := WF_NOTIFICATION.SendGroup(
165 			role		=>	p_receiver_role,
166 			msg_type	=>	'CS_MSGS',
167 			msg_name	=>	'EXPANDED_FYI_MSG',
168 			due_date	=>	NULL,
169 			callback	=>	'CS_MESSAGES_PKG.NOTIFICATION_CALLBACK',
170 			context		=>	to_char(l_message_id),
171 			send_comment	=>	NULL,
172 			priority        =>      l_priority_number );
173 
174       END IF;
175 
176       --
177       -- For each notification in the group, set up the message attributes.
178       -- Note that if the Send API was called, the notification ID will be
179       -- the same as the group ID.
180       -- We are using a cursor loop until Workflow team provides an API for
181       -- updating the notification attributes for the whole group
182       --
183       FOR l_ntf_rec IN l_ntf_csr LOOP
184 
185         l_notification_id := l_ntf_rec.notification_id;
186 
187         -- Call the subprocedure to set the notification attributes
188 	SetAttributes(l_notification_id, l_priority, l_source_obj_ext_id);
189 
190       END LOOP;
191 
192       l_notification_id := l_ntf_group_id;
193 
194     ELSE
195 
196       -- Action requested, send the ACTION_REQUEST_MSG message
197       l_notification_id := WF_NOTIFICATION.Send(
198 			role		=>	p_receiver_role,
199 			msg_type	=>	'CS_MSGS',
200 			msg_name	=>	'ACTION_REQUEST_MSG',
201 			due_date	=>	NULL,
202 			callback	=>	'CS_MESSAGES_PKG.NOTIFICATION_CALLBACK',
203 			context		=>	to_char(l_message_id),
204 			send_comment	=>	NULL,
205 			priority        =>      l_priority_number );
206 
207       -- Set the notification attributes
208       SetAttributes(l_notification_id, l_priority, l_source_obj_ext_id);
209 
210       WF_NOTIFICATION.SetAttrText(
211 			nid		=>	l_notification_id,
212 			aname		=>	'ACTION',
213 			avalue		=>	p_action_type );
214 
215     END IF;
216 
217     -- Get the user information for WHO columns
218     l_user_id	:= to_number(FND_PROFILE.VALUE('USER_ID'));
219     l_login_id	:= to_number(FND_PROFILE.VALUE('LOGIN_ID'));
220 
221     IF (l_user_id IS NULL) THEN
222       l_user_id := -1;
223     END IF;
224 
225     -- Insert a new record into the CS_MESSAGES table
226     INSERT INTO cs_messages (
227 		message_id,
228 		notification_id,
229 		date_sent,
230 		last_update_date,
231 		last_updated_by,
232 		creation_date,
233 		created_by,
234 		last_update_login,
235 		source_object_type_code,
236 		source_object_int_id,
237 		source_object_ext_id,
238 		sender,
239 		sender_role,
240 		receiver,
241 		priority,
242 		expand_roles,
243 		action_code,
244 		confirmation,
245 		message,
246 		responder,
247 		response_date,
248 		response,
249 		responder_comment )
250 	VALUES (
251 		l_message_id,
252 		l_notification_id,
253 		sysdate,
254 		sysdate,
255 		l_user_id,
256 		sysdate,
257 		l_user_id,
258 		l_login_id,
259 		p_source_obj_type_code,
260 		p_source_object_int_id,
261 		p_source_object_ext_id,
262 		p_sender,
263 		p_sender_role,
264 		p_receiver,
265 		p_priority,
266 		p_expand_roles,
267 		p_action_code,
268 		p_confirmation,
269  		p_message,
270 		NULL,
271 		NULL,
272 		NULL,
273 		NULL );
274 
275   END Send_Message;
276 
277 
278 
279 -- ------------------------------------------------------------------------
280 -- Notification_Callback
281 --   Callback function for the Messages module.  This procedure will be
282 --   called by the Workflow Notification system when the recipient has
283 --   responded.
284 --   Note that the context parameter will contain the char representation
285 --   of the MESSAGE_ID.  Parameter text_value and number_value will contain
286 --   the values of RESPONSE and NOTIFICATION_ID respectively.  See the
287 --   WF_NOTIFICATION.Respond API for more detail.
288 -- ------------------------------------------------------------------------
289 
290   PROCEDURE Notification_Callback (
291 		command 	IN	VARCHAR2,
292 		context		IN	VARCHAR2,
293 		attr_name	IN	VARCHAR2    DEFAULT NULL,
294 		attr_type	IN 	VARCHAR2    DEFAULT NULL,
295 		text_value	IN OUT	NOCOPY VARCHAR2,
296 		number_value	IN OUT	NOCOPY NUMBER,
297 		date_value	IN OUT	NOCOPY DATE ) IS
298 
299     l_message_id  NUMBER;
300     l_user_id	  NUMBER;
301     l_login_id	  NUMBER;
302     l_comment	  VARCHAR2(2000);
303     l_confirmation_nid	NUMBER;
304     l_source_type VARCHAR2(100);
305     l_source_id   VARCHAR2(100);
306     l_message     VARCHAR2(2000);
307     l_response    VARCHAR2(30);
308 
309     CURSOR l_ntf_csr IS
310       SELECT ntf.end_date,
311              wf.display_name responder,
312              msg.confirmation,
313              msg.notification_id,
314              msg.sender_role sender
315         FROM wf_notifications ntf, wf_roles wf, cs_messages msg
316        WHERE msg.message_id = l_message_id
317          AND msg.notification_id = ntf.notification_id
318          AND ntf.responder = wf.name(+)
319          FOR UPDATE OF msg.message_id;
320 
321     CURSOR l_response_csr IS
322       SELECT meaning
323         FROM cs_lookups
324        WHERE lookup_type = 'MESSAGE_RESPONSE'
325          AND lookup_code = text_value;
326 
327     l_ntf_rec  l_ntf_csr%ROWTYPE;
328 
329 begin
330   --
331   -- Get the message_id from the context
332   --
333   l_message_id := to_number(context);
334 
335   --
336   -- We should never encounter a GET command because we never
340   IF (upper(command) = 'GET') THEN
337   -- have attributes that are based on item attributes.  It we
338   -- somehow get here, just return NULL for everything
339   --
341     IF (attr_type = 'NUMBER') THEN
342       number_value := to_number(NULL);
343     ELSIF (attr_type = 'DATE') THEN
344       date_value := to_date(NULL);
345     ELSE
346       text_value := to_char(NULL);
347     END IF;
348 
349   ELSIF (upper(command) = 'SET') THEN
350     --
351     -- Do all the work in the COMPLETE command
352     --
353     null;
354 
355   ELSIF (upper(command) = wf_engine.eng_completed) THEN
356 
357     -- Get the user information for WHO columns
358     l_user_id	:= to_number(FND_PROFILE.VALUE('USER_ID'));
359     l_login_id	:= to_number(FND_PROFILE.VALUE('LOGIN_ID'));
360 
361     IF (l_user_id IS NULL) THEN
362       l_user_id := -1;
363     END IF;
364 
365     OPEN l_ntf_csr;
366     FETCH l_ntf_csr INTO l_ntf_rec;
367 
368     -- Get the comment of the responder
369     l_comment := WF_NOTIFICATION.GetAttrText(l_ntf_rec.notification_id, 'COMMENT');
370 
371     -- Update the row in the CS_MESSAGES table
372     UPDATE cs_messages
373        SET last_update_date	= sysdate,
374            last_updated_by	= l_user_id,
375            last_update_login    = l_login_id,
376            responder		= l_ntf_rec.responder,
377            response_date	= l_ntf_rec.end_date,
378            responder_comment	= l_comment,
379            response		= text_value
380      WHERE CURRENT OF l_ntf_csr;
381 
382     -- If confirmation was requested, we need to send it now
383     IF (l_ntf_rec.confirmation = 'Y') THEN
384 
385       -- Get the value for response
386       OPEN l_response_csr;
387       FETCH l_response_csr INTO l_response;
388       CLOSE l_response_csr;
389 
390       l_source_type := WF_NOTIFICATION.GetAttrText(l_ntf_rec.notification_id, 'OBJECT_TYPE');
391       l_source_id   := WF_NOTIFICATION.GetAttrText(l_ntf_rec.notification_id, 'OBJECT_ID');
392       l_message     := WF_NOTIFICATION.GetATTRTEXT(l_ntf_rec.notification_id, 'MESSAGE_TEXT');
393 
394       l_confirmation_nid := WF_NOTIFICATION.Send(
395 			role		=>	l_ntf_rec.sender,
396 			msg_type	=>	'CS_MSGS',
397 			msg_name	=>	'CONFIRMATION_MESSAGE',
398 			due_date	=>	NULL,
399 			callback	=>	'CS_MESSAGES_PKG.NOTIFICATION_CALLBACK',
400 			context		=>	to_char(l_message_id),
401 			send_comment	=>	NULL );
402 
403       -- Set up the message attributes
404       WF_NOTIFICATION.SetAttrText(
405 			nid		=>	l_confirmation_nid,
406 			aname		=>	'OBJECT_TYPE',
407 			avalue		=>	l_source_type );
408 
409       WF_NOTIFICATION.SetAttrText(
410 			nid		=>	l_confirmation_nid,
411 			aname		=>	'OBJECT_ID',
412 			avalue		=>	l_source_id );
413 
414       WF_NOTIFICATION.SetAttrText(
415 			nid		=>	l_confirmation_nid,
416 			aname		=>	'RESPONDER',
417 			avalue		=>	l_ntf_rec.responder );
418 
419       WF_NOTIFICATION.SetAttrText(
420 			nid		=>	l_confirmation_nid,
421 			aname		=>	'RESPONSE',
422 			avalue		=>	l_response );
423 
424       WF_NOTIFICATION.SetAttrText(
425 			nid		=>	l_confirmation_nid,
426 			aname		=>	'COMMENT',
427 			avalue		=>	l_comment );
428 
429       WF_NOTIFICATION.SetAttrText(
430 			nid		=>	l_confirmation_nid,
431 			aname		=>	'MESSAGE',
432 			avalue		=>	l_message );
433     -- Fix for bug 2122488
434     Wf_Notification.Denormalize_Notification(l_confirmation_nid);
435 
436     END IF;
437 
438     CLOSE l_ntf_csr;
439 
440   END IF;
441 
442 end Notification_Callback;
443 
444 --------------------------------------------------------------------------------
445 --  Procedure Name            :   DELETE_MESSAGE
446 --
447 --  Parameters (other than standard ones)
448 --  IN
449 --      p_object_type         :   Type of object for which this procedure is
450 --                                being called. (Here it will be 'SR')
451 --      p_processing_set_id   :   Id that helps the API in identifying the
452 --                                set of SRs for which the child objects have
453 --                                to be deleted.
454 --
455 --  Description
456 --      This procedure physically deletes all the messages that are linked
457 --      to SRs that are to be purged.
458 --
459 --  HISTORY
460 --
461 ----------------+------------+--------------------------------------------------
462 --  DATE        | UPDATED BY | Change Description
463 ----------------+------------+--------------------------------------------------
464 --  2-Aug-2005  | varnaray   | Created
465 --              |            |
466 ----------------+------------+--------------------------------------------------
467 /*#
468  * This procedure physically deletes all the messages that are linked to SRs
469  * that are to be purged.
470  * @param p_object_type Type of object for which this procedure is being called.
471  * (Here it will be 'SR')
472  * @param p_processing_set_id Id that helps the API in identifying the set of
473  * SRs for which the child
474  * objects have to be deleted.
475  * @rep:scope internal
476  * @rep:product CS
477  * @rep:displayname Delete Messages
478  */
479 PROCEDURE Delete_Message
480 (
481   p_api_version_number IN  NUMBER := 1.0
482 , p_init_msg_list      IN  VARCHAR2 := FND_API.G_FALSE
483 , p_commit             IN  VARCHAR2 := FND_API.G_FALSE
484 , p_object_type        IN  VARCHAR2
485 , p_processing_set_id  IN  NUMBER
486 , x_return_status      OUT NOCOPY  VARCHAR2
487 , x_msg_count          OUT NOCOPY  NUMBER
488 , x_msg_data           OUT NOCOPY  VARCHAR2
489 )
490 IS
494 L_API_NAME      CONSTANT VARCHAR2(30)  := 'DELETE_MESSAGE';
491 --------------------------------------------------------------------------------
492 
493 L_API_VERSION   CONSTANT NUMBER        := 1.0;
495 L_API_NAME_FULL CONSTANT VARCHAR2(61)  := 'CS_MESSAGES' || '.' || L_API_NAME;
496 L_LOG_MODULE    CONSTANT VARCHAR2(255) := 'cs.plsql.' || L_API_NAME_FULL || '.';
497 
498 l_row_count     NUMBER := 0;
499 
500 x_msg_index_out NUMBER;
501 
502 BEGIN
503   x_return_status := FND_API.G_RET_STS_SUCCESS;
504 
505   IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
506   THEN
507     FND_LOG.String
508     (
509       FND_LOG.level_procedure
510     , L_LOG_MODULE || 'start'
511     , 'Inside ' || L_API_NAME_FULL || ', called with parameters below:'
512     );
513     FND_LOG.String
514     (
515       FND_LOG.level_procedure
516     , L_LOG_MODULE || 'param 1'
517     , 'p_api_version_number:' || p_api_version_number
518     );
519     FND_LOG.String
520     (
521       FND_LOG.level_procedure
522     , L_LOG_MODULE || 'param 2'
523     , 'p_init_msg_list:' || p_init_msg_list
524     );
525     FND_LOG.String
526     (
527       FND_LOG.level_procedure
528     , L_LOG_MODULE || 'param 3'
529     , 'p_commit:' || p_commit
530     );
531     FND_LOG.String
532     (
533       FND_LOG.level_procedure
534     , L_LOG_MODULE || 'param 4'
535     , 'p_object_type:' || p_object_type
536     );
537     FND_LOG.String
538     (
539       FND_LOG.level_procedure
540     , L_LOG_MODULE || 'param 5'
541     , 'p_processing_set_id:' || p_processing_set_id
542     );
543   END IF ;
544 
545   IF NOT FND_API.Compatible_API_Call
546     (
547       L_API_VERSION
548     , p_api_version_number
549     , L_API_NAME
550     , 'CS_MESSAGES'
551     )
552   THEN
553     FND_MSG_PUB.Count_And_Get
554     (
555       p_count => x_msg_count
556     , p_data  => x_msg_data
557     );
558     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
559   END IF ;
560 
561   IF FND_API.to_Boolean(p_init_msg_list)
562   THEN
563     FND_MSG_PUB.initialize;
564   END IF ;
565 
566   ------------------------------------------------------------------------------
567   -- Parameter Validations:
568   ------------------------------------------------------------------------------
569 
570   IF NVL(p_object_type, 'X') <> 'SR'
571   THEN
572     IF FND_LOG.level_unexpected >= FND_LOG.g_current_runtime_level
573     THEN
574       FND_LOG.String
575       (
576         FND_LOG.level_unexpected
577       , L_LOG_MODULE || 'object_type_invalid'
578       , 'p_object_type has to be SR.'
579       );
580     END IF ;
581 
582     FND_MESSAGE.Set_Name('CS', 'CS_SR_PARAM_VALUE_ERROR');
583     FND_MESSAGE.Set_Token('API_NAME', L_API_NAME_FULL);
584     FND_MESSAGE.Set_Token('PARAM', 'p_object_type');
585     FND_MESSAGE.Set_Token('CURRVAL', p_object_type);
586     FND_MSG_PUB.ADD;
587 
588     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
589   END IF;
590 
591   ---
592 
593   IF p_processing_set_id IS NULL
594   THEN
595     IF FND_LOG.level_unexpected >= FND_LOG.g_current_runtime_level
596     THEN
597       FND_LOG.String
598       (
599         FND_LOG.level_unexpected
600       , L_LOG_MODULE || 'proc_set_id_invalid'
601       , 'p_processing_set_id should not be NULL.'
602       );
603     END IF ;
604 
605     FND_MESSAGE.Set_Name('CS', 'CS_SR_PARAM_VALUE_ERROR');
606     FND_MESSAGE.Set_Token('API_NAME', L_API_NAME_FULL);
607     FND_MESSAGE.Set_Token('PARAM', 'p_processing_set_id');
608     FND_MESSAGE.Set_Token('CURRVAL', NVL(to_char(p_processing_set_id),'NULL'));
609     FND_MSG_PUB.ADD;
610 
611     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
612   END IF;
613 
614   ------------------------------------------------------------------------------
615   -- Actual Logic starts below:
616   ------------------------------------------------------------------------------
617 
618   IF FND_LOG.level_statement >= FND_LOG.g_current_runtime_level
619   THEN
620     FND_LOG.String
621     (
622       FND_LOG.level_statement
623     , L_LOG_MODULE || 'del_sr_message_start'
624     , 'deleting data in table cs_messages'
625     );
626   END IF ;
627 
628   -- The following delete statement deletes the rows in the
629   -- cs_messages table which correspond to the incident_ids in
630   -- the global temp table jtf_object_purge_param_tmp which have
631   -- purge_status NULL indicating that the SR is available for
632   -- purge.
633 
634   DELETE /*+ index(m) */
635     cs_messages m
636   WHERE
637     source_object_type_code = 'INC'
638   AND
639     source_object_int_id IN
640     (
641       SELECT /*+ no_unnest no_semijoin cardinality(10) */
642         object_id
643       FROM
644         jtf_object_purge_param_tmp
645       WHERE
646         object_type = 'SR'
647       AND p_processing_set_id = processing_set_id
648       AND NVL(purge_status, 'S') = 'S'
649     );
650   l_row_count := SQL%ROWCOUNT;
651 
652   IF FND_LOG.level_statement >= FND_LOG.g_current_runtime_level
653   THEN
654     FND_LOG.String
655     (
656       FND_LOG.level_statement
657     , L_LOG_MODULE || 'del_sr_message_end'
658     , 'after deleting data in table cs_messages ' || l_row_count
659     );
660   END IF ;
661 
662   IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
663   THEN
664     FND_LOG.String
665     (
666       FND_LOG.level_procedure
667     , L_LOG_MODULE || 'end'
668     , 'Completed work in ' || L_API_NAME_FULL || ' successfully'
669     );
670   END IF ;
671 EXCEPTION
672   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
673     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
674 
675     IF FND_LOG.level_unexpected >= FND_LOG.g_current_runtime_level
676     THEN
677       FND_LOG.String
678       (
679         FND_LOG.level_unexpected
680       , L_LOG_MODULE || 'unexpected_error'
681       , 'Inside WHEN FND_API.G_EXC_UNEXPECTED_ERROR of ' || L_API_NAME_FULL
682       );
683 
684       x_msg_count := FND_MSG_PUB.Count_Msg;
685 
686       IF x_msg_count > 0
687       THEN
688         FOR
689           i IN 1..x_msg_count
690         LOOP
691           FND_MSG_PUB.Get
692           (
693             p_msg_index     => i
694           , p_encoded       => 'F'
695           , p_data          => x_msg_data
696           , p_msg_index_out => x_msg_index_out
697           );
698           FND_LOG.String
699           (
700             FND_LOG.level_unexpected
701           , L_LOG_MODULE || 'unexpected_error'
702           , 'Error encountered is : ' || x_msg_data
703             || ' [Index:' || x_msg_index_out || ']'
704           );
705         END LOOP;
706       END IF ;
707     END IF ;
708 
709   WHEN OTHERS THEN
710     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
711     FND_MESSAGE.Set_Name('CS', 'CS_SR_MSG_DEL_FAIL');
712     FND_MESSAGE.Set_Token('API_NAME', L_API_NAME_FULL);
713     FND_MESSAGE.Set_Token('ERROR', SQLERRM);
714     FND_MSG_PUB.ADD;
715 
716     IF FND_LOG.level_unexpected >= FND_LOG.g_current_runtime_level
717     THEN
718       FND_LOG.String
719       (
720         FND_LOG.level_unexpected
721       , L_LOG_MODULE || 'when_others'
722       , 'Inside WHEN OTHERS of ' || L_API_NAME_FULL
723         || '. Oracle Error was:'
724       );
725       FND_LOG.String
726       (
727         FND_LOG.level_unexpected
728       , L_LOG_MODULE || 'when_others'
729       , SQLERRM
730       );
731     END IF ;
732 END Delete_Message;
733 --------------------------------------------------------------------------------
734 
735 END CS_MESSAGES_PKG;