DBA Data[Home] [Help]

PACKAGE BODY: APPS.IEM_MAILPREPROCWF_PUB

Source


1 package body IEM_Mailpreprocwf_PUB as
2 /* $Header: iempwfpb.pls 120.4 2006/06/14 01:10:54 rtripath noship $*/
3 
4 /**********************Global Variable Declaration **********************/
5 
6 g_msg_count	number:=0;
7 g_first		number;
8 g_part_count	number:=0;
9 TYPE g_theme_part_rec is RECORD(
10 part_id		number,
11 theme		varchar2(150),
12 weight		number);
13 TYPE t_part_theme_tab IS TABLE OF g_theme_part_rec
14 INDEX By BINARY_INTEGER;
15 G_PKG_NAME	varchar2(30):='IEM_Mailpreprocwf_PUB';
16 G_DEFAULT_FOLDER	varchar2(50):='/Inbox';
17 G_APP_ID		number:=520;
18 G_LOG			char(1):='T';
19 g_topscore		number;
20 g_topclass		varchar2(100);
21 g_flow			varchar2(1);
22 g_process			varchar2(1);
23 g_outval			varchar2(200);
24 
25 /**********************End Of Global Variable Declaration *******************/
26 
27 	PROCEDURE 	IEM_STARTPROCESS(
28      		WorkflowProcess IN VARCHAR2,
29      		ItemType in VARCHAR2 ,
30 			ItemKey in number,
31 			p_itemuserkey in varchar2,
32 			p_msgid in varchar2,
33 			p_msgsize in number,
34 			p_sender in varchar2,
35 			p_username in varchar2,
36 			p_domain in varchar2,
37 			p_priority in varchar2,
38 			p_msg_status in varchar2,
39 			p_email_account_id in number,
40 			p_flow in varchar2,
41 			x_outval out nocopy varchar2,
42 			x_process		OUT NOCOPY varchar2)
43 
44 			IS
45 
46           l_proc_name    varchar2(20):='IEM_STARTPROCESS';
47 		l_ret		number;
48 		l_ret1		number;
49 
50 begin
51                -- invoke an instance of workflow process
52                     wf_engine.CreateProcess( ItemType => itemtype,
53                     ItemKey  => ItemKey,
54                     process  => WorkflowProcess );
55                wf_engine.SetItemAttrNumber(itemtype => itemtype,
56                itemkey  => itemkey,
57                aname      => 'MSGID',
58                avalue     =>  p_msgid );
59           wf_engine.SetItemAttrText (itemtype => itemtype,
60          itemkey  => itemkey,
61          aname      => 'USER_NAME',
62          avalue     =>  p_username );
63          wf_engine.SetItemAttrText (itemtype => itemtype,
64          itemkey  => itemkey,
65          aname      => 'DOMAIN',
66          avalue     =>  p_domain );
67 		G_STAT:='S'	;		-- Process Intialized To Success
68 		G_LOG:='T';
69 		g_flow:=p_flow;		-- Indicate new flow or old flow
70 		g_process:='N';
71 		g_outval:=null;
72 
73 	IF p_sender is not null then 	-- Regular Processing
74 
75                wf_engine.SetItemAttrNumber ( itemtype => itemtype,
76                itemkey  => itemkey,
77                aname => 'MSG_SIZE',
78                avalue     =>  p_msgsize);
79 
80           wf_engine.SetItemAttrText (itemtype => itemtype,
81           itemkey  => itemkey,
82           aname      => 'SENDER',
83           avalue     =>  p_sender );
84 
85 
86          wf_engine.SetItemAttrText (itemtype => itemtype,
87          itemkey  => itemkey,
88 		aname      => 'PRIORITY',
89          avalue     =>  p_priority );
90 
91          wf_engine.SetItemAttrText (itemtype => itemtype,
92          itemkey  => itemkey,
93          aname      => 'MSG_STATUS',
94          avalue     =>  p_msg_status );
95 	ELSE					-- Processing The Retry Folder
96 		wf_engine.SetItemAttrNumber (itemtype => ItemType,
97 	      				itemkey  => ItemKey,
98   	      				aname 	 => 'EMAILACCOUNTID',
99 					avalue	 =>  p_email_account_id);
100 	END IF;
101          wf_engine.StartProcess(itemtype => itemtype,
102          itemkey    => itemkey );
103 	    x_outval:=g_outval;
104 	    x_process:=g_process;
105    exception
106           when others then
107                wf_core.context(G_PKG_NAME, l_proc_name,
108                itemtype, itemkey);
109 			G_STAT:='E';
110                raise;
111 end IEM_STARTPROCESS;
112 
113 -- PROCEDURE IEM_WF_CHKAUTH
114 --
115 -- Check The user and domain for a valid user
116 --
117 -- IN
118 --   itemtype  - type of the current item
119 --   itemkey   - key of the current item
120 --   actid     - process activity instance id
121 --   funcmode  - function execution mode. this is set by the engine
122 --               as either 'RUN', 'CANCEL', 'TIMEOUT'
123 -- OUT
124 --   result
125 --       - COMPLETE[:<result>]
126 --           activity has completed with the indicated result
127 --       - WAITING
128 --           activity is waiting for additional transitions
129 --       - DEFERED
130 --           execution should be defered to background
131 --       - NOTIFIED[:<notification_id>:<assigned_user>]
132 --           activity has notified an external entity that this
133 --           step must be performed.  A call to wf_engine.CompleteActivty
134 --           will signal when this step is complete.  Optional
135 --           return of notification ID and assigned user.
136 --       - ERROR[:<error_code>]
137 --           function encountered an error.
138 procedure IEM_WF_CHKAUTH(
139     itemtype  in varchar2,
140     itemkey   in varchar2,
141     actid     in number,
142     funcmode  in varchar2,
143     result    in out nocopy  varchar2)
144 is
145 
146 l_proc_name	varchar2(20):='IEM_WF_CHKAUTH';
147 l_user	varchar2(40);
148 l_domain	varchar2(30);
149 l_pass	varchar2(100);
150 l_ret	number;
151 l_ret1	number;
152 l_str	varchar2(200);
153 l_msgid	number;
154 l_email_account_id	number;
155 l_errmsg	varchar2(200);
156 l_sender	varchar2(70);
157 l_db_server_id	number;
158 l_stat	varchar2(10);
159 l_count	number;
160 l_data	varchar2(255);
161 begin
162 	l_msgid := wf_engine.GetItemAttrText(
163 					itemtype => ItemType,
164     					itemkey => ItemKey,
165     					aname  	=> 'MSGID' );
166 	select email_account_id into l_email_account_id from
167 	iem_rt_preproc_emails where message_id=l_msgid;
168 		wf_engine.SetItemAttrNumber (itemtype => ItemType,
169 	      				itemkey  => ItemKey,
170   	      				aname 	 => 'EMAILACCOUNTID',
171 					avalue	 =>  l_email_account_id);
172 		result:='COMPLETE:T';
173 EXCEPTION
174   when others then
175     -- The line below records this function call in the error system
176     -- in the case of an exception.
177 		G_STAT:='E';
178     wf_core.context(G_PKG_NAME, l_proc_name,
179                     itemtype, itemkey, to_char(actid), funcmode);
180     raise;
181 end IEM_WF_CHKAUTH;
182 
183 -- PROCEDURE IEM_WF_CHKUSERGRP
184 --
185 -- From the user name find the corresponding activity
186 --
187 -- IN
188 --   itemtype  - type of the current item
189 --   itemkey   - key of the current item
190 --   actid     - process activity instance id
191 --   funcmode  - function execution mode. this is set by the engine
192 --               as either 'RUN', 'CANCEL', 'TIMEOUT'
193 -- OUT
194 --   result
195 --       - COMPLETE[:<result>]
196 --           activity has completed with the indicated result
197 --       - WAITING
198 --           activity is waiting for additional transitions
199 --       - DEFERED
200 --           execution should be defered to background
201 --       - NOTIFIED[:<notification_id>:<assigned_user>]
202 --           activity has notified an external entity that this
203 --           step must be performed.  A call to wf_engine.CompleteActivty
204 --           will signal when this step is complete.  Optional
205 --           return of notification ID and assigned user.
206 --       - ERROR[:<error_code>]
207 --           function encountered an error.
208 procedure IEM_WF_CHKUSERGRP(
209     itemtype  in varchar2,
210     itemkey   in varchar2,
211     actid     in number,
212     funcmode  in varchar2,
213     result    in out nocopy  varchar2)
214 is
215 l_user	varchar2(40);
216 l_proc_name	varchar2(20):='IEM_WF_CHKUSERGRP';
217 l_ret		number;
218 l_msgid		number;
219 begin
220 	l_user := wf_engine.GetItemAttrText(
221 					itemtype => ItemType,
222     					itemkey => ItemKey,
223     					aname  	=> 'USER_NAME' );
224 	l_msgid := wf_engine.GetItemAttrText(
225 					itemtype => ItemType,
226     					itemkey => ItemKey,
227     					aname  	=> 'MSGID' );
228 result:='COMPLETE:'||upper(l_user);
229 exception
230   when others then
231     -- The line below records this function call in the error system
232     -- in the case of an exception.
233 		G_STAT:='E';
234     wf_core.context(G_PKG_NAME, l_proc_name,
235                     itemtype, itemkey, to_char(actid), funcmode);
236     raise;
237 end IEM_WF_CHKUSERGRP;
238 
239 -- PROCEDURE IEM_WF_GETEXTHEADER
240 --
241 -- Get The extended header for the message id
242 --
243 -- IN
244 --   itemtype  - type of the current item
245 --   itemkey   - key of the current item
246 --   actid     - process activity instance id
247 --   funcmode  - function execution mode. this is set by the engine
248 --               as either 'RUN', 'CANCEL', 'TIMEOUT'
249 -- OUT
250 --   result
251 --       - COMPLETE[:<result>]
252 --           activity has completed with the indicated result
253 --       - WAITING
254 --           activity is waiting for additional transitions
255 --       - DEFERED
256 --           execution should be defered to background
257 --       - NOTIFIED[:<notification_id>:<assigned_user>]
258 --           activity has notified an external entity that this
259 --           step must be performed.  A call to wf_engine.CompleteActivty
260 --           will signal when this step is complete.  Optional
261 --           return of notification ID and assigned user.
262 --       - ERROR[:<error_code>]
263 --           function encountered an error.
264 
265 procedure IEM_WF_GETEXTHEADER(
266     itemtype  in varchar2,
267     itemkey   in varchar2,
268     actid     in number,
269     funcmode  in varchar2,
270     result    in out nocopy  varchar2)
271 is
272 l_proc_name	varchar2(20):='IEM_WF_GETEXTHEADER';
273 l_ret		number;
274 l_msgid		number;
275 l_str		varchar2(200);
276 l_errmsg		varchar2(200);
277 ext_hdr_exception   EXCEPTION;
278 begin
279 	result:='COMPLETE:';
280 exception
281   when ext_hdr_exception then
282 	wf_engine.abortprocess(itemtype,itemkey);
283 	result:='COMPLETE:';
284   when others then
285     -- The line below records this function call in the error system
286     -- in the case of an exception.
287     wf_core.context(G_PKG_NAME, l_proc_name,
288                     itemtype, itemkey, to_char(actid), funcmode);
289 		G_STAT:='E';
290     raise;
291 end IEM_WF_GETEXTHEADER;
292 
293 -- PROCEDURE IEM_WF_MSGHDR
294 --
295 -- Process The Message To get the standard Header and populate the attribute
296 --
297 -- IN
298 --   itemtype  - type of the current item
299 --   itemkey   - key of the current item
300 --   actid     - process activity instance id
301 --   funcmode  - function execution mode. this is set by the engine
302 --               as either 'RUN', 'CANCEL', 'TIMEOUT'
303 -- OUT
304 --   result
305 --       - COMPLETE[:<result>]
306 --           activity has completed with the indicated result
307 --       - WAITING
308 --           activity is waiting for additional transitions
309 --       - DEFERED
310 --           execution should be defered to background
311 --       - NOTIFIED[:<notification_id>:<assigned_user>]
312 --           activity has notified an external entity that this
313 --           step must be performed.  A call to wf_engine.CompleteActivty
314 --           will signal when this step is complete.  Optional
315 --           return of notification ID and assigned user.
316 --       - ERROR[:<error_code>]
317 --           function encountered an error.
318 
319 procedure IEM_WF_MSGHDR(
320     itemtype  in varchar2,
321     itemkey   in varchar2,
322     actid     in number,
323     funcmode  in varchar2,
324     result    in out nocopy  varchar2)
325 is
326 l_ret	number;
327 l_proc_name	varchar2(20):='IEM_WF_MSGHDR';
328 l_str		varchar2(200);
329 l_total	number;
330 l_subject	varchar2(1000);
331 l_sender	varchar2(70);
332 l_to_recip	varchar2(240);
333 l_cc_recip	varchar2(240);
334 l_fwd_recip	varchar2(100);
335 l_frm_str	varchar2(80);
336 l_sent_date	date;
337 l_sent_dt1	date;
338 l_reply_to	varchar2(100);
339 l_msg_size 	number;
340 l_msgid 	number;
341 l_errmsg		varchar2(200);
342 msg_hdr_exception	EXCEPTION;
343 begin
344 	l_msgid := wf_engine.GetItemAttrNumber(
345 					itemtype => ItemType,
346     					itemkey => ItemKey,
347     					aname  	=> 'MSGID' );
348 	select to_str,cc_str,from_str,reply_to_str,subject,message_size into
349 	l_to_recip,l_cc_recip,l_frm_str,l_reply_to,l_subject,l_msg_size
350 	from iem_ms_base_headers
351 	where message_id=l_msgid;
352 		wf_engine.SetItemAttrText (itemtype => ItemType,
353 	      				itemkey  => ItemKey,
354   	      				aname 	 => 'MSG_TO',
355 					avalue	 =>  l_to_recip);
356 		wf_engine.SetItemAttrText (itemtype => ItemType,
357 	      				itemkey  => ItemKey,
358   	      				aname 	 => 'MSG_FROM',
359 					avalue	 =>  l_frm_str);
360 		wf_engine.SetItemAttrText (itemtype => ItemType,
361 	      				itemkey  => ItemKey,
362   	      				aname 	 => 'MSG_CC',
363 					avalue	 =>  l_cc_recip);
364 		wf_engine.SetItemAttrText (itemtype => ItemType,
365 	      				itemkey  => ItemKey,
366   	      				aname 	 => 'SUBJECT',
367 					avalue	 =>  l_subject);
368 		wf_engine.SetItemAttrText (itemtype => ItemType,
369 	      				itemkey  => ItemKey,
370   	      				aname 	 => 'SENDER',
371 					avalue	 =>  l_frm_str);
372 		wf_engine.SetItemAttrText (itemtype => ItemType,
373 	      				itemkey  => ItemKey,
374   	      				aname 	 => 'REPLY_TO',
375 					avalue	 =>  l_reply_to);
376 		wf_engine.SetItemAttrNumber (itemtype => ItemType,
377 	      				itemkey  => ItemKey,
378   	      				aname 	 => 'MSG_SIZE',
379 					avalue	 =>  l_msg_size);
380    		result:='COMPLETE:';
381 exception
382   when msg_hdr_exception then
383 	if g_flow='N' then
384 		G_STAT:='E';
385 	end if;
386 	wf_engine.abortprocess(itemtype,itemkey);
387 	result:='COMPLETE:';
388   when others then
389     -- The line below records this function call in the error system
390     -- in the case of an exception.
391     wf_core.context(G_PKG_NAME, l_proc_name,
392                     itemtype, itemkey, to_char(actid), funcmode);
393 		G_STAT:='E';
394     raise;
395 end IEM_WF_MSGHDR;
396 
397 -- PROCEDURE IEM_WF_GETPART
398 --
399 -- Process The Message To get the part attached with the message
400 --
401 -- IN
402 --   itemtype  - type of the current item
403 --   itemkey   - key of the current item
404 --   actid     - process activity instance id
405 --   funcmode  - function execution mode. this is set by the engine
406 --               as either 'RUN', 'CANCEL', 'TIMEOUT'
407 -- OUT
408 --   result
409 --       - COMPLETE[:<result>]
410 --           activity has completed with the indicated result
411 --       - WAITING
412 --           activity is waiting for additional transitions
413 --       - DEFERED
414 --           execution should be defered to background
415 --       - NOTIFIED[:<notification_id>:<assigned_user>]
416 --           activity has notified an external entity that this
417 --           step must be performed.  A call to wf_engine.CompleteActivty
418 --           will signal when this step is complete.  Optional
419 --           return of notification ID and assigned user.
420 --       - ERROR[:<error_code>]
421 --           function encountered an error.
422 
423 procedure IEM_WF_GETPART(
424     itemtype  in varchar2,
425     itemkey   in varchar2,
426     actid     in number,
427     funcmode  in varchar2,
428     result    in out nocopy  varchar2)
429 is
430  l_proc_name	varchar2(20):='IEM_WF_GETPART';
431  l_errtext	varchar2(100);
432  l_msg_id		number;
433  l_ret		number;
434  l_flag		number:=1;
435  l_partcount	number:=1;
436  l_themecount	number;
437  l_themeindex	binary_integer;
438  l_part_theme	number:=1;
439  l_count		number:=0;
440  l_errmsg		varchar2(300);
441  l_part		number;
442  l_str		varchar2(200);
443  get_part_exception	EXCEPTION;
444  begin
445 	result:='COMPLETE:';
446 exception
447   when get_part_exception then
448 	wf_engine.abortprocess(itemtype,itemkey);
449 	result:='COMPLETE:';
450   when others then
451     -- The line below records this function call in the error system
452     -- in the case of an exception.
453     wf_core.context(G_PKG_NAME, l_proc_name,
454                     itemtype, itemkey, to_char(actid), funcmode);
455 		G_STAT:='E';
456     raise;
457 end IEM_WF_GETPART;
458 
459 -- PROCEDURE IEM_WF_AUTHFAILED
460 --
461 -- Show a Message that authorisation is failed and terminate the process
462 --
463 -- IN
464 --   itemtype  - type of the current item
465 --   itemkey   - key of the current item
466 --   actid     - process activity instance id
467 --   funcmode  - function execution mode. this is set by the engine
468 --               as either 'RUN', 'CANCEL', 'TIMEOUT'
469 -- OUT
470 --   result
471 --       - COMPLETE[:<result>]
472 --           activity has completed with the indicated result
473 --       - WAITING
474 --           activity is waiting for additional transitions
475 --       - DEFERED
476 --           execution should be defered to background
477 --       - NOTIFIED[:<notification_id>:<assigned_user>]
478 --           activity has notified an external entity that this
479 --           step must be performed.  A call to wf_engine.CompleteActivty
480 --           will signal when this step is complete.  Optional
481 --           return of notification ID and assigned user.
482 --       - ERROR[:<error_code>]
483 --           function encountered an error.
484 
485 procedure IEM_WF_AUTHFAILED(
486     itemtype  in varchar2,
487     itemkey   in varchar2,
488     actid     in number,
489     funcmode  in varchar2,
490     result    in out nocopy  varchar2)
491 is
492  l_proc_name	varchar2(20):='IEM_WF_AUTHFAILED';
493  auth_fail_exception	EXCEPTION;
494 l_msg_id		number;
495 begin
496 	l_msg_id := wf_engine.GetItemAttrNumber(
497 					itemtype => ItemType,
498     					itemkey => ItemKey,
499     					aname  	=> 'MSGID' );
500 	result:='COMPLETE:';
501 	raise auth_fail_exception;
502 exception
503   when auth_fail_exception then
504 		G_STAT:='E';
505 	raise;
506   when others then
507     -- The line below records this function call in the error system
508     -- in the case of an exception.
509     wf_core.context(G_PKG_NAME, l_proc_name,
510                     itemtype, itemkey, to_char(actid), funcmode);
511 		G_STAT:='E';
512     raise;
513 end IEM_WF_AUTHFAILED;
514 
515 -- PROCEDURE IEM_WF_ENQUEUE
516 --
517 -- Enqueue a processed mail in AQ2
518 --
519 -- IN
520 --   itemtype  - type of the current item
521 --   itemkey   - key of the current item
522 --   actid     - process activity instance id
523 --   funcmode  - function execution mode. this is set by the engine
524 --               as either 'RUN', 'CANCEL', 'TIMEOUT'
525 -- OUT
526 --   result
527 --       - COMPLETE[:<result>]
528 --           activity has completed with the indicated result
529 --       - WAITING
530 --           activity is waiting for additional transitions
531 --       - DEFERED
532 --           execution should be defered to background
533 --       - NOTIFIED[:<notification_id>:<assigned_user>]
534 --           activity has notified an external entity that this
535 --           step must be performed.  A call to wf_engine.CompleteActivty
536 --           will signal when this step is complete.  Optional
537 --           return of notification ID and assigned user.
538 --       - ERROR[:<error_code>]
539 --           functioN ENCOUNTered an error.
540 
541 procedure IEM_WF_ENQUEUE(
542     itemtype  in varchar2,
543     itemkey   in varchar2,
544     actid     in number,
545     funcmode  in varchar2,
546     result    in out nocopy  varchar2)
547 is
548  l_proc_name	varchar2(20):='IEM_WF_ENQUEUE';
549 l_msg_count number;
550 l_ret_status varchar2(40);
551 l_msg_data varchar2(240);
552 l_count	number;
553 i_count	number;
554 l_key1	varchar2(100);
555 l_val1	varchar2(300);
556 l_key2	varchar2(100);
557 l_val2	varchar2(300);
558 l_key3	varchar2(100);
559 l_val3	varchar2(300);
560 l_key4	varchar2(100);
561 l_val4	varchar2(300);
562 l_key5	varchar2(100);
563 l_val5	varchar2(300);
564 l_key6	varchar2(100);
565 l_val6	varchar2(300);
566 l_key7	varchar2(100);
567 l_val7	varchar2(300);
568 l_key8	varchar2(100);
569 l_val8	varchar2(300);
570 l_key9	varchar2(100);
571 l_val9	varchar2(300);
572 l_key10	varchar2(100);
573 l_val10	varchar2(300);
574 l_msg_id	number;
575 l_email_account_id	number;
576 l_priority	varchar2(128);
577 l_domain	varchar2(50);
578 l_user	varchar2(50);
579 l_smtpid	varchar2(240);
580 l_sender	varchar2(70);
581 l_sentdate	date;
582 l_msg_status	varchar2(30);
583 l_msg_size	number;
584 l_class_score	number;
585 l_subject	varchar2(1000);
586 l_class	varchar2(50);
587 l_to_recip	varchar2(240);
588 l_cc_recip	varchar2(240);
589 l_fwd_recip	varchar2(100);
590 l_frm_str	varchar2(80);
591 l_reply_to	varchar2(100);
592 l_ret		number;
593 l_media_id	number;
594 l_errmsg		varchar2(200);
595 l_str		varchar2(200);
596 l_nqstr		varchar2(2000);
597 l_customer_id	number;
598 enq_exception		EXCEPTION;
599 
600 begin
601 	result:='COMPLETE:';
602 exception
603   when enq_exception then
604 	wf_engine.abortprocess(itemtype,itemkey);
605 	result:='COMPLETE:';
606   when others then
607     -- The line below records this function call in the error system
608     -- in the case of an exception.
609     wf_core.context(G_PKG_NAME, l_proc_name,
610                     itemtype, itemkey, to_char(actid), funcmode);
611 		G_STAT:='E';
612     raise;
613 end IEM_WF_ENQUEUE;
614 
615 -- PROCEDURE IEM_WF_NOGRP
616 --
617 -- Process The mail when no user group are defined for the mail.
618 --
619 -- IN
620 --   itemtype  - type of the current item
621 --   itemkey   - key of the current item
622 --   actid     - process activity instance id
623 --   funcmode  - function execution mode. this is set by the engine
624 --               as either 'RUN', 'CANCEL', 'TIMEOUT'
625 -- OUT
626 --   result
627 --       - COMPLETE[:<result>]
628 --           activity has completed with the indicated result
629 --       - WAITING
630 --           activity is waiting for additional transitions
631 --       - DEFERED
632 --           execution should be defered to background
633 --       - NOTIFIED[:<notification_id>:<assigned_user>]
634 --           activity has notified an external entity that this
635 --           step must be performed.  A call to wf_engine.CompleteActivty
636 --           will signal when this step is complete.  Optional
637 --           return of notification ID and assigned user.
638 --       - ERROR[:<error_code>]
639 --           function encountered an error.
640 procedure IEM_WF_NOGRP(
641     itemtype  in varchar2,
642     itemkey   in varchar2,
643     actid     in number,
644     funcmode  in varchar2,
645     result    in out nocopy  varchar2)
646 is
647 l_proc_name	varchar2(20):='IEM_WF_NOGRP';
648 l_user		varchar2(50);
649 l_ret		number;
650 l_msg_id		number;
651 l_str		varchar2(200);
652 l_errmsg		varchar2(200);
653 begin
654 	l_msg_id := wf_engine.GetItemAttrNumber(
655 					itemtype => ItemType,
656     					itemkey => ItemKey,
657     					aname  	=> 'MSGID' );
658 	l_user := wf_engine.GetItemAttrText(
659 					itemtype => ItemType,
660     					itemkey => ItemKey,
661     					aname  	=> 'USER_NAME' );
662 result:='COMPLETE:';
663 exception
664   when others then
665     -- The line below records this function call in the error system
666     -- in the case of an exception.
667     wf_core.context(G_PKG_NAME, l_proc_name,
668                     itemtype, itemkey, to_char(actid), funcmode);
669 		G_STAT:='E';
670     raise;
671 end IEM_WF_NOGRP;
672 
673 -- PROCEDURE IEM_WF_IS_STRUCT
674 --
675 -- Do The Processing when the user belongs to Service
676 --
677 -- IN
678 --   itemtype  - type of the current item
679 --   itemkey   - key of the current item
680 --   actid     - process activity instance id
681 --   funcmode  - function execution mode. this is set by the engine
682 --               as either 'RUN', 'CANCEL', 'TIMEOUT'
683 -- OUT
684 --   result
685 --       - COMPLETE[:<result>]
686 --           activity has completed with the indicated result
687 --       - WAITING
688 --           activity is waiting for additional transitions
689 --       - DEFERED
690 --           execution should be defered to background
691 --       - NOTIFIED[:<notification_id>:<assigned_user>]
692 --           activity has notified an external entity that this
693 --           step must be performed.  A call to wf_engine.CompleteActivty
694 --           will signal when this step is complete.  Optional
695 --           return of notification ID and assigned user.
696 --       - ERROR[:<error_code>]
697 --           function encountered an error.
698 
699 procedure IEM_WF_IS_STRUCT(
700     itemtype  in varchar2,
701     itemkey   in varchar2,
702     actid     in number,
703     funcmode  in varchar2,
704     result    in out nocopy  varchar2)
705 is
706 l_ret	number;
707 l_ret1	number;
708 l_msg_id	number;
709 l_count	number;
710 l_struct	char(1):='F';
711 l_part         number;
712 l_flag         number:=1;
713 l_text         varchar2(700);
714 l_hlbuff       iem_im_wrappers_pvt.highlight_table;
715 l_text_query   varchar2(30):='X Structure ID Tag';
716 l_proc_name	varchar2(20):='IEM_WF_IS_STRUCT';
717 l_sender		varchar2(70);
718 l_errmsg		varchar2(200);
719 l_errtext		varchar2(200);
720 l_query		varchar2(1000);
721 struct_exception	EXCEPTION;
722 begin
723 		result:='COMPLETE:T';
724 exception
725   when struct_exception then
726 	if g_flow='N' then
727 		G_STAT:='E';
728 	end if;
729 	wf_engine.abortprocess(itemtype,itemkey);
730 	result:='COMPLETE:';
731   when others then
732     -- The line below records this function call in the error system
733     -- in the case of an exception.
734     wf_core.context(G_PKG_NAME, l_proc_name,
735                     itemtype, itemkey, to_char(actid), funcmode);
736 		G_STAT:='E';
737     raise;
738 end IEM_WF_IS_STRUCT;
739 
740 -- PROCEDURE IEM_WF_STRUCT_PROC
741 --
742 -- Node For Processing Structured Mail. This Will call another workflow start
743 -- process for processing structured e-mail.
744 --
745 -- IN
746 --   itemtype  - type of the current item
747 --   itemkey   - key of the current item
748 --   actid     - process activity instance id
749 --   funcmode  - function execution mode. this is set by the engine
750 --               as either 'RUN', 'CANCEL', 'TIMEOUT'
751 -- OUT
752 --   resulT
753 --       - COMPLETE[:<result>]
754 --           activity has completed with the indicated result
755 --       - WAITING
756 --           activity is waiting for additional transitions
757 --       - DEFERED
758 --           execution should be defered to background
759 --       - NOTIFIED[:<notification_id>:<assigned_user>]
760 --           activity has notified an external entity that this
761 --           step must be performed.  A call to wf_engine.CompleteActivty
762 --           will signal when this step is complete.  Optional
763 --           return of notification ID and assigned user.
764 --       - ERROR[:<error_code>]
765 --           function encountered an error.
766 
767 procedure IEM_WF_STRUCT_PROC(
768     itemtype  in varchar2,
769     itemkey   in varchar2,
770     actid     in number,
771     funcmode  in varchar2,
772     result    in out nocopy  varchar2)
773 is
774 l_item_type	varchar2(30); -- :=VALUE To be provided by VA Team
775 l_item_key	number;
776 l_wf_process	varchar2(30); --:=VALUE To be provided by VA Team
777 l_proc_name	varchar2(30):='IEM_WF_STRUCT_PROC';
778 l_msg_id		number;
779 l_ret_stat	varchar2(20);
780 
781 begin
782 			result:='COMPLETE:F';
783   exception
784   when others then
785     -- The line below records this function call in the error system
786     -- in the case of an exception.
787     wf_core.context(G_PKG_NAME,l_proc_name,
788                     itemtype, itemkey, to_char(actid), funcmode);
789 		G_STAT:='E';
790     raise;
791 end IEM_WF_STRUCT_PROC;
792 
793 -- PROCEDURE IEM_WF_BCC_TO
794 --
795 -- Node For BCC The mail to a reciepient .
796 --
797 -- IN
798 --   itemtype  - type of the current item
799 --   itemkey   - key of the current item
800 --   actid     - process activity instance id
801 --   funcmode  - function execution mode. this is set by the engine
802 --               as either 'RUN', 'CANCEL', 'TIMEOUT'
803 -- OUT
804 --   result
805 --       - COMPLETE[:<result>]
806 --           activity has completed with the indicated result
807 --       - WAITING
808 --           activity is waiting for additional transitions
809 --       - DEFERED
810 --           execution should be defered to background
811 --       - NOTIFIED[:<notification_id>:<assigned_user>]
812 --           activity has notified an external entity that this
813 --           step must be performed.  A call to wf_engine.CompleteActivty
814 --           will signal when this step is complete.  Optional
815 --           return of notification ID and assigned user.
816 --       - ERROR[:<error_code>]
817 --           function encountered an error.
818 
819 procedure IEM_WF_BCC_TO(
820     itemtype  in varchar2,
821     itemkey   in varchar2,
822     actid     in number,
823     funcmode  in varchar2,
824     result    in out nocopy  varchar2)
825 is
826 l_bcc	varchar2(50);
827 l_proc_name	varchar2(30):='IEM_WF_BCC_TO';
828 l_msg_id		number;
829 l_ret		number;
830 l_errmsg		varchar2(200);
831 l_str		varchar2(200);
832 
833 begin
834  	result:='COMPLETE:';
835 exception
836   when others then
837     -- The line below records this function call in the error system
838     -- in the case of an exception.
839     wf_core.context(G_PKG_NAME, l_proc_name,
840                     itemtype, itemkey, to_char(actid), funcmode);
841 		G_STAT:='E';
842     raise;
843 end IEM_WF_BCC_TO;
844 
845 -- PROCEDURE IEM_WF_DELETEMSG
846 --
847 -- Delete The current Message .
848 --
849 -- IN
850 --   itemtype  - type of the current item
851 --   itemkey   - key of the current item
852 --   actid     - process activity instance id
853 --   funcmode  - function execution mode. this is set by the engine
854 --               as either 'RUN', 'CANCEL', 'TIMEOUT'
855 -- OUT
856 --   result
857 --       - COMPLETE[:<result>]
858 --           activity has completed with the indicated result
859 --       - WAITING
860 --           activity is waiting for additional transitions
861 --       - DEFERED
862 --           execution should be defered to background
863 --       - NOTIFIED[:<notification_id>:<assigned_user>]
864 --           activity has notified an external entity that this
865 --           step must be performed.  A call to wf_engine.CompleteActivty
866 --           will signal when this step is complete.  Optional
867 --           return of notification ID and assigned user.
868 --       - ERROR[:<error_code>]
869 --           function encountered an error.
870 
871 procedure IEM_WF_DELETEMSG(
872     itemtype  in varchar2,
873     itemkey   in varchar2,
874     actid     in number,
875     funcmode  in varchar2,
876     result    in out nocopy  varchar2)
877 is
878 l_msg_id		number;
879 l_folder		varchar2(50);
880 l_proc_name	varchar2(30):='IEM_WF_DELETEMSG';
881 l_errmsg		varchar2(200);
882 l_ret		varchar2(200);
883 l_str		varchar2(200);
884 del_exception	EXCEPTION;
885 
886 begin
887  	result:='COMPLETE:';
888 exception
889   when del_exception then
890 	wf_engine.abortprocess(itemtype,itemkey);
891 	result:='COMPLETE:';
892   when others then
893     -- The line below records this function call in the error system
894     -- in the case of an exception.
895     wf_core.context(G_PKG_NAME, l_proc_name,
896                     itemtype, itemkey, to_char(actid), funcmode);
897 		G_STAT:='E';
898     raise;
899 end IEM_WF_DELETEMSG ;
900 
901 -- PROCEDURE IEM_WF_MOVETO
902 --
903 -- Move The Current Message To The Specified Folder
904 --
905 -- IN
906 --   itemtype  - type of the current item
907 --   itemkey   - key of the current item
908 --   actid     - process activity instance id
909 --   funcmode  - function execution mode. this is set by the engine
910 --               as either 'RUN', 'CANCEL', 'TIMEOUT'
911 -- OUT
912 --   result
913 --       - COMPLETE[:<result>]
914 --           activity has completed with the indicated result
915 --       - WAITING
916 --           activity is waiting for additional transitions
917 --       - DEFERED
918 --           execution should be defered to background
919 --       - NOTIFIED[:<notification_id>:<assigned_user>]
920 --           activity has notified an external entity that this
921 --           step must be performed.  A call to wf_engine.CompleteActivty
922 --           will signal when this step is complete.  Optional
923 --           return of notification ID and assigned user.
924 --       - ERROR[:<error_code>]
925 --           function encountered an error.
926 
927 procedure IEM_WF_MOVETO(
928     itemtype  in varchar2,
929     itemkey   in varchar2,
930     actid     in number,
931     funcmode  in varchar2,
932     result    in out nocopy  varchar2)
933 is
934 l_msg_id		number;
935 l_ret		number;
936 l_folder		varchar2(50);
937 l_proc_name	varchar2(30):='IEM_WF_MOVETO';
938 l_errmsg		varchar2(300);
939 l_str		varchar2(200);
940 
941 begin
942  result:='COMPLETE:';
943 exception
944   when others then
945     -- The line below records this function call in the error system
946     -- in the case of an exception.
947     wf_core.context(G_PKG_NAME, l_proc_name,
948                     itemtype, itemkey, to_char(actid), funcmode);
949 		G_STAT:='E';
950     raise;
951 end IEM_WF_MOVETO ;
952 
953 -- PROCEDURE IEM_WF_COPYTO
954 --
955 -- Copy The Current Message To The Specified Folder
956 --
957 -- IN
958 --   itemtype  - type of the current item
959 --   itemkey   - key of the current item
960 --   actid     - process activity instance id
961 --   funcmode  - function execution mode. this is set by the engine
962 --               as either 'RUN', 'CANCEL', 'TIMEOUT'
963 -- OUT
964 --   result
965 --       - COMPLETE[:<result>]
966 --           activity has completed with the indicated result
967 --       - WAITING
968 --           activity is waiting for additional transitions
969 --       - DEFERED
970 --           execution should be defered to background
971 --       - NOTIFIED[:<notification_id>:<assigned_user>]
972 --           activity has notified an external entity that this
973 --           step must be performed.  A call to wf_engine.CompleteActivty
974 --           will signal when this step is complete.  Optional
975 --           return of notification ID and assigned user.
976 --       - ERROR[:<error_code>]
977 --           function encountered an error.
978 
979 procedure IEM_WF_COPYTO(
980     itemtype  in varchar2,
981     itemkey   in varchar2,
982     actid     in number,
983     funcmode  in varchar2,
984     result    in out nocopy  varchar2)
985 is
986 l_msg_id		number;
987 l_ret		number;
988 l_folder		varchar2(50);
989 l_proc_name	varchar2(30):='IEM_WF_COPYTO';
990 l_errmsg		varchar2(200);
991 l_str		varchar2(200);
992 
993 begin
994 		result:='COMPLETE:';
995 exception
996  	 when others then
997     -- The line below records this function call in the error system
998     -- in the case of an exception.
999     wf_core.context(G_PKG_NAME, l_proc_name,
1000                     itemtype, itemkey, to_char(actid), funcmode);
1001 		G_STAT:='E';
1002     raise;
1003 end IEM_WF_COPYTO ;
1004 
1005 -- PROCEDURE IEM_WF_FORWARDTO
1006 --
1007 -- Forward The Current Message With a Notes Attached
1008 --
1009 -- IN
1010 --   itemtype  - type of the current item
1011 --   itemkey   - key of the current item
1012 --   actid     - process activity instance id
1013 --   funcmode  - function execution mode. this is set by the engine
1014 --               as either 'RUN', 'CANCEL', 'TIMEOUT'
1015 -- OUT
1016 --   result
1017 --       - COMPLETE[:<result>]
1018 --           activity has completed with the indicated result
1019 --       - WAITING
1020 --           activity is waiting for additional transitions
1021 --       - DEFERED
1022 --           execution should be defered to background
1023 --       - NOTIFIED[:<notification_id>:<assigned_user>]
1024 --           activity has notified an external entity that this
1025 --           step must be performed.  A call to wf_engine.CompleteActivty
1026 --           will signal when this step is complete.  Optional
1027 --           return of notification ID and assigned user.
1028 --       - ERROR[:<error_code>]
1029 --           function encountered an error.
1030 
1031 procedure IEM_WF_FORWARDTO(
1032     itemtype  in varchar2,
1033     itemkey   in varchar2,
1034     actid     in number,
1035     funcmode  in varchar2,
1036     result    in out nocopy  varchar2)
1037 is
1038 l_msg_id		number;
1039 l_ret		number;
1040 l_notes		varchar2(500);
1041 l_subject		varchar2(500);
1042 l_user		varchar2(500);
1043 l_fwd_recip		varchar2(100);
1044 l_proc_name	varchar2(30):='IEM_WF_FORWARDTO';
1045 l_errmsg		varchar2(200);
1046 l_str		varchar2(200);
1047 
1048 begin
1049  result:='COMPLETE:';
1050 exception
1051   when others then
1052     -- The line below records this function call in the error system
1053     -- in the case of an exception.
1054     wf_core.context(G_PKG_NAME, l_proc_name,
1055                     itemtype, itemkey, to_char(actid), funcmode);
1056 		G_STAT:='E';
1057     raise;
1058 end IEM_WF_FORWARDTO ;
1059 
1060 -- PROCEDURE IEM_WF_SIMPLESEARCH
1061 --
1062 -- Do a search on the KB Repository
1063 --
1064 -- IN
1065 --   itemtype  - type of the current item
1066 --   itemkey   - key of the current item
1067 --   actid     - process activity instance id
1068 --   funcmode  - function execution mode. this is set by the engine
1069 --               as either 'RUN', 'CANCEL', 'TIMEOUT'
1070 -- OUT
1071 --   result
1072 --       - COMPLETE[:<result>]
1073 --           activity has completed with the indicated result
1074 --       - WAITING
1075 --           activity is waiting for additional transitions
1076 --       - DEFERED
1077 --           execution should be defered to background
1078 --       - NOTIFIED[:<notification_id>:<assigned_user>]
1079 --           activity has notified an external entity that this
1080 --           step must be performed.  A call to wf_engine.CompleteActivty
1081 --           will signal when this step is complete.  Optional
1082 --           return of notification ID and assigned user.
1083 --       - ERROR[:<error_code>]
1084 --           function encountered an error.
1085 
1086 procedure IEM_WF_SIMPLESEARCH(
1087     itemtype  in varchar2,
1088     itemkey   in varchar2,
1089     actid     in number,
1090     funcmode  in varchar2,
1091     result    in out nocopy  varchar2)
1092 is
1093 l_proc_name	varchar2(100):='IEM_WF_SIMPLESEARCH';
1094 begin
1095  result:='COMPLETE:';
1096 exception
1097   when others then
1098     -- The line below records this function call in the error system
1099     -- in the case of an exception.
1100     wf_core.context(G_PKG_NAME, l_proc_name,
1101                     itemtype, itemkey, to_char(actid), funcmode);
1102 		G_STAT:='E';
1103     raise;
1104 end IEM_WF_SIMPLESEARCH ;
1105 
1106 -- PROCEDURE IEM_WF_SPECIFICSEARCH
1107 --
1108 -- Do a specific search on the KB Repository
1109 --
1110 -- IN
1111 --   itemtype  - type of the current item
1112 --   itemkey   - key of the current item
1113 --   actid     - process activity instance id
1114 --   funcmode  - function execution mode. this is set by the engine
1115 --               as either 'RUN', 'CANCEL', 'TIMEOUT'
1116 -- OUT
1117 --   result
1118 --       - COMPLETE[:<result>]
1119 --           activity has completed with the indicated result
1120 --       - WAITING
1121 --           activity is waiting for additional transitions
1122 --       - DEFERED
1123 --           execution should be defered to background
1124 --       - NOTIFIED[:<notification_id>:<assigned_user>]
1125 --           activity has notified an external entity that this
1126 --           step must be performed.  A call to wf_engine.CompleteActivty
1127 --           will signal when this step is complete.  Optional
1128 --           return of notification ID and assigned user.
1129 --       - ERROR[:<error_code>]
1130 --           function encountered an error.
1131 
1132 procedure IEM_WF_SPECIFICSEARCH(
1133     itemtype  in varchar2,
1134     itemkey   in varchar2,
1135     actid     in number,
1136     funcmode  in varchar2,
1137     result    in out nocopy  varchar2)
1138 is
1139 l_proc_name	varchar2(30):='IEM_WF_SPECIFICSEARCH';
1140 
1141 begin
1142  result:='COMPLETE:';
1143 exception
1144   when others then
1145     -- The line below records this function call in the error system
1146     -- in the case of an exception.
1147     wf_core.context(G_PKG_NAME, l_proc_name,
1148                     itemtype, itemkey, to_char(actid), funcmode);
1149 		G_STAT:='E';
1150     raise;
1151 end IEM_WF_SPECIFICSEARCH;
1152 procedure IEM_WF_SEARCHMESSAGE(
1153     itemtype  in varchar2,
1154     itemkey   in varchar2,
1155     actid     in number,
1156     funcmode  in varchar2,
1157     result    in out nocopy  varchar2)
1158 is
1159 l_proc_name	varchar2(20):='IEM_WF_SEARCHMESSAGE';
1160 begin
1161 	result:='COMPLETE:F';
1162 exception
1163   when others then
1164     -- The line below records this function call in the error system
1165     -- in the case of an exception.
1166     wf_core.context(G_PKG_NAME, l_proc_name,
1167                     itemtype, itemkey, to_char(actid), funcmode);
1168 		G_STAT:='E';
1169     raise;
1170 end IEM_WF_SEARCHMESSAGE;
1171 
1172 procedure IEM_WF_STORETHEME(
1173     itemtype  in varchar2,
1174     itemkey   in varchar2,
1175     actid     in number,
1176     funcmode  in varchar2,
1177     result    in out nocopy  varchar2)
1178 is
1179 l_proc_name	varchar2(20):='IEM_WF_STORETHEME';
1180 begin
1181 	result:='COMPLETE:';
1182 exception
1183   when others then
1184     -- The line below records this function call in the error system
1185     -- in the case of an exception.
1186     wf_core.context(G_PKG_NAME, l_proc_name,
1187                     itemtype, itemkey, to_char(actid), funcmode);
1188 		G_STAT:='E';
1189     raise;
1190 end IEM_WF_STORETHEME;
1191 
1192 procedure IEM_WF_THEMEPROC(
1193     itemtype  in varchar2,
1194     itemkey   in varchar2,
1195     actid     in number,
1196     funcmode  in varchar2,
1197     result    in out nocopy  varchar2)
1198 is
1199 l_proc_name	varchar2(20):='IEM_WF_THEMEPROC';
1200 begin
1201 	result:='COMPLETE:';
1202 exception
1203   when others then
1204     -- The line below records this function call in the error system
1205     -- in the case of an exception.
1206     wf_core.context(G_PKG_NAME, l_proc_name,
1207                     itemtype, itemkey, to_char(actid), funcmode);
1208 		G_STAT:='E';
1209     raise;
1210 end IEM_WF_THEMEPROC;
1211 
1212 -- PROCEDURE IEM_WF_KEYVAL
1213 --
1214 -- Find the value based on the key supplied in the message
1215 --
1216 -- IN
1217 --   itemtype  - type of the current item
1218 --   itemkey   - key of the current item
1219 --   actid     - process activity instance id
1220 --   funcmode  - function execution mode. this is set by the engine
1221 --               as either 'RUN', 'CANCEL', 'TIMEOUT'
1222 -- OUT
1223 --   result
1224 --       - COMPLETE[:<result>]
1225 --           activity has completed with the indicated result
1226 --       - WAITING
1227 --           activity is waiting for additional transitions
1228 --       - DEFERED
1229 --           execution should be defered to background
1230 --       - NOTIFIED[:<notification_id>:<assigned_user>]
1231 --           activity has notified an external entity that this
1232 --           step must be performed.  A call to wf_engine.CompleteActivty
1233 --           will signal when this step is complete.  Optional
1234 --           return of notification ID and assigned user.
1235 --       - ERROR[:<error_code>]
1236 --           function encountered an error.
1237 
1238 procedure IEM_WF_KEYVAL(
1239     itemtype  in varchar2,
1240     itemkey   in varchar2,
1241     actid     in number,
1242     funcmode  in varchar2,
1243     result    in out nocopy  varchar2)
1244 is
1245 
1246 l_proc_name	varchar2(20):='IEM_WF_KEYVAL';
1247 l_ret	number;
1248 l_str	varchar2(250);
1249 l_msgid	number;
1250 l_api	number:=1.0;
1251 l_key	varchar2(100);
1252 l_val	varchar2(100);
1253 l_sender	varchar2(70);
1254 l_part	number;
1255 l_err_text	varchar2(100);
1256 begin
1257 		result:='COMPLETE:F';
1258 EXCEPTION
1259   when others then
1260     -- The line below records this function call in the error system
1261     -- in the case of an exception.
1262 		G_STAT:='E';
1263     wf_core.context(G_PKG_NAME, l_proc_name,
1264                     itemtype, itemkey, to_char(actid), funcmode);
1265     raise;
1266 end IEM_WF_KEYVAL;
1267 
1268 -- PROCEDURE IEM_WF_CLASSRULE
1269 --
1270 -- Check The Classifcation Score with thresh hold score
1271 --
1272 -- IN
1273 --   itemtype  - type of the current item
1274 --   itemkey   - key of the current item
1275 --   actid     - process activity instance id
1276 --   funcmode  - function execution mode. this is set by the engine
1277 --               as either 'RUN', 'CANCEL', 'TIMEOUT'
1278 -- OUT
1279 --   result
1280 --       - COMPLETE[:<result>]
1281 --           activity has completed with the indicated result
1282 --       - WAITING
1283 --           activity is waiting for additional transitions
1284 --       - DEFERED
1285 --           execution should be defered to background
1286 --       - NOTIFIED[:<notification_id>:<assigned_user>]
1287 --           activity has notified an external entity that this
1288 --           step must be performed.  A call to wf_engine.CompleteActivty
1289 --           will signal when this step is complete.  Optional
1290 --           return of notification ID and assigned user.
1291 --       - ERROR[:<error_code>]
1292 --           function encountered an error.
1293 
1294 procedure IEM_WF_CLASSRULE(
1295     itemtype  in varchar2,
1296     itemkey   in varchar2,
1297     actid     in number,
1298     funcmode  in varchar2,
1299     result    in out nocopy  varchar2)
1300 is
1301 
1302 l_proc_name	varchar2(20):='IEM_WF_CLASSRULE';
1303 l_ret	number;
1304 l_str	varchar2(200);
1305 l_msgid	number;
1306 l_mscore	number;
1307 l_score	number;
1308 l_sender	varchar2(70);
1309 begin
1310 		result:='COMPLETE:F';
1311 EXCEPTION
1312   when others then
1313     -- The line below records this function call in the error system
1314     -- in the case of an exception.
1315 		G_STAT:='E';
1316     wf_core.context(G_PKG_NAME, l_proc_name,
1317                     itemtype, itemkey, to_char(actid), funcmode);
1318     raise;
1319 end IEM_WF_CLASSRULE;
1320 
1321 -- PROCEDURE IEM_WF_CHKAUTO
1322 --
1323 -- Check The Classifcation Score with thresh hold score  for autoresponce
1324 --
1325 -- IN
1326 --   itemtype  - type of the current item
1327 --   itemkey   - key of the current item
1328 --   actid     - process activity instance id
1329 --   funcmode  - function execution mode. this is set by the engine
1330 --               as either 'RUN', 'CANCEL', 'TIMEOUT'
1331 -- OUT
1332 --   result
1333 --       - COMPLETE[:<result>]
1334 --           activity has completed with the indicated result
1335 --       - WAITING
1336 --           activity is waiting for additional transitions
1337 --       - DEFERED
1338 --           execution should be defered to background
1339 --       - NOTIFIED[:<notification_id>:<assigned_user>]
1340 --           activity has notified an external entity that this
1341 --           step must be performed.  A call to wf_engine.CompleteActivty
1342 --           will signal when this step is complete.  Optional
1343 --           return of notification ID and assigned user.
1344 --       - ERROR[:<error_code>]
1345 --           function encountered an error.
1346 
1347 procedure IEM_WF_CHKAUTO(
1348     itemtype  in varchar2,
1349     itemkey   in varchar2,
1350     actid     in number,
1351     funcmode  in varchar2,
1352     result    in out nocopy  varchar2)
1353 is
1354 
1355 l_proc_name	varchar2(20):='IEM_WF_CHKAUTO';
1356 l_ret	number;
1357 l_str	varchar2(200);
1358 l_msgid	number;
1359 l_mscore	number;
1360 l_score	number;
1361 l_chk	number;
1362 l_email_account_id	number;
1363 l_sender	varchar2(70);
1364 l_subject	varchar2(200);
1365 begin
1366 
1367 		result:='COMPLETE:F';
1368 EXCEPTION
1369   when others then
1370     -- The line below records this function call in the error system
1371     -- in the case of an exception.
1372 		G_STAT:='E';
1373     wf_core.context(G_PKG_NAME, l_proc_name,
1374                     itemtype, itemkey, to_char(actid), funcmode);
1375     raise;
1376 end IEM_WF_CHKAUTO;
1377 
1378 -- PROCEDURE IEM_WF_AUTORESP
1379 --
1380 -- Autorespond to the sender with a set of documents
1381 --
1382 -- IN
1383 --   itemtype  - type of the current item
1384 --   itemkey   - key of the current item
1385 --   actid     - process activity instance id
1386 --   funcmode  - function execution mode. this is set by the engine
1387 --               as either 'RUN', 'CANCEL', 'TIMEOUT'
1388 -- OUT
1389 --   result
1390 --       - COMPLETE[:<result>]
1391 --           activity has completed with the indicated result
1392 --       - WAITING
1393 --           activity is waiting for additional transitions
1394 --       - DEFERED
1395 --           execution should be defered to background
1396 --       - NOTIFIED[:<notification_id>:<assigned_user>]
1397 --           activity has notified an external entity that this
1398 --           step must be performed.  A call to wf_engine.CompleteActivty
1399 --           will signal when this step is complete.  Optional
1400 --           return of notification ID and assigned user.
1401 --       - ERROR[:<error_code>]
1402 --           function encountered an error.
1403 
1404 procedure IEM_WF_AUTORESP(
1405     itemtype  in varchar2,
1406     itemkey   in varchar2,
1407     actid     in number,
1408     funcmode  in varchar2,
1409     result    in out nocopy  varchar2)
1410 is
1411 
1412 l_proc_name	varchar2(20):='IEM_WF_AUTORESP';
1413 
1414 begin
1415 	result:='COMPLETE:F';
1416  END IEM_WF_AUTORESP;
1417 
1418 -- PROCEDURE IEM_WF_ORDSTAT
1419 --
1420 -- Autorespond to the sender with order status
1421 --
1422 -- IN
1423 --   itemtype  - type of the current item
1424 --   itemkey   - key of the current item
1425 --   actid     - process activity instance id
1426 --   funcmode  - function execution mode. this is set by the engine
1427 --               as either 'RUN', 'CANCEL', 'TIMEOUT'
1428 -- OUT
1429 --   result
1430 --       - COMPLETE[:<result>]
1431 --           activity has completed with the indicated result
1432 --       - WAITING
1433 --           activity is waiting for additional transitions
1434 --       - DEFERED
1435 --           execution should be defered to background
1436 --       - NOTIFIED[:<notification_id>:<assigned_user>]
1437 --           activity has notified an external entity that this
1438 --           step must be performed.  A call to wf_engine.CompleteActivty
1439 --           will signal when this step is complete.  Optional
1440 --           return of notification ID and assigned user.
1441 --       - ERROR[:<error_code>]
1442 --           function encountered an error.
1443 
1444 procedure IEM_WF_ORDSTAT(
1445     itemtype  in varchar2,
1446     itemkey   in varchar2,
1447     actid     in number,
1448     funcmode  in varchar2,
1449     result    in out nocopy  varchar2)
1450 is
1451 
1452 l_proc_name	varchar2(20):='IEM_WF_ORDSTAT';
1453 begin
1454 	result:='COMPLETE:F';
1455 END IEM_WF_ORDSTAT;
1456 
1457 end IEM_Mailpreprocwf_PUB ;