[Home] [Help]
PACKAGE BODY: APPS.XDPCORE_ORDER
Source
1 PACKAGE BODY XDPCORE_ORDER AS
2 /* $Header: XDPCOROB.pls 120.1 2005/06/15 22:39:05 appldev $ */
3
4
5 /****
6 All Private Procedures for the Package
7 ****/
8
9 Function HandleOtherWFFuncmode (funcmode IN VARCHAR2) RETURN VARCHAR2;
10
11 PROCEDURE InitializeOrder(itemtype IN VARCHAR2,
12 itemkey IN VARCHAR2);
13
14 FUNCTION ContinueOrder (itemtype IN VARCHAR2,
15 itemkey IN VARCHAR2) RETURN VARCHAR2;
16
17 FUNCTION IsBundleDetected (itemtype IN VARCHAR2,
18 itemkey IN VARCHAR2) RETURN VARCHAR2;
19
20 TYPE RowidArrayType IS TABLE OF ROWID INDEX BY BINARY_INTEGER;
21
22
23 PROCEDURE UPDATE_ORDER_STATUS (p_order_id IN NUMBER ,
24 p_status IN VARCHAR2,
25 p_itemtype IN VARCHAR2,
26 p_itemkey IN VARCHAR2) ;
27
28 /***********************************************
29 * END of Private Procedures/Function Definitions
30 ************************************************/
31
32 -- INITIALIZE_ORDER
33 -- Resultout
34 -- Activity Performed - Activity was completed without any errors
35 --
36 -- Your Description here: Initializatio process for the Order. Set Order Processing
37 -- State, Order Status and itemtype/itemkey.
38
39 Procedure INITIALIZE_ORDER (itemtype IN VARCHAR2,
40 itemkey IN VARCHAR2,
41 actid IN NUMBER,
42 funcmode IN VARCHAR2,
43 resultout OUT NOCOPY VARCHAR2 ) IS
44
45 x_Progress VARCHAR2(2000);
46
47 BEGIN
48
49 -- RUN mode - normal process execution
50 --
51 IF (funcmode = 'RUN') THEN
52
53 InitializeOrder(itemtype, itemkey);
54 resultout := 'COMPLETE:ACTIVITY_PERFORMED';
55 return;
56 ELSE
57 resultout := HandleOtherWFFuncmode(funcmode);
58 return;
59 END IF;
60
61 EXCEPTION
62 WHEN OTHERS THEN
63 wf_core.context('XDPCORE_ORDER', 'INITIALIZE_ORDER', itemtype, itemkey, to_char(actid), funcmode);
64 END INITIALIZE_ORDER;
65
66
67 -- CONTINUE_ORDER
68 -- Resultout
69 -- Activity Performed - Activity was completed without any errors
70 --
71 -- Your Description here: Initializatio process for the Order. Set Order Processing
72 -- State, Order Status and itemtype/itemkey.
73
74 PROCEDURE CONTINUE_ORDER (itemtype IN VARCHAR2,
75 itemkey IN VARCHAR2,
76 actid IN NUMBER,
77 funcmode IN VARCHAR2,
78 resultout OUT NOCOPY VARCHAR2 ) IS
79
80 l_Result VARCHAR2(1);
81 x_Progress VARCHAR2(2000);
82
83 BEGIN
84 -- RUN mode - normal process execution
85 --
86 IF (funcmode = 'RUN') THEN
87
88 l_Result := ContinueOrder(itemtype, itemkey);
89 resultout := 'COMPLETE:' || l_Result;
90 return;
91 ELSE
92 resultout := HandleOtherWFFuncmode(funcmode);
93 return;
94 END IF;
95
96 EXCEPTION
97 WHEN OTHERS THEN
98 wf_core.context('XDPCORE_ORDER', 'CONTINUE_ORDER', itemtype, itemkey, to_char(actid), funcmode);
99 END CONTINUE_ORDER;
100
101
102 -- IS_BUNDLE_DETECTED
103 -- Resultout
104 -- yes/no
105 --
106 -- Your Description here: This procedure determines if the Order Analyzer is
107 -- to Process the current Order
108
109
110 PROCEDURE IS_BUNDLE_DETECTED (itemtype IN VARCHAR2,
111 itemkey IN VARCHAR2,
112 actid IN NUMBER,
113 funcmode IN VARCHAR2,
114 resultout OUT NOCOPY VARCHAR2 ) IS
115
116 l_result VARCHAR2(10);
117 x_Progress VARCHAR2(2000);
118
119 BEGIN
120
121 -- RUN mode - normal process execution
122 --
123 IF (funcmode = 'RUN') THEN
124 l_result := IsBundleDetected(itemtype, itemkey);
125 resultout := 'COMPLETE:' || l_result;
126 return;
127 ELSE
128 resultout := HandleOtherWFFuncmode(funcmode);
129 return;
130 END IF;
131
132 EXCEPTION
133 WHEN OTHERS THEN
134 wf_core.context('XDPCORE_ORDER', 'IS_BUNDLE_DETECTED', itemtype, itemkey, to_char(actid), funcmode);
135 raise;
136 END IS_BUNDLE_DETECTED;
137
138
139 /****
140 All the Private Functions
141 ****/
142
143 FUNCTION HandleOtherWFFuncmode( funcmode IN VARCHAR2) RETURN VARCHAR2
144 IS
145
146 resultout VARCHAR2(30);
147 x_Progress VARCHAR2(2000);
148
149 BEGIN
150
151 IF (funcmode = 'CANCEL') THEN
152 resultout := 'COMPLETE';
153 END IF;
154
155 IF (funcmode = 'RESPOND') THEN
156 resultout := 'COMPLETE';
157 END IF;
158
159 IF (funcmode = 'FORWARD') THEN
160 resultout := 'COMPLETE';
161 END IF;
162
163 IF (funcmode = 'TRANSFER') THEN
164 resultout := 'COMPLETE';
165 END IF;
166
167 IF (funcmode = 'TIMEOUT') THEN
168 resultout := 'COMPLETE';
169 END IF;
170
171 IF (funcmode = 'others') THEN
172 resultout := 'COMPLETE';
173 END IF;
174
175
176 return resultout;
177
178 END;
179
180
181
182
183 FUNCTION ContinueOrder (itemtype IN VARCHAR2,
184 itemkey IN VARCHAR2) RETURN VARCHAR2 IS
185
186 l_OrderID NUMBER;
187 l_Continue VARCHAR2(1) := 'N';
188 x_Progress VARCHAR2(2000);
189
190 BEGIN
191
192 l_OrderID := wf_engine.GetItemAttrNumber(itemtype => ContinueOrder.itemtype,
193 itemkey => ContinueOrder.itemkey,
194 aname => 'ORDER_ID');
195
196 BEGIN
197 SELECT 'Y'
198 INTO l_Continue
199 FROM dual
200 WHERE EXISTS (SELECT LINE_ITEM_ID
201 FROM XDP_ORDER_LINE_ITEMS
202 WHERE ORDER_ID = l_OrderID
203 AND STATUS_CODE = 'READY'
204 AND PROVISIONING_REQUIRED_FLAG = 'Y');
205
206 EXCEPTION
207 WHEN no_data_found THEN
208 l_Continue := 'N';
209 WHEN others THEN
210 RAISE;
211 END;
212
213 return (l_Continue);
214
215 EXCEPTION
216 WHEN others THEN
217
218 x_Progress := 'XDPCORE_ORDER.ContinueOrder. Unhandled Exception: ' || SUBSTR(SQLERRM, 1, 1200);
219 wf_core.context('XDPCORE_ORDER', 'ContinueOrder',itemtype, itemkey, null, x_Progress);
220 raise;
221 END ContinueOrder;
222
223
224
225 PROCEDURE InitializeOrder (itemtype IN VARCHAR2,
226 itemkey IN VARCHAR2) IS
227
228 l_OrderID NUMBER;
229 e_InvalidConfigException EXCEPTION;
230 x_Progress VARCHAR2(2000);
231
232 BEGIN
233
234 l_OrderID := wf_engine.GetItemAttrNumber(itemtype => InitializeOrder.itemtype,
235 itemkey => InitializeOrder.itemkey,
236 aname => 'ORDER_ID');
237
238 IF l_OrderID is null THEN
239 RAISE e_InvalidConfigException;
240 ELSE
241 /*
242 * Update the STATE of the Order to be 'RUNNING' and the status to be 'IN PROGRESS'
243 * Also update the item type and item key
244 */
245
246 UPDATE_ORDER_STATUS (p_order_id => l_OrderID,
247 p_status => 'IN PROGRESS',
248 p_itemtype => itemtype,
249 p_itemkey => itemkey ) ;
250 END IF;
251
252 EXCEPTION
253 WHEN others THEN
254 x_Progress := 'XDPCORE_ORDER.InitializeOrder. Unhandled Exception: ' || SUBSTR(SQLERRM, 1, 1200);
255 wf_core.context('XDPCORE_ORDER', 'InitializeOrder', itemtype, itemkey, null, x_Progress);
256 raise;
257 END InitializeOrder;
258
259
260 FUNCTION IsBundleDetected (itemtype IN VARCHAR2,
261 itemkey IN VARCHAR2) RETURN VARCHAR2 IS
262
263 l_OrderID NUMBER;
264 l_BundleCount NUMBER;
265 l_ErrCode number;
266 l_ErrDescription varchar2(800);
267
268 x_Progress VARCHAR2(2000);
269
270 BEGIN
271
272 l_OrderID := wf_engine.GetItemAttrNumber(itemtype => IsBundleDetected.itemtype,
273 itemkey => IsBundleDetected.itemkey,
274 aname => 'ORDER_ID');
275
276 BEGIN
277 SELECT 1
278 INTO l_BundleCount
279 FROM dual
280 WHERE EXISTS(SELECT BUNDLE_ID
281 FROM XDP_ORDER_LINE_ITEMS
282 WHERE ORDER_ID = l_OrderID
283 AND PROVISIONING_REQUIRED_FLAG = 'Y'
284 AND BUNDLE_ID IS NOT NULL);
285
286
287 EXCEPTION
288 WHEN no_data_found THEn
289 l_BundleCount := 0;
290 WHEN others THEN
291 raise;
292 END;
293
294
295
296 IF l_BundleCount = 0 THEN
297 /* Bundle Not detected */
298
299 XDPCORE.CheckNAddItemAttrText (itemtype => IsBundleDetected.itemtype,
300 itemkey => IsBundleDetected.itemkey,
301 AttrName => 'LINE_PROCESSING_CALLER',
302 AttrValue => 'ORDER',
303 ErrCode => l_ErrCode,
304 ErrStr => l_ErrDescription);
305 return ('N');
306
307 ELSE
308 /* Bundle Detected */
309 --'LINE_PROCESSING_CALLER' attribute is set while launchig lines from
310 --bundle process.. see XDPCORE_BUNDLE.InitializeBundle.. skilaru
311 return ('Y');
312
313 END IF;
314
315 EXCEPTION
316 WHEN others THEN
317 x_Progress := 'XDPCORE_ORDER.IsBundleDetected. Unhandled Exception: ' || SUBSTR(SQLERRM, 1, 1200);
318 wf_core.context('XDPCORE_ORDER', 'IsBundleDetected', itemtype, itemkey, null, x_Progress);
319 raise;
320 END IsBundleDetected;
321
322 PROCEDURE UPDATE_ORDER_STATUS (p_order_id IN NUMBER ,
323 p_status IN VARCHAR2,
324 p_itemtype IN VARCHAR2,
325 p_itemkey IN VARCHAR2) IS
326 PRAGMA AUTONOMOUS_TRANSACTION ;
327 x_progress VARCHAR2(2000);
328
329 BEGIN
330
331 UPDATE xdp_order_headers
332 SET status_code = p_status,
333 wf_item_type = p_itemtype,
334 wf_item_key = p_itemkey ,
335 actual_provisioning_date = sysdate,
336 last_update_date = sysdate,
337 last_updated_by = fnd_global.user_id,
338 last_update_login = fnd_global.login_id
339 WHERE order_id = p_order_id ;
340
341
342 COMMIT ;
343
344 EXCEPTION
345 WHEN others THEN
346 x_Progress := 'XDPCORE_ORDER.UPDATE_ORDER_STATUS. Unhandled Exception: ' || SUBSTR(SQLERRM, 1, 1200);
347 wf_core.context('XDPCORE_ORDER', 'UPDATE_ORDER_STATUS', p_itemtype, p_itemkey, null, x_Progress);
348 rollback;
349 raise;
350
351 END UPDATE_ORDER_STATUS;
352
353 End XDPCORE_ORDER;