[Home] [Help]
PACKAGE BODY: APPS.ASP_ALERTS_WF
Source
1 PACKAGE BODY ASP_ALERTS_WF as
2 /* $Header: aspalrtb.pls 120.5 2005/09/09 17:45 axavier noship $ */
3 ---------------------------------------------------------------------------
4 -- Package Name: ASP_ALERTS_WF
5 ---------------------------------------------------------------------------
6 -- Description:
7 -- This package contains functions associated with the Workflow Activity
8 -- node that interfaces with BSA Workflow and used in the Sales Alerts System.
9 --
10 -- Procedures:
11 -- (see the specification for details)
12 --
13 -- History:
14 -- 10-Aug-2005 axavier created.
15 ---------------------------------------------------------------------------
16
17 /*-------------------------------------------------------------------------*
18 | Private Constants
19 *-------------------------------------------------------------------------*/
20 G_PKG_NAME CONSTANT VARCHAR2(30):= 'ASP_ALERTS_WF';
21 G_FILE_NAME CONSTANT VARCHAR2(12) := 'aspalrtb.pls';
22 G_MODULE CONSTANT VARCHAR2(250) := 'asp.plsql.'||G_PKG_NAME||'.';
23 /*-------------------------------------------------------------------------*
24 | Private Datatypes
25 *-------------------------------------------------------------------------*/
26
27 /*-------------------------------------------------------------------------*
28 | Private Variables
29 *-------------------------------------------------------------------------*/
30
31 /*-------------------------------------------------------------------------*
32 | Private Routines Specification
33 *-------------------------------------------------------------------------*/
34
35 /*-------------------------------------------------------------------------*
36 | Public Routines
37 *-------------------------------------------------------------------------*/
38
39 --------------------------------------------------------------------------------
40 -- Procedure: Initiate_Bsa_Alerts
41 -- This function is associated with the BSA activity node and will launch the
42 -- ASP ALERTS workflow Process.
43 --
44 --------------------------------------------------------------------------------
45
46 PROCEDURE Initiate_Bsa_Alerts(
47 itemtype in VARCHAR2,
48 itemkey in VARCHAR2,
49 actid in NUMBER,
50 funcmode in VARCHAR2,
51 resultout in out NOCOPY VARCHAR2)
52 IS
53 l_event_entity varchar2(100);
54 l_api_name varchar2(100);
55 l_qualified_api_name varchar2(200);
56 l_debug_msg varchar2(1000);
57 l_blanketHeaderId number;
58 l_item_key varchar2(240);
59 l_pre_expire_time_percent varchar2(100);
60 save_threshold number;
61
62 l_debug_runtime number;
63 l_debug_exception number;
64 l_debug_procedure number;
65 l_debug_statment number;
66
67 BEGIN
68 l_api_name := 'Initiate_Bsa_Alerts';
69 l_debug_runtime := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
70 l_debug_exception := FND_LOG.LEVEL_EXCEPTION;
71 l_debug_procedure := FND_LOG.LEVEL_PROCEDURE;
72 l_debug_statment := FND_LOG.LEVEL_STATEMENT;
73
74 save_threshold := wf_engine.threshold;
75 l_qualified_api_name := G_PKG_NAME||'.'||l_api_name;
76 if(l_debug_procedure >= l_debug_runtime) then
77 fnd_log.string(l_debug_procedure, G_MODULE||l_api_name, 'Entered '||G_PKG_NAME||'.'||l_api_name);
78 end if;
79
80 If(funcmode = 'RUN') Then
81 -- l_pre_expire_time_percent := wf_engine.GetItemAttrText( itemtype =>itemtype,
82 -- itemkey =>itemkey,
83 -- aname =>'PRE_EXPIRE_TIME_PERCENT');
84 l_pre_expire_time_percent := wf_engine.GetActivityAttrText( itemtype =>itemtype,
85 itemkey =>itemkey,
86 actid => actid,
87 aname =>'ALERT_PRE_EXPIRE_TIME_PERCENT');
88 -- Construct the unique item key
89 l_blanketHeaderId := To_number(itemkey);
90
91 --======================================================
92 SELECT l_blanketHeaderId ||'-'|| to_char(asp_wf_alerts_s.nextval) INTO l_item_key FROM DUAL;
93 -- Start the ASP Alert Manager Process (ASP_ALERT_PROCESS) with the following info:
94 wf_engine.threshold := -1;
95 wf_engine.CreateProcess( itemtype => 'ASPALERT', itemkey => l_item_key, process => 'ASP_ALERT_PROCESS',user_key=>l_item_key);
96 wf_engine.SetItemAttrText('ASPALERT', l_item_key, 'ALERT_NAME', 'BSA_PRE_EXPIRE_ALERT');
97 wf_engine.SetItemAttrText('ASPALERT', l_item_key, 'ALERT_SOURCE_OBJECT_CODE', 'ORDER');
98 wf_engine.SetItemAttrText('ASPALERT', l_item_key, 'ALERT_SOURCE_OBJECT_ID', l_blanketHeaderId);
99 wf_engine.SetItemAttrText('ASPALERT', l_item_key, 'ALERT_PRE_EXPIRE_TIME_PERCENT', l_pre_expire_time_percent);
100 wf_engine.StartProcess(itemtype => 'ASPALERT', itemkey => l_item_key);
101 commit;
102 resultout := 'COMPLETE:SUCCESS';
103 wf_engine.threshold := save_threshold;
104 return;
105 --======================================================
106
107 --May be needed latter
108 --======================================================
109 /*******************************************************
110 wf_engine.SetItemAttrText('ASPALERT', l_item_key, 'ALERT_NAME', 'BSA_PRE_EXPIRE_ALERT');
111 wf_engine.SetItemAttrText('ASPALERT', l_item_key, 'ALERT_SOURCE_OBJECT_CODE', 'ORDER');
112 wf_engine.SetItemAttrText('ASPALERT', l_item_key, 'ALERT_SOURCE_OBJECT_ID', l_blanketHeaderId);
113 --wf_engine.SetItemAttrText('ASPALERT', l_item_key, 'ALERT_PRE_EXPIRE_TIME_PERCENT', l_pre_expire_time_percent);
114 if(l_debug_procedure >= l_debug_runtime) then
115 fnd_log.string(l_debug_procedure, G_MODULE||l_api_name, 'ALERT_NAME '||'BSA_PRE_EXPIRE_ALERT');
116 fnd_log.string(l_debug_procedure, G_MODULE||l_api_name, 'ALERT_SOURCE_OBJECT_CODE '||'ORDER');
117 fnd_log.string(l_debug_procedure, G_MODULE||l_api_name, 'l_blanketHeaderId '||l_blanketHeaderId);
118 --fnd_log.string(l_debug_procedure, G_MODULE||l_api_name, 'l_pre_expire_time_percent '||l_pre_expire_time_percent);
119 end if;
120
121 resultout := 'COMPLETE:SUCCESS';
122 return;
123 ********************************************************/
124 --======================================================
125
126 End If;
127 --
128 -- Other execution modes may be created in the future. Your
129 -- activity will indicate that it does not implement a mode
130 -- by returning null
131 --
132 resultout := '';
133 wf_engine.threshold := save_threshold;
134 return;
135
136 EXCEPTION
137 When no_data_found Then
138 wf_core.context(G_PKG_NAME, l_api_name, itemtype, itemkey, to_char(actid), funcmode);
139 l_debug_msg := l_qualified_api_name||':NO_DATA_FOUND:'||to_char(SQLCODE)||':'||substr(SQLERRM,1,500);
140 wf_core.token('ORA_ERROR',l_debug_msg);
141 wf_engine.threshold := save_threshold;
142 wf_core.raise('WF_ORA');
143
144 When others Then
145 wf_core.context(G_PKG_NAME, l_api_name, itemtype, itemkey, to_char(actid), funcmode);
146 l_debug_msg := l_qualified_api_name||':OTHERS:'||to_char(SQLCODE)||':'||substr(SQLERRM,1,500);
147 wf_core.token('ORA_ERROR',l_debug_msg);
148 wf_engine.threshold := save_threshold;
149 wf_core.raise('WF_ORA');
150
151 END Initiate_Bsa_Alerts;
152
153
154 End ASP_ALERTS_WF;