DBA Data[Home] [Help]

PACKAGE BODY: APPS.CS_WF_ACTIVITIES_CUST

Source


1 PACKAGE BODY CS_WF_ACTIVITIES_CUST  AS
2 /* $Header: cswfcstb.pls 115.8 2003/03/21 00:45:16 rmanabat ship $ */
3 
4 
5 -- --------------------------------------
6 -- Constants used in this package
7 -- --------------------------------------
8 
9 -- cs_newline varchar2(1) := chr(10);
10 cs_separator varchar2(20) := '--------------------';
11 
12 
13 -- ***************************************************************************
14 -- *									     *
15 -- *			   Service Request Item Type			     *
16 -- *									     *
17 -- ***************************************************************************
18 
19 --                   -----------------------------------------
20 --                   |             PUBLIC SECTION            |
21 --                   | Following procedures are customizable |
22 --                   -----------------------------------------
23 --
24 
25 -- -------------------------------------------------------------------
26 -- Set_Response_Deadline
27 -- -------------------------------------------------------------------
28 
29   PROCEDURE Set_Response_Deadline(
30 		 		itemtype      VARCHAR2,
31                               	itemkey       VARCHAR2,
32                                	actid         NUMBER,
33                                	funmode       VARCHAR2,
34                                	result    OUT NOCOPY VARCHAR2 ) IS
35 
36     l_response_deadline 	DATE;
37     l_default_days		NUMBER;
38 
39   BEGIN
40 
41     IF (funmode = 'RUN') THEN
42 
43       l_response_deadline := WF_ENGINE.GetActivityAttrDate(
44 		itemtype	=>  itemtype,
45 		itemkey		=>  itemkey,
46 		actid		=>  actid,
47 		aname		=>  'RESPONSE_DEADLINE' );
48 
49       IF (l_response_deadline IS NOT NULL) AND
50          (l_response_deadline > sysdate) THEN
51 
52         WF_ENGINE.SetItemAttrDate(
53 		itemtype	=>  itemtype,
54 		itemkey		=>  itemkey,
55 		aname		=>  'RESPONSE_DEADLINE',
56 		avalue		=>  l_response_deadline );
57 
58       ELSE
59 
60         l_default_days := WF_ENGINE.GetActivityAttrNumber(
61 				itemtype	=> itemtype,
62 				itemkey		=> itemkey,
63 				actid		=> actid,
64 				aname		=> 'DEFAULT_DAYS' );
65 
66         IF (l_default_days IS NULL) THEN
67           l_default_days := 3;
68         END IF;
69 
70         WF_ENGINE.SetItemAttrDate(
71 		itemtype	=>  itemtype,
72 		itemkey		=>  itemkey,
73 		aname		=>  'RESPONSE_DEADLINE',
74 		avalue		=>  sysdate + l_default_days );
75 
76       END IF;
77 
78       result := 'COMPLETE';
79 
80     ELSIF (funmode = 'CANCEL') THEN
81       result := 'COMPLETE';
82     END IF;
83 
84   EXCEPTION
85     WHEN OTHERS THEN
86       WF_CORE.Context('CS_WF_ACTIVITIES_CUST', 'Set_Response_Deadline',
87 		      itemtype, itemkey, actid, funmode);
88       RAISE;
89 
90   END Set_Response_Deadline;
91 
92 
93 
94 -- ---------------------------------------------------------------------------
95 -- Initialize_Escalation_Hist
96 --   This procedure corresponds to the INITIALIZE_ESCALATION_HIST function
97 --   activity.  It initializes the ESCALATION_HISTORY item attribute.
98 -- ---------------------------------------------------------------------------
99 
100   PROCEDURE Initialize_Escalation_Hist( itemtype       VARCHAR2,
101                                         itemkey        VARCHAR2,
102                                         actid          NUMBER,
103                                         funmode        VARCHAR2,
104                                         result     OUT NOCOPY VARCHAR2 ) IS
105 
106     l_msg_count		NUMBER;
107     l_msg_data		VARCHAR2(2000);
108     l_return_status	VARCHAR2(1);
109     l_API_ERROR		EXCEPTION;
110     l_request_id	NUMBER;
111     l_owner_id		NUMBER;
112     l_owner_name	VARCHAR2(240);
113     l_dummy_role	VARCHAR2(100);
114     l_escalation_history  VARCHAR2(5000);
115     l_errmsg_name	  VARCHAR2(30);
116 
117 
118     /****
119      Changing this for performance issues due to
120      excessive shared memory and non-mergeable view.
121      rmanabat 03/20/03.
122 
123     CURSOR l_ServiceRequest_csr IS
124       SELECT *
125         FROM CS_INCIDENTS_WORKFLOW_V
126        WHERE incident_id = l_request_id;
127 
128     l_ServiceRequest_rec 	l_ServiceRequest_csr%ROWTYPE;
129     ****/
130 
131     /** Replacing above cursor with this. Bug 2857365. rmanabat 03/20/02 **/
132     CURSOR l_ServiceRequest_csr IS
133       SELECT emp.source_id
134       FROM jtf_rs_resource_extns emp,
135         cs_incidents_all_b inc
136       WHERE inc.incident_id = l_request_id
137         AND emp.resource_id = inc.incident_owner_id;
138 
139   BEGIN
140     IF (funmode = 'RUN') THEN
141 
142       -- Extract the service request record
146 		aname		=> 'REQUEST_ID' );
143       l_request_id := WF_ENGINE.GetItemAttrNumber(
144 		itemtype	=> itemtype,
145 		itemkey		=> itemkey,
147 
148       OPEN l_ServiceRequest_csr;
149       --FETCH l_ServiceRequest_csr INTO l_ServiceRequest_rec;
150       FETCH l_ServiceRequest_csr INTO l_owner_id;
151 
152       IF (l_ServiceRequest_csr%NOTFOUND OR l_owner_id IS NULL) THEN
153         l_errmsg_name := 'CS_WF_SR_CANT_FIND_OWNER';
154         raise l_API_ERROR;
155       END IF;
156 
157       CLOSE l_ServiceRequest_csr;
158 
159       --
160       -- Get the name of the current owner
161       --
162       --l_owner_id := l_ServiceRequest_rec.incident_owner_id;
163 
164       CS_WORKFLOW_PUB.Get_Employee_Role (
165 		p_api_version		=>  1.0,
166 		p_return_status		=>  l_return_status,
167 		p_msg_count		=>  l_msg_count,
168 		p_msg_data		=>  l_msg_data,
169 		p_employee_id  		=>  l_owner_id,
170 		p_role_name		=>  l_dummy_role,
171 		p_role_display_name	=>  l_owner_name );
172 
173       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
174         wf_core.context( pkg_name	=>  'CS_WORKFLOW_PUB',
175 			 proc_name	=>  'Get_Employee_Role',
176 			 arg1		=>  'p_employee_id=>'||
177 					    to_char(l_owner_id));
178 	l_errmsg_name := 'CS_WF_SR_CANT_FIND_OWNER';
179 	raise l_API_ERROR;
180       END IF;
181 
182       -- Get the translated message
183       FND_MESSAGE.SET_NAME('CS', 'CS_SR_ASSIGNED_TO');
184       FND_MESSAGE.Set_Token('OWNER', l_owner_name);
185       l_escalation_history := FND_MESSAGE.Get;
186 
187       -- Now append the date and the separator
188       l_escalation_history := cs_separator ||'
189 	'|| to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS') ||'
190 	'|| l_escalation_history;
194 		itemkey		=> itemkey,
191 
192       WF_ENGINE.SetItemAttrText(
193 		itemtype	=> 'SERVEREQ',
195 		aname		=> 'ESCALATION_HISTORY',
196 		avalue		=> substrb(l_escalation_history, 1, 2000));
197 
198       result := 'COMPLETE';
199 
200     ELSIF (funmode = 'CANCEL') THEN
201       result := 'COMPLETE';
202     END IF;
203 
204   EXCEPTION
205     WHEN l_API_ERROR THEN
206       IF (l_ServiceRequest_csr%ISOPEN) THEN
207         close l_ServiceRequest_csr;
208       END IF;
209       WF_CORE.Raise(l_errmsg_name);
210     WHEN OTHERS THEN
211       WF_CORE.Context('CS_WF_ACTIVITIES_CUST', 'Initialize_Escalation_Hist',
212 		      itemtype, itemkey, actid, funmode);
213       RAISE;
214 
215   END Initialize_Escalation_Hist;
216 
217 
218 
219 -- ---------------------------------------------------------------------------
220 -- Update_Escalation_Hist
221 --   This procedure corresponds to the UPDATE_ESCALATION_HIST function
222 --   activity.  It updates the ESCALATION_HISTORY item attribute.
223 -- ---------------------------------------------------------------------------
224 
225   PROCEDURE Update_Escalation_Hist( itemtype       VARCHAR2,
226                                     itemkey        VARCHAR2,
227                                     actid          NUMBER,
228                                     funmode        VARCHAR2,
229                                     result     OUT NOCOPY VARCHAR2 ) IS
230     l_owner_name	VARCHAR2(240);
231     l_escalation_history  VARCHAR2(5000);
232     l_escalation_comment  VARCHAR2(2000);
233     l_escalation_line     VARCHAR2(2000);
234   BEGIN
235     IF (funmode = 'RUN') THEN
236 
237       l_escalation_comment := WF_ENGINE.GetActivityAttrText(
238 				itemtype	=> itemtype,
239 				itemkey		=> itemkey,
240 				actid		=> actid,
241 				aname		=> 'ESCALATION_COMMENT' );
242 
243       l_escalation_history := WF_ENGINE.GetItemAttrText(
244 				itemtype	=> itemtype,
245 				itemkey		=> itemkey,
246 				aname		=> 'ESCALATION_HISTORY' );
247 
248       l_owner_name := WF_ENGINE.GetActivityAttrText(
249 				itemtype	=> itemtype,
250 				itemkey		=> itemkey,
251 				actid		=> actid,
252 				aname		=> 'ESCALATED_TO' );
253 
254       -- Get the translated escalation message line
255       FND_MESSAGE.SET_NAME('CS', 'CS_SR_ESCALATED_TO');
256       FND_MESSAGE.Set_Token('OWNER', l_owner_name);
257       l_escalation_line := FND_MESSAGE.Get;
258 
259       -- Now append the date and the separator
260       IF (l_escalation_comment IS NULL) THEN
261 	 l_escalation_history := cs_separator ||'
262 	   '|| to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS') ||'
263 	   '|| l_escalation_line ||'
264 	   '|| l_escalation_history;
265       ELSE
266 	 l_escalation_history := cs_separator ||'
267 	   '|| to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS') ||'
268 	   '|| l_escalation_line ||'
269 	   '||'"'||l_escalation_comment||'"'||'
270 	   '|| l_escalation_history;
271       END IF;
275 
272 
273       -- Make sure it doesn't exceed 2000 bytes
274       l_escalation_history := substrb(l_escalation_history, 1, 2000);
276       -- Update item attribute
277       WF_ENGINE.SetItemAttrText(
278 		itemtype	=> 'SERVEREQ',
279 		itemkey		=> itemkey,
280 		aname		=> 'ESCALATION_HISTORY',
281 		avalue		=> l_escalation_history );
282 
283       -- Reset escalation comment
284       WF_ENGINE.SetItemAttrText(
285 		itemtype	=> 'SERVEREQ',
286 		itemkey		=> itemkey,
287 		aname		=> 'LAST_ESCALATION_COMMENT',
288 		avalue		=> l_escalation_comment );
289 
290       WF_ENGINE.SetItemAttrText(
291 		itemtype	=> 'SERVEREQ',
292 		itemkey		=> itemkey,
293 		aname		=> 'ESCALATION_COMMENT',
294 		avalue		=> '' );
295 
296       result := 'COMPLETE';
297 
298     ELSIF (funmode = 'CANCEL') THEN
299       result := 'COMPLETE';
300     END IF;
301 
302   EXCEPTION
303     WHEN OTHERS THEN
304       WF_CORE.Context('CS_WF_ACTIVITIES_CUST', 'Update_Escalation_Hist',
305 		      itemtype, itemkey, actid, funmode);
306       RAISE;
307 
308   END Update_Escalation_Hist;
309 
310 
311 
312 END CS_WF_ACTIVITIES_CUST;