DBA Data[Home] [Help]

PACKAGE BODY: APPS.XDPCORE_ERROR

Source


1 PACKAGE BODY XDPCORE_ERROR AS
2 /* $Header: XDPCORRB.pls 120.2 2006/04/10 23:23:04 dputhiye noship $ */
3 
4 
5 /****
6  All Private Procedures for the Package
7 ****/
8 
9 Function HandleOtherWFFuncmode (funcmode in varchar2) return varchar2;
10 
11 Function FeErrorProcessOptions(itemtype in varchar2,
12                           itemkey in varchar2,
13                           actid in number) return varchar2;
14 
15 Procedure PrepareErrorMessage(itemtype in varchar2,
16                               itemkey in varchar2,
17                                actid in number);
18 
19 
20 Procedure NotifyOutsideSystemOfError(itemtype in varchar2,
21                                      itemkey in varchar2,
22                                      actid in number);
23 
24 Procedure FeErrorNotif (itemtype in varchar2,
25                        itemkey in varchar2,
26                        actid in number,
27                        funcmode in varchar2,
28                        result out NOCOPY varchar2);
29 
30 Function GetNotifRecepient return varchar2;
31 
32 Function GetResubmissionJobID (itemtype in varchar2,
33                                itemkey in varchar2) return number;
34 
35 Procedure SetErrorContext (itemtype in varchar2,
36                        itemkey in varchar2);
37 
38 type RowidArrayType is table of rowid index by binary_integer;
39 
40 
41 
42 /***********************************************
43 * END of Private Procedures/Function Definitions
44 ************************************************/
45 
46 
47 --  FE_ERR_NTF
48 --   Resultout
49 --     Activity Performed   - Activity was completed without any errors
50 --
51 -- Your Description here:
52 
53 Procedure FE_ERR_NTF (itemtype        in varchar2,
54 			itemkey         in varchar2,
55 			actid           in number,
56 			funcmode        in varchar2,
57 			resultout       out NOCOPY varchar2 ) IS
58 
59  x_Progress                     VARCHAR2(2000);
60 
61 BEGIN
62 -- RUN mode - normal process execution
63 --
64         IF (funcmode = 'RUN') THEN
65 --      <your procedure here>
66                 FeErrorNotif (itemtype, itemkey, actid, funcmode, resultout);
67                 return;
68         ELSE
69                 return;
70         END IF;
71 
72 EXCEPTION
73 WHEN OTHERS THEN
74  wf_core.context('XDPCORE_ERROR', 'FE_ERR_NTF', itemtype, itemkey, to_char(actid), funcmode);
75  raise;
76 END FE_ERR_NTF;
77 
78 
79 --  FE_ERROR_PROCESS_OPTIONS
80 --   Resultout
81 --     Activity Performed   - Activity was completed without any errors
82 --
83 -- Your Description here:
84 
85 Procedure FE_ERROR_PROCESS_OPTIONS (itemtype        in varchar2,
86 			itemkey         in varchar2,
87 			actid           in number,
88 			funcmode        in varchar2,
89 			resultout       out NOCOPY varchar2 ) IS
90 
91 l_result varchar2(40);
92 
93  x_Progress                     VARCHAR2(2000);
94 
95 BEGIN
96 -- RUN mode - normal process execution
97 --
98 	IF (funcmode = 'RUN') THEN
99                 l_result := FeErrorProcessOptions(itemtype, itemkey, actid);
100 		resultout := 'COMPLETE:' || l_result;
101                 return;
102         ELSE
103                 resultout := HandleOtherWFFuncmode(funcmode);
104                 return;
105         END IF;
106 
107 
108 EXCEPTION
109 WHEN OTHERS THEN
110  wf_core.context('XDPCORE_ERROR', 'FE_ERROR_PROCESS_OPTIONS', itemtype, itemkey, to_char(actid), funcmode);
111  raise;
112 END FE_ERROR_PROCESS_OPTIONS;
113 
114 
115 --  PREPARE_ERROR_MESSAGE
116 --   Resultout
117 --     Activity Performed   - Activity was completed without any errors
118 --
119 -- Your Description here:
120 
121 Procedure PREPARE_ERROR_MESSAGE (itemtype        in varchar2,
122 			itemkey         in varchar2,
123 			actid           in number,
124 			funcmode        in varchar2,
125 			resultout       out NOCOPY varchar2 ) IS
126 
127  x_Progress                     VARCHAR2(2000);
128 
129 BEGIN
130 -- RUN mode - normal process execution
131 --
132 	IF (funcmode = 'RUN') THEN
133                 PrepareErrorMessage(itemtype, itemkey, actid);
134 		resultout := 'COMPLETE:ACTIVITY_PERFORMED';
135                 return;
136         ELSE
137                 resultout := HandleOtherWFFuncmode(funcmode);
138                 return;
139         END IF;
140 
141 
142 EXCEPTION
143 WHEN OTHERS THEN
144  wf_core.context('XDPCORE_ERROR', 'PREPARE_ERROR_MESSAGE', itemtype, itemkey, to_char(actid), funcmode);
145  raise;
146 END PREPARE_ERROR_MESSAGE;
147 
148 
149 --  NOTIFY_OUTSIDE_SYSTEM_OF_ERROR
150 --   Resultout
151 --     Activity Performed   - Activity was completed without any errors
152 --
153 -- Your Description here:
154 
155 Procedure NOTIFY_OUTSIDE_SYSTEM_OF_ERROR (itemtype        in varchar2,
156 			itemkey         in varchar2,
157 			actid           in number,
158 			funcmode        in varchar2,
159 			resultout       out NOCOPY varchar2 ) IS
160 
161  x_Progress                     VARCHAR2(2000);
162 
163 BEGIN
164 -- RUN mode - normal process execution
165 --
166 	IF (funcmode = 'RUN') THEN
167                 NotifyOutsideSystemOfError(itemtype, itemkey, actid);
168 		resultout := 'COMPLETE:ACTIVITY_PERFORMED';
169                 return;
170         ELSE
171                 resultout := HandleOtherWFFuncmode(funcmode);
172                 return;
173         END IF;
174 
175 
176 EXCEPTION
177 WHEN OTHERS THEN
178  wf_core.context('XDPCORE_ERROR', 'NOTIFY_OUTSIDE_SYSTEM_OF_ERROR', itemtype, itemkey, to_char(actid), funcmode);
179  raise;
180 END NOTIFY_OUTSIDE_SYSTEM_OF_ERROR;
181 
182 Procedure SET_ERROR_CONTEXT (itemtype        in varchar2,
183 			itemkey         in varchar2,
184 			actid           in number,
185 			funcmode        in varchar2,
186 			resultout       out NOCOPY varchar2 ) IS
187 
188  x_Progress                     VARCHAR2(2000);
189 
190 BEGIN
191 -- RUN mode - normal process execution
192 --
193 	IF (funcmode = 'RUN') THEN
194                 SetErrorContext(itemtype, itemkey);
195 		resultout := 'COMPLETE';
196                 return;
197         ELSE
198                 resultout := HandleOtherWFFuncmode(funcmode);
199                 return;
200         END IF;
201 
202 
203 EXCEPTION
204 WHEN OTHERS THEN
205  wf_core.context('XDPCORE_ERROR', 'SET_ERROR_CONTEXT', itemtype, itemkey, to_char(actid), funcmode);
206  raise;
207 END SET_ERROR_CONTEXT;
208 
209 Procedure LOG_SESSION_ERROR( p_errory_type in varchar2)
210 IS
211 
212 l_object_type   VARCHAR2(2000);
213 l_object_key     VARCHAR2(32000);
214 l_error_name      VARCHAR2(30);
215 l_error_message   VARCHAR2(2000);
216 l_error_stack     VARCHAR2(32000);
217 
218 BEGIN
219 
220   XDP_ERRORS_PKG.set_message( XDPCORE.object_type, XDPCORE.object_key, XDPCORE.error_name, XDPCORE.error_message, p_errory_type );
221 
222 EXCEPTION
223   WHEN others THEN
224    raise;
225 END LOG_SESSION_ERROR;
226 
227 /****
228  All the Private Functions
229 ****/
230 
231 Function GetResubmissionJobID (itemtype in varchar2,
232                                itemkey in varchar2) return number is
233  l_JobID number;
234  e_UnhandledException exception;
235 begin
236  begin
237    l_JobID := wf_engine.GetItemAttrNumber(itemtype => GetResubmissionJobID.itemtype,
238                                           itemkey => GetResubmissionJobID.itemkey,
239                                           aname => 'RESUBMISSION_JOB_ID');
240 
241  exception
242  when others then
243   if sqlcode = -20002 then
244       l_JobID := 0;
245       wf_core.clear;
246   else
247     raise e_UnhandledException;
248   end if;
249  end;
250 
251  return l_JobID;
252 
253 End GetResubmissionJobID;
254 
255 Function HandleOtherWFFuncmode( funcmode in varchar2) return varchar2
256 is
257 resultout varchar2(30);
258  x_Progress                     VARCHAR2(2000);
259 
260 begin
261 
262         IF (funcmode = 'CANCEL') THEN
263                 resultout := 'COMPLETE';
264         END IF;
265 
266         IF (funcmode = 'RESPOND') THEN
267                 resultout := 'COMPLETE';
268         END IF;
269 
270         IF (funcmode = 'FORWARD') THEN
271                 resultout := 'COMPLETE';
272         END IF;
273 
274         IF (funcmode = 'TRANSFER') THEN
275                 resultout := 'COMPLETE';
276         END IF;
277 
278         IF (funcmode = 'TIMEOUT') THEN
279                 resultout := 'COMPLETE';
280         END IF;
281 
282         IF (funcmode = 'others') THEN
283                 resultout := 'COMPLETE';
284         END IF;
285 
286 
287         return resultout;
288 
289 end;
290 
291 
292 
293 
294 Function FeErrorProcessOptions (itemtype in varchar2,
295                                 itemkey in varchar2,
296                                 actid in number) return varchar2
297 
298 is
299  l_ProcessOption varchar2(40);
300 
301  x_Progress                     VARCHAR2(2000);
302 
303 begin
304 
305  l_ProcessOption :=  wf_engine.GetActivityAttrText( itemtype => FeErrorProcessOptions.itemtype,
306                                                     itemkey => FeErrorProcessOptions.itemkey,
307                                                     actid => FeErrorProcessOptions.actid,
308                                                     aname => 'FE_ERROR_PROCESS_OPTION');
309 
310  return (l_ProcessOption);
311 
312 exception
313 when others then
314    x_Progress := 'XDPCORE_ERROR.FeErrorProcessOptions. Unhandled Exception: ' || SUBSTR(SQLERRM, 1, 1500);
315    wf_core.context('XDPCORE_ERROR', 'FeErrorProcessOptions', itemtype, itemkey, to_char(actid), x_Progress);
316    raise;
317 end FeErrorProcessOptions;
318 
319 
320 
321 Procedure PrepareErrorMessage (itemtype in varchar2,
322                                itemkey in varchar2,
323                                actid in number)
324 is
325 
326  x_Progress                     VARCHAR2(2000);
327  l_ResubmissionJOBID number;
328 
329  l_NtfSubject varchar2(1000);
330  l_ErrorDesc varchar2(4000);
331  l_ErrorType varchar2(20);
332 
333  l_NtfDesc varchar2(4000);	--Size of this var (4000) is utilized to fix bug 4112678. dputhiye. 21-Feb-2005
334 				--Any change in this value should be rippled to this fix in this procedure.
335 
336  l_FAInstanceID number;
337 
338  l_OrderID number;
339  l_OrderNumber varchar2(40);
340  l_OrderVersion varchar2(40);
341  l_FAName varchar2(80);
342  l_FEName varchar2(80);
343  l_WIName varchar2(80);
344  l_LineName varchar2(40);
345  l_WIResponsiblity varchar2(200);
346  l_status VARCHAR2(1);
347  lv_fp_name VARCHAR2(80);
348  lv_fp_disp_name VARCHAR2(80);
349  ErrCode number;
350  ErrStr varchar2(2000);
351 
352  e_AddAttrException exception;
353 
354   CURSOR cur_error_count(cv_fp_name  varchar2) IS
355   SELECT error_count
356     FROM xdp_error_count
357    WHERE object_key = cv_fp_name
358      AND object_type = XDP_UTILITIES.g_fp_object_type;
359 
360 begin
361 null;
362 
363  l_FAInstanceID := wf_engine.GetItemAttrNumber(itemtype => PrepareErrorMessage.itemtype,
364                                                itemkey => PrepareErrorMessage.itemkey,
365                                                aname => 'FA_INSTANCE_ID');
366 
367 
368  l_ErrorDesc := wf_engine.GetItemAttrText(itemtype => PrepareErrorMessage.itemtype,
369                                           itemkey => PrepareErrorMessage.itemkey,
370                                           aname => 'FE_ERROR_DESCRIPTION');
371 
372 -- Place Holder until FND Bug 2064891 is resolved.
373 
374 	 --l_ErrorDesc := replace(l_ErrorDesc, chr(0), '');
375 	 l_ErrorDesc := replace(l_ErrorDesc, fnd_global.local_chr(0), '');
376 
377  Begin
378      l_ErrorType := wf_engine.GetItemAttrText(itemtype => PrepareErrorMessage.itemtype,
379                                               itemkey => PrepareErrorMessage.itemkey,
380                                               aname => 'FE_ERROR_TYPE');
381 
382          -- reset fe error type to none
383          wf_engine.SetItemAttrText(itemtype => PrepareErrorMessage.itemtype,
384                                    itemkey => PrepareErrorMessage.itemkey,
385                                    aname => 'FE_ERROR_TYPE',
386                                    avalue => 'NONE');
387 
388      exception
389        when others then
390          l_ErrorType := 'NOT_DEFINED';
391        -- this attribute does not exist in the flow as the error occured is an
392        -- unhandled exception..
393  end;
394 
395  /* Get all the Order Config Information to be displayed for the notification */
396 
397  select xoo.order_id, xoo.External_Order_number, NVL(xoo.external_order_version, 'N/A'), xoo.fa_display_name, xoo.wi_display_name, xoo.line_item_name, xfe.display_name
398  into l_OrderID, l_OrderNumber, l_OrderVersion, l_FAName, l_WIName, l_LineName, l_FeName
399  from XDP_ORU_ORDERS_V xoo, XDP_FES_VL xfe
400  where fa_instance_id = l_FAInstanceID
401    and xoo.FE_ID = xfe.fe_id;
402 
403  l_ResubmissionJobID := GetResubmissionJobID(itemtype => PrepareErrorMessage.itemtype,
404                                               itemkey => PrepareErrorMessage.itemkey);
405 
406  if l_ResubmissionJobID <> 0 then
407          FND_MESSAGE.SET_NAME('XDP','XDP_FMC_RESUB_NTF_SUBJECT');
408          FND_MESSAGE.SET_TOKEN('ORDER_NUM', l_OrderNumber);
409          FND_MESSAGE.SET_TOKEN('ORD_VER', l_OrderVersion);
410          FND_MESSAGE.SET_TOKEN('JOBID', to_char(l_ResubmissionJobID));
411          l_NtfSubject := FND_MESSAGE.GET;
412  elsif (l_ErrorType = 'NOTIFY_ERROR') then
413         -- user sent error using NOTIFY_ERROR Macro..
414           FND_MESSAGE.SET_NAME('XDP','XDP_NTF_SBJCT_NTF_ERR');
415           FND_MESSAGE.SET_TOKEN('ORDER_NUM', l_OrderNumber);
416           FND_MESSAGE.SET_TOKEN('ORD_VER', l_OrderVersion);
417           FND_MESSAGE.SET_TOKEN('FA_DISP_NAME', l_FAName);
418           FND_MESSAGE.SET_TOKEN('NOTIFY_ERROR', substr(l_ErrorDesc,1,100));
419           l_NtfSubject := FND_MESSAGE.GET;
420  elsif (l_ErrorType = 'SESSION_LOST') then
421         -- user sent error using NOTIFY_ERROR Macro..
422           FND_MESSAGE.SET_NAME('XDP','XDP_ORDER_SESSION_LOST');
423           FND_MESSAGE.SET_TOKEN('ORDER_NUM', l_OrderNumber);
424           FND_MESSAGE.SET_TOKEN('ORD_VER', l_OrderVersion);
425           FND_MESSAGE.SET_TOKEN('FE_NAME', l_FeName);
426           l_NtfSubject := FND_MESSAGE.GET;
427  else
428         --unhandled exception..
429           lv_fp_name := wf_engine.GetItemAttrText(itemtype => PrepareErrorMessage.itemtype,
430                                                   itemkey => PrepareErrorMessage.itemkey,
431                                                   aname => XDPCORE_FA.g_fp_name );
432 
433           l_status := WF_ENGINE.GetActivityattrtext(itemtype =>PrepareErrorMessage.itemtype,
434                                                     itemkey  =>PrepareErrorMessage.itemkey,
435                                                     actid    =>PrepareErrorMessage.actid,
436                                                     aname    =>'FP_RETRY');
437           IF ( l_status = 'N' ) THEN
438             FND_MESSAGE.SET_NAME('XDP','XDP_FP_ERR_THRSHD_EXCDED');
439             SELECT display_name INTO lv_fp_disp_name
440             FROM xdp_proc_body_vl
441             WHERE proc_name =  lv_fp_name;
442             FND_MESSAGE.SET_TOKEN('FP_NAME', lv_fp_disp_name);
443           ELSE
444             FND_MESSAGE.SET_NAME('XDP','XDP_FMC_NTF_SUBJECT');
445             FND_MESSAGE.SET_TOKEN('FA_DISP_NAME', l_FAName);
446           END IF;
447 
448           FND_MESSAGE.SET_TOKEN('ORDER_NUM', l_OrderNumber);
449           FND_MESSAGE.SET_TOKEN('ORD_VER', l_OrderVersion);
450           l_NtfSubject := FND_MESSAGE.GET;
451  end if;
452          wf_engine.SetItemAttrText(itemtype => PrepareErrorMessage.itemtype,
453                                    itemkey => PrepareErrorMessage.itemkey,
454                                    aname => 'NTF_SUBJECT',
455                                    avalue => l_NtfSubject);
456 
457 
458 
459          FND_MESSAGE.SET_NAME('XDP','XDP_FMC_NTF_ORD_DESC');
460          FND_MESSAGE.SET_TOKEN('ORDER_ID', to_char(l_OrderID));
461          FND_MESSAGE.SET_TOKEN('ORDER_NUMBER', l_OrderNumber);
462          FND_MESSAGE.SET_TOKEN('ORDER_VERSION', l_OrderVersion);
463          FND_MESSAGE.SET_TOKEN('FA', l_FAName);
464          FND_MESSAGE.SET_TOKEN('FE_NAME', l_FEName);
465          FND_MESSAGE.SET_TOKEN('WI', l_WIName);
466          FND_MESSAGE.SET_TOKEN('LINE_NAME', l_LineName);
467 
468          FND_MESSAGE.SET_TOKEN('ERROR_DATE', to_char(SYSDATE,'DD-MON-YYYY HH24:MI:SS'));
469          FND_MESSAGE.SET_TOKEN('ERROR_DESCRIPTION', substr(l_ErrorDesc,1,1000));
470 
471 	l_NtfDesc := FND_MESSAGE.GET;
472         --l_NtfDesc := l_NtfDesc || chr(10) || XDPCORE.error_stack;
473 
474 	--Date: 21-Feb-2005 Author:dputhiye  Bug#:4112678 (Bug 3998762 on 11.5.9)
475         --l_NtfDesc := l_NtfDesc || fnd_global.local_chr(10) || XDPCORE.error_stack;
476 	--The source line commented above has been replaced with the line below.
477 	--error_stack lengths during runtime can get to 32,000+ and must be truncated here to fit in l_NtfDesc.
478 	--Length of the variable l_NtfDesc is 4000, and any change in the declaration must be reflected here.
479         l_NtfDesc := l_NtfDesc || fnd_global.local_chr(10) || substr(XDPCORE.error_stack, 1, 3999 - length(l_NtfDesc));
480 	--End of fix for 4112678
481 
482         -- clear the stack..
483         XDPCORE.error_stack := NULL;
484 
485          wf_engine.SetItemAttrText(itemtype => PrepareErrorMessage.itemtype,
486                                    itemkey => PrepareErrorMessage.itemkey,
487                                    aname => 'NTF_BODY',
488                                    avalue => substr(l_NtfDesc,1,1999));
489 
490          /* future functionality
491          l_WIResponsiblity := XDPCORE_WI.get_wi_responsibility( PrepareErrorMessage.itemtype,
492                                                                 PrepareErrorMessage.itemkey );
493 
494          wf_engine.SetItemAttrText(itemtype => PrepareErrorMessage.itemtype,
495                                    itemkey => PrepareErrorMessage.itemkey,
496                                    aname => 'ERROR_RECEPIENT',
497                                    avalue => l_WIResponsiblity);
498          */
499 
500 exception
501 when e_AddAttrException then
502  x_progress := 'XDPCORE.ERROR.PrepareErrorMessage. Error when adding attribute dynamically. Error: ' ||
503 SUBSTR(ErrStr,1,1500);
504    wf_core.context('XDPCORE_ERROR', 'PrepareErrorMessage', itemtype, itemkey, null, x_Progress);
505    raise;
506 
507 when others then
508    x_Progress := 'XDPCORE_ERROR.PrepareErrorMessage. Unhandled Exception: ' || SUBSTR(SQLERRM, 1, 1500);
509    wf_core.context('XDPCORE_ERROR', 'PrepareErrorMessage', itemtype, itemkey, null, x_Progress);
510    raise;
511 end PrepareErrorMessage;
512 
513 
514 
515 Function GetNotifRecepient return varchar2 is
516 
517   l_NotifReceipent varchar2(100);
518 begin
519 
520 -- Hard Code this for now!!!
521   l_NotifReceipent := 'FND_RESP535:21704';
522 
523  return l_NotifReceipent;
524 
525 end GetNotifRecepient;
526 
527 
528 Procedure NotifyOutsideSystemOfError (itemtype in varchar2,
529                                       itemkey in varchar2,
530                                      actid in number)
531 is
532  x_Progress                     VARCHAR2(2000);
533 
534 begin
535 
536  -- Not yet supported
537 	null;
538 
539 exception
540 when others then
541    x_Progress := 'XDPCORE_ERROR.NotifyOutsideSystemOfError. Unhandled Exception: ' || SUBSTR(SQLERRM, 1, 1500);
542    wf_core.context('XDPCORE_ERROR', 'NotifyOutsideSystemOfError', itemtype, itemkey, to_char(actid), x_Progress);
543    raise;
544 end NotifyOutsideSystemOfError;
545 
546 
547 Procedure FeErrorNotif (itemtype in varchar2,
548                        itemkey in varchar2,
549                        actid in number,
550                        funcmode in varchar2,
551                        result out NOCOPY varchar2)
552 
553 is
554 
555  x_Progress                     VARCHAR2(2000);
556 
557 begin
558 
559  -- Not yet supported
560 	null;
561 
562 exception
563 when others then
564    x_Progress := 'XDPCORE_ERROR.FeErrorNotif. Unhandled Exception: ' || SUBSTR(SQLERRM, 1, 1500);
565 wf_core.context('XDPCORE_ERROR', 'FeErrorNotif', itemtype, itemkey, null, x_Progress);
566   raise;
567 end FeErrorNotif;
568 
569 Procedure SetErrorContext (itemtype in varchar2,
570                        itemkey in varchar2)
571 
572 is
573  l_object_type   VARCHAR2(2000);
574  l_object_key     VARCHAR2(32000);
575  l_error_name      VARCHAR2(30);
576  l_error_message   VARCHAR2(2000);
577  l_error_stack     VARCHAR2(32000);
578  l_order_number  VARCHAR2(40);
579  l_order_version  VARCHAR2(40);
580 
581 
582  l_OrderID NUMBER;
583  l_LineID NUMBER;
584  l_WIInstaceID NUMBER;
585  l_FAInstanceID NUMBER;
586  l_NtfSubject VARCHAR2(2000);
587  l_NtfBody VARCHAR2(2000);
588  l_WIResponsiblity VARCHAR2(100);
589  l_LineName varchar2(100);
590  l_wi_disp_name varchar2(100);
591  l_fa_disp_name varchar2(100);
592  x_Progress                     VARCHAR2(2000);
593  l_NtfURL VARCHAR2(1000);
594  l_click_here VARCHAR2(300);
595  l_text       VARCHAR2(300);
596 
597 begin
598    l_OrderID := wf_engine.GetItemAttrNumber(itemtype => SetErrorContext.itemtype,
599                                           itemkey => SetErrorContext.itemkey,
600                                           aname => 'ORDER_ID');
601     SELECT external_order_number, external_order_version
602       INTO l_order_number, l_order_version
603     FROM XDP_ORDER_HEADERS WHERE order_id = l_OrderID;
604 
605 
606     l_LineID := wf_engine.GetItemAttrNumber(itemtype => SetErrorContext.itemtype,
607                                             itemkey => SetErrorContext.itemkey,
608                                             aname => 'LINE_ITEM_ID');
609 
610     SELECT line_item_name INTO l_LineName FROM xdp_order_line_items WHERE line_item_id = l_LineID;
611 
612     FND_MESSAGE.SET_NAME('XDP','XDP_ORDER_DETAILS');
613     FND_MESSAGE.SET_TOKEN('ORD_NUM', l_order_number);
614     FND_MESSAGE.SET_TOKEN('ORD_VER', l_order_version);
615     FND_MESSAGE.SET_TOKEN('ORD_ID', l_OrderID);
616     FND_MESSAGE.SET_TOKEN('LINE_NAME', l_LineName);
617     l_NtfBody := l_NtfBody || FND_MESSAGE.GET;
618 
619     begin
620       l_WIInstaceID := wf_engine.GetItemAttrNumber(itemtype => SetErrorContext.itemtype,
621                                           itemkey => SetErrorContext.itemkey,
622                                           aname => 'WORKITEM_INSTANCE_ID');
623 
624       l_wi_disp_name := XDPCORE_WI.get_display_name( l_WIInstaceID );
625 
626       FND_MESSAGE.SET_NAME('XDP','XDP_WI_DISP_NAME');
627       FND_MESSAGE.SET_TOKEN('WI', l_wi_disp_name);
628       --l_NtfBody := l_NtfBody || FND_MESSAGE.GET ||CHR(10);
629       l_NtfBody := l_NtfBody || FND_MESSAGE.GET || fnd_global.local_CHR(10);
630 
631 
632       XDP_NOTIFICATIONS.Get_WI_Update_URL(l_WIInstaceID,
633                                           l_OrderID,
634                                           itemtype,
635                                           itemKey,
636                                           l_NtfURL);
637 
638       --09/26/2002 HBCHUNG
639       --setting Notification URL
640       wf_engine.SetItemAttrText(itemtype => SetErrorContext.itemtype,
641                                 itemkey => SetErrorContext.itemkey,
642                                 aname => 'NTF_URL',
643                                 avalue => l_NtfURL );
644 
645    exception
646      when others then
647      --not at WI level do nothing..
648      null;
649    end;
650 
651    begin
652    l_FAInstanceID := wf_engine.GetItemAttrNumber(itemtype => SetErrorContext.itemtype,
653                                           itemkey => SetErrorContext.itemkey,
654                                           aname => 'FA_INSTANCE_ID');
655 
656       l_fa_disp_name := XDPCORE_FA.get_display_name( l_FAInstanceID );
657 
658       FND_MESSAGE.SET_NAME('XDP','XDP_FA_DISP_NAME');
659       FND_MESSAGE.SET_TOKEN('FA', l_fa_disp_name);
660       --l_NtfBody := l_NtfBody || FND_MESSAGE.GET ||CHR(10);
661       l_NtfBody := l_NtfBody || FND_MESSAGE.GET || fnd_global.local_CHR(10);
662    exception
663      when others then
664      --not at FA level do nothing..
665      null;
666   end;
667 
668   -- set error date..
669   FND_MESSAGE.SET_NAME('XDP', 'XDP_ERROR_DATE');
670   FND_MESSAGE.SET_TOKEN('ERROR_DATE', to_char(SYSDATE,'DD-MON-YYYY HH24:MI:SS'));
671   --l_NtfBody := l_NtfBody || FND_MESSAGE.GET ||CHR(10);
672   l_NtfBody := l_NtfBody || FND_MESSAGE.GET || fnd_global.local_CHR(10);
673 
674   l_NtfSubject := l_order_number||' ( '||l_order_version||' ):';
675   -- get error set in the context..
676   XDPCORE.get_error(l_object_type, l_object_key,
677 	    l_error_name, l_error_message, l_error_stack);
678 
679   -- get the translated message....
680   l_NtfSubject := l_NtfSubject || XDP_ERRORS_PKG.get_message( l_error_name, l_error_message );
681 
682   -- set the Notification Subject...
683   wf_engine.SetItemAttrText(itemtype => SetErrorContext.itemtype,
684                             itemkey => SetErrorContext.itemkey,
685                             aname => 'NTF_SUBJECT',
686                             avalue => l_NtfSubject);
687 
688   l_NtfBody := l_NtfBody || substr( l_error_stack, 1, 1999 );
689 
690   wf_engine.SetItemAttrText(itemtype => SetErrorContext.itemtype,
691                             itemkey => SetErrorContext.itemkey,
692                             aname => 'NTF_BODY',
693                             avalue => l_NtfBody );
694 
695   /*
696   -- In future we may want to send the notifications to the data entry folks registered while
697   -- creating the workitems...
698   l_WIResponsiblity := XDPCORE_WI.get_wi_responsibility( SetErrorContext.itemtype,
699                                    SetErrorContext.itemkey );
700 
701   IF l_WIResponsiblity is not null THEN
702     wf_engine.SetItemAttrText(itemtype => SetErrorContext.itemtype,
703                               itemkey => SetErrorContext.itemkey,
704                               aname => 'ERROR_RECEPIENT',
705                               avalue => l_WIResponsiblity);
706   END IF;
707   */
708 
709 
710 exception
711 when others then
712    x_Progress := 'XDPCORE_ERROR.SetErrorContext. Unhandled Exception: ' || SUBSTR(SQLERRM, 1, 1500);
713 wf_core.context('XDPCORE_ERROR', 'SetErrorContext', itemtype, itemkey, null, x_Progress);
714   raise;
715 end SetErrorContext;
716 
717 
718 End XDPCORE_ERROR;