[Home] [Help]
PACKAGE BODY: APPS.ASP_DELIVERY_AGENT
Source
1 PACKAGE BODY ASP_DELIVERY_AGENT as
2 /* $Header: aspdlvab.pls 120.1 2005/09/06 14:45 axavier noship $ */
3 ---------------------------------------------------------------------------
4 -- Package Name: ASP_DELIVERY_AGENT
5 ---------------------------------------------------------------------------
6 -- Description:
7 -- Responsible for the creation of adhoc role and Delivery.
8 --
9 -- Procedures:
10 -- (see the specification for details)
11 --
12 -- History:
13 -- 10-Aug-2005 axavier created.
14 ---------------------------------------------------------------------------
15
16 /*-------------------------------------------------------------------------*
17 | Private Constants
18 *-------------------------------------------------------------------------*/
19 G_PKG_NAME CONSTANT VARCHAR2(30):= 'ASP_DELIVERY_AGENT';
20 G_FILE_NAME CONSTANT VARCHAR2(12) := 'aspdlvab.pls';
21 G_MODULE CONSTANT VARCHAR2(250) := 'asp.plsql.'||G_PKG_NAME||'.';
22
23 /*-------------------------------------------------------------------------*
24 | Private Datatypes
25 *-------------------------------------------------------------------------*/
26
27 /*-------------------------------------------------------------------------*
28 | Private Variables
29 *-------------------------------------------------------------------------*/
30
31 /*-------------------------------------------------------------------------*
32 | Private Routines Specification
33 *-------------------------------------------------------------------------*/
34
35 /*-------------------------------------------------------------------------*
36 | Public Routines
37 *-------------------------------------------------------------------------*/
38
39 --------------------------------------------------------------------------------
40 -- Procedure: Deliver
41 -- Responsible for the creation of adhoc role and Delivery.
42 --
43 --------------------------------------------------------------------------------
44
45 PROCEDURE Deliver(
46 itemtype in VARCHAR2,
47 itemkey in VARCHAR2,
48 actid in NUMBER,
49 funcmode in VARCHAR2,
50 resultout in out NOCOPY VARCHAR2)
51 IS
52 l_event_entity varchar2(100);
53 l_api_name varchar2(100);
54 l_qualified_api_name varchar2(200);
55 l_debug_msg varchar2(1000);
56 l_sms_users varchar2(32767);
57 l_email_users varchar2(32767);
58 l_sms_adhocrole varchar2(320);
59 l_email_adhocrole varchar2(320);
60
61 l_debug_runtime number;
62 l_debug_exception number;
63 l_debug_procedure number;
64 l_debug_statment number;
65
66 l_event_entity varchar2(100);
67 l_alert_code varchar2(30);
68 l_incident_id number;
69 l_task_id number;
70
71 BEGIN
72 l_api_name := 'Deliver';
73 l_debug_runtime := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
74 l_debug_exception := FND_LOG.LEVEL_EXCEPTION;
75 l_debug_procedure := FND_LOG.LEVEL_PROCEDURE;
76 l_debug_statment := FND_LOG.LEVEL_STATEMENT;
77
78 l_qualified_api_name := G_PKG_NAME||'.'||l_api_name;
79 if(l_debug_procedure >= l_debug_runtime) then
80 fnd_log.string(l_debug_procedure, G_MODULE||l_api_name, 'Entered '||G_PKG_NAME||'.'||l_api_name);
81 end if;
82
83 If(funcmode = 'RUN') Then
84 l_sms_users := wf_engine.GetItemAttrText( itemtype =>itemtype,
85 itemkey =>itemkey,
86 aname =>'SMS_USERS');
87
88 l_email_users := wf_engine.GetItemAttrText( itemtype =>itemtype,
89 itemkey =>itemkey,
90 aname =>'EMAIL_USERS');
91
92 if(l_debug_procedure >= l_debug_runtime) then
93 fnd_log.string(l_debug_procedure, G_MODULE||l_api_name, 'l_sms_users '||l_sms_users);
94 fnd_log.string(l_debug_procedure, G_MODULE||l_api_name, 'l_email_users '||l_email_users);
95 end if;
96
97 BEGIN
98 l_sms_adhocrole := 'ASPSMS_' || itemkey;
99 l_email_adhocrole := 'ASPEMAIL_' || itemkey;
100 if(l_debug_procedure >= l_debug_runtime) then
101 fnd_log.string(l_debug_procedure, G_MODULE||l_api_name, 'Before wf_directory.CreateAdHocRole ');
102 end if;
103
104 wf_directory.CreateAdHocRole(role_name => l_sms_adhocrole,
105 role_display_name => l_sms_adhocrole,
106 expiration_date => sysdate+5,
107 role_users => l_sms_users);
108
109 wf_directory.CreateAdHocRole(role_name => l_email_adhocrole,
110 role_display_name => l_email_adhocrole,
111 expiration_date => sysdate+5,
112 role_users => l_email_users);
113 if(l_debug_procedure >= l_debug_runtime) then
114 fnd_log.string(l_debug_procedure, G_MODULE||l_api_name, 'After wf_directory.CreateAdHocRole ');
115 end if;
116
117 EXCEPTION
118 WHEN OTHERS THEN
119 wf_core.context(G_PKG_NAME, l_api_name, itemtype, itemkey, to_char(actid), funcmode);
120 l_debug_msg := l_qualified_api_name||':OTHERS:CreateAdHocRole'||to_char(SQLCODE)||':'||substr(SQLERRM,1,500);
121 wf_core.token('ORA_ERROR',l_debug_msg);
122 if(l_debug_exception >= l_debug_runtime) then
123 fnd_log.string(l_debug_exception, G_MODULE||l_api_name, l_debug_msg);
124 end if;
125 wf_core.raise('WF_ORA');
126 END;
127
128 --/*
129 wf_engine.SetItemAttrText(itemtype, itemkey, 'NOTIF_FROM_ROLE', 'SYSADMIN');
130 wf_engine.SetItemAttrText(itemtype, itemkey, 'SMS_SEND_TO', l_sms_adhocrole);
131 wf_engine.SetItemAttrText(itemtype, itemkey, 'EMAIL_SEND_TO', l_email_adhocrole);
132 wf_engine.SetItemAttrText(itemtype, itemkey, 'DELIVERY_CHANNEL', 'CHANNEL_SMS'); --Hardcoded
133 --*/
134 /*
135 --Set all the attributes for the "Message Delivery Process"
136 if(l_debug_procedure >= l_debug_runtime) then
137 fnd_log.string(l_debug_procedure, G_MODULE||l_api_name, 'Before wf_engine.CreateProcess ALERT_DELIVERY');
138 end if;
139 wf_engine.CreateProcess( itemtype => 'ASPALERT', itemkey => itemkey, process => 'ALERT_DELIVERY');
140
141
142
143 l_event_entity := wf_engine.GetItemAttrText( itemtype =>itemtype,
144 itemkey =>itemkey,
145 aname =>'ALERT_SOURCE_OBJECT_CODE');
146
147 l_alert_code := wf_engine.GetItemAttrText( itemtype =>itemtype,
148 itemkey =>itemkey,
149 aname =>'ALERT_NAME');
150
151 l_incident_id := wf_engine.GetItemAttrText( itemtype =>itemtype,
152 itemkey =>itemkey,
153 aname =>'ALERT_SOURCE_OBJECT_ID');
154
155 begin
156 l_task_id := wf_engine.GetItemAttrText( itemtype =>itemtype,
157 itemkey =>itemkey,
158 aname =>'ALERT_SOURCE_TASK_ID');
159 exception
160 when others then
161 l_task_id := -1;
162 end;
163 wf_engine.SetItemAttrText('ASPALERT', itemkey, 'ALERT_NAME', l_alert_code);
164 wf_engine.SetItemAttrText('ASPALERT', itemkey, 'ALERT_SOURCE_OBJECT_CODE', l_event_entity);
165 wf_engine.SetItemAttrText('ASPALERT', itemkey, 'ALERT_SOURCE_OBJECT_ID', l_incident_id);
166 wf_engine.SetItemAttrText('ASPALERT', itemkey, 'ALERT_SOURCE_TASK_ID', l_task_id);
167
168 wf_engine.SetItemAttrText(itemtype, itemkey, 'NOTIF_FROM_ROLE', 'SYSADMIN');
169 wf_engine.SetItemAttrText(itemtype, itemkey, 'SMS_SEND_TO', l_sms_adhocrole);
170 wf_engine.SetItemAttrText(itemtype, itemkey, 'EMAIL_SEND_TO', l_email_adhocrole);
171 wf_engine.SetItemAttrText(itemtype, itemkey, 'DELIVERY_CHANNEL', 'CHANNEL_EMAIL');
172
173
174 if(l_debug_procedure >= l_debug_runtime) then
175 fnd_log.string(l_debug_procedure, G_MODULE||l_api_name, 'Before wf_engine.StartProcess ALERT_DELIVERY');
176 end if;
177 wf_engine.StartProcess(itemtype => 'ASPALERT', itemkey => itemkey);
178 if(l_debug_procedure >= l_debug_runtime) then
179 fnd_log.string(l_debug_procedure, G_MODULE||l_api_name, 'After wf_engine.StartProcess ALERT_DELIVERY');
180 end if;
181 */
182
183
184 resultout := 'COMPLETE:SUCCESS';
185 return;
186 End If;
187 --
188 -- Other execution modes may be created in the future. Your
189 -- activity will indicate that it does not implement a mode
190 -- by returning null
191 --
192 resultout := '';
193 return;
194
195
196 EXCEPTION
197 When no_data_found Then
198 wf_core.context(G_PKG_NAME, l_api_name, itemtype, itemkey, to_char(actid), funcmode);
199 l_debug_msg := l_qualified_api_name||':NO_DATA_FOUND:'||to_char(SQLCODE)||':'||substr(SQLERRM,1,500);
200 wf_core.token('ORA_ERROR',l_debug_msg);
201 if(l_debug_exception >= l_debug_runtime) then
202 fnd_log.string(l_debug_exception, G_MODULE||l_api_name, l_debug_msg);
203 end if;
204 wf_core.raise('WF_ORA');
205
206 When others Then
207 wf_core.context(G_PKG_NAME, l_api_name, itemtype, itemkey, to_char(actid), funcmode);
208 l_debug_msg := l_qualified_api_name||':OTHERS:'||to_char(SQLCODE)||':'||substr(SQLERRM,1,500);
209 wf_core.token('ORA_ERROR',l_debug_msg);
210 if(l_debug_exception >= l_debug_runtime) then
211 fnd_log.string(l_debug_exception, G_MODULE||l_api_name, l_debug_msg);
212 end if;
213 wf_core.raise('WF_ORA');
214
215 END Deliver;
216
217 End ASP_DELIVERY_AGENT;