DBA Data[Home] [Help]

PACKAGE BODY: APPS.IBE_WFNOTIFICATION_PVT

Source


1 PACKAGE BODY IBE_WFNOTIFICATION_PVT AS
2 /* $Header: IBEVWNTB.pls 115.5 2002/12/10 11:29:56 suchandr ship $ */
3 
4 	PROCEDURE Notify_User (
5 	                p_api_version		IN 	NUMBER,
6 	                p_commit			IN	VARCHAR2 := FND_API.g_false,
7 	                p_init_msg_list	IN	VARCHAR2 := FND_API.g_false,
8                      user_name 		IN   VARCHAR2,
9                      subject 			IN   VARCHAR2,
10 	        		 body 			IN   VARCHAR2,
11                      return_status      OUT NOCOPY  VARCHAR2,
12                 	 x_msg_count		OUT NOCOPY	NUMBER,
13                 	 x_msg_data		OUT NOCOPY VARCHAR2
14 			)
15         IS
16                 wf_itemkey_seq INTEGER;
17 			 wf_itemkey VARCHAR2(30);
18         BEGIN
19                 return_status := FND_API.g_ret_sts_success;
20 
21 --                DBMS_OUTPUT.put_line('user_name: ' || user_name );
22 --                DBMS_OUTPUT.put_line('subject: ' || subject );
23 --                DBMS_OUTPUT.put_line('body: ' || body );
24 
25         select IBE_WFNOTIFICATION_S1.NEXTVAL into wf_itemkey_seq from dual;
26 	   wf_itemkey := 'IBE_USER_' || wf_itemkey_seq;
27 
28 	   wf_engine.CreateProcess (
29 						   itemtype => 'IBE_USER',
30 						   itemkey  =>  wf_itemkey,
31 						   process  => 'IBE_NOTIFY_USER'
32 						  );
33 	   wf_engine.SetItemUserKey (
34 						   itemtype => 'IBE_USER',
35 						   itemkey  =>  wf_itemkey,
36 						   userkey  => 'IBE User Notification ' || wf_itemkey_seq
37 						  );
38 	   wf_engine.SetItemAttrText (
39 						   itemtype => 'IBE_USER',
40 						   itemkey  =>  wf_itemkey,
41 						   aname    => 'ROLE_TO_NOTIFY',
42 						   avalue   =>  user_name
43 						  );
44 	   wf_engine.SetItemAttrText (
45 						   itemtype => 'IBE_USER',
46 						   itemkey  =>  wf_itemkey,
47 						   aname    => 'NOTIFICATION_SUBJECT',
48 						   avalue   =>  subject
49 						  );
50 	   wf_engine.SetItemAttrText (
51 						   itemtype => 'IBE_USER',
52 						   itemkey  =>  wf_itemkey,
53 						   aname    => 'NOTIFICATION_BODY',
54 						   avalue   =>  body
55 						 );
56 	   wf_engine.SetItemOwner (
57 						   itemtype => 'IBE_USER',
58 						   itemkey  =>  wf_itemkey,
59 						   owner    =>  user_name
60 						 );
61 	   wf_engine.StartProcess (
62 						   itemtype => 'IBE_USER',
63 						   itemkey  =>  wf_itemkey
64 						 );
65 
66         EXCEPTION
67                 When others then
68 
69                 return_status := FND_API.g_ret_sts_error;
70                 x_msg_count := 0;
71 
72 			 wf_core.context('IBE_WFNOTIFICATION_PVT',
73 						  'Notify_User',
74 		                       user_name,
75 						   subject,
76 						   body
77 						 );
78                 raise;
79      END Notify_User;
80 
81 	PROCEDURE Send_Email (
82 	                p_api_version		IN 	NUMBER,
83 	                p_commit			IN	VARCHAR2 := FND_API.g_false,
84 	                p_init_msg_list	IN	VARCHAR2 := FND_API.g_false,
85                      email_list 		IN   VARCHAR2,
86                      subject 			IN   VARCHAR2,
87 	        		 body 			IN   VARCHAR2,
88                      return_status      OUT NOCOPY  VARCHAR2,
89                 	 x_msg_count		OUT NOCOPY	NUMBER,
90                 	 x_msg_data		OUT NOCOPY	VARCHAR2
91 			)
92         IS
93                 wf_itemkey_seq INTEGER;
94 			 wf_itemkey VARCHAR2(30);
95 			 role_name VARCHAR2(30);
96 			 role_display_name VARCHAR2(30);
97         BEGIN
98                 return_status := FND_API.g_ret_sts_success;
99 
100 --                DBMS_OUTPUT.put_line('email_list: ' || email_list );
101 --                DBMS_OUTPUT.put_line('subject: ' || subject );
102 --                DBMS_OUTPUT.put_line('body: ' || body );
103 
104         select IBE_WFNOTIFICATION_S2.NEXTVAL into wf_itemkey_seq from dual;
105 	   wf_itemkey := 'IBE_MAIL_' || wf_itemkey_seq;
106 
107 	   role_name := 'IBE_EMAIL_LIST_' || wf_itemkey_seq ;
108 	   role_display_name := 'IBE_EMAIL_LIST_' || wf_itemkey_seq ;
109 
110         wf_directory.CreateAdHocUser(
111 						   name => role_name,
112 						   display_name => role_display_name,
113 						   notification_preference => 'MAILTEXT',
114                                  email_address => email_list,
115 						   expiration_date => sysdate + 1
116 						  );
117 
118 	   wf_engine.CreateProcess (
119 						   itemtype => 'IBE_MAIL',
120 						   itemkey  =>  wf_itemkey,
121 						   process  => 'IBE_SEND_EMAIL'
122 						  );
123 	   wf_engine.SetItemUserKey (
124 						   itemtype => 'IBE_MAIL',
125 						   itemkey  =>  wf_itemkey,
126 						   userkey  => 'IBE Email Notification' || wf_itemkey_seq
127 						  );
128 	   wf_engine.SetItemAttrText (
129 						   itemtype => 'IBE_MAIL',
130 						   itemkey  =>  wf_itemkey,
131 						   aname    => 'ROLE_TO_NOTIFY',
132 						   avalue   =>  role_name
133 						  );
134 	   wf_engine.SetItemAttrText (
135 						   itemtype => 'IBE_MAIL',
136 						   itemkey  =>  wf_itemkey,
137 						   aname    => 'NOTIFICATION_SUBJECT',
138 						   avalue   =>  subject
139 						  );
140 	   wf_engine.SetItemAttrText (
141 						   itemtype => 'IBE_MAIL',
142 						   itemkey  =>  wf_itemkey,
143 						   aname    => 'NOTIFICATION_BODY',
144 						   avalue   =>  body
145 						  );
146 	   wf_engine.SetItemOwner (
147 						   itemtype => 'IBE_MAIL',
148 						   itemkey  =>  wf_itemkey,
149 						   owner    =>  role_name
150 						 );
151 	   wf_engine.StartProcess (
152 						   itemtype => 'IBE_MAIL',
153 						   itemkey  =>  wf_itemkey
154 						 );
155 
156         EXCEPTION
157                 When others then
158 
159                 return_status := FND_API.g_ret_sts_error;
160                 x_msg_count := 0;
161 
162 			 wf_core.context('IBE_WFNOTIFICATION_PVT',
163 						  'Send_Email',
164 		                       email_list,
165 						   subject,
166 						   body
167 						 );
168                 raise;
169      END Send_Email;
170 
171 
172 	PROCEDURE Send_Html_Email (
173 	                p_api_version		IN 	NUMBER,
174 	                p_commit			IN	VARCHAR2 := FND_API.g_false,
175 	                p_init_msg_list	IN	VARCHAR2 := FND_API.g_false,
176                      email_list 		IN   VARCHAR2,
177                      subject 			IN   VARCHAR2,
178 	        		 body 			IN   VARCHAR2,
179                      return_status      OUT NOCOPY  VARCHAR2,
180                 	 x_msg_count		OUT NOCOPY	NUMBER,
181                 	 x_msg_data		OUT NOCOPY	VARCHAR2
182 			)
183         IS
184                 wf_itemkey_seq INTEGER;
185 			 wf_itemkey VARCHAR2(30);
186 			 role_name VARCHAR2(30);
187 			 role_display_name VARCHAR2(30);
188         BEGIN
189                 return_status := FND_API.g_ret_sts_success;
190 
191 --                DBMS_OUTPUT.put_line('email_list: ' || email_list );
192 --                DBMS_OUTPUT.put_line('subject: ' || subject );
193 --                DBMS_OUTPUT.put_line('body: ' || body );
194 
195         select IBE_WFNOTIFICATION_S2.NEXTVAL into wf_itemkey_seq from dual;
196 	   wf_itemkey := 'IBE_MAIL_' || wf_itemkey_seq;
197 
198 	   role_name := 'IBE_EMAIL_LIST_' || wf_itemkey_seq ;
199 	   role_display_name := 'IBE_EMAIL_LIST_' || wf_itemkey_seq ;
200 
201         wf_directory.CreateAdHocUser(
202 						   name => role_name,
203 						   display_name => role_display_name,
204 						   notification_preference => 'MAILHTML',
205                                  email_address => email_list,
206 						   expiration_date => sysdate + 1
207 						  );
208 
209 	   wf_engine.CreateProcess (
210 						   itemtype => 'IBE_MAIL',
211 						   itemkey  =>  wf_itemkey,
212 						   process  => 'IBE_SEND_EMAIL'
213 						  );
214 	   wf_engine.SetItemUserKey (
215 						   itemtype => 'IBE_MAIL',
216 						   itemkey  =>  wf_itemkey,
217 						   userkey  => 'IBE Email Notification' || wf_itemkey_seq
218 						  );
219 	   wf_engine.SetItemAttrText (
220 						   itemtype => 'IBE_MAIL',
221 						   itemkey  =>  wf_itemkey,
222 						   aname    => 'ROLE_TO_NOTIFY',
223 						   avalue   =>  role_name
224 						  );
225 	   wf_engine.SetItemAttrText (
226 						   itemtype => 'IBE_MAIL',
227 						   itemkey  =>  wf_itemkey,
228 						   aname    => 'NOTIFICATION_SUBJECT',
229 						   avalue   =>  subject
230 						  );
231 	   wf_engine.SetItemAttrText (
232 						   itemtype => 'IBE_MAIL',
233 						   itemkey  =>  wf_itemkey,
234 						   aname    => 'NOTIFICATION_BODY',
235 						   avalue   =>  body
236 						  );
237 	   wf_engine.SetItemOwner (
238 						   itemtype => 'IBE_MAIL',
239 						   itemkey  =>  wf_itemkey,
240 						   owner    =>  role_name
241 						 );
242 	   wf_engine.StartProcess (
243 						   itemtype => 'IBE_MAIL',
244 						   itemkey  =>  wf_itemkey
245 						 );
246 
247         EXCEPTION
248                 When others then
249 
250                 return_status := FND_API.g_ret_sts_error;
251                 x_msg_count := 0;
252 
253 			 wf_core.context('IBE_WFNOTIFICATION_PVT',
254 						  'Send_HTML_Email',
255 		                       email_list,
256 						   subject,
257 						   body
258 						 );
259                 raise;
260      END Send_Html_Email;
261 
262 END IBE_WFNOTIFICATION_PVT ;