[Home] [Help]
PACKAGE BODY: APPS.CLN_WSH_SHIP_ORDER_OUT_PKG
Source
1 PACKAGE BODY CLN_WSH_SHIP_ORDER_OUT_PKG AS
2 /* $Header: CLNWSHSB.pls 115.4 2004/02/04 10:09:38 kkram noship $ */
3 -- Package
4 -- CLN_WSH_SO_PKG
5 --
6 -- Purpose
7 -- Specification of package body: CLN_WSH_SO_PKG.
8 -- This package bunbles all the procedures
9 -- required for 3B12 Shipping implementation
10 --
11 -- History
12 -- Oct-6-2003 Viswanthan Umapathy Created
13
14
15 l_debug_level NUMBER := to_number(nvl(fnd_profile.value('CLN_DEBUG_LEVEL'), '5'));
16
17 -- Name
18 -- CREATE_COLLABORATION
19 -- Purpose
20 -- creates a new collaboration in the collaboration history
21 -- Arguments
22 --
23 -- Notes
24 -- No specific notes
25
26 PROCEDURE CREATE_COLLABORATION(
27 x_return_status OUT NOCOPY VARCHAR2,
28 x_msg_data OUT NOCOPY VARCHAR2,
29 p_delivery_number IN VARCHAR2,
30 p_tp_type IN VARCHAR2,
31 p_tp_id IN VARCHAR2,
32 p_tp_site_id IN VARCHAR2,
33 p_doc_dir IN VARCHAR2,
34 p_txn_type IN VARCHAR2,
35 p_txn_subtype IN VARCHAR2,
36 p_xmlg_doc_id IN VARCHAR2,
37 p_doc_creation_date IN DATE,
38 p_appl_ref_id IN VARCHAR2,
39 p_int_ctl_num IN VARCHAR2)
40 IS
41 PRAGMA AUTONOMOUS_TRANSACTION;
42 l_return_status VARCHAR2(1000);
43 l_return_msg VARCHAR2(2000);
44 l_debug_mode VARCHAR2(300);
45 l_error_code NUMBER;
46 l_error_msg VARCHAR2(2000);
47 l_tp_id NUMBER;
48 l_msg_text VARCHAR2(1000);
49 l_cln_ch_parameters wf_parameter_list_t;
50 l_event_key NUMBER;
51 l_entity_number VARCHAR2(30);
52 BEGIN
53 -- Sets the debug mode to be FILE
54 l_debug_mode := cln_debug_pub.Set_Debug_Mode('FILE');
55
56 SAVEPOINT SO_PROCESSING_TXN;
57
58 -- Initialize API return status to success
59 x_return_status := FND_API.G_RET_STS_SUCCESS;
60
61 FND_MESSAGE.SET_NAME('CLN','CLN_G_RET_MSG_SUCCESS');
62 x_msg_data := FND_MESSAGE.GET;
63
64 IF (l_Debug_Level <= 2) THEN
65 cln_debug_pub.Add('ENTERING CREATE_COLLABORATION', 2);
66 END IF;
67
68 -- Parameters List
69 IF (l_Debug_Level <= 1) THEN
70 cln_debug_pub.Add('With the following parameters:', 1);
71 cln_debug_pub.Add('p_delivery_number:' || p_delivery_number, 1);
72 cln_debug_pub.Add('p_tp_type:' || p_tp_type, 1);
73 cln_debug_pub.Add('p_tp_id:' || p_tp_id, 1);
74 cln_debug_pub.Add('p_tp_site_id:' || p_tp_site_id, 1);
75 cln_debug_pub.Add('p_doc_dir:' || p_doc_dir, 1);
76 cln_debug_pub.Add('p_txn_type:' || p_txn_type, 1);
77 cln_debug_pub.Add('p_txn_subtype:' || p_txn_subtype, 1);
78 cln_debug_pub.Add('p_xmlg_doc_id:' || p_xmlg_doc_id, 1);
79 cln_debug_pub.Add('p_doc_creation_date:' || p_doc_creation_date, 1);
80 cln_debug_pub.Add('p_appl_ref_id:' || p_appl_ref_id, 1);
81 END IF;
82
83 SELECT cln_generic_s.nextval INTO l_event_key FROM dual;
84
85 l_cln_ch_parameters := wf_parameter_list_t();
86
87 -- This query can never fail
88 SELECT ENTITY_NUMBER
89 INTO l_entity_number
90 FROM WSH_TRANSACTIONS_HISTORY
91 WHERE ENTITY_TYPE ='DLVY'
92 AND DOCUMENT_NUMBER = p_delivery_number
93 AND ROWNUM < 2;
94
95
96 -- Set event parameters
97 WF_EVENT.AddParameterToList('DOCUMENT_NO', l_entity_number, l_cln_ch_parameters); --l_entity_number holds delivery number. p_delivery_number holds shipping document number in wsh_transactions_history
98
99 WF_EVENT.AddParameterToList('TRADING_PARTNER_TYPE', p_tp_type, l_cln_ch_parameters);
100 WF_EVENT.AddParameterToList('TRADING_PARTNER_ID', p_tp_id, l_cln_ch_parameters);
101 WF_EVENT.AddParameterToList('TRADING_PARTNER_SITE', p_tp_site_id, l_cln_ch_parameters);
102 WF_EVENT.AddParameterToList('DOCUMENT_DIRECTION', p_doc_dir, l_cln_ch_parameters);
103 WF_EVENT.AddParameterToList('XMLG_INTERNAL_TXN_TYPE', p_txn_type, l_cln_ch_parameters);
104 WF_EVENT.AddParameterToList('XMLG_INTERNAL_TXN_SUBTYPE', p_txn_subtype, l_cln_ch_parameters);
105 WF_EVENT.AddParameterToList('XMLG_DOCUMENT_ID', p_xmlg_doc_id, l_cln_ch_parameters);
106
107 WF_EVENT.AddParameterToList('DOCUMENT_CREATION_DATE', to_char(p_doc_creation_date, 'YYYY-MM-DD HH24:MI:SS'), l_cln_ch_parameters);
108 WF_EVENT.AddParameterToList('REFERENCE_ID', p_appl_ref_id, l_cln_ch_parameters);
109 WF_EVENT.AddParameterToList('XMLG_INTERNAL_CONTROL_NUMBER', p_int_ctl_num, l_cln_ch_parameters);
110
111 -- Raise create collaboration event
112 WF_EVENT.Raise('oracle.apps.cln.ch.collaboration.create',
113 l_event_key, NULL, l_cln_ch_parameters, NULL);
114
115 IF (l_Debug_Level <= 1) THEN
116 cln_debug_pub.Add('Workflow event- oracle.apps.cln.ch.collaboration.create raised', 1);
117 END IF;
118
119 COMMIT;
120
121 IF (l_Debug_Level <= 2) THEN
122 cln_debug_pub.Add('EXITING CREATE_COLLABORATION', 2);
123 END IF;
124
125 EXCEPTION
126 WHEN OTHERS THEN
127 ROLLBACK;
128 IF (l_Debug_Level <= 6) THEN
129 cln_debug_pub.Add('Rolledback the autonomous transaction');
130 END IF;
131 l_error_code := SQLCODE;
132 l_error_msg := SQLERRM;
133 x_return_status := FND_API.G_RET_STS_ERROR ;
134 x_msg_data := l_error_code||' : '||l_error_msg;
135 IF (l_Debug_Level <= 6) THEN
136 cln_debug_pub.Add(x_msg_data, 6);
137 END IF;
138 x_msg_data := 'While trying to create a collaboration'
139 || ' for 3B12 outbound document delivery number '
140 || l_entity_number
141 || ', the following error is encountered:'
142 || x_msg_data;
143 IF (l_Debug_Level <= 2) THEN
144 cln_debug_pub.Add('EXITING CREATE_COLLABORATION', 2);
145 END IF;
146 END CREATE_COLLABORATION;
147
148
149
150 -- Name
151 -- UPDATE_COLLABORATION
152 -- Purpose
153 -- Updates the collaboration in the collaboration history
154 -- Arguments
155 --
156 -- Notes
157 -- No specific notes
158
159 PROCEDURE UPDATE_COLLABORATION(
160 x_return_status OUT NOCOPY VARCHAR2,
161 x_msg_data OUT NOCOPY VARCHAR2,
162 p_delivery_number IN VARCHAR2,
163 p_tp_type IN VARCHAR2,
164 p_tp_id IN VARCHAR2,
165 p_tp_site_id IN VARCHAR2,
166 p_doc_dir IN VARCHAR2,
167 p_txn_type IN VARCHAR2,
168 p_txn_subtype IN VARCHAR2,
169 p_xmlg_doc_id IN VARCHAR2,
170 p_appl_ref_id IN VARCHAR2,
171 p_int_ctrl_num IN VARCHAR2)
172 IS
173 l_return_status VARCHAR2(1000);
174 l_return_msg VARCHAR2(2000);
175 l_debug_mode VARCHAR2(300);
176 l_error_code NUMBER;
177 l_error_msg VARCHAR2(2000);
178 l_msg_text VARCHAR2(2000);
179 l_cln_ch_parameters wf_parameter_list_t;
180 l_event_key NUMBER;
181 l_entity_number VARCHAR2(30);
182
183 BEGIN
184 -- Sets the debug mode to be FILE
185 l_debug_mode := cln_debug_pub.Set_Debug_Mode('FILE');
186
187 -- Initialize API return status to success
188 x_return_status := FND_API.G_RET_STS_SUCCESS;
189
190 FND_MESSAGE.SET_NAME('CLN','CLN_SHIP_ORDER_REQ_RN_GEN');
191 -- Ship Order Request Generated
192 l_msg_text := FND_MESSAGE.GET;
193
194 IF (l_Debug_Level <= 2) THEN
195 cln_debug_pub.Add('ENTERING UPDATE_COLLABORATION', 2);
196 END IF;
197
198 -- Parameters List
199 IF (l_Debug_Level <= 1) THEN
200 cln_debug_pub.Add('With the following parameters:', 1);
201 cln_debug_pub.Add('p_delivery_number:' || p_delivery_number, 1);
202 cln_debug_pub.Add('p_tp_type:' || p_tp_type, 1);
203 cln_debug_pub.Add('p_tp_id:' || p_tp_id, 1);
204 cln_debug_pub.Add('p_tp_site_id:' || p_tp_site_id, 1);
205 cln_debug_pub.Add('p_doc_dir:' || p_doc_dir, 1);
206 cln_debug_pub.Add('p_txn_type:' || p_txn_type, 1);
207 cln_debug_pub.Add('p_txn_subtype:' || p_txn_subtype, 1);
208 cln_debug_pub.Add('p_xmlg_doc_id:' || p_xmlg_doc_id, 1);
209 cln_debug_pub.Add('p_appl_ref_id:' || p_appl_ref_id, 1);
210 cln_debug_pub.Add('p_int_ctrl_num:' || p_int_ctrl_num, 1);
211 END IF;
212
213 -- This query can never fail
214 SELECT ENTITY_NUMBER
215 INTO l_entity_number
216 FROM WSH_TRANSACTIONS_HISTORY
217 WHERE ENTITY_TYPE ='DLVY'
218 AND DOCUMENT_NUMBER = p_delivery_number
219 AND ROWNUM < 2;
220
221 SELECT cln_generic_s.nextval INTO l_event_key FROM dual;
222
223 l_cln_ch_parameters := wf_parameter_list_t();
224
225 -- Set event parameters
226 WF_EVENT.AddParameterToList('XMLG_INTERNAL_CONTROL_NUMBER', p_int_ctrl_num, l_cln_ch_parameters);
227 WF_EVENT.AddParameterToList('REFERENCE_ID', p_appl_ref_id, l_cln_ch_parameters);
228 WF_EVENT.AddParameterToList('TRADING_PARTNER_TYPE', p_tp_type, l_cln_ch_parameters);
229 WF_EVENT.AddParameterToList('TRADING_PARTNER_ID', p_tp_id, l_cln_ch_parameters);
230 WF_EVENT.AddParameterToList('TRADING_PARTNER_SITE', p_tp_site_id, l_cln_ch_parameters);
231 WF_EVENT.AddParameterToList('DOCUMENT_DIRECTION', p_doc_dir, l_cln_ch_parameters);
232 WF_EVENT.AddParameterToList('XMLG_INTERNAL_TXN_TYPE', p_txn_type, l_cln_ch_parameters);
233 WF_EVENT.AddParameterToList('XMLG_INTERNAL_TXN_SUBTYPE', p_txn_subtype, l_cln_ch_parameters);
234 WF_EVENT.AddParameterToList('XMLG_DOCUMENT_ID', p_xmlg_doc_id, l_cln_ch_parameters);
235 -- WF_EVENT.AddParameterToList('ORIGINATOR_REFERENCE', p_delivery_number, l_cln_ch_parameters);
236 WF_EVENT.AddParameterToList('MESSAGE_TEXT', l_msg_text, l_cln_ch_parameters);
237
238 -- Raise update collaboration event
239 WF_EVENT.Raise('oracle.apps.cln.ch.collaboration.update',
240 l_event_key, NULL, l_cln_ch_parameters, NULL);
241 cln_debug_pub.Add('Workflow event- oracle.apps.cln.ch.collaboration.update raised', 1);
242
243 IF (l_Debug_Level <= 2) THEN
244 cln_debug_pub.Add('EXITING UPDATE_COLLABORATION', 2);
245 END IF;
246 EXCEPTION
247 WHEN OTHERS THEN
248 ROLLBACK;
249 IF (l_Debug_Level <= 6) THEN
250 cln_debug_pub.Add('Rolledback the autonomous transaction');
251 END IF;
252 l_error_code := SQLCODE;
253 l_error_msg := SQLERRM;
254 x_return_status := FND_API.G_RET_STS_ERROR ;
255 x_msg_data := l_error_code||' : '||l_error_msg;
256 IF (l_Debug_Level <= 6) THEN
257 cln_debug_pub.Add(x_msg_data, 3);
258 END IF;
259 x_msg_data := 'While trying to update the collaboration'
260 || ' for 3B12 outbound document delivery number '
261 || l_entity_number
262 || ', the following error is encountered:'
263 || x_msg_data;
264 IF (l_Debug_Level <= 2) THEN
265 cln_debug_pub.Add('EXITING UPDATE_COLLABORATION', 2);
266 END IF;
267 END UPDATE_COLLABORATION;
268
269
270
271 -- Name
272 -- GET_DELIVERY_INFORMATION
273 -- Purpose
274 -- Gets the required additional delievry information
275 -- for a Delivery Document Number
276 -- Arguments
277 -- Delivery Document Number
278 -- Notes
279 -- No specific notes
280
281 PROCEDURE GET_DELIVERY_INFORMATION(
282 x_return_status OUT NOCOPY VARCHAR2,
283 x_msg_data OUT NOCOPY VARCHAR2,
284 p_document_number IN VARCHAR2,
285 x_customer_po_number OUT NOCOPY VARCHAR2,
286 x_customer_id OUT NOCOPY NUMBER,
287 x_delivery_creation_date OUT NOCOPY DATE)
288 IS
289 l_debug_mode VARCHAR2(300);
290 l_error_code NUMBER;
291 l_error_msg VARCHAR2(2000);
292 BEGIN
293 -- Sets the debug mode to be FILE
294 l_debug_mode := cln_debug_pub.Set_Debug_Mode('FILE');
295
296 -- Initialize API return status to success
297 x_return_status := FND_API.G_RET_STS_SUCCESS;
298
299 IF (l_Debug_Level <= 2) THEN
300 cln_debug_pub.Add('ENTERING GET_DELIVERY_INFORMATION', 2);
301 END IF;
302
303 -- Parameters List
304 IF (l_Debug_Level <= 1) THEN
308
305 cln_debug_pub.Add('With the following parameters:', 1);
306 cln_debug_pub.Add('p_document_number:' || p_document_number, 1);
307 END IF;
309 SELECT WDD.CUST_PO_NUMBER, WDD.CUSTOMER_ID, WND.CREATION_DATE
310 INTO x_customer_po_number, x_customer_id, x_delivery_creation_date
311 FROM WSH_NEW_DELIVERIES WND,
312 WSH_TRANSACTIONS_HISTORY WTH,
313 WSH_DELIVERY_DETAILS WDD,
314 WSH_DELIVERY_ASSIGNMENTS WDA
315 WHERE WTH.ENTITY_NUMBER = WND.NAME
316 AND WTH.ENTITY_TYPE ='DLVY'
317 AND WTH.DOCUMENT_DIRECTION = 'O'
318 AND WTH.DOCUMENT_NUMBER = P_DOCUMENT_NUMBER
319 AND WDD.CONTAINER_FLAG = 'N'
320 AND WDD.DELIVERY_DETAIL_ID = WDA.DELIVERY_DETAIL_ID
321 AND WDA.DELIVERY_ID = WND.DELIVERY_ID
322 AND ROWNUM < 2;
323
324 IF (l_Debug_Level <= 1) THEN
325 cln_debug_pub.Add('x_customer_po_number:' || x_customer_po_number, 1);
326 cln_debug_pub.Add('x_customer_id:' || x_customer_id, 1);
327 cln_debug_pub.Add('x_delivery_creation_date:' || x_delivery_creation_date, 1);
328 END IF;
329
330 IF (l_Debug_Level <= 2) THEN
331 cln_debug_pub.Add('EXITING GET_DELIVERY_INFORMATION', 2);
332 END IF;
333 EXCEPTION
334 WHEN OTHERS THEN
335 l_error_code := SQLCODE;
336 l_error_msg := SQLERRM;
337 x_return_status := FND_API.G_RET_STS_ERROR ;
338 x_msg_data := l_error_code||' : '||l_error_msg;
339 IF (l_Debug_Level <= 6) THEN
340 cln_debug_pub.Add(x_msg_data, 3);
341 END IF;
342 x_msg_data := 'While trying to retrieve the additional delivery information'
343 || ' for a 3B12 outbound document delivery number '
344 || p_document_number
345 || ', the following error is encountered:'
346 || x_msg_data;
347 IF (l_Debug_Level <= 2) THEN
348 cln_debug_pub.Add('EXITING GET_DELIVERY_INFORMATION', 2);
349 END IF;
350 END GET_DELIVERY_INFORMATION;
351
352
353
354 -- Name
355 -- GET_FROM_ROLE_ORG_ID
356 -- Purpose
357 -- Gets the Organization ID for a given Delivery Document Number
358 -- Arguments
359 -- Delivery Document Number
360 -- Notes
361 -- No specific notes
362
363 FUNCTION GET_FROM_ROLE_ORG_ID
364 (P_DOCUMENT_NUMBER IN NUMBER)
365 RETURN NUMBER
366 IS
367 l_org_id NUMBER DEFAULT 0;
368 l_return_msg VARCHAR2(2000);
369 l_debug_mode VARCHAR2(300);
370 l_error_code NUMBER;
371 l_error_msg VARCHAR2(2000);
372 BEGIN
373
374 -- Sets the debug mode to be FILE
375 l_debug_mode := cln_debug_pub.Set_Debug_Mode('FILE');
376
377 IF (l_Debug_Level <= 2) THEN
378 cln_debug_pub.Add('ENTERING GET_FROM_ROLE_ORG_ID', 2);
379 END IF;
380
381 -- Parameters List
382 IF (l_Debug_Level <= 1) THEN
383 cln_debug_pub.Add('With the following parameters:', 1);
384 cln_debug_pub.Add('P_DOCUMENT_NUMBER:' || P_DOCUMENT_NUMBER, 1);
385 END IF;
386
387 SELECT WND.ORGANIZATION_ID
388 INTO l_org_id
389 FROM WSH_NEW_DELIVERIES WND,
390 WSH_TRANSACTIONS_HISTORY WTH
391 WHERE WTH.ENTITY_NUMBER = WND.NAME
392 AND WTH.ENTITY_TYPE ='DLVY'
393 AND WTH.DOCUMENT_DIRECTION = 'O'
394 AND WTH.DOCUMENT_NUMBER = P_DOCUMENT_NUMBER;
395
396 IF (l_Debug_Level <= 1) THEN
397 cln_debug_pub.Add('l_org_id:' || l_org_id, 1);
398 END IF;
399
400 IF (l_Debug_Level <= 2) THEN
401 cln_debug_pub.Add('EXITING GET_FROM_ROLE_ORG_ID', 2);
402 END IF;
403
404 RETURN l_org_id;
405 EXCEPTION
406 WHEN OTHERS THEN
407 l_error_code := SQLCODE;
408 l_error_msg := SQLERRM;
409 l_return_msg := l_error_code||' : '||l_error_msg;
410 IF (l_Debug_Level <= 6) THEN
411 cln_debug_pub.Add(l_return_msg, 3);
412 END IF;
413 l_return_msg := 'While trying to get the organizationid '
414 || ' for 3B12 outbound document delivery number '
415 || P_DOCUMENT_NUMBER
416 || ', the following error is encountered:'
417 || l_return_msg;
418 IF (l_Debug_Level <= 2) THEN
419 cln_debug_pub.Add('EXITING GET_FROM_ROLE_ORG_ID', 2);
420 END IF;
421 RETURN l_org_id;
422 END GET_FROM_ROLE_ORG_ID;
423
424
425
426 -- Name
427 -- GET_TO_ROLE_LOCATION_ID
428 -- Purpose
429 -- Gets the toRole Location ID for a given Delivery Document Number
430 -- Arguments
431 -- Delivery Document Number
432 -- Notes
433 -- No specific notes
434
435 FUNCTION GET_TO_ROLE_LOCATION_ID
436 (P_DOCUMENT_NUMBER IN NUMBER)
437 RETURN NUMBER
438 IS
439 l_loc_id NUMBER DEFAULT 0;
440 l_return_msg VARCHAR2(2000);
441 l_debug_mode VARCHAR2(300);
442 l_error_code NUMBER;
443 l_error_msg VARCHAR2(2000);
444 BEGIN
445
446 -- Sets the debug mode to be FILE
447 l_debug_mode := cln_debug_pub.Set_Debug_Mode('FILE');
448
449 IF (l_Debug_Level <= 2) THEN
450 cln_debug_pub.Add('ENTERING GET_TO_ROLE_LOCATION_ID', 2);
451 END IF;
452
453 -- Parameters List
454 IF (l_Debug_Level <= 1) THEN
455 cln_debug_pub.Add('With the following parameters:', 1);
456 cln_debug_pub.Add('P_DOCUMENT_NUMBER:' || P_DOCUMENT_NUMBER, 1);
457 END IF;
458
459 SELECT WND.INITIAL_PICKUP_LOCATION_ID
460 INTO l_loc_id
461 FROM WSH_NEW_DELIVERIES WND,
462 WSH_TRANSACTIONS_HISTORY WTH
463 WHERE WTH.ENTITY_NUMBER = WND.NAME
464 AND WTH.ENTITY_TYPE ='DLVY'
465 AND WTH.DOCUMENT_DIRECTION = 'O'
466 AND WTH.DOCUMENT_NUMBER = P_DOCUMENT_NUMBER;
467
468 IF (l_Debug_Level <= 1) THEN
469 cln_debug_pub.Add('l_loc_id:' || l_loc_id, 1);
470 END IF;
471
472 IF (l_Debug_Level <= 2) THEN
473 cln_debug_pub.Add('EXITING GET_TO_ROLE_LOCATION_ID', 2);
474 END IF;
475 RETURN l_loc_id;
476 EXCEPTION
477 WHEN OTHERS THEN
478 l_error_code := SQLCODE;
479 l_error_msg := SQLERRM;
480 l_return_msg := l_error_code||' : '||l_error_msg;
481 IF (l_Debug_Level <= 6) THEN
482 cln_debug_pub.Add(l_return_msg, 3);
483 END IF;
484 l_return_msg := 'While trying to get the toRole Location ID '
485 || ' for 3B12 outbound document delivery number '
486 || P_DOCUMENT_NUMBER
487 || ', the following error is encountered:'
488 || l_return_msg;
489 IF (l_Debug_Level <= 2) THEN
490 cln_debug_pub.Add('EXITING GET_TO_ROLE_LOCATION_ID', 2);
491 END IF;
492 RETURN l_loc_id;
493 END GET_TO_ROLE_LOCATION_ID;
494
495 END CLN_WSH_SHIP_ORDER_OUT_PKG;