[Home] [Help]
PACKAGE BODY: APPS.AMS_TCOP_WF_PKG
Source
1 PACKAGE BODY AMS_TCOP_WF_PKG AS
2 /* $Header: amsvtcwb.pls 120.1 2005/11/17 04:16:47 mayjain noship $ */
3 -- ===============================================================
4 -- Start of Comments
5 -- Package name
6 -- AMS_TCOP_WF_PKG
7 -- Purpose
8 --
9 -- This package has all the methods required to integrate with
10 -- OMO Schedule Execution Workflow
11 --
12 -- History
13 --
14 -- NOTE
15 --
16 -- End of Comments
17 -- ===============================================================
18
19 Procedure Is_Fatigue_Enabled (
20 itemtype in varchar2,
21 itemkey in varchar2,
22 actid in number,
23 funcmode in varchar2,
24 result out nocopy varchar2
25 ) is
26
27 l_fatigue_enabled_flag varchar2(1);
28 l_schedule_id number;
29 l_activity_id number;
30
31 begin
32
33 if ( funcmode = 'RUN') then
34
35 -- Get the Schedule Id set in the Schedule Execution Workflow instance
36 l_schedule_id := WF_ENGINE.getItemAttrText
37 (itemtype => itemtype,
38 itemkey => itemkey,
39 aname => 'SCHEDULE_ID');
40
41
42 l_fatigue_enabled_flag := AMS_TCOP_UTIL_PKG.Is_Fatigue_Rule_Applicable(
43 l_schedule_id
44 );
45
46 if (l_fatigue_enabled_flag = 'Y') then
47 result := 'COMPLETE:Y';
48 else
49 result := 'COMPLETE:N';
50 end if;
51
52 return;
53
54 end if;
55
56 if ( funcmode = 'CANCEL') then
57 result := 'COMPLETE';
58 return;
59 end if;
60
61 if ( funcmode = 'RESPOND') then
62 result := 'COMPLETE';
63 return;
64 end if;
65
66 EXCEPTION
67
68 WHEN OTHERS THEN
69 wf_core.context(G_PKG_NAME,'Check_Schedule_Status',itemtype,itemkey,
70 actid,funcmode);
71 raise ;
72
73 end Is_Fatigue_Enabled;
74
75 Procedure Add_Request_To_Queue (
76 itemtype in varchar2,
77 itemkey in varchar2,
78 actid in varchar2,
79 funcmode in varchar2,
80 result out nocopy varchar2
81 )
82 is
83 l_schedule_id NUMBER;
84 begin
85
86 if ( funcmode = 'RUN') then
87
88 -- Get the Schedule Id set in the Schedule Execution Workflow instance
89 l_schedule_id := WF_ENGINE.getItemAttrText
90 (itemtype => itemtype,
91 itemkey => itemkey,
92 aname => 'SCHEDULE_ID');
93
94
95 -- Enqueue the traffic cop request
96 AMS_TCOP_SCHEDULER_PKG.ENQUEUE
97 (
98 l_schedule_id,
99 itemtype,
100 itemkey
101 );
102
103 result := 'COMPLETE';
104
105 return;
106
107 end if;
108
109 if ( funcmode = 'CANCEL') then
110 result := 'COMPLETE';
111 return;
112 end if;
113
114 if ( funcmode = 'RESPOND') then
115 result := 'COMPLETE';
116 return;
117 end if;
118
119 EXCEPTION
120
121 WHEN OTHERS THEN
122 wf_core.context(G_PKG_NAME,'Add_Request_To_Queue',itemtype,itemkey,
123 actid,funcmode);
124 raise ;
125
126 end Add_Request_To_Queue;
127
128 Procedure Is_This_Request_Scheduled (
129 itemtype in varchar2,
130 itemkey in varchar2,
131 actid in number,
132 funcmode in varchar2,
133 result out nocopy varchar2
134 )
135 is
136 l_response VARCHAR2(1);
137 l_schedule_id NUMBER;
138 begin
139
140 if ( funcmode = 'RUN') then
141
142 -- Get the Schedule Id set in the Schedule Execution Workflow instance
143 l_schedule_id := WF_ENGINE.getItemAttrText
144 (itemtype => itemtype,
145 itemkey => itemkey,
146 aname => 'SCHEDULE_ID');
147
148 -- Enqueue the traffic cop request
149 l_response := AMS_TCOP_SCHEDULER_PKG.Is_This_Schedule_Ready_To_Run (
150 l_schedule_id
151 );
152
153 if (l_response = 'Y') THEN
154 result := 'COMPLETE:Y';
155 ELSE
156 result := 'COMPLETE:N';
157 END IF;
158
159 return;
160
161 end if;
162
163 if ( funcmode = 'CANCEL') then
164 result := 'COMPLETE';
165 return;
166 end if;
167
168 if ( funcmode = 'RESPOND') then
169 result := 'COMPLETE';
170 return;
171 end if;
172
173 end Is_This_Request_Scheduled;
174
175 Procedure Invoke_TCOP_Engine (
176 itemtype in varchar2,
177 itemkey in varchar2,
178 actid in number,
179 funcmode in varchar2,
180 result out nocopy varchar2
181 )
182 is
183 l_schedule_id NUMBER;
184 begin
185
186 AMS_Utility_PVT.Write_Conc_Log('AMS_TCOP_WF_PKG.Invoke_TCOP_Engine ==> Entered Invoke_TCOP_Engine');
187 if ( funcmode = 'RUN') then
188
189 -- Get the Schedule Id set in the Schedule Execution Workflow instance
190 l_schedule_id := WF_ENGINE.getItemAttrText
191 (itemtype => itemtype,
192 itemkey => itemkey,
193 aname => 'SCHEDULE_ID');
194
195 AMS_Utility_PVT.Write_Conc_Log('AMS_TCOP_WF_PKG.Invoke_TCOP_Engine ==> l_schedule_id = ' || l_schedule_id);
196
197
198 AMS_TCOP_ENGINE_PKG.Apply_Fatigue_Rules(l_schedule_id);
199
200 result := 'COMPLETE:SUCCESS';
201
202 return;
203
204 end if;
205
206 if ( funcmode = 'CANCEL') then
207 result := 'COMPLETE';
208 return;
209 end if;
210
211 if ( funcmode = 'RESPOND') then
212 result := 'COMPLETE';
213 return;
214 end if;
215 AMS_Utility_PVT.Write_Conc_Log('AMS_TCOP_WF_PKG.Invoke_TCOP_Engine ==> Exiting Invoke_TCOP_Engine');
216
217
218 /**
219 WF_ENGINE.SetItemAttrText(itemtype => p_itemtype,
220 itemkey => p_itemkey ,
221 aname => 'AMS_TCOP_ERROR_MSG',
222 avalue => l_final_data );
223 **/
224
225 end Invoke_TCOP_Engine;
226
227
228 Procedure Run_FR_Conc_Request (
229 itemtype in varchar2,
230 itemkey in varchar2,
231 actid in number,
232 funcmode in varchar2,
233 result out NOCOPY varchar2
234 )
235 IS
236 l_request_id NUMBER;
237 BEGIN
238 l_request_id := 0;
239
240 if ( funcmode = 'RUN') then
241 -- Call the concurrent program for "AMS : Apply Fatigue Rules".
242 l_request_id := FND_REQUEST.SUBMIT_REQUEST (
243 application => 'AMS',
244 program => 'AMSTCSCP'
245 );
246
247 WF_ENGINE.SetItemAttrText(itemtype => itemtype,
248 itemkey => itemkey,
249 aname => 'AMS_TCOP_PROGRAM_MSG',
250 avalue => 'Concurrent Request Id = ' || to_char(l_request_id));
251
252 result := 'COMPLETE';
253
254 return;
255 end if;
256
257 if ( funcmode = 'CANCEL') then
258 result := 'COMPLETE';
259 return;
260 end if;
261
262 if ( funcmode = 'RESPOND') then
263 result := 'COMPLETE';
264 return;
265 end if;
266
267 END Run_FR_Conc_Request;
268
269 END AMS_TCOP_WF_PKG;