DBA Data[Home] [Help]

PACKAGE BODY: APPS.ASO_WFNOTIFICATION_PVT

Source


1 PACKAGE BODY ASO_WFNOTIFICATION_PVT AS
2 /* $Header: asovwntb.pls 120.1 2005/06/29 12:46:20 appldev ship $ */
3 
4 /* For notifying a user/role */
5 
6 PROCEDURE Notify_User (
7                 p_api_version		IN 	NUMBER,
8                 p_commit		IN	VARCHAR2 := FND_API.g_false,
9                 p_init_msg_list		IN	VARCHAR2 := FND_API.g_false,
10                 p_user_name 		IN   	VARCHAR2,
11                 p_subject 		IN   	VARCHAR2,
12       		p_body 			IN   	VARCHAR2,
13                 x_return_status       OUT NOCOPY /* file.sql.39 change */  	 VARCHAR2,
14                 x_msg_count	 OUT NOCOPY /* file.sql.39 change */  NUMBER,
15                 x_msg_data	 OUT NOCOPY /* file.sql.39 change */  VARCHAR2
16 			)
17 IS
18 
19 wf_itemkey_seq INTEGER;
20 wf_itemkey VARCHAR2(30);
21 
22 BEGIN
23 
24   x_return_status := FND_API.g_ret_sts_success;
25 
26   IF ASO_DEBUG_PUB.G_Debug_Flag = 'Y' THEN
27     aso_debug_pub.add('user_name: ' || p_user_name , 1, 'N' );
28     aso_debug_pub.add('subject: ' || p_subject , 1, 'N' );
29     aso_debug_pub.add('object: ' || p_body , 1, 'N' );
30   END IF;
31 
32   select ASO_WFNOTIFICATION_S1.NEXTVAL into wf_itemkey_seq from dual;
33 		  wf_itemkey := 'ASO_USER_' || wf_itemkey_seq;
34 
35    wf_engine.CreateProcess   ( itemtype => 'ASO_USER',
36 			       itemkey  =>  wf_itemkey,
37 			       process  => 'ASO_NOTIFY_USER' );
38 
39    wf_engine.SetItemUserKey  ( itemtype => 'ASO_USER',
40 			       itemkey  =>  wf_itemkey,
41 			       userkey  => 'ASO User Notification ' || wf_itemkey_seq );
42 
43    wf_engine.SetItemAttrText ( itemtype => 'ASO_USER',
44 			       itemkey  =>  wf_itemkey,
45 			       aname    => 'ROLE_TO_NOTIFY',
46 			       avalue   =>  p_user_name );
47 
48    wf_engine.SetItemAttrText ( itemtype => 'ASO_USER',
49 			       itemkey  =>  wf_itemkey,
50 			       aname    => 'NOTIFICATION_SUBJECT',
51 			       avalue   =>  p_subject );
52 
53    wf_engine.SetItemAttrText ( itemtype => 'ASO_USER',
54 			       itemkey  =>  wf_itemkey,
55 			       aname    => 'NOTIFICATION_BODY',
56 			       avalue   =>  p_body );
57 
58    wf_engine.SetItemOwner    ( itemtype => 'ASO_USER',
59      			       itemkey  =>  wf_itemkey,
60 			       owner    =>  p_user_name );
61 
62    wf_engine.StartProcess    ( itemtype => 'ASO_USER',
63 			       itemkey  =>  wf_itemkey );
64 
65 
66   EXCEPTION
67       When others then
68         x_return_status := FND_API.g_ret_sts_error;
69         x_msg_count := 0;
70 	wf_core.context('ASO_WFNOTIFICATION_PVT', 'Notify_User', p_user_name, p_subject, p_body);
71         raise;
72 
73 END Notify_User;
74 
75 /* For sending email to one or more email addresses */
76 
77 PROCEDURE Send_Email ( p_api_version		IN 	NUMBER,
78 	               p_commit			IN	VARCHAR2 := FND_API.g_false,
79 	               p_init_msg_list		IN	VARCHAR2 := FND_API.g_false,
80                        p_email_list 		IN   	VARCHAR2,
81                        p_subject 		IN   	VARCHAR2,
82 	               p_body 			IN   	VARCHAR2,
83                        x_return_status       OUT NOCOPY /* file.sql.39 change */  	 VARCHAR2,
84                        x_msg_count	 OUT NOCOPY /* file.sql.39 change */  NUMBER,
85                        x_msg_data	 OUT NOCOPY /* file.sql.39 change */  VARCHAR2
86 			)
87 IS
88 
89 wf_itemkey_seq INTEGER;
90 wf_itemkey VARCHAR2(30);
91 role_name VARCHAR2(30);
92 role_display_name VARCHAR2(30);
93 
94 BEGIN
95 
96   x_return_status := FND_API.g_ret_sts_success;
97 
98   IF ASO_DEBUG_PUB.G_Debug_Flag = 'Y' THEN
99     aso_debug_pub.add('email_list: ' || p_email_list , 1, 'N' );
100     aso_debug_pub.add('subject: ' || p_subject , 1, 'N' );
101     aso_debug_pub.add('object: ' || p_body , 1, 'N' );
102   END IF;
103 
104   select ASO_WFNOTIFICATION_S2.NEXTVAL into wf_itemkey_seq from dual;
105 		  wf_itemkey := 'ASO_MAIL_' || wf_itemkey_seq;
106 
107 
108   role_name := 'ASO_EMAIL_LIST_' || wf_itemkey_seq ;
109   role_display_name := 'ASO_EMAIL_LIST_' || wf_itemkey_seq ;
110 
111   wf_directory.CreateAdHocUser ( name => role_name,
112 				 display_name => role_display_name,
113 				 notification_preference => 'MAILTEXT',
114                                  email_address => p_email_list,
115 				 expiration_date => sysdate + 1 );
116 
117    wf_engine.CreateProcess     ( itemtype => 'ASO_MAIL',
118 				 itemkey  =>  wf_itemkey,
119 				 process  => 'ASO_SEND_EMAIL' );
120 
121    wf_engine.SetItemUserKey    ( itemtype => 'ASO_MAIL',
122 				 itemkey  =>  wf_itemkey,
123 				 userkey  => 'ASO Email Notification' || wf_itemkey_seq );
124 
125    wf_engine.SetItemAttrText   ( itemtype => 'ASO_MAIL',
126 				 itemkey  =>  wf_itemkey,
127 				 aname    => 'ROLE_TO_NOTIFY',
128 				 avalue   =>  role_name );
129 
130    wf_engine.SetItemAttrText   ( itemtype => 'ASO_MAIL',
131 				 itemkey  =>  wf_itemkey,
132 				 aname    => 'NOTIFICATION_SUBJECT',
133 				 avalue   =>  p_subject );
134 
135    wf_engine.SetItemAttrText   ( itemtype => 'ASO_MAIL',
136 				 itemkey  =>  wf_itemkey,
137 				 aname    => 'NOTIFICATION_BODY',
138 				 avalue   =>  p_body );
139 
140    wf_engine.SetItemOwner      ( itemtype => 'ASO_MAIL',
141 			         itemkey  =>  wf_itemkey,
142         			 owner    =>  role_name );
143 
144    wf_engine.StartProcess      ( itemtype => 'ASO_MAIL',
145 				 itemkey  =>  wf_itemkey );
146 
147 EXCEPTION
148 
149     When others then
150       x_return_status := FND_API.g_ret_sts_error;
151       x_msg_count := 0;
152       wf_core.context('ASO_WFNOTIFICATION_PVT', 'Send_Email', p_email_list, p_subject, p_body );
153       raise;
154 
155 END Send_Email;
156 
157 END ASO_WFNOTIFICATION_PVT ;