DBA Data[Home] [Help]

PACKAGE BODY: APPS.XNP_WF_TIMERS

Source


1 PACKAGE BODY XNP_WF_TIMERS AS
2 /* $Header: XNPWFTMB.pls 120.1 2005/06/17 03:42:34 appldev  $ */
3 
4 PROCEDURE FireDefaultJeopardyTimer ( itemtype IN VARCHAR2
5                                     ,itemkey IN VARCHAR2 );
6 PROCEDURE fire
7  (ITEMTYPE IN VARCHAR2
8  ,ITEMKEY IN VARCHAR2
9  ,ACTID IN NUMBER
10  ,FUNCMODE IN VARCHAR2
11  ,RESULTOUT OUT NOCOPY VARCHAR2
12  )
13 IS
14  x_progress VARCHAR2(2000);
15  l_workitem_instance_id NUMBER;
16  l_fa_instance_id NUMBER;
17  l_order_id NUMBER;
18  l_reference_id NUMBER;
19  l_timer_code VARCHAR2(80);
20  l_callback_ref_id VARCHAR2(1024);
21  l_tmp_callback_ref_id VARCHAR2(2000) := NULL;
22  l_error_code NUMBER := 0;
23  l_error_message VARCHAR2(2000);
24  e_FIRE	EXCEPTION;
25 BEGIN
26 
27   --
28   -- RUN mode - normal process execution
29   --
30 
31   IF (funcmode = 'RUN') THEN
32 
33     -- The run code
34     BEGIN
35     l_workitem_instance_id :=
36       wf_engine.GetItemAttrNumber
37       (itemtype => itemtype
38       ,itemkey  => itemkey
39       ,aname   => 'WORKITEM_INSTANCE_ID'
40       );
41      EXCEPTION
42      WHEN OTHERS THEN
43         wf_core.clear;
44 --	l_workitem_instance_id := 0;
45 	l_workitem_instance_id := NULL;
46      END;
47 
48      BEGIN
49      l_fa_instance_id :=
50       wf_engine.GetItemAttrNumber
51       (itemtype => itemtype
52       ,itemkey  => itemkey
53       ,aname   => 'FA_INSTANCE_ID'
54       );
55      EXCEPTION
56      WHEN OTHERS THEN
57         wf_core.clear;
58 --	l_fa_instance_id := 0;
59 	l_fa_instance_id := NULL;
60      END;
61 
62     BEGIN
63     l_order_id :=
64       wf_engine.GetItemAttrNumber
65       (itemtype => itemtype
66       ,itemkey  => itemkey
67       ,aname   => 'ORDER_ID'
68       );
69     EXCEPTION
70     WHEN OTHERS THEN
71         wf_core.clear;
72 --	l_order_id := 0;
73 	l_order_id := NULL;
74     END;
75 
76     -- Get the event type to publish
77     l_timer_code :=
78      wf_engine.GetActivityAttrText
79       (itemtype => itemtype
80       ,itemkey  => itemkey
81       ,actid	=> actid
82       ,aname   => 'TIMER_NAME'
83       );
84 
85     -- Get the callback reference id
86     XNP_UTILS.CHECK_TO_GET_REF_ID
87     (p_itemtype       => itemtype
88     ,p_itemkey        => itemkey
89     ,p_actid          => actid
90     ,p_workitem_instance_id => l_workitem_instance_id
91     ,x_reference_id  => l_callback_ref_id
92     );
93 
94     XNP_TIMER_STANDARD.FIRE
95      (p_order_id => l_order_id
96      ,p_workitem_instance_id => l_workitem_instance_id
97      ,p_fa_instance_id => l_fa_instance_id
98      ,p_timer_code => l_timer_code
99      ,p_callback_ref_id => l_callback_ref_id
100      ,x_error_code => l_error_code
101      ,x_error_message => l_error_message
102      );
103 
104   	IF l_error_code <> 0
105 	THEN
106 		raise e_FIRE;
107 	END IF;
108 
109   -- Completion
110     resultout := 'COMPLETE';
111     return;
112 
113   END IF;
114   --
115   -- CANCEL mode
116   --
117   -- This is in the event that the activity must be undone.
118   --
119   IF (funcmode = 'CANCEL' ) THEN
120     -- The cancel code
121 
122     null;
123     -- no result needed
124     resultout := 'COMPLETE';
125     RETURN;
126   END IF;
127 
128   -- For other execution modes: return null
129 
130   resultout := '';
131   return;
132 
133   EXCEPTION
134     WHEN OTHERS THEN
135     /* Record this function call in the error
136      * system in case of an exception
137      */
138 
139      fnd_message.set_name('XNP','STD_ERROR');
140      fnd_message.set_token(
141        'ERROR_LOCN','XNP_WF_TIMERS.FIRE');
142 
143      if(l_error_code <> 0) then
144 		fnd_message.set_token('ERROR_TEXT',
145        ':'||to_char(l_error_code)||':'||l_error_message);
146      else
147        fnd_message.set_token('ERROR_TEXT',
148          ':'||to_char(SQLCODE)||':'||SQLERRM);
149      end if;
150      x_progress := fnd_message.get;
151      wf_core.context(
152         'XNP_WF_TIMERS'
153         , 'FIRE'
154         , itemtype
155         , itemkey
156         , to_char(actid)
157         , funcmode
158         , x_progress);
159     RAISE;
160 
161 END FIRE;
162 
163 PROCEDURE get_timer_status
164  (ITEMTYPE IN VARCHAR2
165  ,ITEMKEY IN VARCHAR2
166  ,ACTID IN NUMBER
167  ,FUNCMODE IN VARCHAR2
168  ,RESULTOUT OUT NOCOPY VARCHAR2
169  )
170 IS
171  x_progress VARCHAR2(2000);
172  l_reference_id VARCHAR2(80);
173  l_timer_code VARCHAR2(20);
174  l_status VARCHAR2(20);
175  l_callback_ref_id VARCHAR2(1024);
176  l_tmp_callback_ref_id VARCHAR2(2000) := NULL;
177  l_timer_id NUMBER := NULL;
178  l_workitem_instance_id NUMBER;
179  l_error_code NUMBER := 0;
180  l_error_message VARCHAR2(2000);
181  e_GET_TIMER_STATUS	EXCEPTION;
182 
183 BEGIN
184 
185   --
186   -- RUN mode - normal process execution
187   --
188 
189   IF (funcmode = 'RUN') THEN
190 
191     -- The run code
192     BEGIN
193     l_workitem_instance_id :=
194       wf_engine.GetItemAttrNumber
195       (itemtype => itemtype
196       ,itemkey  => itemkey
197       ,aname   => 'WORKITEM_INSTANCE_ID'
198       );
199      EXCEPTION
200      WHEN OTHERS THEN
201         wf_core.clear;
202 --	l_workitem_instance_id := 0;
203 	l_workitem_instance_id := NULL;
204      END;
205 
206     -- Get the event type to publish
207     l_timer_code :=
208      wf_engine.GetActivityAttrText
209       (itemtype => itemtype
210       ,itemkey  => itemkey
211       ,actid => actid
212       ,aname   => 'TIMER_NAME'
213       );
214 
215     -- Get the callback reference id
216     XNP_UTILS.CHECK_TO_GET_REF_ID
217     (p_itemtype       => itemtype
218     ,p_itemkey        => itemkey
219     ,p_actid          => actid
220     ,p_workitem_instance_id => l_workitem_instance_id
221     ,x_reference_id  => l_callback_ref_id
222     );
223 
224     XNP_TIMER_STANDARD.GET_TIMER_STATUS
225     (p_reference_id => l_callback_ref_id
226      ,p_timer_message_code => l_timer_code
227      ,x_timer_id => l_timer_id
228      ,x_status => l_status
229      ,x_error_code => l_error_code
230      ,x_error_message => l_error_message
231      );
232 
233 	-- If Timer is not found, it can be interpreted as
234 	-- it is INACTIVE. Specifically in case of Timers with
235 	-- delay, it is more appropriate to call such timers
236 	-- to be INACTIVE rather than giving NOT FOUND ERROR.
237 	-- Bug # 1552348
238 
239 	IF l_error_code = xnp_errors.g_timer_not_found THEN
240 		resultout := 'COMPLETE:' || 'INACTIVE';
241 		return;
242 	END IF;
243 
244 	-- Changed till this point.
245 
246     IF l_error_code <> 0
247     THEN
248        RAISE e_GET_TIMER_STATUS;
249     END IF;
250     -- Completion
251     resultout := 'COMPLETE:' || l_status;
252     return;
253 
254   END IF;
255   --
256   -- CANCEL mode
257   --
258   -- This is in the event that the activity must be undone.
259   --
260   IF (funcmode = 'CANCEL' ) THEN
261     -- The cancel code
262 
263     null;
264     -- no result needed
265     resultout := 'COMPLETE';
266     return;
267   END IF;
268 
269   -- For other execution modes: return null
270 
271   resultout := '';
272   return;
273 
274   EXCEPTION
275     WHEN OTHERS THEN
276     /* Record this function call in the error
277      * system in case of an exception
278      */
279      fnd_message.set_name('XNP','STD_ERROR');
280      fnd_message.set_token(
281        'ERROR_LOCN','XNP_WF_TIMERS.GET_TIMER_STATUS');
282      if(l_error_code <> 0) then
283 		fnd_message.set_token('ERROR_TEXT',
284        ':'||to_char(l_error_code)||':'||l_error_message);
285      else
286        fnd_message.set_token('ERROR_TEXT',
287          ':'||to_char(SQLCODE)||':'||SQLERRM);
288      end if;
289      x_progress := fnd_message.get;
290      wf_core.context(
291         'XNP_WF_STANDARD'
292         , 'GET_TIMER_STATUS'
293         , itemtype
294         , itemkey
295         , to_char(actid)
296         , funcmode
297         , x_progress);
298       RAISE;
299 
300 END get_timer_status;
301 
302 PROCEDURE start_related_timers
303  (ITEMTYPE IN VARCHAR2
304  ,ITEMKEY IN VARCHAR2
305  ,ACTID IN NUMBER
306  ,FUNCMODE IN VARCHAR2
307  ,RESULTOUT OUT NOCOPY VARCHAR2
308  )
309 IS
310  x_progress VARCHAR2(2000);
311  l_message_code VARCHAR2(20);
312  l_callback_ref_id VARCHAR2(1024);
313  l_tmp_callback_ref_id VARCHAR2(2000) := NULL;
314  l_order_id NUMBER;
315  l_workitem_instance_id NUMBER;
316  l_fa_instance_id NUMBER;
317  l_error_code NUMBER := 0;
318  l_error_message VARCHAR2(2000);
319  e_START_RELATED_TIMERS	EXCEPTION;
320 
321 BEGIN
322 
323   --
324   -- RUN mode - normal process execution
325   --
326 
327   IF (funcmode = 'RUN') THEN
328 
329     -- The run code
330     BEGIN
331     l_workitem_instance_id :=
332       wf_engine.GetItemAttrNumber
333       (itemtype => itemtype
334       ,itemkey  => itemkey
335       ,aname   => 'WORKITEM_INSTANCE_ID'
336       );
337      EXCEPTION
338      WHEN OTHERS THEN
339         wf_core.clear;
340 --	l_workitem_instance_id := 0;
341 	l_workitem_instance_id := NULL;
342      END;
343 
344     BEGIN
345     l_fa_instance_id :=
346       wf_engine.GetItemAttrNumber
347       (itemtype => itemtype
348       ,itemkey  => itemkey
349       ,aname   => 'FA_INSTANCE_ID'
350       );
351      EXCEPTION
352      WHEN OTHERS THEN
353         wf_core.clear;
354 --	l_fa_instance_id := 0;
355 	l_fa_instance_id := NULL;
356      END;
357 
358     BEGIN
359     l_order_id :=
360       wf_engine.GetItemAttrNumber
361       (itemtype => itemtype
362       ,itemkey  => itemkey
363       ,aname   => 'ORDER_ID'
364       );
365      EXCEPTION
366      WHEN OTHERS THEN
367         wf_core.clear;
368 --	l_order_id := 0;
369 	l_order_id := NULL;
370      END;
371 
372     -- Get the event type to publish
373     l_message_code :=
374      wf_engine.GetActivityAttrText
375       (itemtype => itemtype
376       ,itemkey  => itemkey
377       ,actid => actid
378       ,aname   => 'MESSAGE_CODE'
379       );
380 
381     -- Get the callback reference id
382     XNP_UTILS.CHECK_TO_GET_REF_ID
383     (p_itemtype       => itemtype
384     ,p_itemkey        => itemkey
385     ,p_actid          => actid
386     ,p_workitem_instance_id => l_workitem_instance_id
387     ,x_reference_id  => l_callback_ref_id
388     );
389 
390     XNP_TIMER_STANDARD.START_RELATED_TIMERS
391     (
392 	p_message_code => l_message_code
393 	,p_callback_ref_id => l_callback_ref_id
394 	,x_error_code => l_error_code
395 	,x_error_message => l_error_message
396 	,p_order_id => l_order_id
397 	,p_workitem_instance_id => l_workitem_instance_id
398 	,p_fa_instance_id => l_fa_instance_id
399      );
400 
401     IF l_error_code <> 0
402     THEN
403 	raise e_START_RELATED_TIMERS;
404     END IF;
405 
406     -- Completion
407     resultout := 'COMPLETE';
408     return;
409 
410   END IF;
411   --
412   -- CANCEL mode
413   --
414   -- This is in the event that the activity must be undone.
415   --
416   IF (funcmode = 'CANCEL' ) THEN
417     -- The cancel code
418 
419     null;
420     -- no result needed
421     resultout := 'COMPLETE';
422     return;
423   END IF;
424 
425   -- For other execution modes: return null
426 
427   resultout := '';
428   return;
429 
430   EXCEPTION
431     WHEN OTHERS THEN
432     /* Record this function call in the error
433      * system in case of an exception
434      */
435      fnd_message.set_name('XNP','STD_ERROR');
436      fnd_message.set_token(
437        'ERROR_LOCN','XNP_WF_TIMERS.START_RELATED_TIMERS');
438      if(l_error_code <> 0) then
439 		fnd_message.set_token('ERROR_TEXT',
440        ':'||to_char(l_error_code)||':'||l_error_message);
441      else
442        fnd_message.set_token('ERROR_TEXT',
443          ':'||to_char(SQLCODE)||':'||SQLERRM);
444      end if;
445      x_progress := fnd_message.get;
446      wf_core.context(
447         'XNP_WF_TIMERS'
448         , 'START_RELATED_TIMERS'
449         , itemtype
450         , itemkey
451         , to_char(actid)
452         , funcmode
453         , x_progress);
454 
455       RAISE;
456 
457 END start_related_timers;
458 
459 PROCEDURE restart_all
460  (ITEMTYPE IN VARCHAR2
461  ,ITEMKEY IN VARCHAR2
462  ,ACTID IN NUMBER
463  ,FUNCMODE IN VARCHAR2
464  ,RESULTOUT OUT NOCOPY VARCHAR2
465  )
466 IS
467  x_progress VARCHAR2(2000);
468  l_callback_ref_id VARCHAR2(1024);
469  l_error_code NUMBER := 0;
470  l_error_message VARCHAR2(2000);
471  l_workitem_instance_id NUMBER;
472  e_RESTART_ALL	EXCEPTION;
473 
474 BEGIN
475 
476   --
477   -- RUN mode - normal process execution
478   --
479 
480   IF (funcmode = 'RUN') THEN
481 
482     -- The run code
483     BEGIN
484     l_workitem_instance_id :=
485       wf_engine.GetItemAttrNumber
486       (itemtype => itemtype
487       ,itemkey  => itemkey
488       ,aname   => 'WORKITEM_INSTANCE_ID'
489       );
490      EXCEPTION
491      WHEN OTHERS THEN
492         wf_core.clear;
493 --	l_workitem_instance_id := 0;
494 	l_workitem_instance_id := NULL;
495      END;
496 
497     -- Get the event type to publish
498 
499     -- Get the callback reference id
500     XNP_UTILS.CHECK_TO_GET_REF_ID
501     (p_itemtype       => itemtype
502     ,p_itemkey        => itemkey
503     ,p_actid          => actid
504     ,p_workitem_instance_id => l_workitem_instance_id
505     ,x_reference_id  => l_callback_ref_id
506     );
507 
508     XNP_TIMER_STANDARD.RESTART_ALL
509     (
510      p_reference_id => l_callback_ref_id
511      ,x_error_code => l_error_code
512      ,x_error_message => l_error_message
513      );
514 
515     IF l_error_code <> 0
516     THEN
517 	raise e_RESTART_ALL;
518     END IF;
519 
520     -- Completion
521     resultout := 'COMPLETE';
522     return;
523 
524   END IF;
525   --
526   -- CANCEL mode
527   --
528   -- This is in the event that the activity must be undone.
529   --
530   IF (funcmode = 'CANCEL' ) THEN
531     -- The cancel code
532 
533     null;
534     -- no result needed
535     resultout := 'COMPLETE';
536     return;
537   END IF;
538 
539   -- For other execution modes: return null
540 
541   resultout := '';
542   return;
543 
544   EXCEPTION
545     WHEN OTHERS THEN
546     /* Record this function call in the error
547      * system in case of an exception
548      */
549      /* Record this function call in the error
550      * system in case of an exception
551      */
552      fnd_message.set_name('XNP','STD_ERROR');
553      fnd_message.set_token(
554        'ERROR_LOCN','XNP_WF_TIMERS.RESTART_ALL');
555      if(l_error_code <> 0) then
556 		fnd_message.set_token('ERROR_TEXT',
557        ':'||to_char(l_error_code)||':'||l_error_message);
558      else
559        fnd_message.set_token('ERROR_TEXT',
560          ':'||to_char(SQLCODE)||':'||SQLERRM);
561      end if;
562      x_progress := fnd_message.get;
563      wf_core.context(
564         'XNP_WF_TIMERS'
565         , 'RESTART_ALL'
566         , itemtype
567         , itemkey
568         , to_char(actid)
569         , funcmode
570         , x_progress);
571 
572       RAISE;
573 
574 END restart_all;
575 
576 PROCEDURE recalculate_all
577  (ITEMTYPE IN VARCHAR2
578  ,ITEMKEY IN VARCHAR2
579  ,ACTID IN NUMBER
580  ,FUNCMODE IN VARCHAR2
581  ,RESULTOUT OUT NOCOPY VARCHAR2
582  )
583 IS
584  x_progress VARCHAR2(2000);
585  l_callback_ref_id VARCHAR2(1024);
586  l_error_code NUMBER := 0;
587  l_error_message VARCHAR2(2000);
588  l_workitem_instance_id NUMBER;
589  e_RECALCULATE_ALL	EXCEPTION;
590 
591 BEGIN
592 
593   --
594   -- RUN mode - normal process execution
595   --
596 
597   IF (funcmode = 'RUN') THEN
598 
599     -- The run code
600     BEGIN
601     l_workitem_instance_id :=
602       wf_engine.GetItemAttrNumber
603       (itemtype => itemtype
604       ,itemkey  => itemkey
605       ,aname   => 'WORKITEM_INSTANCE_ID'
606       );
607      EXCEPTION
608      WHEN OTHERS THEN
609         wf_core.clear;
610 --	l_workitem_instance_id := 0;
611 	l_workitem_instance_id := NULL;
612      END;
613 
614     -- Get the event type to publish
615 
616     -- Get the callback reference id
617     XNP_UTILS.CHECK_TO_GET_REF_ID
618     (p_itemtype       => itemtype
619     ,p_itemkey        => itemkey
620     ,p_actid          => actid
621     ,p_workitem_instance_id => l_workitem_instance_id
622     ,x_reference_id  => l_callback_ref_id
623     );
624 
625     XNP_TIMER_STANDARD.RECALCULATE_ALL
626     (
627      p_reference_id => l_callback_ref_id
628      ,x_error_code => l_error_code
629      ,x_error_message => l_error_message
630     );
631 
632     IF l_error_code <> 0
633     THEN
634 	raise e_RECALCULATE_ALL;
635     END IF;
636 
637     -- Completion
638     resultout := 'COMPLETE';
639     return;
640 
641   END IF;
642   --
643   -- CANCEL mode
644   --
645   -- This is in the event that the activity must be undone.
646   --
647   IF (funcmode = 'CANCEL' ) THEN
648     -- The cancel code
649 
650     null;
651     -- no result needed
652     resultout := 'COMPLETE';
653     return;
654   END IF;
655 
656   -- For other execution modes: return null
657 
658   resultout := '';
659   return;
660 
661   EXCEPTION
662     WHEN OTHERS THEN
663     /* Record this function call in the error
664      * system in case of an exception
665      */
666      fnd_message.set_name('XNP','STD_ERROR');
667      fnd_message.set_token(
668        'ERROR_LOCN','XNP_WF_TIMERS.RECALCULATE_ALL');
669      if(l_error_code <> 0) then
670 		fnd_message.set_token('ERROR_TEXT',
671        ':'||to_char(l_error_code)||':'||l_error_message);
672      else
673        fnd_message.set_token('ERROR_TEXT',
674          ':'||to_char(SQLCODE)||':'||SQLERRM);
675      end if;
676      x_progress := fnd_message.get;
677      wf_core.context(
678         'XNP_WF_TIMERS'
679         , 'RECALCULATE_ALL'
680         , itemtype
681         , itemkey
682         , to_char(actid)
683         , funcmode
684         , x_progress);
685 
686       RAISE;
687 
688 END recalculate_all;
689 
690 PROCEDURE remove
691  (ITEMTYPE IN VARCHAR2
692  ,ITEMKEY IN VARCHAR2
693  ,ACTID IN NUMBER
694  ,FUNCMODE IN VARCHAR2
695  ,RESULTOUT OUT NOCOPY VARCHAR2
696  )
697 IS
698  x_progress VARCHAR2(2000);
699  l_callback_ref_id VARCHAR2(1024);
700  l_timer_code VARCHAR2(1024);
701  l_error_code NUMBER := 0;
702  l_error_message VARCHAR2(2000);
703  l_workitem_instance_id NUMBER;
704  e_REMOVE	EXCEPTION;
705 
706 BEGIN
707 
708   --
709   -- RUN mode - normal process execution
710   --
711 
712   IF (funcmode = 'RUN') THEN
713 
714     -- The run code
715     BEGIN
716     l_workitem_instance_id :=
717       wf_engine.GetItemAttrNumber
718       (itemtype => itemtype
719       ,itemkey  => itemkey
720       ,aname   => 'WORKITEM_INSTANCE_ID'
721       );
722      EXCEPTION
723      WHEN OTHERS THEN
724         wf_core.clear;
725 --	l_workitem_instance_id := 0;
726 	l_workitem_instance_id := NULL;
727      END;
728 
729     -- Get the event type to publish
730 
731     -- Get the callback reference id
732     XNP_UTILS.CHECK_TO_GET_REF_ID
733     (p_itemtype       => itemtype
734     ,p_itemkey        => itemkey
735     ,p_actid          => actid
736     ,p_workitem_instance_id => l_workitem_instance_id
737     ,x_reference_id  => l_callback_ref_id
738     );
739 
740     l_timer_code :=
741      wf_engine.GetActivityAttrText
742       (itemtype => itemtype
743       ,itemkey  => itemkey
744       ,actid => actid
745       ,aname   => 'TIMER_NAME'
746       );
747 
748     XNP_TIMER_STANDARD.REMOVE
749     (
750      p_reference_id => l_callback_ref_id
751      ,p_timer_message_code => l_timer_code
752      ,x_error_code => l_error_code
753      ,x_error_message => l_error_message
754     );
755 
756     IF l_error_code <> 0
757     THEN
758 	raise e_REMOVE;
759     END IF;
760 
761     -- Completion
762     resultout := 'COMPLETE';
763     return;
764 
765   END IF;
766   --
767   -- CANCEL mode
768   --
769   -- This is in the event that the activity must be undone.
770   --
771   IF (funcmode = 'CANCEL' ) THEN
772     -- The cancel code
773 
774     null;
775     -- no result needed
776     resultout := 'COMPLETE';
777     return;
778   END IF;
779 
780   -- For other execution modes: return null
781 
782 
783   resultout := '';
784   return;
785 
786   EXCEPTION
787     WHEN OTHERS THEN
788     /* Record this function call in the error
789      * system in case of an exception
790      */
791      fnd_message.set_name('XNP','STD_ERROR');
792      fnd_message.set_token(
793        'ERROR_LOCN','XNP_WF_TIMERS.REMOVE');
794      if(l_error_code <> 0) then
795 		fnd_message.set_token('ERROR_TEXT',
796        ':'||to_char(l_error_code)||':'||l_error_message);
797      else
798        fnd_message.set_token('ERROR_TEXT',
799          ':'||to_char(SQLCODE)||':'||SQLERRM);
800      end if;
801      x_progress := fnd_message.get;
802      wf_core.context(
803         'XNP_WF_TIMERS'
804         , 'REMOVE'
805         , itemtype
806         , itemkey
807         , to_char(actid)
808         , funcmode
809         , x_progress);
810 
811       RAISE;
812 
813 END remove;
814 
815 PROCEDURE deregister
816  (ITEMTYPE IN VARCHAR2
817  ,ITEMKEY IN VARCHAR2
818  ,ACTID IN NUMBER
819  ,FUNCMODE IN VARCHAR2
820  ,RESULTOUT OUT NOCOPY VARCHAR2
821  )
822 IS
823  x_progress VARCHAR2(2000);
824  l_order_id	NUMBER;
825  l_error_code NUMBER := 0;
826  l_error_message VARCHAR2(2000);
827  l_workitem_instance_id NUMBER;
828  e_DEREGISTER	EXCEPTION;
829 
830 BEGIN
831 
832   --
833   -- RUN mode - normal process execution
834   --
835 
836   IF (funcmode = 'RUN') THEN
837 
838     l_order_id :=
839       wf_engine.GetItemAttrNumber
840       (itemtype => itemtype
841       ,itemkey  => itemkey
842       ,aname   => 'ORDER_ID'
843       );
844 
845     -- The run code
846 
847     -- Get the event type to publish
848 
849     XNP_TIMER_STANDARD.DEREGISTER
850     (
851      p_order_id => l_order_id
852      ,x_error_code => l_error_code
853      ,x_error_message => l_error_message
854     );
855 
856     IF l_error_code <> 0
857     THEN
858 	raise e_DEREGISTER;
859     END IF;
860 
861     -- Completion
862     resultout := 'COMPLETE';
863     return;
864 
865   END IF;
866   --
867   -- CANCEL mode
868   --
869   -- This is in the event that the activity must be undone.
870   --
871   IF (funcmode = 'CANCEL' ) THEN
872     -- The cancel code
873 
874     null;
875     -- no result needed
876     resultout := 'COMPLETE';
877     return;
878   END IF;
879 
880   -- For other execution modes: return null
881 
882   resultout := '';
883   return;
884 
885   EXCEPTION
886     WHEN OTHERS THEN
887     /* Record this function call in the error
888      * system in case of an exception
889      */
890      fnd_message.set_name('XNP','STD_ERROR');
891      fnd_message.set_token(
892        'ERROR_LOCN','XNP_WF_TIMERS.DEREGISTER');
893      if(l_error_code <> 0) then
894 		fnd_message.set_token('ERROR_TEXT',
895        ':'||to_char(l_error_code)||':'||l_error_message);
896      else
897        fnd_message.set_token('ERROR_TEXT',
898          ':'||to_char(SQLCODE)||':'||SQLERRM);
899      end if;
900      x_progress := fnd_message.get;
901      wf_core.context(
902         'XNP_WF_TIMERS'
903         , 'DEREGISTER'
904         , itemtype
905         , itemkey
906         , to_char(actid)
907         , funcmode
908         , x_progress);
909 
910       RAISE;
911 
912 END deregister;
913 
914 -----------------------------------------------------------------------
915 ----- API Name   : Get Jeopardy Flag
916 ----- Type       : Public
917 ----- Purpose    : Retrieves the jeopardy flag for the given order id
918 ----- Parameters : ITEMTYPE
919 -----              ITEMKEY
920 -----              ACTID
921 -----              FUNCMODE
922 -----              RESULTOUT
923 ------------------------------------------------------------------------
924 PROCEDURE GET_JEOPARDY_FLAG
925  (ITEMTYPE IN VARCHAR2
926  ,ITEMKEY IN VARCHAR2
927  ,ACTID IN NUMBER
928  ,FUNCMODE IN VARCHAR2
929  ,RESULTOUT OUT NOCOPY VARCHAR2
930  )
931 IS
932  x_progress VARCHAR2(2000);
933  l_order_id	NUMBER;
934  l_flag		VARCHAR2(1);
935  l_error_code NUMBER := 0;
936  l_error_message VARCHAR2(2000);
937  l_workitem_instance_id NUMBER;
938  e_get_jeopardy_flag	EXCEPTION;
939 
940 BEGIN
941 
942   --
943   -- RUN mode - normal process execution
944   --
945 
946   IF (funcmode = 'RUN') THEN
947 
948     l_order_id :=
949       wf_engine.GetItemAttrNumber
950       (itemtype => itemtype
951       ,itemkey  => itemkey
952       ,aname   => 'ORDER_ID'
953       );
954 
955     -- The run code
956 
957     -- Get the event type to publish
958 
959     XNP_TIMER_STANDARD.get_jeopardy_flag
960     (
961      p_order_id => l_order_id
962      ,x_flag => l_flag
963      ,x_error_code => l_error_code
964      ,x_error_message => l_error_message
965     );
966 
967     IF l_error_code <> 0
968     THEN
969 	raise e_get_jeopardy_flag;
970     END IF;
971 
972     IF( l_flag = 'Y' ) THEN
973       FireDefaultJeopardyTimer( GET_JEOPARDY_FLAG.ITEMTYPE,
974                                 GET_JEOPARDY_FLAG.ITEMKEY );
975     END IF;
976 
977     -- Completion
978     resultout := 'COMPLETE';
979     return;
980 
981   END IF;
982   --
983   -- CANCEL mode
984   --
985   -- This is in the event that the activity must be undone.
986   --
987   IF (funcmode = 'CANCEL' ) THEN
988     -- The cancel code
989 
990     null;
991     -- no result needed
992     resultout := 'COMPLETE';
993     return;
994   END IF;
995 
996   -- For other execution modes: return null
997 
998   resultout := '';
999   return;
1000 
1001   EXCEPTION
1002     WHEN OTHERS THEN
1003     /* Record this function call in the error
1004      * system in case of an exception
1005      */
1006      fnd_message.set_name('XNP','STD_ERROR');
1007      fnd_message.set_token(
1008        'ERROR_LOCN','XNP_WF_TIMERS.GET_JEOPARDY_FLAG');
1009      if(l_error_code <> 0) then
1010 		fnd_message.set_token('ERROR_TEXT',
1011        ':'||to_char(l_error_code)||':'||l_error_message);
1012      else
1013        fnd_message.set_token('ERROR_TEXT',
1014          ':'||to_char(SQLCODE)||':'||SQLERRM);
1015      end if;
1016      x_progress := fnd_message.get;
1017      wf_core.context(
1018         'XNP_WF_TIMERS'
1019         , 'GET_JEOPARDY_FLAG'
1020         , itemtype
1021         , itemkey
1022         , to_char(actid)
1023         , funcmode
1024         , x_progress);
1025 
1026       RAISE;
1027 
1028 END GET_JEOPARDY_FLAG;
1029 
1030 PROCEDURE FireDefaultJeopardyTimer ( itemtype IN VARCHAR2
1031                                     ,itemkey IN VARCHAR2 )
1032 IS
1033   l_timer_id   NUMBER;
1034   l_timer_contents   VARCHAR2(200);
1035   l_error_code NUMBER;
1036   l_error_message VARCHAR2(200);
1037   p_sender_name VARCHAR2(200);
1038   p_recipient_list VARCHAR2(200);
1039   p_version NUMBER;
1040   l_reference_id VARCHAR2(200);
1041   l_opp_reference_id VARCHAR2(200);
1042   l_order_id NUMBER;
1043   p_wi_instance_id NUMBER;
1044   p_fa_instance_id  NUMBER;
1045 
1046   timerException exception;
1047 BEGIN
1048 
1049   l_order_id := wf_engine.GetItemAttrNumber(itemtype => FireDefaultJeopardyTimer.itemtype,
1050                                           itemkey => FireDefaultJeopardyTimer.itemkey,
1051                                           aname => 'ORDER_ID');
1052 
1053   l_reference_id := to_char( l_order_id );
1054   l_opp_reference_id := l_reference_id;
1055 
1056   XNP_T_DEF_JEOPARDY_TMR_U.FIRE( x_timer_id => l_timer_id,
1057                                  x_timer_contents => l_timer_contents,
1058 				 x_error_code => l_error_code,
1059                                  x_error_message => l_error_message,
1060 				 p_reference_id => l_reference_id,
1061 				 p_opp_reference_id => l_opp_reference_id,
1062 				 p_order_id => l_order_id);
1063 
1064   IF( l_error_code <> 0 ) THEN
1065      raise timerException;
1066   END IF;
1067 
1068   EXCEPTION
1069     WHEN OTHERS THEN
1070      wf_core.context(  'XNP_WF_TIMERS'  , 'FireDefaultJeopardyTimer'  , itemtype  , itemkey, l_error_message );
1071 
1072 END FireDefaultJeopardyTimer;
1073 
1074 END XNP_WF_TIMERS;