DBA Data[Home] [Help]

PACKAGE BODY: APPS.OKS_CT_EVENTS_WFA

Source


1 PACKAGE BODY OKS_CT_EVENTS_WFA  AS
2 /* $Header: OKSCTEVB.pls 120.2 2006/02/23 01:08:12 jvorugan noship $ */
3 
4 -- ***************************************************************************
5 -- *									     *
6 -- *			   Contract EVENT Item Type 			     *
7 -- *									     *
8 -- ***************************************************************************
9 
10         	l_user_id number;
11 		l_resp_id number;
12 		l_resp_appl_id number;
13 
14 PROCEDURE SELECTOR (
15 		itemtype      	IN VARCHAR2,
16 		itemkey       	IN VARCHAR2,
17 		actid         	IN NUMBER,
18 		funcmode      	IN VARCHAR2,
19 		result    	OUT NOCOPY VARCHAR2 ) IS
20 		l_user_id number;
21 		l_resp_id number;
22 		l_resp_appl_id number;
23         	l_forward_to_username varchar2(30);
24 BEGIN
25  	IF (funcmode = 'RUN') THEN
26 
27  /*
28     		FND_PROFILE.Get('OKS_SERVICE_REQUEST_CREATOR', l_forward_to_username);
29 
30 
31       		wf_engine.SetItemAttrText(
32 					itemtype 	=> itemtype,
33     				itemkey 	=> itemkey,
34     				aname  	=> 'FORWARD_TO_USERNAME' ,
35                     avalue  => l_forward_to_username);
36        BEGIN
37        	select user_id into l_user_id
38        	from fnd_user
39        	where user_name = l_forward_to_username;
40        EXCEPTION
41         when others then
42         null;
43        END;
44 
45        WF_ENGINE.SetItemAttrNumber (
46                     itemtype  => itemtype,
47                     itemkey   => itemkey,
48                     aname     => 'USER_ID',
49                     avalue    => l_user_id
50                     );
51 */
52 
53 		result := 'CREATE_SR'; --'COMPLETE';
54  -- Engine calls SET_CTX just before activity execution
55    	ELSIF (funcmode = 'SET_CTX') THEN
56           -- First get the user id, resp id, and appl id
57 
58       --FND_GLOBAL.Apps_Initialize(1001296, 21708, 515);
59 /*
60       FND_PROFILE.Get('OKS_SERVICE_REQUEST_CREATOR', l_forward_to_username);
61 
62 
63       wf_engine.SetItemAttrText(
64 					itemtype 	=> itemtype,
65     				itemkey 	=> itemkey,
66     				aname  	=> 'FORWARD_TO_USERNAME' ,
67                     avalue  => l_forward_to_username);
68        BEGIN
69        select user_id into l_user_id
70        from fnd_user
71        where user_name = l_forward_to_username;
72        EXCEPTION
73         when others then
74         null;
75        END;
76 
77        WF_ENGINE.SetItemAttrNumber (
78                     itemtype  => itemtype,
79                     itemkey   => itemkey,
80                     aname     => 'USER_ID',
81                     avalue    => l_user_id
82                     );
83 */
84      result := 'CREATE_SR'; --'COMPLETE';
85 
86 END IF;
87 
88 EXCEPTION
89 	WHEN OTHERS then
90 		WF_CORE.context(OKS_CT_EVENTS_WFA.l_pkg_name,'Selector',itemtype,itemkey,actid,funcmode);
91 		raise;
92 END SELECTOR;
93 
94 -- ---------------------------------------------------------------------------
95 -- Get Values
96 --   This procedure corresponds to the GET_VALUES function activity.
97 -- ---------------------------------------------------------------------------
98 
99 PROCEDURE GET_VALUES(
100 		itemtype      	IN VARCHAR2,
101 		itemkey       	IN VARCHAR2,
102 		actid         	IN NUMBER,
103 		funcmode      	IN VARCHAR2,
104 		result    	OUT NOCOPY VARCHAR2 ) IS
105 
106 	l_event_id		NUMBER := 0;
107     l_oce_id		NUMBER := 0;
108     l_k_line_id     NUMBER := 0;
109     v_rownum        NUMBER := 0;
110     v_line_id       NUMBER := 0;
111 
112 	l_cp_service_id		NUMBER;
113 	l_customer_product_id	NUMBER;
114 --	l_event_name		CS_EVENTS.NAME%TYPE;
115 	l_customer_id		NUMBER;
116         l_party_number	        OKX_PARTIES_V.PARTY_NUMBER%TYPE;
117 	l_customer_name	OKX_PARTIES_V.NAME%TYPE := null;
118     l_sr_summary        VARCHAR2(100);
119     l_forward_to_username varchar2(30);
120     l_user_id           NUMBER;
121 
122 
123 
124     l_jtot_object_code  OKC_CONDITION_HEADERS_V.jtot_object_code%TYPE;
125     l_object_id         OKC_CONDITION_HEADERS_V.object_id%TYPE;
126 
127 
128 
129     CURSOR contract_cur IS
130      select  cpl.object1_id1 customer_id,opv.name customer_name,opv.party_number party_number
131     from    okc_k_lines_v cle,
132             okc_k_headers_v chr,
133             okc_k_party_roles_b cpl,
134             okx_parties_v opv
135     where   cle.id = l_k_line_id
136     and     cle.dnz_chr_id = chr.id
137     and     cpl.chr_id = chr.id
138     and     cpl.cle_id is null
139     and     cpl.dnz_chr_id = chr.id
140     and     cpl.rle_code= 'CUSTOMER'
141     and     cpl.jtot_object1_code = 'OKX_PARTY'
142     and     cpl.object1_id1 = opv.id1 --to_char(opv.id1) -- commented because of performance bug 3157787
143     and     opv.party_type = 'ORGANIZATION';
144 
145 
146     CURSOR c_req_summary IS
147     select  'CONTRACT - '||okhv.contract_number||'; MODIFIER - '||okhv.contract_number_modifier||
148                 '; SERVICE - '||msi.segment1||'; LINE NO. - '||oklv.line_number SR_SUMMARY
149     from    okc_k_headers_v okhv,
150             okc_k_lines_v   oklv,
151             okc_k_items cim,
152             mtl_system_items msi
153     where   okhv.id = oklv.chr_id
154     and     oklv.id = l_k_line_id
155     and     oklv.id = cim.cle_id
156     and     cim.jtot_object1_code = 'OKX_SERVICE'
157     and     cim.object1_id1 = msi.inventory_item_id --to_char(msi.inventory_item_id)
158     and     cim.object1_id2 = msi.organization_id; --to_char(msi.organization_id);
159 
160 
161 
162 
163 BEGIN
164 
165    	IF (funcmode= 'RUN') THEN
166 
167     FND_PROFILE.Get('OKS_SERVICE_REQUEST_CREATOR', l_forward_to_username);
168 
169 
170       wf_engine.SetItemAttrText(
171 					itemtype 	=> itemtype,
172     				itemkey 	=> itemkey,
173     				aname  	=> 'FORWARD_TO_USERNAME' ,
174                     avalue  => l_forward_to_username);
175        BEGIN
176        select user_id into l_user_id
177        from fnd_user
178        where user_name = l_forward_to_username;
179        EXCEPTION
180         when others then
181         null;
182        END;
183 
184        WF_ENGINE.SetItemAttrNumber (
185                     itemtype  => itemtype,
186                     itemkey   => itemkey,
187                     aname     => 'USER_ID',
188                     avalue    => l_user_id
189                     );
190 
191 
192 
193         l_k_line_id := wf_engine.GetItemAttrNumber(
194 				itemtype 	=> itemtype,
195     				itemkey 	=> itemkey,
196     				aname  	=> 'K_LINE_ID');
197 
198 
199                     --log_errors('k_line_id: '||l_k_line_id);
200 
201 
202 			OPEN contract_cur;
203 			FETCH contract_cur INTO l_customer_id, l_customer_name,l_party_number;
204 			CLOSE contract_cur;
205 
206              --log_errors('customer name: '||l_customer_id||'-'||l_customer_name||'-'||l_party_number);
207 
208                  -- l_customer_id changed to l_party_numberfor bug 2608720
209 /*
210 		wf_engine.SetItemAttrText(
211 					itemtype 	=> itemtype,
212     					itemkey 	=> itemkey,
213     					aname  	=> 'CUSTOMER',
214 					avalue	=> l_customer_name || ':' || l_customer_id);
215 
216 */
217 
218 		wf_engine.SetItemAttrText(
219 					itemtype 	=> itemtype,
220     					itemkey 	=> itemkey,
221     					aname  	=> 'CUSTOMER',
222 					avalue	=> l_customer_name || ':' ||l_party_number);
223 
224 		wf_engine.SetItemAttrNumber(
225 					itemtype 	=> itemtype,
226     					itemkey 	=> itemkey,
227     					aname  	=> 'CUSTOMER_ID',
228 					avalue	=> l_customer_id);
229 
230 
231         for     req_sum_rec in c_req_summary loop
232                 l_sr_summary := req_sum_rec.SR_SUMMARY;
233         end loop;
234 
235 
236         wf_engine.SetItemAttrText(
237 					itemtype 	=> itemtype,
238     					itemkey 	=> itemkey,
239     					aname  	=> 'REQUEST_SUMMARY',
240 					avalue	=> 'SR created by : '||l_sr_summary);
241 
242 	/*	FOR wfparam_rec IN wfparam_cur LOOP
243 
244 			IF wfparam_rec.data_type = 'VARCHAR2' THEN
245 				wf_engine.SetItemAttrText(
246 					itemtype 	=> itemtype,
247     					itemkey 	=> itemkey,
248     					aname  		=> wfparam_rec.name,
249 					avalue		=> wfparam_rec.value);
250 
251 			ELSIF wfparam_rec.data_type = 'DATE'  THEN
252 				wf_engine.SetItemAttrDate(
253 					itemtype 	=> itemtype,
254     					itemkey 	=> itemkey,
255     					aname  		=> wfparam_rec.name,
256 					avalue		=> TO_DATE(wfparam_rec.value, 'DD-MM-YYYY HH24:MI:SS'));
257 			ELSIF wfparam_rec.data_type = 'NUMBER'  THEN
258 				wf_engine.SetItemAttrNumber(
259 					itemtype 	=> itemtype,
260     					itemkey 	=> itemkey,
261     					aname  		=> wfparam_rec.name,
262 					avalue		=> TO_NUMBER(wfparam_rec.value));
263 			END IF;
264 		END LOOP; */
265         --log_errors('set success');
266       		result := 'COMPLETE';
267     	ELSIF (funcmode= 'CANCEL') THEN
268       		result := 'COMPLETE';
269     	END IF;
270 EXCEPTION
271     WHEN OTHERS THEN
272       WF_CORE.Context(OKS_CT_EVENTS_WFA.l_pkg_name, 'Get_Values',
273 		      itemtype, itemkey, actid, funcmode);
274       RAISE;
275 END GET_VALUES;
276 
277 
278 PROCEDURE CREATE_SR (
279 		itemtype      	IN VARCHAR2,
280 		itemkey       	IN VARCHAR2,
281 		actid         	IN NUMBER,
282 		funcmode      	IN VARCHAR2,
283 		result    	OUT NOCOPY VARCHAR2
284 ) IS
285 	l_return_status	VARCHAR2(1);
286     	l_msg_count		NUMBER;
287     	l_msg_data		VARCHAR2(2000);
288 	l_user_id			NUMBER;
289 	l_login_id		NUMBER;
290  	l_status_name		CS_INCIDENT_STATUSES.NAME%TYPE;
291 	l_severity_name	    CS_INCIDENT_SEVERITIES.NAME%TYPE;
292 	l_urgency_name		CS_INCIDENT_URGENCIES.NAME%TYPE;
293 	l_type_name		    CS_INCIDENT_TYPES.NAME%TYPE;
294 	l_customer_id		NUMBER;
295 	--NPALEPU
296         --09-AUG-2005
297         --TCA Project
298         --Replaced RA_CUSTOMERS.CUSTOMER_NAME%TYPE with HZ_PARTIES.PARTY_NAME%TYPE as RA_CUSTOMERS is obsoleted.
299         /*l_customer_name           RA_CUSTOMERS.CUSTOMER_NAME%TYPE; */
300         l_customer_name         HZ_PARTIES.PARTY_NAME%TYPE;
301         --END NPALEPU
302 	l_request_id		NUMBER;
303 	l_request_number	CS_INCIDENTS_V.INCIDENT_NUMBER%TYPE;
304 	l_request_summary	CS_INCIDENTS_V.SUMMARY%TYPE;
305     l_org_id            NUMBER;
306     l_request_id_in     NUMBER;
307     l_request_number_in NUMBER;
308 
309 	l_call_id			NUMBER;
310     l_interaction_id	NUMBER;
311     l_workflow_process_id			NUMBER;
312 	l_itemkey			VARCHAR2(80);
313 	l_return_wf_status	VARCHAR2(1);
314 	l_event_id		NUMBER;
315     l_oce_id		NUMBER;
316     l_k_line_id		NUMBER;
317  	l_errmsg_name		VARCHAR2(30);
318     l_API_ERROR		EXCEPTION;
319 
320 
321     l_service_request_rec   CS_SERVICEREQUEST_PUB.SERVICE_REQUEST_REC_TYPE;
322     l_notes_tab             CS_SERVICEREQUEST_PUB.NOTES_TABLE;
323     l_contacts_tab          CS_SERVICEREQUEST_PUB.CONTACTS_TABLE;
324     l_individual_owner      NUMBER;
325     l_group_owner           NUMBER;
326     l_individual_type       VARCHAR2(100);
327     l_resp_appl_id	    number;
328     l_resp_id		    number;
329     l_SR_type_id	    number;
330 
331 
332 
333  /*  Modified by Jvorugan for Bug:4915689
334     Now it considers the relationship status between Contract party and its contacts
335 
336    CURSOR  contact_point IS
337     select  chcpv.party_id party_id,
338             chcpv.contact_point_id contact_point_id,
339             chcpv.CONTACT_POINT_TYPE CONTACT_POINT_TYPE,
340             chcpv.PRIMARY_FLAG PRIMARY_FLAG,
341             chcpv.party_type party_type
342     from    csc_hz_parties_v chpv,
343             csc_hz_contact_points_v chcpv
344     where   obj_party_type = 'ORGANIZATION'
345     and     object_id = (select object1_id1 from  okc_k_party_roles_v
346                     where jtot_object1_code = 'OKX_PARTY'
347                     and     chr_id = (select chr_id from okc_k_lines_v where id = l_k_line_id)
348                     and     rownum = 1) --l_party_id
349     and     chpv.party_id = chcpv.party_id --and     chpv.subject_id = chcpv.party_id
350     and     chcpv.PRIMARY_FLAG = 'Y'
351     and     chcpv.party_TYPE = 'PARTY_RELATIONSHIP' --'PERSON'
352     and     rownum = 1;
353     */
354 
355     CURSOR    contact_point IS
356      select    chcpv.party_id party_id,
357             chcpv.contact_point_id contact_point_id,
358             chcpv.CONTACT_POINT_TYPE CONTACT_POINT_TYPE,
359             chcpv.PRIMARY_FLAG PRIMARY_FLAG,
360             chcpv.party_type party_type,
361             chpv.sub_status
362     from    csc_hz_parties_v chpv,
363             csc_hz_contact_points_v chcpv,
364             hz_relationships r
365     where   chpv.obj_party_type = 'ORGANIZATION'
366     and     chpv.object_id = (select object1_id1 from  okc_k_party_roles_v
367                     where jtot_object1_code = 'OKX_PARTY'
368                     and chr_id = (select chr_id from okc_k_lines_v where
369                                          id = l_k_line_id)
370                     and    rownum = 1)
371     and    chpv.party_id = chcpv.party_id
372     and    chcpv.PRIMARY_FLAG = 'Y'
373     and    chcpv.party_TYPE = 'PARTY_RELATIONSHIP' --'PERSON'
374     and    chpv.subject_id = r.subject_id
375     and    chpv.object_id = r.object_id
376     and    r.status = 'A'
377     and    chpv.sub_status = 'A'
378     and    chpv.obj_status = 'A'
379     and    rownum = 1;
380 
381 
382 
383     CURSOR status IS
384     select assent.opn_code opn_code
385     from   okc_assents_v assent,
386            okc_k_lines_v cle ,
387            okc_k_headers_v okh
388     where  cle.id = l_k_line_id
389     and    okh.id = cle.dnz_chr_id
390     and    assent.sts_code = cle.sts_code
391     and    assent.scs_code = okh.scs_code
392     and    assent.opn_code = 'ENTITLE'
393     and    assent.allowed_yn = 'Y';
394 
395     CURSOR appscntxt IS
396     select resp.responsibility_id,
397            resp.responsibility_application_id
398     from   fnd_user_resp_groups resp,
399            cs_sr_type_mapping srmap
400     where  resp.user_id    = l_user_id
401     and    resp.responsibility_id = srmap.responsibility_id
402     and    srmap.incident_type_id = l_SR_type_id
403     and    rownum = 1;
404 
405 
406 BEGIN
407 --log_errors('entered create_sr');
408 
409 
410     	IF (funcmode= 'RUN') THEN
411 
412 
413         l_user_id   := wf_engine.GetItemAttrNumber(
414 				    itemtype 	=> itemtype,
415     				itemkey 	=> itemkey,
416     				aname  	=> 'USER_ID');
417 
418                     --log_errors('entered create_sr USER_ID');
419 
420 		l_customer_id := wf_engine.GetItemAttrNumber(
421 				itemtype 	=> itemtype,
422     				itemkey 	=> itemkey,
423     				aname  	=> 'CUSTOMER_ID');
424 
425                     --log_errors(' create_sr CUSTOMER_ID');
426 
427 
428 		l_type_name := wf_engine.GetItemAttrText(
429 				itemtype 	=> itemtype,
430     				itemkey 	=> itemkey,
431     				aname  	=> 'REQUEST_TYPE');
432                      --log_errors('entered create_sr 2');
433 
434 
435 		l_status_name := wf_engine.GetItemAttrText(
436 				itemtype 	=> itemtype,
437     				itemkey 	=> itemkey,
438     				aname  	=> 'REQUEST_STATUS');  --log_errors('entered create_sr 3');
439 
440 		l_severity_name := wf_engine.GetItemAttrText(
441 				itemtype 	=> itemtype,
442     				itemkey 	=> itemkey,
443     				aname  	=> 'REQUEST_SEVERITY');  --log_errors('entered create_sr 4');
444 
445 		l_request_summary := wf_engine.GetItemAttrText(
446 				itemtype 	=> itemtype,
447     				itemkey 	=> itemkey,
448     				aname  	=> 'REQUEST_SUMMARY');  --log_errors('entered create_sr 5');
449 
450         l_k_line_id := wf_engine.GetItemAttrNumber(
451 				itemtype 	=> itemtype,
452     				itemkey 	=> itemkey,
453     				aname  	=> 'K_LINE_ID');
454 
455 
456 --log_errors('customer name: '||l_customer_id);
457 --log_errors('request summ: '||l_request_summary);
458 
459 
460         CS_ServiceRequest_PUB.initialize_rec(l_service_request_rec);
461 
462 -- uptaking function Security based SR creation introduced by SR team in 11.5.9
463 -- bug 3025009
464 
465     if nvl(fnd_profile.value('CS_SR_USE_TYPE_RESPON_SETUP'),'NO') = 'YES' then
466 
467   	  fnd_profile.get('INC_DEFAULT_INCIDENT_TYPE',l_SR_type_id);
468 
469       for appscntxt_rec in appscntxt loop
470 	  l_resp_id 		:= appscntxt_rec.responsibility_id;
471         l_resp_appl_id 		:= appscntxt_rec.responsibility_application_id;
472       end loop;
473 
474     end if;
475 
476         l_service_request_rec.summary 		:= l_request_summary;
477         l_service_request_rec.caller_type 	:= 'ORGANIZATION';
478         l_service_request_rec.customer_id 	:= l_customer_id ;
479 -- added because it is a required parameter to SR API. bug 2960675
480 	  l_service_request_rec.verify_cp_flag 	:= 'N';
481 
482 
483 
484 /* -- code bumped back to SR API version 2.0
485 
486         l_service_request_rec.creation_program_code    := 'OKS_CT_EVENTS_WFA';
487         l_service_request_rec.last_update_program_code := 'OKS_CT_EVENTS_WFA';
488         l_service_request_rec.sr_creation_channel      := 'AUTOMATIC';
489 
490 */
491 
492         for  ct_pt_rec in contact_point loop
493 
494         l_contacts_tab(1).party_id :=           ct_pt_rec.party_id;
495         l_contacts_tab(1).contact_point_id :=   ct_pt_rec.contact_point_id;
496         l_contacts_tab(1).CONTACT_POINT_TYPE := ct_pt_rec.CONTACT_POINT_TYPE;
497         l_contacts_tab(1).PRIMARY_FLAG :=       ct_pt_rec.PRIMARY_FLAG;
498         l_contacts_tab(1).CONTACT_TYPE :=       ct_pt_rec.party_type;
499 
500         end loop;
501 
502         for sts_rec in status loop
503 
504 /*-- code bumped back to SR API version 2.0
505 
506              CS_SERVICEREQUEST_PUB.CREATE_SERVICEREQUEST(
507                 p_api_version			        => 3.0, --2.0, changed from 11.5.9
508                 p_init_msg_list		            => FND_API.G_TRUE, --FND_API.G_FALSE, --commented to clean the message stack
509                 p_commit		                => FND_API.G_FALSE, --FND_API.G_TRUE,
510                 x_return_status	                => l_return_status,
511                 x_msg_count			            => l_msg_count,
512                 x_msg_data			            => l_msg_data,
513 		p_resp_appl_id			=> l_resp_appl_id,
514 		p_resp_id			=> l_resp_id,
515                 p_user_id			            => l_user_id,
516                 p_service_request_rec           => l_service_request_rec,
517                 p_notes                         => l_notes_tab,
518                 p_contacts                      => l_contacts_tab,
519                 x_request_id			        => l_request_id,
520                 x_request_number		        => l_request_number,
521                 x_interaction_id                => l_interaction_id,
522                 x_workflow_process_id           => l_workflow_process_id,
523               -- Added for assignment manager changes for 11.5.9
524                 x_individual_owner              => l_individual_owner,
525                 x_group_owner                   => l_group_owner,
526                 x_individual_type               => l_individual_type);
527 */
528 
529 
530 
531              CS_SERVICEREQUEST_PUB.CREATE_SERVICEREQUEST(
532                 p_api_version			        => 2.0,
533                 p_init_msg_list		            => FND_API.G_TRUE, --FND_API.G_FALSE, --commented to clean the message stack. bug 2960675.
534                 p_commit		                => FND_API.G_FALSE, --FND_API.G_TRUE,
535                 x_return_status	                => l_return_status,
536                 x_msg_count			            => l_msg_count,
537                 x_msg_data			            => l_msg_data,
538 		p_resp_appl_id			=> l_resp_appl_id,
539 		p_resp_id			=> l_resp_id,
540                 p_user_id			            => l_user_id,
541                 p_service_request_rec           => l_service_request_rec,
542                 p_notes                         => l_notes_tab,
543                 p_contacts                      => l_contacts_tab,
544                 x_request_id			        => l_request_id,
545                 x_request_number		        => l_request_number,
546                 x_interaction_id                => l_interaction_id,
547                 x_workflow_process_id           => l_workflow_process_id);
548 
549 
550 	       	WF_ENGINE.SetItemAttrText(
551     					itemtype 	=> itemtype,
552     					itemkey 	=> itemkey,
553     					aname  	=> 'REQUEST_NUMBER',
554 					avalue	=> l_request_number);
555 
556 
557     		 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
558 
559              WF_ENGINE.SetItemAttrText(
560     					itemtype 	=> itemtype,
561     					itemkey 	=> itemkey,
562     					aname  	=> 'L_MSG_DATA',
563 					    avalue	=> 'API error: CS_SERVICEREQUEST_PUB.CREATE_SERVICEREQUEST '||l_msg_data);
564 
565         		WF_CORE.context(
566 				pkg_name	=>  OKS_CT_EVENTS_WFA.l_pkg_name,
567 			 	proc_name	=>  'CREATE_SR',
568 			 	arg1		=>  'p_itemkey =>'||itemkey );
569 
570                 result := 'COMPLETE:SR_CREATE_ERROR';
571 
572              else
573 
574               WF_ENGINE.SetItemAttrText(
575     					itemtype 	=> itemtype,
576     					itemkey 	=> itemkey,
577     					aname  	=> 'L_MSG_DATA',
578 					    avalue	=> 'success ');
579 
580                 result := 'COMPLETE:SR_CREATED';
581 
582              END IF;
583 
584            end loop;
585 
586            If result is NULL Then
587 
588             result := 'COMPLETE:NOT_ENTITLE';
589 
590            end if;
591 
592       --		result := 'COMPLETE';
593     	ELSIF (funcmode= 'CANCEL') THEN
594       		result := 'COMPLETE';
595     	END IF;
596 
597 EXCEPTION
598     WHEN OTHERS THEN
599       WF_CORE.Context(OKS_CT_EVENTS_WFA.l_pkg_name, 'Create_SR',
600 		      itemtype, itemkey, actid, funcmode);
601       RAISE;
602 
603 END CREATE_SR;
604 
605 
606 -- OUT
607 --   Resultout    - 'COMPLETE:T' if receiver is found
608 --		  - 'COMPLETE:F' if receiver is not found
609 --
610 PROCEDURE VALIDATE_RECEIVER (
611 		itemtype	in varchar2,
612 		itemkey  	in varchar2,
613 		actid		in number,
614 		funcmode	in varchar2,
615 		result		out nocopy varchar2	) is
616 	l_receiver_name	VARCHAR2(30);
617 BEGIN
618 	--
619   	-- RUN mode - activity
620 	--
621 
622   	IF funcmode = 'RUN' THEN
623 		l_receiver_name := wf_engine.GetItemAttrText(
624 					itemtype 	=> itemtype,
625     					itemkey 	=> itemkey,
626     					aname  	=> 'FORWARD_TO_USERNAME' );
627 
628 
629 		IF  l_receiver_name IS NULL then
630 			--
631 			result := 'COMPLETE:F';
632 			--
633 		ELSE
634 			-- Write your own code here to validate the receiver name here
635 			--
636 			result := 'COMPLETE:T';
637 			--
638 		END IF;
639 	--
640   	-- CANCEL mode - activity
641 	--
642   	ELSIF (funcmode = 'CANCEL') THEN
643 		--
644     		result := 'COMPLETE:';
645     		return;
646 	--
647 	-- TIMEOUT mode
648 	--
649 	ELSIF (funcmode = 'TIMEOUT') THEN
650 		result := 'COMPLETE:';
651 		return;
652 	END IF;
653 EXCEPTION
654 	WHEN OTHERS then
655 		WF_CORE.context(OKS_CT_EVENTS_WFA.l_pkg_name,'Validate_Receiver',itemtype,itemkey,actid,funcmode);
656 		raise;
657 END VALIDATE_RECEIVER;
658 
659 PROCEDURE UPDATE_EVENT (
660 		itemtype	in varchar2,
661 		itemkey  	in varchar2,
662 		actid		in number,
663 		funcmode	in varchar2,
664 		result		out nocopy varchar2	) is
665 	l_event_id	NUMBER;
666 BEGIN
667 	--
668   	-- RUN mode - activity
669 	--
670 
671   	IF funcmode = 'RUN' THEN
672 		/*l_event_id := wf_engine.GetItemAttrNumber(
673 					itemtype 	=> itemtype,
674     					itemkey 	=> itemkey,
675     					aname  	=> 'EVENT_ID' );*/
676 
677                         --log_errors('updating events ');
678 
679 	/*	UPDATE CS_EVENTS
680 			SET LAST_EVENT_DATE = sysdate
681 		WHERE EVENT_ID = l_event_id;*/
682 
683 		result := 'COMPLETE';
684 	--
685   	-- CANCEL mode - activity
686 	--
687   	ELSIF (funcmode = 'CANCEL') THEN
688 		--
689     		result := 'COMPLETE:';
690     		return;
691 	--
692 	-- TIMEOUT mode
693 	--
694 	ELSIF (funcmode = 'TIMEOUT') THEN
695 		result := 'COMPLETE:';
696 		return;
697 	END IF;
698 EXCEPTION
699 	WHEN OTHERS then
700 		WF_CORE.context(OKS_CT_EVENTS_WFA.l_pkg_name,'Update_Event',itemtype,itemkey,actid,funcmode);
701 		raise;
702 END UPDATE_EVENT;
703 
704 END OKS_CT_EVENTS_WFA;