1 PACKAGE BODY WSH_ASN_RECEIPT_PVT as
2 /* $Header: WSHVASRB.pls 120.2 2005/10/26 02:00:40 rahujain noship $ */
3
4
5 G_PKG_NAME CONSTANT VARCHAR2(50) := 'WSH_ASN_RECEIPT_PVT';
6 LIMITED_PRECISION NUMBER := 5;
7
8 --{ --NNP-WV
9
10
11 -- Start of comments
12 -- API name : addWeightVolume
13 -- Type : Public
14 -- Pre-reqs : None.
15 -- Function : To consolidate (aggregate) the volume and weight of a delivery and its corresponding
16 -- LPN id. This API is called whenever there is a change in quantiy,weight,volume due
17 -- to split in delivery and also reassignment of lines to new deliveries or an explicit
18 -- change in the weight or volume.It makes use of two cache tables (a key-value pair) for
19 -- this consolidation(aggregate) purpose.
20 -- Parameters :
21 -- IN:
22 -- p_key IN NUMBER
23 -- The key in key-value pair.
24 -- p_value IN NUMBER
25 -- The value in key-value pair.
26 -- IN OUT:
27 -- x_cachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
28 -- The key-value table where the key value is <= ( 2^31 - 1 )
29 -- x_cacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
30 -- The key-value table where the key value is > ( 2^31 - 1 )
31 -- OUT:
32 -- x_return_status OUT NOCOPY VARCHAR2
33 -- Cache Tables :
34 -- ----------------------------------------------------------------------
35 -- | Cache Table Name | Key | Value |
36 -- ----------------------------------------------------------------------
37 -- | x_cachetbl | Delivery / LPN ID | The difference in gross |
38 -- | | | weight / net weight / |
39 -- | | | volume to be updated for |
40 -- | | | the given key. |
41 -- | x_cacheExttbl | Delivery / LPN ID | The difference in gross |
42 -- | | | weight / net weight / |
43 -- | | | volume to be updated for |
44 -- | | | the given key. |
45 -- -----------------------------------------------------------------------
46 -- Version : 1.0
47 -- Previous version 1.0
48 -- Initial version 1.0
49 -- End of comments
50
51
52 PROCEDURE addWeightVolume
53 (
54 p_key IN NUMBER,
55 p_value IN NUMBER,
56 x_cachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
57 x_cacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
58 x_return_status OUT NOCOPY VARCHAR2
59 )
60 IS
61 --{
62 --
63 --
64 l_num_warnings NUMBER := 0;
65 l_num_errors NUMBER := 0;
66 l_return_status VARCHAR2(30);
67 l_value number;
68 --
69 l_debug_on BOOLEAN;
70 --
71 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'addWeightVolume';
72 --
73 --}
74 BEGIN
75 --{
76 --
77 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
78 --
79 IF l_debug_on IS NULL
80 THEN
81 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
82 END IF;
83 --
84 --
85 -- Debug Statements
86 --
87 IF l_debug_on THEN
88 WSH_DEBUG_SV.push(l_module_name);
89 --
90 WSH_DEBUG_SV.log(l_module_name,'P_key',p_key);
91 WSH_DEBUG_SV.log(l_module_name,'p_value',p_value);
92 END IF;
93 --
94 --
95 --
96 IF l_debug_on THEN
97 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_CACHED_VALUE-x_cacheTbl',WSH_DEBUG_SV.C_PROC_LEVEL);
98 END IF;
99 --
100 -- Searching the cache tables to find out, if they already have a entry
101 -- for the given key, if so get the corresponding value.
102 wsh_util_core.get_cached_value
103 (
104 p_cache_tbl => x_cacheTbl,
105 p_cache_ext_tbl => x_cacheExtTbl,
106 p_key => p_key,
107 p_value => l_value,
108 p_action => 'GET',
109 x_return_status => l_return_status
110 );
111 --
112 --
113 IF l_debug_on THEN
114 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
115 WSH_DEBUG_SV.log(l_module_name,'l_value',l_value);
116 END IF;
117 --
118 --
119 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR
120 THEN
121 RAISE FND_API.G_EXC_ERROR;
122 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR
123 THEN
124 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
125 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_WARNING
126 THEN
127 l_value := 0;
128 END IF;
129 --
130 --
131 l_value := NVL(l_value,0) + NVL(p_value,0);
132 --
133 --
134 IF l_debug_on THEN
135 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_CACHED_VALUE-x_cacheTbl',WSH_DEBUG_SV.C_PROC_LEVEL);
136 END IF;
137 --
138 wsh_util_core.get_cached_value
139 (
140 p_cache_tbl => x_cacheTbl,
141 p_cache_ext_tbl => x_cacheExtTbl,
142 p_key => p_key,
143 p_value => l_value,
144 p_action => 'PUT',
145 x_return_status => l_return_status
146 );
147 --
148 --
149 --
150 IF l_debug_on THEN
151 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
152 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
153 END IF;
154 --
155 wsh_util_core.api_post_call
156 (
157 p_return_status => l_return_status,
158 x_num_warnings => l_num_warnings,
159 x_num_errors => l_num_errors
160 );
161 --
162 IF l_debug_on THEN
163 WSH_DEBUG_SV.logmsg(l_module_name,
164 'Number of Errors='||l_num_errors||',Number of Warnings='||l_num_warnings);
165 END IF;
166 --
167 IF l_num_errors > 0
168 THEN
169 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
170 ELSIF l_num_warnings > 0
171 THEN
172 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
173 ELSE
174 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
175 END IF;
176 --
177 -- Debug Statements
178 --
179 IF l_debug_on THEN
180 WSH_DEBUG_SV.pop(l_module_name);
181 END IF;
182 --
183 --}
184 EXCEPTION
185 --{
186 WHEN FND_API.G_EXC_ERROR THEN
187 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
188 --
189 -- Debug Statements
190 --
191 IF l_debug_on THEN
192 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
193 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
194 END IF;
195 --
196 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
197 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
198 --
199 -- Debug Statements
200 --
201 IF l_debug_on THEN
202 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
203 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
204 END IF;
205 --
206 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
207 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
208 --
209 -- Debug Statements
210 --
211 IF l_debug_on THEN
212 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
213 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
214 END IF;
215 --
216 WHEN OTHERS THEN
217 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
218 wsh_util_core.default_handler('WSH_ASN_RECEIPT_PVT.addWeightVolume');
219 --
220 -- Debug Statements
221 --
222 IF l_debug_on THEN
223 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
224 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
225 END IF;
226 --
227 --}
228 END addWeightVolume;
229
230
231
232 -- Start of comments
233 -- API name : processWeightVolume
234 -- Type : Public
235 -- Pre-reqs : None.
236 -- Function : The basic job of this API is to take care of the changes in gross weight,net weight
237 -- and volume changes.This it does by making calls to the API WSH_ASN_RECEIPT_PVT.addWeightVolume
238 -- by giving the appropriate inputs each time.
239 -- Parameters :
243 -- p_diff_gross_weight IN NUMBER
240 -- IN:
241 -- p_delivery_lpn_id IN NUMBER
242 -- The delivery ID for which the change in volume/weight has occured.
244 -- The difference in gross weight that has happened for the input Delivery's lines.
245 -- p_diff_net_weight IN NUMBER
246 -- The difference in net weight that has happened for the input Delivery's lines.
247 -- p_diff_volume IN NUMBER
248 -- The difference in volume that has happened for the input Delivery's lines .
249 -- IN OUT:
250 -- x_GWTcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
251 -- The key-value cache table,which contains the gross weight details.
252 -- The key's value is <= ( 2^31 - 1 ).
253 -- x_GWTcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
254 -- The key-value cache table,which contains the gross weight details.
255 -- The key's value is > ( 2^31 - 1 ).
256 -- x_NWTcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
257 -- The key-value cache table,which contains the net weight details.
258 -- The key's value is <= ( 2^31 - 1 ).
259 -- x_NWTcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
260 -- The key-value cache table,which contains the net weight details.
261 -- The key's value is > ( 2^31 - 1 ).
262 -- x_VOLcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
263 -- The key-value cache table,which contains the volume details.
264 -- The key's value is <= ( 2^31 - 1 ).
265 -- x_VOLcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
266 -- The key-value cache table,which contains the volume details.
267 -- The key's value is > ( 2^31 - 1 ).
268 -- OUT:
269 --Cache Tables :
270 -- ----------------------------------------------------------------------
271 -- | Cache Table Name | Key | Value |
272 -- ----------------------------------------------------------------------
273 -- |x_GWTcachetbl | LPN ID/Delivery ID | Gross Weight |
274 -- |x_GWTcacheExttbl | LPN ID/Delivery ID | Gross Weight |
275 -- -----------------------------------------------------------------------
276 -- |x_NWTcachetbl | LPN ID/Delivery ID | Net Weight |
277 -- |x_NWTcacheExttbl | LPN ID/Delivery ID | Net Weight |
278 -- -----------------------------------------------------------------------
279 -- |x_VOLcachetbl | LPN ID/Delivery ID | Volume |
280 -- |x_VOLcacheExttbl | LPN ID/Delivery ID | Volume |
281 -- -----------------------------------------------------------------------
282 -- Version : 1.0
283 -- Previous version 1.0
284 -- Initial version 1.0
285 -- End of comments
286
287
288
289
290 PROCEDURE processWeightVolume
291 (
292 p_delivery_lpn_id IN NUMBER,
293 p_diff_gross_weight IN NUMBER,
294 p_diff_net_weight IN NUMBER,
295 p_diff_volume IN NUMBER,
296 x_GWTcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
297 x_GWTcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
298 x_NWTcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
299 x_NWTcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
300 x_VOLcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
301 x_VOLcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
302 x_return_status OUT NOCOPY VARCHAR2
303 )
304 IS
305 --{
306 --
307 --
308 l_num_warnings NUMBER := 0;
309 l_num_errors NUMBER := 0;
310 l_return_status VARCHAR2(30);
311 --
312 l_debug_on BOOLEAN;
313 --
314 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'processWeightVolume';
315 --
316 --}
317 BEGIN
318 --{
319 --
320 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
321 --
322 IF l_debug_on IS NULL
323 THEN
324 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
325 END IF;
326 --
327 --
328 -- Debug Statements
329 --
330 IF l_debug_on THEN
331 WSH_DEBUG_SV.push(l_module_name);
332 --
333 WSH_DEBUG_SV.log(l_module_name,'p_delivery_lpn_id',p_delivery_lpn_id);
334 WSH_DEBUG_SV.log(l_module_name,'p_diff_gross_weight',p_diff_gross_weight);
335 WSH_DEBUG_SV.log(l_module_name,'p_diff_net_weight',p_diff_net_weight);
336 WSH_DEBUG_SV.log(l_module_name,'p_diff_volume',p_diff_volume);
337 END IF;
338 --
339 IF p_delivery_lpn_id IS NOT NULL
340 THEN
341 --{
342 IF l_debug_on THEN
346
343 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_ASN_RECEIPT_PVT.addWeightVolume-GWT',WSH_DEBUG_SV.C_PROC_LEVEL);
344 END IF;
345 --
347 --call for changes in gross weight.
348 WSH_ASN_RECEIPT_PVT.addWeightVolume
349 (
350 p_key => p_delivery_lpn_id,
351 p_value => p_diff_gross_weight,
352 x_cacheTbl => x_GWTcacheTbl,
353 x_cacheExtTbl => x_GWTcacheExtTbl,
354 x_return_status => l_return_status
355 );
356 --
357 --
358 --
359 IF l_debug_on THEN
360 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
361 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
362 END IF;
363 --
364 wsh_util_core.api_post_call
365 (
366 p_return_status => l_return_status,
367 x_num_warnings => l_num_warnings,
368 x_num_errors => l_num_errors
369 );
370 --
371 --
372 IF l_debug_on THEN
373 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_ASN_RECEIPT_PVT.addWeightVolume-NWT',WSH_DEBUG_SV.C_PROC_LEVEL);
374 END IF;
375 --
376 --call for changes in net weight.
377 WSH_ASN_RECEIPT_PVT.addWeightVolume
378 (
379 p_key => p_delivery_lpn_id,
380 p_value => p_diff_net_weight,
381 x_cacheTbl => x_NWTcacheTbl,
382 x_cacheExtTbl => x_NWTcacheExtTbl,
383 x_return_status => l_return_status
384 );
385 --
386 --
387 --
388 IF l_debug_on THEN
389 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
390 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
391 END IF;
392 --
393 wsh_util_core.api_post_call
394 (
395 p_return_status => l_return_status,
396 x_num_warnings => l_num_warnings,
397 x_num_errors => l_num_errors
398 );
399 --
400 --
401 IF l_debug_on THEN
402 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_ASN_RECEIPT_PVT.addWeightVolume-VOL',WSH_DEBUG_SV.C_PROC_LEVEL);
403 END IF;
404 --
405 --call for changes in volume.
406 WSH_ASN_RECEIPT_PVT.addWeightVolume
407 (
408 p_key => p_delivery_lpn_id,
409 p_value => p_diff_volume,
410 x_cacheTbl => x_VOLcacheTbl,
411 x_cacheExtTbl => x_VOLcacheExtTbl,
412 x_return_status => l_return_status
413 );
414 --
415 --
416 --
417 IF l_debug_on THEN
418 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
419 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
420 END IF;
421 --
422 wsh_util_core.api_post_call
423 (
424 p_return_status => l_return_status,
425 x_num_warnings => l_num_warnings,
426 x_num_errors => l_num_errors
427 );
428 --
429 --
430
431 --}
432 END IF;
433 --
434 IF l_debug_on THEN
435 WSH_DEBUG_SV.logmsg(l_module_name,
436 'Number of Errors='||l_num_errors||',Number of Warnings='||l_num_warnings);
437 END IF;
438 --
439 IF l_num_errors > 0
440 THEN
441 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
442 ELSIF l_num_warnings > 0
443 THEN
444 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
445 ELSE
446 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
447 END IF;
448 --
449 -- Debug Statements
450 --
451 IF l_debug_on THEN
452 WSH_DEBUG_SV.pop(l_module_name);
453 END IF;
454 --
455 --}
456 EXCEPTION
457 --{
458 WHEN FND_API.G_EXC_ERROR THEN
462 --
459 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
460 --
461 -- Debug Statements
463 IF l_debug_on THEN
464 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
465 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
466 END IF;
467 --
468 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
469 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
470 --
471 -- Debug Statements
472 --
473 IF l_debug_on THEN
474 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
475 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
476 END IF;
477 --
478 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
479 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
480 --
481 -- Debug Statements
482 --
483 IF l_debug_on THEN
484 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
485 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
486 END IF;
487 --
488 WHEN OTHERS THEN
489 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
490 wsh_util_core.default_handler('WSH_ASN_RECEIPT_PVT.processWeightVolume');
491 --
492 -- Debug Statements
493 --
494 IF l_debug_on THEN
495 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
496 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
497 END IF;
498 --
499 --}
500 END processWeightVolume;
501 --
502 --
503
504 -- Start of comments
505 -- API name :
506 -- Type : Public
507 -- Pre-reqs : None.
508 -- Function : This API is used to check for the existence of entry in the cache tables (i/p parameters)
509 -- for the given input key p_key.If a value is found in the key-value cache tables
510 -- for the given key, then the two OUT variables for this API(x_diff_net_weight and
511 -- x_diff_volume ) are appropriatley updated with the new value.The two main cache
512 -- tables are x_NWTcachetbl and x_VOLcachetbl.
513 -- Parameters :
514 -- IN:
515 -- p_key IN NUMBER
516 -- The key based on which the cache tables are searched for matching entries.
517 -- IN OUT:
518 -- x_NWTcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
519 -- The key-value cache table having the net weight details for key values < (2^31 -1).
520 -- x_NWTcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
521 -- The key-value cache table having the net weight details for key values > (2^31 -1).
522 -- x_VOLcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
523 -- The key-value cache table having the volume weight details for key values < (2^31 -1).
524 -- x_VOLcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
525 -- The key-value cache table having the volume weight details for key values > (2^31 -1).
526 -- OUT:
527 -- x_return_status OUT NOCOPY VARCHAR2
528 -- Cache Tables:
529 -- ----------------------------------------------------------------------
530 -- | Cache Table Name | Key | Value |
531 -- ----------------------------------------------------------------------
532 -- |x_NWTcachetbl | LPN ID/Delivery ID | Net Weight |
533 -- |x_NWTcacheExttbl | LPN ID/Delivery ID | Net Weight |
534 -- -----------------------------------------------------------------------
535 -- |x_VOLcachetbl | LPN ID/Delivery ID | Volume |
536 -- |x_VOLcacheExttbl | LPN ID/Delivery ID | Volume |
537 -- -----------------------------------------------------------------------
538 -- Version : 1.0
539 -- Previous version 1.0
540 -- Initial version 1.0
541 -- End of comments
542
543 PROCEDURE getNetWeightVolume
544 (
545 p_key IN NUMBER,
546 x_NWTcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
547 x_NWTcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
548 x_VOLcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
549 x_VOLcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
550 x_diff_net_weight OUT NOCOPY NUMBER,
551 x_diff_volume OUT NOCOPY NUMBER,
552 x_return_status OUT NOCOPY VARCHAR2
553 )
554 IS
555 --{
556 --
557 --
558 l_num_warnings NUMBER := 0;
559 l_num_errors NUMBER := 0;
563 --
560 l_return_status VARCHAR2(30);
561 --
562 l_debug_on BOOLEAN;
564 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'getNetWeightVolume';
565 --
566 --}
567 BEGIN
568 --{
569 --
570 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
571 --
572 IF l_debug_on IS NULL
573 THEN
574 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
575 END IF;
576 --
577 --
578 -- Debug Statements
579 --
580 IF l_debug_on THEN
581 WSH_DEBUG_SV.push(l_module_name);
582 WSH_DEBUG_SV.log(l_module_name,'p_key',p_key);
583 END IF;
584 --
585 IF l_debug_on THEN
586 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_CACHED_VALUE-x_NWTcacheTbl',WSH_DEBUG_SV.C_PROC_LEVEL);
587 END IF;
588 --
589 wsh_util_core.get_cached_value
590 (
591 p_cache_tbl => x_NWTcacheTbl,
592 p_cache_ext_tbl => x_NWTcacheExtTbl,
593 p_key => p_key,
594 p_value => x_diff_net_weight,
595 p_action => 'GET',
596 x_return_status => l_return_status
597 );
598 --
599 --
600 IF l_debug_on THEN
601 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
602 WSH_DEBUG_SV.log(l_module_name,'x_diff_net_weight',x_diff_net_weight);
603 END IF;
604 --
605 --
606 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR
607 THEN
608 RAISE FND_API.G_EXC_ERROR;
609 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR
610 THEN
611 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
612 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_WARNING
613 THEN
614 x_diff_net_weight := 0;
615 END IF;
616 --
617 --
618 IF l_debug_on THEN
619 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_CACHED_VALUE-x_VOLcacheTbl',WSH_DEBUG_SV.C_PROC_LEVEL);
620 END IF;
621 --
622 wsh_util_core.get_cached_value
623 (
624 p_cache_tbl => x_VOLcacheTbl,
625 p_cache_ext_tbl => x_VOLcacheExtTbl,
626 p_key => p_key,
627 p_value => x_diff_volume,
628 p_action => 'GET',
629 x_return_status => l_return_status
630 );
631 --
632 --
633 IF l_debug_on THEN
634 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
635 WSH_DEBUG_SV.log(l_module_name,'x_diff_volume',x_diff_volume);
636 END IF;
637 --
638 --
639 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR
640 THEN
641 RAISE FND_API.G_EXC_ERROR;
642 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR
643 THEN
644 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
645 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_WARNING
646 THEN
647 x_diff_volume := 0;
648 END IF;
649 --
650 --
651 IF l_debug_on THEN
652 WSH_DEBUG_SV.logmsg(l_module_name,
653 'Number of Errors='||l_num_errors||',Number of Warnings='||l_num_warnings);
654 END IF;
655 --
656 IF l_num_errors > 0
657 THEN
658 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
659 ELSIF l_num_warnings > 0
660 THEN
661 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
662 ELSE
663 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
664 END IF;
665 --
666 -- Debug Statements
667 --
668 IF l_debug_on THEN
669 WSH_DEBUG_SV.pop(l_module_name);
670 END IF;
671 --
672 --}
673 EXCEPTION
674 --{
675 WHEN FND_API.G_EXC_ERROR THEN
676 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
677 --
678 -- Debug Statements
679 --
680 IF l_debug_on THEN
681 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
682 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
683 END IF;
684 --
685 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
686 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
687 --
688 -- Debug Statements
689 --
693 END IF;
690 IF l_debug_on THEN
691 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
692 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
694 --
695 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
696 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
697 --
698 -- Debug Statements
699 --
700 IF l_debug_on THEN
701 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
702 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
703 END IF;
704 --
705 WHEN OTHERS THEN
706 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
707 wsh_util_core.default_handler('WSH_ASN_RECEIPT_PVT.getNetWeightVolume');
708 --
709 -- Debug Statements
710 --
711 IF l_debug_on THEN
712 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
713 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
714 END IF;
715 --
716 --}
717 END getNetWeightVolume;
718 --
719 --
720
721
722 -- Start of comments
723 -- API name : updateDlvyWeightVolume
724 -- Type : Public
725 -- Pre-reqs : None.
726 -- Function : This API updates the given input deliverie's weight/volume
727 -- based on the other input parameter values.
728 -- Parameters :
729 -- IN:
730 -- p_deliveryId IN NUMBER
731 -- The Delivery id for which the update in weight/volume has to be done.
732 -- p_diff_gross_weight IN NUMBER
733 -- The difference in gross weight, that has to be updated for the Delivery.
734 -- p_diff_net_weight IN NUMBER
735 -- The difference in net weight, that has to be updated for the Delivery.
736 -- p_diff_volume IN NUMBER
737 -- The difference in volume, that has to be updated for the Delivery.
738 -- IN OUT:
739 --
740 -- OUT:
741 -- x_return_status OUT NOCOPY VARCHAR2
742 -- Version : 1.0
743 -- Previous version 1.0
744 -- Initial version 1.0
745 -- End of comments
746
747 PROCEDURE updateDlvyWeightVolume
748 (
749 p_deliveryId IN NUMBER,
750 p_diff_gross_weight IN NUMBER,
751 p_diff_net_weight IN NUMBER,
752 p_diff_volume IN NUMBER,
753 x_return_status OUT NOCOPY VARCHAR2
754 )
755 IS
756 --{
757 --
758 --
759 l_num_warnings NUMBER := 0;
760 l_num_errors NUMBER := 0;
761 l_return_status VARCHAR2(30);
762 --
763 l_debug_on BOOLEAN;
764 --
765 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'updateDlvyWeightVolume';
766 --
767 --}
768 BEGIN
769 --{
770 --
771 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
772 --
773 IF l_debug_on IS NULL
774 THEN
775 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
776 END IF;
777 --
778 --
779 -- Debug Statements
780 --
781 IF l_debug_on THEN
782 WSH_DEBUG_SV.push(l_module_name);
783 WSH_DEBUG_SV.log(l_module_name,'p_deliveryId',p_deliveryId);
784 WSH_DEBUG_SV.log(l_module_name,'p_diff_gross_weight',p_diff_gross_weight);
785 WSH_DEBUG_SV.log(l_module_name,'p_diff_net_weight',p_diff_net_weight);
786 WSH_DEBUG_SV.log(l_module_name,'p_diff_volume',p_diff_volume);
787 END IF;
788 --
789 UPDATE wsh_new_deliveries
790 SET gross_weight = NVL(gross_weight,0) - NVL(p_diff_gross_weight,0),
791 net_weight = NVL(net_weight,0) - NVL(p_diff_net_weight,0),
792 volume = NVL(volume,0) - NVL(p_diff_volume,0),
793 LAST_UPDATE_DATE = SYSDATE,
794 LAST_UPDATED_BY = FND_GLOBAL.USER_ID,
795 LAST_UPDATE_LOGIN = FND_GLOBAL.LOGIN_ID
796 WHERE delivery_id = p_deliveryId;
797 --
798 --
799 IF l_debug_on THEN
800 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_WV_UTILS.Del_WV_Post_Process',WSH_DEBUG_SV.C_PROC_LEVEL);
801 END IF;
802 --
803 WSH_WV_UTILS.Del_WV_Post_Process
804 (
805 p_delivery_id => p_deliveryId,
806 p_diff_gross_wt => NVL(-1 * p_diff_gross_weight,0),
807 p_diff_net_wt => NVL(-1 * p_diff_net_weight,0),
808 p_diff_volume => NVL(-1 * p_diff_volume,0),
809 x_return_status => l_return_status
810 );
811 --
812 --
813 IF l_debug_on THEN
814 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
815 END IF;
816 --
817 --
818 IF l_debug_on THEN
819 WSH_DEBUG_SV.logmsg(l_module_name,
820 'Number of Errors='||l_num_errors||',Number of Warnings='||l_num_warnings);
821 END IF;
822 --
823 IF l_num_errors > 0
824 THEN
825 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
829 ELSE
826 ELSIF l_num_warnings > 0
827 THEN
828 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
830 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
831 END IF;
832 --
833 -- Debug Statements
834 --
835 IF l_debug_on THEN
836 WSH_DEBUG_SV.pop(l_module_name);
837 END IF;
838 --
839 --}
840 EXCEPTION
841 --{
842 WHEN FND_API.G_EXC_ERROR THEN
843 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
844 --
845 -- Debug Statements
846 --
847 IF l_debug_on THEN
848 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
849 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
850 END IF;
851 --
852 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
853 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
854 --
855 -- Debug Statements
856 --
857 IF l_debug_on THEN
858 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
859 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
860 END IF;
861 --
862 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
863 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
864 --
865 -- Debug Statements
866 --
867 IF l_debug_on THEN
868 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
869 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
870 END IF;
871 --
872 WHEN OTHERS THEN
873 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
874 wsh_util_core.default_handler('WSH_ASN_RECEIPT_PVT.updateDlvyWeightVolume');
875 --
876 -- Debug Statements
877 --
878 IF l_debug_on THEN
879 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
880 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
881 END IF;
882 --
883 --}
884 END updateDlvyWeightVolume;
885 --
886 --
887
888
889
890 -- Start of comments
891 -- API name : updateLPNWeightVolume
892 -- Type : Public
893 -- Pre-reqs : None.
894 -- Function : This API is used to update any changes in weight/volume happening
895 -- for an LPN.
896 -- Parameters :
897 -- IN:
898 -- p_LPNId IN NUMBER
899 -- The LPN id for which the update in weight/volume has to be done.
900 -- p_diff_gross_weight IN NUMBER
901 -- The difference in gross weight, that has to be updated for the LPN.
902 -- p_diff_net_weight IN NUMBER
903 -- The difference in net weight, that has to be updated for the LPN.
904 -- p_diff_volume IN NUMBER
905 -- The difference in volume, that has to be updated for the LPN.
906 -- IN OUT:
907 -- OUT:
908 -- x_return_status OUT NOCOPY VARCHAR2
909 -- Version : 1.0
910 -- Previous version 1.0
911 -- Initial version 1.0
912 -- End of comments
913
914 PROCEDURE updateLPNWeightVolume
915 (
916 p_LPNId IN NUMBER,
917 p_diff_gross_weight IN NUMBER,
918 p_diff_net_weight IN NUMBER,
919 p_diff_volume IN NUMBER,
920 x_return_status OUT NOCOPY VARCHAR2
921 )
922 IS
923 --{
924 --
925 --
926 l_num_warnings NUMBER := 0;
927 l_num_errors NUMBER := 0;
928 l_return_status VARCHAR2(30);
929 --
930 l_debug_on BOOLEAN;
931 --
932 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'updateLPNWeightVolume';
933 --
934 --}
935 BEGIN
936 --{
937 --
938 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
939 --
940 IF l_debug_on IS NULL
941 THEN
942 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
943 END IF;
944 --
945 --
946 -- Debug Statements
947 --
948 IF l_debug_on THEN
949 WSH_DEBUG_SV.push(l_module_name);
950 WSH_DEBUG_SV.log(l_module_name,'p_LPNId',p_LPNId);
951 WSH_DEBUG_SV.log(l_module_name,'p_diff_gross_weight',p_diff_gross_weight);
952 WSH_DEBUG_SV.log(l_module_name,'p_diff_net_weight',p_diff_net_weight);
953 WSH_DEBUG_SV.log(l_module_name,'p_diff_volume',p_diff_volume);
954 END IF;
955 --
956 UPDATE wsh_delivery_details
957 SET gross_weight = NVL(gross_weight,0) - NVL(p_diff_gross_weight,0),
958 net_weight = NVL(net_weight,0) - NVL(p_diff_net_weight,0),
959 filled_volume = NVL(filled_volume,0) - NVL(p_diff_volume,0),
960 LAST_UPDATE_DATE = SYSDATE,
961 LAST_UPDATED_BY = FND_GLOBAL.USER_ID,
962 LAST_UPDATE_LOGIN = FND_GLOBAL.LOGIN_ID
963 WHERE delivery_detail_id = p_LPNId;
964 --
965 --
966 IF l_debug_on THEN
970 WSH_WV_UTILS.DD_WV_Post_Process
967 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_WV_UTILS.DD_WV_Post_Process',WSH_DEBUG_SV.C_PROC_LEVEL);
968 END IF;
969 --
971 (
972 p_delivery_detail_id => p_LPNId,
973 p_diff_gross_wt => NVL(-1 * p_diff_gross_weight,0),
974 p_diff_net_wt => NVL(-1 * p_diff_net_weight,0),
975 p_diff_fill_volume => NVL(-1 * p_diff_volume,0),
976 x_return_status => l_return_status
977 );
978 --
979 --
980 IF l_debug_on THEN
981 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
982 END IF;
983 --
984 --
985 IF l_debug_on THEN
986 WSH_DEBUG_SV.logmsg(l_module_name,
987 'Number of Errors='||l_num_errors||',Number of Warnings='||l_num_warnings);
988 END IF;
989 --
990 IF l_num_errors > 0
991 THEN
992 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
993 ELSIF l_num_warnings > 0
994 THEN
995 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
996 ELSE
997 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
998 END IF;
999 --
1000 -- Debug Statements
1001 --
1002 IF l_debug_on THEN
1003 WSH_DEBUG_SV.pop(l_module_name);
1004 END IF;
1005 --
1006 --}
1007 EXCEPTION
1008 --{
1009 WHEN FND_API.G_EXC_ERROR THEN
1010 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1011 --
1012 -- Debug Statements
1013 --
1014 IF l_debug_on THEN
1015 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1016 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
1017 END IF;
1018 --
1019 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1020 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
1021 --
1022 -- Debug Statements
1023 --
1024 IF l_debug_on THEN
1025 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1026 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
1027 END IF;
1028 --
1029 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
1030 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
1031 --
1032 -- Debug Statements
1033 --
1034 IF l_debug_on THEN
1035 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1036 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
1037 END IF;
1038 --
1039 WHEN OTHERS THEN
1040 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
1041 wsh_util_core.default_handler('WSH_ASN_RECEIPT_PVT.updateLPNWeightVolume');
1042 --
1043 -- Debug Statements
1044 --
1045 IF l_debug_on THEN
1046 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
1047 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
1048 END IF;
1049 --
1050 --}
1051 END updateLPNWeightVolume;
1052 --
1053 --
1054
1055 -- Start of comments
1056 -- API name : updateWeightVolume
1057 -- Type : Public
1058 -- Pre-reqs : None.
1059 -- Function : The main job of this API is to to determine whether any change in values has happened
1060 -- for the deliveries/LPN weight or volume. If there is some change then it takes care of
1061 -- updating the same.
1062 -- Parameters :
1063 -- IN:
1064 -- p_entity IN VARCHAR2
1065 -- IN OUT:
1066 -- x_GWTcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
1067 -- x_GWTcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
1068 -- x_NWTcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
1069 -- x_NWTcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
1070 -- x_VOLcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
1071 -- x_VOLcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
1072 -- OUT:
1073 -- x_return_status OUT NOCOPY VARCHAR2
1074 -- Version : 1.0
1075 --Cache Tables:
1076 -- ----------------------------------------------------------------------
1077 -- | Cache Table Name | Key | Value |
1078 -- ----------------------------------------------------------------------
1079 -- |x_GWTcachetbl | LPN ID/Delivery ID | Gross Weight |
1080 -- |x_GWTcacheExttbl | LPN ID/Delivery ID | Gross Weight |
1081 -- -----------------------------------------------------------------------
1082 -- |x_NWTcachetbl | LPN ID/Delivery ID | Net Weight |
1083 -- |x_NWTcacheExttbl | LPN ID/Delivery ID | Net Weight |
1084 -- -----------------------------------------------------------------------
1085 -- |x_VOLcachetbl | LPN ID/Delivery ID | Volume |
1089 -- Initial version 1.0
1086 -- |x_VOLcacheExttbl | LPN ID/Delivery ID | Volume |
1087 -- -----------------------------------------------------------------------
1088 -- Previous version 1.0
1090 -- End of comments
1091
1092 PROCEDURE updateWeightVolume
1093 (
1094 p_entity IN VARCHAR2,
1095 x_GWTcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
1096 x_GWTcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
1097 x_NWTcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
1098 x_NWTcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
1099 x_VOLcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
1100 x_VOLcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
1101 x_return_status OUT NOCOPY VARCHAR2
1102 )
1103 IS
1104 --{
1105 --
1106 --
1107 l_num_warnings NUMBER := 0;
1108 l_num_errors NUMBER := 0;
1109 l_return_status VARCHAR2(30);
1110 --
1111 l_index NUMBER;
1112 --
1113 l_delivery_lpn_id NUMBER;
1114 l_diff_gross_weight NUMBER;
1115 l_diff_net_weight NUMBER;
1116 l_diff_volume NUMBER;
1117 l_debug_on BOOLEAN;
1118 --
1119 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'updateWeightVolume';
1120 --
1121 --}
1122 BEGIN
1123 --{
1124 --
1125 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
1126 --
1127 IF l_debug_on IS NULL
1128 THEN
1129 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
1130 END IF;
1131 --
1132 --
1133 -- Debug Statements
1134 --
1135 IF l_debug_on THEN
1136 WSH_DEBUG_SV.push(l_module_name);
1137 WSH_DEBUG_SV.log(l_module_name,'p_entity',p_entity);
1138 END IF;
1139 --
1140 l_index := x_GWTCacheTbl.FIRST;
1141 --
1142 --
1143
1144 -- checking for weight/volume changes for the delivery/lpns present
1145 -- in the cache table x_GWTCacheTbl, for which the key-value is less
1146 -- than (2^31)
1147 WHILE l_index IS NOT NULL
1148 LOOP
1149 --{
1150 l_delivery_lpn_id := x_GWTCacheTbl(l_index).key;
1151 l_diff_gross_weight := x_GWTCacheTbl(l_index).value;
1152 --
1153 --
1154 IF l_debug_on THEN
1155 WSH_DEBUG_SV.log(l_module_name,'l_diff_gross_weight',l_diff_gross_weight);
1156 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_ASN_RECEIPT_PVT.getNetWeightVolume',WSH_DEBUG_SV.C_PROC_LEVEL);
1157 END IF;
1158 --
1159 --
1160 -- This API whether the weight/volume has changed for the given
1161 -- delivery/LPN and returns the difference if any.
1162 WSH_ASN_RECEIPT_PVT.getNetWeightVolume
1163 (
1164 p_key => l_delivery_lpn_id,
1165 x_NWTcachetbl => x_NWTcachetbl,
1166 x_NWTcacheExttbl => x_NWTcacheExttbl,
1167 x_VOLcachetbl => x_VOLcachetbl,
1168 x_VOLcacheExttbl => x_VOLcacheExttbl,
1169 x_diff_net_weight => l_diff_net_weight,
1170 x_diff_volume => l_diff_volume,
1171 x_return_status => l_return_status
1172 );
1173 --
1174 IF l_debug_on THEN
1175 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
1176 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
1177 END IF;
1178 --
1179 wsh_util_core.api_post_call
1180 (
1181 p_return_status => l_return_status,
1182 x_num_warnings => l_num_warnings,
1183 x_num_errors => l_num_errors
1184 );
1185 --
1186 --
1187 -- If true , it implies that a change in volume/weight has happened for the given
1188 -- input delivery/LPN.This change in value is determined by the call to the
1189 IF l_diff_gross_weight > 0
1190 OR l_diff_net_weight > 0
1191 OR l_diff_volume > 0
1192 THEN
1193 --{
1194 IF p_entity = 'DLVY'
1195 THEN
1196 --{
1197 IF l_debug_on THEN
1198 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_ASN_RECEIPT_PVT.updateDlvyWeightVolume',WSH_DEBUG_SV.C_PROC_LEVEL);
1199 END IF;
1200 --
1201 --
1202 WSH_ASN_RECEIPT_PVT.updateDlvyWeightVolume
1203 (
1204 p_deliveryId => l_delivery_lpn_id,
1205 p_diff_gross_weight => l_diff_gross_weight,
1206 p_diff_net_weight => l_diff_net_weight,
1207 p_diff_volume => l_diff_volume,
1208 x_return_status => l_return_status
1209 );
1210 --}
1211 ELSIF p_entity = 'LPN'
1212 THEN
1216 END IF;
1213 --{
1214 IF l_debug_on THEN
1215 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_ASN_RECEIPT_PVT.updateLPNWeightVolume',WSH_DEBUG_SV.C_PROC_LEVEL);
1217 --
1218 --
1219 WSH_ASN_RECEIPT_PVT.updateLPNWeightVolume
1220 (
1221 p_LPNId => l_delivery_lpn_id,
1222 p_diff_gross_weight => l_diff_gross_weight,
1223 p_diff_net_weight => l_diff_net_weight,
1224 p_diff_volume => l_diff_volume,
1225 x_return_status => l_return_status
1226 );
1227 --}
1228 END IF;
1229 --
1230 IF l_debug_on THEN
1231 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
1232 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
1233 END IF;
1234 --
1235 wsh_util_core.api_post_call
1236 (
1237 p_return_status => l_return_status,
1238 x_num_warnings => l_num_warnings,
1239 x_num_errors => l_num_errors
1240 );
1241 --}
1242 END IF;
1243 --
1244 --
1245 l_index := x_GWTCacheTbl.NEXT(l_index);
1246 --}
1247 END LOOP;
1248 --
1249 --
1250 l_index := x_GWTCacheExtTbl.FIRST;
1251 --
1252 --
1253 -- checking for weight/volume changes for the delivery/lpns present
1254 -- in the cache table x_GWTCacheExtTbl, for which the key-value is greater
1255 -- than (2^31 - 1)
1256 WHILE l_index IS NOT NULL
1257 LOOP
1258 --{
1259 l_delivery_lpn_id := x_GWTCacheExtTbl(l_index).key;
1260 l_diff_gross_weight := x_GWTCacheExtTbl(l_index).value;
1261 --
1262 --
1263 IF l_debug_on THEN
1264 WSH_DEBUG_SV.log(l_module_name,'l_diff_gross_weight',l_diff_gross_weight);
1265 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_ASN_RECEIPT_PVT.getNetWeightVolume',WSH_DEBUG_SV.C_PROC_LEVEL);
1266 END IF;
1267 --
1268 --
1269 -- This API whether the weight/volume has changed for the given
1270 -- delivery/LPN and returns the difference if any.
1271 WSH_ASN_RECEIPT_PVT.getNetWeightVolume
1272 (
1273 p_key => l_delivery_lpn_id,
1274 x_NWTcachetbl => x_NWTcachetbl,
1275 x_NWTcacheExttbl => x_NWTcacheExttbl,
1276 x_VOLcachetbl => x_VOLcachetbl,
1277 x_VOLcacheExttbl => x_VOLcacheExttbl,
1278 x_diff_net_weight => l_diff_net_weight,
1279 x_diff_volume => l_diff_volume,
1280 x_return_status => l_return_status
1281 );
1282 --
1283 IF l_debug_on THEN
1284 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
1285 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
1286 END IF;
1287 --
1288 wsh_util_core.api_post_call
1289 (
1290 p_return_status => l_return_status,
1291 x_num_warnings => l_num_warnings,
1292 x_num_errors => l_num_errors
1293 );
1294 --
1295 --
1296 -- If true , it implies that a change in volume/weight has happened for the given
1297 -- input delivery/LPN.This change in value is determined by the call to the
1298 IF l_diff_gross_weight > 0
1299 OR l_diff_net_weight > 0
1300 OR l_diff_volume > 0
1301 THEN
1302 --{
1303 IF p_entity = 'DLVY'
1304 THEN
1305 --{
1306 IF l_debug_on THEN
1307 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_ASN_RECEIPT_PVT.updateDlvyWeightVolume',WSH_DEBUG_SV.C_PROC_LEVEL);
1308 END IF;
1309 --
1310 --
1311 WSH_ASN_RECEIPT_PVT.updateDlvyWeightVolume
1312 (
1313 p_deliveryId => l_delivery_lpn_id,
1314 p_diff_gross_weight => l_diff_gross_weight,
1315 p_diff_net_weight => l_diff_net_weight,
1316 p_diff_volume => l_diff_volume,
1317 x_return_status => l_return_status
1318 );
1319 --}
1320 ELSIF p_entity = 'LPN'
1321 THEN
1322 --{
1323 IF l_debug_on THEN
1324 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_ASN_RECEIPT_PVT.updateLPNWeightVolume',WSH_DEBUG_SV.C_PROC_LEVEL);
1325 END IF;
1326 --
1327 --
1328 WSH_ASN_RECEIPT_PVT.updateLPNWeightVolume
1329 (
1330 p_LPNId => l_delivery_lpn_id,
1331 p_diff_gross_weight => l_diff_gross_weight,
1335 );
1332 p_diff_net_weight => l_diff_net_weight,
1333 p_diff_volume => l_diff_volume,
1334 x_return_status => l_return_status
1336 --}
1337 END IF;
1338 --
1339 IF l_debug_on THEN
1340 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
1341 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
1342 END IF;
1343 --
1344 wsh_util_core.api_post_call
1345 (
1346 p_return_status => l_return_status,
1347 x_num_warnings => l_num_warnings,
1348 x_num_errors => l_num_errors
1349 );
1350 --}
1351 END IF;
1352 --
1353 --
1354 l_index := x_GWTCacheExtTbl.NEXT(l_index);
1355 --}
1356 END LOOP;
1357 --
1358 --
1359 --
1360 IF l_debug_on THEN
1361 WSH_DEBUG_SV.logmsg(l_module_name,
1362 'Number of Errors='||l_num_errors||',Number of Warnings='||l_num_warnings);
1363 END IF;
1364 --
1365 IF l_num_errors > 0
1366 THEN
1367 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1368 ELSIF l_num_warnings > 0
1369 THEN
1370 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
1371 ELSE
1372 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
1373 END IF;
1374 --
1375 -- Debug Statements
1376 --
1377 IF l_debug_on THEN
1378 WSH_DEBUG_SV.pop(l_module_name);
1379 END IF;
1380 --
1381 --}
1382 EXCEPTION
1383 --{
1384 WHEN FND_API.G_EXC_ERROR THEN
1385 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1386 --
1387 -- Debug Statements
1388 --
1389 IF l_debug_on THEN
1390 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1391 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
1392 END IF;
1393 --
1394 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1395 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
1396 --
1397 -- Debug Statements
1398 --
1399 IF l_debug_on THEN
1400 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1401 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
1402 END IF;
1403 --
1404 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
1405 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
1406 --
1407 -- Debug Statements
1408 --
1409 IF l_debug_on THEN
1410 WSH_DEBUG_SV.logmsg(l_module_name,'WSH_UTIL_CORE.G_EXC_WARNING exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1411 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_UTIL_CORE.G_EXC_WARNING');
1412 END IF;
1413 --
1414 WHEN OTHERS THEN
1415 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
1416 wsh_util_core.default_handler('WSH_ASN_RECEIPT_PVT.updateWeightVolume');
1417 --
1418 -- Debug Statements
1419 --
1420 IF l_debug_on THEN
1421 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
1422 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
1423 END IF;
1424 --
1425 --}
1426 END updateWeightVolume;
1427 --} --NNP-WV
1428 --
1429 --
1430 -- Start of comments
1431 -- API name : Process_Matched_Txns
1432 -- Type : Private
1433 -- Pre-reqs : None.
1434 -- Function : The following actions are carried out in this API:
1435 -- 1.If the API is called from UI, the p_line_rec structure is empty.
1436 -- Derive the p_line_rec if called from UI.
1437 -- 2.Match the ASN/Receipt to wsh_delivery_details, where by records in wsh_delivery_details
1438 -- are updated, new records are created if needed.
1439 -- 3.If the original PO record is closed/cancelled, then collect the list of those
1440 -- recrods into x_po_cancel_rec and x_po_close_rec which are the OUT parameters
1441 -- which will be used in Ravi's API to later perform cancle/close action on the
1442 -- delivery details.
1443 -- 4.Call initialize_txn API which will create delivery/trip for those recrods for which delivery
1444 -- id is null, created trip id for those records for which delivery id is persent, but trip
1445 -- id is null.
1446 -- 5.Call reconfigure_del_trip API which will reconfigure the delviery and
1447 -- trip based on the grouping criteria.
1448 -- 6.Collect the list of unique delivery ids which needs tp be repriced.
1449 --
1450 -- Parameters :
1451 -- IN OUT:
1452 -- p_dd_rec IN OUT NOCOPY WSH_IB_UI_RECON_GRP.asn_rcv_del_det_rec_type
1453 -- p_line_rec IN OUT NOCOPY OE_WSH_BULK_GRP.line_rec_type
1454 -- p_action_prms IN OUT NOCOPY WSH_GLBL_VAR_STRCT_GRP.dd_action_parameters_rec_type
1455 --IN:
1456 -- p_shipment_header_id IN NUMBER,
1457 -- p_max_txn_id IN NUMBER
1458 -- OUT:
1462 -- Cache Tables :
1459 -- x_po_cancel_rec OUT NOCOPY OE_WSH_BULK_GRP.line_rec_type
1460 -- x_po_close_rec OUT NOCOPY OE_WSH_BULK_GRP.line_rec_type
1461 -- x_return_status OUT NOCOPY VARCHAR2
1463 -- ----------------------------------------------------------------------
1464 -- | Cache Table Name | Key | Value |
1465 -- ----------------------------------------------------------------------
1466 -- |l_index_dd_ids_cache | index | Delivery Detail ID |
1467 -- |l_index_dd_ids_ext_cache | index | Delivery Detail ID |
1468 -- |----------------------------------------------------------------------
1469 -- |l_index_del_ids_cache | index | Delivery ID |
1470 -- |l_index_del_ids_ext_cache | index | Delivery ID |
1471 -- |----------------------------------------------------------------------
1472 -- |l_del_ids_del_ids_cache | Delivery Detail ID | Delivery Detail ID |
1473 -- |l_del_ids_del_ids_ext_cache| Delivery Detail ID | Delivery Detail ID |
1474 -- |----------------------------------------------------------------------
1475 -- |l_sli_qty_cache | Shipment Line ID | Quantity |
1476 -- |l_sli_qty_ext_cache | Shipment Line ID | Quantity |
1477 -- |----------------------------------------------------------------------
1478 -- |l_sli_sli_cache | Shipment Line ID | Shipment Line ID |
1479 -- |l_sli_sli_ext_cache | Shipment Line ID | Shipment Line ID |
1480 -- |----------------------------------------------------------------------
1481 -- |l_del_reprice_tbl | Delivery ID | Delivery ID |
1482 -- |l_del_reprice_ext_tbl | Delivery ID | Delivery ID |
1483 -- -----------------------------------------------------------------------
1484 -- Version : 1.0
1485 -- Previous version 1.0
1486 -- Initial version 1.0
1487 -- End of comments
1488
1489 PROCEDURE Process_Matched_Txns(
1490 p_dd_rec IN OUT NOCOPY WSH_IB_UI_RECON_GRP.asn_rcv_del_det_rec_type,
1491 p_line_rec IN OUT NOCOPY OE_WSH_BULK_GRP.line_rec_type,
1492 p_action_prms IN OUT NOCOPY WSH_GLBL_VAR_STRCT_GRP.dd_action_parameters_rec_type,
1493 p_shipment_header_id IN NUMBER,
1494 p_max_txn_id IN NUMBER,
1495 x_po_cancel_rec OUT NOCOPY OE_WSH_BULK_GRP.line_rec_type,
1496 x_po_close_rec OUT NOCOPY OE_WSH_BULK_GRP.line_rec_type,
1497 x_return_status OUT NOCOPY VARCHAR2)
1498
1499 IS
1500
1501 -- Cursor to fetch the src_requested_quantity2 for the po_line_location_id
1502
1503 Cursor c_src_qty2(p_line_id NUMBER,p_line_location_id NUMBER)
1504 is
1505 select src_requested_quantity2,
1506 src_requested_quantity_uom2,
1507 src_requested_quantity,
1508 src_requested_quantity_uom
1509 from WSH_DELIVERY_DETAILS
1510 where
1511 source_line_id = p_line_id and --performance
1512 po_shipment_line_id = p_line_location_id and
1513 source_code = 'PO'
1514 order by decode(Released_status,'X',1,2);
1515 --AND rownum = 1;
1516
1517 -- Cursor to fetch the sum of the requested quantity for the givine po_line_location_id
1518
1519 Cursor c_sum_req_qty(p_line_id NUMBER,p_line_location_id NUMBER)
1520 IS
1521 select sum(requested_quantity)
1522 from wsh_delivery_details
1523 where
1524 source_line_id = p_line_id and --performance
1525 po_shipment_line_id = p_line_location_id and
1526 source_code = 'PO';
1527
1528 -- Cursor to fetch the delivery,delivery leg and trip infrmation for the delivery being processed.
1529 CURSOR get_delivery_info(p_del_id_c1 NUMBER) IS
1530 SELECT t.trip_id
1531 FROM wsh_new_deliveries dl,
1532 wsh_delivery_legs dg,
1533 wsh_trip_stops st,
1534 wsh_trips t
1535 WHERE dl.delivery_id = p_del_id_c1 AND
1536 dl.delivery_id = dg.delivery_id AND
1537 dg.drop_off_stop_id = st.stop_id AND
1538 st.stop_location_id = dl.ULTIMATE_DROPOFF_LOCATION_ID AND
1539 st.trip_id = t.trip_id;
1540
1541 -- Cursor to fing if a particular delivery has legs associated with it or not.
1542
1543 CURSOR c_has_del_leg(p_del_id_c2 NUMBER) IS
1544 SELECT '1'
1545 FROM wsh_new_deliveries dl,
1546 wsh_delivery_legs dg
1547 WHERE dl.delivery_id = p_del_id_c2 AND
1548 dl.delivery_id = dg.delivery_id;
1549
1550 CURSOR line_csr (p_delivery_detail_id NUMBER)
1551 IS
1552 SELECT wdd.gross_weight, wdd.net_weight, wdd.volume,
1553 NVL(wdd.wv_frozen_flag,'Y') wv_frozen_flag,
1554 wda.parent_delivery_detail_id,
1555 wda.delivery_id,
1556 NVL(wdd1.wv_frozen_flag,'Y') lpn_wv_frozen_flag,
1557 NVL(wnd.wv_frozen_flag,'Y') dlvy_wv_frozen_flag,
1558 NVL
1559 (
1560 wdd.shipped_quantity,
1561 NVL
1562 (
1563 wdd.picked_quantity,
1564 wdd.requested_quantity
1565 )
1566 ) wv_qty,
1567 wdd.requested_quantity requested_quantity
1568 FROM wsh_delivery_details wdd,
1569 wsh_delivery_assignments_v wda,
1570 wsh_delivery_details wdd1,
1571 wsh_new_deliveries wnd
1572 where wdd.delivery_detail_id = p_delivery_detail_id
1573 AND wdd.delivery_detail_id = wda.delivery_detail_id
1574 --AND wda.delivery_id = wnd.delivery_id
1578 l_line_rec line_csr%ROWTYPE;
1575 AND wda.parent_delivery_detail_id = wdd1.delivery_detail_id (+)
1576 AND wda.delivery_id = wnd.delivery_id (+);
1577
1579 --
1580 --
1581 CURSOR packed_csr(p_wdd_id NUMBER)
1582 IS
1583 SELECT parent_delivery_Detail_id
1584 FROM wsh_delivery_assignments_v
1585 WHERE delivery_Detail_id = p_wdd_id;
1586
1587
1588 temp_lpn NUMBER;
1589
1590 p_dd_info WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Rec_Type;
1591 p_dd_assign_info WSH_DELIVERY_DETAILS_PKG.Delivery_Assignments_Rec_type;
1592
1593 p_dd_list WSH_PO_CMG_PVT.dd_list_type;
1594 l_local_dd_rec LOCAL_DD_REC_TABLE_TYPE;
1595
1596 l_parent_wdd_id NUMBER;
1597 l_return_status VARCHAR2(1);
1598 l_new_dd_id NUMBER;
1599 l_child_rtv_qty_to_consolidate NUMBER;
1600 l_child_remaining_qty NUMBER;
1601 l_remaining_qty NUMBER;
1602 l_remaining_qty1 NUMBER;
1603 l_pending_qty NUMBER;
1604 l_delivery_detail_id NUMBER;
1605 x_row_id VARCHAR2(30);
1606 x_rowid VARCHAR2(30);
1607 x_delivery_detail_id NUMBER;
1608 k NUMBER;
1609 x_split_weight NUMBER;
1610 x_split_volume NUMBER;
1611 x_delivery_assignment_id NUMBEr;
1612 l_header_id NUMBER;
1613 l_additional_line_info_rec WSH_BULK_PROCESS_PVT.additional_line_info_rec_type;
1614 l_api_version CONSTANT NUMBER := 1.0;
1615 l_msg_count NUMBER := 0;
1616 l_msg_data VARCHAR2(1000) := NULL;
1617 l_release_status VARCHAR2(1);
1618 l_update_dd_rec update_dd_rec_type;
1619 l_po_line_location_id NUMBER;
1620 l_index NUMBER;
1621 l_i_index NUMBER;
1622 l_i NUMBER;
1623 l_num_warnings NUMBER := 0;
1624 l_num_errors NUMBER := 0;
1625 l_itemp NUMBER;
1626 l_trip_id NUMBER;
1627 l_temp_char VARCHAR2(1);
1628
1629
1630 --arun's change
1631 l_dd_ids WSH_UTIL_CORE.id_tab_type;
1632
1633 l_index_dd_ids_cache WSH_UTIL_CORE.key_value_tab_type;
1634 l_index_dd_ids_ext_cache WSH_UTIL_CORE.key_value_tab_type;
1635 l_index_del_ids_cache WSH_UTIL_CORE.key_value_tab_type;
1636 l_index_del_ids_ext_cache WSH_UTIL_CORE.key_value_tab_type;
1637
1638 l_uniq_del_ids_tab wsh_util_core.id_tab_type;
1639
1640 l_del_ids_del_ids_cache WSH_UTIL_CORE.key_value_tab_type;
1641 l_del_ids_del_ids_ext_cache WSH_UTIL_CORE.key_value_tab_type;
1642
1643 --change for consolidate qty
1644 l_sli_qty_cache WSH_UTIL_CORE.key_value_tab_type;
1645 l_sli_qty_ext_cache WSH_UTIL_CORE.key_value_tab_type;
1646 l_sli_sli_cache WSH_UTIL_CORE.key_value_tab_type;
1647 l_sli_sli_ext_cache WSH_UTIL_CORE.key_value_tab_type;
1648 l_shp_line_id NUMBER;
1649 l_quantity NUMBER;
1650 l_src_qty NUMBER;
1651 l_src_qty_uom VARCHAR2(3);
1652 l_src_qty2 NUMBER;
1653 l_src_qty_uom2 VARCHAR2(3);
1654 l_sum_req_qty NUMBER;
1655 l_ratio NUMBER;
1656 --end of change for consolidate qty
1657
1658 --l_action_prms
1659 l_action_prms WSH_BULK_TYPES_GRP.action_parameters_rectype;
1660 --end of arun's change
1661 l_populate_p_line_rec VARCHAR2(1) := 'N';
1662
1663
1664 l_del_ids_tab WSH_UTIL_CORE.id_tab_type;
1665 l_del_reprice_tbl WSH_UTIL_CORE.key_value_tab_type;
1666 l_del_reprice_ext_tbl WSH_UTIL_CORE.key_value_tab_type;
1667 j NUMBER;
1668 l_ind NUMBER;
1669 -- code copied after finding the diff
1670 l_object_version_number NUMBER;
1671
1672 l_outermost_lpn NUMBER;
1673 l_outermost_lpn_name VARCHAR2(50);
1674
1675 p_loc_id_index_cache WSH_UTIL_CORE.key_value_tab_type;
1676 p_loc_id_index_ext_cache WSH_UTIL_CORE.key_value_tab_type;
1677 l_value NUMBER;
1678 l_cache_return_status VARCHAR2(1);
1679 l_pline_rec_count NUMBER;
1680
1681 kk NUMBER;
1682
1683 --{ --NNP-WV
1684 l_lpnGWTcachetbl WSH_UTIL_CORE.key_value_tab_type;
1685 l_lpnGWTcacheExttbl WSH_UTIL_CORE.key_value_tab_type;
1686 l_lpnNWTcachetbl WSH_UTIL_CORE.key_value_tab_type;
1687 l_lpnNWTcacheExttbl WSH_UTIL_CORE.key_value_tab_type;
1688 l_lpnVOLcachetbl WSH_UTIL_CORE.key_value_tab_type;
1689 l_lpnVOLcacheExttbl WSH_UTIL_CORE.key_value_tab_type;
1690 --
1691 --
1692 l_dlvyGWTcachetbl WSH_UTIL_CORE.key_value_tab_type;
1693 l_dlvyGWTcacheExttbl WSH_UTIL_CORE.key_value_tab_type;
1694 l_dlvyNWTcachetbl WSH_UTIL_CORE.key_value_tab_type;
1695 l_dlvyNWTcacheExttbl WSH_UTIL_CORE.key_value_tab_type;
1696 l_dlvyVOLcachetbl WSH_UTIL_CORE.key_value_tab_type;
1697 l_dlvyVOLcacheExttbl WSH_UTIL_CORE.key_value_tab_type;
1698 --
1699 --
1700 l_org_wv_qty NUMBER;
1701 l_gross_wt_pc NUMBER;
1702 l_net_wt_pc NUMBER;
1703 l_vol_pc NUMBER;
1704 --
1705 l_old_wv_qty NUMBER;
1706 l_new_wv_qty NUMBER;
1707 l_old_dd_gross_weight NUMBER;
1708 l_old_dd_net_weight NUMBER;
1709 l_old_dd_volume NUMBER;
1713 --} --NNP-WV
1710 l_diff_dd_gross_weight NUMBER;
1711 l_diff_dd_net_weight NUMBER;
1712 l_diff_dd_volume NUMBER;
1714
1715 l_lpnIdCacheTbl WSH_UTIL_CORE.key_value_tab_type;
1716 l_lpnIdCacheExtTbl WSH_UTIL_CORE.key_value_tab_type;
1717
1718 l_detail_tab WSH_UTIL_CORE.id_tab_type; -- DBI Project
1719 l_dbi_rs VARCHAR2(1); -- DBI Project
1720
1721 --
1722 l_debug_on BOOLEAN;
1723 --
1724 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'PROCESS_MATCHED_TXNS';
1725 --
1726 BEGIN
1727
1728 --
1729 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
1730 --
1731 IF l_debug_on IS NULL
1732 THEN
1733 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
1734 END IF;
1735 --
1736 --
1737 -- Debug Statements
1738 --
1739 IF l_debug_on THEN
1740 WSH_DEBUG_SV.push(l_module_name);
1741 --
1742 WSH_DEBUG_SV.log(l_module_name,'P_SHIPMENT_HEADER_ID',P_SHIPMENT_HEADER_ID);
1743 WSH_DEBUG_SV.log(l_module_name,'P_MAX_TXN_ID',P_MAX_TXN_ID);
1744 END IF;
1745 --
1746 SAVEPOINT Process_Matched_Txns_PVT;
1747 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
1748 -- When the API is called from UI, p_line_Rec will not be populated.
1749 -- Need to populate the p_line_rec information in this case.
1750 -- If the API is called from matching algorithm, we have the entire p_line_rec
1751 -- populated.
1752 -- The first part of the API is to derive p_line_rec in case it is empty
1753 -- and also assign the p_line_rec index value to p_dd_rec.
1754 -- It is possible that the same po_line_location can have multiple receipt lines.
1755 -- Also same receipt lines can have multiple entries in p_dd_rec.
1756 -- p_line_rec is populated when ever the receipt line id(rcv_shipment_line_id)
1757 -- changes.
1758
1759 IF p_line_rec.po_shipment_line_id.COUNT = 0 THEN
1760 -- Need to populate the p_line_rec information in this case.
1761 -- This is done by setting the flag l_populate_p_line_rec.
1762 l_populate_p_line_rec := 'Y';
1763 END IF;
1764
1765 IF l_debug_on THEN
1766 WSH_DEBUG_SV.log(l_module_name,'l_populate_p_line_rec',l_populate_p_line_rec);
1767 WSH_DEBUG_SV.log(l_module_name,'p_line_rec.po_shipment_line_id.COUNT',p_line_rec.po_shipment_line_id.COUNT);
1768 WSH_DEBUG_SV.log(l_module_name,'p_dd_rec.transaction_type',p_dd_rec.transaction_type);
1769 END IF;
1770 --
1771
1772 IF p_dd_rec.transaction_type = 'ASN' THEN
1773 --{
1774 l_release_status := 'C';
1775 ELSIF p_dd_rec.transaction_type = 'RECEIPT' THEN
1776 l_release_status := 'L';
1777 END IF;
1778
1779 --}
1780 l_po_line_location_id := -99;
1781
1782 FOR i IN 1..p_dd_rec.del_detail_id_tab.COUNT
1783 LOOP
1784 -- check if the rcv_shipment_line_id is present in the cache table for the current
1785 -- record
1786 -- if it is present, return the value from the cache table to
1787 -- p_dd_rec.shpmt_line_id_idx_tab
1788 -- if data is not in cache table call WSH_INBOUND_UTIL_PKG.get_po_rcv_attributes() API.
1789 -- after calling WSH_INBOUND_UTIL_PKG.get_po_rcv_attributes() API, put the value of
1790 -- rcv_shipment_line_id and the index of p_line_rec to the cache table, so that if
1791 -- another record belonging to the same rcv_shipment_line_id is encountered, then
1792 -- the p_line_rec index can be obtained from the cache table.
1793 -- p_dd_rec.shipment_line_id_idx is the link between the two structures viz.p_line_rec
1794 -- and p_dd_rec.
1795
1796 IF l_debug_on THEN
1797 WSH_DEBUG_SV.log(l_module_name,'p-dd-rec-index i',i);
1798 WSH_DEBUG_SV.log(l_module_name,'p_dd_rec.po_line_location_id_tab(i)',p_dd_rec.po_line_location_id_tab(i));
1799 WSH_DEBUG_SV.log(l_module_name,'p_dd_rec.shipment_line_id_tab(i)',p_dd_rec.shipment_line_id_tab(i));
1800 WSH_DEBUG_SV.log(l_module_name,'p_dd_rec.process_asn_rcv_flag_tab(i)',p_dd_rec.process_asn_rcv_flag_tab(i));
1801 WSH_DEBUG_SV.log(l_module_name,'p_dd_rec.child_index_tab(i)',p_dd_rec.child_index_tab(i));
1802 WSH_DEBUG_SV.log(l_module_name,'p_dd_rec.del_detail_id_tab(i)',p_dd_rec.del_detail_id_tab(i));
1806 END IF;
1803 WSH_DEBUG_SV.log(l_module_name,'p_dd_rec.delivery_id_tab(i)',p_dd_rec.delivery_id_tab(i));
1804 WSH_DEBUG_SV.log(l_module_name,'p_dd_rec.trip_id_tab(i)',p_dd_rec.trip_id_tab(i));
1805 WSH_DEBUG_SV.log(l_module_name,'p_dd_rec.ship_from_location_id_tab(i)',p_dd_rec.ship_from_location_id_tab(i));
1807 --
1808
1809 l_cache_return_status := wsh_util_core.g_ret_sts_success;
1810
1811 IF l_populate_p_line_rec = 'Y' THEN
1812 --{
1813 IF l_debug_on THEN
1814 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_CACHED_VALUE-p_loc_id_index_cache',WSH_DEBUG_SV.C_PROC_LEVEL);
1815 END IF;
1816 --
1817 IF (p_dd_rec.process_asn_rcv_flag_tab(i) ='Y')
1818 THEN
1819 --{
1820 wsh_util_core.get_cached_value(
1821 p_cache_tbl => p_loc_id_index_cache,
1822 p_cache_ext_tbl => p_loc_id_index_ext_cache,
1823 p_value => l_value,
1824 p_key => NVL(p_dd_rec.shipment_line_id_tab(i),-99999),
1825 p_action => 'GET',
1826 x_return_status => l_cache_return_status);
1827
1828 IF l_debug_on THEN
1829 WSH_DEBUG_SV.log(l_module_name,'pointer to p_line_rec',l_value);
1830 END IF;
1831 --
1832 IF l_cache_return_status = WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
1833 --{
1834 -- rcv_shipment_line_id is present in the cache table.
1835 p_dd_rec.shpmt_line_id_idx_tab(i) := l_value;
1836 ELSIF l_cache_return_status = WSH_UTIL_CORE.G_RET_STS_WARNING THEN
1837 -- Need to derive the po information by calling WSH_INBOUND_UTIL_PKG.get_po_rcv_attributes()
1838 --
1839 -- Debug Statements
1840 --
1841 IF l_debug_on THEN
1842 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INBOUND_UTIL_PKG.GET_PO_RCV_ATTRIBUTES',WSH_DEBUG_SV.C_PROC_LEVEL);
1843 END IF;
1844 --
1845 WSH_INBOUND_UTIL_PKG.get_po_rcv_attributes(
1846 p_po_line_location_id => p_dd_rec.po_line_location_id_tab(i),
1847 p_rcv_shipment_line_id => p_dd_rec.shipment_line_id_tab(i),
1848 x_line_rec => p_line_rec,
1849 x_return_status => l_return_status);
1850 --
1851 -- Debug Statements
1852 --
1853 IF l_debug_on THEN
1854 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
1855 END IF;
1856 --
1857 wsh_util_core.api_post_call(
1858 p_return_status => l_return_status,
1859 x_num_warnings => l_num_warnings,
1860 x_num_errors => l_num_errors);
1861
1862 l_pline_rec_count := p_line_rec.header_id.COUNT;
1863 IF l_debug_on THEN
1864 WSH_DEBUG_SV.log(l_module_name,'pointer to p_line_rec',l_pline_rec_count);
1865 END IF;
1866 --
1867 p_dd_rec.shpmt_line_id_idx_tab(i) := p_line_rec.header_id.COUNT;
1868
1869 --
1870 IF p_dd_rec.shipment_line_id_tab(i) IS NOT NULL
1871 THEN
1872 -- populate the shipment_line_id to p_dd_rec structure.
1873 --{
1874 IF l_debug_on THEN
1875 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_CACHED_VALUE-p_loc_id_index_cache',WSH_DEBUG_SV.C_PROC_LEVEL);
1876 END IF;
1877 --
1878 wsh_util_core.get_cached_value(
1879 p_cache_tbl => p_loc_id_index_cache,
1880 p_cache_ext_tbl => p_loc_id_index_ext_cache,
1881 p_value => l_pline_rec_count,
1882 p_key => p_dd_rec.shipment_line_id_tab(i),
1883 p_action => 'PUT',
1884 x_return_status => l_cache_return_status);
1885 IF l_cache_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
1886 raise FND_API.G_EXC_ERROR;
1887 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR -- Added by NPARIKH
1888 THEN
1889 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1890 END IF;
1891 --}
1892 END IF;
1893
1894 ElSIF l_cache_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
1895 raise FND_API.G_EXC_ERROR;
1896 ELSIF l_cache_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
1897 raise FND_API.G_EXC_UNEXPECTED_ERROR;
1898 END IF;
1899
1900 --}
1901
1902 --}
1903 END IF;
1904
1905
1906
1907 END IF;--End if of l_populate_p_line_rec
1908
1909 --moved this code from the above if -- end if so that requested quantity uom
1910 -- populated in p_line_rec even when matching algorithm calls process_matched_txns
1911
1912 IF (p_dd_rec.process_asn_rcv_flag_tab(i) ='Y')
1913 THEN
1914 --{
1915 p_line_rec.requested_quantity_uom(p_dd_rec.shpmt_line_id_idx_tab(i)) :=
1916 p_dd_rec.requested_qty_uom_tab(i);
1917
1918 p_line_rec.requested_quantity_uom2(p_dd_rec.shpmt_line_id_idx_tab(i)) :=
1919
1920 p_dd_rec.requested_qty_uom2_tab(i);
1921
1925 END IF;
1922 IF l_debug_on THEN
1923 WSH_DEBUG_SV.log(l_module_name,'p_dd_rec.requested_quantity_uom ---', p_dd_rec.requested_qty_uom_tab(i));
1924 --}
1926 END IF;
1927
1928 END LOOP;-- End loop of p_dd_rec.(By this time the enitre p_line_rec is populated with the values )
1929
1930
1931
1932 FOR i IN 1..p_dd_rec.del_detail_id_tab.COUNT
1933 LOOP
1934 l_child_rtv_qty_to_consolidate := 0;
1935 l_child_remaining_qty := 0;
1936 l_remaining_qty := 0;
1937 l_remaining_qty1 := 0;
1938 l_pending_qty := 0;
1939
1940 IF l_debug_on THEN
1941 WSH_DEBUG_SV.log(l_module_name,'processing index i in p_dd_rec ---', i);
1942 WSH_DEBUG_SV.log(l_module_name,'p_dd_rec.process_asn_rcv_flag_tab(i)', p_dd_rec.process_asn_rcv_flag_tab(i));
1943 WSH_DEBUG_SV.log(l_module_name,'p_dd_rec.child_index_tab(i)', p_dd_rec.child_index_tab(i));
1944 WSH_DEBUG_SV.log(l_module_name,'p_dd_rec.del_detail_id_tab(i)', p_dd_rec.del_detail_id_tab(i));
1945 END IF;
1946
1947 -- Process_matched_txn api will process only those records for which
1948 -- the process_asn_rcv_flag is set to'Y'.
1949 -- After processing each record, the flag is set to 'X'.
1950
1951 IF (p_dd_rec.process_asn_rcv_flag_tab(i) ='Y') THEN
1952 --{
1953
1954 --{ -- NNP-WV
1955 l_line_rec.gross_weight := NULL;
1956 l_line_rec.net_weight := NULL;
1957 l_line_rec.volume := NULL;
1958 l_line_rec.wv_frozen_flag := NULL;
1959 l_line_rec.delivery_id := NULL;
1960 l_line_rec.parent_delivery_detail_id := NULL;
1961 l_line_rec.dlvy_wv_frozen_flag := NULL;
1962 l_line_rec.lpn_wv_frozen_flag := NULL;
1963 l_line_rec.wv_qty := NULL;
1964 l_line_rec.requested_quantity := NULL;
1965 --
1966 l_old_dd_gross_weight := NULL;
1967 l_old_dd_net_weight := NULL;
1968 l_old_dd_volume := NULL;
1969 --
1970 l_diff_dd_gross_weight := 0;
1971 l_diff_dd_net_weight := 0;
1972 l_diff_dd_volume := 0;
1973 --}
1974
1975 --{ --NNP-WV
1976 IF p_dd_rec.del_detail_id_tab(i) IS NOT NULL
1977 --AND p_dd_rec.delivery_id_tab(i) IS NOT NULL
1978 THEN
1979 --{
1980 OPEN line_csr (p_dd_rec.del_detail_id_tab(i));
1981 FETCH line_csr INTO l_line_rec;
1982 --
1983 -- Need to add error handling for NoDataFound----this should not happen.
1984 --
1985 CLOSE line_csr;
1986 --
1987 --
1988 --
1989 IF l_debug_on THEN
1990 WSH_DEBUG_SV.logmsg(l_module_name, 'l_line_rec:l_net_wt '||l_line_rec.net_weight||' l_gross_wt '||l_line_rec.gross_weight||' l_vol '||l_line_rec.volume);
1991 WSH_DEBUG_SV.logmsg(l_module_name, 'l_line_rec:dlvy_id '||l_line_rec.delivery_id||' parent_wdd_id '||l_line_rec.parent_delivery_detail_id);
1992 WSH_DEBUG_SV.logmsg(l_module_name, 'l_line_rec:wv_qty '||l_line_rec.wv_qty || ' req qty ' || l_line_rec.requested_quantity);
1993 WSH_DEBUG_SV.logmsg(l_module_name, 'wv_frozen_flag:line '||l_line_rec.wv_frozen_flag||' dlvy '||l_line_rec.dlvy_wv_frozen_flag || ' lpn ' || l_line_rec.lpn_wv_frozen_flag);
1994 END IF;
1995 --
1996 --
1997 IF l_line_rec.wv_frozen_flag = 'Y'
1998 THEN
1999 --{
2000 l_org_wv_qty := l_line_rec.wv_qty;
2001 /*NVL
2002 (
2003 p_dd_rec.shipped_qty_db_tab(i),
2004 NVL
2005 (
2006 p_dd_rec.picked_qty_db_tab(i),
2007 p_dd_rec.requested_qty_db_tab(i)
2008 )
2009 );
2010 */
2011 --
2012 --
2013 IF l_org_wv_qty <> 0
2014 THEN
2015 l_gross_wt_pc := l_line_rec.gross_weight / l_org_wv_qty;
2016 l_net_wt_pc := l_line_rec.net_weight / l_org_wv_qty;
2017 l_vol_pc := l_line_rec.volume / l_org_wv_qty;
2018 ELSE
2019 l_gross_wt_pc := 0;
2020 l_net_wt_pc := 0;
2021 l_vol_pc := 0;
2022 END IF;
2023 --
2024 --
2025 IF l_debug_on THEN
2026 WSH_DEBUG_SV.logmsg(l_module_name, 'Frozen Y l_net_wt_pc '||l_net_wt_pc||' l_gross_wt_pc '||l_gross_wt_pc||' l_vol_pc '||l_vol_pc);
2027 END IF;
2028 --
2032 p_dd_rec.received_qty_tab(i),
2029 --
2030 l_old_wv_qty := NVL
2031 (
2033 NVL
2034 (
2035 p_dd_rec.shipped_qty_tab(i),
2036 NVL
2037 (
2038 p_dd_rec.picked_qty_tab(i),
2039 p_dd_rec.requested_qty_tab(i)
2040 )
2041 )
2042 );
2043 --
2044 IF l_old_wv_qty < l_org_wv_qty
2045 AND (
2046 p_dd_rec.child_index_tab(i) IS NOT NULL
2047 OR l_line_rec.requested_quantity > l_old_wv_qty
2048 )
2049 THEN
2050 l_old_dd_gross_weight := ROUND( l_old_wv_qty * l_gross_wt_pc ,5);
2051 l_old_dd_net_weight := ROUND( l_old_wv_qty * l_net_wt_pc ,5);
2052 l_old_dd_volume := ROUND( l_old_wv_qty * l_vol_pc ,5);
2053 --
2054 l_diff_dd_gross_weight := l_line_rec.gross_weight - l_old_dd_gross_weight;
2055 l_diff_dd_net_weight := l_line_rec.net_weight - l_old_dd_net_weight;
2056 l_diff_dd_volume := l_line_rec.volume - l_old_dd_volume;
2057 END IF;
2058 --
2059 --}
2060 ELSE
2061 --{
2062 l_old_dd_gross_weight := NULL;
2063 l_old_dd_net_weight := NULL;
2064 l_old_dd_volume := NULL;
2065 --
2066 l_diff_dd_gross_weight := 0;
2067 l_diff_dd_net_weight := 0;
2068 l_diff_dd_volume := 0;
2069 --}
2070 END IF;
2071 --
2072 --
2073 IF l_debug_on THEN
2074 WSH_DEBUG_SV.logmsg(l_module_name, 'l_old_dd:l_net_wt '||l_old_dd_net_weight||' l_gross_wt '||l_old_dd_gross_weight||' l_vol '||l_old_dd_volume);
2075 WSH_DEBUG_SV.logmsg(l_module_name, 'l_diff_dd-Orig:l_net_wt '||l_diff_dd_net_weight||' l_gross_wt '||l_diff_dd_gross_weight||' l_vol '||l_diff_dd_volume);
2076 END IF;
2077 --}
2078 END IF;
2079 --}
2080
2081 -- In the p_dd_rec structure, we can have records for which child index is populated.
2082 -- This means that certain split has happened in memory and child records are derived
2083 -- out of the current line.
2084 -- First we loop through all the recors for which child index is not null
2085 -- Start from the parent record and process all the child records till the last level is reached.
2086 -- Once the records are processed, then the process_asn_rcv_flag is set to 'X'
2087 -- inorder to avoid selecting the same records later in the loop.
2088 -- After processing the records for which child index is not null, we process those records
2089 -- for which p_dd_rec.child_index is NULL.
2090
2091 IF (p_dd_rec.child_index_tab(i) IS NOT NULL) THEN
2092 --{
2093 IF p_dd_rec.del_detail_id_tab(i) IS NOT NULL THEN
2094 -- bulk update those records whose delivery detail id is not null in p_dd_rec.
2095 -- This is done by populating l_update_dd_rec structure which is later used for bulk update.
2096 IF l_debug_on THEN
2097 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit populate_update_dd_rec',WSH_DEBUG_SV.C_PROC_LEVEL);
2098 END IF;
2099 --{
2100 populate_update_dd_rec(
2101 p_dd_rec => p_dd_rec,
2102 p_index => i,
2103 p_line_rec => p_line_rec,
2104 p_gross_weight => l_old_dd_gross_weight,
2105 p_net_weight => l_old_dd_net_weight,
2106 p_volume => l_old_dd_volume,
2107 x_release_status => l_release_status,
2108 l_update_dd_rec => l_update_dd_rec,
2109 x_lpnIdCacheTbl => l_lpnIdCacheTbl,
2110 x_lpnIdCacheExtTbl => l_lpnIdCacheExtTbl,
2111 x_return_status => l_return_status);
2112
2113
2114 --
2115 -- Debug Statements
2116 --
2117 IF l_debug_on THEN
2118 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
2119 END IF;
2120 --
2121 wsh_util_core.api_post_call(
2122 p_return_status => l_return_status,
2123 x_num_warnings => l_num_warnings,
2124 x_num_errors => l_num_errors);
2125
2126
2127 ELSE
2128 -- p_dd_rec.delivery_detail_id is null.Need to insert record into wsh_delivery_details.
2129 -- This is done by first populating addtional line information using
2130 -- WSH_PO_CMG_PVT.populate_additional_line_info API and then calling
2131 -- WSH_BULK_PROCESS_PVT.bulk_insert_details API to do the insert operation.
2132 --
2133 -- Debug Statements
2134 --
2135 IF l_debug_on THEN
2139 -- calling WSH_PO_CMG_PVT.populate_additional_line_info
2136 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_PO_CMG_PVT.POPULATE_ADDITIONAL_LINE_INFO',WSH_DEBUG_SV.C_PROC_LEVEL);
2137 END IF;
2138 --
2140 WSH_PO_CMG_PVT.populate_additional_line_info(
2141 p_line_rec => p_line_rec,
2142 p_index => p_dd_rec.shpmt_line_id_idx_tab(i),
2143 p_additional_line_info_rec => l_additional_line_info_rec ,
2144 x_return_status => l_return_status);
2145
2146 --
2147 -- Debug Statements
2148 --
2149 IF l_debug_on THEN
2150 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
2151 END IF;
2152 --
2153 wsh_util_core.api_post_call(
2154 p_return_status => l_return_status,
2155 x_num_warnings => l_num_warnings,
2156 x_num_errors => l_num_errors);
2157
2158 --
2159 -- Debug Statements
2160 --
2161 IF l_debug_on THEN
2162 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_BULK_PROCESS_PVT.BULK_INSERT_DETAILS',WSH_DEBUG_SV.C_PROC_LEVEL);
2163 WSH_DEBUG_SV.log(l_module_name,'P_line_rec.requested_quantity is', P_line_rec.requested_quantity(p_dd_rec.shpmt_line_id_idx_tab(i)));
2164 WSH_DEBUG_SV.log(l_module_name,'P_line_rec.received_quantity is', P_line_rec.received_quantity(p_dd_rec.shpmt_line_id_idx_tab(i)));
2165 WSH_DEBUG_SV.log(l_module_name,'P_line_recs index is ', p_dd_rec.shpmt_line_id_idx_tab(i));
2166 END IF;
2167 --
2168 l_action_prms.org_id := p_line_rec.org_id(p_dd_rec.shpmt_line_id_idx_tab(i));
2169
2170 p_line_rec.requested_quantity_uom(p_dd_rec.shpmt_line_id_idx_tab(i)) :=
2171 p_dd_rec.requested_qty_uom_tab(i);
2172
2173 p_line_rec.requested_quantity_uom2(p_dd_rec.shpmt_line_id_idx_tab(i)) :=
2174 p_dd_rec.requested_qty_uom2_tab(i);
2175
2176 IF l_debug_on THEN
2177 WSH_DEBUG_SV.log(l_module_name,'p_dd_rec.requested_quantity_uom 2nd occurance ', p_dd_rec.requested_qty_uom_tab(i));
2178 END IF;
2179 -- Calling WSH_BULK_PROCESS_PVT.bulk_insert_details
2180 WSH_BULK_PROCESS_PVT.bulk_insert_details(
2181 P_line_rec => P_line_rec,
2182 p_index => p_dd_rec.shpmt_line_id_idx_tab(i),
2183 p_action_prms => l_action_prms,--change by arun
2184 p_additional_line_info_rec => l_additional_line_info_rec,
2185 X_return_status => l_return_status);
2186
2187 --
2188 -- Debug Statements
2189 --
2190 IF l_debug_on THEN
2191 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
2192 END IF;
2193 --
2194 wsh_util_core.api_post_call(
2195 p_return_status => l_return_status,
2196 x_num_warnings => l_num_warnings,
2197 x_num_errors => l_num_errors);
2198
2199 IF p_dd_rec.delivery_id_tab(i) is NOT NULL THEN
2200 --
2201 --
2202 IF l_debug_on THEN
2203 WSH_DEBUG_SV.logmsg(l_module_name,'updating WDA');
2204 WSH_DEBUG_SV.log(l_module_name,'p_line_rec.delivery_detail_id(p_dd_rec.shpmt_line_id_idx_tab(i))',p_line_rec.delivery_detail_id(p_dd_rec.shpmt_line_id_idx_tab(i)));
2205 END IF;
2206
2207 -- Updating wsh_delivery_assignments_v after the insert into wsh_delivery_details.
2208
2209 update wsh_delivery_assignments_v
2210 set delivery_id = p_dd_rec.delivery_id_tab(i),
2211 last_update_date = SYSDATE,
2212 last_updated_by = FND_GLOBAL.USER_ID,
2213 last_update_login = FND_GLOBAL.LOGIN_ID
2214 where delivery_detail_id =
2215 p_line_rec.delivery_detail_id(p_dd_rec.shpmt_line_id_idx_tab(i));
2216 END IF;
2217 --
2218 -- populating p_dd_rec.delivery_detail id with the new delivery_detail id.
2219 -- Also setting the p_line_rec.delivery_detail_id to NULL as the same p_line_rec
2220 -- may used later for another record.
2221
2222 p_dd_rec.del_detail_id_tab(i) := p_line_rec.delivery_detail_id(p_dd_rec.shpmt_line_id_idx_tab(i));
2223 p_line_rec.delivery_detail_id(p_dd_rec.shpmt_line_id_idx_tab(i)):= NULL;
2227 END IF;
2224 p_dd_rec.last_update_date_tab(i) := NULL;
2225 IF l_debug_on THEN
2226 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit populate_update_dd_rec',WSH_DEBUG_SV.C_PROC_LEVEL);
2228 -- Once delivery_detail_id is populated, populate the update_dd_rec which will be used at the end
2229 -- for bulk update.
2230
2231 populate_update_dd_rec(
2232 p_dd_rec => p_dd_rec,
2233 p_index => i,
2234 p_line_rec => p_line_rec,
2235 x_release_status => l_release_status,
2236 l_update_dd_rec => l_update_dd_rec,
2237 x_lpnIdCacheTbl => l_lpnIdCacheTbl,
2238 x_lpnIdCacheExtTbl => l_lpnIdCacheExtTbl,
2239 x_return_status => l_return_status);
2240 --
2241 -- Debug Statements
2242 --
2243 IF l_debug_on THEN
2244 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
2245 END IF;
2246 --
2247 wsh_util_core.api_post_call(
2248 p_return_status => l_return_status,
2249 x_num_warnings => l_num_warnings,
2250 x_num_errors => l_num_errors);
2251
2252 END IF;
2253 --}
2254
2255 k := i;
2256 p_dd_rec.process_asn_rcv_flag_tab(k) := 'X';
2257 --
2258 WHILE p_dd_rec.child_index_tab(k) IS NOT NULL
2259 LOOP
2260
2261 IF l_debug_on THEN
2262 WSH_DEBUG_SV.log(l_module_name,'k',k);
2263 END IF;
2264 --
2265 IF (p_dd_rec.process_asn_rcv_flag_tab(p_dd_rec.child_index_tab(k)) ='Y')
2266 THEN
2267 --{
2268 -- Start with the child record and populate the necessary
2269 -- fields only and create a new delivery detail from the
2270 -- parent delivery detail.
2271
2272 p_dd_info.rcv_shipment_line_id := p_dd_rec.shipment_line_id_tab(p_dd_rec.child_index_tab(k));
2273 --p_dd_info.requested_quantity:= p_dd_rec.shipped_qty_tab(p_dd_rec.child_index_tab(k));
2274 p_dd_info.requested_quantity:= p_dd_rec.requested_qty_tab(p_dd_rec.child_index_tab(k));
2275 p_dd_info.picked_quantity :=FND_API.G_MISS_NUM;
2276 p_dd_info.picked_quantity2 :=FND_API.G_MISS_NUM;
2277 p_dd_info.shipped_quantity:=p_dd_rec.shipped_qty_tab(p_dd_rec.child_index_tab(k));
2278 p_dd_info.returned_quantity:= p_dd_rec.returned_qty_tab(p_dd_rec.child_index_tab(k));
2279 p_dd_info.received_quantity:=p_dd_rec.received_qty_tab(p_dd_rec.child_index_tab(k));
2280 p_dd_info.requested_quantity2:=p_dd_rec.requested_qty2_tab(p_dd_rec.child_index_tab(k));
2281 p_dd_info.shipped_quantity2:=p_dd_rec.shipped_qty2_tab(p_dd_rec.child_index_tab(k));
2282 p_dd_info.returned_quantity2:=p_dd_rec.returned_qty2_tab(p_dd_rec.child_index_tab(k));
2283 p_dd_info.received_quantity2:=p_dd_rec.received_qty2_tab(p_dd_rec.child_index_tab(k));
2284
2285 /* added by NNP */
2286 p_dd_info.tracking_number:=
2287 p_line_rec.tracking_number(p_dd_rec.shpmt_line_id_idx_tab(p_dd_rec.child_index_tab(k)));
2288 p_dd_info.ship_from_location_id:=p_dd_rec.ship_from_location_id_tab(p_dd_rec.child_index_tab(k));
2289
2290 /* added by NNP */
2291
2292
2293 /*
2294 p_dd_info.inventory_item_id:=
2295 nvl(p_line_rec.rcv_inventory_item_id(p_dd_rec.shpmt_line_id_idx_tab(k)),
2296 p_line_rec.inventory_item_id(p_dd_rec.shpmt_line_id_idx_tab(k)) );
2297 p_dd_info.item_description:=
2298 nvl(p_line_rec.rcv_item_description(p_dd_rec.shpmt_line_id_idx_tab(k)),
2299 p_line_rec.item_description(p_dd_rec.shpmt_line_id_idx_tab(k)));
2300 */
2301 /* commented above and replaced with the following
2302 replaced k with p_dd_rec.child_index_tab(k)
2303 -- NNP */
2304 -- Check for substitue item.
2305 -- Receipt can be made against the inventory item that is mentioned in the PO
2306 -- or against the subtitute item.
2307 -- If the item is different at the time of matching the ASN/Receipt, precedence
2308 -- is given to the substitute item that is mentioned in the ASN/Receipt.
2309
2310 p_dd_info.inventory_item_id:=
2311 nvl
2312 (
2313 p_line_rec.rcv_inventory_item_id(p_dd_rec.shpmt_line_id_idx_tab(p_dd_rec.child_index_tab(k))),
2314 p_line_rec.inventory_item_id(p_dd_rec.shpmt_line_id_idx_tab(p_dd_rec.child_index_tab(k)))
2315 );
2316 p_dd_info.item_description:=
2317 nvl
2318 (
2319 p_line_rec.rcv_item_description(p_dd_rec.shpmt_line_id_idx_tab(p_dd_rec.child_index_tab(k))),
2320 p_line_rec.item_description(p_dd_rec.shpmt_line_id_idx_tab(p_dd_rec.child_index_tab(k)))
2321 );
2322
2323 l_child_rtv_qty_to_consolidate := p_dd_rec.returned_qty_tab(p_dd_rec.child_index_tab(k));
2324
2325 IF l_debug_on THEN
2326 WSH_DEBUG_SV.log(l_module_name,'p_dd_info.requested_quantity', p_dd_info.requested_quantity);
2327 WSH_DEBUG_SV.log(l_module_name,'p_dd_info.received_quantity', p_dd_info.received_quantity);
2328 WSH_DEBUG_SV.log(l_module_name,'p_dd_info.rcv_shipment_line_id',p_dd_info.rcv_shipment_line_id);
2332 WSH_DEBUG_SV.log(l_module_name,'p_dd_info.returned_quantity',p_dd_info.returned_quantity);
2329 WSH_DEBUG_SV.log(l_module_name,'p_dd_info.picked_quantity',p_dd_info.picked_quantity);
2330 WSH_DEBUG_SV.log(l_module_name,'p_dd_info.picked_quantity2',p_dd_info.picked_quantity2);
2331 WSH_DEBUG_SV.log(l_module_name,'p_dd_info.shipped_quantity',p_dd_info.shipped_quantity);
2333 WSH_DEBUG_SV.log(l_module_name,'p_dd_info.requested_quantity2',p_dd_info.requested_quantity2);
2334 WSH_DEBUG_SV.log(l_module_name,'p_dd_info.shipped_quantity2',p_dd_info.shipped_quantity2);
2335 WSH_DEBUG_SV.log(l_module_name,'p_dd_info.returned_quantity2',p_dd_info.returned_quantity2);
2336 WSH_DEBUG_SV.log(l_module_name,'p_dd_info.received_quantity2',p_dd_info.received_quantity2);
2337 END IF;
2338 -- set the released status to 'C'-Shipped if transaction type is ASN and
2339 -- shipped qty is not null.
2340 -- set the released status to 'L'-Closed if transaction type is Receipt
2341 -- and received qty is not null.
2342 -- Calculates the remaining qty to see if the case is that of a partial shipment/receipt
2343 -- All the remaining quantities for a particular po_line_location_id
2344 -- will be cosolidated and a single record will be inserted into wsh_delivery_details
2345 -- in case if there are no open delivery_details present for the same.
2346
2347 IF p_dd_rec.transaction_type = 'ASN' THEN
2348 --{
2349 IF p_dd_rec.shipped_qty_tab(p_dd_rec.child_index_tab(k)) IS NULL AND
2350 p_dd_rec.received_qty_tab(p_dd_rec.child_index_tab(k)) IS NULL
2351 THEN
2352 --{
2353 p_dd_info.released_status := 'X';
2354 ELSE
2355 p_dd_info.released_status := 'C';
2356 p_dd_info.requested_quantity:=
2357 least(p_dd_rec.requested_qty_tab(p_dd_rec.child_index_tab(k)),
2358 p_dd_rec.shipped_qty_tab(p_dd_rec.child_index_tab(k)) );
2359 /* added by NNP */
2360 p_dd_info.requested_quantity2:=
2361 least(p_dd_rec.requested_qty2_tab(p_dd_rec.child_index_tab(k)),
2362 p_dd_rec.shipped_qty2_tab(p_dd_rec.child_index_tab(k)) );
2363 /* added by NNP */
2364 END IF;
2365 --}
2366 l_child_remaining_qty :=
2367 p_dd_rec.requested_qty_tab(p_dd_rec.child_index_tab(k))-
2368 nvl(p_dd_rec.shipped_qty_tab(p_dd_rec.child_index_tab(k)),0);
2369 END IF;
2370 --}
2371
2372 IF p_dd_rec.transaction_type = 'RECEIPT' THEN
2373 --{
2374 IF p_dd_rec.shipped_qty_tab(p_dd_rec.child_index_tab(k)) IS NULL AND
2375 p_dd_rec.received_qty_tab(p_dd_rec.child_index_tab(k)) IS NULL
2376 THEN
2377 --{
2378 p_dd_info.released_status := 'X';
2379 ELSE
2380 p_dd_info.released_status := 'L';
2381 p_dd_info.requested_quantity:=
2382 least(p_dd_rec.requested_qty_tab(p_dd_rec.child_index_tab(k)),
2383 p_dd_rec.received_qty_tab(p_dd_rec.child_index_tab(k)) );
2384 /* added by NNP */
2385 p_dd_info.requested_quantity2:=
2386 least(p_dd_rec.requested_qty2_tab(p_dd_rec.child_index_tab(k)),
2387 p_dd_rec.received_qty2_tab(p_dd_rec.child_index_tab(k)) );
2388 /* added by NNP */
2389 END IF;
2390 --}
2391 l_child_remaining_qty :=
2392 p_dd_rec.requested_qty_tab(p_dd_rec.child_index_tab(k))-
2393 nvl(p_dd_rec.received_qty_tab(p_dd_rec.child_index_tab(k)),0);
2394 END IF;
2395 --}
2396
2397 IF l_debug_on THEN
2398 WSH_DEBUG_SV.log(l_module_name,'l_child_remaining_qty',l_child_remaining_qty);
2399 END IF;
2400 --
2401 -- if the remaining qty greater than zero, then the requested qty of the child is
2402 -- set to the corresponding shipped qty.Else it is left untouched.
2403
2404 IF l_child_remaining_qty <= 0 THEN
2405 --{
2406 p_dd_info.requested_quantity := p_dd_rec.requested_qty_tab(p_dd_rec.child_index_tab(k));
2407 ELSIF l_child_remaining_qty > 0 THEN
2408 IF p_dd_rec.transaction_type = 'ASN' THEN
2409 --{
2410 p_dd_info.requested_quantity := p_dd_rec.shipped_qty_tab(p_dd_rec.child_index_Tab(k));
2411 ELSIF p_dd_rec.transaction_type ='RECEIPT' THEN
2412 p_dd_info.requested_quantity := p_dd_rec.received_qty_tab(p_dd_rec.child_index_tab(k));
2413 --}
2414 END IF;
2415 --}
2416 END IF;
2417
2418 IF l_debug_on THEN
2419 WSH_DEBUG_SV.log(l_module_name,'p_dd_info.requested_quantity',p_dd_info.requested_quantity);
2420 END IF;
2421
2422 -- Create New Detail from old Delivery detail having the above attributes
2423 -- being different.
2424 -- The check on released status id done because all the open quantities are getting
2425 -- consolidated at the end.
2426 IF p_dd_info.released_status <> 'X' THEN
2427 --{
2428 --{ --NNP-WV
2429 IF l_line_rec.wv_frozen_flag = 'Y'
2430 THEN
2431 --{
2432 l_new_wv_qty := NVL
2433 (
2434 p_dd_info.received_quantity,
2435 NVL
2436 (
2440 );
2437 p_dd_info.shipped_quantity,
2438 p_dd_info.requested_quantity
2439 )
2441 --
2442 p_dd_info.gross_weight := ROUND( l_new_wv_qty * l_gross_wt_pc ,5);
2443 p_dd_info.net_weight := ROUND( l_new_wv_qty * l_net_wt_pc ,5);
2444 p_dd_info.volume := ROUND( l_new_wv_qty * l_vol_pc ,5);
2445 --
2446 l_diff_dd_gross_weight := l_diff_dd_gross_weight - p_dd_info.gross_weight;
2447 l_diff_dd_net_weight := l_diff_dd_net_weight - p_dd_info.net_weight;
2448 l_diff_dd_volume := l_diff_dd_volume - p_dd_info.volume;
2449 --
2450 --}
2451 ELSE
2452 --{
2453 p_dd_info.gross_weight := 0;
2454 p_dd_info.net_weight := 0;
2455 p_dd_info.volume := 0;
2456 --}
2457 END IF;
2458 --
2459 --
2460 IF l_debug_on THEN
2461 WSH_DEBUG_SV.logmsg(l_module_name, 'p_dd_info:l_net_wt '||p_dd_info.net_weight||' l_gross_wt '||p_dd_info.gross_weight||' l_vol '||p_dd_info.volume);
2462 WSH_DEBUG_SV.logmsg(l_module_name, 'l_diff_dd-Curr:l_net_wt '||l_diff_dd_net_weight||' l_gross_wt '||l_diff_dd_gross_weight||' l_vol '||l_diff_dd_volume);
2463 END IF;
2464 --}
2465
2466 --
2467 -- Debug Statements
2468 --
2469 IF l_debug_on THEN
2470 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DELIVERY_DETAILS_PKG.CREATE_NEW_DETAIL_FROM_OLD',WSH_DEBUG_SV.C_PROC_LEVEL);
2471 END IF;
2472 --
2473 -- Calling WSH_DELIVERY_DETAILS_PKG.CREATE_NEW_DETAIL_FROM_OLD() to create new delivery detail
2474 -- from old.
2475
2476 WSH_DELIVERY_DETAILS_PKG.CREATE_NEW_DETAIL_FROM_OLD(
2477 p_delivery_detail_rec => p_dd_info,
2478 --p_delivery_detail_id => p_dd_rec.del_detail_id_tab(k),
2479 p_delivery_detail_id => p_dd_rec.parent_delivery_detail_id_tab(p_dd_rec.child_index_tab(k)),
2480 x_row_id => x_row_id,
2481 x_delivery_detail_id => x_delivery_detail_id,
2482 x_return_status => l_return_status);
2483
2484 --
2485 -- Debug Statements
2486 --
2487 IF l_debug_on THEN
2488 WSH_DEBUG_SV.log(l_module_name,'x_delivery_detail_id-new split ddid',x_delivery_detail_id);
2489 WSH_DEBUG_SV.log(l_module_name,'requested qty of record inserted is',p_dd_info.requested_quantity);
2490 WSH_DEBUG_SV.log(l_module_name,'received qty of record inserted is',p_dd_info.received_quantity);
2491 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
2492 END IF;
2493 --
2494 wsh_util_core.api_post_call(
2495 p_return_status => l_return_status,
2496 x_num_warnings => l_num_warnings,
2497 x_num_errors => l_num_errors);
2498
2499
2500 l_delivery_detail_id := x_delivery_detail_id;
2501
2502 -- Create delivery assignments for the newly created delivery detail
2503
2504 p_dd_assign_info.delivery_detail_id := l_delivery_detail_id;
2505 p_dd_rec.del_detail_id_tab(p_dd_rec.child_index_tab(k)) := l_delivery_detail_id;
2506
2507 IF p_dd_rec.delivery_id_tab(p_dd_rec.child_index_tab(k)) IS NOT NULL
2508 THEN
2509 --{
2510 p_dd_assign_info.delivery_id := p_dd_rec.delivery_id_tab(p_dd_rec.child_index_tab(k));
2511 ELSE
2512 p_dd_assign_info.delivery_id := NULL;
2513 END IF;
2514 --}
2515 --
2516 -- Debug Statements
2517 --
2518 IF l_debug_on THEN
2519 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DELIVERY_DETAILS_PKG.CREATE_DELIVERY_ASSIGNMENTS',WSH_DEBUG_SV.C_PROC_LEVEL);
2520 END IF;
2521 --
2522 WSH_DELIVERY_DETAILS_PKG.Create_Delivery_Assignments(
2523 p_delivery_assignments_info => p_dd_assign_info,
2524 x_rowid => x_rowid,
2525 x_delivery_assignment_id => x_delivery_assignment_id,
2526 x_return_status => l_return_status);
2527 --
2528 -- Debug Statements
2529 --
2530 IF l_debug_on THEN
2531 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
2532 END IF;
2533 --
2534 wsh_util_core.api_post_call(
2535 p_return_status => l_return_status,
2536 x_num_warnings => l_num_warnings,
2537 x_num_errors => l_num_errors);
2538
2539 END IF; -- End if for released status
2540 --}
2541
2542 -- mark the records both child and parent as Processed so that they are not
2543 -- eligible for reprocessing as we traverse in the loop.
2544
2545 p_dd_rec.process_asn_rcv_flag_tab(k) := 'X';
2549 --Update l_remaining_qty with the remaining qty to be shipped and return
2546 p_dd_rec.process_asn_rcv_flag_tab(p_dd_rec.child_index_tab(k)) := 'X';
2547
2548
2550 --to vendor qty of child.
2551
2552 IF l_child_remaining_qty > 0 THEN
2553 l_remaining_qty := l_remaining_qty + (l_child_remaining_qty + nvl(l_child_rtv_qty_to_consolidate,0));
2554 ELSE
2555 l_remaining_qty := l_remaining_qty + nvl(l_child_rtv_qty_to_consolidate,0);
2556 END IF;
2557
2558 IF l_debug_on THEN
2559 WSH_DEBUG_SV.log(l_module_name,'l_remaining_qty',l_remaining_qty);
2560 WSH_DEBUG_SV.log(l_module_name,'l_child_rtv_qty_to_consolidate',l_child_rtv_qty_to_consolidate);
2561 END IF;
2562
2563 --Reset k to the child index of present record.
2564 --}
2565 END IF;-- end if for asn_rec_flag for child
2566 --
2567 -- This should be outside if, otherwise will result into infinite loop
2568 --
2569 k := p_dd_rec.child_index_tab(k);
2570 END LOOP; --While loop ends here.
2571
2572 IF l_debug_on THEN
2573 WSH_DEBUG_SV.logmsg(l_module_name,'outside child index recvursive loop');
2574 END IF;
2575
2576 --Add Parent rtv quantity to remaining quantity for consolidation.
2577
2578 l_remaining_qty := l_remaining_qty + nvl(p_dd_rec.returned_qty_tab(i),0);
2579
2580 IF l_debug_on THEN
2581 WSH_DEBUG_SV.log(l_module_name,'l_remaining_qty',l_remaining_qty);
2582 WSH_DEBUG_SV.log(l_module_name,'p_dd_rec.returned_qty_tab(i)',p_dd_rec.returned_qty_tab(i));
2583 END IF;
2584
2585 --Check if remaining quantity is greater than zero.
2586
2587 IF nvl(l_remaining_qty,0) > 0 THEN
2588 -- Consolidate all the open quantities agains the same po line location to insert one
2589 -- record at the end into wsh_delivery_details.
2590 --{
2591 IF l_debug_on THEN
2592 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit Consolidate_qty',WSH_DEBUG_SV.C_PROC_LEVEL);
2593 END IF;
2594 consolidate_qty(
2595 p_sli_qty_cache => l_sli_qty_cache,
2596 p_sli_qty_ext_cache => l_sli_qty_ext_cache,
2597 p_remaining_qty => l_remaining_qty,
2598 po_shipment_line_id => p_dd_rec.po_line_location_id_tab(i),
2599 x_return_status => l_return_status);
2600 --
2601 -- Debug Statements
2602 --
2603 IF l_debug_on THEN
2604 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
2605 END IF;
2606 --
2607 wsh_util_core.api_post_call(
2608 p_return_status => l_return_status,
2609 x_num_warnings => l_num_warnings,
2610 x_num_errors => l_num_errors);
2611
2612 END IF;--For remaining qty.
2613 --}
2614
2615 ELSE--child Index.
2616 -- Process p_dd_rec records whose child index is null.
2617 IF p_dd_rec.del_detail_id_tab(i) is not NULL THEN
2618 -- bulk update those records whose delivery detail id is not null in p_dd_rec.
2619 -- This is done by populating l_updae_dd_rec structure which is later used for bulk update.
2620 --{
2621 IF l_debug_on THEN
2622 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit populate_update_dd_rec',WSH_DEBUG_SV.C_PROC_LEVEL);
2623 END IF;
2624 populate_update_dd_rec(
2625 p_dd_rec => p_dd_rec,
2626 p_index => i,
2627 p_line_rec => p_line_rec,
2628 p_gross_weight => l_old_dd_gross_weight,
2629 p_net_weight => l_old_dd_net_weight,
2630 p_volume => l_old_dd_volume,
2631 x_release_status => l_release_status,
2632 l_update_dd_rec => l_update_dd_rec,
2633 x_lpnIdCacheTbl => l_lpnIdCacheTbl,
2634 x_lpnIdCacheExtTbl => l_lpnIdCacheExtTbl,
2635 x_return_status => l_return_status);
2636
2637 --
2638 -- Debug Statements
2639 --
2640 IF l_debug_on THEN
2641 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
2642 END IF;
2643 --
2644 wsh_util_core.api_post_call(
2645 p_return_status => l_return_status,
2646 x_num_warnings => l_num_warnings,
2647 x_num_errors => l_num_errors);
2648
2649 --}
2650 ELSIF p_dd_rec.transaction_type = 'ASN'
2651 AND nvl(p_dd_rec.shipped_qty_tab(i),0) = 0
2652 THEN
2653 --{ --- Added by NPARIKH
2654
2655 IF l_debug_on THEN
2656 WSH_DEBUG_SV.log(l_module_name,'p_dd_rec.shipped_qty_tab(i)', p_dd_rec.shipped_qty_tab(i));
2657 END IF;
2658
2659 --}
2660 ELSIF p_dd_rec.transaction_type = 'RECEIPT'
2661 AND nvl(p_dd_rec.received_qty_tab(i),0) = 0
2662 THEN
2663 --{ --- Added by NPARIKH
2664
2665 IF l_debug_on THEN
2669 --}
2666 WSH_DEBUG_SV.log(l_module_name,'p_dd_rec.received_qty_tab(i)', p_dd_rec.received_qty_tab(i));
2667 END IF;
2668
2670 ELSE
2671 -- delivery_detail_id is null.
2672 -- need to insert record into wdd.
2673 --
2674 -- Debug Statements
2675 --
2676 IF l_debug_on THEN
2677 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_PO_CMG_PVT.POPULATE_ADDITIONAL_LINE_INFO',WSH_DEBUG_SV.C_PROC_LEVEL);
2678 END IF;
2679 --
2680 -- Calling WSH_PO_CMG_PVT.populate_additional_line_info
2681 WSH_PO_CMG_PVT.populate_additional_line_info(
2682 p_line_rec => p_line_rec,
2683 p_index => p_dd_rec.shpmt_line_id_idx_tab(i),
2684 p_additional_line_info_rec => l_additional_line_info_rec ,
2685 x_return_status => l_return_status);
2686
2687 --
2688 -- Debug Statements
2689 --
2690 IF l_debug_on THEN
2691 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
2692 END IF;
2693 --
2694 wsh_util_core.api_post_call(
2695 p_return_status => l_return_status,
2696 x_num_warnings => l_num_warnings,
2697 x_num_errors => l_num_errors);
2698
2699 --
2700 -- Debug Statements
2701 --
2702 IF l_debug_on THEN
2703 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_BULK_PROCESS_PVT.BULK_INSERT_DETAILS - 2 ',WSH_DEBUG_SV.C_PROC_LEVEL);
2704 WSH_DEBUG_SV.log(l_module_name,'P_line_rec.requested_quantity is', P_line_rec.requested_quantity(p_dd_rec.shpmt_line_id_idx_tab(i)));
2705 WSH_DEBUG_SV.log(l_module_name,'P_line_rec.received_quantity is', P_line_rec.received_quantity(p_dd_rec.shpmt_line_id_idx_tab(i)));
2706 WSH_DEBUG_SV.log(l_module_name,'P_line_recs index is ', p_dd_rec.shpmt_line_id_idx_tab(i));
2707 END IF;
2708 --
2709 l_action_prms.org_id := p_line_rec.org_id(p_dd_rec.shpmt_line_id_idx_tab(i));
2710
2711 p_line_rec.requested_quantity_uom(p_dd_rec.shpmt_line_id_idx_tab(i)) :=
2712 p_dd_rec.requested_qty_uom_tab(i);
2713
2714 p_line_rec.requested_quantity_uom2(p_dd_rec.shpmt_line_id_idx_tab(i)) :=
2715 p_dd_rec.requested_qty_uom2_tab(i);
2716 IF l_debug_on THEN
2717 WSH_DEBUG_SV.log(l_module_name,'p_dd_rec.requested_quantity_uom 3rd occurance ', p_dd_rec.requested_qty_uom_tab(i));
2718 END IF;
2719
2720 -- Calling WSH_BULK_PROCESS_PVT.bulk_insert_details
2721
2722 WSH_BULK_PROCESS_PVT.bulk_insert_details (
2723 P_line_rec => P_line_rec,
2724 p_index => p_dd_rec.shpmt_line_id_idx_tab(i),
2725 p_action_prms => l_action_prms,--change by arun
2726 p_additional_line_info_rec => l_additional_line_info_rec,
2727 X_return_status => l_return_status);
2728
2729 --
2730 -- Debug Statements
2731 --
2732 IF l_debug_on THEN
2733 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
2734 END IF;
2735 --
2736 wsh_util_core.api_post_call(
2737 p_return_status => l_return_status,
2738 x_num_warnings => l_num_warnings,
2739 x_num_errors => l_num_errors);
2740
2741 IF p_dd_rec.delivery_id_tab(i) is NOT NULL THEN
2742 --
2743 IF l_debug_on THEN
2744 WSH_DEBUG_SV.logmsg(l_module_name,'updating WDA-#2');
2745 WSH_DEBUG_SV.log(l_module_name,'p_line_rec.delivery_detail_id(p_dd_rec.shpmt_line_id_idx_tab(i))',p_line_rec.delivery_detail_id(p_dd_rec.shpmt_line_id_idx_tab(i)));
2746 END IF;
2747 -- updating delivery assignments
2748
2749 update wsh_delivery_assignments_v
2750 set delivery_id = p_dd_rec.delivery_id_tab(i),
2751 last_update_date = SYSDATE,
2752 last_updated_by = FND_GLOBAL.USER_ID,
2753 last_update_login = FND_GLOBAL.LOGIN_ID
2754 where delivery_detail_id = p_line_rec.delivery_detail_id(p_dd_rec.shpmt_line_id_idx_tab(i));
2755 END IF;
2756 --
2757 p_dd_rec.del_detail_id_tab(i) := p_line_rec.delivery_detail_id(p_dd_rec.shpmt_line_id_idx_tab(i));
2758 p_line_rec.delivery_detail_id(p_dd_rec.shpmt_line_id_idx_tab(i)):= NULL;
2759 p_dd_rec.last_update_date_tab(i) := NULL;
2760
2761 IF l_debug_on THEN
2762 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit populate_update_dd_rec',WSH_DEBUG_SV.C_PROC_LEVEL);
2763 END IF;
2764
2765 -- Once delviery detail is created, populate the l_update_dd_rec to do the bulk_update at the end
2766
2767 populate_update_dd_rec(
2768 p_dd_rec => p_dd_rec,
2769 p_index => i,
2770 p_line_rec => p_line_rec,
2771 x_release_status => l_release_status,
2772 l_update_dd_rec => l_update_dd_rec,
2773 x_lpnIdCacheTbl => l_lpnIdCacheTbl,
2774 x_lpnIdCacheExtTbl => l_lpnIdCacheExtTbl,
2775 x_return_status => l_return_status);
2776
2777 END IF;
2778 --}
2782 WSH_DEBUG_SV.log(l_module_name,'p_dd_rec.requested_qty_tab(i)', p_dd_rec.requested_qty_tab(i));
2779 p_dd_rec.process_asn_rcv_flag_tab(i) := 'X';
2780
2781 IF l_debug_on THEN
2783 WSH_DEBUG_SV.log(l_module_name,'p_dd_rec.received_qty_tab(i)', p_dd_rec.received_qty_tab(i));
2784 END IF;
2785 IF p_dd_rec.transaction_type = 'ASN' THEN
2786 --{
2787 l_pending_qty := (nvl(p_dd_rec.requested_qty_tab(i),0) -
2788 nvl(p_dd_rec.shipped_qty_tab(i),0));
2789 ELSIF p_dd_rec.transaction_type = 'RECEIPT' then
2790 l_pending_qty := (nvl(p_dd_rec.requested_qty_tab(i),0) -
2791 nvl(p_dd_rec.received_qty_tab(i),0));
2792 END IF;
2793 --]
2794
2795 IF l_debug_on THEN
2796 WSH_DEBUG_SV.log(l_module_name,'l_pending_qty',l_pending_qty);
2797 WSH_DEBUG_SV.log(l_module_name,'p_dd_rec.returned_qty_tab(i)',p_dd_rec.returned_qty_tab(i));
2798 END IF;
2799
2800 IF l_pending_qty > 0 THEN
2801 --{
2802 l_remaining_qty1 := nvl(p_dd_rec.returned_qty_tab(i),0) + l_pending_qty;
2803 ELSE
2804 l_remaining_qty1 := nvl(p_dd_rec.returned_qty_tab(i),0);
2805 END IF;
2806 --}
2807 IF l_debug_on THEN
2808 WSH_DEBUG_SV.log(l_module_name,'l_remaining_qty1',l_remaining_qty1);
2809 END IF;
2810 --
2811 IF nvl(l_remaining_qty1,0) > 0 THEN
2812 -- Consolidate all the open quantities of the same po line location.
2813 --{
2814 IF l_debug_on THEN
2815 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit consolidate_qty',WSH_DEBUG_SV.C_PROC_LEVEL);
2816 END IF;
2817 consolidate_qty(
2818 p_sli_qty_cache => l_sli_qty_cache,
2819 p_sli_qty_ext_cache => l_sli_qty_ext_cache,
2820 p_remaining_qty => l_remaining_qty1,
2821 po_shipment_line_id => p_dd_rec.po_line_location_id_tab(i),
2822 x_return_status => l_return_status);
2823
2824 --
2825 -- Debug Statements
2826 --
2827 IF l_debug_on THEN
2828 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
2829 END IF;
2830 --
2831 wsh_util_core.api_post_call(
2832 p_return_status => l_return_status,
2833 x_num_warnings => l_num_warnings,
2834 x_num_errors => l_num_errors);
2835 END IF; --For remaining qty1.
2836 --}
2837 END IF;--Child index
2838 --}
2839
2840 --{ --NNP-WV
2841 --
2842 --
2843 IF l_debug_on THEN
2844 WSH_DEBUG_SV.logmsg(l_module_name, 'l_line_rec:wv_frozen_flag '||l_line_rec.wv_frozen_flag);
2845 WSH_DEBUG_SV.logmsg(l_module_name, 'l_diff_dd-final:l_net_wt '||l_diff_dd_net_weight||' l_gross_wt '||l_diff_dd_gross_weight||' l_vol '||l_diff_dd_volume);
2846 END IF;
2847 --
2848 IF l_line_rec.wv_frozen_flag = 'Y'
2849 THEN
2850 --{
2851 IF l_diff_dd_gross_weight > 0
2852 OR l_diff_dd_net_weight > 0
2853 OR l_diff_dd_volume > 0
2854 THEN
2855 --{
2856 IF l_line_rec.parent_delivery_detail_id IS NOT NULL
2857 THEN
2858 --{
2859 IF l_line_rec.lpn_wv_frozen_flag <> 'Y'
2860 THEN
2861 --{
2862 IF l_debug_on THEN
2863 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_ASN_RECEIPT_PVT.processWeightVolume',WSH_DEBUG_SV.C_PROC_LEVEL);
2864 END IF;
2865 --
2866 WSH_ASN_RECEIPT_PVT.processWeightVolume
2867 (
2868 p_delivery_lpn_id => l_line_rec.parent_delivery_detail_id,
2869 p_diff_gross_weight => l_diff_dd_gross_weight,
2870 p_diff_net_weight => l_diff_dd_net_weight,
2871 p_diff_volume => l_diff_dd_volume,
2872 x_GWTcachetbl => l_lpnGWTcachetbl,
2873 x_GWTcacheExttbl => l_lpnGWTcacheExttbl,
2874 x_NWTcachetbl => l_lpnNWTcachetbl,
2875 x_NWTcacheExttbl => l_lpnNWTcacheExttbl,
2876 x_VOLcachetbl => l_lpnVOLcachetbl,
2877 x_VOLcacheExttbl => l_lpnVOLcacheExttbl,
2878 x_return_status => l_return_status
2879 );
2880 --
2881 IF l_debug_on THEN
2882 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
2883 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
2884 END IF;
2885 --
2886 wsh_util_core.api_post_call
2887 (
2888 p_return_status => l_return_status,
2892 --}
2889 x_num_warnings => l_num_warnings,
2890 x_num_errors => l_num_errors
2891 );
2893 END IF;
2894 --}
2895 ELSIF l_line_rec.delivery_id IS NOT NULL
2896 AND l_line_rec.dlvy_wv_frozen_flag <> 'Y'
2897 THEN
2898 --{
2899 IF l_debug_on THEN
2900 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_ASN_RECEIPT_PVT.processWeightVolume',WSH_DEBUG_SV.C_PROC_LEVEL);
2901 END IF;
2902 --
2903 WSH_ASN_RECEIPT_PVT.processWeightVolume
2904 (
2905 p_delivery_lpn_id => l_line_rec.delivery_id,
2906 p_diff_gross_weight => l_diff_dd_gross_weight,
2907 p_diff_net_weight => l_diff_dd_net_weight,
2908 p_diff_volume => l_diff_dd_volume,
2909 x_GWTcachetbl => l_dlvyGWTcachetbl,
2910 x_GWTcacheExttbl => l_dlvyGWTcacheExttbl,
2911 x_NWTcachetbl => l_dlvyNWTcachetbl,
2912 x_NWTcacheExttbl => l_dlvyNWTcacheExttbl,
2913 x_VOLcachetbl => l_dlvyVOLcachetbl,
2914 x_VOLcacheExttbl => l_dlvyVOLcacheExttbl,
2915 x_return_status => l_return_status
2916 );
2917 --
2918 IF l_debug_on THEN
2919 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
2920 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
2921 END IF;
2922 --
2923 wsh_util_core.api_post_call
2924 (
2925 p_return_status => l_return_status,
2926 x_num_warnings => l_num_warnings,
2927 x_num_errors => l_num_errors
2928 );
2929 --}
2930 END IF;
2931 --}
2932 END IF;
2933 --}
2934 END IF;
2935 --}
2936 END IF;--Process Flag
2937 --}
2938 -- arun's change
2939
2940
2941
2942 IF (p_dd_rec.process_asn_rcv_flag_tab(i) ='X')
2943 AND ( p_dd_rec.del_detail_id_tab(i) IS NOT NULL )
2944 THEN
2945 -- populate the local dd rec structure from p_dd_rec for those records for which
2946 -- the process_asn_rcv_flag is 'X'.
2947
2948 --kk is the index of the local dd_rec
2949 kk := l_local_dd_rec.COUNT + 1;
2950
2951 l_local_dd_rec(kk).del_detail_id := p_dd_rec.del_detail_id_tab(i);
2952 l_local_dd_rec(kk).delivery_id := p_dd_rec.delivery_id_tab(i);
2953 l_local_dd_rec(kk).shipment_line_id := p_dd_rec.shipment_line_id_tab(i);
2954 l_local_dd_rec(kk).shpmt_line_id_idx := p_dd_rec.shpmt_line_id_idx_tab(i);
2955 l_local_dd_rec(kk).transaction_type := p_dd_rec.transaction_type;
2956 l_local_dd_rec(kk).shipment_header_id := p_dd_rec.shipment_header_id;
2957 l_local_dd_rec(kk).bol := p_line_rec.bill_of_lading(l_local_dd_rec(kk).shpmt_line_id_idx);
2958 l_local_dd_rec(kk).lpn_id := p_line_rec.lpn_id(l_local_dd_rec(kk).shpmt_line_id_idx);
2959 l_local_dd_rec(kk).lpn_name := NULL;
2960 l_local_dd_rec(kk).psno := p_line_rec.packing_slip_number(l_local_dd_rec(kk).shpmt_line_id_idx);
2961 l_local_dd_rec(kk).waybill := p_line_rec.tracking_number(l_local_dd_rec(kk).shpmt_line_id_idx);
2962 l_local_dd_rec(kk).trip_id := p_dd_rec.trip_id_tab(i);
2963 l_local_dd_rec(kk).truck_num := p_line_rec.truck_num(l_local_dd_rec(kk).shpmt_line_id_idx);
2964 l_local_dd_rec(kk).rcv_gross_weight := p_line_rec.rcv_gross_weight(l_local_dd_rec(kk).shpmt_line_id_idx);
2965 l_local_dd_rec(kk).rcv_gross_weight_uom_code := p_line_rec.rcv_gross_weight_uom_code(l_local_dd_rec(kk).shpmt_line_id_idx);
2966 l_local_dd_rec(kk).rcv_net_weight := p_line_rec.rcv_net_weight(l_local_dd_rec(kk).shpmt_line_id_idx);
2967 l_local_dd_rec(kk).rcv_net_weight_uom_code := p_line_rec.rcv_net_weight_uom_code(l_local_dd_rec(kk).shpmt_line_id_idx);
2968 l_local_dd_rec(kk).rcv_Tare_weight := p_line_rec.rcv_Tare_weight(l_local_dd_rec(kk).shpmt_line_id_idx);
2969 l_local_dd_rec(kk).rcv_Tare_weight_uom_code := p_line_rec.rcv_Tare_weight_uom_code(l_local_dd_rec(kk).shpmt_line_id_idx);
2970
2971 l_local_dd_rec(kk).schedule_ship_date := p_line_rec.schedule_ship_date(l_local_dd_rec(kk).shpmt_line_id_idx);
2972 l_local_dd_rec(kk).initial_pickup_date := p_line_rec.shipped_date(l_local_dd_rec(kk).shpmt_line_id_idx);
2973 l_local_dd_rec(kk).expected_receipt_date := p_line_rec.expected_receipt_date(l_local_dd_rec(kk).shpmt_line_id_idx);
2977
2974 l_local_dd_rec(kk).rcv_carrier_id := p_line_rec.rcv_carrier_id(l_local_dd_rec(kk).shpmt_line_id_idx);
2975
2976
2978 -- populate the trip_id field based on
2979 -- as trip_id returned if we get the trip id corresponding to the last leg of this delivery
2980 --
2981
2982 IF p_dd_rec.delivery_id_tab(i) IS NOT NULL THEN
2983 OPEN get_delivery_info(p_dd_rec.delivery_id_tab(i));
2984 FETCH get_delivery_info INTO l_trip_id;
2985
2986 IF get_delivery_info%FOUND THEN
2987
2988 l_local_dd_rec(kk).trip_id := l_trip_id;
2989 p_dd_rec.trip_id_tab(i) := l_trip_id;
2990
2991 ELSIF get_delivery_info%NOTFOUND THEN
2992
2993 OPEN c_has_del_leg(p_dd_rec.delivery_id_tab(i));
2994 FETCH c_has_del_leg INTO l_temp_char;
2995
2996 IF c_has_del_leg%FOUND THEN
2997
2998 l_local_dd_rec(kk).trip_id := -1;
2999 p_dd_rec.trip_id_tab(i) := -1;
3000
3001 ELSIF c_has_del_leg%NOTFOUND THEN
3002
3003 l_local_dd_rec(kk).trip_id := NULL;
3004 p_dd_rec.trip_id_tab(i) := NULL;
3005
3006 END IF;
3007
3008 CLOSE c_has_del_leg;
3009 END IF;
3010 CLOSE get_delivery_info;
3011 END IF;
3012
3013
3014
3015 IF l_debug_on THEN
3016 WSH_DEBUG_SV.log(l_module_name,'p_dd_rec.transaction_type ',p_dd_rec.transaction_type);
3017 WSH_DEBUG_SV.log(l_module_name,'$$$$$$$$$$$$ ',l_return_status);
3018 WSH_DEBUG_SV.log(l_module_name,'delivery_id ',l_local_dd_rec(kk).delivery_id);
3019 WSH_DEBUG_SV.log(l_module_name,'del_detail_id',l_local_dd_rec(kk).del_detail_id);
3020 WSH_DEBUG_SV.log(l_module_name,'index ',kk);
3021 WSH_DEBUG_SV.log(l_module_name,'trip_id ',l_local_dd_rec(kk).trip_id);
3022 END IF;
3023
3024 IF p_dd_rec.transaction_type = 'RECEIPT'
3025 THEN
3026 --{
3027 l_parent_wdd_id := NULL;
3028 --
3029 --
3030 FOR packed_rec IN packed_csr(l_local_dd_Rec(kk).del_detail_id)
3031 LOOP
3032 l_parent_wdd_id := packed_rec.parent_Delivery_detail_id;
3033 END LOOP;
3034 --
3035 --
3036 IF l_debug_on THEN
3037 WSH_DEBUG_SV.log(l_module_name,'l_local_dd_rec(kk).del_detail_id ',l_local_dd_rec(kk).del_detail_id);
3038 WSH_DEBUG_SV.log(l_module_name,'l_parent_wdd_id ',l_parent_wdd_id);
3039 END IF;
3040 --
3041 --
3042 IF l_parent_wdd_id IS NOT NULL
3043 THEN
3044 l_local_dd_rec(kk).lpn_id := NULL;
3045 END IF;
3046 --}
3047 END IF;
3048
3049 IF l_debug_on THEN
3050 WSH_DEBUG_SV.log(l_module_name,'l_local_dd_rec(kk).lpn_id ',l_local_dd_rec(kk).lpn_id);
3051 END IF;
3052
3053 IF l_local_dd_rec(kk).lpn_id IS NOT NULL
3054 THEN
3055 --
3056 -- Debug Statements
3057 --
3058 IF l_debug_on THEN
3059 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INBOUND_UTIL_PKG.GET_OUTERMOST_LPN',WSH_DEBUG_SV.C_PROC_LEVEL);
3060 END IF;
3061 --
3062 -- Goods can me packed in multiple containers.
3063 -- So the lpn id that is passed need not necessary be the outermost lpn.
3064 -- So we derive the outermost lpn using the GET_OUTERMOST_LPN API.
3065
3066 WSH_INBOUND_UTIL_PKG.GET_OUTERMOST_LPN(
3067 p_lpn_id => l_local_dd_rec(kk).lpn_id,
3068 p_shipment_header_id => l_local_dd_rec(kk).shipment_header_id,
3069 p_lpn_context => 7,
3070 x_outermost_lpn => l_outermost_lpn,
3071 x_outermost_lpn_name => l_outermost_lpn_name,
3072 x_return_status => l_return_status);
3073 --
3074 -- Debug Statements
3075 --
3076 IF l_debug_on THEN
3077 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
3078 END IF;
3079 --
3080 wsh_util_core.api_post_call(
3081 p_return_status => l_return_status,
3082 x_num_warnings => l_num_warnings,
3083 x_num_errors => l_num_errors);
3084
3085 IF l_outermost_lpn IS NOT NULL THEN
3086 l_local_dd_rec(kk).lpn_id := l_outermost_lpn;
3087 l_local_dd_rec(kk).lpn_name := l_outermost_lpn_name;
3088 END IF;
3089
3090 IF l_debug_on THEN
3091 WSH_DEBUG_SV.log(l_module_name,'l_local_dd_rec(kk).lpn_id ',l_local_dd_rec(kk).lpn_id);
3092 WSH_DEBUG_SV.log(l_module_name,'l_local_dd_rec(kk).lpn_name ',l_local_dd_rec(kk).lpn_name);
3093 END IF;
3094
3095 END IF;
3096
3097
3098 --IF BOL IS NULL THEN THIS IS DONE TO AVOID THE CREATION OF MULTIPLE DELIVERY IDS
3099 --FOR A DELIVERY ID HAVING MORE THAN ONE NULL BOL.
3100
3101
3102 IF l_local_dd_rec(kk).delivery_id IS NULL THEN
3103 -- collecting del det ids . key will be the index and value will be del det id
3104 --
3105 -- Debug Statements
3106 --
3107 IF l_debug_on THEN
3108 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_CACHED_VALUE-l_index_dd_ids_cache',WSH_DEBUG_SV.C_PROC_LEVEL);
3109 END IF;
3110 --
3111 wsh_util_core.get_cached_value(
3112 p_cache_tbl => l_index_dd_ids_cache,
3116 p_action => 'PUT',
3113 p_cache_ext_tbl => l_index_dd_ids_ext_cache,
3114 p_value => l_local_dd_rec(kk).del_detail_id ,
3115 p_key => kk,
3117 x_return_status => l_return_status);
3118 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
3119 raise FND_API.G_EXC_ERROR;
3120 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR -- Added by NPARIKH
3121 THEN
3122 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3123 END IF;
3124
3125 ELSIF l_local_dd_rec(kk).trip_id IS NULL THEN
3126 --COOLECTING ALL THOSE DELIVERY IDS WHICH HAVE NULL TRIP IDS
3127 --FOR CREATING TRIPS AT INITILIZE
3128 --HERE THERE WIL BE TWO CALLS TO GET CACHED VALUE
3129 --THE FIRST ONE IS FOR COLLECTING THE INDEX AND THE DELIVERY IDS
3130 --SO FOR THIS ONE THE P_KEY WILL BE THE INDEX AND THE P_VALUE
3131 --WILL BE THE DELIVERY ID..THIS WILL HAVE DUPLICATE VALUES IN THE
3132 --P_VALUE I.E DUPLICATE DELIVERY IDS..
3133 --THE SECOND GET CACHE VALUE WILL HAVE BOTH THE P_KEY AND P_VALUE
3134 --AS THE DELIVERY ID ITSELF, SINCE ONLY FROM THIS THE DELIVERY IDS
3135 --WILL BE COLLECTED AND SENT TO AUTOCREATE TRIPS AT DELIVERY LEVEL.
3136
3137 --
3138 -- Debug Statements
3139 --
3140 IF l_debug_on THEN
3141 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_CACHED_VALUE-l_index_del_ids_cache',WSH_DEBUG_SV.C_PROC_LEVEL);
3142 END IF;
3143 --
3144 wsh_util_core.get_cached_value(
3145 p_cache_tbl => l_index_del_ids_cache,
3146 p_cache_ext_tbl => l_index_del_ids_ext_cache,
3147 p_value => l_local_dd_rec(kk).delivery_id,
3148 p_key => kk,
3149 p_action => 'PUT',
3150 x_return_status => l_return_status);
3151 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
3152 raise FND_API.G_EXC_ERROR;
3153 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR -- Added by NPARIKH
3154 THEN
3155 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3156 END IF;
3157
3158
3159
3160 --
3161 -- Debug Statements
3162 --
3163 IF l_debug_on THEN
3164 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_CACHED_VALUE-l_del_ids_del_ids_cache',WSH_DEBUG_SV.C_PROC_LEVEL);
3165 END IF;
3166 --
3167 wsh_util_core.get_cached_value(
3168 p_cache_tbl => l_del_ids_del_ids_cache,
3169 p_cache_ext_tbl => l_del_ids_del_ids_ext_cache,
3170 p_value => l_local_dd_rec(kk).delivery_id,
3171 p_key => l_local_dd_rec(kk).delivery_id,
3172 p_action => 'PUT',
3173 x_return_status => l_return_status);
3174 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
3175 raise FND_API.G_EXC_ERROR;
3176 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR -- Added by NPARIKH
3177 THEN
3178 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3179 END IF;
3180 END IF;
3181
3182
3183 IF l_local_dd_rec(kk).delivery_id IS NOT NULL THEN
3184
3185 --start of code for bug # 3179040
3186 --collecting unique delivery ids which are to be passed to unassign_open_det_from_del
3187 --from the Initilize_txns API.
3188 l_uniq_del_ids_tab(l_local_dd_rec(kk).delivery_id) := l_local_dd_rec(kk).delivery_id;
3189 --end of code for bug # 3179040
3190
3191 --
3192 -- Debug Statements
3193 --
3194 IF l_debug_on THEN
3195 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_CACHED_VALUE-l_del_reprice_tbl',WSH_DEBUG_SV.C_PROC_LEVEL);
3196 END IF;
3197 --
3198 wsh_util_core.get_cached_value(
3199 p_cache_tbl => l_del_reprice_tbl,
3200 p_cache_ext_tbl => l_del_reprice_ext_tbl,
3201 p_value => l_local_dd_rec(kk).delivery_id,
3202 p_key => l_local_dd_rec(kk).delivery_id,
3203 p_action => 'PUT',
3204 x_return_status => l_return_status);
3205 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
3206 raise FND_API.G_EXC_ERROR;
3207 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR -- Added by NPARIKH
3208 THEN
3209 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3210 END IF;
3211 END IF;
3212
3213 --
3214 --end of arun's change
3215 END IF;-- end if of process_ans_rcv_flag
3216 END LOOP;--For p_dd_rec
3217
3218 j := 1;
3219 l_ind := l_del_reprice_tbl.FIRST;
3220 WHILE l_ind IS NOT NULL
3221 LOOP
3222 l_del_ids_tab(j) := l_del_reprice_tbl(l_ind).value;
3223 j := j + 1;
3224 l_ind := l_del_reprice_tbl.NEXT(l_ind);
3225 END LOOP;
3226 l_ind := l_del_reprice_ext_tbl.FIRST;
3227 WHILE l_ind IS NOT NULL
3228 LOOP
3229 l_del_ids_tab(j) := l_del_reprice_ext_tbl(l_ind).value;
3230 j := j + 1;
3231 l_ind := l_del_reprice_ext_tbl.NEXT(l_ind);
3232 END LOOP;
3233
3234 -- Once deliveries has been reconfigured, need to reprice the delivery.
3235 -- The unique list of deliveries is collected in l_del_ids_tab structure.
3236 --
3237 -- Debug Statements
3238 --
3239 IF l_debug_on THEN
3240 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DELIVERY_LEGS_ACTIONS.MARK_REPRICE_REQUIRED',WSH_DEBUG_SV.C_PROC_LEVEL);
3241 END IF;
3245 p_entity_ids => l_del_ids_tab,
3242 --
3243 WSH_DELIVERY_LEGS_ACTIONS.Mark_Reprice_Required(
3244 p_entity_type => 'DELIVERY',
3246 p_consolidation_change => 'N',
3247 x_return_status => l_return_status);
3248
3249 --
3250 -- Debug Statements
3251 --
3252 IF l_debug_on THEN
3253 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
3254 END IF;
3255 --
3256 wsh_util_core.api_post_call(
3257 p_return_status => l_return_status,
3258 x_num_warnings => l_num_warnings,
3259 x_num_errors => l_num_errors);
3260
3261
3262
3263 IF l_debug_on THEN
3264 WSH_DEBUG_SV.logmsg(l_module_name,'UPDATING WDD-Main');
3265 WSH_DEBUG_SV.log(l_module_name,'l_update_dd_rec.delivery_detail_id.COUNT',l_update_dd_rec.delivery_detail_id.COUNT);
3266 l_itemp := l_update_dd_rec.delivery_detail_id.first;
3267 while l_itemp is not null
3268 loop
3269 WSH_DEBUG_SV.log(l_module_name,'l_itemp',l_itemp);
3270 WSH_DEBUG_SV.log(l_module_name,'l_update_dd_rec.requested_quantity(l_itemp)',l_update_dd_rec.requested_quantity(l_itemp));
3271 WSH_DEBUG_SV.log(l_module_name,'l_update_dd_rec.received_quantity(l_itemp)',l_update_dd_rec.received_quantity(l_itemp));
3272 WSH_DEBUG_SV.log(l_module_name,'l_update_dd_rec.delivery_detail_id(l_itemp)',l_update_dd_rec.delivery_detail_id(l_itemp));
3273 WSH_DEBUG_SV.log(l_module_name,'l_update_dd_rec.released_status(l_itemp)',l_update_dd_rec.released_status(l_itemp));
3274 WSH_DEBUG_SV.log(l_module_name,'l_update_dd_rec.released_status_db(l_itemp)',l_update_dd_rec.released_status_db(l_itemp));
3275 WSH_DEBUG_SV.log(l_module_name,'l_update_dd_rec.gross_weight(l_itemp)',l_update_dd_rec.gross_weight(l_itemp));
3276 WSH_DEBUG_SV.log(l_module_name,'l_update_dd_rec.net_weight(l_itemp)',l_update_dd_rec.net_weight(l_itemp));
3277 WSH_DEBUG_SV.log(l_module_name,'l_update_dd_rec.volume(l_itemp)',l_update_dd_rec.volume(l_itemp));
3278 WSH_DEBUG_SV.log(l_module_name,'l_update_dd_rec.ship_from_location_id(l_itemp)',l_update_dd_rec.ship_from_location_id(l_itemp));
3279 WSH_DEBUG_SV.log(l_module_name,'l_update_dd_rec.last_update_date(l_itemp)',l_update_dd_rec.last_update_date(l_itemp));
3280 l_itemp := l_update_dd_rec.delivery_detail_id.next(l_itemp);
3281 end loop;
3282 END IF;
3283 --
3284 -- Bulk updating all the delivery_detail records using the l_update_dd_rec which was populated in the
3285 -- main loop above.
3286
3287 FORALL i in 1..l_update_dd_rec.delivery_detail_id.COUNT
3288 update wsh_delivery_details
3289 set requested_quantity = l_update_dd_rec.requested_quantity(i),
3290 shipped_quantity = l_update_dd_rec.shipped_quantity(i),
3291 returned_quantity = l_update_dd_rec.returned_quantity(i),
3292 received_quantity = l_update_dd_rec.received_quantity(i),
3293 requested_quantity2 = l_update_dd_rec.requested_quantity2(i),
3294 shipped_quantity2 = l_update_dd_rec.shipped_quantity2(i),
3295 returned_quantity2 = l_update_dd_rec.returned_quantity2(i),
3296 received_quantity2 = l_update_dd_rec.received_quantity2(i),
3297 released_status = l_update_dd_rec.released_status(i),
3298 rcv_shipment_line_id = l_update_dd_rec.rcv_shipment_line_id(i),
3299 inventory_item_id = l_update_dd_rec.inventory_item_id(i),
3300 ship_from_location_id = NVL(l_update_dd_rec.ship_from_location_id(i),ship_from_location_id),
3301 item_description = l_update_dd_rec.item_description(i),
3302 tracking_number = l_update_dd_rec.waybill_num(i),
3303 gross_weight = NVL(l_update_dd_rec.gross_weight(i), gross_weight),
3304 net_weight = NVL(l_update_dd_rec.net_weight(i), net_weight),
3305 volume = NVL(l_update_dd_rec.volume(i), volume),
3306 earliest_pickup_date = NVL(earliest_pickup_date, l_update_dd_rec.shipped_date(i)),
3307 latest_pickup_date = NVL(latest_pickup_date, l_update_dd_rec.shipped_date(i)),
3308 last_update_date = SYSDATE,
3309 last_updated_by = FND_GLOBAL.USER_ID,
3310 last_update_login = FND_GLOBAL.LOGIN_ID
3311 where delivery_detail_id = l_update_dd_rec.delivery_detail_id(i)
3312 and released_status = l_update_dd_rec.released_status_db(i)
3313 AND last_update_date = NVL(l_update_dd_rec.last_update_date(i), last_update_date)
3314 RETURNING delivery_detail_id BULK COLLECT INTO l_detail_tab;
3315
3316 IF SQL%ROWCOUNT <> l_update_dd_rec.delivery_detail_id.COUNT THEN
3317 IF l_debug_on THEN
3318 WSH_DEBUG_SV.logmsg(l_module_name,'NUMBER OF ROWS UPDATED IS NOT EQUAL TO THE NUMBER OF ROWS THAT HAD TO BE BULK UPDATED');
3319 WSH_DEBUG_SV.log(l_module_name,'SQL%ROWCOUNT',SQL%ROWCOUNT);
3320 WSH_DEBUG_SV.log(l_module_name,'l_update_dd_rec.delivery_detail_id.COUNT',l_update_dd_rec.delivery_detail_id.COUNT);
3321 END IF;
3322
3323 FND_MESSAGE.SET_NAME('WSH','WSH_DELIVERY_LINES_CHANGED');
3324 wsh_util_core.add_message(WSH_UTIL_CORE.G_RET_STS_ERROR,l_module_name);
3325 RAISE FND_API.G_EXC_ERROR;
3326 END IF;
3327 --
3328 -- DBI Project
3329 -- Update of wsh_delivery_details where requested_quantity/released_status
3330 -- are changed, call DBI API after the update.
3331 -- This API will also check for DBI Installed or not
3332 IF l_debug_on THEN
3333 WSH_DEBUG_SV.log(l_module_name,'Calling DBI API. delivery details count l_detail_tab : ',l_detail_tab.count);
3334 END IF;
3335 WSH_INTEGRATION.DBI_Update_Detail_Log
3336 (p_delivery_detail_id_tab => l_detail_tab,
3340 IF l_debug_on THEN
3337 p_dml_type => 'UPDATE',
3338 x_return_status => l_dbi_rs);
3339
3341 WSH_DEBUG_SV.log(l_module_name,'Return Status after DBI Call-',l_dbi_rs);
3342 END IF;
3343 IF l_dbi_rs = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
3344 x_return_status := l_dbi_rs;
3345 -- just pass this return status to caller API
3346 IF l_debug_on THEN
3347 WSH_DEBUG_SV.logmsg(l_module_name,'DBI API Returned Unexpected error '||x_return_status);
3348 WSH_DEBUG_SV.pop(l_module_name);
3349 END IF;
3350 ROLLBACK;
3351 return;
3352 END IF;
3353
3354 -- End of Code for DBI Project
3355 --
3356
3357 IF l_debug_on THEN
3358 WSH_DEBUG_SV.log(l_module_name,'l_sli_qty_cache.COUNT',l_sli_qty_cache.COUNT);
3359 END IF;
3360 --
3361 IF l_sli_qty_cache.COUNT > 0
3362 OR l_sli_qty_ext_cache.COUNT > 0 THEN
3363 -- populate the p_line_rec.consolidate_quantity with the consolidated qty for
3364 -- particular po_line_location_id.
3365 --{
3366 p_line_rec.consolidate_quantity.EXTEND(p_line_rec.po_shipment_line_id.COUNT);
3367
3368 l_index := p_line_rec.po_shipment_line_id.FIRST;
3369 IF l_debug_on THEN
3370 WSH_DEBUG_SV.log(l_module_name,'l_index',l_index);
3371 END IF;
3372 WHILE l_index IS NOT NULL
3373 LOOP
3374 l_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
3375 --
3376 -- Debug Statements
3377 --
3378 IF l_debug_on THEN
3379 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_CACHED_VALUE',WSH_DEBUG_SV.C_PROC_LEVEL);
3380 END IF;
3381 --
3382 wsh_util_core.get_cached_value(
3383 p_cache_tbl => l_sli_qty_cache,
3384 p_cache_ext_tbl => l_sli_qty_ext_cache,
3385 p_value => l_quantity,
3386 p_key => p_line_rec.po_shipment_line_id(l_index),
3387 p_action => 'GET',
3388 x_return_status => l_return_status );
3389
3390 IF l_debug_on THEN
3391 WSH_DEBUG_SV.log(l_module_name,'p_line_rec.po_shipment_line_id(l_index)',p_line_rec.po_shipment_line_id(l_index));
3392 WSH_DEBUG_SV.log(l_module_name,'sli_qty_cache: l_quantity',l_quantity);
3393 END IF;
3394 --
3395 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
3396
3397 IF l_debug_on THEN
3398 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_CACHED_VALUE',WSH_DEBUG_SV.C_PROC_LEVEL);
3399 END IF;
3400 --
3401 wsh_util_core.get_cached_value(
3402 p_cache_tbl => l_sli_sli_cache,
3403 p_cache_ext_tbl => l_sli_sli_ext_cache,
3404 p_value => l_shp_line_id,
3405 p_key => p_line_rec.po_shipment_line_id(l_index),
3406 p_action => 'GET',
3407 x_return_status => l_return_status );
3408
3409 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
3410 p_line_rec.consolidate_quantity(l_index) := 0;
3411
3412 ElSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_WARNING THEN
3413
3414 p_line_rec.consolidate_quantity(l_index) := l_quantity;
3415
3416 IF l_debug_on THEN
3417 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_CACHED_VALUE',WSH_DEBUG_SV.C_PROC_LEVEL);
3418 END IF;
3419 --
3420 wsh_util_core.get_cached_value(
3421 p_cache_tbl => l_sli_sli_cache,
3422 p_cache_ext_tbl => l_sli_sli_ext_cache,
3423 p_value => p_line_rec.po_shipment_line_id(l_index),
3424 p_key => p_line_rec.po_shipment_line_id(l_index),
3425 p_action => 'PUT',
3426 x_return_status => l_return_status );
3427 ElSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
3428 raise FND_API.G_EXC_ERROR;
3429 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
3430 raise FND_API.G_EXC_UNEXPECTED_ERROR;
3431 END IF;
3432 ElSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
3433 raise FND_API.G_EXC_ERROR;
3434 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
3435 raise FND_API.G_EXC_UNEXPECTED_ERROR;
3436 END IF;
3437
3438 OPEN c_src_qty2(p_line_rec.line_id(l_index),p_line_rec.po_shipment_line_id(l_index)); --performance
3439 FETCH c_src_qty2
3440 into l_src_qty2,l_src_qty_uom2,
3441 l_src_qty,l_src_qty_uom;
3442 CLOSE c_src_qty2;
3443
3444 /*
3445 OPEN c_sum_req_qty(p_line_rec.line_id(l_index),p_line_rec.po_shipment_line_id(l_index)); --performance
3446 FETCH c_sum_req_qty into l_sum_req_qty;
3447 CLOSE c_sum_req_qty;
3448
3449
3450 l_ratio := l_src_qty2/l_sum_req_qty;
3451 */
3452
3453 l_ratio := l_src_qty2/l_src_qty;
3454 -- HW OPMCONV - No need to use OPM precision. Use current INV which is 5
3455 p_line_rec.requested_quantity2(l_index)
3456 := ROUND(l_ratio*l_quantity,WSH_UTIL_CORE.C_MAX_DECIMAL_DIGITS_INV); -- RV DEC_QTY
3457 p_line_rec.requested_quantity_uom2(l_index)
3458 := l_src_qty_uom2;
3459
3460 IF l_debug_on THEN
3461 WSH_DEBUG_SV.log(l_module_name,'l_ratio',l_ratio);
3462 WSH_DEBUG_SV.log(l_module_name,'l_src_qty2',l_src_qty2);
3463 WSH_DEBUG_SV.log(l_module_name,'l_sum_req_qty',l_sum_req_qty);
3464 WSH_DEBUG_SV.log(l_module_name,'p_line_rec.requested_quantity2(l_index)',p_line_rec.requested_quantity2(l_index));
3468
3465 WSH_DEBUG_SV.log(l_module_name,'l_src_qty_uom2',l_src_qty_uom2);
3466 END IF;
3467 --
3469 l_index := p_line_rec.po_shipment_line_id.NEXT(l_index);
3470 END LOOP;
3471
3472 --l_action_prms.action_code := p_dd_rec.transaction_type;
3473
3474 END IF;
3475 --}
3476
3477 IF l_debug_on THEN
3478 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_ASN_RECEIPT_PVT.INITIALIZE_TXNS',WSH_DEBUG_SV.C_PROC_LEVEL);
3479 END IF;
3480
3481
3482 Initialize_txns(
3483 p_local_dd_rec => l_local_dd_rec,
3484 p_index_dd_ids_cache => l_index_dd_ids_cache,
3485 p_index_dd_ids_ext_cache => l_index_dd_ids_ext_cache,
3486 p_index_del_ids_cache => l_index_del_ids_cache,
3487 p_index_del_ids_ext_cache => l_index_del_ids_ext_cache,
3488 p_del_ids_del_ids_cache => l_del_ids_del_ids_cache,
3489 p_del_ids_del_ids_ext_cache => l_del_ids_del_ids_ext_cache,
3490 p_uniq_del_ids_tab => l_del_ids_tab, -- changed by NPARIKH, l_uniq_del_ids_tab,
3491 p_action_prms => p_action_prms,
3492 p_shipment_header_id => p_dd_Rec.shipment_header_id,
3493 x_return_status => l_return_status) ;
3494
3495 --
3496 -- Debug Statements
3497 --
3498 IF l_debug_on THEN
3499 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
3500 END IF;
3501 --
3502 wsh_util_core.api_post_call(
3503 p_return_status => l_return_status,
3504 x_num_warnings => l_num_warnings,
3505 x_num_errors => l_num_errors);
3506
3507 IF l_sli_qty_cache.COUNT > 0
3508 OR l_sli_qty_cache.COUNT > 0 THEN
3509 --{
3510 l_action_prms.action_code := p_dd_rec.transaction_type;
3511
3512 -- Call Reapprove_PO API to insert new record into wsh_delivery_details
3513 -- for the consolidated qty.
3514 -- When this API is called with p_line_rec.consolidated_qty duly populated,
3515 -- we set the case as increment in the REAPPROVE_PO API.
3516 -- The Update_quantity API checks if there are any open delivery details record
3517 -- present for the same po_line_location id.If present, it adds the
3518 -- p_line_rec.consolidated_qty to the open delviery_detail.
3519 -- If not, it creates a new records for the consolidated_qty.
3520 --
3521 -- Debug Statements
3522 --
3523 IF l_debug_on THEN
3524 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_PO_CMG_PVT.REAPPROVE_PO',WSH_DEBUG_SV.C_PROC_LEVEL);
3525 END IF;
3526 --
3527 WSH_PO_CMG_PVT.Reapprove_PO(
3528 p_line_rec => p_line_rec,
3529 p_action_prms => l_action_prms,
3530 p_dd_list => p_dd_list,
3531 x_return_status => l_return_status);
3532
3533
3534 --
3535 -- Debug Statements
3536 --
3537 IF l_debug_on THEN
3538 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
3539 END IF;
3540 --
3541 wsh_util_core.api_post_call(
3542 p_return_status => l_return_status,
3543 x_num_warnings => l_num_warnings,
3544 x_num_errors => l_num_errors);
3545
3546 END IF;
3547 --}
3548
3549 IF l_debug_on THEN
3550 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_ASN_RECEIPT_PVT.RECONFIGURE_DEL_TRIPS',WSH_DEBUG_SV.C_PROC_LEVEL);
3551 END IF;
3552
3553
3554 Reconfigure_del_trips(
3555 p_local_dd_rec => l_local_dd_rec,
3556 p_action_prms => p_action_prms,
3557 x_lpnGWTcachetbl => l_lpnGWTcachetbl, --NNP-WV
3558 x_lpnGWTcacheExttbl => l_lpnGWTcacheExttbl,
3559 x_lpnNWTcachetbl => l_lpnNWTcachetbl,
3560 x_lpnNWTcacheExttbl => l_lpnNWTcacheExttbl,
3561 x_lpnVOLcachetbl => l_lpnVOLcachetbl,
3562 x_lpnVOLcacheExttbl => l_lpnVOLcacheExttbl,
3563 x_dlvyGWTcachetbl => l_dlvyGWTcachetbl,
3564 x_dlvyGWTcacheExttbl => l_dlvyGWTcacheExttbl,
3565 x_dlvyNWTcachetbl => l_dlvyNWTcachetbl,
3566 x_dlvyNWTcacheExttbl => l_dlvyNWTcacheExttbl,
3567 x_dlvyVOLcachetbl => l_dlvyVOLcachetbl,
3568 x_dlvyVOLcacheExttbl => l_dlvyVOLcacheExttbl,
3569 p_shipment_header_id => p_dd_Rec.shipment_header_id,
3570 x_return_status => l_return_status);
3571
3572 --
3573 -- Debug Statements
3574 --
3575 IF l_debug_on THEN
3576 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
3577 END IF;
3578 --
3579 wsh_util_core.api_post_call(
3580 p_return_status => l_return_status,
3581 x_num_warnings => l_num_warnings,
3582 x_num_errors => l_num_errors);
3583
3584
3585 /* Commenting this as post_process will be now called in the wsh_ib_ui_recon_grp.match_shipemtns API.
3586
3587 IF p_action_prms.caller not like 'WSH_IB_MATCH%' THEN
3588 --{
3589 IF l_debug_on THEN
3590 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INBOUND_TXN_HISTORY_PKG.post_process',WSH_DEBUG_SV.C_PROC_LEVEL);
3591 END IF;
3592
3593 WSH_INBOUND_TXN_HISTORY_PKG.post_process(
3594 p_shipment_header_id => p_shipment_header_id,
3595 p_max_rcv_txn_id => p_max_txn_id,
3596 p_action_code => 'MATCHED',
3597 p_txn_type => p_dd_rec.transaction_type,
3598 p_object_version_number => l_object_version_number,
3599 x_return_status => l_return_status);
3600
3601 wsh_util_core.api_post_call(
3602 p_return_status => l_return_status,
3606 END IF;
3603 x_num_warnings => l_num_warnings,
3604 x_num_errors => l_num_errors);
3605 --}
3607 */
3608
3609 For h in p_line_rec.header_id.FIRST..p_line_rec.header_id.LAST
3610 LOOP
3611 IF l_debug_on THEN
3612 WSH_DEBUG_SV.log(l_module_name,'p_line_rec.closed_flag(h)',p_line_rec.closed_flag(h));
3613 WSH_DEBUG_SV.log(l_module_name,'p_line_rec.closed_code(h)',p_line_rec.closed_code(h));
3614 WSH_DEBUG_SV.log(l_module_name,'p_line_rec.cancelled_flag(h)',p_line_rec.cancelled_flag(h));
3615 END IF;
3616 --
3617 -- If PO has done a cancel/close operation on a particular record, and due to
3618 -- the fact that the corresponding transaction was in pending status, it could not
3619 -- be updated at that point of time, for such records, once the matching has been done,
3620 -- the recrods need to be updated to the status of the corresponding po record.
3621
3622 /* For cancelled recrods also the closed code is populated as CLOSED.
3623 So instead of populating the cancel rec, the close rec is getting populated
3624 and the open lines are getting closed instead of cancelled.Putting additional
3625 check on the cancelled_flag to avoid this.*/
3626
3627 IF ((p_line_rec.closed_code(h) = 'CLOSED' OR
3628 p_line_rec.closed_code(h) = 'CLOSED FOR RECEIVING' OR
3629 p_line_rec.closed_code(h) = 'FINALLY CLOSED') AND
3630 p_line_rec.cancelled_flag(h) <> 'Y') THEN
3631 --{
3632 x_po_close_rec.header_id.EXTEND;
3633 x_po_close_rec.line_id.EXTEND;
3634 x_po_close_rec.po_shipment_line_id.EXTEND;
3635 x_po_close_rec.source_blanket_reference_id.EXTEND;
3636
3637 x_po_close_rec.header_id(x_po_close_rec.header_id.COUNT)
3638 := p_line_rec.header_id(h);
3639 x_po_close_rec.line_id(x_po_close_rec.header_id.COUNT )
3640 := p_line_rec.line_id(h);
3641 x_po_close_rec.po_shipment_line_id(x_po_close_rec.header_id.COUNT)
3642 := p_line_rec.po_shipment_line_id(h);
3643 x_po_close_rec.source_blanket_reference_id(x_po_close_rec.header_id.COUNT)
3644 := p_line_rec.source_blanket_reference_id(h);
3645 ELSIF p_line_rec.cancelled_flag(h) = 'Y' THEN
3646
3647 x_po_cancel_rec.header_id.EXTEND;
3648 x_po_cancel_rec.line_id.EXTEND;
3649 x_po_cancel_rec.po_shipment_line_id.EXTEND;
3650 x_po_cancel_rec.source_blanket_reference_id.EXTEND;
3651
3652 x_po_cancel_rec.header_id(x_po_cancel_rec.header_id.COUNT)
3653 := p_line_rec.header_id(h);
3654 x_po_cancel_rec.line_id(x_po_cancel_rec.header_id.COUNT )
3655 := p_line_rec.line_id(h);
3656 x_po_cancel_rec.po_shipment_line_id(x_po_cancel_rec.header_id.COUNT )
3657 := p_line_rec.po_shipment_line_id(h);
3658 x_po_cancel_rec.source_blanket_reference_id(x_po_cancel_rec.header_id.COUNT)
3659 := p_line_rec.source_blanket_reference_id(h);
3660 END IF;
3661 --}
3662 END LOOP;
3663
3664
3665 --
3666 -- Debug Statements
3667 --
3668 IF l_debug_on THEN
3669 WSH_DEBUG_SV.pop(l_module_name);
3670 END IF;
3671 --
3672
3673 IF l_num_errors > 0 THEN
3674 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
3675 ELSIF l_num_warnings > 0 THEN
3676 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
3677 END IF;
3678
3679
3680 EXCEPTION
3681 WHEN FND_API.G_EXC_ERROR THEN
3682 ROLLBACK TO Process_Matched_Txns_PVT;
3683 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
3684 WSH_UTIL_CORE.ADD_MESSAGE(x_return_status,l_module_name);
3685
3686 --
3687 -- Debug Statements
3688 --
3689 IF l_debug_on THEN
3690 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
3691 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
3692 END IF;
3693 --
3694 WHEN OTHERS THEN
3695 ROLLBACK TO Process_Matched_Txns_PVT;
3696 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
3697 WSH_UTIL_CORE.DEFAULT_HANDLER('WSH_ASN_RECEIPT_PVT.Process_Matched_Txns',l_module_name);
3698
3699
3700 --
3701 -- Debug Statements
3702 --
3703 IF l_debug_on THEN
3704 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
3705 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
3706 END IF;
3707 --
3708 END Process_Matched_Txns;
3709
3710 /*========================================================================
3711 -- PROCEDURE : Cancel_ASN
3712 -- HISTORY : Created the API.
3713 --========================================================================*/
3714 --Start of comments
3715 -- API name : Cancel_ASN
3716 -- Type : Private
3717 -- Pre-reqs : None.
3718 -- Function : From purchasing side we get the list of ASN_SHIPMENT_HEADER_ID
3719 -- to be cancelled.Get all the delivery details for the
3720 -- ASN_SHIPMENT_HEADER_ID having the RELEASED_STATUS as C.
3721 -- Get the most recent data from the purchasing tables PO_HEADERS,
3722 -- PO_LINES and PO_LINE_LOCATIONS which need to be propagated to
3723 -- the delivery details becoming OPEN after the cancellation of
3724 -- the ASN. Call Update_attributes(by calling Reapprove_PO) by passing the list of delivery
3725 -- details on which the Purchasing attributes need to be propagated.
3726 -- We need to unpack the delivery details getting OPENED from the
3730 -- Parameters :
3727 -- outermost LPN corresponding to the LPN_id and also unassign
3728 -- the container from the delivery.
3729 -- Get the list of deliveries, trips and trip stops for updating the status on the entities
3731 -- IN OUT:
3732 -- p_action_prms IN OUT NOCOPY WSH_GLBL_VAR_STRCT_GRP.dd_action_parameters_rec_type
3733 --IN:
3734 -- p_header_id IN NUMBER,
3735 -- OUT:
3736 -- x_return_status OUT NOCOPY VARCHAR2
3737 --Cache Tables:
3738 -- ----------------------------------------------------------------------
3739 -- | Cache Table Name | Key | Value |
3740 -- ----------------------------------------------------------------------
3741 -- |l_lpnGWTcachetbl | LPN ID | Gross Weight |
3742 -- |l_lpnGWTcacheExttbl | LPN ID | Gross Weight |
3743 -- -----------------------------------------------------------------------
3744 -- |l_lpnNWTcachetbl | LPN ID | Net Weight |
3745 -- |l_lpnNWTcacheExttbl | LPN ID | Net Weight |
3746 -- -----------------------------------------------------------------------
3747 -- |l_lpnVOLcachetbl | LPN ID | Volume |
3748 -- |l_lpnVOLcacheExttbl | LPN ID | Volume |
3749 -- -----------------------------------------------------------------------
3750 -- |l_dlvyGWTcachetbl | Delivery ID | Gross Weight |
3751 -- |l_dlvyGWTcacheExttbl | Delivery ID | Gross Weight |
3752 -- -----------------------------------------------------------------------
3753 -- |l_dlvyNWTcachetbl | Delivery ID | Net Weight |
3754 -- |l_dlvyNWTcacheExttbl | Delivery ID | Net Weight |
3755 -- -----------------------------------------------------------------------
3756 -- |l_dlvyVOLcachetbl | Delivery ID | Volume |
3757 -- |l_dlvyVOLcacheExttbl | Delivery ID | Volume |
3758 -- -----------------------------------------------------------------------
3759 -- Version : 1.0
3760 -- Previous version 1.0
3761 -- Initial version 1.0
3762 -- End of comments
3763
3764 PROCEDURE Cancel_ASN(
3765 p_header_id IN NUMBER,
3766 p_action_prms IN OUT NOCOPY WSH_GLBL_VAR_STRCT_GRP.dd_action_parameters_rec_type,
3767 x_return_status OUT NOCOPY VARCHAR2) IS
3768
3769 /*Cursor c_get_dds(p_header_id NUMBER) IS
3770 SELECT
3771 Wdd.delivery_detail_id,
3772 Wda.parent_delivery_detail_id,
3773 wdd.po_shipment_line_id
3774 FROM
3775 WSH_DELIVERY_DETAILS WDD,
3776 wsh_delivery_assignments_v WDA,
3777 WSH_NEW_DELIVERIES WND
3778 WHERE wdd.delivery_detail_id = wda.delivery_detail_id and
3779 wdd.line_direction not in ('O','IO') and
3780 Wda.delivery_id = wnd.delivery_id and
3781 Wnd.asn_shipment_header_id = p_header_id;*/
3782
3783 -- Cursor to get the delivery_id associated with the asn_shipment_header_id
3784 -- that is passed for cancellation.
3785
3786 Cursor c_get_deliveries(p_header_id NUMBER) IS
3787 SELECT
3788 Delivery_id
3789 FROM
3790 Wsh_new_deliveries
3791 WHERE ASN_SHIPMENT_HEADER_ID = p_header_id;
3792
3793 l_line_rec OE_WSH_BULK_GRP.line_rec_type;
3794 l_max_txn_id NUMBER;
3795 l_dd_list WSH_PO_CMG_PVT.dd_list_type;
3796 l_Stop_ids wsh_util_core.Id_Tab_Type;
3797 l_Trip_ids wsh_util_core.Id_Tab_Type;
3798 l_Delivery_ids wsh_util_core.Id_Tab_Type;
3799 l_sf_locn_id_tbl wsh_util_core.Id_Tab_Type;
3800 l_picked_qty_tbl wsh_util_core.Id_Tab_Type;
3801 l_validate_flag VARCHAR2(1) := 'Y';
3802 l_return_status VARCHAR2(1);
3803 l_dd_list_count NUMBER;
3804
3805 l_num_warnings NUMBER := 0;
3806 l_num_errors NUMBER := 0;
3807 l_object_version_number NUMBER;
3808 --changes made by arun
3809 l_initial_pickup_date_tab wsh_util_core.Date_Tab_Type;
3810 l_expected_receipt_date_tab wsh_util_core.Date_Tab_Type;
3811 l_rcv_carrier_id_tab wsh_util_core.Id_Tab_Type;
3812 l_gross_weight_of_first NUMBER;
3813 l_net_weight_of_first NUMBER;
3814 l_shipment_header_id_tab wsh_util_core.id_Tab_Type;
3815
3816
3817 l_dd_unassigned_tbl wsh_util_core.Id_Tab_Type;
3818 l_wdd_tbl wsh_util_core.Id_Tab_Type;
3819
3820 --changes made by arun
3821 l_action_prms WSH_BULK_TYPES_GRP.action_parameters_rectype;
3822 l_status VARCHAR2(50);
3823 l_txn_type VARCHAR2(50);
3824 l_local_ddrec LOCAL_DD_REC_TABLE_TYPE;
3825
3826 l_unassign_action_prms WSH_GLBL_VAR_STRCT_GRP.dd_action_parameters_rec_type;
3827 --
3828 l_lpnGWTcachetbl WSH_UTIL_CORE.key_value_tab_type;
3829 l_lpnGWTcacheExttbl WSH_UTIL_CORE.key_value_tab_type;
3830 l_lpnNWTcachetbl WSH_UTIL_CORE.key_value_tab_type;
3831 l_lpnNWTcacheExttbl WSH_UTIL_CORE.key_value_tab_type;
3832 l_lpnVOLcachetbl WSH_UTIL_CORE.key_value_tab_type;
3833 l_lpnVOLcacheExttbl WSH_UTIL_CORE.key_value_tab_type;
3834 --
3835 --
3836 l_dlvyGWTcachetbl WSH_UTIL_CORE.key_value_tab_type;
3837 l_dlvyGWTcacheExttbl WSH_UTIL_CORE.key_value_tab_type;
3838 l_dlvyNWTcachetbl WSH_UTIL_CORE.key_value_tab_type;
3839 l_dlvyNWTcacheExttbl WSH_UTIL_CORE.key_value_tab_type;
3843 l_detail_tab WSH_UTIL_CORE.id_tab_type; -- DBI Project
3840 l_dlvyVOLcachetbl WSH_UTIL_CORE.key_value_tab_type;
3841 l_dlvyVOLcacheExttbl WSH_UTIL_CORE.key_value_tab_type;
3842
3844 l_dbi_rs VARCHAR2(1); -- DBI Project
3845
3846 --
3847 l_debug_on BOOLEAN;
3848 --
3849 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'CANCEL_ASN';
3850 --
3851 BEGIN
3852
3853 --
3854 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
3855 --
3856 IF l_debug_on IS NULL
3857 THEN
3858 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
3859 END IF;
3860 --
3861 --
3862 -- Debug Statements
3863 --
3864 IF l_debug_on THEN
3865 WSH_DEBUG_SV.push(l_module_name);
3866 --
3867 WSH_DEBUG_SV.log(l_module_name,'P_HEADER_ID',P_HEADER_ID);
3868 END IF;
3869 --
3870 SAVEPOINT Cancel_ASN_PVT;
3871
3872 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
3873
3874 IF l_debug_on THEN
3875 WSH_DEBUG_SV.logmsg(l_module_name,'updating WDD');
3876 END IF;
3877 --
3878 -- Updating the all the records in wsh_delivery_details
3879 -- corresponding to the shipment_header_id that is being passed
3880 -- for cancellation.
3881
3882 UPDATE WSH_DELIVERY_DETAILS
3883 SET released_status = 'X',
3884 Shipped_quantity = NULL,
3885 received_quantity = NULL,
3886 shipped_quantity2 = NULL,
3887 received_quantity2 = NULL,
3888 rcv_shipment_line_id = NULL,
3889 LAST_UPDATE_DATE = SYSDATE,
3890 LAST_UPDATED_BY = FND_GLOBAL.USER_ID,
3891 LAST_UPDATE_LOGIN = FND_GLOBAL.LOGIN_ID
3892 where delivery_detail_id in (select wdd.delivery_detail_id
3893 from wsh_delivery_details wdd,
3894 wsh_delivery_assignments_v wda,
3895 wsh_new_deliveries wnd
3896 where wdd.delivery_detail_id = wda.delivery_detail_id
3897 and wda.delivery_id = wnd.delivery_id
3898 and wnd.asn_shipment_header_id = p_header_id
3899 and wdd.line_direction not in ('O','IO'))
3900 and released_status = 'C'
3901 returning delivery_detail_id,po_shipment_line_id,ship_from_location_id, picked_quantity
3902 BULK COLLECT INTO l_dd_list.delivery_detail_id,l_dd_list.po_shipment_line_id,l_sf_locn_id_tbl, l_picked_qty_tbl;
3903 -- DBI Project
3904 -- Update of wsh_delivery_details where requested_quantity/released_status
3905 -- are changed, call DBI API after the update.
3906 -- This API will also check for DBI Installed or not
3907 FOR i in 1..l_dd_list.delivery_detail_id.count LOOP
3908 l_detail_tab(i) := l_dd_list.delivery_detail_id(i) ;
3909 END LOOP;
3910 IF l_debug_on THEN
3911 WSH_DEBUG_SV.log(l_module_name,'Calling DBI API. delivery detail l_detail_tab count : ',l_detail_tab.count);
3912 END IF;
3913 WSH_INTEGRATION.DBI_Update_Detail_Log
3914 (p_delivery_detail_id_tab => l_detail_tab,
3915 p_dml_type => 'UPDATE',
3916 x_return_status => l_dbi_rs);
3917 IF l_debug_on THEN
3918 WSH_DEBUG_SV.log(l_module_name,'Return Status after DBI Call-',l_dbi_rs);
3919 END IF;
3920 IF l_dbi_rs = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
3921 x_return_status := l_dbi_rs;
3922 rollback to Cancel_ASN_PVT;
3923 -- just pass this return status to caller API
3924 IF l_debug_on THEN
3925 WSH_DEBUG_SV.logmsg(l_module_name,'DBI API Returned Unexpected error '||x_return_status);
3926 WSH_DEBUG_SV.pop(l_module_name);
3927 END IF;
3928 return;
3929 END IF;
3930 -- End of Code for DBI Project
3931 --
3932
3933 --
3934 -- Debug Statements
3935 --
3936 IF l_debug_on THEN
3937 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_PO_CMG_PVT.REAPPROVE_PO',WSH_DEBUG_SV.C_PROC_LEVEL);
3938 END IF;
3939 --
3940 l_action_prms.action_code := 'CANCEL_ASN';
3941
3942 -- Call Reapprove_PO with action code as 'CANCEL_ASN'.
3943 -- This will inturn call Update_Atributes to update the non quantity attributes.
3944
3945 WSH_PO_CMG_PVT.Reapprove_PO(
3946 p_line_rec => l_line_rec,
3947 p_action_prms => l_action_prms,
3948 p_dd_list => l_dd_list,
3949 x_return_status => l_return_status);
3950
3951 --
3952 -- Debug Statements
3953 --
3954 IF l_debug_on THEN
3955 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
3956 END IF;
3957 --
3958 wsh_util_core.api_post_call(
3959 p_return_status => l_return_status,
3960 x_num_warnings => l_num_warnings,
3961 x_num_errors => l_num_errors);
3962
3963 l_dd_list_count := l_dd_list.delivery_detail_id.COUNT;
3964
3965
3966 For v_get_deliveries IN c_get_deliveries(p_header_id) LOOP
3967 --
3968 -- Debug Statements
3969 --
3970 IF l_debug_on THEN
3971 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_CONTAINER_ACTIONS.UNPACK_INBOUND_DELIVERY',WSH_DEBUG_SV.C_PROC_LEVEL);
3972 WSH_DEBUG_SV.log(l_module_name,'delivery id',v_get_deliveries.delivery_id);
3973 END IF;
3974 --
3975 -- unpack the delivery.
3976
3977 WSH_CONTAINER_ACTIONS.unpack_inbound_delivery(
3981 --
3978 p_delivery_id => v_get_deliveries.delivery_id,
3979 x_return_status => l_return_status);
3980
3982 -- Debug Statements
3983 --
3984 IF l_debug_on THEN
3985 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
3986 END IF;
3987 --
3988 wsh_util_core.api_post_call(
3989 p_return_status => l_return_status,
3990 x_num_warnings => l_num_warnings,
3991 x_num_errors => l_num_errors);
3992
3993 l_Delivery_ids(l_delivery_ids.count + 1) := v_get_deliveries.delivery_id;
3994 END LOOP;
3995
3996 --
3997 FOR i in 1..l_dd_list.delivery_detail_id.count LOOP
3998 IF (l_sf_locn_id_tbl(i) = -1
3999 OR nvl(l_picked_qty_tbl(i),0) = 0
4000 )
4001 THEN
4002 -- Collect the list of delivery detail ids that needs to be unassigned from the delivery.
4003 l_dd_unassigned_tbl(l_dd_unassigned_tbl.count + 1) := l_dd_list.delivery_detail_id(i) ;
4004 l_wdd_tbl(l_wdd_tbl.count + 1) := l_dd_list.delivery_detail_id(i) ;
4005
4006 END IF;
4007
4008 END LOOP;
4009
4010 IF l_dd_unassigned_tbl.COUNT > 0 THEN
4011
4012 IF l_debug_on THEN
4013 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DELIVERY_DETAILS_ACTIONS.UNASSIGN_MULTIPLE_DETAILS',WSH_DEBUG_SV.C_PROC_LEVEL);
4014 END IF;
4015
4016 l_unassign_action_prms := p_action_prms;
4017 --l_unassign_action_prms.caller := wsh_util_core.C_IB_RECEIPT_PREFIX;
4018 l_unassign_action_prms.caller := wsh_util_core.C_IB_ASN_PREFIX;
4019
4020 WSH_DELIVERY_DETAILS_ACTIONS.unassign_multiple_details(
4021 p_rec_of_detail_ids => l_dd_unassigned_tbl,
4022 p_from_delivery => 'Y',
4023 p_from_container => 'N',
4024 x_return_status => l_return_status,
4025 p_validate_flag => 'Y',
4026 p_action_prms => l_unassign_action_prms);
4027
4028 wsh_util_core.api_post_call(
4029 p_return_status => l_return_status,
4030 x_num_warnings => l_num_warnings,
4031 x_num_errors => l_num_errors);
4032
4033 END IF;
4034
4035
4036 --
4037
4038 --Call Update status by passing list of the deliveries, trips and trip stops.
4039 IF l_debug_on THEN
4040 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_ASN_RECEIPT_PVT.UPDATE_STATUS',WSH_DEBUG_SV.C_PROC_LEVEL);
4041 END IF;
4042
4043 update_status(
4044 p_action_prms => p_action_prms,
4045 p_del_ids => l_delivery_ids,
4046 p_trip_ids => l_trip_ids,
4047 p_stop_ids => l_stop_ids,
4048 p_shipment_header_id_tab => l_shipment_header_id_tab,
4049 p_initial_pickup_date_tab => l_initial_pickup_date_tab,
4050 p_expected_receipt_date_tab => l_expected_receipt_date_tab,
4051 p_rcv_carrier_id_tab => l_rcv_carrier_id_tab,
4052 p_local_dd_rec => l_local_ddrec,
4053 x_lpnGWTcachetbl => l_lpnGWTcachetbl, --NNP-WV
4054 x_lpnGWTcacheExttbl => l_lpnGWTcacheExttbl,
4055 x_lpnNWTcachetbl => l_lpnNWTcachetbl,
4056 x_lpnNWTcacheExttbl => l_lpnNWTcacheExttbl,
4057 x_lpnVOLcachetbl => l_lpnVOLcachetbl,
4058 x_lpnVOLcacheExttbl => l_lpnVOLcacheExttbl,
4059 x_dlvyGWTcachetbl => l_dlvyGWTcachetbl,
4060 x_dlvyGWTcacheExttbl => l_dlvyGWTcacheExttbl,
4061 x_dlvyNWTcachetbl => l_dlvyNWTcachetbl,
4062 x_dlvyNWTcacheExttbl => l_dlvyNWTcacheExttbl,
4063 x_dlvyVOLcachetbl => l_dlvyVOLcachetbl,
4064 x_dlvyVOLcacheExttbl => l_dlvyVOLcacheExttbl,
4065 x_return_status => l_return_status);
4066
4067 --
4068 -- Debug Statements
4069 --
4070 IF l_debug_on THEN
4071 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
4072 END IF;
4073 --
4074 wsh_util_core.api_post_call(
4075 p_return_status => l_return_status,
4076 x_num_warnings => l_num_warnings,
4077 x_num_errors => l_num_errors);
4078
4079
4080 -- update the trips by passing delivery_ids.
4081 --
4082 -- Debug Statements
4083 --
4084 IF l_debug_on THEN
4085 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INBOUND_UTIL_PKG.SETTRIPSTOPSTATUS',WSH_DEBUG_SV.C_PROC_LEVEL);
4086 END IF;
4087 --
4088 WSH_INBOUND_UTIL_PKG.setTripStopStatus(
4089 p_transaction_code => 'ASN',
4090 p_action_code => 'CANCEL',
4091 p_delivery_id_tab => l_delivery_ids,
4092 x_return_status => l_return_status);
4093
4094 wsh_util_core.api_post_call(
4095 p_return_status => l_return_status,
4096 x_num_warnings => l_num_warnings,
4097 x_num_errors => l_num_errors);
4098
4099 -- Calling reprice API
4100 WSH_DELIVERY_LEGS_ACTIONS.Mark_Reprice_Required(
4101 p_entity_type => 'DELIVERY',
4102 p_entity_ids => l_delivery_ids,
4103 x_return_status => l_return_status);
4104
4105 wsh_util_core.api_post_call(
4106 p_return_status => l_return_status,
4107 x_num_warnings => l_num_warnings,
4111 THEN
4108 x_num_errors => l_num_errors);
4109
4110 IF l_wdd_tbl.count > 0
4112 -- Calling wt/vol API
4113 --WSH_WV_UTILS.Delivery_Weight_Volume(
4114 --p_del_rows => l_delivery_ids,
4115 /* changed by Nikhil */
4116 WSH_WV_UTILS.detail_weight_volume(
4117 p_detail_rows => l_wdd_tbl,
4118 p_override_flag => 'Y',
4119 p_calc_wv_if_frozen => 'N',
4120 x_return_status => l_return_status);
4121
4122 wsh_util_core.api_post_call(
4123 p_return_status => l_return_status,
4124 x_num_warnings => l_num_warnings,
4125 x_num_errors => l_num_errors);
4126 --
4127 END IF;
4128
4129 WSH_TP_RELEASE.calculate_cont_del_tpdates(
4130 p_entity => 'DLVY',
4131 p_entity_ids => l_delivery_ids,
4132 x_return_status => l_return_status);
4133 --
4134 IF l_debug_on THEN
4135 WSH_DEBUG_SV.log(l_module_name,'Return Status after calling calculate_cont_del_tpdates',l_return_status);
4136 END IF;
4137 --
4138 wsh_util_core.api_post_call(
4139 p_return_status => l_return_status,
4140 x_num_warnings => l_num_warnings,
4141 x_num_errors => l_num_errors);
4142
4143
4144 -- Call WSH_INBOUND_TXN_HISTORY_PKG.post_process() API to update the status in TXN_HISTORY_TABLe.
4145 -- Pass 'CANCELLEd' as the status for cancel_asn and 'MAnual reconciliation reqd for revert_ASN.
4146 -- Commenting out the call as per Nikhil's e-mail udpate.
4147
4148 /* IF p_action_prms.action_code = 'CANCEL_ASN' then
4149 l_status := 'CANCEL';
4150 l_txn_type := 'ASN';
4151 ELSE
4152 --l_status := 'Manual Reconciliation Required';
4153 l_status := 'REVERT';
4154 l_txn_type := 'ASN';
4155 END IF;
4156
4157 --
4158 -- Debug Statements
4159 --
4160 IF l_debug_on THEN
4161 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INBOUND_TXN_HISTORY_PKG.POST_PROCESS',WSH_DEBUG_SV.C_PROC_LEVEL);
4162 END IF;
4163 --
4164 WSH_INBOUND_TXN_HISTORY_PKG.post_process(
4165 p_shipment_header_id => p_header_id,
4166 p_max_rcv_txn_id => l_max_txn_id,
4167 p_action_code => l_status,
4168 p_txn_type => l_txn_type,
4169 p_object_version_number => l_object_version_number,
4170 x_return_status => l_return_status);
4171
4172 --
4173 -- Debug Statements
4174 --
4175 IF l_debug_on THEN
4176 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
4177 END IF;
4178 --
4179 wsh_util_core.api_post_call(
4180 p_return_status => l_return_status,
4181 x_num_warnings => l_num_warnings,
4182 x_num_errors => l_num_errors);
4183 */
4184 --
4185 -- Debug Statements
4186 --
4187 IF l_debug_on THEN
4188 WSH_DEBUG_SV.pop(l_module_name);
4189 END IF;
4190 --
4191 IF l_num_errors > 0 THEN
4192 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
4193 ELSIF l_num_warnings > 0 THEN
4194 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
4195 END IF;
4196
4197
4198 EXCEPTION
4199 WHEN FND_API.G_EXC_ERROR THEN
4200 ROLLBACK TO Cancel_ASN_PVT;
4201 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
4202 WSH_UTIL_CORE.ADD_MESSAGE(x_return_status,l_module_name);
4203
4204 --
4205 -- Debug Statements
4206 --
4207 IF l_debug_on THEN
4208 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
4209 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
4210 END IF;
4211 --
4212 WHEN OTHERS THEN
4213 ROLLBACK TO Cancel_ASN_PVT;
4214 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
4215 WSH_UTIL_CORE.DEFAULT_HANDLER('WSH_ASN_RECEIPT_PVT.Cancel_ASN');
4216
4217 --
4218 -- Debug Statements
4219 --
4220 IF l_debug_on THEN
4221 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
4222 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
4223 END IF;
4224 --
4225 END Cancel_ASN;
4226
4227
4228 -- Start of comments
4229 -- API name : unassign_open_det_from_del
4230 -- Type : Public
4231 -- Pre-reqs : None.
4232 -- Function : This API finds the open delivery detail lines for the given input
4233 -- deliveries (i/p parameter p_del_ids) and unassigns them from their
4234 -- respective deliveries.
4235 -- Parameters :
4236 -- IN:
4237 -- p_del_ids IN wsh_util_core.id_tab_type
4238 -- A table containing the list of delivery IDs for which the action
4239 -- should be carried out.
4240 -- p_action_prms IN WSH_GLBL_VAR_STRCT_GRP.dd_action_parameters_rec_type
4241 -- contains the action code ,the caller ,the transaction type etc.
4242 -- IN OUT:
4243 -- OUT:
4244 -- x_return_status OUT NOCOPY VARCHAR2
4245 -- Version : 1.0
4246 -- Previous version 1.0
4247 -- Initial version 1.0
4248 -- End of comments
4249
4250 PROCEDURE unassign_open_det_from_del(
4251 p_del_ids IN wsh_util_core.id_tab_type,
4252 p_action_prms IN WSH_GLBL_VAR_STRCT_GRP.dd_action_parameters_rec_type,
4256 --Cursor to get the open lines for a Delivery ID.
4253 p_shipment_header_id IN NUMBER,
4254 x_return_status OUT NOCOPY VARCHAR2 ) IS
4255
4257 cursor c_get_open_dds(p_del_id NUMBER) IS
4258 SELECT
4259 wdd.delivery_detail_id
4260 FROM
4261 wsh_delivery_details wdd,
4262 wsh_delivery_assignments_v wda
4263 WHERE
4264 wdd.delivery_detail_id = wda.delivery_detail_id AND
4265 wda.delivery_id = p_del_id AND
4266 wdd.released_status = 'X';
4267
4268 --Cursor to get the closed and open lines for a given Delivery ID.
4269 cursor c_get_open_closed_dds(v_del_id NUMBER) IS
4270 SELECT
4271 wdd.delivery_detail_id, nvl(wdd.container_flag,'N') container_flag
4272 FROM
4273 wsh_delivery_details wdd,
4274 wsh_delivery_assignments_v wda
4275 WHERE
4276 wdd.delivery_detail_id = wda.delivery_detail_id AND
4277 wda.delivery_id = v_del_id AND
4278 wdd.released_status in ('X', 'C');
4279
4280
4281 --Cursor to get the shipped lines for a given shipment header id
4282 cursor c_get_shipped_dds(p_shipment_header_id NUMBER) IS
4283 SELECT
4284 wdd.delivery_detail_id, nvl(wdd.container_flag,'N') container_flag
4285 FROM
4286 wsh_delivery_details wdd,
4287 wsh_delivery_assignments_v wda,
4288 wsh_new_deliveries wnd
4289 WHERE
4290 wdd.delivery_detail_id = wda.delivery_detail_id AND
4291 wda.delivery_id = wnd.delivery_id AND
4292 wnd.asn_shipment_header_id = p_shipment_header_id AND
4293 wdd.released_status in ( 'C')
4294 and not exists
4295 (
4296 SELECT 1
4297 FROM wsh_delivery_details wdd1,
4298 wsh_delivery_assignments_v wda1
4299 WHERE wdd1.delivery_detail_id = wda1.delivery_detail_id
4300 AND wda1.delivery_id = wnd.delivery_id
4301 AND wdd1.released_status in ( 'L')
4302 );
4303
4304
4305
4306
4307 lpn_ids_tab WSH_UTIL_CORE.ID_TAB_TYPE;
4308 dd_ids_tab WSH_UTIL_CORE.ID_TAB_TYPE;
4309 l_dd_id NUMBER;
4310 l_delivery_flag VARCHAR2(1) := 'Y';
4311 l_return_status VARCHAR2(1);
4312 l_num_warnings NUMBER := 0;
4313 l_num_errors NUMBER := 0;
4314 i NUMBER;
4315 l_index NUMBER;
4316
4317
4318 l_unassign_action_prms WSH_GLBL_VAR_STRCT_GRP.dd_action_parameters_rec_type;
4319 --
4320 l_debug_on BOOLEAN;
4321 --
4322 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'UNASSIGN_OPEN_DET_FROM_DEL';
4323 --
4324 BEGIN
4325 --
4326 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
4327 --
4328 IF l_debug_on IS NULL
4329 THEN
4330 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
4331 END IF;
4332 --
4333 --
4334 -- Debug Statements
4335 --
4336 IF l_debug_on THEN
4337 WSH_DEBUG_SV.push(l_module_name);
4338 WSH_DEBUG_SV.log(l_module_name,'Caller',p_action_prms.caller);
4339 WSH_DEBUG_SV.log(l_module_name,'Action', p_action_prms.action_code);
4340 WSH_DEBUG_SV.log(l_module_name,'p_del_ids.count',p_del_ids.count);
4341 WSH_DEBUG_SV.log(l_module_name,'p_shipment_header_id',p_shipment_header_id);
4342 END IF;
4343 --
4344 l_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
4345
4346 i := p_del_ids.FIRST;
4347 WHILE i IS NOT NULL
4348 LOOP
4349
4350 --If action code is ASN, then only the lines with status 'X' are collected
4351 --to be unassigned from the delivery.
4352 IF p_action_prms.action_code = 'ASN' THEN
4353 FOR v_get_open_dds IN c_get_open_dds(p_del_ids(i)) LOOP
4354 dd_ids_tab(dd_ids_tab.COUNT+1) := v_get_open_dds.delivery_detail_id;
4355
4356 IF l_debug_on THEN
4357 WSH_DEBUG_SV.log(l_module_name,'DD ID for unassign from dlvy:',v_get_open_dds.delivery_detail_id);
4358 END IF;
4359 --
4360 END LOOP;
4361 END IF;
4362
4363 --If action code is Receipt, then only the lines with status 'X' or 'C' are
4364 --collected to be unassigned from the delivery.
4365 IF p_action_prms.action_code = 'RECEIPT' THEN
4366 FOR v_get_open_closed_dds IN c_get_open_closed_dds(p_del_ids(i)) LOOP
4367
4368 IF l_debug_on THEN
4369 WSH_DEBUG_SV.log(l_module_name,'DD ID for unassign from dlvy:',v_get_open_closed_dds.delivery_detail_id);
4370 WSH_DEBUG_SV.log(l_module_name,'container flag for unassign from dlvy:',v_get_open_closed_dds.container_flag);
4371 END IF;
4372 --
4373 IF v_get_open_closed_dds.container_flag = 'Y'
4374 THEN
4375 --{
4376 lpn_ids_tab(lpn_ids_tab.COUNT+1) := v_get_open_closed_dds.delivery_detail_id;
4377 --}
4378 ELSE
4379 --{
4380 dd_ids_tab(dd_ids_tab.COUNT+1) := v_get_open_closed_dds.delivery_detail_id;
4381 --}
4382 END IF;
4383 END LOOP;
4384 --
4385 --
4386 IF l_debug_on THEN
4387 WSH_DEBUG_SV.logmsg(l_module_name,'Find any other deliveries shipped but not recieved');
4388 END IF;
4389 --
4390 --
4391 FOR v_get_shipped_dds IN c_get_shipped_dds(p_shipment_header_id) LOOP
4392
4393 IF l_debug_on THEN
4394 WSH_DEBUG_SV.log(l_module_name,'DD ID for unassign from dlvy:',v_get_shipped_dds.delivery_detail_id);
4395 WSH_DEBUG_SV.log(l_module_name,'container flag for unassign from dlvy:',v_get_shipped_dds.container_flag);
4396 END IF;
4397 --
4398 IF v_get_shipped_dds.container_flag = 'Y'
4399 THEN
4403 ELSE
4400 --{
4401 lpn_ids_tab(lpn_ids_tab.COUNT+1) := v_get_shipped_dds.delivery_detail_id;
4402 --}
4404 --{
4405 dd_ids_tab(dd_ids_tab.COUNT+1) := v_get_shipped_dds.delivery_detail_id;
4406 --}
4407 END IF;
4408
4409 END LOOP;
4410 END IF;
4411
4412 i := p_del_ids.NEXT(i);
4413 END LOOP;
4414
4415 IF l_debug_on THEN
4416 WSH_DEBUG_SV.log(l_module_name,'lpn_ids_tab.count',lpn_ids_tab.count);
4417 END IF;
4418
4419 -- If true ->There are some LPNs to be unassigned from their respective deliveries.
4420 -- Also the delivery detail IDs for which these are assigned as LPNs(parent delivery detail Id)
4421 -- should be updated.
4422 IF lpn_ids_tab.COUNT > 0
4423 THEN
4424 --{ --Deleting the rows in wsh_delivery_assignments_v corresponding to the selected LPNs.
4425 FORALL i IN lpn_ids_tab.FIRST..lpn_ids_tab.LAST
4426 DELETE wsh_delivery_assignments_v
4427 WHERE delivery_detail_id = lpn_ids_tab(i);
4428
4429 IF l_debug_on THEN
4430 WSH_DEBUG_SV.log(l_module_name,'SQL%ROWCOUNT After delete LPN from WDA',SQL%ROWCOUNT);
4431 END IF;
4432
4433 --Deleting the rows in WSH_DELIVERY_DETAILS corresponding to the selected LPNs.
4434 FORALL i IN lpn_ids_tab.FIRST..lpn_ids_tab.LAST
4435 DELETE WSH_DELIVERY_DETAILS
4436 WHERE delivery_detail_id = lpn_ids_tab(i);
4437
4438 IF l_debug_on THEN
4439 WSH_DEBUG_SV.log(l_module_name,'SQL%ROWCOUNT After delete LPN from WDD',SQL%ROWCOUNT);
4440 END IF;
4441
4442 --updating the rows in WDA for which the selected LPNs are parent Delivery Details.
4443 FORALL i IN lpn_ids_tab.FIRST..lpn_ids_tab.LAST
4444 UPDATE wsh_delivery_assignments_v
4445 SET parent_delivery_detail_id = NULL
4446 WHERE parent_delivery_detail_id = lpn_ids_tab(i);
4447
4448 IF l_debug_on THEN
4449 WSH_DEBUG_SV.log(l_module_name,'SQL%ROWCOUNT After update contents on WDD',SQL%ROWCOUNT);
4450 END IF;
4451 --}
4452 END IF;
4453 --
4454 --
4455 -- Debug Statements
4456 --
4457 IF l_debug_on THEN
4458 WSH_DEBUG_SV.log(l_module_name,'dd_ids_tab.count',dd_ids_tab.count);
4459 END IF;
4460 --
4461
4462 -- If true -> there are delivery details to be unassigned from thier
4463 -- respective deliveries.
4464 IF dd_ids_tab.count > 0 THEN
4465 --{
4466 IF l_debug_on THEN
4467 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DELIVERY_DETAILS
4468 _ACTIONS.UNASSIGN_MULTIPLE_DETAILS',WSH_DEBUG_SV.C_PROC_LEVEL);
4469 END IF;
4470
4471 l_unassign_action_prms := p_action_prms;
4472 --l_unassign_action_prms.caller := wsh_util_core.C_IB_RECEIPT_PREFIX;
4473 l_unassign_action_prms.caller := wsh_util_core.C_IB_ASN_PREFIX;
4474
4475 --Call API WSH_DELIVERY_DETAILS_ACTIONS.Unassign_Multiple_Details.
4476 WSH_DELIVERY_DETAILS_ACTIONS.Unassign_Multiple_Details(
4477 P_REC_OF_DETAIL_IDS => dd_ids_tab,
4478 P_FROM_delivery => 'Y',
4479 P_FROM_container => 'N',
4480 x_return_status => l_return_status,
4481 p_validate_flag => 'Y',
4482 p_action_prms => l_unassign_action_prms);
4483
4484 --
4485 -- Debug Statements
4486 --
4487 IF l_debug_on THEN
4488 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
4489 END IF;
4490 --
4491 wsh_util_core.api_post_call(
4492 p_return_status => l_return_status,
4493 x_num_warnings => l_num_warnings,
4494 x_num_errors => l_num_errors);
4495
4496 /*
4497 i := p_del_ids.FIRST;
4498 WHILE i IS NOT NULL
4499 LOOP
4500 --
4501 -- Debug Statements
4502 --
4503 IF l_debug_on THEN
4504 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_PO_CMG_PVT.LOG_EXCEPTION',WSH_DEBUG_SV.C_PROC_LEVEL);
4505 END IF;
4506 --
4507 WSH_PO_CMG_PVT.Log_Exception(
4508 p_entity_id => p_del_ids(i),
4509 p_logging_entity_name => 'DELIVERY_ID',
4510 p_exception_name => 'WSH_IB_DEL_CHANGE',
4511 x_return_status => l_return_status);
4512
4513 --
4514 -- Debug Statements
4515 --
4516 IF l_debug_on THEN
4517 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
4518 END IF;
4519 --
4520 wsh_util_core.api_post_call(
4521 p_return_status => l_return_status,
4522 x_num_warnings => l_num_warnings,
4523 x_num_errors => l_num_errors);
4524
4525 i := p_del_ids.NEXT(i);
4526
4527 END LOOP;
4528 */
4529
4530 --}
4531 END IF;
4532 x_return_status := l_return_status;
4533 --
4534 -- Debug Statements
4535 --
4536 IF l_debug_on THEN
4537 WSH_DEBUG_SV.pop(l_module_name);
4538 END IF;
4539 --
4540 IF l_num_errors > 0 THEN
4541 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
4542 ELSIF l_num_warnings > 0 THEN
4543 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
4544 END IF;
4545
4546 EXCEPTION
4547 WHEN OTHERS THEN
4548 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
4549 WSH_UTIL_CORE.Default_Handler('WSH_ASN_RECEIPT_PVT.UNASSIGN_OPEN_DET_FROM_DEL');
4550
4551 --
4552 -- Debug Statements
4553 --
4554 IF l_debug_on THEN
4558 --
4555 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
4556 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
4557 END IF;
4559 END unassign_open_det_from_del;
4560
4561
4562
4563 -- Start of comments
4564 -- API name : initialize_txns
4565 -- Type : Public
4566 -- Pre-reqs : None.
4567 -- Function : This API is meant to achieve the following purposes:
4568 --
4569 -- 1.It prepares the dd_rec to have the following information like
4570 -- delivery_id and trip id.
4571 -- 2.Once the structure is prepared, it identifies the unique
4572 -- deliveries within the list and checks if the deliveries consist
4573 -- of any delivery detail not yet shipped. It unassigns all those
4574 -- delivery details.
4575 -- 3.For lines which have a delivery ID but not yet assigned to a
4576 -- Trip, the API WSH_TRIPS_ACTIONS.autocreate_trip_multi to create Trips.
4577 -- 4.It identifies the delivery details having null delivery_ids.
4578 -- Invokes WSH_TRIPS_ACTIONS.AUTOCREATE_DEL_TRIP for the entire list of Delivery details
4579 -- so that all the records in the dd_rec structure become uniform
4580 -- in all respect for further treatment.
4581 -- Parameters :
4582 -- IN:
4583 -- IN OUT:
4584 -- p_local_dd_rec IN OUT NOCOPY LOCAL_DD_REC_TABLE_TYPE
4585 -- p_index_dd_ids_cache IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
4586 -- A key-value pair cache with the value as the delivery detail id and key
4587 -- as the index of the corresponding record in p_local_dd_rec.This contains
4588 -- those delivery detail ids for which both a delivery and a trip has to
4589 -- be created.The index is useful for populating the correct record in
4590 -- p_local_dd_rec, once the delivery and trip are created.
4591 -- p_index_dd_ids_ext_cache IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
4592 -- A key-value pair cache with the value as the delivery detail id and key
4593 -- as the index of the corresponding record in p_local_dd_rec.This contains
4594 -- those delivery detail ids for which both a delivery and a trip has to
4595 -- be created.Records are stored in this cache if the key exceeds 2^31.
4596 -- The index is useful for populating the correct record in p_local_dd_rec,
4597 -- once the delivery and trip are created.
4598 -- p_index_del_ids_cache IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
4599 -- A key-value pair cache with the value as the delivery id and key
4600 -- as the index of the corresponding record in p_local_dd_rec.This contains
4601 -- those delivery ids for which a trip has to be created.
4602 -- The index is useful for populating the correct record in p_local_dd_rec,
4603 -- once the delivery and trip are created.
4604 -- p_index_del_ids_ext_cache IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
4605 -- A key-value pair cache with the value as the delivery id and key
4606 -- as the index of the corresponding record in p_local_dd_rec.This contains
4607 -- those delivery ids for which a trip has to be created.Records are
4608 -- stored in this cache if the key exceeds 2^31.
4609 -- The index is useful for populating the correct record in p_local_dd_rec,
4610 -- once the trip is created.
4611 -- p_del_ids_del_ids_cache IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
4612 -- A key-value pair cache with the value as the delivery id and key
4613 -- as delivery id of the corresponding record in p_local_dd_rec.This contains
4614 -- those delivery ids for which a trip has to be created.This cache is just used
4615 -- for maintaining non-duplicate delivery ids and not used for mapping purpose
4616 -- like the previous cache tables viz..p_index_del_ids_cache and p_index_del_ids_ext_cache.
4617 -- p_del_ids_del_ids_ext_cache IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
4618 -- A key-value pair cache with the value as the delivery id and key
4619 -- as delivery id of the corresponding record in p_local_dd_rec.This contains
4620 -- those delivery ids for which a trip has to be created.This cache is just used
4621 -- for maintaining non-duplicate delivery ids and not used for mapping purpose
4622 -- like the previous cache tables viz..p_index_del_ids_cache and p_index_del_ids_ext_cache.
4623 -- Records are stored in this cache if the key exceeds 2^31.
4624 -- p_uniq_del_ids_tab IN OUT NOCOPY WSH_UTIL_CORE.ID_TAB_TYPE
4625 -- This is a pl/sql table which contains the unique deliveries passed to this API.
4626 -- this table is also updated in this API once the deliveries are created for the
4627 -- delivery detail ids present in the cache tables p_index_dd_ids_cache and
4628 -- p_index_dd_ids_ext_cache.This table is not contiguous.
4629 -- p_action_prms IN OUT NOCOPY WSH_GLBL_VAR_STRCT_GRP.dd_action_parameters_rec_type
4630 -- This contains the caller, type of action to be performed.
4631 -- p_shipment_header_id IN NUMBER
4632 -- RCV Shipment header id
4633 -- OUT:
4634 -- x_return_status OUT NOCOPY VARCHAR2
4635 --Cache Tables
4636 -- ----------------------------------------------------------------------
4637 -- | Cache Table Name | Key | Value |
4638 -- ----------------------------------------------------------------------
4639 -- |p_index_dd_ids_cache | Index | Delivery Detail ID |
4643 -- |p_index_del_ids_ext_cache |Index | Delivery ID |
4640 -- |p_index_dd_ids_ext_cache | Index | Delivery Detail ID |
4641 -- -----------------------------------------------------------------------
4642 -- |p_index_del_ids_cache |Index | Delivery ID |
4644 -- -----------------------------------------------------------------------
4645 -- |p_del_ids_del_ids_cache | Delivery ID | Delivery ID |
4646 -- |p_del_ids_del_ids_ext_cache| Delivery ID | Delivery ID |
4647 -- -----------------------------------------------------------------------
4648 -- Version : 1.0
4649 -- Previous version 1.0
4650 -- Initial version 1.0
4651 -- End of comments
4652
4653
4654
4655
4656
4657 PROCEDURE Initialize_txns(
4658 p_local_dd_rec IN OUT NOCOPY LOCAL_DD_REC_TABLE_TYPE,
4659 p_index_dd_ids_cache IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
4660 p_index_dd_ids_ext_cache IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
4661 p_index_del_ids_cache IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
4662 p_index_del_ids_ext_cache IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
4663 p_del_ids_del_ids_cache IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
4664 p_del_ids_del_ids_ext_cache IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
4665 p_uniq_del_ids_tab IN OUT NOCOPY WSH_UTIL_CORE.ID_TAB_TYPE,
4666 p_action_prms IN OUT NOCOPY WSH_GLBL_VAR_STRCT_GRP.dd_action_parameters_rec_type,
4667 p_shipment_header_id IN NUMBER,
4668 x_return_status OUT NOCOPY VARCHAR2 ) IS
4669
4670
4671 --Cursor to get the Trip ID for a Delivery Detail ID.
4672 cursor c_get_del_id_trip_id (p_del_detail_id NUMBER)
4673 is
4674 select wda.delivery_id,
4675 wt.trip_id
4676 FROM wsh_delivery_assignments_v wda,
4677 wsh_delivery_legs wdl,
4678 wsh_trip_stops wts,
4679 wsh_trips wt
4680 WHERE wda.delivery_detail_id = p_del_detail_id
4681 AND wda.delivery_id = wdl.delivery_id
4682 AND wdl.pick_up_stop_id = wts.stop_id
4683 AND wts.trip_id = wt.trip_id;
4684
4685 --Cursor to get the Trip ID for a Delivery ID.
4686 cursor c_get_trip_id (p_delivery_id NUMBER)
4687 is
4688 select wt.trip_id
4689 FROM wsh_delivery_assignments_v wda,
4690 wsh_delivery_legs wdl,
4691 wsh_trip_stops wts,
4692 wsh_trips wt
4693 WHERE wda.delivery_id = p_delivery_id
4694 AND wda.delivery_id = wdl.delivery_id
4695 AND wdl.pick_up_stop_id = wts.stop_id
4696 AND wts.trip_id = wt.trip_id;
4697
4698
4699
4700 l_new_trip_id_count NUMBER;
4701 l_new_trip_ids wsh_util_core.id_tab_type;
4702 l_del_ids wsh_util_core.id_tab_type;
4703 l_del_id_to_assign wsh_delivery_assignments_v.delivery_id%type;
4704 l_return_status VARCHAR2(1);
4705 l_num_warnings NUMBER := 0;
4706 l_num_errors NUMBER := 0;
4707 l_index NUMBER;
4708 l_del_rows WSH_UTIL_CORE.id_tab_type;
4709 l_trip_rows WSH_UTIL_CORE.id_tab_type;
4710 l_org_rows WSH_UTIL_CORE.id_tab_type;
4711 l_dd_ids_tab WSH_UTIL_CORE.id_tab_type;
4712 l_ind NUMBER;
4713 j NUMBER := 0;
4714
4715 l_trip_ids wsh_util_core.id_tab_type;
4716 l_trip_names wsh_util_core.Column_Tab_Type;
4717 l_carrier_id NUMBER;
4718
4719 --
4720 l_debug_on BOOLEAN;
4721 --
4722 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'INITIALIZE_TXNS';
4723 --
4724 BEGIN
4725 --
4726 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
4727 --
4728 IF l_debug_on IS NULL
4729 THEN
4730 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
4731 END IF;
4732 --
4733 --
4734 -- Debug Statements
4735 --
4736 IF l_debug_on THEN
4737 WSH_DEBUG_SV.push(l_module_name);
4738 WSH_DEBUG_SV.log(l_module_name,'Caller',p_action_prms.caller);
4739 WSH_DEBUG_SV.log(l_module_name,'Action', p_action_prms.action_code);
4740 WSH_DEBUG_SV.log(l_module_name,'p_index_dd_ids_cache.count',p_index_dd_ids_cache.count );
4741 WSH_DEBUG_SV.log(l_module_name,'p_index_dd_ids_ext_cache.count',p_index_dd_ids_ext_cache.count );
4742 WSH_DEBUG_SV.log(l_module_name,'p_index_del_ids_cache.count',p_index_del_ids_cache.count );
4743 WSH_DEBUG_SV.log(l_module_name,'p_index_del_ids_ext_cache.count', p_index_del_ids_ext_cache.count);
4744 WSH_DEBUG_SV.log(l_module_name,'p_del_ids_del_ids_cache.count',p_del_ids_del_ids_cache.count );
4745 WSH_DEBUG_SV.log(l_module_name,'p_del_ids_del_ids_ext_cache.count',p_del_ids_del_ids_ext_cache.count);
4746 WSH_DEBUG_SV.log(l_module_name,'p_uniq_del_ids_tab.count',p_uniq_del_ids_tab.count);
4747 WSH_DEBUG_SV.log(l_module_name,'p_shipment_header_id',p_shipment_header_id);
4748 END IF;
4749 --
4750 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS ;
4751
4752 l_carrier_id := p_local_dd_rec(p_local_dd_rec.FIRST).rcv_carrier_id;
4753
4754 IF l_debug_on THEN
4755 WSH_DEBUG_SV.log(l_module_name,'l_carrier_id',l_carrier_id);
4756 END IF;
4757
4758 --collecting all delivery detaild IDs from the non-contiguous key-value pairs
4759 --p_index_dd_ids_cache and p_index_dd_ids_ext_cache to the contiguous table
4760 --l_dd_ids_tab
4761
4762 j := 1;
4766 IF l_debug_on THEN
4763 l_ind := p_index_dd_ids_cache.FIRST;
4764 WHILE l_ind IS NOT NULL
4765 LOOP
4767 WSH_DEBUG_SV.log(l_module_name,'DD ID for AUTOCREATE_DEL_TRIP:',p_index_dd_ids_cache(l_ind).value);
4768 END IF;
4769 --
4770 l_dd_ids_tab(j) := p_index_dd_ids_cache(l_ind).value;
4771 j := j + 1;
4772 l_ind := p_index_dd_ids_cache.NEXT(l_ind);
4773 END LOOP;
4774 l_ind := p_index_dd_ids_ext_cache.FIRST;
4775 WHILE l_ind IS NOT NULL
4776 LOOP
4777 IF l_debug_on THEN
4778 WSH_DEBUG_SV.log(l_module_name,'DD ID for AUTOCREATE_DEL_TRIP:',p_index_dd_ids_ext_cache(l_ind).value);
4779 END IF;
4780 --
4781 l_dd_ids_tab(j) := p_index_dd_ids_ext_cache(l_ind).value;
4782 j := j + 1;
4783 l_ind := p_index_dd_ids_ext_cache.NEXT(l_ind);
4784 END LOOP;
4785
4786
4787 -- Calls the API WSH_TRIPS_ACTIONS.AUTOCREATE_DEL_TRIP to create delivery and trip for those
4788 -- delivery detail ids not having both.
4789 IF l_dd_ids_tab.count > 0 THEN
4790
4791 --
4792 -- Debug Statements
4793 --
4794 IF l_debug_on THEN
4795 WSH_DEBUG_SV.log(l_module_name,'l_dd_ids_tab.count',l_dd_ids_tab.count);
4796 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_TRIPS_ACTIONS.AUTOCREATE_DEL_TRIP',WSH_DEBUG_SV.C_PROC_LEVEL);
4797 END IF;
4798 --
4799
4800
4801 WSH_TRIPS_ACTIONS.AUTOCREATE_DEL_TRIP(
4802 p_line_rows => l_dd_ids_tab,
4803 p_org_rows => l_org_rows,
4804 p_max_detail_commit => 1000,
4805 x_del_rows => l_del_rows,
4806 x_trip_rows => l_trip_rows,
4807 x_return_status => l_return_status);
4808 --
4809 -- Debug Statements
4810 --
4811 IF l_debug_on THEN
4812 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
4813 END IF;
4814 --
4815 wsh_util_core.api_post_call(
4816 p_return_status => l_return_status,
4817 x_num_warnings => l_num_warnings,
4818 x_num_errors => l_num_errors);
4819
4820
4821 IF l_debug_on THEN
4822 WSH_DEBUG_SV.logmsg(l_module_name,'populating dlvy and trip');
4823 END IF;
4824 --
4825 j := 1;
4826 l_ind := p_index_dd_ids_cache.FIRST;
4827
4828 -- populating the p_local_dd_rec structure with the newly created delivery and trip ids
4829 -- in their appropriate indexes
4830 -- and also collect all these delivery ids in the unique del ids list
4831
4832 WHILE l_ind IS NOT NULL
4833 LOOP
4834 OPEN c_get_del_id_trip_id(p_index_dd_ids_cache(l_ind).value);
4835 FETCH c_get_del_id_trip_id
4836 INTO
4837 p_local_dd_rec(l_ind).delivery_id,
4838 p_local_dd_rec(l_ind).trip_id;
4839 IF l_debug_on THEN
4840 WSH_DEBUG_SV.log(l_module_name,'WDD_ID',p_index_dd_ids_cache(l_ind).value);
4841 WSH_DEBUG_SV.log(l_module_name,'DLVY_ID',p_local_dd_rec(l_ind).delivery_id);
4842 WSH_DEBUG_SV.log(l_module_name,'TRIP_ID',p_local_dd_rec(l_ind).trip_id);
4843 END IF;
4844 --
4845 CLOSE c_get_del_id_trip_id;
4846 --
4847 l_new_trip_id_count := NVL(l_new_trip_id_count,0) + 1;
4848 l_new_trip_ids(l_new_trip_id_count) := p_local_dd_rec(l_ind).trip_id;
4849 --
4850
4851 l_ind := p_index_dd_ids_cache.NEXT(l_ind);
4852 END LOOP;
4853
4854 l_ind := p_index_dd_ids_ext_cache.FIRST;
4855 WHILE l_ind IS NOT NULL
4856 LOOP
4857 OPEN c_get_del_id_trip_id(p_index_dd_ids_ext_cache(l_ind).value);
4858 FETCH c_get_del_id_trip_id
4859 INTO
4860 p_local_dd_rec(l_ind).delivery_id,
4861 p_local_dd_rec(l_ind).trip_id;
4862 CLOSE c_get_del_id_trip_id;
4863 --
4864 l_new_trip_id_count := NVL(l_new_trip_id_count,0) + 1;
4865 l_new_trip_ids(l_new_trip_id_count) := p_local_dd_rec(l_ind).trip_id;
4866 --
4867
4868 l_ind := p_index_dd_ids_ext_cache.NEXT(l_ind);
4869 END LOOP;
4870
4871 END IF; --dd_ids tab count > 0
4872
4873
4874 j := 1;
4875 l_del_rows.delete;
4876 l_ind := p_del_ids_del_ids_cache.FIRST;
4877
4878 --collecting all delivery IDs from the non-contiguous key-value pairs
4879 --p_del_ids_del_ids_cache and p_del_ids_del_ids_ext_cache to the contiguous table
4880 --l_del_rows
4881 WHILE l_ind IS NOT NULL
4882 LOOP
4883 l_del_rows(j) := p_del_ids_del_ids_cache(l_ind).value;
4884 IF l_debug_on THEN
4885 WSH_DEBUG_SV.log(l_module_name,' l_del_rows(j)', l_del_rows(j));
4886 END IF;
4887 --
4888 j := j + 1;
4889 l_ind := p_del_ids_del_ids_cache.NEXT(l_ind);
4890 END LOOP;
4891
4892 l_ind := p_del_ids_del_ids_ext_cache.FIRST;
4893 WHILE l_ind IS NOT NULL
4894 LOOP
4895 l_del_rows(j) := p_del_ids_del_ids_ext_cache(l_ind).value;
4896 IF l_debug_on THEN
4897 WSH_DEBUG_SV.log(l_module_name,' l_del_rows(j)', l_del_rows(j));
4898 END IF;
4899 --
4900 j := j + 1;
4901 l_ind := p_del_ids_del_ids_ext_cache.NEXT(l_ind);
4902 END LOOP;
4903
4904
4905
4906 -- Calls the API WSH_TRIPS_ACTIONS.AUTOCREATE_TRIP_MULTI to create trip for those
4907 -- delivery ids which have not been assigned to any trip.
4908 IF l_del_rows.COUNT > 0 THEN
4909 --
4910 -- Debug Statements
4911 --
4912 IF l_debug_on THEN
4916 --
4913 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_TRIPS_ACTIONS.AUTOCREATE_TRIP_MULTI',WSH_DEBUG_SV.C_PROC_LEVEL);
4914 WSH_DEBUG_SV.log(l_module_name,'l_del_rows.count = ',l_del_rows.count);
4915 END IF;
4917
4918 WSH_TRIPS_ACTIONS.autocreate_trip_multi(
4919 p_del_rows => l_del_rows,
4920 x_trip_ids => l_trip_ids,
4921 x_trip_names => l_trip_names,
4922 x_return_status => l_return_status);
4923
4924 --
4925 -- Debug Statements
4926 --
4927 IF l_debug_on THEN
4928 WSH_DEBUG_SV.log(l_module_name,'RET STS OF WSH_TRIPS_ACTIONS.autocreate_trip_multi IS :', l_return_status);
4929 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
4930 END IF;
4931 --
4932 wsh_util_core.api_post_call(
4933 p_return_status => l_return_status,
4934 x_num_warnings => l_num_warnings,
4935 x_num_errors => l_num_errors);
4936
4937
4938 IF l_debug_on THEN
4939 WSH_DEBUG_SV.logmsg(l_module_name,'populating trip only');
4940 END IF;
4941 --
4942
4943 -- populating the dd_rec structure with the newly created trip ids
4944 -- in their appropriate indexes.The Delivery IDs for which the Trip has to
4945 -- be updated is derived from the two cache tables.
4946
4947 j := 1;
4948 l_ind := p_index_del_ids_cache.FIRST;
4949 WHILE l_ind IS NOT NULL
4950 LOOP
4951
4952 OPEN c_get_trip_id(p_index_del_ids_cache(l_ind).value);
4953 FETCH c_get_trip_id
4954 INTO
4955 p_local_dd_rec(l_ind).trip_id;
4956 CLOSE c_get_trip_id;
4957 IF l_debug_on THEN
4958 WSH_DEBUG_SV.log(l_module_name,'p_index_del_ids_cache(l_ind).value',p_index_del_ids_cache(l_ind).value);
4959 WSH_DEBUG_SV.log(l_module_name,'p_local_dd_rec(l_ind).trip_id',p_local_dd_rec(l_ind).trip_id);
4960 END IF;
4961 --
4962 --
4963 l_new_trip_id_count := NVL(l_new_trip_id_count,0) + 1;
4964 l_new_trip_ids(l_new_trip_id_count) := p_local_dd_rec(l_ind).trip_id;
4965 --
4966 l_ind := p_index_del_ids_cache.NEXT(l_ind);
4967 j := j+1;
4968 END LOOP;
4969
4970
4971 l_ind := p_index_del_ids_ext_cache.FIRST;
4972 WHILE l_ind IS NOT NULL
4973 LOOP
4974 OPEN c_get_trip_id(p_index_del_ids_ext_cache(l_ind).value);
4975 FETCH c_get_trip_id
4976 INTO
4977 p_local_dd_rec(l_ind).trip_id;
4978 CLOSE c_get_trip_id;
4979 IF l_debug_on THEN
4980 WSH_DEBUG_SV.log(l_module_name,'p_index_del_ids_ext_cache(l_ind).value',p_index_del_ids_ext_cache(l_ind).value);
4981 WSH_DEBUG_SV.log(l_module_name,'p_local_dd_rec(l_ind).trip_id',p_local_dd_rec(l_ind).trip_id);
4982 END IF;
4983 --
4984 --
4985 l_new_trip_id_count := NVL(l_new_trip_id_count,0) + 1;
4986 l_new_trip_ids(l_new_trip_id_count) := p_local_dd_rec(l_ind).trip_id;
4987 --
4988 l_ind := p_index_del_ids_ext_cache.NEXT(l_ind);
4989 j := j+1;
4990 END LOOP;
4991
4992 END IF; --l_del_rows count > 0
4993
4994
4995
4996 IF l_debug_on THEN
4997 WSH_DEBUG_SV.logmsg(l_module_name,'updating carrier on trip');
4998 WSH_DEBUG_SV.log(l_module_name,'l_new_trip_id_count',l_new_trip_id_count);
4999 END IF;
5000
5001 IF l_new_trip_id_count > 0
5002 THEN
5003 FORALL i in l_new_trip_ids.FIRST..l_new_trip_ids.LAST
5004 UPDATE WSH_TRIPS
5005 SET carrier_id = l_carrier_id,
5006 last_update_date = SYSDATE,
5007 last_updated_by = FND_GLOBAL.USER_ID,
5008 last_update_login = FND_GLOBAL.LOGIN_ID
5009 WHERE trip_id = l_new_trip_ids(i);
5010 END IF;
5011
5012 --collecting unique del ids into a table from a non-contiguous table, to be passed to
5013 --WSH_ASN_RECEIPT_PVT.UNASSIGN_OPEN_DET_FROM_DEL
5014
5015 j := 1;
5016 l_ind := p_uniq_del_ids_tab.FIRST;
5017 WHILE l_ind IS NOT NULL
5018 LOOP
5019 l_del_ids(j) := p_uniq_del_ids_tab(l_ind);
5020 j := j + 1;
5021 l_ind := p_uniq_del_ids_tab.NEXT(l_ind);
5022 END LOOP;
5023
5024
5025 --call unassign open details for all deliveries i.e basically all the records
5026 --in the p_local_dd_rec structure
5027 IF l_del_ids.count > 0 THEN
5028 --
5029 -- Debug Statements
5030 --
5031 IF l_debug_on THEN
5032 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_ASN_RECEIPT_PVT.UNASSIGN_OPEN_DET_FROM_DEL',WSH_DEBUG_SV.C_PROC_LEVEL);
5033 WSH_DEBUG_SV.log(l_module_name,'l_del_ids.count',l_del_ids.count);
5034 END IF;
5035 --
5036 unassign_open_det_from_del(
5037 p_del_ids => l_del_ids,
5038 p_action_prms => p_action_prms,
5039 p_shipment_header_id => p_shipment_header_id,
5040 x_return_status => l_return_status);
5041 --
5042 -- Debug Statements
5043 --
5044 IF l_debug_on THEN
5045 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
5046 END IF;
5047 --
5048 wsh_util_core.api_post_call(
5049 p_return_status => l_return_status,
5050 x_num_warnings => l_num_warnings,
5051 x_num_errors => l_num_errors);
5052
5053 END IF; --l_del_ids > 0
5054
5055
5056 --
5057 -- Debug Statements
5058 --
5059 IF l_debug_on THEN
5060 WSH_DEBUG_SV.pop(l_module_name);
5061 END IF;
5065 ELSIF l_num_warnings > 0 THEN
5062 --
5063 IF l_num_errors > 0 THEN
5064 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
5066 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
5067 END IF;
5068
5069
5070 EXCEPTION
5071 WHEN FND_API.G_EXC_ERROR THEN
5072 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
5073 WSH_UTIL_CORE.ADD_MESSAGE(x_return_status,l_module_name);
5074
5075 --
5076 -- Debug Statements
5077 --
5078 IF l_debug_on THEN
5079 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
5080 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
5081 END IF;
5082 --
5083 WHEN OTHERS THEN
5084 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
5085 WSH_UTIL_CORE.Default_Handler('WSH_ASN_RECEIPT_PVT.UPDATE_STATUS');
5086
5087 --
5088 -- Debug Statements
5089 --
5090 IF l_debug_on THEN
5091 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
5092 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
5093 END IF;
5094 --
5095 END initialize_txns;
5096
5097 -- Start of comments
5098 -- API name : reconfigure_del_trips
5099 -- Type : Public
5100 -- Pre-reqs : None.
5101 -- Function : The Bill of Lading(From WSH_DOCUMENT_INSTANCES for entity name
5102 -- and entity id) will trigger the reconfiguration of the
5103 -- deliveries and associated trips.
5104 -- For delivery details which will be marked as 'C'-SHIPPED,
5105 -- we need to ensure that lines having the same Bill of Lading
5106 -- fall in the same delivery leg.
5107 -- 1. In this API, first the dd_rec information is arranged in
5108 -- the ascending order of Trip ID,delivery id, BOL and LPN_ids.
5109 -- 2. The sorted records are divided into logical groups based on BOL
5110 -- and calls are made to the API create_update_waybill_psno_bol
5111 -- for each such group.
5112 -- 4. For every BOL Group, whenever it encounters the change
5113 -- in the LPN, it packs a group of delivery details into a single
5114 -- LPN.
5115 -- Parameters :
5116 -- IN:
5117 -- IN OUT:
5118 -- p_local_dd_rec IN OUT NOCOPY LOCAL_DD_REC_TABLE_TYPE,
5119 -- The structure which contains necessary information of the changed attributes
5120 -- of the lines.
5121 -- p_action_prms IN OUT NOCOPY WSH_GLBL_VAR_STRCT_GRP.dd_action_parameters_rec_type
5122 --- A record which contains the action code, transaction type etc..
5123 -- x_lpnGWTcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
5124 -- A key-value cache (mapping table) which has the key as LPN id and value as
5125 -- Gross weight for the corresponding LPN. The key ranges from 1 to (2^31 -1)
5126 -- x_lpnGWTcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
5127 -- A key-value cache (mapping table) which has the key as LPN id and value as
5128 -- Gross weight for the corresponding LPN. The key ranges from 2^31 and greater.
5129 -- x_lpnNWTcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
5130 -- A key-value cache (mapping table) which has the key as LPN id and value as
5131 -- Net weight for the corresponding LPN. The key ranges from 1 to (2^31 -1)
5132 -- x_lpnNWTcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
5133 -- A key-value cache (mapping table) which has the key as LPN id and value as
5134 -- Net weight for the corresponding LPN. The key ranges from 2^31 and greater.
5135 -- x_lpnVOLcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
5136 -- A key-value cache (mapping table) which has the key as LPN id and value as
5137 -- Volume for the corresponding LPN. The key ranges from 1 to (2^31 -1)
5138 -- x_lpnVOLcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
5139 -- A key-value cache (mapping table) which has the key as LPN id and value as
5140 -- Volume for the corresponding LPN. The key ranges from 2^31 and greater.
5141 -- x_dlvyGWTcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
5142 -- A key-value cache (mapping table) which has the key as Delivery id and value as
5143 -- Gross weight for the corresponding LPN. The key ranges from 1 to (2^31 -1)
5144 -- x_dlvyGWTcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
5145 -- A key-value cache (mapping table) which has the key as Delivery id and value as
5146 -- Gross weight for the corresponding LPN. The key ranges from 2^31 and greater.
5147 -- x_dlvyNWTcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
5148 -- A key-value cache (mapping table) which has the key as Delivery id and value as
5149 -- Net weight for the corresponding LPN. The key ranges from 1 to (2^31 -1)
5150 -- x_dlvyNWTcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
5151 -- A key-value cache (mapping table) which has the key as Delivery id and value as
5152 -- Net weight for the corresponding LPN. The key ranges from 2^31 and greater.
5153 -- x_dlvyVOLcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
5154 -- A key-value cache (mapping table) which has the key as Delivery id and value as
5155 -- Volume for the corresponding LPN. The key ranges from 1 to (2^31 -1)
5156 -- x_dlvyVOLcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
5157 -- A key-value cache (mapping table) which has the key as Delivery id and value as
5161 --Cache Tables :
5158 -- Volume for the corresponding LPN. The key ranges from 2^31 and greater.
5159
5160 -- OUT:
5162 -- ----------------------------------------------------------------------
5163 -- | Cache Table Name | Key | Value |
5164 -- ----------------------------------------------------------------------
5165 -- |x_lpnGWTcachetbl | LPN ID | Gross Weight |
5166 -- |x_lpnGWTcacheExttbl | LPN ID | Gross Weight |
5167 -- -----------------------------------------------------------------------
5168 -- |x_lpnNWTcachetbl | LPN ID | Net Weight |
5169 -- |x_lpnNWTcacheExttbl | LPN ID | Net Weight |
5170 -- -----------------------------------------------------------------------
5171 -- |x_lpnVOLcachetbl | LPN ID | Volume |
5172 -- |x_lpnVOLcacheExttbl | LPN ID | Volume |
5173 -- -----------------------------------------------------------------------
5174 -- |x_dlvyGWTcachetbl | Delivery ID | Gross Weight |
5175 -- |x_dlvyGWTcacheExttbl | Delivery ID | Gross Weight |
5176 -- -----------------------------------------------------------------------
5177 -- |x_dlvyNWTcachetbl | Delivery ID | Net Weight |
5178 -- |x_dlvyNWTcacheExttbl | Delivery ID | Net Weight |
5179 -- -----------------------------------------------------------------------
5180 -- |x_dlvyVOLcachetbl | Delivery ID | Volume |
5181 -- |x_dlvyVOLcacheExttbl | Delivery ID | Volume |
5182 -- -----------------------------------------------------------------------
5183 -- Version : 1.0
5184 -- Previous version 1.0
5185 -- Initial version 1.0
5186 -- End of comments
5187
5188
5189
5190 PROCEDURE reconfigure_del_trips(
5191 p_local_dd_rec IN OUT NOCOPY LOCAL_DD_REC_TABLE_TYPE,
5192 p_action_prms IN OUT NOCOPY WSH_GLBL_VAR_STRCT_GRP.dd_action_parameters_rec_type,
5193 x_lpnGWTcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
5194 x_lpnGWTcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
5195 x_lpnNWTcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
5196 x_lpnNWTcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
5197 x_lpnVOLcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
5198 x_lpnVOLcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
5199 x_dlvyGWTcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
5200 x_dlvyGWTcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
5201 x_dlvyNWTcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
5202 x_dlvyNWTcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
5203 x_dlvyVOLcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
5204 x_dlvyVOLcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
5205 p_shipment_header_id IN NUMBER, -- added by NPARIKH
5206 x_return_status OUT NOCOPY VARCHAR2) IS
5207
5208 --Cursor to get the Stop IDs corresponding to a Trip.
5209 CURSOR c_get_stop_ids(l_cur_trip_id NUMBER)
5210 IS
5211 SELECT
5212 stop_id
5213 FROM
5214 WSH_TRIP_STOPS WTS
5215 WHERE WTS.trip_id = l_cur_trip_id;
5216
5217 l_in_rec WSH_DELIVERY_VALIDATIONS.ChgStatus_in_rec_type;
5218
5219 CURSOR empty_it_dlvy_csr (p_shipment_header_id IN NUMBER)
5220 IS
5221 SELECT delivery_id, ultimate_dropoff_date, name, status_code
5222 FROM wsh_new_deliveries wnd
5223 WHERE wnd.asn_shipment_header_id = p_shipment_header_id
5224 AND wnd.status_code = 'IT'
5225 AND NOT EXISTS (
5226 select 1
5227 FROM wsh_delivery_assignments_v wda
5228 WHERE wda.delivery_id = wnd.delivery_id
5229 );
5230
5231 l_stored_del_id NUMBER;
5232 l_trigger NUMBER;--set to '1' when ever a new delivery ID has to be created
5233 l_gross_weight NUMBER;
5234 l_net_weight NUMBER;
5235 l_volume NUMBER;
5236 l_return_status VARCHAR2(1);
5237 l_use_LPNS NUMBER;
5238 l_psno_flag NUMBER := 0;
5239 l_waybill_flag NUMBER := 0;
5240 l_psno VARCHAR2(250);
5241 l_waybill VARCHAR2(30);
5242 l_new_del_id NUMBER;
5243 curr_lpn NUMBER;
5244 curr_lpn_name VARCHAR2(50);
5245 curr_bol VARCHAR2(50);
5246 curr_del NUMBER;
5247 curr_del_det NUMBER;
5248 l_found NUMBER;
5249 temp_ids wsh_util_core.id_tab_type;
5250 pack_ids wsh_util_core.id_tab_type;
5251 temp_dels wsh_util_core.id_tab_type;
5252 l_wdd_tbl wsh_util_core.Id_Tab_Type;
5253 unique_trips wsh_util_core.id_tab_type;
5254 l_trips_tab wsh_util_core.id_tab_type;
5255 l_pack_status VARCHAR2(1);
5256 l_stop_ids_tab wsh_util_core.id_tab_type;
5257 l_stop_id NUMBER;
5258 l_del_ids_tab wsh_util_core.id_tab_type;
5259 j NUMBER;
5260 l_local_dd_rec LOCAL_DD_REC_TABLE_TYPE;
5261 dd_rec_count NUMBER;
5262 l_num_warnings NUMBER := 0;
5263 l_num_errors NUMBER := 0;
5264 l_ind NUMBER;
5265
5266 curr_trip_id NUMBER;
5270 truck_flag NUMBER ;
5267 curr_truck_num VARCHAR2(35);
5268 prev_trip_id NUMBER;
5269 prev_truck_num VARCHAR2(35);
5271
5272
5273 curr_initial_pickup_date DATE;
5274 curr_expected_receipt_date DATE;
5275 curr_rcv_carrier_id NUMBER;
5276
5277 l_initial_pickup_date_tab wsh_util_core.Date_Tab_Type;
5278 l_expected_receipt_date_tab wsh_util_core.Date_Tab_Type;
5279 l_rcv_carrier_id_tab wsh_util_core.Id_Tab_Type;
5280
5281 l_gross_weight_of_first NUMBER;
5282 l_net_weight_of_first NUMBER;
5283
5284 curr_header_id NUMBER;
5285 l_header_ids_for_del_ids_tab wsh_util_core.id_Tab_Type;
5286
5287 l_dd_index NUMBER;
5288 --
5289 l_debug_on BOOLEAN;
5290 --
5291 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'RECONFIGURE_DEL_TRIPS';
5292 --
5293 BEGIN
5294
5295 --
5296 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
5297 --
5298 IF l_debug_on IS NULL
5299 THEN
5300 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
5301 END IF;
5302 --
5303 --
5304 -- Debug Statements
5305 --
5306 IF l_debug_on THEN
5307 WSH_DEBUG_SV.push(l_module_name);
5308 WSH_DEBUG_SV.log(l_module_name,'p_action_prms.action_code',p_action_prms.action_code);
5309 WSH_DEBUG_SV.log(l_module_name,'p_shipment_header_id',p_shipment_header_id);
5310 END IF;
5311 --
5312 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS ;
5313 l_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS ;
5314 SAVEPOINT RECONFIG_DEL_TRIPS_PVT;
5315
5316
5317
5318 l_local_dd_rec := p_local_dd_rec;
5319
5320
5321 IF l_debug_on THEN
5322 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit SORT_DD_REC',WSH_DEBUG_SV.C_PROC_LEVEL);
5323 END IF;
5324 --Arrange the data in p_local_dd_rec in the ascending order of Trip ID,delivery id, BOL and LPN.
5325 sort_dd_rec(
5326 p_local_dd_rec => l_local_dd_rec,
5327 x_return_status => l_return_status);
5328
5329 --
5330 -- Debug Statements
5331 --
5332 IF l_debug_on THEN
5333 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
5334 END IF;
5335 --
5336 wsh_util_core.api_post_call(
5337 p_return_status => l_return_status,
5338 x_num_warnings => l_num_warnings,
5339 x_num_errors => l_num_errors);
5340
5341 --Once sorted, the records of the l_local_dd_rec are considered
5342 --to be in LOGICAL GROUPS based on the BOL. i.e records
5343 --having the same Trip,Delivery ID and BOL
5344 --are considered to be a logical group.
5345 --For every such group we need to execute WSH_ASN_RECEIPT_PVT.SYNCH_BOLS
5346 --for the first group within the delivery. For the subsequent groups, a call is made
5347 --to the API WSH_INBOUND_UTIL_PKG.SPLIT_INBOUND_DELIVERY to create a new delivery
5348 --for this logical group based on the existing Delivery ID.But the calls to
5349 --above mentioned APIs are not directly made from the current Procedure, rather the API
5350 --CREATE_UPDATE_WAYBILL_PSNO_BOL takes care of the same.The variable
5351 --l_trigger is used to determine whether a logical group is the first group
5352 --within the delivery.
5353
5354
5355 curr_lpn := l_local_dd_rec(1).lpn_id;
5356 curr_lpn_name := l_local_dd_rec(1).lpn_name;
5357 curr_del := l_local_dd_rec(1).delivery_id;
5358 curr_BOL := l_local_dd_rec(1).BOL;
5359 curr_del_det := l_local_dd_rec(1).del_detail_id;
5360 curr_initial_pickup_date := l_local_dd_rec(1).initial_pickup_date;
5361 curr_expected_receipt_date := l_local_dd_rec(1).expected_receipt_date;
5362 curr_header_id := l_local_dd_rec(1).shipment_header_id;
5363 curr_rcv_carrier_id := l_local_dd_rec(1).rcv_carrier_id;
5364
5365
5366 --If it is '0' then it means the logical group is the
5367 --first group.
5368 --If it is '1' then it means the logical group is not
5369 --the first group and thereby requires a new delivery to
5370 --be created for the lines in this logical group.
5371 l_trigger := 0;
5372 prev_trip_id := l_local_dd_rec(1).trip_id;
5373 prev_truck_num := l_local_dd_rec(1).truck_num;
5374 truck_flag := 0;
5375
5376
5377 FOR i IN 1..l_local_dd_rec.COUNT loop
5378
5379
5380 IF l_debug_on THEN
5381 WSH_DEBUG_SV.log(l_module_name,'i',i);
5382 WSH_DEBUG_SV.log(l_module_name,'curr_lpn',curr_lpn);
5383 WSH_DEBUG_SV.log(l_module_name,'curr_lpn_name',curr_lpn_name);
5384 WSH_DEBUG_SV.log(l_module_name,'curr_del',curr_del);
5385 WSH_DEBUG_SV.log(l_module_name,'curr_BOL',curr_BOL);
5386 WSH_DEBUG_SV.log(l_module_name,'curr_del_det',curr_del_det);
5387 WSH_DEBUG_SV.log(l_module_name,'curr_header_id',curr_header_id);
5388 WSH_DEBUG_SV.log(l_module_name,'curr_initial_pickup_date',curr_initial_pickup_date);
5389 WSH_DEBUG_SV.log(l_module_name,'curr_expected_receipt_date',curr_expected_receipt_date);
5390 WSH_DEBUG_SV.log(l_module_name,'l_trigger',l_trigger);
5391 WSH_DEBUG_SV.log(l_module_name,'prev_trip_id',prev_trip_id);
5392 WSH_DEBUG_SV.log(l_module_name,'prev_truck_num',prev_truck_num);
5393 WSH_DEBUG_SV.log(l_module_name,'truck_flag',truck_flag);
5394 WSH_DEBUG_SV.log(l_module_name,'WDD ID',l_local_dd_rec(i).del_detail_id );
5395 END IF;
5396 --
5397 --
5398 l_wdd_tbl(l_wdd_tbl.count + 1) := l_local_dd_rec(i).del_detail_id ;
5399
5400
5401
5402 -- WSH_ASN_RECEIPT_PVT.CREATE_UPDATE_WAYBILL_PSNO_BOL() is called
5406 -- miss the call for the last set of records.
5403 -- 1. when ever the delivery changes from the previous record of l_local_dd_rec
5404 -- 2. when ever the BOl changes from the previous record of l_local_dd_rec
5405 -- 3. After this for loop(the outer most loop of this procedure) so that we don't
5407
5408 -- WSH_CONTAINER_ACTIONS.PACK_INBOUND_LINES is called
5409 -- 1. when ever the LPN changes within a LOGICAL GROUP of l_local_dd_rec records.
5410 -- 2. when ever the BOl changes (gets called thru create_update_waybill_psno_bol)
5411 -- 3. when ever the Delivery Id changes
5412
5413 IF (curr_del = l_local_dd_rec(i).delivery_id) THEN
5414
5415 --The BOL has changed from the previous record, but both records have the
5416 --same delivery.
5417 IF (NVL(curr_BOL,'$$$$$$') <> NVL(l_local_dd_rec(i).BOL,'$$$$$$')) THEN
5418 IF l_debug_on THEN
5419 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit CREATE_UPDATE_WAYBILL_PSNO_BOL 1',WSH_DEBUG_SV.C_PROC_LEVEL);
5420 END IF;
5421 --This API (create_update_waybill_psno_bol) based on the l_trigger (0/1) determines whether
5422 --a new Delivery ID has to be created for the current logical group.
5423 create_update_waybill_psno_bol(
5424 p_local_dd_rec=> l_local_dd_rec,
5425 l_loop_index => i,
5426 pack_ids => pack_ids,
5427 curr_del => curr_del,
5428 curr_bol => curr_bol,
5429 curr_lpn => curr_lpn,
5430 curr_lpn_name => curr_lpn_name,
5431 curr_del_det => curr_del_det,
5432 l_psno => l_psno,
5433 l_waybill => l_waybill,
5434 l_psno_flag => l_psno_flag,
5435 l_trigger => l_trigger,
5436 l_waybill_flag=> l_waybill_flag ,
5437 temp_dels => temp_dels,
5438 p_action_prms => p_action_prms,
5439 x_return_status=> l_return_status);
5440 --
5441 -- Debug Statements
5442 --
5443 IF l_debug_on THEN
5444 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
5445 END IF;
5446 --
5447 wsh_util_core.api_post_call(
5448 p_return_status => l_return_status,
5449 x_num_warnings => l_num_warnings,
5450 x_num_errors => l_num_errors);
5451
5452 l_initial_pickup_date_tab(l_initial_pickup_date_tab.COUNT + 1) := curr_initial_pickup_date;
5453 l_expected_receipt_date_tab(l_expected_receipt_date_tab.COUNT + 1) := curr_expected_receipt_date;
5454 l_header_ids_for_del_ids_tab(l_header_ids_for_del_ids_tab.COUNT + 1) := curr_header_id;
5455 l_rcv_carrier_id_tab(l_rcv_carrier_id_tab.COUNT + 1) := curr_rcv_carrier_id;
5456
5457 -- this part (ELSE ) gets executed whenver the BOLs are the same within the same delivery.
5458 -- i.e the BOL of the previous and current record are the same.
5459 ELSE -- }{ else for curr_bol --FOR THE IF STMT
5460
5461 --If true, implies the LPN has changed from the previous record, so pack the previous
5462 --lines having the same LPN to a Container.
5463 --{
5464 IF ( (NVL(curr_lpn,-999) <> NVL(l_local_dd_rec(i).lpn_id,-999) ) AND (curr_lpn IS NOT NULL)) THEN
5465
5466 --
5467 -- Debug Statements
5468 --
5469 IF l_debug_on THEN
5470 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_CONTAINER_ACTIONS.PACK_INBOUND_LINES',WSH_DEBUG_SV.C_PROC_LEVEL);
5471 END IF;
5472 --
5473 --Call wsh_container_actions.pack_inbound_lines to pack lines to LPNs.
5474 wsh_container_actions.pack_inbound_lines(
5475 p_lines_tbl => pack_ids ,
5476 p_lpn_id => curr_lpn ,
5477 p_lpn_name => curr_lpn_name ,
5478 p_delivery_id=> curr_del ,
5479 p_transactionType => p_action_prms.action_code,
5480 x_return_status => l_return_status,
5481 p_waybill_number => l_local_dd_rec(i).waybill) ;
5482 --
5483 -- Debug Statements
5484 --
5485 IF l_debug_on THEN
5486 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
5487 END IF;
5488 --
5489 wsh_util_core.api_post_call(
5490 p_return_status => l_return_status,
5491 x_num_warnings => l_num_warnings,
5492 x_num_errors => l_num_errors);
5493
5494 --once assigned to a container, the pack_ids is deleted, so that the same lines
5495 --don't get assigned to another container.
5496 pack_ids.delete;
5497 END IF;
5498 --}
5499 END IF;
5500 --}
5501
5502 --Executed (Else part ) if the delivery ID has changed from the previous record.
5503 --So things like packing the lines to containers,creating new delivery ID (based on l_trigger value)
5504 --for the logical group etc are taken care by the call to the API CREATE_UPDATE_WAYBILL_PSNO_BOL.
5505 ELSE
5506 IF l_debug_on THEN
5507 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit CREATE_UPDATE_WAYBILL_PSNO_BOL 2',WSH_DEBUG_SV.C_PROC_LEVEL);
5508 END IF;
5509 --Call to API CREATE_UPDATE_WAYBILL_PSNO_BOL.
5510 create_update_waybill_psno_bol(
5511 p_local_dd_rec => l_local_dd_rec,
5512 l_loop_index => i,
5513 pack_ids => pack_ids,
5514 curr_del => curr_del,
5515 curr_bol => curr_bol,
5516 curr_lpn => curr_lpn,
5520 l_waybill => l_waybill,
5517 curr_lpn_name => curr_lpn_name,
5518 curr_del_det => curr_del_det,
5519 l_psno => l_psno,
5521 l_psno_flag => l_psno_flag,
5522 l_trigger => l_trigger,
5523 l_waybill_flag=> l_waybill_flag ,
5524 temp_dels => temp_dels,
5525 p_action_prms => p_action_prms,
5526 x_return_status=> l_return_status);
5527 --
5528 -- Debug Statements
5529 --
5530 IF l_debug_on THEN
5531 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
5532 END IF;
5533 --
5534 wsh_util_core.api_post_call(
5535 p_return_status => l_return_status,
5536 x_num_warnings => l_num_warnings,
5537 x_num_errors => l_num_errors);
5538
5539 l_initial_pickup_date_tab(l_initial_pickup_date_tab.COUNT + 1) := curr_initial_pickup_date;
5540 l_expected_receipt_date_tab(l_expected_receipt_date_tab.COUNT + 1) := curr_expected_receipt_date;
5541 l_header_ids_for_del_ids_tab(l_header_ids_for_del_ids_tab.COUNT + 1) := curr_header_id;
5542 l_rcv_carrier_id_tab(l_rcv_carrier_id_tab.COUNT + 1) := curr_rcv_carrier_id;
5543 l_trigger := 0;
5544
5545 END IF;
5546
5547 IF l_debug_on THEN
5548 WSH_DEBUG_SV.log(l_module_name,'l_psno_flag',l_psno_flag);
5549 WSH_DEBUG_SV.log(l_module_name,'l_psno',l_psno);
5550 WSH_DEBUG_SV.log(l_module_name,'l_waybill_flag',l_waybill_flag);
5551 WSH_DEBUG_SV.log(l_module_name,'l_waybill',l_waybill);
5552 END IF;
5553 --
5554
5555
5556 -- l_psno_flag : this flag is used to check whether
5557 -- the psno remains the same within a delivery.
5558 IF ( l_psno_flag = 0 ) THEN
5559 IF ( (NVL(l_psno,'$$$') <> NVL(l_local_dd_rec(i).psno,'$$$'))
5560 AND (l_psno IS NOT NULL))
5561 THEN
5562 l_psno_flag := 1;
5563 END IF;
5564 END IF;
5565
5566
5567 -- l_waybill_flag : this flag is used to check whether
5568 -- the waybill remains the same within a delivery.
5569 IF ( l_waybill_flag = 0 ) THEN
5570 IF ( (NVL(l_waybill,'$$$$$') <> NVL(l_local_dd_rec(i).waybill,'$$$$$'))
5571 AND (l_waybill IS NOT NULL) )
5572 THEN
5573 l_waybill_flag := 1;
5574 END IF;
5575 END IF;
5576
5577
5578 --collects the delivery detail IDs corresponding to a logical group.
5579 IF ( (curr_del_det <> l_local_dd_rec(i).del_detail_id) OR (pack_ids.count = 0) )THEN
5580 pack_ids(pack_ids.count + 1) := l_local_dd_rec(i).del_detail_id;
5581 END IF;
5582
5583
5584 --collecting unique trips
5585 IF ( l_local_dd_rec(i).trip_id is not null ) AND ( l_local_dd_rec(i).trip_id <> -1 ) THEN
5586 unique_trips(l_local_dd_rec(i).trip_id) := l_local_dd_rec(i).trip_id;
5587 END IF;
5588
5589
5590
5591 curr_del := l_local_dd_rec(i).delivery_id;
5592 curr_BOL := l_local_dd_rec(i).BOL;
5593 curr_lpn := l_local_dd_rec(i).lpn_id;
5594 curr_lpn_name := l_local_dd_rec(i).lpn_name;
5595 curr_del_det := l_local_dd_rec(i).del_detail_id;
5596 l_psno := l_local_dd_rec(i).psno;
5597 l_waybill:= l_local_dd_rec(i).waybill;
5598 curr_initial_pickup_date := l_local_dd_rec(i).initial_pickup_date;
5599 curr_expected_receipt_date := l_local_dd_rec(i).expected_receipt_date;
5600 curr_header_id := l_local_dd_rec(i).shipment_header_id;
5601 curr_trip_id := l_local_dd_rec(i).trip_id;
5602 curr_truck_num := l_local_dd_rec(i).truck_num;
5603 curr_rcv_carrier_id := l_local_dd_rec(i).rcv_carrier_id;
5604
5605
5606 -- truck_flag : this flag is used to check whether
5607 -- the truck number remains the same within a trip.
5608 IF curr_trip_id <> prev_trip_id THEN
5609 IF (truck_flag = 0) AND ( prev_trip_id <> -1 ) THEN
5610 UPDATE wsh_trips
5611 SET vehicle_number = prev_truck_num
5612 WHERE trip_id = prev_trip_id;
5613 ELSE
5614
5615 truck_flag := 0;
5616 END IF;
5617 ELSE
5618 IF truck_flag = 0 THEN
5619 IF NVL(curr_truck_num,'$$$') <> NVL(prev_truck_num,'$$$') THEN
5620 truck_flag := 1;
5621 END IF;
5622 END IF;
5623 END IF;
5624
5625 prev_trip_id := curr_trip_id;
5626 prev_truck_num := curr_truck_num;
5627
5628
5629 --
5630 END LOOP;
5631 --End of the outermost while loop.Once the control comes out of
5632 --this loop, it does not mean that all the records of l_local_dd_rec where succesfully
5633 --processed like packing into containers ,BOL assignments etc..
5634 --There will be atleast a single record in all cases where the above mentioned process
5635 --has to be done, since the above mentioned outermost loop uses such a logic. (current
5636 --record compared against the previous record).So for such left out records (which will
5637 --fall in a single logical group always), the process like creating conatiners, new delievry IDs
5638 --etc..has to be done.So a call to CREATE_UPDATE_WAYBILL_PSNO_BOL is made.
5639
5640 --
5641 IF (truck_flag = 0 ) AND ( curr_trip_id <> -1 ) THEN
5642 UPDATE wsh_trips
5643 SET vehicle_number = curr_truck_num
5644 WHERE trip_id = curr_trip_id;
5645 END IF;
5646 --
5647
5648 --True always, since there will be atleast one left out unprocessed record always.
5649 IF (pack_ids.COUNT > 0) THEN
5650
5651 IF l_debug_on THEN
5652 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit CREATE_UPDATE_WAYBILL_PSNO_BOL 3',WSH_DEBUG_SV.C_PROC_LEVEL);
5653 END IF;
5657 p_local_dd_rec => l_local_dd_rec,
5654
5655 --Call to API create_update_waybill_psno_bol
5656 create_update_waybill_psno_bol(
5658 l_loop_index => l_local_dd_rec.LAST,
5659 pack_ids => pack_ids,
5660 curr_del => curr_del,
5661 curr_bol => curr_bol,
5662 curr_lpn => curr_lpn,
5663 curr_lpn_name => curr_lpn_name,
5664 curr_del_det => curr_del_det,
5665 l_psno => l_psno,
5666 l_waybill => l_waybill,
5667 l_psno_flag => l_psno_flag,
5668 l_trigger => l_trigger,
5669 l_waybill_flag=> l_waybill_flag ,
5670 temp_dels => temp_dels,
5671 p_action_prms => p_action_prms,
5672 x_return_status=> l_return_status);
5673 --
5674 -- Debug Statements
5675 --
5676 IF l_debug_on THEN
5677 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
5678 END IF;
5679 --
5680 wsh_util_core.api_post_call(
5681 p_return_status => l_return_status,
5682 x_num_warnings => l_num_warnings,
5683 x_num_errors => l_num_errors);
5684
5685 l_initial_pickup_date_tab(l_initial_pickup_date_tab.COUNT + 1) := curr_initial_pickup_date;
5686 l_expected_receipt_date_tab(l_expected_receipt_date_tab.COUNT + 1) := curr_expected_receipt_date;
5687 l_header_ids_for_del_ids_tab(l_header_ids_for_del_ids_tab.COUNT + 1) := curr_header_id;
5688 l_rcv_carrier_id_tab(l_rcv_carrier_id_tab.COUNT + 1) := curr_rcv_carrier_id;
5689 IF ( l_local_dd_rec(l_local_dd_rec.LAST).trip_id IS NOT NULL )
5690 AND ( l_local_dd_rec(l_local_dd_rec.LAST).trip_id <> -1 )THEN
5691 unique_trips(l_local_dd_rec(l_local_dd_rec.LAST).trip_id) := l_local_dd_rec(l_local_dd_rec.LAST).trip_id;
5692 END IF;
5693
5694
5695 END IF;
5696
5697 IF l_debug_on THEN
5698 WSH_DEBUG_SV.log(l_module_name,'l_wdd_tbl.count',l_wdd_tbl.count);
5699 WSH_DEBUG_SV.log(l_module_name,'l_wdd_tbl.first',l_wdd_tbl.first);
5700 WSH_DEBUG_SV.log(l_module_name,'l_wdd_tbl.last',l_wdd_tbl.last);
5701 END IF;
5702
5703
5704 --IF temp_dels.COUNT > 0 THEN
5705 IF l_wdd_tbl.COUNT > 0 THEN
5706
5707 /*
5708 *By now we have got the following lists, temp_dels . We need to call the
5709 *following apis to recalculate weight and volume for the deliveries and trips,
5710 *updating the status of the delivery, trip and trip stops and execute the
5711 *rating request for the deliveries.
5712 */
5713
5714 WSH_WV_UTILS.detail_weight_volume(
5715 p_detail_rows => l_wdd_tbl,
5716 p_override_flag => 'Y',
5717 p_calc_wv_if_frozen => 'N', --'Y',
5718 x_return_status => l_return_status);
5719 --
5720 -- Debug Statements
5721 --
5722 IF l_debug_on THEN
5723 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
5724 END IF;
5725 --
5726 wsh_util_core.api_post_call(
5727 p_return_status => l_return_status,
5728 x_num_warnings => l_num_warnings,
5729 x_num_errors => l_num_errors);
5730
5731 END IF;
5732
5733 /*
5734 FTE_FREIGHT_PRICING.shipment_reprice(
5735 p_fte_trip_id => NULL, -- Input only ONE of the following FOUR
5736 p_segment_id => NULL,
5737 p_delivery_id => temp_dels(i),
5738 p_delivery_leg_id => NULL,
5739 x_return_status => l_return_status) ;
5740
5741 wsh_util_core.api_post_call(
5742 p_return_status => l_return_status,
5743 x_num_warnings => l_num_warnings,
5744 x_num_errors => l_num_errors);
5745 */
5746
5747
5748 --copying unique trip ids and stop ids to a table in contigous locations
5749 j := 1;
5750 l_ind := unique_trips.FIRST;
5751 WHILE l_ind IS NOT NULL
5752 LOOP
5753 l_trips_tab(j) := unique_trips(l_ind);
5754
5755
5756 OPEN c_get_stop_ids(unique_trips(l_ind));
5757 FETCH c_get_stop_ids BULK COLLECT INTO l_stop_ids_tab;
5758 CLOSE c_get_stop_ids;
5759 j := j + 1;
5760 l_ind := unique_trips.NEXT(l_ind);
5761 END LOOP;
5762
5763
5764 -- If true -> Then call the the API UPDATE_STATUS of the same package to update various
5765 -- attributes of the delivery which has changed.
5766 IF temp_dels.COUNT > 0 THEN
5767
5768 update_status(
5769 p_action_prms => p_action_prms,
5770 p_del_ids => temp_dels,
5771 p_trip_ids => unique_trips,
5772 p_stop_ids => l_stop_ids_tab,
5773 p_shipment_header_id_tab => l_header_ids_for_del_ids_tab,
5774 p_initial_pickup_date_tab => l_initial_pickup_date_tab,
5775 p_expected_receipt_date_tab => l_expected_receipt_date_tab,
5776 p_rcv_carrier_id_tab => l_rcv_carrier_id_tab,
5777 p_local_dd_rec => l_local_dd_rec,
5778 x_lpnGWTcachetbl => x_lpnGWTcachetbl, --NNP-WV
5779 x_lpnGWTcacheExttbl => x_lpnGWTcacheExttbl,
5780 x_lpnNWTcachetbl => x_lpnNWTcachetbl,
5781 x_lpnNWTcacheExttbl => x_lpnNWTcacheExttbl,
5782 x_lpnVOLcachetbl => x_lpnVOLcachetbl,
5783 x_lpnVOLcacheExttbl => x_lpnVOLcacheExttbl,
5784 x_dlvyGWTcachetbl => x_dlvyGWTcachetbl,
5785 x_dlvyGWTcacheExttbl => x_dlvyGWTcacheExttbl,
5789 x_dlvyVOLcacheExttbl => x_dlvyVOLcacheExttbl,
5786 x_dlvyNWTcachetbl => x_dlvyNWTcachetbl,
5787 x_dlvyNWTcacheExttbl => x_dlvyNWTcacheExttbl,
5788 x_dlvyVOLcachetbl => x_dlvyVOLcachetbl,
5790 x_return_status => l_return_status);
5791 --
5792 -- Debug Statements
5793 --
5794 IF l_debug_on THEN
5795 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
5796 END IF;
5797 --
5798 wsh_util_core.api_post_call(
5799 p_return_status => l_return_status,
5800 x_num_warnings => l_num_warnings,
5801 x_num_errors => l_num_errors);
5802
5803 END IF;
5804
5805 --
5806 -- Close empty IT deliveries , associated with ASN (shipped but not received)
5807 --
5808 IF p_action_prms.action_code = 'RECEIPT' -- added by NPARIKH
5809 THEN
5810 --{
5811 FOR empty_it_dlvy_rec IN empty_it_dlvy_csr (p_shipment_header_id => p_shipment_header_id)
5812 LOOP
5813 --{
5814 l_in_rec.delivery_id := empty_it_dlvy_rec.delivery_id;
5815 l_in_rec.name := empty_it_dlvy_rec.name;
5816 l_in_rec.status_code := empty_it_dlvy_rec.status_code;
5817 l_in_rec.actual_date := empty_it_dlvy_rec.ultimate_dropoff_date;
5818 l_in_rec.manual_flag := 'N';
5819 l_in_rec.caller := WSH_UTIL_CORE.C_IB_RECEIPT_PREFIX;
5820 --
5821 temp_dels(temp_dels.COUNT + 1) := empty_it_dlvy_rec.delivery_id;
5822 --
5823 --
5824 IF l_debug_on THEN
5825 WSH_DEBUG_SV.log(l_module_name,'empty_it_dlvy_rec.delivery_id',empty_it_dlvy_rec.delivery_id);
5826 WSH_DEBUG_SV.log(l_module_name,'empty_it_dlvy_rec.status_code',empty_it_dlvy_rec.status_code);
5827 WSH_DEBUG_SV.log(l_module_name,'empty_it_dlvy_rec.ultimate_dropoff_date',empty_it_dlvy_rec.ultimate_dropoff_date);
5828 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_NEW_DELIVERY_ACTIONS.setClose',WSH_DEBUG_SV.C_PROC_LEVEL);
5829 END IF;
5830 --
5831 WSH_NEW_DELIVERY_ACTIONS.setClose
5832 (
5833 p_in_rec => l_in_rec,
5834 x_return_status => l_return_status
5835 );
5836 --
5837 -- Debug Statements
5838 --
5839 IF l_debug_on THEN
5840 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
5841 END IF;
5842 --
5843 wsh_util_core.api_post_call(
5844 p_return_status => l_return_status,
5845 x_num_warnings => l_num_warnings,
5846 x_num_errors => l_num_errors);
5847
5848 --}
5849 END LOOP;
5850 --}
5851 END IF;
5852
5853 -- If true -> Then call the the API WSH_INBOUND_UTIL_PKG.SETTRIPSTOPSTATUS to update various
5854 -- trip stop status of the deliveries.
5855 IF temp_dels.COUNT > 0 THEN
5856
5857 IF l_debug_on THEN
5858 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INBOUND_UTIL_PKG.SETTRIPSTOPSTATUS',WSH_DEBUG_SV.C_PROC_LEVEL);
5859 END IF;
5860 --
5861
5862 IF l_debug_on THEN
5863 WSH_DEBUG_SV.log(l_module_name,'action code to trip stop :',p_action_prms.action_code);
5864 END IF;
5865
5866 WSH_INBOUND_UTIL_PKG.setTripStopStatus(
5867 p_transaction_code => l_local_dd_rec(1).transaction_type,
5868 p_action_code => 'APPLY',
5869 p_delivery_id_tab => temp_dels,
5870 x_return_status => l_return_status);
5871
5872 IF l_debug_on THEN
5873 WSH_DEBUG_SV.log(l_module_name,'ret sts of trip stop :',l_return_status);
5874 END IF;
5875
5876 --
5877 -- Debug Statements
5878 --
5879 IF l_debug_on THEN
5880 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
5881 END IF;
5882 --
5883 wsh_util_core.api_post_call(
5884 p_return_status => l_return_status,
5885 x_num_warnings => l_num_warnings,
5886 x_num_errors => l_num_errors);
5887
5888 END IF;
5889
5890 --
5891 -- Debug Statements
5892 --
5893 IF l_debug_on THEN
5894 WSH_DEBUG_SV.pop(l_module_name);
5895 END IF;
5896 --
5897 IF l_num_errors > 0 THEN
5898 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
5899 ELSIF l_num_warnings > 0 THEN
5900 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
5901 END IF;
5902
5903
5904 EXCEPTION
5905 WHEN FND_API.G_EXC_ERROR THEN
5906 ROLLBACK TO RECONFIG_DEL_TRIPS_PVT;
5907 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
5908 WSH_UTIL_CORE.ADD_MESSAGE(x_return_status,l_module_name);
5909
5910 --
5911 -- Debug Statements
5912 --
5913 IF l_debug_on THEN
5914 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
5915 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
5916 END IF;
5917 --
5918 WHEN OTHERS THEN
5919 ROLLBACK TO RECONFIG_DEL_TRIPS_PVT;
5920 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
5921 WSH_UTIL_CORE.Default_Handler('WSH_ASN_RECEIPT_PVT.RECONFIGURE_DEL_TRIPS');
5922
5923 --
5924 -- Debug Statements
5925 --
5926 IF l_debug_on THEN
5930 --
5927 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
5928 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
5929 END IF;
5931 END reconfigure_del_trips;
5932
5933
5934 -- Start of comments
5935 -- API name : sort_dd_rec
5936 -- Type : Public
5937 -- Pre-reqs : None.
5938 -- Function : This API sorts records in the p_local_dd_rec structure on the
5939 -- order of trip id,delivery ids,bill of lading and lpn ids.
5940 -- Parameters :
5941 -- IN:
5942 -- IN OUT:
5943 -- p_local_dd_rec IN OUT NOCOPY LOCAL_DD_REC_TABLE_TYPE
5944 -- A record structure with data passed from process_matched_txns API.
5945 -- OUT:
5946 -- x_return_status OUT NOCOPY VARCHAR2
5947 -- Version : 1.0
5948 -- Previous version 1.0
5949 -- Initial version 1.0
5950 -- End of comments
5951
5952
5953 PROCEDURE sort_dd_rec(
5954 p_local_dd_rec IN OUT NOCOPY LOCAL_DD_REC_TABLE_TYPE,
5955 x_return_status OUT NOCOPY VARCHAR2) AS
5956
5957 l_return_status varchar2(1);
5958 t_dd_rec LOCAL_DD_REC_TABLE_TYPE;
5959 l_count NUMBER;
5960 l_lb NUMBER;
5961 l_ub NUMBER;
5962 l_num_warnings NUMBER := 0;
5963 l_num_errors NUMBER := 0;
5964 --
5965 l_debug_on BOOLEAN;
5966 --
5967 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'SORT_DD_REC';
5968 --
5969 begin
5970 --
5971 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
5972 --
5973 IF l_debug_on IS NULL
5974 THEN
5975 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
5976 END IF;
5977 --
5978 --
5979 -- Debug Statements
5980 --
5981 IF l_debug_on THEN
5982 WSH_DEBUG_SV.push(l_module_name);
5983 END IF;
5984 --
5985 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
5986 l_count := p_local_dd_rec.COUNT;
5987
5988 IF l_debug_on THEN
5989 WSH_DEBUG_SV.log(l_module_name, 'l_count', l_count);
5990 WSH_DEBUG_SV.logmsg(l_module_name, 'Before the loop - BASED ON TRIP ID');
5991 WSH_DEBUG_SV.log(l_module_name, 'its first index is', p_local_dd_rec.first);
5992 WSH_DEBUG_SV.log(l_module_name, 'its last index is', p_local_dd_rec.last);
5993 END IF;
5994
5995 --BUBBLE SORT BASED ON TRIP ID
5996 FOR i in 1..(l_count-1) LOOP
5997 FOR j in (i+1)..l_count LOOP
5998 IF p_local_dd_rec(i).trip_id > p_local_dd_rec(j).trip_id THEN
5999 t_dd_rec(1) := p_local_dd_rec(i);
6000 p_local_dd_rec(i) := p_local_dd_rec(j);
6001 p_local_dd_rec(j) := t_dd_rec(1);
6002 END IF;
6003 END LOOP;
6004 END LOOP;
6005
6006
6007
6008 IF l_debug_on THEN
6009 WSH_DEBUG_SV.logmsg(l_module_name, 'Before the loop - BASED ON TRIP ID,DEL_ID');
6010 END IF;
6011
6012 --BUBBLE SORT BASED ON TRIP ID,DELIVERY ID
6013 l_ub := 1;
6014 WHILE l_ub < l_count LOOP
6015 l_lb := l_ub;
6016 WHILE p_local_dd_rec(l_ub).trip_id = p_local_dd_rec(l_ub+1).trip_id LOOP
6017 l_ub := l_ub + 1;
6018 IF l_ub = l_count THEN
6019 EXIT;
6020 END IF;
6021 END LOOP;
6022 FOR i in l_lb..(l_ub-1) LOOP
6023 FOR j in (i+1)..l_ub LOOP
6024 IF p_local_dd_rec(i).delivery_id > p_local_dd_rec(j).delivery_id THEN
6025 t_dd_rec(1) := p_local_dd_rec(i);
6026 p_local_dd_rec(i) := p_local_dd_rec(j);
6027 p_local_dd_rec(j) := t_dd_rec(1);
6028 END IF;
6029 END LOOP;
6030 END LOOP;
6031 l_ub := l_ub + 1;
6032 END LOOP;
6033
6034
6035 IF l_debug_on THEN
6036 WSH_DEBUG_SV.logmsg(l_module_name, 'Before the loop - BASED ON TRIP ID,DELIVERY ID,BOL');
6037 END IF;
6038
6039 l_ub := 1;
6040 --BUBBLE SORT BASED ON TRIP ID,DELIVERY ID,BOL IN THAT ORDER.
6041 WHILE l_ub < l_count LOOP
6042 l_lb := l_ub;
6043 WHILE p_local_dd_rec(l_ub).delivery_id = p_local_dd_rec(l_ub+1).delivery_id LOOP
6044 l_ub := l_ub + 1;
6045 IF l_ub = l_count THEN
6046 EXIT;
6047 END IF;
6048 END LOOP;
6049 FOR i in l_lb..(l_ub-1) LOOP
6050 FOR j in (i+1)..l_ub LOOP
6051 IF (nvl(p_local_dd_rec(i).bol,'zzzzzz')) > (nvl(p_local_dd_rec(j).bol,'zzzzzz')) THEN
6052 -- IF nvl(p_local_dd_rec(i).bol,'Z') > nvl(p_local_dd_rec(j).bol,'A') THEN
6053 t_dd_rec(1) := p_local_dd_rec(i);
6054 p_local_dd_rec(i) := p_local_dd_rec(j);
6055 p_local_dd_rec(j) := t_dd_rec(1);
6056 END IF;
6057 END LOOP;
6058 END LOOP;
6059 l_ub := l_ub + 1;
6060 END LOOP;
6061
6062 IF l_debug_on THEN
6063 WSH_DEBUG_SV.logmsg(l_module_name, 'Before the loop - BASED ON TRIP ID,DEL_ID,BOL,LPNS');
6064 END IF;
6065
6066
6067
6068 l_ub := 1;
6069 WHILE l_ub < l_count LOOP
6070 l_lb := l_ub;
6071 --BUBBLE SORT BASED ON TRIP ID,DEL_ID,BOL,LPNS
6072 WHILE ( nvl(p_local_dd_rec(l_ub).bol,'99999999') = nvl(p_local_dd_rec(l_ub+1).bol,'99999999') )
6073 AND ( p_local_dd_rec(l_ub).delivery_id = p_local_dd_rec(l_ub+1).delivery_id )LOOP
6074 -- commented by RV -- bug
6075 -- AND ( p_local_dd_rec(l_lb).delivery_id = p_local_dd_rec(l_ub).delivery_id )LOOP
6076 l_ub := l_ub + 1;
6077 IF l_ub = l_count THEN
6078 EXIT;
6079 END IF;
6080 END LOOP;
6084 t_dd_rec(1) := p_local_dd_rec(i);
6081 FOR i in l_lb..(l_ub - 1) LOOP
6082 FOR j in (i+1)..l_ub LOOP
6083 IF NVL(p_local_dd_rec(i).lpn_id,999999) > NVL(p_local_dd_rec(j).lpn_id,999999) THEN
6085 p_local_dd_rec(i) := p_local_dd_rec(j);
6086 p_local_dd_rec(j) := t_dd_rec(1);
6087 END IF;
6088 END LOOP;
6089 END LOOP;
6090 l_ub := l_ub + 1;
6091 END LOOP;
6092
6093 IF l_debug_on THEN
6094 WSH_DEBUG_SV.logmsg(l_module_name, 'After the loop - BASED ON TRIP ID,DEL_ID,BOL,LPNS');
6095 END IF;
6096 --
6097 -- Debug Statements
6098 --
6099 IF l_debug_on THEN
6100 WSH_DEBUG_SV.pop(l_module_name);
6101 END IF;
6102 --
6103 IF l_num_errors > 0 THEN
6104 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6105 ELSIF l_num_warnings > 0 THEN
6106 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
6107 END IF;
6108
6109
6110 EXCEPTION
6111 WHEN OTHERS THEN
6112 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
6113 WSH_UTIL_CORE.Default_Handler('WSH_ASN_RECEIPT_PVT.SORT_DD_REC');
6114 --
6115 -- Debug Statements
6116 --
6117 IF l_debug_on THEN
6118 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
6119 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
6120 END IF;
6121 --
6122 END sort_dd_rec;
6123
6124
6125
6126 -- Start of comments
6127 -- API name : synch_bols
6128 -- Type : Public
6129 -- Pre-reqs : None.
6130 -- Function : This API updates the bill of lading for a Delivery leg ID
6131 -- corresponding to the input parameter(p_del_id)
6132 -- on the shipping tables.If the data is not found in the
6133 -- shipping tables, it takes care of adding the new row to the
6134 -- shipping tables.
6135 -- Parameters :
6136 -- IN: p_del_id IN NUMBER,
6137 -- p_bol IN VARCHAR2,
6138 -- p_action_prms IN WSH_GLBL_VAR_STRCT_GRP.dd_action_parameters_rec_type,
6139 -- IN OUT:
6140 --
6141 -- OUT: x_return_status OUT NOCOPY VARCHAR2
6142 -- Version : 1.0
6143 -- Previous version 1.0
6144 -- Initial version 1.0
6145 -- End of comments
6146
6147
6148 PROCEDURE synch_bols(
6149 p_del_id IN NUMBER,
6150 p_bol IN VARCHAR2,
6151 p_action_prms IN WSH_GLBL_VAR_STRCT_GRP.dd_action_parameters_rec_type,
6152 x_return_status OUT NOCOPY VARCHAR2) IS
6153
6154 --Cursor to get the BOL and delivery Leg ID of a Delivery ID.
6155 Cursor c_BOL(p_del_id NUMBER ) is
6156 select
6157 WDG.delivery_leg_id,
6158 wdi.sequence_number bol
6159 from
6160 wsh_delivery_legs wdg,
6161 wsh_document_instances wdi
6162 where
6163 wdg.delivery_leg_id = wdi.entity_id and
6164 wdi.entity_name = 'WSH_DELIVERY_LEGS' AND
6165 wdg.delivery_id = p_del_id AND
6166 wdi.document_type= 'BOL';
6167
6168 l_delivery_leg_id NUMBER;
6169 l_bol VARCHAR2(50);
6170 l_return_status VARCHAR2(1);
6171 l_num_warnings NUMBER;
6172 l_num_errors NUMBER;
6173
6174 --
6175 l_debug_on BOOLEAN;
6176 --
6177 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'SYNCH_BOLS';
6178 --
6179 BEGIN
6180 --
6181 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
6182 --
6183 IF l_debug_on IS NULL
6184 THEN
6185 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
6186 END IF;
6187 --
6188 --
6189 -- Debug Statements
6190 --
6191 IF l_debug_on THEN
6192 WSH_DEBUG_SV.push(l_module_name);
6193 --
6194 WSH_DEBUG_SV.log(l_module_name,'P_DEL_ID',P_DEL_ID);
6195 WSH_DEBUG_SV.log(l_module_name,'P_BOL',P_BOL);
6196 END IF;
6197 --
6198 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
6199 OPEN c_BOL(p_del_id);
6200 FETCH C_BOL into
6201 l_delivery_leg_id,
6202 l_bol;
6203
6204 --
6205 IF l_debug_on THEN
6206 WSH_DEBUG_SV.log(l_module_name,'l_delivery_leg_id',l_delivery_leg_id);
6207 WSH_DEBUG_SV.log(l_module_name,'l_bol',l_bol);
6208 END IF;
6209 --
6210
6211
6212 -- If there is a row present in the table wsh_document_instances for this
6213 -- delivery leg id, then the corresponding row is updated with the new BOL,
6214 -- if the BOLs are different i.e if the BOL passed as an input to this API
6215 -- is different from the BOL present in the table.
6216 -- If there is no row in the table wsh_document_instances for this
6217 -- delivery leg id, then the API WSH_ASN_RECEIPT_PVT.CREATE_UPDATE_INBOUND_DOCUMENT
6218 -- is called to create a new row.
6219
6220 IF c_BOL%FOUND THEN
6221 IF ((p_bol IS NOT NULL) AND (nvl(p_bol,'$$$$') <> nvl(l_bol,'$$$$'))) THEN
6222 UPDATE wsh_document_instances
6223 SET sequence_number = p_bol,
6224 last_update_date = SYSDATE,
6225 last_updated_by = FND_GLOBAL.USER_ID,
6226 last_update_login = FND_GLOBAL.LOGIN_ID
6230 END IF;
6227 WHERE entity_name = 'WSH_DELIVERY_LEGS'
6228 AND entity_id = l_delivery_leg_id
6229 AND document_type= 'BOL';
6231 ELSIF (c_BOL%NOTFOUND) AND (p_bol IS NOT NULL) THEN
6232
6233
6234 IF l_debug_on THEN
6235 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_ASN_RECEIPT_PVT.CREATE_UPDATE_INBOUND_DOCUMENT',WSH_DEBUG_SV.C_PROC_LEVEL);
6236 END IF;
6237
6238
6239 create_update_inbound_document (
6240 p_document_number => p_bol,
6241 p_entity_name => 'WSH_DELIVERY_LEGS',
6242 p_delivery_id => p_del_id,
6243 p_transaction_type => p_action_prms.action_code,
6244 x_return_status => l_return_status);
6245 --
6246 -- Debug Statements
6247 --
6248 IF l_debug_on THEN
6249 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
6250 END IF;
6251 --
6252 wsh_util_core.api_post_call(
6253 p_return_status => l_return_status,
6254 x_num_warnings => l_num_warnings,
6255 x_num_errors => l_num_errors);
6256
6257 END IF;
6258
6259 CLOSE c_bol;
6260
6261 IF l_debug_on THEN
6262 WSH_DEBUG_SV.log(l_module_name,'ret sts at synch bols',x_return_status);
6263 END IF;
6264
6265 --
6266 -- Debug Statements
6267 --
6268 IF l_debug_on THEN
6269 WSH_DEBUG_SV.pop(l_module_name);
6270 END IF;
6271 --
6272 IF l_num_errors > 0 THEN
6273 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6274 ELSIF l_num_warnings > 0 THEN
6275 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
6276 END IF;
6277
6278
6279 EXCEPTION
6280 WHEN FND_API.G_EXC_ERROR THEN
6281 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6282 WSH_UTIL_CORE.ADD_MESSAGE(x_return_status,l_module_name);
6283
6284 --
6285 -- Debug Statements
6286 --
6287 IF l_debug_on THEN
6288 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
6289 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
6290 END IF;
6291 --
6292 WHEN OTHERS THEN
6293 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
6294 WSH_UTIL_CORE.Default_Handler('WSH_ASN_RECEIPT_PVT.SYNCH_BOLS',l_module_name);
6295
6296 --
6297 -- Debug Statements
6298 --
6299 IF l_debug_on THEN
6300 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
6301 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
6302 END IF;
6303 --
6304 END synch_bols;
6305
6306
6307 --========================================================================
6308 -- PROCEDURE : update_status
6309 --
6310 -- COMMENT : This API receives a list of delivery IDs,trip IDs and
6311 -- stop IDs and updates the status code of the IDs based
6312 -- on the received action code.
6313 -- HISTORY : Created the API.
6314 --Cache Tables :
6315 -- ----------------------------------------------------------------------
6316 -- | Cache Table Name | Key | Value |
6317 -- ----------------------------------------------------------------------
6318 -- |x_lpnGWTcachetbl | LPN ID | Gross Weight |
6319 -- |x_lpnGWTcacheExttbl | LPN ID | Gross Weight |
6320 -- -----------------------------------------------------------------------
6321 -- |x_lpnNWTcachetbl | LPN ID | Net Weight |
6322 -- |x_lpnNWTcacheExttbl | LPN ID | Net Weight |
6323 -- -----------------------------------------------------------------------
6324 -- |x_lpnVOLcachetbl | LPN ID | Volume |
6325 -- |x_lpnVOLcacheExttbl | LPN ID | Volume |
6326 -- -----------------------------------------------------------------------
6327 -- |x_dlvyGWTcachetbl | Delivery ID | Gross Weight |
6328 -- |x_dlvyGWTcacheExttbl | Delivery ID | Gross Weight |
6329 -- -----------------------------------------------------------------------
6330 -- |x_dlvyNWTcachetbl | Delivery ID | Net Weight |
6331 -- |x_dlvyNWTcacheExttbl | Delivery ID | Net Weight |
6332 -- -----------------------------------------------------------------------
6333 -- |x_dlvyVOLcachetbl | Delivery ID | Volume |
6334 -- |x_dlvyVOLcacheExttbl | Delivery ID | Volume |
6335 -- -----------------------------------------------------------------------
6336 --========================================================================
6337
6338
6339
6340 PROCEDURE update_status (
6341 p_action_prms IN OUT NOCOPY WSH_GLBL_VAR_STRCT_GRP.dd_action_parameters_rec_type,
6342 p_del_ids IN wsh_util_core.id_tab_type,
6343 p_trip_ids IN wsh_util_core.id_tab_type,
6344 p_stop_ids IN wsh_util_core.id_tab_type,
6345 p_shipment_header_id_tab IN wsh_util_core.id_tab_type,
6346 p_initial_pickup_date_tab IN wsh_util_core.Date_Tab_Type ,
6347 p_expected_receipt_date_tab IN wsh_util_core.Date_Tab_Type ,
6351 x_lpnGWTcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
6348 p_rcv_carrier_id_tab IN wsh_util_core.Id_Tab_Type,
6349 p_local_dd_rec IN LOCAL_DD_REC_TABLE_TYPE,
6350 x_lpnGWTcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
6352 x_lpnNWTcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
6353 x_lpnNWTcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
6354 x_lpnVOLcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
6355 x_lpnVOLcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
6356 x_dlvyGWTcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
6357 x_dlvyGWTcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
6358 x_dlvyNWTcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
6359 x_dlvyNWTcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
6360 x_dlvyVOLcachetbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
6361 x_dlvyVOLcacheExttbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
6362 x_return_status OUT NOCOPY VARCHAR2) IS
6363
6364
6365 l_delivery_info WSH_NEW_DELIVERIES_PVT.Delivery_Rec_Type;
6366 l_num_warnings NUMBER := 0;
6367 l_num_errors NUMBER := 0;
6368 l_return_status VARCHAR2(1);
6369 l_organization_id Number;
6370
6371 --Cursor to get the Ship method code for a Delivery ID for a given Carrier.
6372 cursor l_carrier_csr (p_delivery_id IN NUMBER, p_carrier_id IN NUMBER) IS
6373 select wcs.ship_method_code
6374 from wsh_new_deliveries wnd,
6375 wsh_carriers_v wcv,
6376 wsh_carrier_services wcs,
6377 wsh_org_carrier_services wocs
6378 where wnd.delivery_id = p_delivery_id
6379 and wcv.carrier_id = p_carrier_id
6380 and wcv.active = 'A'
6381 and wocs.organization_id = wnd.organization_id
6382 and nvl(wcs.enabled_flag, 'N') = 'Y'
6383 and nvl(wocs.enabled_flag, 'N')= 'Y'
6384 and wcv.carrier_id = wcs.carrier_id
6385 and wcs.service_level = wnd.service_level(+)
6386 and wcs.mode_of_transport = wnd.mode_of_transport(+);
6387
6388 l_update_smc_flag VARCHAR2(1) := 'N';
6389
6390 l_flag boolean := FALSE;
6391
6392 l_ship_method_code VARCHAR2(32767);
6393 --
6394 l_debug_on BOOLEAN;
6395 --
6396 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'UPDATE_STATUS';
6397 l_wf_rs VARCHAR2(1); --Pick to POD WF Project
6398 --
6399 BEGIN
6400 --
6401 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
6402 --
6403 IF l_debug_on IS NULL
6404 THEN
6405 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
6406 END IF;
6407 --
6408 --
6409 -- Debug Statements
6410 --
6411 IF l_debug_on THEN
6412 WSH_DEBUG_SV.push(l_module_name);
6413 WSH_DEBUG_SV.log(l_module_name,'p_action_prms.action_code',p_action_prms.action_code);
6414 WSH_DEBUG_SV.log(l_module_name,'p_del_ids.COUNT',p_del_ids.COUNT);
6415 WSH_DEBUG_SV.log(l_module_name,'p_trip_ids.COUNT',p_trip_ids.COUNT);
6416 WSH_DEBUG_SV.log(l_module_name,'p_stop_ids.COUNT',p_stop_ids.COUNT);
6417 WSH_DEBUG_SV.log(l_module_name,'p_shipment_header_id_tab.COUNT',p_shipment_header_id_tab.COUNT);
6418 WSH_DEBUG_SV.log(l_module_name,'p_initial_pickup_date_tab.COUNT',p_initial_pickup_date_tab.COUNT);
6419 WSH_DEBUG_SV.log(l_module_name,'p_expected_receipt_date_tab.COUNT',p_expected_receipt_date_tab.COUNT);
6420 WSH_DEBUG_SV.log(l_module_name,'p_rcv_carrier_id_tab.COUNT',p_rcv_carrier_id_tab.COUNT);
6421 END IF;
6422 --
6423 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
6424 SAVEPOINT UPDATE_STATUS_PVT;
6425
6426 IF p_del_ids.COUNT > 0 THEN
6427 FOR i IN 1..p_del_ids.COUNT LOOP
6428
6429 IF l_debug_on THEN
6430 WSH_DEBUG_SV.log(l_module_name,'p_del_ids(i)',p_del_ids(i));
6431 END IF;
6432 --
6433 IF ( p_action_prms.action_code IN ('ASN', 'RECEIPT')) THEN
6434 --{
6435 l_ship_method_code := NULL;
6436 l_update_smc_flag := NULL;
6437 IF (p_rcv_carrier_id_tab(i) is NOT NULL) THEN
6438 --{
6439 open l_carrier_csr(p_del_ids(i), p_rcv_carrier_id_tab(i));
6440 fetch l_carrier_csr into l_ship_method_code;
6441 close l_carrier_csr;
6442
6443 IF l_ship_method_code IS NULL THEN
6444 l_update_smc_flag := 'Y';
6445 END IF;
6446 --}
6447 END IF;
6448 --}
6449 END IF;
6450
6451 IF p_action_prms.action_code ='ASN' THEN
6452
6453 IF l_debug_on THEN
6454 WSH_DEBUG_SV.log(l_module_name,'p_del_ids(i)',p_del_ids(i));
6455 WSH_DEBUG_SV.log(l_module_name,'p_shipment_header_id_tab(i)',p_shipment_header_id_tab(i));
6456 WSH_DEBUG_SV.log(l_module_name,'p_initial_pickup_date_tab(i)',p_initial_pickup_date_tab(i));
6457 END IF;
6458
6459 UPDATE WSH_NEW_DELIVERIES
6460 SET status_code = 'IT',
6461 ASN_SHIPMENT_HEADER_ID = p_shipment_header_id_tab(i),
6462 INITIAL_PICKUP_DATE = nvl(p_initial_pickup_date_tab(i),INITIAL_PICKUP_DATE),
6463 ULTIMATE_DROPOFF_DATE = GREATEST
6464 (
6465 nvl
6466 (
6467 p_initial_pickup_date_tab(i),
6468 nvl
6469 (
6470 INITIAL_PICKUP_DATE,
6474 nvl
6471 nvl(p_expected_receipt_date_tab(i),ULTIMATE_DROPOFF_DATE)
6472 )
6473 ),
6475 (
6476 p_expected_receipt_date_tab(i),
6477 NVL
6478 (
6479 ULTIMATE_DROPOFF_DATE,
6480 NVL(p_initial_pickup_date_tab(i), INITIAL_PICKUP_DATE)
6481 )
6482 )
6483 ),
6484 carrier_id = nvl(p_rcv_carrier_id_tab(i), carrier_id),
6485 ship_method_code = decode(l_update_smc_flag, 'Y', NULL,nvl(l_ship_method_code, ship_method_code)),
6486 service_level = decode(l_update_smc_flag, 'Y', NULL,service_level),
6487 mode_of_transport = decode(l_update_smc_flag, 'Y', NULL,mode_of_transport),
6488 last_update_date = SYSDATE,
6489 last_updated_by = FND_GLOBAL.USER_ID,
6490 last_update_login = FND_GLOBAL.LOGIN_ID
6491 Where DELIVERY_ID = p_del_ids(i)
6492 RETURNING organization_id into l_organization_id ;
6493
6494 /*CURRENTLY NOT IN USE
6495 --Raise Event: Pick To Pod Workflow
6496 WSH_WF_STD.Raise_Event(
6497 p_entity_type => 'DELIVERY',
6498 p_entity_id => p_del_ids(i),
6499 p_event => 'oracle.apps.fte.delivery.ib.asnmatched' ,
6500 p_organization_id => l_organization_id ,
6501 x_return_status => l_wf_rs ) ;
6502 --Error Handling to be done in WSH_WF_STD.Raise_Event itself
6503 IF l_debug_on THEN
6504 WSH_DEBUG_SV.log(l_module_name,'Current Time is ',SYSDATE);
6505 WSH_DEBUG_SV.log(l_module_name,'Delivery ID is ', p_del_ids(i));
6506 WSH_DEBUG_SV.log(l_module_name,'Return Status After Calling WSH_WF_STD.Raise_Event',l_wf_rs);
6507 END IF;
6508 --Done Raise Event: Pick To Pod Workflow
6509 */
6510 ELSIF p_action_prms.action_code = 'CANCEL_ASN' or p_action_prms.action_code = 'REVERT_ASN' then
6511 UPDATE WSH_NEW_DELIVERIES
6512 SET status_code = 'OP',
6513 Asn_shipment_header_id = NULL,
6514 last_update_date = SYSDATE,
6515 last_updated_by = FND_GLOBAL.USER_ID,
6516 last_update_login = FND_GLOBAL.LOGIN_ID
6517 Where DELIVERY_ID = p_del_ids(i)
6518 RETURNING organization_id into l_organization_id ;
6519
6520 /*CURRENTLY NOT IN USE
6521 --Raise Event: Pick To Pod Workflow
6522 WSH_WF_STD.Raise_Event(
6523 p_entity_type => 'DELIVERY',
6524 p_entity_id => p_del_ids(i),
6525 p_event => 'oracle.apps.fte.delivery.ib.asnreverted' ,
6526 p_organization_id => l_organization_id ,
6527 x_return_status => l_wf_rs ) ;
6528 --Error Handling to be done in WSH_WF_STD.Raise_Event itself
6529 IF l_debug_on THEN
6530 WSH_DEBUG_SV.log(l_module_name,'Current Time is ',SYSDATE);
6531 WSH_DEBUG_SV.log(l_module_name,'Delivery ID is ', p_del_ids(i));
6532 WSH_DEBUG_SV.log(l_module_name,'Return Status After Calling WSH_WF_STD.Raise_Event',l_wf_rs);
6533 END IF;
6534 --Done Raise Event: Pick To Pod Workflow
6535 */
6536 ELSIF p_action_prms.action_code = 'RECEIPT' THEN
6537
6538 IF l_debug_on THEN
6539 WSH_DEBUG_SV.log(l_module_name,'p_del_ids(i)',p_del_ids(i));
6540 WSH_DEBUG_SV.log(l_module_name,'p_shipment_header_id_tab(i)',p_shipment_header_id_tab(i));
6541 WSH_DEBUG_SV.log(l_module_name,'p_expected_receipt_date_tab(i)',p_expected_receipt_date_tab(i));
6542 END IF;
6543
6544 UPDATE WSH_NEW_DELIVERIES
6545 SET status_code = 'CL',
6546 RCV_SHIPMENT_HEADER_ID = p_shipment_header_id_tab(i),
6547 --INITIAL_PICKUP_DATE = p_initial_pickup_date_tab(i),
6548 --INITIAL_PICKUP_DATE = nvl(p_initial_pickup_date_tab(i),INITIAL_PICKUP_DATE),
6549 --ULTIMATE_DROPOFF_DATE = GREATEST(nvl(p_initial_pickup_date_tab(i),nvl(INITIAL_PICKUP_DATE, nvl(p_expected_receipt_date_tab(i),ULTIMATE_DROPOFF_DATE))),
6550 --nvl(p_expected_receipt_date_tab(i),ULTIMATE_DROPOFF_DATE)),
6551 INITIAL_PICKUP_DATE =
6552 LEAST
6553 (
6554 nvl
6555 (
6556 p_initial_pickup_date_tab(i),
6557 nvl
6558 (
6559 INITIAL_PICKUP_DATE,
6560 nvl(p_expected_receipt_date_tab(i),ULTIMATE_DROPOFF_DATE)
6561 )
6562 ),
6563 nvl
6564 (
6565 p_expected_receipt_date_tab(i),
6566 NVL
6567 (
6568 ULTIMATE_DROPOFF_DATE,
6569 NVL(p_initial_pickup_date_tab(i), INITIAL_PICKUP_DATE)
6570 )
6571 )
6572 ),
6573 ULTIMATE_DROPOFF_DATE = NVL
6574 (
6578 ULTIMATE_DROPOFF_DATE,
6575 p_expected_receipt_date_tab(i),
6576 NVL
6577 (
6579 NVL(p_initial_pickup_date_tab(i), INITIAL_PICKUP_DATE)
6580 )
6581 ),
6582 carrier_id = nvl(p_rcv_carrier_id_tab(i), carrier_id),
6583 ship_method_code = decode(l_update_smc_flag, 'Y', NULL,nvl(l_ship_method_code, ship_method_code)),
6584 service_level = decode(l_update_smc_flag, 'Y', NULL,service_level),
6585 mode_of_transport = decode(l_update_smc_flag, 'Y', NULL,mode_of_transport),
6586 last_update_date = SYSDATE,
6587 last_updated_by = FND_GLOBAL.USER_ID,
6588 last_update_login = FND_GLOBAL.LOGIN_ID
6589 Where DELIVERY_ID = p_del_ids(i)
6590 RETURNING organization_id into l_organization_id ;
6591
6592 /*CURRENTLY NOT IN USE
6593 --Raise Event: Pick To Pod Workflow
6594 WSH_WF_STD.Raise_Event(
6595 p_entity_type => 'DELIVERY',
6596 p_entity_id => p_del_ids(i),
6597 p_event => 'oracle.apps.fte.delivery.ib.receiptreceived' ,
6598 p_organization_id => l_organization_id ,
6599 x_return_status => l_wf_rs ) ;
6600 --Error Handling to be done in WSH_WF_STD.Raise_Event itself
6601 IF l_debug_on THEN
6602 WSH_DEBUG_SV.log(l_module_name,'Current Time is ',SYSDATE);
6603 WSH_DEBUG_SV.log(l_module_name,'Delivery ID is ', p_del_ids(i));
6604 WSH_DEBUG_SV.log(l_module_name,'Return Status After Calling WSH_WF_STD.Raise_Event',l_wf_rs);
6605 END IF;
6606 --Done Raise Event: Pick To Pod Workflow
6607 */
6608
6609 END IF;
6610 END LOOP;
6611
6612 l_flag := FALSE;
6613
6614 IF (p_del_ids.COUNT = 1 AND(p_action_prms.action_code ='ASN' OR p_action_prms.action_code ='RECEIPT')
6615 AND
6616 (p_local_dd_rec(p_local_dd_rec.FIRST).rcv_gross_weight IS NOT NULL
6617 AND p_local_dd_rec(p_local_dd_rec.FIRST).rcv_net_weight IS NOT NULL
6618 AND p_local_dd_rec(p_local_dd_rec.FIRST).rcv_gross_weight_uom_code IS NOT NULL
6619 )
6620 )
6621 THEN
6622 l_flag := TRUE;
6623 --
6624 -- Debug Statements
6625 --
6626 IF l_debug_on THEN
6627 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_NEW_DELIVERIES_PVT.POPULATE_RECORD',WSH_DEBUG_SV.C_PROC_LEVEL);
6628 END IF;
6629 --
6630 WSH_NEW_DELIVERIES_PVT.Populate_Record
6631 (p_delivery_id => p_del_ids(p_del_ids.FIRST),
6632 x_delivery_info => l_delivery_info,
6633 x_return_status => l_return_status);
6634 --
6635 -- Debug Statements
6636 --
6637 IF l_debug_on THEN
6638 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
6639 END IF;
6640 --
6641 wsh_util_core.api_post_call(
6642 p_return_status => l_return_status,
6643 x_num_warnings => l_num_warnings,
6644 x_num_errors => l_num_errors);
6645
6646 l_delivery_info.gross_weight := p_local_dd_rec(p_local_dd_rec.FIRST).rcv_gross_weight ;
6647 l_delivery_info.net_weight := p_local_dd_rec(p_local_dd_rec.FIRST).rcv_net_weight;
6648 l_delivery_info.WEIGHT_UOM_CODE := p_local_dd_rec(p_local_dd_rec.FIRST).rcv_gross_weight_uom_code;
6649 l_delivery_info.PRORATE_WT_FLAG := 'Y'; --Set Prorate weight flag
6650 --
6651 -- Debug Statements
6652 --
6653 IF l_debug_on THEN
6654 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_NEW_DELIVERIES_PVT.UPDATE_DELIVERY',WSH_DEBUG_SV.C_PROC_LEVEL);
6655 END IF;
6656 --
6657 WSH_NEW_DELIVERIES_PVT.Update_Delivery
6658 (p_rowid => l_delivery_info.ROWID,
6659 p_delivery_info => l_delivery_info,
6660 x_return_status => l_return_status);
6661 --
6662 -- Debug Statements
6663 --
6664 IF l_debug_on THEN
6665 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
6666 END IF;
6667 --
6668 wsh_util_core.api_post_call(
6669 p_return_status => l_return_status,
6670 x_num_warnings => l_num_warnings,
6671 x_num_errors => l_num_errors);
6672
6673 END IF;
6674 --
6675 --
6676 --{ --NNP-WV
6677 IF l_debug_on THEN
6678 WSH_DEBUG_SV.log(l_module_name,'l_flag',l_flag);
6679 END IF;
6680
6681 IF ( NOT(l_flag) AND(p_action_prms.action_code ='ASN' OR p_action_prms.action_code ='RECEIPT') )
6682 THEN
6683 --{
6684 IF l_debug_on THEN
6685 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_ASN_RECEIPT_PVT.updateWeightVolume',WSH_DEBUG_SV.C_PROC_LEVEL);
6686 END IF;
6687 --
6688 --
6689 WSH_ASN_RECEIPT_PVT.updateWeightVolume
6690 (
6691 p_entity => 'DLVY',
6692 x_GWTcachetbl => x_dlvyGWTcachetbl,
6693 x_GWTcacheExttbl => x_dlvyGWTcacheExttbl,
6694 x_NWTcachetbl => x_dlvyNWTcachetbl,
6695 x_NWTcacheExttbl => x_dlvyNWTcacheExttbl,
6699 );
6696 x_VOLcachetbl => x_dlvyVOLcachetbl,
6697 x_VOLcacheExttbl => x_dlvyVOLcacheExttbl,
6698 x_return_status => l_return_status
6700 --
6701 IF l_debug_on THEN
6702 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
6703 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
6704 END IF;
6705 --
6706 wsh_util_core.api_post_call
6707 (
6708 p_return_status => l_return_status,
6709 x_num_warnings => l_num_warnings,
6710 x_num_errors => l_num_errors
6711 );
6712 --
6713 IF l_debug_on THEN
6714 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_ASN_RECEIPT_PVT.updateWeightVolume',WSH_DEBUG_SV.C_PROC_LEVEL);
6715 END IF;
6716 --
6717 --
6718 WSH_ASN_RECEIPT_PVT.updateWeightVolume
6719 (
6720 p_entity => 'LPN',
6721 x_GWTcachetbl => x_LPNGWTcachetbl,
6722 x_GWTcacheExttbl => x_LPNGWTcacheExttbl,
6723 x_NWTcachetbl => x_LPNNWTcachetbl,
6724 x_NWTcacheExttbl => x_LPNNWTcacheExttbl,
6725 x_VOLcachetbl => x_LPNVOLcachetbl,
6726 x_VOLcacheExttbl => x_LPNVOLcacheExttbl,
6727 x_return_status => l_return_status
6728 );
6729 --
6730 IF l_debug_on THEN
6731 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
6732 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
6733 END IF;
6734 --
6735 wsh_util_core.api_post_call
6736 (
6737 p_return_status => l_return_status,
6738 x_num_warnings => l_num_warnings,
6739 x_num_errors => l_num_errors
6740 );
6741 --
6742 --}
6743 END IF;
6744 --}
6745
6746 END IF;
6747
6748 --
6749 -- Debug Statements
6750 --
6751 IF l_debug_on THEN
6752 WSH_DEBUG_SV.pop(l_module_name);
6753 END IF;
6754 --
6755 IF l_num_errors > 0 THEN
6756 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6757 ELSIF l_num_warnings > 0 THEN
6758 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
6759 END IF;
6760
6761
6762 EXCEPTION
6763 WHEN OTHERS THEN
6764 ROLLBACK TO UPDATE_STATUS_PVT;
6765 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
6766 WSH_UTIL_CORE.Default_Handler('WSH_ASN_RECEIPT_PVT.UPDATE_STATUS',l_module_name);
6767
6768 --
6769 -- Debug Statements
6770 --
6771 IF l_debug_on THEN
6772 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
6773 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
6774 END IF;
6775 --
6776 END Update_status;
6777
6778
6779 -- Start of comments
6780 -- API name : consolidate_qty
6781 -- Type : Public
6782 -- Pre-reqs : None.
6783 -- Function : This API consolidates (aggregates) the quantity pertaining to
6784 -- each unique shipment line ID.
6785 -- Parameters :
6786 -- IN:
6787 -- po_shipment_line_id IN NUMBER
6788 -- The Shipment line ID based on which the quantities are consolidated
6789 -- against.
6790 -- IN OUT:
6791 -- p_sli_qty_cache IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
6792 -- A key-value mapping table.The key is the input parameter po_shipment_line_id
6793 -- and the value is the sum of the values of the input parameter p_remaining_qty
6794 -- corresponding to that po_shipment_line_id. Values are stored in this table
6795 -- only if the key value is <= (2^31 -1).
6796 -- p_sli_qty_ext_cache IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
6797 -- A key-value mapping table.The key is the input parameter po_shipment_line_id
6798 -- and the value is the sum of the values of the input parameter p_remaining_qty
6799 -- corresponding to that po_shipment_line_id. Values are stored in this table
6800 -- only if the key value is > (2^31 -1).
6801 -- p_remaining_qty IN OUT NOCOPY NUMBER
6802 -- The quantity to be consilidated against the given po_shipment_line_id.
6803 -- OUT:
6804 -- x_return_status OUT NOCOPY VARCHAR2
6805 --Cache Tables:
6806 -- ----------------------------------------------------------------------
6807 -- | Cache Table Name | Key | Value |
6808 -- ----------------------------------------------------------------------
6809 -- |p_sli_qty_cache | Shipment Line ID | Quantity |
6810 -- |p_sli_qty_ext_cache | Shipment Line ID | Quantity |
6811 -- |----------------------------------------------------------------------
6812 -- Version : 1.0
6813 -- Previous version 1.0
6814 -- Initial version 1.0
6815 -- End of comments
6816
6817
6818 PROCEDURE consolidate_qty(
6819 p_sli_qty_cache IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
6820 p_sli_qty_ext_cache IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
6824
6821 p_remaining_qty IN OUT NOCOPY NUMBER,
6822 po_shipment_line_id IN NUMBER,
6823 x_return_status OUT NOCOPY VARCHAR2) IS
6825 l_new_qty NUMBER;
6826 l_return_status VARCHAR2(1);
6827 l_num_warnings NUMBER;
6828 l_num_errors NUMBER;
6829 --
6830 l_debug_on BOOLEAN;
6831 --
6832 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'CONSOLIDATE_QTY';
6833 --
6834 BEGIN
6835
6836 --
6837 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
6838 --
6839 IF l_debug_on IS NULL
6840 THEN
6841 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
6842 END IF;
6843 --
6844 --
6845 -- Debug Statements
6846 --
6847 IF l_debug_on THEN
6848 WSH_DEBUG_SV.push(l_module_name);
6849 --
6850 WSH_DEBUG_SV.log(l_module_name,'P_REMAINING_QTY',P_REMAINING_QTY);
6851 WSH_DEBUG_SV.log(l_module_name,'PO_SHIPMENT_LINE_ID',PO_SHIPMENT_LINE_ID);
6852 WSH_DEBUG_SV.log(l_module_name,'p_sli_qty_cache.count',p_sli_qty_cache.count);
6853 WSH_DEBUG_SV.log(l_module_name,'p_sli_qty_ext_cache.count',p_sli_qty_ext_cache.count);
6854 END IF;
6855 --
6856 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
6857 l_new_qty := p_remaining_qty;
6858
6859 --
6860 -- Debug Statements
6861 --
6862 IF l_debug_on THEN
6863 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_CACHED_VALUE-p_sli_qty_cache',WSH_DEBUG_SV.C_PROC_LEVEL);
6864 END IF;
6865 --
6866 wsh_util_core.get_cached_value(
6867 p_cache_tbl => p_sli_qty_cache,
6868 p_cache_ext_tbl => p_sli_qty_ext_cache,
6869 p_value => p_remaining_qty,
6870 p_key => po_shipment_line_id,
6871 p_action => 'GET',
6872 x_return_status => l_return_status );
6873
6874 IF l_debug_on THEN
6875 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
6876 WSH_DEBUG_SV.log(l_module_name,'after get-p_remaining_qty',p_remaining_qty);
6877 END IF;
6878 --
6879
6880 --MEANS THE PO_LINE_LOCATION_ID IS NOT THERE IN THE CACHE
6881 --SO ADD IT TO THE CACHE WITH THE NEW QTY AS
6882 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_WARNING THEN
6883 p_remaining_qty := l_new_qty;
6884
6885 --MEANS THE PO_LINE_LOCATION_ID IS ALREADY THERE.SO GET THE QTY(which is now available
6886 --in the p_remaining_qty) ...AND ADD THE NEW QTY
6887 --TO IT..AND ADD THE CONSILADTED QTY BACK TO THE CACHE FOR THIS PO_LINE_LOCATION_ID
6888 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
6889 p_remaining_qty := p_remaining_qty + l_new_qty;
6890 ElSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
6891 raise FND_API.G_EXC_ERROR;
6892 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
6893 raise FND_API.G_EXC_UNEXPECTED_ERROR;
6894 END IF;
6895
6896 IF l_debug_on THEN
6897 WSH_DEBUG_SV.log(l_module_name,'final-p_remaining_qty',p_remaining_qty);
6898 END IF;
6899 --
6900 --
6901 -- Debug Statements
6902 --
6903 IF l_debug_on THEN
6904 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_CACHED_VALUE-p_sli_qty_cache',WSH_DEBUG_SV.C_PROC_LEVEL);
6905 END IF;
6906 --
6907 wsh_util_core.get_cached_value(
6908 p_cache_tbl => p_sli_qty_cache,
6909 p_cache_ext_tbl => p_sli_qty_ext_cache,
6910 p_value => p_remaining_qty,
6911 p_key => po_shipment_line_id,
6912 p_action => 'PUT',
6913 x_return_status => l_return_status );
6914
6915 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
6916 raise FND_API.G_EXC_ERROR;
6917 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR -- Added by NPARIKH
6918 THEN
6919 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6920 END IF;
6921
6922
6923
6924 IF l_debug_on THEN
6925 WSH_DEBUG_SV.pop(l_module_name);
6926 END IF;
6927 --
6928 IF l_num_errors > 0 THEN
6929 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6930 ELSIF l_num_warnings > 0 THEN
6931 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
6932 END IF;
6933
6934
6935 EXCEPTION
6936 WHEN OTHERS THEN
6937 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6938 WSH_UTIL_CORE.Default_Handler('WSH_ASN_RECEIPT_PVT.CONSOLIDATE_QTY',l_module_name);
6939
6940 --
6941 -- Debug Statements
6942 --
6943 IF l_debug_on THEN
6944 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
6945 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
6946 END IF;
6947 --
6948 END consolidate_qty;
6949
6950
6951
6952 -- Start of comments
6953 -- API name : populate_update_dd_rec
6954 -- Type : Public
6955 -- Pre-reqs : None.
6956 -- Function : This API is used to populate the o/p paramater l_update_dd_rec (table of records)
6957 -- which is used for the bulk updates at final stages of process_matched_txns API.
6958 -- It derives the information for a particular delivery Detail ID
6959 -- corresponding to the records pointed by the i/p parameter p_index
6960 -- from the other i/p parameters p_line_rec and p_dd_rec. The API also finds out whether
6961 -- the corresponding Delivery detail ID has an LPN.If it has an LPN
6962 -- then it gets the information about that line also and updates the same
6963 -- into a new record of l_update_dd_rec.
6964 -- Parameters:
6965 -- IN:
6966 -- p_index IN NUMBER
6970 -- It contains a record for each delivery detail line.
6967 -- The position of the record of p_dd_rec upon which this API has been called.
6968 -- p_line_rec IN OE_WSH_BULK_GRP.line_rec_type
6969 -- A table of records which contains all information got from the PO side.
6971 -- p_gross_weight IN NUMBER DEFAULT NULL
6972 -- p_net_weight IN NUMBER DEFAULT NULL
6973 -- p_volume IN NUMBER DEFAULT NULL
6974 -- x_release_status IN VARCHAR2
6975 -- IN OUT:
6976 -- p_dd_rec IN OUT NOCOPY WSH_IB_UI_RECON_GRP.asn_rcv_del_det_rec_type
6977 -- A table of records used only within this package.It gets its data
6978 -- from the record structure p_line_rec and also from other API calls
6979 -- made from the API process_matched_txns of this Package.
6980 -- l_update_dd_rec IN OUT NOCOPY update_dd_rec_type
6981 -- x_lpnIdCacheTbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
6982 -- x_lpnIdCacheExtTbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type
6983 -- OUT:
6984 -- x_return_status OUT NOCOPY VARCHAR2
6985 --Cache Tables:
6986 -- ----------------------------------------------------------------------
6987 -- | Cache Table Name | Key | Value |
6988 -- ----------------------------------------------------------------------
6989 -- |x_lpnIdCacheTbl | LPN ID | LPN ID |
6990 -- |x_lpnIdCacheExtTbl | LPN ID | LPN ID |
6991 -- -----------------------------------------------------------------------
6992 -- Version : 1.0
6993 -- Previous version 1.0
6994 -- Initial version 1.0
6995 -- End of comments
6996
6997
6998
6999 Procedure populate_update_dd_rec(
7000 p_dd_rec IN OUT NOCOPY WSH_IB_UI_RECON_GRP.asn_rcv_del_det_rec_type,
7001 p_index IN NUMBER,
7002 p_line_rec IN OE_WSH_BULK_GRP.line_rec_type,
7003 p_gross_weight IN NUMBER DEFAULT NULL,
7004 p_net_weight IN NUMBER DEFAULT NULL,
7005 p_volume IN NUMBER DEFAULT NULL,
7006 x_release_status IN VARCHAR2,
7007 l_update_dd_rec IN OUT NOCOPY update_dd_rec_type,
7008 x_lpnIdCacheTbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
7009 x_lpnIdCacheExtTbl IN OUT NOCOPY WSH_UTIL_CORE.key_value_tab_type,
7010 x_return_status OUT NOCOPY VARCHAR2
7011 )
7012
7013 IS
7014
7015 i NUMBER;
7016 l_index NUMBER ;
7017 l_return_status VARCHAR2(1);
7018 l_shp_rcv_qty NUMBER;
7019 l_shp_rcv_qty2 NUMBER;
7020 l_num_warnings NUMBER := 0;
7021 l_num_errors NUMBER := 0;
7022
7023 CURSOR lpn_csr(p_delivery_detail_id IN NUMBER)
7024 IS
7025 SELECT parent_delivery_detail_id, wdd.last_update_date
7026 FROM wsh_delivery_assignments_v wda, wsh_delivery_details wdd
7027 WHERE wda.delivery_detail_id = p_delivery_detail_id
7028 AND wdd.delivery_detail_id = wda.parent_delivery_detail_id;
7029 --
7030 l_lpn_id NUMBER;
7031 l_lpn_last_update_date DATE;
7032 --
7033 l_debug_on BOOLEAN;
7034 --
7035 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'POPULATE_UPDATE_DD_REC';
7036 --
7037 BEGIN
7038
7039 --
7040 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
7041 --
7042 IF l_debug_on IS NULL
7043 THEN
7044 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
7045 END IF;
7046 --
7047 --
7048 -- Debug Statements
7049 --
7050 IF l_debug_on THEN
7051 WSH_DEBUG_SV.push(l_module_name);
7052 --
7053 WSH_DEBUG_SV.log(l_module_name,'P_INDEX',P_INDEX);
7054 WSH_DEBUG_SV.log(l_module_name,'P_gross_weight',P_gross_weight);
7055 WSH_DEBUG_SV.log(l_module_name,'P_net_weight',P_net_weight);
7056 WSH_DEBUG_SV.log(l_module_name,'P_volume',P_volume);
7057 WSH_DEBUG_SV.log(l_module_name,'X_RELEASE_STATUS',X_RELEASE_STATUS);
7058 WSH_DEBUG_SV.log(l_module_name,'l_update_dd_rec.delivery_detail_id.COUNT',l_update_dd_rec.delivery_detail_id.COUNT);
7059 END IF;
7060 --
7061 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
7062
7063 i:= (l_update_dd_rec.delivery_detail_id.COUNT)+1;
7064 l_index := p_dd_rec.shpmt_line_id_idx_tab(p_index);
7065
7066 l_update_dd_rec.delivery_detail_id.EXTEND;
7067 l_update_dd_rec.requested_quantity.EXTEND;
7068 l_update_dd_rec.shipped_quantity.EXTEND;
7069 l_update_dd_rec.returned_quantity.EXTEND;
7070 l_update_dd_rec.received_quantity.EXTEND;
7071 l_update_dd_rec.requested_quantity2.EXTEND;
7072 l_update_dd_rec.shipped_quantity2.EXTEND;
7073 l_update_dd_rec.returned_quantity2.EXTEND;
7074 l_update_dd_rec.received_quantity2.EXTEND;
7075 l_update_dd_rec.inventory_item_id.EXTEND;
7076 l_update_dd_rec.ship_from_location_id.EXTEND;
7077 l_update_dd_rec.item_description.EXTEND;
7078 l_update_dd_rec.released_status.EXTEND;
7079 l_update_dd_rec.rcv_shipment_line_id.EXTEND;
7080 l_update_dd_rec.waybill_num.EXTEND;
7081 l_update_dd_rec.released_status_db.EXTEND;
7082 l_update_dd_rec.gross_weight.EXTEND;
7083 l_update_dd_rec.net_weight.EXTEND;
7084 l_update_dd_rec.volume.EXTEND;
7085 l_update_dd_rec.last_update_date.EXTEND;
7086 l_update_dd_rec.shipped_date.EXTEND;
7087
7088 IF p_dd_rec.transaction_type = 'ASN' THEN
7089 l_shp_rcv_qty := p_dd_rec.shipped_qty_tab(p_index);
7090 l_shp_rcv_qty2 := p_dd_rec.shipped_qty2_tab(p_index); -- NNP
7091 ELSIF p_dd_rec.transaction_type = 'RECEIPT' THEN
7095
7092 l_shp_rcv_qty := p_dd_rec.received_qty_tab(p_index);
7093 l_shp_rcv_qty2 := p_dd_rec.received_qty2_tab(p_index); -- NNP
7094 END IF;
7096 IF l_debug_on THEN
7097 WSH_DEBUG_SV.log(l_module_name,'l_shp_rcv_quantity',l_shp_rcv_qty);
7098 WSH_DEBUG_SV.log(l_module_name,'l_shp_rcv_quantity2',l_shp_rcv_qty2);
7099 WSH_DEBUG_SV.log(l_module_name,'p_dd_rec.requested_qty_tab(p_index)',p_dd_rec.requested_qty_tab(p_index));
7100 WSH_DEBUG_SV.log(l_module_name,'p_dd_rec.ship_from_location_id_tab(p_index)',p_dd_rec.ship_from_location_id_tab(p_index));
7101 WSH_DEBUG_SV.log(l_module_name,'p_dd_rec.last_update_date_tab(p_index)',p_dd_rec.last_update_date_tab(p_index));
7102 WSH_DEBUG_SV.log(l_module_name,'p_line_rec.shipped_date(l_index)',p_line_rec.shipped_date(l_index));
7103 END IF;
7104
7105 l_update_dd_rec.delivery_detail_id(i) := p_dd_rec.del_detail_id_tab(p_index);
7106 l_update_dd_rec.requested_quantity(i) := least(p_dd_rec.requested_qty_tab(p_index),l_shp_rcv_qty);
7107 l_update_dd_rec.shipped_quantity(i) := p_dd_rec.shipped_qty_tab(p_index);
7108 l_update_dd_rec.returned_quantity(i) := p_dd_rec.returned_qty_tab(p_index);
7109 l_update_dd_rec.received_quantity(i) := p_dd_rec.received_qty_tab(p_index);
7110 l_update_dd_rec.requested_quantity2(i) := least(p_dd_rec.requested_qty2_tab(p_index),l_shp_rcv_qty2); -- NNP
7111 l_update_dd_rec.shipped_quantity2(i) := p_dd_rec.shipped_qty2_tab(p_index);
7112 l_update_dd_rec.returned_quantity2(i) := p_dd_rec.returned_qty2_tab(p_index);
7113 l_update_dd_rec.received_quantity2(i) := p_dd_rec.received_qty2_tab(p_index);
7114 l_update_dd_rec.inventory_item_id(i) := nvl(p_line_rec.rcv_inventory_item_id(l_index),p_line_rec.inventory_item_id(l_index));
7115 l_update_dd_rec.item_description(i) := nvl(p_line_rec.rcv_item_description(l_index),p_line_rec.item_description(l_index));
7116 l_update_dd_rec.released_status(i) := x_release_status;
7117 l_update_dd_rec.rcv_shipment_line_id(i):= p_dd_rec.shipment_line_id_tab(p_index);
7118 l_update_dd_rec.ship_from_location_id(i):= p_dd_rec.ship_from_location_id_tab(p_index);
7119 l_update_dd_rec.waybill_num(i) := p_line_rec.tracking_number(l_index);
7120 l_update_dd_rec.released_status_db(i) := p_dd_rec.released_status_tab(p_index);
7121 l_update_dd_rec.gross_weight(i) := p_gross_weight;
7122 l_update_dd_rec.net_weight(i) := p_net_weight;
7123 l_update_dd_rec.volume(i) := p_volume;
7124 l_update_dd_rec.last_update_date(i) := p_dd_rec.last_update_date_tab(p_index);
7125 l_update_dd_rec.shipped_date(i) := p_line_rec.shipped_date(l_index);
7126
7127
7128 /* added by NNP for LPN */
7129
7130
7131 -- If true , then derive the information for the LPN corresponding to the delivery detail ID
7132 IF p_dd_rec.transaction_type = 'RECEIPT'
7133 THEN
7134 --{
7135 l_lpn_id := NULL;
7136 --
7137 OPEN lpn_csr (p_delivery_detail_id => l_update_dd_rec.delivery_detail_id(i) );
7138 --
7139 FETCH lpn_csr INTO l_lpn_id, l_lpn_last_update_date;
7140 --
7141 CLOSE lpn_csr;
7142 --
7143 IF l_debug_on THEN
7144 WSH_DEBUG_SV.log(l_module_name,'l_lpn_id',l_lpn_id);
7145 WSH_DEBUG_SV.log(l_module_name,'l_lpn_lasT_update_date',l_lpn_last_update_date);
7146 WSH_DEBUG_SV.log(l_module_name,'contents - WDD ID ',l_update_dd_rec.delivery_detail_id(i));
7147 END IF;
7148 --
7149
7150 --If true, it implies that the current delivery detail has an LPN associated with it.
7151 IF l_lpn_id IS NOT NULL
7152 THEN
7153 --{
7154 IF l_debug_on THEN
7155 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_CACHED_VALUE-x_lpnIdcacheTbl',WSH_DEBUG_SV.C_PROC_LEVEL);
7156 END IF;
7157 --
7158
7159 --Check whether the LPN is already there in the cache table. If the LPN is
7160 --not in the cache table, this API will return a warning.
7161 wsh_util_core.get_cached_value
7162 (
7163 p_cache_tbl => x_lpnIdcacheTbl,
7164 p_cache_ext_tbl => x_lpnIdcacheExtTbl,
7165 p_key => l_lpn_id,
7166 p_value => l_lpn_id,
7167 p_action => 'GET',
7168 x_return_status => l_return_status
7169 );
7170 --
7171 --
7172 IF l_debug_on THEN
7173 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
7174 END IF;
7175 --
7176 --
7177 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR
7178 THEN
7179 RAISE FND_API.G_EXC_ERROR;
7180 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR
7181 THEN
7182 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7183 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_WARNING
7184 THEN
7185 --{
7186 IF l_debug_on THEN
7187 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_CACHED_VALUE-x_cacheTbl',WSH_DEBUG_SV.C_PROC_LEVEL);
7188 END IF;
7189 --
7190
7191 --Add the LPN ID into this table as it is not existing till now.
7192 wsh_util_core.get_cached_value
7193 (
7194 p_cache_tbl => x_lpnIdcacheTbl,
7195 p_cache_ext_tbl => x_lpnIdcacheExtTbl,
7196 p_key => l_lpn_id,
7197 p_value => l_lpn_id,
7198 p_action => 'PUT',
7199 x_return_status => l_return_status
7200 );
7204 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
7201 --
7202 --
7203 IF l_debug_on THEN
7205 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
7206 END IF;
7207 --
7208 wsh_util_core.api_post_call
7209 (
7210 p_return_status => l_return_status,
7211 x_num_warnings => l_num_warnings,
7212 x_num_errors => l_num_errors
7213 );
7214 --
7215 i:= (l_update_dd_rec.delivery_detail_id.COUNT)+1;
7216 --
7217
7218 --updating the l_update_dd_rec with the details of the LPN ID.
7219
7220 l_update_dd_rec.delivery_detail_id.EXTEND;
7221 l_update_dd_rec.requested_quantity.EXTEND;
7222 l_update_dd_rec.shipped_quantity.EXTEND;
7223 l_update_dd_rec.returned_quantity.EXTEND;
7224 l_update_dd_rec.received_quantity.EXTEND;
7225 l_update_dd_rec.requested_quantity2.EXTEND;
7226 l_update_dd_rec.shipped_quantity2.EXTEND;
7227 l_update_dd_rec.returned_quantity2.EXTEND;
7228 l_update_dd_rec.received_quantity2.EXTEND;
7229 l_update_dd_rec.inventory_item_id.EXTEND;
7230 l_update_dd_rec.ship_from_location_id.EXTEND;
7231 l_update_dd_rec.item_description.EXTEND;
7232 l_update_dd_rec.released_status.EXTEND;
7233 l_update_dd_rec.rcv_shipment_line_id.EXTEND;
7234 l_update_dd_rec.waybill_num.EXTEND;
7235 l_update_dd_rec.released_status_db.EXTEND;
7236 l_update_dd_rec.gross_weight.EXTEND;
7237 l_update_dd_rec.net_weight.EXTEND;
7238 l_update_dd_rec.volume.EXTEND;
7239 l_update_dd_rec.last_update_date.EXTEND;
7240 l_update_dd_rec.shipped_date.EXTEND;
7241 --
7242 l_update_dd_rec.delivery_detail_id(i) := l_lpn_id;
7243 l_update_dd_rec.requested_quantity(i) := 1;
7244 l_update_dd_rec.shipped_quantity(i) := 1;
7245 l_update_dd_rec.returned_quantity(i) := NULL;
7246 l_update_dd_rec.received_quantity(i) := 1;
7247 l_update_dd_rec.requested_quantity2(i) := NULL;
7248 l_update_dd_rec.shipped_quantity2(i) := NULL;
7249 l_update_dd_rec.returned_quantity2(i) := NULL;
7250 l_update_dd_rec.received_quantity2(i) := NULL;
7251 l_update_dd_rec.inventory_item_id(i) := NULL;
7252 l_update_dd_rec.item_description(i) := NULL;
7253 l_update_dd_rec.released_status(i) := x_release_status;
7254 l_update_dd_rec.rcv_shipment_line_id(i):= p_dd_rec.shipment_line_id_tab(p_index);
7255 l_update_dd_rec.ship_from_location_id(i):= p_dd_rec.ship_from_location_id_tab(p_index);
7256 l_update_dd_rec.waybill_num(i) := NULL;
7257 l_update_dd_rec.released_status_db(i) := 'C';
7258 l_update_dd_rec.gross_weight(i) := NULL;
7259 l_update_dd_rec.net_weight(i) := NULL;
7260 l_update_dd_rec.volume(i) := NULL;
7261 l_update_dd_rec.last_update_date(i) := l_lpn_last_update_date;
7262 l_update_dd_rec.shipped_date(i) := p_line_rec.shipped_date(l_index);
7263 --}
7264 END IF;
7265 --}
7266 END IF;
7267 --}
7268 END IF;
7269 --
7270 -- Debug Statements
7271 --
7272 IF l_debug_on THEN
7273 WSH_DEBUG_SV.pop(l_module_name);
7274 END IF;
7275 --
7276
7277 IF l_num_errors > 0 THEN
7278 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
7279 ELSIF l_num_warnings > 0 THEN
7280 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
7281 END IF;
7282
7283
7284 EXCEPTION
7285 WHEN OTHERS THEN
7286 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
7287 WSH_UTIL_CORE.Default_Handler('WSH_ASN_RECEIPT_PVT.POPULATE_UPDATE_DD_REC',l_module_name);
7288
7289 --
7290 -- Debug Statements
7291 --
7292 IF l_debug_on THEN
7293 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
7294 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
7295 END IF;
7296 --
7297
7298
7299 END populate_update_dd_rec;
7300
7301
7302
7303
7304 -- Start of comments
7305 -- API name : create_update_waybill_psno_bol
7306 -- Type : Public
7307 -- Pre-reqs : None.
7308 -- Function : This API creates/updates the waybill,PSNO or BOL for the
7309 -- current record of p_local_dd_rec being passed to this API.
7310 -- Parameters:
7311 -- IN:
7312 -- l_loop_index IN NUMBER
7313 -- The current record of the i/p parameter p_local_dd_rec .
7314 -- IN OUT:
7315 -- p_local_dd_rec IN OUT NOCOPY LOCAL_DD_REC_TABLE_TYPE
7316 -- A record structure which contains all...
7317 -- pack_ids IN OUT NOCOPY WSH_UTIL_CORE.id_tab_type
7318 -- Contains a list of delivery detail IDs which have a common LPN or no LPN.
7319 -- curr_del IN OUT NOCOPY NUMBER
7320 -- The current delivery upon which all the other input parameters depend on.
7321 -- curr_bol IN OUT NOCOPY VARCHAR2
7322 -- The BOL corresponding to the Delivery leg id of the delivery specified in the
7326 -- in the input parameter curr_del.
7323 -- input parameter curr_del.
7324 -- curr_lpn IN OUT NOCOPY NUMBER
7325 -- The LPN corresponding to the list of delivery detail IDs of the delivery specified
7327 -- curr_lpn_name IN OUT NOCOPY VARCHAR2
7328 -- curr_del_det IN OUT NOCOPY NUMBER
7329 -- l_psno IN OUT NOCOPY VARCHAR2
7330 -- The packing slip number corresponding to the delivery specified in the input parameter
7331 -- curr_del.
7332 -- l_waybill IN OUT NOCOPY VARCHAR2
7333 -- The waybill number corresponding to the delivery specified in the input parameter
7334 -- curr_del.
7335 -- l_psno_flag IN OUT NOCOPY NUMBER
7336 -- Can take the value 0 or 1.
7337 -- If the value is 0, it means that the Packing Slip # has remained the same for all
7338 -- those records of p_local_dd_rec which correspond to the current delivery.In this
7339 -- case the PSNO is updated against the delivery ID.
7340 -- If the value is 1, then the PSNO is updated as NULL for the current delivery.
7341 -- l_trigger IN OUT NOCOPY NUMBER
7342 -- Can take the value 0 or 1.
7343 -- If the value is 0, it means there is no need to create a
7344 -- new delivery based on the existing delivery.
7345 -- If the value is 1, it means a split has to be done for the existing
7346 -- delivery and a new delivery has to be created and also the delivery details
7347 -- present in the input parameter pack_ids have to be re-assigned to this new
7348 -- delivery.
7349 -- l_waybill_flag IN OUT NOCOPY NUMBER
7350 -- Can take the value 0 or 1.
7351 -- If the value is 0, it means that the waybill # has remained the same for all those records
7352 -- of p_local_dd_rec which correspond to the current delivery.In this case the waybill
7353 -- is updated against the delivery ID.
7354 -- If the value is 1, then the waybill is updated as NULL for the current delivery.
7355 -- temp_dels IN OUT NOCOPY WSH_UTIL_CORE.id_tab_type
7356 -- Contains non-duplicate delivery IDs belonging to the record structure p_local_dd_rec
7357 -- This is a dynamic container and goes on adding until all the records of the structure
7358 -- are scanned.
7359 -- p_action_prms IN OUT NOCOPY WSH_GLBL_VAR_STRCT_GRP.dd_action_parameters_rec_type
7360 -- The Record which specifies the Caller,Action to Be performed and the transaction type etc.
7361 -- OUT:
7362 -- x_return_status OUT NOCOPY VARCHAR2
7363 -- Version : 1.0
7364 -- Previous version 1.0
7365 -- Initial version 1.0
7366 -- End of comments
7367
7368
7369 PROCEDURE create_update_waybill_psno_bol(
7370 p_local_dd_rec IN OUT NOCOPY LOCAL_DD_REC_TABLE_TYPE,
7371 l_loop_index IN NUMBER,
7372 pack_ids IN OUT NOCOPY WSH_UTIL_CORE.id_tab_type,
7373 curr_del IN OUT NOCOPY NUMBER,
7374 curr_bol IN OUT NOCOPY VARCHAR2,
7375 curr_lpn IN OUT NOCOPY NUMBER,
7376 curr_lpn_name IN OUT NOCOPY VARCHAR2,
7377 curr_del_det IN OUT NOCOPY NUMBER,
7378 l_psno IN OUT NOCOPY VARCHAR2,
7379 l_waybill IN OUT NOCOPY VARCHAR2,
7380 l_psno_flag IN OUT NOCOPY NUMBER,
7381 l_trigger IN OUT NOCOPY NUMBER,
7382 l_waybill_flag IN OUT NOCOPY NUMBER,
7383 temp_dels IN OUT NOCOPY WSH_UTIL_CORE.id_tab_type,
7384 p_action_prms IN OUT NOCOPY WSH_GLBL_VAR_STRCT_GRP.dd_action_parameters_rec_type,
7385 x_return_status OUT NOCOPY VARCHAR2
7386 )
7387 IS
7388
7389 --Cursor to get the Delivery Leg ID for a given Delivery.
7390 CURSOR get_delivery_info(p_delivery_id NUMBER) IS
7391 SELECT dg.delivery_leg_id
7392 FROM wsh_new_deliveries dl,
7393 wsh_delivery_legs dg,
7394 wsh_trip_stops st,
7395 wsh_trips t
7396 WHERE dl.delivery_id = p_delivery_id AND
7397 dl.delivery_id = dg.delivery_id AND
7398 dg.pick_up_stop_id = st.stop_id AND
7399 st.trip_id = t.trip_id;
7400
7401 --Cursor to get the last Delivery Leg ID for a given Delivery.
7402 CURSOR c_get_last_leg(p_delivery_id NUMBER) IS
7403 SELECT wdl.delivery_leg_id
7404 FROM wsh_new_deliveries wnd,
7405 wsh_delivery_legs wdl,
7406 wsh_trip_stops wts,
7407 wsh_trips wt
7408 WHERE wnd.delivery_id = p_delivery_id AND
7409 wnd.delivery_id = wdl.delivery_id AND
7410 wdl.drop_off_stop_id = wts.stop_id AND
7411 wnd.ultimate_dropoff_location_id = wts.stop_location_id AND
7412 wts.trip_id = wt.trip_id;
7413
7414 l_return_status VARCHAR2(1);
7415 l_pack_status VARCHAR2(1);
7416 l_stored_del_id NUMBER;
7417 l_delivery_leg_id NUMBER;
7418 l_num_warnings NUMBER;
7419 l_num_errors NUMBER;
7420 l_new_del_id NUMBER;
7421 l_final_del_leg_id NUMBER;
7422 --
7423 l_row_id NUMBER;
7424 l_leg_id_tab WSH_UTIL_CORE.id_tab_type;
7425 --
7426 l_debug_on BOOLEAN;
7427 --
7428 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'CREATE_UPDATE_WAYBILL_PSNO_BOL';
7429 --
7430 BEGIN
7431 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
7432 --
7433 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
7434 --
7435 IF l_debug_on IS NULL
7436 THEN
7437 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
7438 END IF;
7439 --
7440 --
7441 -- Debug Statements
7442 --
7443 IF l_debug_on THEN
7444 WSH_DEBUG_SV.push(l_module_name);
7445 --
7446 WSH_DEBUG_SV.log(l_module_name,'L_LOOP_INDEX',L_LOOP_INDEX);
7447 WSH_DEBUG_SV.log(l_module_name,'CURR_DEL',CURR_DEL);
7448 WSH_DEBUG_SV.log(l_module_name,'CURR_BOL',CURR_BOL);
7452 WSH_DEBUG_SV.log(l_module_name,'L_PSNO',L_PSNO);
7449 WSH_DEBUG_SV.log(l_module_name,'CURR_LPN',CURR_LPN);
7450 WSH_DEBUG_SV.log(l_module_name,'CURR_LPN_NAME',CURR_LPN_NAME);
7451 WSH_DEBUG_SV.log(l_module_name,'CURR_DEL_DET',CURR_DEL_DET);
7453 WSH_DEBUG_SV.log(l_module_name,'L_WAYBILL',L_WAYBILL);
7454 WSH_DEBUG_SV.log(l_module_name,'L_PSNO_FLAG',L_PSNO_FLAG);
7455 WSH_DEBUG_SV.log(l_module_name,'L_TRIGGER',L_TRIGGER);
7456 WSH_DEBUG_SV.log(l_module_name,'L_WAYBILL_FLAG',L_WAYBILL_FLAG);
7457 WSH_DEBUG_SV.log(l_module_name,'pack_ids.COUNT',pack_ids.COUNT);
7458 END IF;
7459 --
7460
7461
7462 --Pack the delivery detail IDs into a container and give the curr_lpn name
7463 --as the name for the container.
7464 IF curr_lpn IS NOT NULL THEN
7465 --{
7466 --
7467 -- Debug Statements
7468 --
7469 IF l_debug_on THEN
7470 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_CONTAINER_ACTIONS.PACK_INBOUND_LINES',WSH_DEBUG_SV.C_PROC_LEVEL);
7471 END IF;
7472 --
7473 --Call to API wsh_container_actions.pack_inbound_lines
7474 wsh_container_actions.pack_inbound_lines(
7475 p_lines_tbl => pack_ids ,
7476 p_lpn_id => curr_lpn ,
7477 p_lpn_name => curr_lpn_name ,
7478 p_delivery_id=> curr_del ,
7479 p_transactionType => p_action_prms.action_code,
7480 x_return_status => l_return_status,
7481 p_waybill_number => p_local_dd_rec(l_loop_index).waybill) ;
7482 --
7483 -- Debug Statements
7484 --
7485 IF l_debug_on THEN
7486 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
7487 END IF;
7488 --
7489 wsh_util_core.api_post_call(
7490 p_return_status => l_return_status,
7491 x_num_warnings => l_num_warnings,
7492 x_num_errors => l_num_errors);
7493 END IF;
7494 --}
7495
7496
7497
7498 --If the value of l_trigger is 1, it means a split has to be done for the existing
7499 --delivery and a new delivery has to be created and also the delivery details
7500 --present in the input parameter pack_ids have to be re-assigned to this newly created
7501 --delivery.
7502 IF l_trigger = 1 THEN
7503 --{
7504 --
7505 -- Debug Statements
7506 --
7507 IF l_debug_on THEN
7508 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INBOUND_UTIL_PKG.SPLIT_INBOUND_DELIVERY',WSH_DEBUG_SV.C_PROC_LEVEL);
7509 END IF;
7510 --
7511 --Call to API WSH_INBOUND_UTIL_PKG.split_inbound_delivery
7512 WSH_INBOUND_UTIL_PKG.split_inbound_delivery(
7513 p_delivery_detail_id_tbl => pack_ids,
7514 p_delivery_id => curr_del,
7515 x_delivery_id => l_new_del_id,
7516 x_return_status => l_return_status);
7517 --
7518 -- Debug Statements
7519 --
7520 IF l_debug_on THEN
7521 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
7522 END IF;
7523 --
7524 wsh_util_core.api_post_call(
7525 p_return_status => l_return_status,
7526 x_num_warnings => l_num_warnings,
7527 x_num_errors => l_num_errors);
7528
7529
7530 OPEN c_get_last_leg(l_new_del_id); --code changed to use the newly created Delivery ID
7531 FETCH c_get_last_leg
7532 INTO l_final_del_leg_id;
7533
7534 -- Create a new record in the table wsh_document_instances and update the record
7535 -- with the BOL number curr_bol for the current Delivery.
7536 IF (c_get_last_leg%FOUND) AND (curr_bol IS NOT NULL) THEN
7537
7538 IF l_debug_on THEN
7539 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_ASN_RECEIPT_PVT.CREATE_UPDATE_INBOUND_DOCUMENT ',WSH_DEBUG_SV.C_PROC_LEVEL);
7540 END IF;
7541
7542 --Call to API create_update_inbound_document
7543 create_update_inbound_document (
7544 p_document_number => curr_bol,
7545 p_entity_name => 'WSH_DELIVERY_LEGS',
7546 p_delivery_id => l_new_del_id, --code changed to use the newly created Delivery ID
7547 p_transaction_type => p_action_prms.action_code,
7548 x_return_status => l_return_status);
7549
7550 --
7551 -- Debug Statements
7552 --
7553 IF l_debug_on THEN
7554 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
7555 END IF;
7556 --
7557 wsh_util_core.api_post_call(
7558 p_return_status => l_return_status,
7559 x_num_warnings => l_num_warnings,
7560 x_num_errors => l_num_errors);
7561 END IF;
7562
7563 CLOSE c_get_last_leg;
7564 l_stored_del_id := l_new_del_id;
7565
7566
7567 -- The following Else part -> Set the BOL for the last leg of the current Delivery if a matching record
7568 -- is already existing in the table wsh_document_instances.
7569 ELSE -- corresponding to IF l_trigger = 1 THEN
7570 --} {
7571
7572 OPEN c_get_last_leg(curr_del);
7573 FETCH c_get_last_leg
7574 INTO l_final_del_leg_id;
7575
7576 IF c_get_last_leg%FOUND THEN
7577
7578 IF l_debug_on THEN
7579 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_ASN_RECEIPT_PVT.SYNCH_BOLS',WSH_DEBUG_SV.C_PROC_LEVEL);
7580 END IF;
7581
7582 --API to update/synch the BOL.
7586 p_action_prms => p_action_prms,
7583 synch_bols(
7584 p_del_id => curr_del,
7585 p_bol => curr_bol,
7587 x_return_status => l_return_status);
7588
7589 --
7590 -- Debug Statements
7591 --
7592 IF l_debug_on THEN
7593 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
7594 END IF;
7595 --
7596
7597 wsh_util_core.api_post_call(
7598 p_return_status => l_return_status,
7599 x_num_warnings => l_num_warnings,
7600 x_num_errors => l_num_errors);
7601
7602 END IF;
7603
7604 CLOSE c_get_last_leg;
7605
7606 --l_trigger is set to 1 because for the Delivery ID curr_del, the first set of Detail lines having the same
7607 --BOL have been processed.
7608 l_trigger := 1;
7609 l_stored_del_id := curr_del;
7610 END IF;
7611
7612 temp_dels(temp_dels.COUNT + 1) := l_stored_del_id;
7613 pack_ids.delete;
7614 pack_ids(pack_ids.count + 1) := p_local_dd_rec(l_loop_index).del_detail_id;
7615
7616
7617 -- Update the Packing Slip number for the current delivery after checking
7618 -- for the existence of a matching record in wsh_document_instances.
7619 -- If there is no matching record insert a new record using the
7620 -- API WSH_ASN_RECEIPT_PVT.CREATE_UPDATE_INBOUND_DOCUMENT.
7621 IF ((l_psno_flag = 0) AND (l_psno IS NOT NULL) ) THEN
7622 UPDATE wsh_document_instances
7623 SET
7624 sequence_number = l_psno,
7625 last_update_date = SYSDATE,
7626 last_updated_by = FND_GLOBAL.USER_ID,
7627 last_update_login = FND_GLOBAL.LOGIN_ID
7628 where
7629 entity_id = l_stored_del_id
7630 AND entity_name = 'WSH_NEW_DELIVERIES'
7631 AND document_type= 'PACK_TYPE';
7632
7633
7634 IF SQL%NOTFOUND THEN
7635
7636 IF l_debug_on THEN
7637 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_ASN_RECEIPT_PVT.CREATE_UPDATE_INBOUND_DOCUMENT',WSH_DEBUG_SV.C_PROC_LEVEL);
7638 END IF;
7639
7640 create_update_inbound_document (
7641 p_document_number => l_psno,
7642 p_entity_name => 'WSH_NEW_DELIVERIES',
7643 p_delivery_id => l_stored_del_id,
7644 p_transaction_type => p_action_prms.action_code,
7645 x_return_status => l_return_status);
7646
7647 --
7648 -- Debug Statements
7649 --
7650 IF l_debug_on THEN
7651 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
7652 END IF;
7653 --
7654 wsh_util_core.api_post_call(
7655 p_return_status => l_return_status,
7656 x_num_warnings => l_num_warnings,
7657 x_num_errors => l_num_errors);
7658 END IF;
7659 END IF;
7660
7661
7662 -- Update the Packing Slip number for the current delivery iff
7663 -- the waybill has not changed within the lines belonging to the
7664 -- same delivery.
7665 IF ((l_waybill_flag = 0) AND (l_waybill IS NOT NULL) ) THEN
7666 UPDATE
7667 wsh_new_deliveries
7668 SET
7669 waybill = l_waybill,
7670 last_update_date = SYSDATE,
7671 last_updated_by = FND_GLOBAL.USER_ID,
7672 last_update_login = FND_GLOBAL.LOGIN_ID
7673 WHERE
7674 delivery_id = l_stored_del_id;
7675 END IF;
7676
7677 --Reset the Flags.
7678 l_psno_flag := 0;
7679 l_waybill_flag := 0;
7680
7681 curr_del := p_local_dd_rec(l_loop_index).delivery_id;
7682 curr_BOL := p_local_dd_rec(l_loop_index).BOL;
7683 curr_lpn := p_local_dd_rec(l_loop_index).lpn_id;
7684 curr_lpn_name := p_local_dd_rec(l_loop_index).lpn_name;
7685 curr_del_det := p_local_dd_rec(1).del_detail_id;
7686 l_psno := p_local_dd_rec(l_loop_index).psno;
7687 l_waybill:= p_local_dd_rec(l_loop_index).waybill;
7688
7689 --
7690 -- Debug Statements
7691 --
7692 IF l_debug_on THEN
7693 WSH_DEBUG_SV.pop(l_module_name);
7694 END IF;
7695 --
7696 IF l_num_errors > 0 THEN
7697 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
7698 ELSIF l_num_warnings > 0 THEN
7699 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
7700 END IF;
7701
7702
7703 EXCEPTION
7704 WHEN FND_API.G_EXC_ERROR THEN
7705 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
7706 WSH_UTIL_CORE.ADD_MESSAGE(x_return_status,l_module_name);
7707
7708 --
7709 -- Debug Statements
7710 --
7711 IF l_debug_on THEN
7712 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
7713 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
7714 END IF;
7715 --
7716 WHEN OTHERS THEN
7717 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
7718 WSH_UTIL_CORE.Default_Handler('WSH_ASN_RECEIPT_PVT.create_update_waybill_psno_bol',l_module_name);
7719
7720 --
7721 -- Debug Statements
7722 --
7723 IF l_debug_on THEN
7724 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
7725 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
7726 END IF;
7727 --
7728 END create_update_waybill_psno_bol;
7729
7730
7731
7732
7733 -- Start of comments
7734 -- API name : create_update_inbound_document
7735 -- Type : Public
7736 -- Pre-reqs : None.
7737 -- Function : This API creates/updates documents like BOL,PSNO and waybill depending
7738 -- on whether they are already existing for the Delivery or not.
7739 -- Parameters :
7740 -- IN:
7741 -- p_document_number IN VARCHAR2
7742 -- This holds the PSNO/BOL depending upon the entity name.If the
7743 -- input p_entity_name is 'WSH_NEW_DELIVERIES', then this parameter holds PSNO.
7747 -- Specifies what kind of document is present in the input parameter
7744 -- If the input p_entity_name is 'WSH_DELIVERY_LEGS', then this parameter
7745 -- holds BOL.
7746 -- p_entity_name IN VARCHAR2
7748 -- p_document_number.
7749 -- p_delivery_id IN NUMBER
7750 -- p_transaction_type IN VARCHAR2
7751 -- Specifies the type od Transaction viz.ASN RECEIPT
7752 -- IN OUT:
7753 -- OUT:
7754 -- x_return_status OUT NOCOPY VARCHAR2
7755 -- Version : 1.0
7756 -- Previous version 1.0
7757 -- Initial version 1.0
7758 -- End of comments
7759
7760
7761 PROCEDURE create_update_inbound_document (
7762 p_document_number IN VARCHAR2,
7763 p_entity_name IN VARCHAR2,
7764 p_delivery_id IN NUMBER,
7765 p_transaction_type IN VARCHAR2,
7766 x_return_status OUT NOCOPY VARCHAR2) IS
7767
7768 --Cursor to get a Deliveries Leg ID,ship method Code etc.
7769 CURSOR get_delivery_info IS
7770 SELECT dg.delivery_leg_id,
7771 dl.initial_pickup_location_id,
7772 dl.ULTIMATE_DROPOFF_LOCATION_ID,
7773 t.ship_method_code,
7774 dl.organization_id,
7775 t.name
7776 FROM wsh_new_deliveries dl,
7777 wsh_delivery_legs dg,
7778 wsh_trip_stops st,
7779 wsh_trips t
7780 WHERE dl.delivery_id = p_delivery_id AND
7781 dl.delivery_id = dg.delivery_id AND
7782 dg.drop_off_stop_id = st.stop_id AND
7783 st.stop_location_id = dl.ULTIMATE_DROPOFF_LOCATION_ID AND
7784 st.trip_id = t.trip_id;
7785
7786 --Cursor to get the Ledger ID for the Organisation. -- LE Uptake
7787 CURSOR get_ledger_id (l_org_id NUMBER) IS --performance
7788 select to_number(ORG_INFORMATION1)
7789 from
7790 HR_ORGANIZATION_INFORMATION
7791 where
7792 ORGANIZATION_ID = l_org_id AND
7793 (ORG_INFORMATION_CONTEXT || '') ='Accounting Information';
7794
7795 --Cursor to get the Documents sequence .
7796 CURSOR get_doc_sequence_category_id(l_doc_type VARCHAR2) IS
7797 select doc_sequence_category_id
7798 from wsh_doc_sequence_categories
7799 where document_type = l_doc_type;
7800
7801 --Cursor to determine the existence of PSNO/BOL for the given Delivery ID and its last Leg.
7802 Cursor c_bol_psno_exists(l_ent_id NUMBER,l_ent_name VARCHAR2,l_doc_type VARCHAR2) is
7803 select
7804 '1'
7805 from
7806 wsh_document_instances wdi
7807 where
7808 wdi.entity_id = l_ent_id AND
7809 wdi.entity_name = l_ent_name AND
7810 wdi.document_type= l_doc_type;
7811
7812
7813 l_return_status varchar2(1);
7814 l_doc_sequence_category_id NUMBER;
7815 l_ledger_id NUMBER; -- LE Uptake
7816 l_delivery_leg_id NUMBER;
7817 l_pickup_location_id NUMBER;
7818 l_ultimate_dropoff_location_id NUMBER;
7819 l_location_id NUMBER;
7820 l_ship_method_code VARCHAR2(30);
7821 l_organization_id NUMBER;
7822 l_document_number VARCHAR2(50);
7823 l_pack_slip_flag VARCHAR2(1);
7824 l_trip_name VARCHAR2(50);
7825 x_msg_count NUMBER;
7826 x_msg_data VARCHAR2(2000);
7827 l_num_warnings NUMBER;
7828 l_num_errors NUMBER;
7829
7830 l_entity_id NUMBER;
7831 l_temp NUMBER;
7832 l_document_type VARCHAR2(30);
7833 l_document_sub_type VARCHAR2(30);
7834
7835 l_status VARCHAR2(25) := 'OPEN'; -- Bug 3761178
7836 l_appl_num NUMBER; --Bug# 3789154
7837 --
7838 l_debug_on BOOLEAN;
7839 --
7840 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'CREATE_UPDATE_INBOUND_DOCUMENT';
7841 --
7842 BEGIN
7843
7844
7845 x_return_status := wsh_util_core.g_ret_sts_success;
7846 --
7847 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
7848 --
7849 IF l_debug_on IS NULL
7850 THEN
7851 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
7852 END IF;
7853 --
7854 --
7855 -- Debug Statements
7856 --
7857 IF l_debug_on THEN
7858 WSH_DEBUG_SV.push(l_module_name);
7859 --
7860 WSH_DEBUG_SV.log(l_module_name,'P_DELIVERY_ID',p_delivery_id);
7861 WSH_DEBUG_SV.log(l_module_name,'P_DOCUMENT_NUMBER',p_document_number);
7862 WSH_DEBUG_SV.log(l_module_name,'p_entity_name',p_entity_name);
7863 WSH_DEBUG_SV.log(l_module_name,'p_transaction_type',p_transaction_type);
7864 END IF;
7865 --
7866
7867 OPEN get_delivery_info;
7868 FETCH get_delivery_info INTO l_delivery_leg_id,
7869 l_pickup_location_id,
7870 l_ultimate_dropoff_location_id,
7871 l_ship_method_code,
7872 l_organization_id,
7873 l_trip_name;
7874 CLOSE get_delivery_info;
7875
7876
7877
7878 -- LE Uptake
7879 OPEN get_ledger_id(l_organization_id);
7880 FETCH get_ledger_id INTO l_ledger_id;
7881
7882 IF (get_ledger_id%NOTFOUND) THEN
7883 FND_MESSAGE.SET_NAME('WSH','WSH_LEDGER_NOT_FOUND');
7884
7885
7886
7887 raise FND_API.G_EXC_ERROR;
7888 END IF;
7889
7890 CLOSE get_ledger_id;
7891
7892
7893 IF p_transaction_type = 'ASN' THEN
7894 l_location_id := l_pickup_location_id;
7895 ELSIF p_transaction_type = 'RECEIPT' THEN
7896 l_location_id := l_ultimate_dropoff_location_id;
7897 END IF;
7898
7899
7900
7901 IF p_entity_name = 'WSH_DELIVERY_LEGS' THEN
7902 l_document_type := 'BOL';
7903 l_document_sub_type := l_ship_method_code; -- l_document_sub_type used to retrive the prefix and suufix and docuemnt category type .which is not needed
7904 l_entity_id := l_delivery_leg_id;
7905
7906 ELSIF p_entity_name = 'WSH_NEW_DELIVERIES' THEN
7907 l_document_type := 'PACK_TYPE';
7908 l_document_sub_type := 'SALES_ORDER';
7909 l_entity_id := p_delivery_id;
7910
7911 END IF;
7915 FETCH get_doc_sequence_category_id INTO l_doc_sequence_category_id;
7912
7913 /*
7914 OPEN get_doc_sequence_category_id(l_document_type);
7916 CLOSE get_doc_sequence_category_id;
7917 */
7918
7919 OPEN c_bol_psno_exists(l_entity_id,p_entity_name,l_document_type);
7920 FETCH c_bol_psno_exists INTO l_temp;
7921
7922
7923 IF l_debug_on THEN
7924 WSH_DEBUG_SV.log(l_module_name,'l_temp',l_temp);
7925 END IF;
7926
7927
7928 --True if record already exists in wsh_document_instances for this delivery leg id
7929 --.So just do an update for the current document number.
7930 IF c_bol_psno_exists%FOUND THEN
7931
7932
7933 UPDATE wsh_document_instances
7934 SET sequence_number = p_document_number,
7935 last_update_date = SYSDATE,
7936 last_updated_by = FND_GLOBAL.USER_ID,
7937 last_update_login = FND_GLOBAL.LOGIN_ID
7938 WHERE entity_name = p_entity_name
7939 AND entity_id = l_entity_id
7940 AND document_type= l_document_type;
7941
7942 --means no matching records in wsh_document_instances
7943 --so insert a new record
7944 ELSIF c_bol_psno_exists%NOTFOUND THEN
7945
7946 --{ Bug 3761178
7947 --
7948 -- The decode statement that was in the values clause of the coming insert stmt
7949 -- have been modified to make use of local variable l_status for performance reasons.
7950 --
7951
7952 IF p_entity_name = 'WSH_DELIVERY_LEGS' THEN
7953 l_status := 'PLANNED';
7954 ELSIF p_entity_name ='WSH_NEW_DELIVERIES' THEN
7955 l_status := 'OPEN';
7956 END IF;
7957
7958 --}
7959
7960 l_appl_num := 665; --Bug# 3789154
7961
7962 INSERT INTO wsh_document_instances
7963 ( document_instance_id
7964 , document_type
7965 , sequence_number
7966 , status
7967 , final_print_date
7968 , entity_name
7969 , entity_id
7970 , doc_sequence_category_id
7971 , created_by
7972 , creation_date
7973 , last_updated_by
7974 , last_update_date
7975 , last_update_login
7976 , program_application_id
7977 , program_id
7978 , program_update_date
7979 , request_id
7980 , attribute_category
7981 , attribute1
7982 , attribute2
7983 , attribute3
7984 , attribute4
7985 , attribute5
7986 , attribute6
7987 , attribute7
7988 , attribute8
7989 , attribute9
7990 , attribute10
7991 , attribute11
7992 , attribute12
7993 , attribute13
7994 , attribute14
7995 , attribute15
7996 )
7997 VALUES
7998 ( wsh_document_instances_s.nextval
7999 , l_document_type
8000 , p_document_number
8001 , l_status
8002 , null
8003 , p_entity_name
8004 , l_entity_id
8005 , l_doc_sequence_category_id
8006 , fnd_global.user_id
8007 , sysdate
8008 , fnd_global.user_id
8009 , sysdate
8010 , fnd_global.login_id
8011 , l_appl_num --Bug# 3789154
8012 , null
8013 , null
8014 , null
8015 , null
8016 , null
8017 , null
8018 , null
8019 , null
8020 , null
8021 , null
8022 , null
8023 , null
8024 , null
8025 , null
8026 , null
8027 , null
8028 , null
8029 , null
8030 , null
8031 );
8032
8033 END IF;
8034
8035 CLOSE c_bol_psno_exists;
8036
8037
8038 --
8039 -- Debug Statements
8040 --
8041 IF l_debug_on THEN
8042 WSH_DEBUG_SV.pop(l_module_name);
8043 END IF;
8044 --
8045 IF l_num_errors > 0 THEN
8046 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
8047 ELSIF l_num_warnings > 0 THEN
8048 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
8049 END IF;
8050
8051
8052 EXCEPTION
8053 WHEN FND_API.G_EXC_ERROR THEN
8054 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
8055 WSH_UTIL_CORE.ADD_MESSAGE(x_return_status,l_module_name);
8056
8057 --
8058 -- Debug Statements
8059 --
8060 IF l_debug_on THEN
8061 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
8062 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
8063 END IF;
8064 --
8065 WHEN OTHERS THEN
8066 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
8067 WSH_UTIL_CORE.Default_Handler('WSH_ASN_RECEIPT_PVT.create_update_inbound_document ',l_module_name);
8068 --
8069 -- Debug Statements
8070 --
8071 IF l_debug_on THEN
8072 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
8073 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
8074 END IF;
8075 --
8076 end create_update_inbound_document ;
8077
8078
8079
8080
8081 -- Start of comments
8082 -- API name : cancel_close_pending_txns
8083 -- Type : Public
8084 -- Pre-reqs : None.
8085 -- Function : This API calls the WSH_PO_CMG_PVT.close_cancel_po with two sets of data
8086 -- which were collected in the API WSH_ASN_RECEIPT_PVT.Process_Matched_Txns
8087 -- .These(two sets of data) contain rows which were tried to be closed or
8088 -- cancelled when txns were pending against them and therefore those lines
8089 -- have to be closed when the txns have been matched.This job is taken care
8090 -- of this API.
8091 -- Parameters:
8092 -- IN:
8093 -- p_po_cancel_rec IN OE_WSH_BULK_GRP.line_rec_type
8094 -- contains details of the lines which are to be cancelled.These details
8098 -- include shipment_line_id, header_id,delivery_detail_id etc.
8095 -- include shipment_line_id, header_id,delivery_detail_id etc.
8096 -- p_po_close_rec IN OE_WSH_BULK_GRP.line_rec_type
8097 -- contains details of the lines which are to be closed..These details
8099 -- IN OUT:
8100 -- OUT:
8101 -- Version : 1.0
8102 -- Previous version 1.0
8103 -- Initial version 1.0
8104 -- End of comments
8105
8106
8107 PROCEDURE cancel_close_pending_txns(
8108 p_po_cancel_rec IN OE_WSH_BULK_GRP.line_rec_type,
8109 p_po_close_rec IN OE_WSH_BULK_GRP.line_rec_type,
8110 x_return_status OUT NOCOPY VARCHAR2)
8111
8112 IS
8113
8114 l_action_prms WSH_BULK_TYPES_GRP.action_parameters_rectype;
8115 l_num_warnings NUMBER := 0;
8116 l_num_errors NUMBER := 0;
8117 l_return_status VARCHAR2(1);
8118
8119 --
8120 l_debug_on BOOLEAN;
8121 --
8122 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'cancel_close_pending_txns';
8123 --
8124
8125 BEGIN
8126
8127 x_return_status := wsh_util_core.g_ret_sts_success;
8128 --
8129 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
8130 --
8131 IF l_debug_on IS NULL
8132 THEN
8133 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
8134 END IF;
8135 --
8136 --
8137 -- Debug Statements
8138 --
8139 IF l_debug_on THEN
8140 WSH_DEBUG_SV.push(l_module_name);
8141 WSH_DEBUG_SV.log(l_module_name, 'l_action_prms.action_code',l_action_prms.action_code);
8142 WSH_DEBUG_SV.log(l_module_name, 'p_po_cancel_rec.header_id.COUNT',p_po_cancel_rec.header_id.COUNT);
8143 WSH_DEBUG_SV.log(l_module_name, 'p_po_close_rec.header_id.COUNT',p_po_close_rec.header_id.COUNT);
8144 END IF;
8145 --
8146
8147 -- True if there are any lines(Delivery_detail_id s) to be Cancelled.Typically these are the
8148 -- lines which were tried to be cancelled, when transactions were pending against them.
8149 IF p_po_cancel_rec.line_id.COUNT > 0 THEN
8150 --
8151 -- Debug Statements
8152 --
8153 IF l_debug_on THEN
8154 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_PO_CMG_PVT.CANCEL_CLOSE_PO',WSH_DEBUG_SV.C_PROC_LEVEL);
8155
8156 END IF;
8157 --
8158 l_action_prms.action_code := 'CANCEL_PO';
8159 --Call API WSH_PO_CMG_PVT.cancel_close_po
8160 WSH_PO_CMG_PVT.cancel_close_po(
8161 p_line_rec => p_po_cancel_rec,
8162 p_action_prms => l_action_prms,
8163 x_return_status => l_return_status);
8164 --
8165 -- Debug Statements
8166 --
8167 IF l_debug_on THEN
8168 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
8169 END IF;
8170 --
8171 wsh_util_core.api_post_call(
8172 p_return_status => l_return_status,
8173 x_num_warnings => l_num_warnings,
8174 x_num_errors => l_num_errors);
8175
8176 END IF;
8177
8178 -- True if there are any lines(Delivery_detail_id s) to be Closed.Typically these are the
8179 -- lines which were tried to be closed, when transactions were pending against them.
8180 IF p_po_close_rec.line_id.COUNT > 0 THEN
8181 --
8182 -- Debug Statements
8183 --
8184 IF l_debug_on THEN
8185 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_PO_CMG_PVT.CANCEL_CLOSE_PO',WSH_DEBUG_SV.C_PROC_LEVEL);
8186 END IF;
8187 --
8188 l_action_prms.action_code := 'CLOSE_PO';
8189 --
8190 --Call API WSH_PO_CMG_PVT.cancel_close_po
8191 WSH_PO_CMG_PVT.cancel_close_po(
8192 p_line_rec => p_po_close_rec,
8193 p_action_prms => l_action_prms,
8194 x_return_status => l_return_status);
8195 --
8196 -- Debug Statements
8197 --
8198 IF l_debug_on THEN
8199 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.API_POST_CALL',WSH_DEBUG_SV.C_PROC_LEVEL);
8200 END IF;
8201 --
8202 wsh_util_core.api_post_call(
8203 p_return_status => l_return_status,
8204 x_num_warnings => l_num_warnings,
8205 x_num_errors => l_num_errors);
8206
8207 END IF;
8208
8209
8210
8211 --
8212 -- Debug Statements
8213 --
8214 IF l_debug_on THEN
8215 WSH_DEBUG_SV.pop(l_module_name);
8216 END IF;
8217 --
8218 IF l_num_errors > 0 THEN
8219 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
8220 ELSIF l_num_warnings > 0 THEN
8221 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
8222 END IF;
8223
8224
8225 EXCEPTION
8226 WHEN FND_API.G_EXC_ERROR THEN
8227 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
8228 WSH_UTIL_CORE.ADD_MESSAGE(x_return_status,l_module_name);
8229
8230 --
8231 -- Debug Statements
8232 --
8233 IF l_debug_on THEN
8234 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
8235 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_ERROR');
8236 END IF;
8237 --
8238 WHEN OTHERS THEN
8239 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
8240 WSH_UTIL_CORE.Default_Handler('WSH_ASN_RECEIPT_PVT.cancel_close_pending_txns');
8241
8242 --
8243 -- Debug Statements
8244 --
8245 IF l_debug_on THEN
8246 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
8247 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
8248 END IF;
8249 --
8250 END cancel_close_pending_txns;
8251
8252 END WSH_ASN_RECEIPT_PVT;