[Home] [Help]
PACKAGE BODY: APPS.WSH_USA_INV_PVT
Source
1 PACKAGE BODY WSH_USA_INV_PVT as
2 /* $Header: WSHUSAIB.pls 120.46.12020000.10 2013/05/30 13:31:02 skanduku ship $ */
3
4 --G_PACKAGE_NAME CONSTANT VARCHAR2(50) := 'WSH_USA_INV_PVT';
5
6
7 -- declare the private function (Bug3012297)
8 FUNCTION check_inv_info (
9 p_delivery_detail_split_rec IN DeliveryDetailInvRecType,
10 p_delivery_detail_id IN NUMBER default NULL,
11 p_rsv IN inv_reservation_global.mtl_reservation_rec_type
12 ) return BOOLEAN;
13
14
15 /**
16 Procedure handles unassigning of delivery detail from delivery/container
17 This procedure is called after detail is set to Backordered status to handle
18 Wt/Vol adjustments as well as any other processing logic.
19 The backordered delivery detail is unassigned from the delivery
20 if the delivery is not planned
21 The backordered delivery detail is unpacked if the org is wms enabled
22 or if the org is not wms enabled and the delivery is not planned.
23 Parameters :
24 p_backorder_rec_tbl - Input Table of Records with the following record structure:
25 delivery_detail_id - Delivery Detail which is getting backordered
26 delivery_id - Delivery of the backordered detail
27 container_id - Immediate Parent Container of the backordered detail
28 organization_id - Delivery Detail's Organization
29 line_direction - Line Direction
30 planned_flag - Delivery is Planned or not (Y/N)
31 gross_weight - Detail's Gross Weight
32 net_weight - Detail's Net Weight
33 volume - Detail's Volume
34 del_batch_id - Delivery's Pick Release Batch Id (whether created during Pick Release process)
35 x_return_status - Return Status (Success/Unexpected Error)
36 */
37 PROCEDURE Unassign_Backordered_Details (
38 p_backorder_rec_tbl IN Back_Det_Rec_Tbl,
39 p_org_info_tbl IN WSH_PICK_LIST.Org_Params_Rec_Tbl,
40 x_return_status OUT NOCOPY VARCHAR2
41 ) IS
42
43
44 -- K LPN CONV. rv
45 cursor l_cnt_orgn_csr (p_cnt_inst_id IN NUMBER) IS
46 select organization_id
47 from wsh_delivery_details
48 where delivery_detail_id = p_cnt_inst_id
49 and container_flag = 'Y'
50 and source_code = 'WSH';
51
52 -- OTM R12 : unassign delivery detail
53
54 CURSOR c_detail_cont_planning_cur (p_detail_id IN NUMBER) IS
55 SELECT ignore_for_planning
56 FROM wsh_delivery_details
57 WHERE delivery_detail_id = p_detail_id;
58
59 -- End of OTM R12 : unassign delivery detail
60
61 l_wms_org VARCHAR2(10) := 'N';
62 l_sync_tmp_rec wsh_glbl_var_strct_grp.sync_tmp_rec_type;
63 l_cnt_orgn_id NUMBER;
64 l_new_parent_detail_id NUMBER;
65 l_num_warnings NUMBER := 0;
66 -- K LPN CONV. rv
67
68 l_mdc_detail_tab wsh_util_core.id_tab_type;
69 l_dd_id WSH_UTIL_CORE.ID_TAB_TYPE;
70 l_del_tab WSH_UTIL_CORE.Id_Tab_Type;
71 l_return_status VARCHAR2(1);
72 l_new_delivery_id WSH_DELIVERY_ASSIGNMENTS_V.DELIVERY_ID%TYPE;
73
74 l_reprice_del_tab WSH_UTIL_CORE.ID_TAB_TYPE;
75
76 MARK_REPRICE_ERROR EXCEPTION;
77 e_return EXCEPTION;
78
79 l_num_errors NUMBER := 0;
80 l_found_assigned_del BOOLEAN;
81
82 l_debug_on BOOLEAN;
83 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PACKAGE_NAME || '.' || 'UNASSIGN_BACKORDERED_DETAILS';
84
85
86 -- OTM R12 : unassign delivery detail
87 l_ignore_for_planning WSH_DELIVERY_DETAILS.IGNORE_FOR_PLANNING%TYPE;
88 l_is_delivery_empty VARCHAR2(1);
89 l_interface_flag_tab WSH_UTIL_CORE.COLUMN_TAB_TYPE;
90 l_delivery_id_tab WSH_UTIL_CORE.ID_TAB_TYPE;
91 l_gc3_is_installed VARCHAR2(1);
92 l_call_update VARCHAR2(1);
93 -- End of OTM R12 : unassign delivery detail
94
95 l_delivery_id_mod NUMBER; --Bug 9406326
96
97 BEGIN
98
99 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
100 IF l_debug_on IS NULL THEN
101 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
102 END IF;
103
104 IF l_debug_on THEN
105 WSH_DEBUG_SV.push(l_module_name);
106 WSH_DEBUG_SV.log(l_module_name,'P_BACKORDER_REC_TBL.COUNT',P_BACKORDER_REC_TBL.COUNT);
107 WSH_DEBUG_SV.log(l_module_name,'P_ORG_INFO_TBL.COUNT',P_ORG_INFO_TBL.COUNT);
108 END IF;
109
110 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
111
112 -- OTM R12
113 l_gc3_is_installed := WSH_UTIL_CORE.G_GC3_IS_INSTALLED;
114
115 IF (l_gc3_is_installed IS NULL) THEN
116 l_gc3_is_installed := WSH_UTIL_CORE.GC3_IS_INSTALLED;
117 END IF;
118 -- End of OTM R12
119
120 -- Return back to caller if there are no records in table
121 IF p_backorder_rec_tbl.COUNT = 0 THEN
122 IF l_debug_on THEN
123 WSH_DEBUG_SV.pop(l_module_name);
124 END IF;
125 RETURN;
126 END IF;
127
128 FOR i in p_backorder_rec_tbl.FIRST..p_backorder_rec_tbl.LAST LOOP --{
129
130 l_new_delivery_id := NULL;
131 l_new_parent_detail_id := NULL;
132 l_cnt_orgn_id := NULL;
133
134 SAVEPOINT unassign_backorder_details;
135
136 -- For Pick Release cases where Delivery exists
137 IF WSH_PICK_LIST.G_BATCH_ID IS NOT NULL AND p_backorder_rec_tbl(i).delivery_id IS NOT NULL THEN --{
138
139 l_delivery_id_mod := MOD(p_backorder_rec_tbl(i).delivery_id,WSH_UTIL_CORE.C_INDEX_LIMIT) ; --Bug 9406326
140
141 -- If the Delivery will be unassigned, then add to the list
142 -- This is used to unassign empty containers from the Delivery at the end of Pick Release process
143 IF p_backorder_rec_tbl(i).planned_flag = 'N'
144 AND (NOT WSH_PICK_LIST.g_unassigned_delivery_ids.exists(l_delivery_id_mod)) THEN --{ --Bug 9406326 replaced p_backorder_rec_tbl(i).delivery_id with l_delivery_id_mod
145 IF l_debug_on THEN
146 WSH_DEBUG_SV.logmsg(l_module_name,'Assigning delivery to WSH_PICK_LIST.g_unassigned_delivery_ids');
147 END IF;
148 WSH_PICK_LIST.g_unassigned_delivery_ids(l_delivery_id_mod) := p_backorder_rec_tbl(i).delivery_id; --Bug 9406326 replaced p_backorder_rec_tbl(i).delivery_id with l_delivery_id_mod
149 END IF; --}
150
151 -- Storing Pre-existing Assigned Deliveries to call Adjust_Planned_Flag API in Pick Release process
152 -- These deliveries will not have either a batch_id or the same Pick Release batch_id
153 -- This is required since some deliveries will no longer have any details from the Pick Release batch
154 -- and they might have to be Planned. Hence this is stored in this table
155 IF WSH_PICK_LIST.G_BATCH_ID <> NVL(p_backorder_rec_tbl(i).del_batch_id, -99) THEN --{
156 IF WSH_PICK_LIST.g_assigned_del_tbl.count = 0 THEN --{
157 WSH_PICK_LIST.g_assigned_del_tbl(WSH_PICK_LIST.g_assigned_del_tbl.count+1) := p_backorder_rec_tbl(i).delivery_id;
158 ELSE
159 l_found_assigned_del := FALSE;
160 FOR j in WSH_PICK_LIST.g_assigned_del_tbl.FIRST .. WSH_PICK_LIST.g_assigned_del_tbl.LAST LOOP
161 IF WSH_PICK_LIST.g_assigned_del_tbl(j) = p_backorder_rec_tbl(i).delivery_id THEN
162 l_found_assigned_del := TRUE;
163 EXIT;
164 END IF;
165 END LOOP;
166 IF NOT l_found_assigned_del THEN
167 WSH_PICK_LIST.g_assigned_del_tbl(WSH_PICK_LIST.g_assigned_del_tbl.count+1) := p_backorder_rec_tbl(i).delivery_id;
168 END IF;
169 END IF; --}
170 END IF; --}
171
172 END IF; --}
173
174
175 -- J: W/V Changes
176 -- Decrement the W/V from parent(s) since the updates below will unassign the delivery detail
177 -- from container and/or delivery
178 IF ((p_backorder_rec_tbl(i).planned_flag = 'N' AND
179 (p_backorder_rec_tbl(i).delivery_id is NOT NULL OR p_backorder_rec_tbl(i).container_id is NOT NULL))
180 OR (p_backorder_rec_tbl(i).planned_flag = 'Y' and
181 p_org_info_tbl(p_backorder_rec_tbl(i).organization_id).wms_org = 'Y' AND
182 p_backorder_rec_tbl(i).container_id is NOT NULL)
183 ) THEN --{
184 IF l_debug_on THEN
185 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_WV_UTILS.DD_WV_Post_Process', WSH_DEBUG_SV.C_PROC_LEVEL);
186 END IF;
187
188 WSH_WV_UTILS.DD_WV_Post_Process(
189 p_delivery_detail_id => p_backorder_rec_tbl(i).delivery_detail_id,
190 p_diff_gross_wt => -1 * p_backorder_rec_tbl(i).gross_weight,
191 p_diff_net_wt => -1 * p_backorder_rec_tbl(i).net_weight,
192 p_diff_volume => -1 * p_backorder_rec_tbl(i).volume,
193 p_diff_fill_volume => -1 * p_backorder_rec_tbl(i).volume,
194 p_check_for_empty => 'Y',
195 x_return_status => l_return_status);
196
197 IF (l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR) THEN
198 WSH_UTIL_CORE.Add_Message(l_return_status);
199 IF l_debug_on THEN
200 WSH_DEBUG_SV.logmsg(l_module_name,'Error in WSH_WV_UTILS.DD_WV_Post_Process ');
201 END IF;
202 ROLLBACK TO unassign_backorder_details;
203 l_num_errors := l_num_errors + 1;
204 GOTO next_record;
205 END IF;
206 END IF; --}
207
208 -- Can the Update Statement below be replaced to call Unassign_Detail_From_Delivery ? 2 open issues remain :
209 -- 1. Delivery can be absent.
210 -- 2. Unassign Api will raise error if called for Planned Delivery. Also unpacking should be
211 -- independent of unassignment
212
213 UPDATE wsh_delivery_assignments_v
214 SET delivery_id = decode(p_backorder_rec_tbl(i).planned_flag, 'N', null, delivery_id),
215 parent_delivery_detail_id = decode(p_org_info_tbl(p_backorder_rec_tbl(i).organization_id).wms_org,
216 'Y', null,
217 decode(p_backorder_rec_tbl(i).planned_flag, 'N', null, parent_delivery_detail_id))
218 WHERE delivery_detail_id = p_backorder_rec_tbl(i).delivery_detail_id
219 RETURNING delivery_id, parent_delivery_detail_id
220 INTO l_new_delivery_id, l_new_parent_detail_id;
221
222
223 -- OTM R12 : unassign delivery detail
224 -- delivery_id is updated only when planned_flag = 'N', so check it
225 -- Bug 7136152 : Needs to perform the following actions only when delivery
226 -- Id is not null.
227 IF (l_gc3_is_installed = 'Y' AND
228 p_backorder_rec_tbl(i).planned_flag = 'N' AND
229 p_backorder_rec_tbl(i).delivery_id IS NOT NULL) THEN
230
231 -- grab ignore_for_planning
232 OPEN c_detail_cont_planning_cur(p_backorder_rec_tbl(i).delivery_detail_id);
233 FETCH c_detail_cont_planning_cur into l_ignore_for_planning;
234 CLOSE c_detail_cont_planning_cur;
235
236 IF (nvl(l_ignore_for_planning, 'N') = 'N') THEN
237 l_call_update := 'Y';
238 l_delivery_id_tab(1) := p_backorder_rec_tbl(i).delivery_id;
239 l_is_delivery_empty := WSH_NEW_DELIVERY_ACTIONS.IS_DELIVERY_EMPTY(p_backorder_rec_tbl(i).delivery_id);
240
241 IF (l_is_delivery_empty = WSH_UTIL_CORE.G_RET_STS_ERROR) THEN
242 IF l_debug_on THEN
243 WSH_DEBUG_SV.logmsg(l_module_name,'Error in WSH_NEW_DELIVERIE_ACTIONS.IS_DELIVERY_EMPTY '||to_char(p_backorder_rec_tbl(i).delivery_id));
244 END IF;
245 ROLLBACK TO unassign_backorder_details;
246 l_num_errors := l_num_errors + 1;
247 GOTO next_record;
248 ELSIF (l_is_delivery_empty = 'Y') THEN
249 l_interface_flag_tab(1) := WSH_NEW_DELIVERIES_PVT.C_TMS_DELETE_REQUIRED;
250 ELSIF (l_is_delivery_empty = 'N') THEN
251 l_interface_flag_tab(1) := NULL;
252 --Bug7608629
253 --removed code which checked for gross weight
254 --now irrespective of gross weight UPDATE_TMS_INTERFACE_FLAG will be called
255 END IF;
256
257 IF l_call_update = 'Y' THEN
258 WSH_NEW_DELIVERIES_PVT.UPDATE_TMS_INTERFACE_FLAG(
259 p_delivery_id_tab => l_delivery_id_tab,
260 p_tms_interface_flag_tab => l_interface_flag_tab,
261 x_return_status => l_return_status);
262
263 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
264 IF l_debug_on THEN
265 WSH_DEBUG_SV.logmsg(l_module_name,'Error in WSH_NEW_DELIVERIES_PVT.UPDATE_TMS_INTERFACE_FLAG');
266 END IF;
267 ROLLBACK TO unassign_backorder_details;
268 l_num_errors := l_num_errors + 1;
269 GOTO next_record;
270 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
271 IF l_debug_on THEN
272 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error in WSH_NEW_DELIVERIES_PVT.UPDATE_TMS_INTERFACE_FLAG');
273 END IF;
274 RAISE e_return;
275 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_WARNING THEN
276 IF l_debug_on THEN
277 WSH_DEBUG_SV.logmsg(l_module_name,'Warning in WSH_NEW_DELIVERIES_PVT.UPDATE_TMS_INTERFACE_FLAG');
278 END IF;
279 l_num_warnings := l_num_warnings + 1;
280 END IF;
281 END IF;
282 END IF;
283 END IF; -- if OTM installed and the delivery is not planned
284 -- End of OTM R12 : unassign delivery detail
285
286 IF l_new_delivery_id IS NULL AND p_backorder_rec_tbl(i).delivery_id IS NOT NULL THEN
287 -- unassignment needs to mark delivery's legs as repricing required.
288 l_reprice_del_tab( l_reprice_del_tab.COUNT+1 ) := p_backorder_rec_tbl(i).delivery_id;
289 END IF;
290
291 l_mdc_detail_tab(1) := p_backorder_rec_tbl(i).delivery_detail_id;
292 IF p_backorder_rec_tbl(i).planned_flag = 'N' THEN --{
293 l_mdc_detail_tab(1) := p_backorder_rec_tbl(i).delivery_detail_id;
294 WSH_DELIVERY_DETAILS_ACTIONS.Delete_Consol_Record(
295 p_detail_id_tab => l_mdc_detail_tab,
296 x_return_status => l_return_status);
297
298 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
299 IF l_debug_on THEN
300 WSH_DEBUG_SV.logmsg(l_module_name,'Error in WSH_DELIVERY_DETAILS_ACTIONS.Delete_Consol_Record');
301 END IF;
302 ROLLBACK TO unassign_backorder_details;
303 l_num_errors := l_num_errors + 1;
304 GOTO next_record;
305 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
306 IF l_debug_on THEN
307 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error in WSH_DELIVERY_DETAILS_ACTIONS.Delete_Consol_Record ');
308 END IF;
309 RAISE e_return;
310 END IF;
311 --}
312 ELSIF p_org_info_tbl(p_backorder_rec_tbl(i).organization_id).wms_org = 'Y' THEN --{
313 l_mdc_detail_tab(1) := p_backorder_rec_tbl(i).delivery_detail_id;
314 WSH_DELIVERY_DETAILS_ACTIONS.Create_Consol_Record(
315 p_detail_id_tab => l_mdc_detail_tab,
316 x_return_status => l_return_status);
317
318 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
319 IF l_debug_on THEN
320 WSH_DEBUG_SV.logmsg(l_module_name,'Error in WSH_DELIVERY_DETAILS_ACTIONS.Create_Consol_Record');
321 END IF;
322 ROLLBACK TO unassign_backorder_details;
323 l_num_errors := l_num_errors + 1;
324 GOTO next_record;
325 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
326 IF l_debug_on THEN
327 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error in WSH_DELIVERY_DETAILS_ACTIONS.Create_Consol_Record');
328 END IF;
329 RAISE e_return;
330 END IF;
331 END IF; --}
332
333 -- LPN CONV. rv
334 IF nvl(l_new_parent_detail_id,-999) <> nvl(p_backorder_rec_tbl(i).container_id,-999) THEN
335 --{
336 open l_cnt_orgn_csr(p_backorder_rec_tbl(i).container_id);
337 fetch l_cnt_orgn_csr into l_cnt_orgn_id;
338 close l_cnt_orgn_csr;
339 IF l_debug_on THEN
340 WSH_DEBUG_SV.log(l_module_name,'Parent Container Orgn Id Is',l_cnt_orgn_id);
341 END IF;
342
343 l_wms_org := wsh_util_validate.check_wms_org(l_cnt_orgn_id);
344
345 IF WSH_WMS_LPN_GRP.G_CALLBACK_REQUIRED = 'Y'
346 AND p_backorder_rec_tbl(i).line_direction IN ('O', 'IO')
347 AND
348 (
349 (WSH_WMS_LPN_GRP.GK_WMS_UNPACK and l_wms_org = 'Y')
350 OR
351 (WSH_WMS_LPN_GRP.GK_INV_UNPACK and l_wms_org = 'N')
352 )
353 THEN
354 --{
355 --
356 l_sync_tmp_rec.delivery_detail_id := p_backorder_rec_tbl(i).delivery_detail_id;
357 l_sync_tmp_rec.parent_delivery_detail_id := p_backorder_rec_tbl(i).container_id;
358 l_sync_tmp_rec.delivery_id := p_backorder_rec_tbl(i).delivery_id;
359 l_sync_tmp_rec.operation_type := 'PRIOR';
360 --
361 WSH_WMS_SYNC_TMP_PKG.MERGE
362 (
363 p_sync_tmp_rec => l_sync_tmp_rec,
364 x_return_status => l_return_status
365 );
366 IF l_debug_on THEN
367 WSH_DEBUG_SV.log(l_module_name,'Return Status',l_return_status);
368 END IF;
369 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
370 IF l_debug_on THEN
371 WSH_DEBUG_SV.logmsg(l_module_name,'Error in WSH_WMS_SYNC_TMP_PKG.MERGE ');
372 END IF;
373 ROLLBACK TO unassign_backorder_details;
374 l_num_errors := l_num_errors + 1;
375 GOTO next_record;
376 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
377 IF l_debug_on THEN
378 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected Error in WSH_WMS_SYNC_TMP_PKG.MERGE ');
379 END IF;
380 RAISE e_return;
381 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_WARNING THEN
382 l_num_warnings := l_num_warnings + 1;
383 END IF;
384 --}
385 END IF;
386 --}
387 END IF;
388 -- LPN CONV. rv
389
390 IF p_backorder_rec_tbl(i).delivery_id IS NOT NULL OR p_backorder_rec_tbl(i).container_id IS NOT NULL THEN --{
391 --
392 --Bug9575761 Added condition p_backorder_rec_tbl(i).planned_flag <> 'Y'
393 IF (p_backorder_rec_tbl(i).delivery_id IS NOT NULL) AND (p_backorder_rec_tbl(i).planned_flag <> 'Y') THEN --{
394 l_del_tab(1) := p_backorder_rec_tbl(i).delivery_id;
395 WSH_TP_RELEASE.calculate_cont_del_tpdates(
396 p_entity => 'DLVY',
397 p_entity_ids => l_del_tab,
398 x_return_status => l_return_status);
399 ELSIF p_backorder_rec_tbl(i).container_id IS NOT NULL THEN
400 l_del_tab(1) := p_backorder_rec_tbl(i).container_id;
401 WSH_TP_RELEASE.calculate_cont_del_tpdates(
402 p_entity => 'DLVB',
403 p_entity_ids => l_del_tab,
404 x_return_status => l_return_status);
405 END IF; --}
406 -- Common Error Handling for above APIs
407 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN --{
408 IF l_debug_on THEN
409 WSH_DEBUG_SV.logmsg(l_module_name,'Error in WSH_TP_RELEASE.calculate_cont_del_tpdates ');
410 END IF;
411 ROLLBACK TO unassign_backorder_details;
412 l_num_errors := l_num_errors + 1;
413 GOTO next_record;
414 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
415 IF l_debug_on THEN
416 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected Error in WSH_TP_RELEASE.calculate_cont_del_tpdates ');
417 END IF;
418 RAISE e_return;
419 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_WARNING THEN
420 l_num_warnings := l_num_warnings + 1;
421 END IF; --}
422 END IF; --}
423
424 IF l_debug_on THEN
425 WSH_DEBUG_SV.log(l_module_name,'Updated wsh_delivery_assignments_v for backordered_delivery_detail ' ,p_backorder_rec_tbl(i).delivery_detail_id);
426 END IF;
427
428 -- FP bug 4208538 from bug 4075078
429 -- Freight costs need to be deleted for the delivery detail if
430 -- calculated by FTE AND detail is unassigned from the delivery.
431 -- If backordered line remains assigned to delivery, it can retain
432 -- freight costs.
433 -- Bug 2769639 fixes this in the API Unassign_Detail_From_Delivery,
434 -- and it needs to be incorporated here as well.
435 IF WSH_UTIL_CORE.FTE_Is_Installed = 'Y' AND l_new_delivery_id IS NULL THEN --{
436 l_dd_id(1) := p_backorder_rec_tbl(i).delivery_detail_id;
437
438 IF l_debug_on THEN
439 WSH_DEBUG_SV.log(l_module_name,'Call WSH_FREIGHT_COSTS_PVT.Remove_FTE_Freight_Costs',p_backorder_rec_tbl(i).delivery_detail_id);
440 END IF;
441
442 WSH_FREIGHT_COSTS_PVT.Remove_FTE_Freight_Costs(
443 p_delivery_details_tab => l_dd_id,
444 x_return_status => l_return_status) ;
445
446 IF l_debug_on THEN
447 WSH_DEBUG_SV.log(l_module_name,'After WSH_FREIGHT_COSTS_PVT.Remove_FTE_Freight_Costs: return',l_return_status);
448 END IF;
449
450 IF l_return_status IN (WSH_UTIL_CORE.G_RET_STS_ERROR, WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR) THEN --{
451 FND_MESSAGE.Set_Name('WSH', 'WSH_REPRICE_REQUIRED_ERR');
452 WSH_UTIL_CORE.add_message(l_return_status, l_module_name);
453 IF l_debug_on THEN
454 WSH_DEBUG_SV.logmsg(l_module_name,'Remove_FTE_Freight_Costs failed');
455 END IF;
456 ROLLBACK TO unassign_backorder_details;
457 l_num_errors := l_num_errors + 1;
458 GOTO next_record;
459 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_WARNING THEN
460 l_num_warnings := l_num_warnings + 1;
461 END IF; --}
462 END IF; --}
463
464 -- J: W/V Changes
465 -- Adjust the W/V back on delivery since the dd gets unassigned from container but stays on delivery
466 -- in the following case
467 IF p_org_info_tbl(p_backorder_rec_tbl(i).organization_id).wms_org = 'Y'
468 AND p_backorder_rec_tbl(i).planned_flag = 'Y' AND p_backorder_rec_tbl(i).delivery_id is NOT NULL
469 AND p_backorder_rec_tbl(i).container_id is NOT NULL THEN --{
470 IF l_debug_on THEN
471 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_WV_UTILS.DD_WV_Post_Process'
472 ,WSH_DEBUG_SV.C_PROC_LEVEL);
473 END IF;
474
475 WSH_WV_UTILS.DD_WV_Post_Process(
476 p_delivery_detail_id => p_backorder_rec_tbl(i).delivery_detail_id,
477 p_diff_gross_wt => p_backorder_rec_tbl(i).gross_weight,
478 p_diff_net_wt => p_backorder_rec_tbl(i).net_weight,
479 p_diff_volume => p_backorder_rec_tbl(i).volume,
480 p_diff_fill_volume => p_backorder_rec_tbl(i).volume,
481 x_return_status => l_return_status);
482
483 IF (l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR) THEN
484 WSH_UTIL_CORE.Add_Message(l_return_status);
485 IF l_debug_on THEN
486 WSH_DEBUG_SV.logmsg(l_module_name,'Error in WSH_WV_UTILS.DD_WV_Post_Process ');
487 END IF;
488 ROLLBACK TO unassign_backorder_details;
489 l_num_errors := l_num_errors + 1;
490 GOTO next_record;
491 END IF;
492 END IF; --}
493
494 << next_record >>
495 NULL;
496
497 END LOOP; --}
498
499 IF l_reprice_del_tab.COUNT > 0 THEN --{
500 WSH_DELIVERY_LEGS_ACTIONS.Mark_Reprice_Required(
501 p_entity_type => 'DELIVERY',
502 p_entity_ids => l_reprice_del_tab,
503 x_return_status => l_return_status);
504 IF l_debug_on THEN
505 WSH_DEBUG_SV.log(l_module_name,'Mark_Reprice_Required l_return_status',l_return_status);
506 END IF;
507 IF l_return_status IN (WSH_UTIL_CORE.G_RET_STS_ERROR, WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR) THEN
508 RAISE MARK_REPRICE_ERROR;
509 END IF;
510 END IF; --}
511
512 IF (l_num_errors > 0) THEN
513 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
514 ELSIF (l_num_warnings > 0) THEN
515 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
516 END IF;
517
518 IF l_debug_on THEN
519 WSH_DEBUG_SV.pop(l_module_name);
520 END IF;
521
522 EXCEPTION
523
524 WHEN MARK_REPRICE_ERROR THEN
525 x_return_status := l_return_status;
526 FND_MESSAGE.SET_NAME('WSH', 'WSH_REPRICE_REQUIRED_ERR');
527 WSH_UTIL_CORE.add_message(l_return_status,l_module_name);
528 -- OTM R12 : unassign delivery detail
529 IF (c_detail_cont_planning_cur%ISOPEN) THEN
530 CLOSE c_detail_cont_planning_cur;
531 END IF;
532 -- End of OTM R12 : unassign delivery detail
533 IF l_debug_on THEN
534 WSH_DEBUG_SV.logmsg(l_module_name,'MARK_REPRICE_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
535 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:MARK_REPRICE_ERROR');
536 END IF;
537
538 WHEN e_return THEN
539 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
540 WSH_UTIL_CORE.default_handler('WSH_USA_INV_PVT.unassign_backordered_details');
541 -- OTM R12 : unassign delivery detail
542 IF (c_detail_cont_planning_cur%ISOPEN) THEN
543 CLOSE c_detail_cont_planning_cur;
544 END IF;
545 -- End of OTM R12 : unassign delivery detail
546 IF l_debug_on THEN
547 WSH_DEBUG_SV.logmsg(l_module_name,'UNASSIGN_BACKORDERED_DETAILS e_return exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
548 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:UNASSIGN_BACKORDERED_DETAILS');
549 END IF;
550
551 WHEN OTHERS THEN
552 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
553 WSH_UTIL_CORE.default_handler('WSH_USA_INV_PVT.unassign_backordered_details');
554 -- OTM R12 : unassign delivery detail
555 IF (c_detail_cont_planning_cur%ISOPEN) THEN
556 CLOSE c_detail_cont_planning_cur;
557 END IF;
558 IF (l_cnt_orgn_csr%ISOPEN) THEN
559 CLOSE l_cnt_orgn_csr;
560 END IF;
561 -- End of OTM R12 : unassign delivery detail
562 IF l_debug_on THEN
563 WSH_DEBUG_SV.logmsg(l_module_name,'UNASSIGN_BACKORDERED_DETAILS exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
564 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:UNASSIGN_BACKORDERED_DETAILS');
565 END IF;
566
567 END Unassign_Backordered_Details;
568
569
570 -- Bug 2573434 : new local procedure added
571 /**
572 Procedure handles backorder of lines
573 This API updates the delivery detail and calls unassign_backordered_detail for
574 unassignment and other post processing calls
575 Parameters :
576 p_delivery_detail_id - Delivery Detail which is getting backordered
577 p_requested_quantity - Requested quantity
578 p_requested_quantity2 - Requested quantity2
579 p_planned_flag - Delivery is Planned or not (Y/N)
580 p_wms_enabled_flag - Organization is WMS Organization or not (Y/N)
581 p_del_batch_id - Delivery's Pick Release Batch Id
582 x_split_quantity - Split Quantity
583 -- muom
584 x_split_quantity2 - Split Quantity2
585 x_return_status - Return Status (Success/Unexpected Error)
586 */
587 PROCEDURE backorder_delivery_detail (
588 p_delivery_detail_id IN NUMBER,
589 p_requested_quantity IN NUMBER,
590 p_requested_quantity2 IN NUMBER,
591 p_planned_flag IN VARCHAR2,
592 p_wms_enabled_flag IN VARCHAR2,
593 p_replenishment_status IN VARCHAR2 DEFAULT NULL, --bug# 6689448 (replenishment project)
594 p_del_batch_id IN NUMBER,
595 x_split_quantity OUT NOCOPY NUMBER,
596 -- muom
597 x_split_quantity2 OUT NOCOPY NUMBER,
598 x_return_status OUT NOCOPY VARCHAR2
599 ) IS
600
601 -- J: W/V Changes
602 CURSOR C1 is
603 select parent_delivery_detail_id,
604 delivery_id
605 from wsh_delivery_assignments_v
606 where delivery_detail_id = p_delivery_detail_id;
607 l_container_id NUMBER;
608 l_delivery_id NUMBER;
609 l_gross_weight NUMBER;
610 l_net_weight NUMBER;
611 l_volume NUMBER;
612 l_return_status VARCHAR2(1);
613
614 l_user_id NUMBER;
615 l_login_id NUMBER;
616
617 --
618 l_debug_on BOOLEAN;
619 --
620 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PACKAGE_NAME || '.' || 'BACKORDER_DELIVERY_DETAIL';
621 --
622
623 l_detail_tab WSH_UTIL_CORE.id_tab_type; -- DBI Project
624 l_dbi_rs VARCHAR2(1); -- DBI Project
625 l_dd_txn_id NUMBER; -- DBI Project
626 l_txn_return_status VARCHAR2(1); -- DBI Project
627 l_wf_rs VARCHAR2(1); -- Pick To POD WF project
628 l_standalone_mode VARCHAR2(1); -- standalone project changes
629
630
631 --Begin OPM Bug 3561937
632
633 CURSOR get_pref_grade(wdd_id NUMBER) IS
634 SELECT oelines.preferred_grade,
635 wdd.organization_id, -- LPN CONV. rv
636 nvl(wdd.line_direction,'O') -- LPN CONV. rv
637 FROM oe_order_lines_all oelines, wsh_delivery_details wdd
638 WHERE wdd.delivery_detail_id = wdd_id
639 AND wdd.source_code = 'OE'
640 AND wdd.source_line_id = oelines.line_id;
641
642
643 l_organization_id NUMBER;
644 -- HW OPMCONV - changed size of grade to 150
645 l_oeline_pref_grade VARCHAR2(150) := NULL;
646 l_line_direction VARCHAR2(10);
647
648 l_backorder_rec_tbl Back_Det_Rec_Tbl;
649 l_org_info_tbl WSH_PICK_LIST.Org_Params_Rec_Tbl;
650
651 BEGIN
652
653 --
654 -- Debug Statements
655 --
656 --
657 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
658 --
659 IF l_debug_on IS NULL
660 THEN
661 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
662 END IF;
663 --
664 -- Standalone project Changes
665 l_standalone_mode := WMS_DEPLOY.wms_deployment_mode;
666 IF l_debug_on THEN
667 WSH_DEBUG_SV.push(l_module_name);
668 --
669 WSH_DEBUG_SV.log(l_module_name,'P_DELIVERY_DETAIL_ID',P_DELIVERY_DETAIL_ID);
670 WSH_DEBUG_SV.log(l_module_name,'P_REQUESTED_QUANTITY',P_REQUESTED_QUANTITY);
671 WSH_DEBUG_SV.log(l_module_name,'P_REQUESTED_QUANTITY2',P_REQUESTED_QUANTITY2);
672 WSH_DEBUG_SV.log(l_module_name,'P_PLANNED_FLAG',P_PLANNED_FLAG);
673 WSH_DEBUG_SV.log(l_module_name,'P_WMS_ENABLED_FLAG',P_WMS_ENABLED_FLAG);
674 WSH_DEBUG_SV.log(l_module_name,'P_DEL_BATCH_ID',P_DEL_BATCH_ID);
675 WSH_DEBUG_SV.log(l_module_name,'P_REPLENISHMENT_STATUS',p_replenishment_status);
676 WSH_DEBUG_SV.log(l_module_name,'l_standalone_mode',l_standalone_mode);
677 END IF;
678 --
679
680 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
681
682 -- J: W/V Changes
683 OPEN C1;
684 FETCH C1 INTO l_container_id, l_delivery_id;
685 CLOSE C1;
686
687 l_user_id := FND_GLOBAL.user_id;
688 l_login_id := FND_GLOBAL.login_id;
689
690 OPEN get_pref_grade(p_delivery_detail_id);
691 FETCH get_pref_grade INTO l_oeline_pref_grade,
692 l_organization_id, l_line_direction; -- LPN CONV. rv
693 CLOSE get_pref_grade;
694
695 UPDATE wsh_delivery_details
696 SET released_status = DECODE(requested_quantity, 0, 'D', decode(pickable_flag,'Y','B','X')) ,
697 requested_quantity = DECODE(p_requested_quantity, NULL, requested_quantity, p_requested_quantity),
698 requested_quantity2 = DECODE(p_requested_quantity2, NULL, requested_quantity2, p_requested_quantity2),
699 subinventory = original_subinventory,
700 --standalone project changes: start
701 locator_id = DECODE(l_standalone_mode,'D',original_locator_id ,NULL) ,
702 lot_number = DECODE(l_standalone_mode,'D',original_lot_number ,NULL) ,
703 revision = DECODE(l_standalone_mode,'D',original_revision ,NULL) ,
704 -- standalone project changes: end
705 move_order_line_id = DECODE(requested_quantity, 0, move_order_line_id, NULL),--Bug 2114166
706 picked_quantity = NULL,
707 picked_quantity2 = NULL,
708 preferred_grade = l_oeline_pref_grade,
709 serial_number = NULL,
710 -- Batch_id is required for additional processing in Release_Batch API and hence this is retained for Pick Release
711 -- Pick Release sets batch_id as Null for backordered details at the end of Pick Release process
712 batch_id = WSH_PICK_LIST.G_BATCH_ID,
713 lpn_id = NULL,
714 last_update_date = SYSDATE,
715 last_updated_by = l_user_id,
716 last_update_login = l_login_id,
717 transaction_id = NULL,
718 replenishment_status = p_replenishment_status --bug# 6689448 (replenishment project)
719 WHERE delivery_detail_id = p_delivery_detail_id
720 -- muom
721 RETURNING requested_quantity, requested_quantity2, gross_weight, net_weight, volume, organization_id
722 INTO x_split_quantity, x_split_quantity2, l_gross_weight, l_net_weight, l_volume, l_organization_id;
723 --Added organization_id for raise event: Pick to POD workflow
724
725 --
726 -- DBI Project
727 -- Update of wsh_delivery_details where released_status
728 -- are changed, call DBI API after the update.
729 -- This API will also check for DBI Installed or not
730 --DBI
731 WSH_DD_TXNS_PVT. create_dd_txn_from_dd (
732 p_delivery_detail_id => p_delivery_detail_id,
733 x_dd_txn_id => l_dd_txn_id,
734 x_return_status =>l_txn_return_status);
735 IF (l_txn_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
736 x_return_status := l_txn_return_status;
737 RETURN;
738 END IF;
739 --DBI
740
741 --bug# 6719369 (replenishment project) : replenishment case, invoke replenishment requested business event.
742 IF ( p_replenishment_status IS NULL ) THEN
743 --{
744 --Raise Event : Pick To Pod Workflow
745 WSH_WF_STD.Raise_Event(
746 p_entity_type => 'LINE',
747 p_entity_id => p_delivery_detail_id ,
748 p_event => 'oracle.apps.wsh.line.gen.backordered' ,
749 p_organization_id => l_organization_id,
750 x_return_status => l_wf_rs ) ;
751 IF l_debug_on THEN
752 WSH_DEBUG_SV.log(l_module_name,'Current Time is ',SYSDATE);
753 WSH_DEBUG_SV.log(l_module_name,'Delivery Detail Id is ',p_delivery_detail_id );
754 wsh_debug_sv.log(l_module_name,'Return Status After Calling WSH_WF_STD.Raise_Event',l_wf_rs);
755 END IF;
756 --Done Raise Event: Pick To Pod Workflow
757 ELSE
758 WSH_WF_STD.Raise_Event(
759 p_entity_type => 'LINE',
760 p_entity_id => p_delivery_detail_id ,
761 p_event => 'oracle.apps.wsh.line.gen.replenishmentrequested' ,
762 p_organization_id => l_organization_id,
763 x_return_status => l_wf_rs ) ;
764 IF l_debug_on THEN
765 WSH_DEBUG_SV.log(l_module_name,'Current Time is ',SYSDATE);
766 WSH_DEBUG_SV.log(l_module_name,'Delivery Detail Id is ',p_delivery_detail_id );
767 wsh_debug_sv.log(l_module_name,'Return Status After Calling WSH_WF_STD.Raise_Event',l_wf_rs);
768 END IF;
769 --}
770 END IF;
771
772
773 IF l_debug_on THEN
774 WSH_DEBUG_SV.log(l_module_name,'Calling DBI API.Detail id-',p_delivery_detail_id);
775 END IF;
776 l_detail_tab(1) := p_delivery_detail_id;
777 WSH_INTEGRATION.DBI_Update_Detail_Log
778 (p_delivery_detail_id_tab => l_detail_tab,
779 p_dml_type => 'UPDATE',
780 x_return_status => l_dbi_rs);
781
782 IF l_debug_on THEN
783 WSH_DEBUG_SV.log(l_module_name,'Return Status after DBI Call-',l_dbi_rs);
784 END IF;
785 IF l_dbi_rs = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
786 x_return_status := l_dbi_rs;
787 -- just pass this return status to caller API
788 IF l_debug_on THEN
789 WSH_DEBUG_SV.logmsg(l_module_name,'DBI API Returned Unexpected error '||x_return_status);
790 WSH_DEBUG_SV.pop(l_module_name);
791 END IF;
792 return;
793 END IF;
794 -- End of Code for DBI Project
795 --
796 --bug# 6719369 (replenishment2 project) : Unassigning delivery needs to be done only for back order delivery lines and not for
797 -- replenishment requested lines.
798 IF ( p_replenishment_status IS NULL ) THEN
799 --{
800 IF l_debug_on THEN
801 WSH_DEBUG_SV.log(l_module_name,'Updated wsh_delivery_details for backordered_delivery_detail ' ,p_delivery_detail_id);
802 END IF;
803 -- If Pick Release is run in Parallel Mode, then Unassigning is Deferred
804 -- Unassignment API is later called from WSH_PICK_LIST.Release_Batch API
805 -- For backordering in other cases or Non-Parallel Pick Release, unassign api is called immediately
806 IF WSH_PICK_LIST.G_PICK_REL_PARALLEL IS NULL OR (NOT WSH_PICK_LIST.G_PICK_REL_PARALLEL) THEN --{
807 -- Assigning all values to Backorder Table of Record
808 l_backorder_rec_tbl(1).delivery_detail_id := p_delivery_detail_id;
809 l_backorder_rec_tbl(1).delivery_id := l_delivery_id;
810 l_backorder_rec_tbl(1).container_id := l_container_id;
811 l_backorder_rec_tbl(1).organization_id := l_organization_id;
812 l_backorder_rec_tbl(1).line_direction := l_line_direction;
813 l_backorder_rec_tbl(1).planned_flag := p_planned_flag;
814 l_backorder_rec_tbl(1).gross_weight := l_gross_weight;
815 l_backorder_rec_tbl(1).net_weight := l_net_weight;
816 l_backorder_rec_tbl(1).volume := l_volume;
817 l_backorder_rec_tbl(1).del_batch_id := p_del_batch_id;
818
819 -- Assigning wms flag in Org Table Info
820 l_org_info_tbl(l_organization_id).wms_org := p_wms_enabled_flag;
821
822 IF l_debug_on THEN
823 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit Unassign_Backordered_Details',WSH_DEBUG_SV.C_PROC_LEVEL);
824 END IF;
825 Unassign_Backordered_Details (
826 p_backorder_rec_tbl => l_backorder_rec_tbl,
827 p_org_info_tbl => l_org_info_tbl,
828 x_return_status => l_return_status );
829
830 IF l_debug_on THEN
831 WSH_DEBUG_SV.log(l_module_name,'After Unassign_Backordered_Details: return',l_return_status);
832 END IF;
833 IF l_return_status IN (WSH_UTIL_CORE.G_RET_STS_ERROR, WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR) THEN
834 x_return_status := l_return_status;
835 WSH_UTIL_CORE.Add_Message(x_return_status);
836 IF l_debug_on THEN
837 WSH_DEBUG_SV.log(l_module_name,'Return Status',x_return_status);
838 WSH_DEBUG_SV.pop(l_module_name);
839 END IF;
840 RETURN;
841 ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_WARNING THEN
842 IF x_return_status = WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
843 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
844 END IF;
845 END IF;
846 --}
847 ELSE
848 IF l_debug_on THEN
849 WSH_DEBUG_SV.logmsg(l_module_name,'Deferring call to Unassign_Backordered_Details for detail : '||p_delivery_detail_id);
850 END IF;
851 END IF;
852 --}
853 END IF;
854
855 IF l_debug_on THEN
856 WSH_DEBUG_SV.log(l_module_name,'Return Status at the end of backorder_delivery_detail API is',x_return_status);
857 WSH_DEBUG_SV.pop(l_module_name);
858 END IF;
859
860 EXCEPTION
861
862 WHEN OTHERS THEN
863 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
864 WSH_UTIL_CORE.default_handler('WSH_USA_INV_PVT.backorder_delivery_detail');
865 IF l_debug_on THEN
866 WSH_DEBUG_SV.logmsg(l_module_name,'BACKORDER_DELIVERY_DETAIL_FAILED exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
867 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:BACKORDER_DELIVERY_DETAIL');
868 END IF;
869
870 END backorder_delivery_detail;
871
872 -- This procedure is used to find out how much of reservations need to be
873 -- transferred. It returns total staged and unstaged reservations
874
875 -- HW OPMCONV - Added Qty2
876 PROCEDURE Get_total_reserved_quantity (p_source_code IN VARCHAR2 ,
877 p_source_header_id IN NUMBER ,
878 p_source_line_id IN NUMBER ,
879 p_organization_id IN NUMBER ,
880 x_total_rsv IN OUT NOCOPY NUMBER ,
881 x_total_rsv2 IN OUT NOCOPY NUMBER ,
882 x_return_status IN OUT NOCOPY VARCHAR2)
883 IS
884 l_rsv_array inv_reservation_global.mtl_reservation_tbl_type;
885 l_size NUMBER ;
886 l_return_status VARCHAR2(1);
887
888 l_msg_count NUMBER;
889 l_msg_data VARCHAR2(2000);
890 l_staged_flag VARCHAR2(1);
891
892 totals_failed EXCEPTION;
893
894 -- HW OPMCONV - Added debug variable
895 l_debug_on BOOLEAN;
896 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PACKAGE_NAME || '.' || 'GET_TOTAL_RESERVED_QUANTITY';
897 BEGIN
898
899 --
900 -- Debug Statements
901 --
902 --
903 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
904 --
905 IF l_debug_on IS NULL THEN
906 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
907 -- add more debug messages
908 WSH_DEBUG_SV.push(l_module_name);
909 WSH_DEBUG_SV.log(l_module_name,'P_SOURCE_CODE',P_SOURCE_CODE);
910 WSH_DEBUG_SV.log(l_module_name,'P_SOURCE_HEADER_ID',P_SOURCE_HEADER_ID);
911 WSH_DEBUG_SV.log(l_module_name,'P_SOURCE_LINE_ID',P_SOURCE_LINE_ID);
912 WSH_DEBUG_SV.log(l_module_name,'P_ORGANIZATION_ID',P_ORGANIZATION_ID);
913 END IF;
914 --
915
916 x_total_rsv := 0 ;
917 -- HW OPMCONV - Added Qty2
918 x_total_rsv2 := 0 ;
919
920 query_reservations (
921 p_source_code => p_source_code,
922 p_source_header_id => p_source_header_id,
923 p_source_line_id => p_source_line_id,
924 p_organization_id => p_organization_id,
925 p_lock_records => fnd_api.g_true,
926 p_delivery_detail_id => null, --X-dock
927 x_mtl_reservation_tbl => l_rsv_array,
928 x_mtl_reservation_tbl_count => l_size,
929 x_return_status => l_return_status);
930
931 IF (l_return_status <> fnd_api.g_ret_sts_success) THEN
932 raise totals_failed;
933 END IF;
934
935 IF l_size = 0 THEN -- This case is specific for non staged reservations as
936 RETURN; -- for a backordered DD reservations might or might not exist
937 END IF;
938
939 oe_debug_pub.add('In Get_total_Reserved_quantity ',2);
940 oe_debug_pub.add('x_total_rsv , l_rsv_array(i).primary_reservation_quantity , l_rsv_array(i).requirement_Date ',2);
941
942 IF l_debug_on THEN
943 WSH_DEBUG_SV.log(l_module_name,'x_total_rsv2',x_total_rsv2);
944 END IF;
945
946 FOR i in 1..l_rsv_array.count
947 LOOP
948
949 x_total_rsv := x_total_rsv + l_rsv_array(i).primary_reservation_quantity ;
950 oe_debug_pub.add(x_total_rsv || ' : ' || l_rsv_array(i).primary_reservation_quantity || ' : ' || l_rsv_array(i).requirement_Date ,2);
951 -- HW OPMCONV - Get Qty2
952 x_total_rsv2 := x_total_rsv2 + l_rsv_array(i).secondary_reservation_quantity ;
953 IF l_debug_on THEN
954 WSH_DEBUG_SV.logmsg(l_module_name,'x_total_rsv2',x_total_rsv2);
955 END IF;
956
957 END LOOP ;
958
959 IF l_debug_on THEN
960 WSH_DEBUG_SV.pop(l_module_name);
961 END IF;
962
963 EXCEPTION
964 WHEN totals_failed THEN
965 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
966 WSH_UTIL_CORE.add_message (x_return_status);
967 IF l_debug_on THEN
968 WSH_DEBUG_SV.logmsg(l_module_name,'GET_TOTAL_RESERVED_QUANTITY exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
969 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:GET_TOTAL_RESERVED_QUANTITY');
970 END IF;
971
972 WHEN OTHERS THEN
973 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
974 WSH_UTIL_CORE.default_handler('WSH_USA_INV_PVT.Get_total_Reserved_quantity');
975 IF l_debug_on THEN
976 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
977 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
978 END IF;
979
980 END Get_total_Reserved_quantity ;
981
982
983 -- This is a wrapper on inv_reservation_pub.query_reservation_om_hdr_line
984 -- X-dock, added parameter p_delivery_detail_id
985 PROCEDURE query_reservations (
986 p_source_code IN VARCHAR2,
987 p_source_header_id IN NUMBER,
988 p_source_line_id IN NUMBER,
989 p_organization_id IN NUMBER,
990 p_lock_records IN VARCHAR2,
991 p_cancel_order_mode IN NUMBER,
992 p_direction_flag IN VARCHAR2 ,
993 p_delivery_detail_id IN NUMBER,
994 x_mtl_reservation_tbl OUT NOCOPY inv_reservation_global.mtl_reservation_tbl_type,
995 x_mtl_reservation_tbl_count OUT NOCOPY NUMBER,
996 x_return_status OUT NOCOPY VARCHAR2)
997
998 IS
999 l_rsv inv_reservation_global.mtl_reservation_rec_type;
1000 l_msg_count NUMBER;
1001 l_msg_data VARCHAR2(2000);
1002 l_error_text VARCHAR2(6000);
1003 l_error_code NUMBER;
1004 l_sales_order_id NUMBER;
1005 l_sort_by_req_date NUMBER ;
1006 query_reservation_failed EXCEPTION;
1007
1008
1009 --
1010 l_debug_on BOOLEAN;
1011 --
1012 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PACKAGE_NAME || '.' || 'QUERY_RESERVATIONS';
1013 --
1014 BEGIN
1015 --
1016 -- Debug Statements
1017 --
1018 --
1019 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
1020 --
1021 IF l_debug_on IS NULL
1022 THEN
1023 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
1024 END IF;
1025 --
1026 IF l_debug_on THEN
1027 WSH_DEBUG_SV.push(l_module_name);
1028 --
1029 WSH_DEBUG_SV.log(l_module_name,'P_SOURCE_CODE',P_SOURCE_CODE);
1030 WSH_DEBUG_SV.log(l_module_name,'P_SOURCE_HEADER_ID',P_SOURCE_HEADER_ID);
1031 WSH_DEBUG_SV.log(l_module_name,'P_SOURCE_LINE_ID',P_SOURCE_LINE_ID);
1032 WSH_DEBUG_SV.log(l_module_name,'P_ORGANIZATION_ID',P_ORGANIZATION_ID);
1033 WSH_DEBUG_SV.log(l_module_name,'P_LOCK_RECORDS',P_LOCK_RECORDS);
1034 WSH_DEBUG_SV.log(l_module_name,'P_CANCEL_ORDER_MODE',P_CANCEL_ORDER_MODE);
1035 WSH_DEBUG_SV.log(l_module_name,'P_DELIVERY_DETAIL_ID',P_DELIVERY_DETAIL_ID);
1036 END IF;
1037 --
1038 --
1039 -- Debug Statements
1040 --
1041 IF l_debug_on THEN
1042 WSH_DEBUG_SV.logmsg(l_module_name, 'IN WSH_USA_INV_PVT.QUERY_RESERVATIONS ORDER LINE = '|| P_SOURCE_LINE_ID );
1043 END IF;
1044 --
1045 --
1046 -- Debug Statements
1047 --
1048 IF l_debug_on THEN
1049 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit OE_ORDER_SCH_UTIL.GET_MTL_SALES_ORDER_ID',WSH_DEBUG_SV.C_PROC_LEVEL);
1050 END IF;
1051 --
1052 l_sales_order_id
1053 := OE_ORDER_SCH_UTIL.Get_mtl_sales_order_id(p_source_header_id);
1054 IF l_debug_on THEN
1055 WSH_DEBUG_SV.log(l_module_name,'l_sales_order_id',l_sales_order_id);
1056 END IF;
1057 l_rsv.demand_source_header_id := l_sales_order_id;
1058 l_rsv.demand_source_line_id := p_source_line_id;
1059 l_rsv.organization_id := p_organization_id;
1060 l_rsv.demand_source_line_detail := p_delivery_detail_id; -- X-dock
1061
1062 l_sort_by_req_date := inv_reservation_global.g_query_no_sort ;
1063
1064 if p_direction_flag = 'L' then
1065 -- The following statment is commented because we ideally need this code , but
1066 -- we cannot since it will mean we have to include INV's patch .
1067 -- When front-porting to newer releases , please use this statment instead of the following hard-coding.
1068 -- l_sort_by_req_date := inv_reservation_global.g_query_req_date_inv_desc ;
1069 l_sort_by_req_date := 5 ;
1070 elsif p_direction_flag = 'F' then
1071 -- l_sort_by_req_date := inv_reservation_global.g_query_req_date_inv_asc ;
1072 l_sort_by_req_date := 4 ;
1073 end if ;
1074 --
1075 -- Debug Statements
1076 --
1077 IF l_debug_on THEN
1078 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit INV_RESERVATION_PUB.QUERY_RESERVATION_OM_HDR_LINE',WSH_DEBUG_SV.C_PROC_LEVEL);
1079 END IF;
1080 --
1081 INV_RESERVATION_PUB.query_reservation_om_hdr_line
1082 (
1083 p_api_version_number => 1.0
1084 , p_init_msg_lst => fnd_api.g_true
1085 , x_return_status => x_return_status
1086 , x_msg_count => l_msg_count
1087 , x_msg_data => l_msg_data
1088 , p_query_input => l_rsv
1089 , p_cancel_order_mode => p_cancel_order_mode
1090 , x_mtl_reservation_tbl => x_mtl_reservation_tbl
1091 , x_mtl_reservation_tbl_count => x_mtl_reservation_tbl_count
1092 , x_error_code => l_error_code
1093 , p_lock_records => p_lock_records
1094 );
1095 IF l_debug_on THEN
1096 WSH_DEBUG_SV.log(l_module_name,'query_reservation_om_hdr_line x_return_status',x_return_status);
1097 END IF;
1098
1099
1100 IF x_return_status = fnd_api.g_ret_sts_success THEN
1101 --
1102 -- Debug Statements
1103 --
1104 IF l_debug_on THEN
1105 WSH_DEBUG_SV.logmsg(l_module_name, 'NUMBER OF RESERVATIONS FOUND: '||TO_CHAR ( X_MTL_RESERVATION_TBL_COUNT ) );
1106 END IF;
1107 --
1108 ELSE
1109 FND_MESSAGE.Set_Name('WSH', 'WSH_QUERY_RESERVATION');
1110 IF l_msg_count = 1 THEN
1111 --
1112 -- Debug Statements
1113 --
1114 IF l_debug_on THEN
1115 WSH_DEBUG_SV.logmsg(l_module_name, 'ERROR: '|| L_MSG_DATA );
1116 END IF;
1117 --
1118 FND_MESSAGE.Set_Token('ERROR_TEXT',l_msg_data);
1119 ELSE
1120 FOR l_index IN 1..l_msg_count LOOP
1121 l_msg_data := fnd_msg_pub.get;
1122 --
1123 -- Debug Statements
1124 --
1125 IF l_debug_on THEN
1126 WSH_DEBUG_SV.logmsg(l_module_name, 'ERROR: '|| L_MSG_DATA );
1127 END IF;
1128 --
1129 l_error_text := l_error_text || l_msg_data;
1130 END LOOP;
1131 FND_MESSAGE.Set_Token('ERROR_TEXT',l_error_text);
1132 END IF;
1133 raise query_reservation_failed;
1134 END IF;
1135
1136 --
1137 -- Debug Statements
1138 --
1139 IF l_debug_on THEN
1140 WSH_DEBUG_SV.pop(l_module_name);
1141 END IF;
1142 --
1143 EXCEPTION
1144 WHEN query_reservation_failed THEN
1145 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1146 WSH_UTIL_CORE.add_message (x_return_status,l_module_name);
1147 IF l_debug_on THEN
1148 WSH_DEBUG_SV.logmsg(l_module_name,'QUERY_RESERVATION_FAILED exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1149 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:QUERY_RESERVATION_FAILED');
1150 END IF;
1151 END QUERY_RESERVATIONS;
1152
1153 -- This is a wrapper on inv_reservation_pub.delete_reservation
1154 PROCEDURE delete_reservation (
1155 p_query_input IN inv_reservation_global.mtl_reservation_rec_type,
1156 x_return_status OUT NOCOPY VARCHAR2)
1157 IS
1158 l_msg_count NUMBER;
1159 l_msg_data VARCHAR2(2000);
1160 l_error_text VARCHAR2(6000);
1161 l_dummy_sn INV_RESERVATION_GLOBAL.serial_number_tbl_type;
1162 delete_reservation_failed EXCEPTION;
1163
1164 --
1165 l_debug_on BOOLEAN;
1166 --
1167 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PACKAGE_NAME || '.' || 'DELETE_RESERVATION';
1168 --
1169 BEGIN
1170 --
1171 -- Debug Statements
1172 --
1173 --
1174 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
1175 --
1176 IF l_debug_on IS NULL
1177 THEN
1178 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
1179 END IF;
1180 --
1181 IF l_debug_on THEN
1182 WSH_DEBUG_SV.push(l_module_name);
1183 WSH_DEBUG_SV.logmsg(l_module_name, 'IN WSH_USA_INV_PVT.DELETE_RESERVATION ORDER LINE = '|| P_QUERY_INPUT.DEMAND_SOURCE_LINE_ID );
1184 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit INV_RESERVATION_PUB.DELETE_RESERVATION',WSH_DEBUG_SV.C_PROC_LEVEL);
1185 END IF;
1186
1187 INV_RESERVATION_PUB.delete_reservation
1188 (
1189 p_api_version_number => 1.0
1190 , p_init_msg_lst => fnd_api.g_true
1191 , x_return_status => x_return_status
1192 , x_msg_count => l_msg_count
1193 , x_msg_data => l_msg_data
1194 , p_rsv_rec => p_query_input
1195 , p_serial_number => l_dummy_sn
1196 );
1197 IF l_debug_on THEN
1198 WSH_DEBUG_SV.log(l_module_name,'delete_reservation x_return_status',x_return_status);
1199 END IF;
1200
1201 IF x_return_status = fnd_api.g_ret_sts_success THEN
1202 --
1203 -- Debug Statements
1204 --
1205 IF l_debug_on THEN
1206 WSH_DEBUG_SV.logmsg(l_module_name, 'RESERVATION DELETED FOR RESERVATION ID : '||P_QUERY_INPUT.RESERVATION_ID );
1207 END IF;
1208 --
1209 ELSE
1210 --
1211 -- Debug Statements
1212 --
1213 IF l_debug_on THEN
1214 WSH_DEBUG_SV.logmsg(l_module_name, 'COULD NOT DELETE RESERVATION FOR RESERVATION ID : '||P_QUERY_INPUT.RESERVATION_ID );
1215 END IF;
1216 --
1217 FND_MESSAGE.Set_Name('WSH', 'WSH_DELETE_RESERVATION');
1218 IF l_msg_count = 1 THEN
1219 --
1220 -- Debug Statements
1221 --
1222 IF l_debug_on THEN
1223 WSH_DEBUG_SV.logmsg(l_module_name, 'ERROR: '|| L_MSG_DATA );
1224 END IF;
1225 --
1226 FND_MESSAGE.Set_Token('ERROR_TEXT',l_msg_data);
1227 ELSE
1228 FOR l_index IN 1..l_msg_count LOOP
1229 l_msg_data := fnd_msg_pub.get;
1230 --
1231 -- Debug Statements
1232 --
1233 IF l_debug_on THEN
1234 WSH_DEBUG_SV.logmsg(l_module_name, 'ERROR: '|| L_MSG_DATA );
1235 END IF;
1236 --
1237 l_error_text := l_error_text || l_msg_data;
1238 END LOOP;
1239 FND_MESSAGE.Set_Token('ERROR_TEXT',l_error_text);
1240 END IF;
1241 raise delete_reservation_failed;
1242 END IF;
1243
1244 --
1245 -- Debug Statements
1246 --
1247 IF l_debug_on THEN
1248 WSH_DEBUG_SV.pop(l_module_name);
1249 END IF;
1250 --
1251 EXCEPTION
1252 WHEN delete_reservation_failed THEN
1253 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1254 WSH_UTIL_CORE.add_message (x_return_status,l_module_name);
1255 --
1256 -- Debug Statements
1257 --
1258 IF l_debug_on THEN
1259 WSH_DEBUG_SV.logmsg(l_module_name,'DELETE_RESERVATION_FAILED exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1260 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:DELETE_RESERVATION_FAILED');
1261 END IF;
1262 --
1263 END delete_reservation;
1264
1265 -- This is a wrapper on inv_reservation_pub.create_reservation
1266 -- HW OPMCONV Pass Qty2 in order to call the correct INV_create_reservation
1267 PROCEDURE create_reservation (
1268 p_query_input IN inv_reservation_global.mtl_reservation_rec_type,
1269 p_qty2 IN NUMBER default NULL,
1270 x_reservation_id OUT NOCOPY NUMBER,
1271 x_qty_reserved OUT NOCOPY NUMBER,
1272 x_return_status OUT NOCOPY VARCHAR2)
1273
1274 IS
1275
1276 l_msg_count NUMBER;
1277 l_msg_data VARCHAR2(2000);
1278 l_error_text VARCHAR2(6000);
1279 l_dummy_sn INV_RESERVATION_GLOBAL.serial_number_tbl_type;
1280
1281 -- HW OPMCONV - Added variable
1282 X_SECONDARY_QTY_RESERVED NUMBER;
1283
1284 create_reservation_failed EXCEPTION;
1285
1286 --
1287 l_debug_on BOOLEAN;
1288 --
1289 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PACKAGE_NAME || '.' || 'CREATE_RESERVATION';
1290 --
1291 BEGIN
1292 /* if OPM do null */
1293 --
1294 -- Debug Statements
1295 --
1296 --
1297 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
1298 --
1299 IF l_debug_on IS NULL
1300 THEN
1301 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
1302 END IF;
1303 --
1304 IF l_debug_on THEN
1305 WSH_DEBUG_SV.push(l_module_name);
1306 WSH_DEBUG_SV.log(l_module_name, 'p_query_input.organization_id',p_query_input.organization_id);
1307 END IF;
1308 --
1309 --
1310 -- Debug Statements
1311 --
1312
1313 -- HW OPMCONV. Removed forking
1314 --
1315 --
1316 -- Debug Statements
1317 --
1318 IF l_debug_on THEN
1319 WSH_DEBUG_SV.logmsg(l_module_name, 'IN WSH_USA_INV_PVT.CREATE_RESERVATION ' );
1320 END IF;
1321 --
1322
1323 --
1324 -- Debug Statements
1325 --
1326 IF l_debug_on THEN
1327 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit INV_RESERVATION_PUB.CREATE_RESERVATION',WSH_DEBUG_SV.C_PROC_LEVEL);
1328 END IF;
1329 --
1330
1331
1332 -- HW OPMCONV check if qty2 exists to call the correct API
1333 IF ( p_qty2 is NULL OR p_qty2 = FND_API.G_MISS_NUM ) THEN
1334 INV_RESERVATION_PUB.create_reservation
1335 (
1336 p_api_version_number => 1.0
1337 , p_init_msg_lst => fnd_api.g_true
1338 , x_return_status => x_return_status
1339 , x_msg_count => l_msg_count
1340 , x_msg_data => l_msg_data
1341 , p_rsv_rec => p_query_input
1342 , p_serial_number => l_dummy_sn
1343 , x_serial_number => l_dummy_sn
1344 , p_partial_reservation_flag => fnd_api.g_true
1345 , p_force_reservation_flag => fnd_api.g_false
1346 , p_validation_flag => fnd_api.g_true
1347 -- bug 5333667: remove p_over_reservation_flag added by bug 5099694
1348 -- because it is necessary to validate the new reservation.
1349 , x_quantity_reserved => x_qty_reserved
1350 , x_reservation_id => x_reservation_id
1351 );
1352 ELSE
1353 INV_RESERVATION_PUB.create_reservation
1354 (
1355 p_api_version_number => 1.0
1356 , p_init_msg_lst => fnd_api.g_true
1357 , x_return_status => x_return_status
1358 , x_msg_count => l_msg_count
1359 , x_msg_data => l_msg_data
1360 , p_rsv_rec => p_query_input
1361 , p_serial_number => l_dummy_sn
1362 , x_serial_number => l_dummy_sn
1363 , p_partial_reservation_flag => fnd_api.g_true
1364 , p_force_reservation_flag => fnd_api.g_false
1365 -- Bug 5099694
1366 , p_over_reservation_flag =>3
1367 , p_validation_flag => fnd_api.g_true
1368 , x_quantity_reserved => x_qty_reserved
1369 , x_secondary_quantity_reserved => x_secondary_qty_reserved
1370 , x_reservation_id => x_reservation_id
1371 );
1372 END IF;
1373 IF l_debug_on THEN
1374 WSH_DEBUG_SV.log(l_module_name,'INV_RESERVATION_PUB.CREATE_RESERVATION',x_return_status);
1375 END IF;
1376
1377 IF x_return_status = fnd_api.g_ret_sts_success THEN
1378 --
1379 -- Debug Statements
1380 --
1381 IF l_debug_on THEN
1382 WSH_DEBUG_SV.logmsg(l_module_name, 'RESERVATION CREATED FOR RESERVATION ID : '||X_RESERVATION_ID );
1383 END IF;
1384 --
1385 ELSE
1386 FND_MESSAGE.Set_Name('WSH', 'WSH_CREATE_RESERVATION');
1387 IF l_msg_count = 1 THEN
1388 --
1389 -- Debug Statements
1390 --
1391 IF l_debug_on THEN
1392 WSH_DEBUG_SV.logmsg(l_module_name, 'ERROR: '|| L_MSG_DATA );
1393 END IF;
1394 --
1395 FND_MESSAGE.Set_Token('ERROR_TEXT',l_msg_data);
1396 ELSE
1397 FOR l_index IN 1..l_msg_count LOOP
1398 l_msg_data := fnd_msg_pub.get;
1399 --
1400 -- Debug Statements
1401 --
1402 IF l_debug_on THEN
1403 WSH_DEBUG_SV.logmsg(l_module_name, 'ERROR: '|| L_MSG_DATA );
1404 END IF;
1405 --
1406 l_error_text := l_error_text || l_msg_data;
1407 END LOOP;
1408 FND_MESSAGE.Set_Token('ERROR_TEXT',l_error_text);
1409 END IF;
1410 raise create_reservation_failed;
1411 END IF;
1412 -- HW OPMCONV removed forking
1413
1414
1415 --
1416 -- Debug Statements
1417 --
1418 IF l_debug_on THEN
1419 WSH_DEBUG_SV.pop(l_module_name);
1420 END IF;
1421 --
1422 EXCEPTION
1423 WHEN create_reservation_failed THEN
1424 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1425 WSH_UTIL_CORE.add_message (x_return_status,l_module_name);
1426 --
1427 -- Debug Statements
1428 --
1429 IF l_debug_on THEN
1430 WSH_DEBUG_SV.logmsg(l_module_name,'CREATE_RESERVATION_FAILED exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1431 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:CREATE_RESERVATION_FAILED');
1432 END IF;
1433 --
1434 END;
1435
1436
1437 -- This is a wrapper on inv_reservation_pub.update_reservation
1438 PROCEDURE update_reservation (
1439 p_query_input IN inv_reservation_global.mtl_reservation_rec_type,
1440 p_new_resv_rec IN inv_reservation_global.mtl_reservation_rec_type,
1441 x_return_status OUT NOCOPY VARCHAR2)
1442
1443 IS
1444
1445 l_msg_count NUMBER;
1446 l_msg_data VARCHAR2(2000);
1447 l_error_text VARCHAR2(6000);
1448 l_dummy_sn INV_RESERVATION_GLOBAL.serial_number_tbl_type;
1449
1450 update_reservation_failed EXCEPTION;
1451
1452 --
1453 l_debug_on BOOLEAN;
1454 --
1455 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PACKAGE_NAME || '.' || 'UPDATE_RESERVATION';
1456 --
1457 BEGIN
1458 --
1459 -- Debug Statements
1460 --
1461 --
1462 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
1463 --
1464 IF l_debug_on IS NULL
1465 THEN
1466 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
1467 END IF;
1468 --
1469 IF l_debug_on THEN
1470 WSH_DEBUG_SV.push(l_module_name);
1471 WSH_DEBUG_SV.log(l_module_name,'p_query_input.reservation_id',p_query_input.reservation_id);
1472 WSH_DEBUG_SV.log(l_module_name,'p_query_input.organization_id',p_query_input.organization_id);
1473 WSH_DEBUG_SV.log(l_module_name,'p_query_input.inventory_item_id',p_query_input.inventory_item_id);
1474 WSH_DEBUG_SV.log(l_module_name,'p_new_resv_rec.reservation_id',p_new_resv_rec.reservation_id);
1475 WSH_DEBUG_SV.log(l_module_name,'p_new_resv_rec.organization_id',p_new_resv_rec.organization_id);
1476 WSH_DEBUG_SV.log(l_module_name,'p_new_resv_rec.inventory_item_id',p_new_resv_rec.inventory_item_id);
1477
1478 WSH_DEBUG_SV.logmsg(l_module_name, 'DEBUGGING IN UPDATE RESER' );
1479 WSH_DEBUG_SV.logmsg(l_module_name, 'p_new_resv_recsecondary_reservation_quantity '||p_new_resv_rec.secondary_reservation_quantity );
1480 WSH_DEBUG_SV.logmsg(l_module_name, 'p_new_resv_rec.secondary_UOM_CODE '||p_new_resv_rec.secondary_uom_code );
1481 WSH_DEBUG_SV.logmsg(l_module_name, 'p_new_resv_rec.secondary_ID '||p_new_resv_rec.secondary_uom_id );
1482
1483
1484 END IF;
1485 --
1486 -- Debug Statements
1487 --
1488 IF l_debug_on THEN
1489 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit INV_RESERVATION_PUB.UPDATE_RESERVATION',WSH_DEBUG_SV.C_PROC_LEVEL);
1490 END IF;
1491 --
1492
1493
1494 INV_RESERVATION_PUB.update_reservation
1495 (
1496 p_api_version_number => 1.0
1497 , p_init_msg_lst => fnd_api.g_true
1498 , x_return_status => x_return_status
1499 , x_msg_count => l_msg_count
1500 , x_msg_data => l_msg_data
1501 , p_original_rsv_rec => p_query_input
1502 , p_to_rsv_rec => p_new_resv_rec
1503 , p_original_serial_number => l_dummy_sn -- no serial contorl
1504 , p_to_serial_number => l_dummy_sn -- no serial control
1505 , p_validation_flag => fnd_api.g_true
1506 -- Bug 5099694
1507 , p_over_reservation_flag =>3
1508 );
1509 IF l_debug_on THEN
1510 WSH_DEBUG_SV.log(l_module_name,'INV_RESERVATION_PUB.update_reservation',x_return_status);
1511 END IF;
1512
1513 IF x_return_status = fnd_api.g_ret_sts_success THEN
1514 --
1515 -- Debug Statements
1516 --
1517 IF l_debug_on THEN
1518 WSH_DEBUG_SV.logmsg(l_module_name, 'RESERVATION UPDATED FOR RESERVATION ID : '||TO_CHAR ( P_QUERY_INPUT.RESERVATION_ID ) );
1519 END IF;
1520 --
1521 ELSE
1522 FND_MESSAGE.Set_Name('WSH', 'WSH_UPDATE_RESERVATION');
1523 IF l_msg_count = 1 THEN
1524 --
1525 -- Debug Statements
1526 --
1527 IF l_debug_on THEN
1528 WSH_DEBUG_SV.logmsg(l_module_name, 'ERROR: '|| L_MSG_DATA );
1529 END IF;
1530 --
1531 FND_MESSAGE.Set_Token('ERROR_TEXT',l_msg_data);
1532 ELSE
1533 FOR l_index IN 1..l_msg_count LOOP
1534 l_msg_data := fnd_msg_pub.get;
1535 --
1536 -- Debug Statements
1537 --
1538 IF l_debug_on THEN
1539 WSH_DEBUG_SV.logmsg(l_module_name, 'ERROR: '|| L_MSG_DATA );
1540 END IF;
1541 --
1542 l_error_text := l_error_text || l_msg_data;
1543 END LOOP;
1544 FND_MESSAGE.Set_Token('ERROR_TEXT',l_error_text);
1545 END IF;
1546 raise update_reservation_failed;
1547 END IF;
1548
1549 --
1550 -- Debug Statements
1551 --
1552 IF l_debug_on THEN
1553 WSH_DEBUG_SV.pop(l_module_name);
1554 END IF;
1555 --
1556 EXCEPTION
1557 WHEN update_reservation_failed THEN
1558 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1559 WSH_UTIL_CORE.add_message (x_return_status,l_module_name);
1560 --
1561 -- Debug Statements
1562 --
1563 IF l_debug_on THEN
1564 WSH_DEBUG_SV.logmsg(l_module_name,'UPDATE_RESERVATION_FAILED exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1565 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:UPDATE_RESERVATION_FAILED');
1566 END IF;
1567 --
1568 END;
1569
1570 FUNCTION check_allocations (
1571 p_move_order_line_id IN NUMBER) RETURN BOOLEAN
1572 IS
1573 l_trolin_rec INV_MOVE_ORDER_PUB.Trolin_Rec_Type;
1574
1575 --
1576 l_debug_on BOOLEAN;
1577 --
1578 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PACKAGE_NAME || '.' || 'CHECK_ALLOCATIONS';
1579 --
1580 BEGIN
1581 --
1582 -- Debug Statements
1583 --
1584 --
1585 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
1586 --
1587 IF l_debug_on IS NULL
1588 THEN
1589 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
1590 END IF;
1591 --
1592 IF l_debug_on THEN
1593 WSH_DEBUG_SV.push(l_module_name);
1594 --
1595 WSH_DEBUG_SV.log(l_module_name,'P_MOVE_ORDER_LINE_ID',P_MOVE_ORDER_LINE_ID);
1596 END IF;
1597 --
1598 --
1599 -- Debug Statements
1600 --
1601 IF l_debug_on THEN
1602 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit INV_TROLIN_UTIL.QUERY_ROW',WSH_DEBUG_SV.C_PROC_LEVEL);
1603 END IF;
1604 --
1605 l_trolin_rec := INV_TROLIN_UTIL.Query_Row(
1606 p_line_id => p_move_order_line_id);
1607 IF nvl(l_trolin_rec.quantity_detailed,0) > 0 THEN
1608 --
1609 -- Debug Statements
1610 --
1611 IF l_debug_on THEN
1612 WSH_DEBUG_SV.pop(l_module_name);
1613 END IF;
1614 --
1615 RETURN TRUE;
1616 ELSE
1617 --
1618 -- Debug Statements
1619 --
1620 IF l_debug_on THEN
1621 WSH_DEBUG_SV.pop(l_module_name);
1622 END IF;
1623 --
1624 RETURN FALSE;
1625 END IF;
1626 END;
1627
1628 -- This private function checks the inventory information for the delivery detail against those of the
1629 -- reservation record and returns TRUE if they match
1630 -- 3012297 (for OPM - adding delivery_detail_id parameter)
1631 FUNCTION check_inv_info (
1632 p_delivery_detail_split_rec IN DeliveryDetailInvRecType,
1633 p_delivery_detail_id IN NUMBER default NULL,
1634 p_rsv IN inv_reservation_global.mtl_reservation_rec_type
1635 ) return BOOLEAN IS
1636
1637 --
1638 l_debug_on BOOLEAN;
1639 --
1640 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PACKAGE_NAME || '.' || 'CHECK_INV_INFO';
1641 --
1642
1643 -- 3012297
1644 -- HW OPMCONV. Removed OPM local variables
1645
1646 l_delivery_detail_id NUMBER;
1647 l_organization_id NUMBER;
1648
1649 Cursor get_dd_info (p_delivery_detail_id IN NUMBER) is
1650 Select organization_id
1651 From wsh_delivery_details
1652 Where delivery_detail_id = p_delivery_detail_id;
1653 BEGIN
1654 --
1655 -- Debug Statements
1656 --
1657 --
1658 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
1659 --
1660 IF l_debug_on IS NULL
1661 THEN
1662 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
1663 END IF;
1664 --
1665 IF l_debug_on THEN
1666 WSH_DEBUG_SV.push(l_module_name);
1667 END IF;
1668 --
1669 --
1670 -- Debug Statements
1671 --
1672 IF l_debug_on THEN
1673 -- HW BUG#:3456926 - Removed OPM debugging msg and kept WSH
1674 WSH_DEBUG_SV.logmsg(l_module_name, 'IN WSH_USA_INV_PVT.CHECK_INV_INFO FOR DETAIL : '|| P_DELIVERY_DETAIL_SPLIT_REC.DELIVERY_DETAIL_ID||' REL STAT : '||P_DELIVERY_DETAIL_SPLIT_REC.RELEASED_STATUS );
1675 END IF;
1676 --
1677
1678 -- 3012297 (initializing l_process_flag)
1679
1680 IF p_delivery_detail_id is NULL THEN
1681 l_delivery_detail_id := p_delivery_detail_split_rec.delivery_detail_id;
1682 l_organization_id := p_delivery_detail_split_rec.organization_id;
1683 ELSE
1684 OPEN get_dd_info(p_delivery_detail_id);
1685 FETCH get_dd_info
1686 INTO l_organization_id;
1687 ClOSE get_dd_info;
1688 l_delivery_detail_id := p_delivery_detail_id;
1689 END IF;
1690 -- HW OPMCONV. Removed checking for process org
1691
1692
1693 --HW OPMCONV. Removed code forking
1694
1695 IF p_delivery_detail_split_rec.subinventory IS NOT NULL THEN
1696 IF p_delivery_detail_split_rec.subinventory <> p_rsv.subinventory_code THEN
1697 --
1698 -- Debug Statements
1699 --
1700 IF l_debug_on THEN
1701 WSH_DEBUG_SV.pop(l_module_name);
1702 END IF;
1703 --
1704 return FALSE;
1705 END IF;
1706
1707 END IF;
1708
1709
1710 IF p_delivery_detail_split_rec.revision IS NOT NULL THEN
1711 IF p_delivery_detail_split_rec.revision <> p_rsv.revision THEN
1712 --
1713 -- Debug Statements
1714 --
1715 IF l_debug_on THEN
1716 WSH_DEBUG_SV.pop(l_module_name);
1717 END IF;
1718 --
1719 return FALSE;
1720 END IF;
1721 END IF;
1722 IF p_delivery_detail_split_rec.lot_number IS NOT NULL THEN
1723 IF p_delivery_detail_split_rec.lot_number <> p_rsv.lot_number THEN
1724 --
1725 -- Debug Statements
1726 --
1727 IF l_debug_on THEN
1728 WSH_DEBUG_SV.pop(l_module_name);
1729 END IF;
1730 --
1731 return FALSE;
1732 END IF;
1733 END IF;
1734
1735 -- Bug 2773605: In addition to the inventory controls , the lpn_id should also
1736 -- be the same.
1737 IF p_delivery_detail_split_rec.lpn_id IS NOT NULL THEN
1738 IF p_delivery_detail_split_rec.lpn_id <> p_rsv.lpn_id THEN
1739 --
1740 -- Debug Statements
1741 --
1742 IF l_debug_on THEN
1743 WSH_DEBUG_SV.pop(l_module_name);
1744 END IF;
1745 --
1746 return FALSE;
1747 END IF;
1748 END IF;
1749
1750 IF p_delivery_detail_split_rec.locator_id IS NOT NULL THEN
1751 IF p_delivery_detail_split_rec.locator_id <> p_rsv.locator_id THEN
1752 --
1753 -- Debug Statements
1754 --
1755 IF l_debug_on THEN
1756 WSH_DEBUG_SV.pop(l_module_name);
1757 END IF;
1758 --
1759 return FALSE;
1760 END IF;
1761 END IF;
1762 -- HW OPMCONV. Removed ELSE. No need to fork the code
1763 --
1764 -- Debug Statements
1765 --
1766 IF l_debug_on THEN
1767 WSH_DEBUG_SV.pop(l_module_name);
1768 END IF;
1769 --
1770 return TRUE;
1771
1772 END check_inv_info;
1773
1774 -- This procedure takes care that staged reservations get reduced by the cancellation quantity from
1775 -- appropriate inventory controls when some quantity from a staged delivery line is reduced
1776 PROCEDURE cancel_staged_reservation (
1777 p_source_code IN VARCHAR2,
1778 p_source_header_id IN NUMBER,
1779 p_source_line_id IN NUMBER,
1780 p_delivery_detail_split_rec IN DeliveryDetailInvRecType,
1781 p_cancellation_quantity IN NUMBER,
1782 p_cancellation_quantity2 IN NUMBER,
1783 x_return_status OUT NOCOPY VARCHAR2)
1784 IS
1785
1786 l_rsv inv_reservation_global.mtl_reservation_rec_type;
1787 l_rsv_new inv_reservation_global.mtl_reservation_rec_type;
1788 l_rsv_array inv_reservation_global.mtl_reservation_tbl_type;
1789 l_size NUMBER;
1790 l_msg_count NUMBER;
1791 l_msg_data VARCHAR2(240);
1792 l_cancelled_reservation_qty NUMBER;
1793 l_cancelled_reservation_qty2 NUMBER;
1794 l_cancellation_quantity NUMBER;
1795 l_cancellation_quantity2 NUMBER;
1796 l_staged_flag VARCHAR2(1);
1797 -- HW OPMCONV. Removed OPM variables
1798
1799 l_pickable_flag VARCHAR2(1);
1800 l_reservable_flag VARCHAR2(1);
1801
1802 l_delivery_detail_id NUMBER;
1803
1804 cursor pickable_flag (p_delivery_detail IN number) is
1805 select pickable_flag
1806 from wsh_delivery_details
1807 where delivery_detail_id = p_delivery_detail;
1808
1809 cancel_failed EXCEPTION;
1810
1811 --
1812 l_debug_on BOOLEAN;
1813 --
1814 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PACKAGE_NAME || '.' || 'CANCEL_STAGED_RESERVATION';
1815 --
1816 BEGIN
1817
1818 --
1819 -- Debug Statements
1820 --
1821 --
1822 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
1823 --
1824 IF l_debug_on IS NULL
1825 THEN
1826 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
1827 END IF;
1828 --
1829 IF l_debug_on THEN
1830 WSH_DEBUG_SV.push(l_module_name);
1831 --
1832 WSH_DEBUG_SV.log(l_module_name,'P_SOURCE_CODE',P_SOURCE_CODE);
1833 WSH_DEBUG_SV.log(l_module_name,'P_SOURCE_HEADER_ID',P_SOURCE_HEADER_ID);
1834 WSH_DEBUG_SV.log(l_module_name,'P_SOURCE_LINE_ID',P_SOURCE_LINE_ID);
1835 WSH_DEBUG_SV.log(l_module_name,'P_CANCELLATION_QUANTITY',P_CANCELLATION_QUANTITY);
1836 WSH_DEBUG_SV.log(l_module_name,'P_CANCELLATION_QUANTITY2',P_CANCELLATION_QUANTITY2);
1837 WSH_DEBUG_SV.log(l_module_name,'p_delivery_detail_split_rec.organization_id',p_delivery_detail_split_rec.organization_id);
1838 WSH_DEBUG_SV.log(l_module_name,'p_delivery_detail_split_rec.delivery_detail_id',p_delivery_detail_split_rec.delivery_detail_id);
1839 WSH_DEBUG_SV.log(l_module_name,'p_delivery_detail_split_rec.inventory_item_id',p_delivery_detail_split_rec.inventory_item_id);
1840 END IF;
1841 --
1842 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
1843
1844 IF p_cancellation_quantity = 0 THEN
1845 --
1846 -- Debug Statements
1847 --
1848 IF l_debug_on THEN
1849 WSH_DEBUG_SV.pop(l_module_name);
1850 END IF;
1851 --
1852 RETURN;
1853 END IF;
1854
1855 --
1856 -- Debug Statements
1857 --
1858 IF l_debug_on THEN
1859 WSH_DEBUG_SV.logmsg(l_module_name, 'IN WSH_USA_INV_PVT.CANCEL_STAGED_RESERVATION QUANTITY : '|| P_CANCELLATION_QUANTITY );
1860 END IF;
1861 --
1862
1863 --X-dock, conditionally populate delivery_detail_id
1864 WSH_USA_INV_PVT.get_putaway_detail_id
1865 (p_detail_id => p_delivery_detail_split_rec.delivery_detail_id,
1866 p_released_status => p_delivery_detail_split_rec.released_status,
1867 p_move_order_line_id => p_delivery_detail_split_rec.move_order_line_id,
1868 x_detail_id => l_delivery_detail_id,
1869 x_return_status => x_return_status);
1870
1871 IF x_return_status <> fnd_api.g_ret_sts_success THEN
1872 raise cancel_failed;
1873 END IF;
1874 --end of X-dock
1875
1876 -- X-dock, l_rsv_array would be appropriately populated with null or not null
1877 -- value of delivery_detail_id and used in delete_reservation or update_reservation calls
1878 query_reservations (
1879 p_source_code => p_source_code,
1880 p_source_header_id => p_source_header_id,
1881 p_source_line_id => p_source_line_id,
1882 p_organization_id => p_delivery_detail_split_rec.organization_id,
1883 p_lock_records => fnd_api.g_true,
1884 p_delivery_detail_id => l_delivery_detail_id, --X-dock changes
1885 x_mtl_reservation_tbl => l_rsv_array,
1886 x_mtl_reservation_tbl_count => l_size,
1887 x_return_status => x_return_status);
1888
1889
1890 --
1891 -- Debug Statements
1892 --
1893 IF l_debug_on THEN
1894 WSH_DEBUG_SV.log(l_module_name, 'query_reservations x_return_status',x_return_status);
1895 WSH_DEBUG_SV.logmsg(l_module_name, 'L_SIZE: '||L_SIZE );
1896 END IF;
1897
1898 IF (x_return_status <> fnd_api.g_ret_sts_success) OR (l_size = 0) THEN
1899 IF x_return_status = fnd_api.g_ret_sts_success THEN
1900 OPEN pickable_flag(p_delivery_detail_split_rec.delivery_detail_id);
1901 FETCH pickable_flag INTO l_pickable_flag;
1902 CLOSE pickable_flag;
1903 --
1904 -- Debug Statements
1905 --
1906 IF l_debug_on THEN
1907 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DELIVERY_DETAILS_INV.GET_RESERVABLE_FLAG',WSH_DEBUG_SV.C_PROC_LEVEL);
1908 END IF;
1909 --
1910 l_reservable_flag := WSH_DELIVERY_DETAILS_INV.get_reservable_flag(
1911 x_item_id => p_delivery_detail_split_rec.inventory_item_id,
1912 x_organization_id => p_delivery_detail_split_rec.organization_id,
1913 x_pickable_flag => l_pickable_flag);
1914 IF l_debug_on THEN
1915 WSH_DEBUG_SV.log(l_module_name, 'get_reservable_flag l_reservable_flag,x_return_status',l_reservable_flag||','||x_return_status);
1916 END IF;
1917 -- Non reservable/transactable items will always have no reservations.
1918 IF l_reservable_flag = 'N' THEN
1919 --
1920 -- Debug Statements
1921 --
1922 IF l_debug_on THEN
1923 WSH_DEBUG_SV.logmsg(l_module_name, 'NON RESERVABLE/TRANSACTABLE ITEM' );
1924 WSH_DEBUG_SV.pop(l_module_name);
1925 END IF;
1926 RETURN;
1927 END IF;
1928 END IF;
1929 raise cancel_failed;
1930 END IF;
1931
1932 l_cancellation_quantity := p_cancellation_quantity;
1933 l_cancellation_quantity2 := p_cancellation_quantity2;
1934
1935 --
1936 -- Debug Statements
1937 --
1938 -- HW OPMCONV. Removed checking for process org
1939
1940
1941 -- loop over all the reservation records in l_rsv_array
1942
1943 FOR l_counter in 1..l_size
1944 LOOP
1945 IF NOT l_cancellation_quantity > 0 THEN
1946 EXIT;
1947 END IF;
1948 -- HW OPMCONV. No need to fork code
1949 --
1950 -- Debug Statements
1951 --
1952 IF l_debug_on THEN
1953 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit INV_STAGED_RESERVATION_UTIL.QUERY_STAGED_FLAG',WSH_DEBUG_SV.C_PROC_LEVEL);
1954 END IF;
1955 --
1956 INV_STAGED_RESERVATION_UTIL.query_staged_flag
1957 ( x_return_status => x_return_status,
1958 x_msg_count => l_msg_count,
1959 x_msg_data => l_msg_data,
1960 x_staged_flag => l_staged_flag,
1961 p_reservation_id => l_rsv_array(l_counter).reservation_id);
1962 IF l_debug_on THEN
1963 WSH_DEBUG_SV.log(l_module_name, 'query_staged_flag x_return_status',x_return_status);
1964 END IF;
1965 -- HW OPMCONV. No need to fork code
1966
1967 --
1968 -- Debug Statements
1969 --
1970 IF l_debug_on THEN
1971 WSH_DEBUG_SV.logmsg(l_module_name, 'AFTER INV_STAGED_RESERVATION_UTIL.QUERY_STAGED_FLAG : '||L_STAGED_FLAG );
1972 END IF;
1973 --
1974
1975 -- HW OPMCONV - Update qty2 using new reservation flds
1976 IF l_rsv_array(l_counter).secondary_reservation_quantity = FND_API.G_MISS_NUM THEN
1977 l_rsv_array(l_counter).secondary_reservation_quantity := null;
1978 END IF;
1979
1980 -- Bug3012297 (Included reference to parameters)
1981 IF check_inv_info( p_delivery_detail_split_rec => p_delivery_detail_split_rec
1982 , p_rsv => l_rsv_array(l_counter))
1983 AND l_staged_flag = 'Y' THEN
1984
1985 IF l_rsv_array(l_counter).primary_reservation_quantity
1986 < l_cancellation_quantity THEN
1987 -- Can we delete reservation if detailed_quantity exists ?
1988 -- This would never happen. Detailed quantity is cleared
1989 -- during pick confirm (08/21 John)
1990 --
1991 -- Debug Statements
1992 --
1993 IF l_debug_on THEN
1994 WSH_DEBUG_SV.logmsg(l_module_name, 'GOING TO DELETE_RESERVATION IN CANCEL_STAGED_RESERVATION ' );
1995 END IF;
1996 --
1997 delete_reservation (p_query_input => l_rsv_array(l_counter),
1998 x_return_status => x_return_status );
1999 IF l_debug_on THEN
2000 WSH_DEBUG_SV.log(l_module_name, 'delete_reservation x_return_status',x_return_status);
2001 END IF;
2002
2003 IF x_return_status <> fnd_api.g_ret_sts_success THEN
2004 raise cancel_failed;
2005 END IF;
2006
2007 l_cancelled_reservation_qty := l_rsv_array(l_counter).primary_reservation_quantity;
2008 -- HW OPMCONV - Update Qty2 using new reservation flds.
2009 l_cancelled_reservation_qty2 := l_rsv_array(l_counter).secondary_reservation_quantity;
2010
2011 ELSE
2012
2013 l_rsv_new.primary_reservation_quantity := l_rsv_array(l_counter).primary_reservation_quantity -
2014 l_cancellation_quantity;
2015 -- HW OPMCONV - Update Qty2 using new reservation flds.
2016 l_rsv_new.secondary_reservation_quantity := nvl(abs(l_rsv_array(l_counter).secondary_reservation_quantity),0) - nvl(abs(l_cancellation_quantity2),0);
2017 --
2018 -- Debug Statements
2019 --
2020 IF l_debug_on THEN
2021 -- HW OPMCONV - Print correct value of Qty2
2022 WSH_DEBUG_SV.logmsg(l_module_name, 'UPDATE QTY2 '|| l_rsv_new.secondary_reservation_quantity );
2023 END IF;
2024 --
2025 -- HW OPMCONV - Ensure Qty2 are NULL before updating
2026 IF ( l_rsv_new.secondary_reservation_quantity = 0 OR
2027 l_rsv_new.secondary_reservation_quantity = FND_API.G_MISS_NUM ) THEN
2028 l_rsv_new.secondary_reservation_quantity := NULL;
2029 END IF;
2030
2031 update_reservation (p_query_input => l_rsv_array(l_counter),
2032 p_new_resv_rec => l_rsv_new,
2033 x_return_status => x_return_status);
2034 IF l_debug_on THEN
2035 WSH_DEBUG_SV.log(l_module_name, 'update_reservation x_return_status',x_return_status);
2036 END IF;
2037
2038 IF x_return_status <> fnd_api.g_ret_sts_success THEN
2039 raise cancel_failed;
2040 END IF;
2041
2042 EXIT;
2043 END IF;
2044 l_cancellation_quantity := l_cancellation_quantity - l_cancelled_reservation_qty;
2045 l_cancellation_quantity2 := l_cancellation_quantity2 - l_cancelled_reservation_qty2;
2046 END IF; -- end of check_inv_info and staged_flag = 'Y'
2047 END LOOP;
2048
2049 --
2050 -- Debug Statements
2051 --
2052 IF l_debug_on THEN
2053 WSH_DEBUG_SV.pop(l_module_name);
2054 END IF;
2055 --
2056 EXCEPTION
2057 WHEN cancel_failed THEN
2058 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
2059 --
2060 -- Debug Statements
2061 --
2062 IF l_debug_on THEN
2063 WSH_DEBUG_SV.logmsg(l_module_name,'CANCEL_FAILED exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2064 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:CANCEL_FAILED');
2065 END IF;
2066 --
2067 WHEN others THEN
2068 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
2069 wsh_util_core.default_handler('WSH_USA_INV_PVT.cancel_staged_reservation',l_module_name);
2070
2071 IF l_debug_on THEN
2072 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
2073 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
2074 END IF;
2075 END cancel_staged_reservation;
2076
2077
2078 -- This procedure takes care that non staged reservations get reduced by the cancellation quantity
2079 -- when some quantity from one or more non staged delivery line is reduced
2080 PROCEDURE cancel_nonstaged_reservation (
2081 p_source_code IN VARCHAR2,
2082 p_source_header_id IN NUMBER,
2083 p_source_line_id IN NUMBER,
2084 p_delivery_detail_id IN NUMBER,
2085 p_organization_id IN NUMBER,
2086 p_cancellation_quantity IN NUMBER,
2087 p_cancellation_quantity2 IN NUMBER,
2088 x_return_status OUT NOCOPY VARCHAR2)
2089 IS
2090
2091 -- Bug 2595657
2092 CURSOR c_nonstaged_qty is
2093 SELECT nvl(sum(requested_quantity),0),
2094 nvl(sum(requested_quantity2),0)
2095 FROM wsh_delivery_details
2096 WHERE source_line_id = p_source_line_id
2097 and source_header_id = p_source_header_id
2098 and source_code = p_source_code
2099 and organization_id = p_organization_id
2100 and ((released_status in ('R','B','N'))
2101 OR
2102 (released_status = 'S' and move_order_line_id IS NULL) -- Bug 5185995
2103 );
2104
2105 l_nonstaged_qty NUMBER;
2106 l_nonstaged_qty2 NUMBER;
2107 l_nonstaged_rsv_qty NUMBER;
2108 l_nonstaged_rsv_qty2 NUMBER;
2109 -- Bug 2595657
2110
2111 l_rsv inv_reservation_global.mtl_reservation_rec_type;
2112 l_rsv_new inv_reservation_global.mtl_reservation_rec_type;
2113 l_rsv_array inv_reservation_global.mtl_reservation_tbl_type;
2114 l_size NUMBER;
2115 l_msg_count NUMBER;
2116 l_msg_data VARCHAR2(240);
2117 l_cancelled_reservation_qty NUMBER;
2118 l_cancelled_reservation_qty2 NUMBER;
2119 l_cancellation_quantity NUMBER;
2120 l_cancellation_quantity2 NUMBER;
2121 l_staged_flag VARCHAR2(1);
2122 -- HW OPMCONV. Removed OPM local variables
2123 --MUOM bug 16662301
2124 l_fulfillment_base VARCHAR2(1);
2125
2126 l_delivery_detail_id NUMBER;
2127
2128 l_rsv_match VARCHAR2(1); --Bug3012297
2129 l_dd_split_dummy DeliveryDetailInvRecType; -- Bug 30122295
2130
2131 cancel_failed EXCEPTION;
2132
2133 --
2134 l_debug_on BOOLEAN;
2135 --
2136 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PACKAGE_NAME || '.' || 'CANCEL_NONSTAGED_RESERVATION';
2137 --
2138 BEGIN
2139
2140 --
2141 -- Debug Statements
2142 --
2143 --
2144 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
2145 --
2146 IF l_debug_on IS NULL
2147 THEN
2148 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
2149 END IF;
2150 --
2151 IF l_debug_on THEN
2152 WSH_DEBUG_SV.push(l_module_name);
2153 --
2154 WSH_DEBUG_SV.log(l_module_name,'P_SOURCE_CODE',P_SOURCE_CODE);
2155 WSH_DEBUG_SV.log(l_module_name,'P_SOURCE_HEADER_ID',P_SOURCE_HEADER_ID);
2156 WSH_DEBUG_SV.log(l_module_name,'P_SOURCE_LINE_ID',P_SOURCE_LINE_ID);
2157 WSH_DEBUG_SV.log(l_module_name,'P_ORGANIZATION_ID',P_ORGANIZATION_ID);
2158 WSH_DEBUG_SV.log(l_module_name,'P_delivery_detail_id',P_delivery_detail_id);
2159 WSH_DEBUG_SV.log(l_module_name,'P_CANCELLATION_QUANTITY',P_CANCELLATION_QUANTITY);
2160 WSH_DEBUG_SV.log(l_module_name,'P_CANCELLATION_QUANTITY2',P_CANCELLATION_QUANTITY2);
2161 END IF;
2162 --
2163 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
2164
2165 IF p_cancellation_quantity = 0 THEN
2166 --
2167 -- Debug Statements
2168 --
2169 IF l_debug_on THEN
2170 WSH_DEBUG_SV.pop(l_module_name);
2171 END IF;
2172 --
2173 RETURN;
2174 END IF;
2175
2176 --X-dock, conditionally populate delivery_detail_id
2177 -- released-status and MOL are passed as null and will be derived within the API
2178 WSH_USA_INV_PVT.get_putaway_detail_id
2179 (p_detail_id => p_delivery_detail_id,
2180 p_released_status => null,
2181 p_move_order_line_id => null,
2182 x_detail_id => l_delivery_detail_id,
2183 x_return_status => x_return_status);
2184
2185 IF x_return_status <> fnd_api.g_ret_sts_success THEN
2186 raise cancel_failed;
2187 END IF;
2188 --end of X-dock
2189
2190 --X-dock changes
2191 -- Output from above API l_rsv_array will contain demand_source_line_detail as null or not null
2192 -- which can be used for delete_reservation and update_reservation calls
2193 query_reservations (
2194 p_source_code => p_source_code,
2195 p_source_header_id => p_source_header_id,
2196 p_source_line_id => p_source_line_id,
2197 p_organization_id => p_organization_id,
2198 p_delivery_detail_id => l_delivery_detail_id, -- X-dock changes
2199 p_lock_records => fnd_api.g_true,
2200 x_mtl_reservation_tbl => l_rsv_array,
2201 x_mtl_reservation_tbl_count => l_size,
2202 x_return_status => x_return_status);
2203
2204
2205 IF l_debug_on THEN
2206 WSH_DEBUG_SV.log(l_module_name,'query_reservations x_return_status',x_return_status);
2207 END IF;
2208
2209 IF (x_return_status <> fnd_api.g_ret_sts_success) THEN
2210 raise cancel_failed;
2211 END IF;
2212
2213 IF l_size = 0 THEN -- This case is specific for non staged reservations as
2214 --
2215 -- Debug Statements
2216 --
2217 IF l_debug_on THEN
2218 WSH_DEBUG_SV.pop(l_module_name);
2219 END IF;
2220 --
2221 RETURN; -- for a backordered DD reservations might or might not exist
2222 END IF;
2223
2224 l_cancellation_quantity := p_cancellation_quantity;
2225 l_cancellation_quantity2 := p_cancellation_quantity2;
2226
2227 --
2228 -- Debug Statements
2229 --
2230
2231 -- HW OPMCONV. Removed checking for process org
2232
2233 -- Bug 2595657 : Do not cancel p_cancellation_quantity reservation. Always cancel excess reservation
2234 OPEN c_nonstaged_qty;
2235 FETCH c_nonstaged_qty
2236 INTO l_nonstaged_qty, l_nonstaged_qty2;
2237 CLOSE c_nonstaged_qty;
2238
2239 -- HW OPMCONV - Added debugging statement
2240 IF l_debug_on THEN
2241 WSH_DEBUG_SV.log(l_module_name,'After fetching l_nonstaged_qty',l_nonstaged_qty);
2242
2243 WSH_DEBUG_SV.log(l_module_name,'After fetching l_nonstaged_qty2',l_nonstaged_qty2);
2244 END IF;
2245
2246
2247 l_nonstaged_rsv_qty := 0;
2248 l_nonstaged_rsv_qty2 := 0;
2249 FOR l_counter in 1..l_size
2250 LOOP
2251 -- HW OPMCONV. Removed forking the code
2252
2253 IF l_debug_on THEN
2254 WSH_DEBUG_SV.log(l_module_name,'Calling program unit INV_STAGED_RESERVATION_UTIL.query_staged_flag',WSH_DEBUG_SV.C_PROC_LEVEL);
2255 END IF;
2256
2257 IF l_debug_on THEN
2258
2259 WSH_DEBUG_SV.log(l_module_name,'BEG OF LOOP l_nonstaged_qty',l_nonstaged_qty);
2260
2261 WSH_DEBUG_SV.log(l_module_name,'BEG OF LOOP l_nonstaged_qty2',l_nonstaged_qty2);
2262 END IF;
2263 INV_STAGED_RESERVATION_UTIL.query_staged_flag(
2264 x_return_status => x_return_status,
2265 x_msg_count => l_msg_count,
2266 x_msg_data => l_msg_data,
2267 x_staged_flag => l_staged_flag,
2268 p_reservation_id => l_rsv_array(l_counter).reservation_id);
2269 IF l_debug_on THEN
2270 WSH_DEBUG_SV.log(l_module_name,'INV_STAGED_RESERVATION_UTIL.query_staged_flag',l_staged_flag);
2271 END IF;
2272 -- HW OPMCONV. Removed code forking
2273
2274 -- Bug3012297
2275 IF l_staged_flag <> 'Y'
2276 AND check_inv_info( p_delivery_detail_split_rec => l_dd_split_dummy
2277 , p_delivery_detail_id => p_delivery_detail_id
2278 , p_rsv => l_rsv_array(l_counter))
2279 THEN
2280
2281 IF l_debug_on THEN
2282 WSH_DEBUG_SV.log(l_module_name,'BEFORE l_nonstaged_rsv_qty',l_nonstaged_rsv_qty);
2283 WSH_DEBUG_SV.log(l_module_name,'(l_rsv_array(l_counter).primary_reservation_quantity ',(l_rsv_array(l_counter).primary_reservation_quantity ));
2284 WSH_DEBUG_SV.log(l_module_name,'l_rsv_array(l_counter).detailed_quantity ',l_rsv_array(l_counter).detailed_quantity );
2285 END IF;
2286 l_nonstaged_rsv_qty := l_nonstaged_rsv_qty + (l_rsv_array(l_counter).primary_reservation_quantity
2287 - nvl(l_rsv_array(l_counter).detailed_quantity,0));
2288 IF l_debug_on THEN
2289 WSH_DEBUG_SV.log(l_module_name,'AFTER l_nonstaged_rsv_qty',l_nonstaged_rsv_qty);
2290 -- HW OPMCONV Added Qty2 using new reservation flds
2291 END IF;
2292 IF l_debug_on THEN
2293 WSH_DEBUG_SV.log(l_module_name,'l_nonstaged_rsv_qty2',l_nonstaged_rsv_qty2);
2294 WSH_DEBUG_SV.log(l_module_name,'(l_rsv_array(l_counter).secondary_reservation_quantity ',(l_rsv_array(l_counter).secondary_reservation_quantity ));
2295 WSH_DEBUG_SV.log(l_module_name,'l_rsv_array(l_counter).secondary_detailed_quantity ',l_rsv_array(l_counter).secondary_detailed_quantity );
2296 END IF;
2297 l_nonstaged_rsv_qty2 := l_nonstaged_rsv_qty2 + (l_rsv_array(l_counter).secondary_reservation_quantity
2298 - nvl(l_rsv_array(l_counter).secondary_detailed_quantity,0));
2299
2300
2301 IF l_debug_on THEN
2302 WSH_DEBUG_SV.log(l_module_name,'AFTER l_nonstaged_rsv_qty2',l_nonstaged_rsv_qty2);
2303 -- HW OPMCONV Added Qty2 using new reservation flds
2304 END IF;
2305 END IF;
2306 --End Bug3012297
2307
2308 -- HW OPMCONV - Update correct Qty2 using new reservation flds.
2309
2310 IF l_rsv_array(l_counter).secondary_reservation_quantity = FND_API.G_MISS_NUM
2311 OR l_rsv_array(l_counter).secondary_reservation_quantity = 0 THEN
2312 l_rsv_array(l_counter).secondary_reservation_quantity := null;
2313 END IF;
2314
2315
2316 END LOOP;
2317
2318 --MUOM Bug 16662301
2319 l_fulfillment_base := WSH_UTIL_CORE.Get_Line_Fulfillment_Base(p_source_code, p_source_line_id);
2320
2321 IF l_debug_on THEN
2322 WSH_DEBUG_SV.log(l_module_name,'l_nonstaged_rsv_qty',l_nonstaged_rsv_qty);
2323 WSH_DEBUG_SV.log(l_module_name,'l_nonstaged_qty',l_nonstaged_qty);
2324 WSH_DEBUG_SV.log(l_module_name,'l_nonstaged_rsv_qty2',l_nonstaged_rsv_qty2);
2325 WSH_DEBUG_SV.log(l_module_name,'l_nonstaged_qty2',l_nonstaged_qty2);
2326 --MUOM Bug 16662301
2327 WSH_DEBUG_SV.log(l_module_name,'l_fulfillment_base',l_fulfillment_base);
2328 END IF;
2329
2330 -- l_nonstaged_qty would have got reduced by p_cancellation_quantity by this time
2331 -- MUOM Bug 16662301: Modified condition
2332 IF ( l_fulfillment_base = 'P' and l_nonstaged_rsv_qty > l_nonstaged_qty ) THEN
2333 l_cancellation_quantity := l_nonstaged_rsv_qty - l_nonstaged_qty;
2334 -- KYH BUG 4259636 BEGIN
2335 -- =====================
2336 -- Cannot compute cancellation quantity using summed quantities because it may mix various
2337 -- lot specific calculations. Compute it later on a lot specific basis driving off l_cancellation_quantity
2338 -- l_cancellation_quantity2 := l_nonstaged_rsv_qty2 - l_nonstaged_qty2;
2339 -- KYH BUG 4259636 END
2340 ELSIF ( l_fulfillment_base = 'S' and l_nonstaged_rsv_qty2 > l_nonstaged_qty2 ) THEN
2341 l_cancellation_quantity2 := l_nonstaged_rsv_qty2 - l_nonstaged_qty2;
2342 ELSE
2343 l_cancellation_quantity := 0;
2344 l_cancellation_quantity2 := 0;
2345 END IF;
2346
2347 IF l_debug_on THEN
2348 WSH_DEBUG_SV.logmsg(l_module_name,'Going to Cancel l_cancellation_quantity: ' || l_cancellation_quantity
2349 || ', l_cancellation_quantity2:' || l_cancellation_quantity2 );
2350 END IF;
2351 -- 2595657
2352
2353 -- loop over all the reservation records in l_rsv_array
2354
2355 FOR l_counter in 1..l_size
2356 LOOP
2357 -- MUOM Bug 16662301: Added IF condition -- {
2358 IF l_fulfillment_base = 'P'
2359 THEN
2360 IF NOT l_cancellation_quantity > 0 then
2361 exit;
2362 END IF;
2363 -- HW OPMCONV. Removed forking the code
2364 --
2365 -- Debug Statements
2366 --
2367 IF l_debug_on THEN
2368 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit INV_STAGED_RESERVATION_UTIL.QUERY_STAGED_FLAG',WSH_DEBUG_SV.C_PROC_LEVEL);
2369 END IF;
2370 --
2371 INV_STAGED_RESERVATION_UTIL.query_staged_flag
2372 ( x_return_status => x_return_status,
2373 x_msg_count => l_msg_count,
2374 x_msg_data => l_msg_data,
2375 x_staged_flag => l_staged_flag,
2376 p_reservation_id => l_rsv_array(l_counter).reservation_id);
2377 IF l_debug_on THEN
2378 WSH_DEBUG_SV.log(l_module_name,'query_staged_flag x_return_status',x_return_status);
2379 END IF;
2380 -- HW OPMCONV. No need to fork the code
2381 --
2382 -- Debug Statements
2383 --
2384 IF l_debug_on THEN
2385 WSH_DEBUG_SV.logmsg(l_module_name, 'AFTER INV_STAGED_RESERVATION_UTIL.QUERY_STAGED_FLAG : '||L_STAGED_FLAG );
2386 END IF;
2387 --
2388
2389 -- HW OPMCONV -Update Qty2 using new reservation flds.
2390
2391 IF l_rsv_array(l_counter).secondary_reservation_quantity = FND_API.G_MISS_NUM THEN
2392 l_rsv_array(l_counter).secondary_reservation_quantity := null;
2393 END IF;
2394
2395 -- Bug3012297
2396 l_rsv_match := 'N';
2397 IF l_staged_flag <> 'Y' THEN
2398 -- HW OPMCONV . Removed forking the code
2399
2400 l_rsv_match := 'Y';
2401 -- HW OPMCONV. Removed ELSIF
2402
2403 END IF;
2404 -- End Bug3012297
2405
2406 -- Bug3012297 (Replaced following IF)
2407 -- IF l_staged_flag <> 'Y' THEN
2408 IF l_rsv_match = 'Y' THEN
2409
2410 -- Should be able to reduce any non detailed quantity ?
2411
2412 IF l_rsv_array(l_counter).primary_reservation_quantity -
2413 nvl(l_rsv_array(l_counter).detailed_quantity,0)
2414 < l_cancellation_quantity THEN
2415
2416 -- Can we delete reservation if detailed_quantity exists ?
2417 -- No (08/21 John)
2418
2419 IF nvl(l_rsv_array(l_counter).detailed_quantity,0) <> 0 THEN
2420
2421 l_rsv_new.primary_reservation_quantity :=
2422 l_rsv_array(l_counter).detailed_quantity;
2423 -- HW OPMCONV - Added Qty2
2424 l_rsv_new.secondary_reservation_quantity :=
2425 l_rsv_array(l_counter).secondary_detailed_quantity;
2426
2427 -- HW OPMCONV - Ensure Qty2 are NULL before updating
2428
2429 IF ( l_rsv_new.secondary_reservation_quantity = 0 OR
2430 l_rsv_new.secondary_reservation_quantity = FND_API.G_MISS_NUM ) THEN
2431 l_rsv_new.secondary_reservation_quantity := NULL;
2432 END IF;
2433
2434 IF l_debug_on THEN
2435 WSH_DEBUG_SV.logmsg(l_module_name, 'DEBUGGING' );
2436 WSH_DEBUG_SV.logmsg(l_module_name, 'l_rsv_new.secondary_reservation_quantity '||l_rsv_new.secondary_reservation_quantity );
2437 WSH_DEBUG_SV.logmsg(l_module_name, 'l_rsv_new.secondary_UOM_CODE '||l_rsv_new.secondary_uom_code );
2438 WSH_DEBUG_SV.logmsg(l_module_name, 'l_rsv_new.secondary_ID '||l_rsv_new.secondary_uom_id );
2439 END IF;
2440
2441 update_reservation (
2442 p_query_input => l_rsv_array(l_counter),
2443 p_new_resv_rec => l_rsv_new,
2444 x_return_status => x_return_status);
2445
2446 IF l_debug_on THEN
2447 WSH_DEBUG_SV.log(l_module_name,'update_reservation x_return_status',x_return_status);
2448 END IF;
2449 IF x_return_status <> fnd_api.g_ret_sts_success THEN
2450 raise cancel_failed;
2451 END IF;
2452
2453 ELSE
2454 --
2455 -- Debug Statements
2456 --
2457 IF l_debug_on THEN
2458 WSH_DEBUG_SV.logmsg(l_module_name, 'GOING TO DELETE_RESERVATION IN CANCEL_NON__STAGED_RESERVATION ' );
2459 END IF;
2460 --
2461 delete_reservation (
2462 p_query_input => l_rsv_array(l_counter),
2463 x_return_status => x_return_status );
2464 IF l_debug_on THEN
2465 WSH_DEBUG_SV.log(l_module_name,'delete_reservation x_return_status',x_return_status);
2466 END IF;
2467
2468 IF x_return_status <> fnd_api.g_ret_sts_success THEN
2469 raise cancel_failed;
2470 END IF;
2471
2472 END IF;
2473
2474 l_cancelled_reservation_qty :=
2475 l_rsv_array(l_counter).primary_reservation_quantity -
2476 nvl(l_rsv_array(l_counter).detailed_quantity,0);
2477 -- HW OPMCONV Update Qty2 using new reservations flds.
2478 l_cancelled_reservation_qty2 :=
2479 l_rsv_array(l_counter).secondary_reservation_quantity -
2480 nvl(l_rsv_array(l_counter).secondary_detailed_quantity,0);
2481
2482 -- l_rsv_array(l_counter).attribute2;
2483 ELSE
2484 l_rsv_new.primary_reservation_quantity :=
2485 l_rsv_array(l_counter).primary_reservation_quantity -
2486 l_cancellation_quantity;
2487 -- KYH BUG 4259636 BEGIN
2488 -- =====================
2489 -- Ensure cancellation_quantity2 is computed in accordance with any
2490 -- lot specific calculation in play for the reservation line
2491 -- otherwise we may be mixing item level and lot specific level calculations
2492 IF l_rsv_array(l_counter).secondary_uom_code <> FND_API.G_MISS_CHAR THEN
2493 -- For dual tracked items compute the secondary cancellation qty in
2494 -- accordance with any lot specific calculation in play
2495 l_cancellation_quantity2 := WSH_WV_UTILS.convert_uom(
2496 item_id => l_rsv_array(l_counter).inventory_item_id
2497 , lot_number => l_rsv_array(l_counter).lot_number
2498 , org_id => l_rsv_array(l_counter).organization_id
2499 , p_max_decimal_digits => NULL -- use default precision
2500 , quantity => l_cancellation_quantity
2501 , from_uom => l_rsv_array(l_counter).primary_uom_code
2502 , to_uom => l_rsv_array(l_counter).secondary_uom_code
2503 );
2504
2505 IF l_cancellation_quantity2 = 0 THEN
2506 -- conversion failed
2507 IF l_debug_on THEN
2508 WSH_DEBUG_SV.logmsg(l_module_name, 'ERROR on UOM conversion to secondary UOM : '||l_rsv_array(l_counter).secondary_uom_code );
2509 END IF;
2510 raise cancel_failed;
2511 END IF;
2512 END IF;
2513 IF l_debug_on THEN
2514 WSH_DEBUG_SV.log(l_module_name,'Going to Cancel l_cancellation_quantity',l_cancellation_quantity);
2515 WSH_DEBUG_SV.log(l_module_name,'Going to Cancel l_cancellation_quantity2',l_cancellation_quantity2);
2516 WSH_DEBUG_SV.log(l_module_name,'Lot involved for conversions is ',l_rsv_array(l_counter).lot_number);
2517 END IF;
2518 -- KYH BUG 4259636 END
2519 -- HW OPMCONV Update Qty2 using new reservations flds.
2520 -- l_rsv_new.attribute2 :=
2521 l_rsv_new.secondary_reservation_quantity :=
2522 nvl(abs(l_rsv_array(l_counter).secondary_reservation_quantity),0) -
2523 nvl(l_cancellation_quantity2,0);
2524
2525
2526
2527 -- HW OPMCONV - Ensure Qty2 are NULL before updating
2528 IF ( l_rsv_new.secondary_reservation_quantity = 0 OR
2529 l_rsv_new.secondary_reservation_quantity = FND_API.G_MISS_NUM ) THEN
2530 l_rsv_new.secondary_reservation_quantity := NULL;
2531 END IF;
2532
2533 update_reservation (
2534 p_query_input => l_rsv_array(l_counter),
2535 p_new_resv_rec => l_rsv_new,
2536 x_return_status => x_return_status);
2537 IF l_debug_on THEN
2538 WSH_DEBUG_SV.log(l_module_name,'update_reservation x_return_status',x_return_status);
2539 END IF;
2540
2541 IF x_return_status <> fnd_api.g_ret_sts_success THEN
2542 raise cancel_failed;
2543 END IF;
2544
2545 EXIT;
2546 END IF;
2547 l_cancellation_quantity := l_cancellation_quantity - l_cancelled_reservation_qty;
2548 -- l_cancellation_quantity2 := l_cancellation_quantity2 - l_cancelled_reservation_qty2; --BUG 4259636
2549
2550 END IF;
2551 -- }
2552 -- MUOM Bug 16662301: Added condition for FB based on 'Secondary UOM'
2553 ELSIF ( l_fulfillment_base = 'S' )
2554 THEN -- {
2555 IF NOT l_cancellation_quantity2 > 0 then
2556 exit;
2557 END IF;
2558 --
2559 IF l_debug_on THEN
2560 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit INV_STAGED_RESERVATION_UTIL.QUERY_STAGED_FLAG',WSH_DEBUG_SV.C_PROC_LEVEL);
2561 END IF;
2562 --
2563 INV_STAGED_RESERVATION_UTIL.query_staged_flag (
2564 x_return_status => x_return_status,
2565 x_msg_count => l_msg_count,
2566 x_msg_data => l_msg_data,
2567 x_staged_flag => l_staged_flag,
2568 p_reservation_id => l_rsv_array(l_counter).reservation_id );
2569 --
2570 IF l_debug_on THEN
2571 WSH_DEBUG_SV.log(l_module_name,'query_staged_flag x_return_status',x_return_status);
2572 WSH_DEBUG_SV.logmsg(l_module_name, 'AFTER INV_STAGED_RESERVATION_UTIL.QUERY_STAGED_FLAG : '||L_STAGED_FLAG );
2573 END IF;
2574 --
2575 l_rsv_match := 'N';
2576 IF l_staged_flag <> 'Y' THEN
2577 l_rsv_match := 'Y';
2578 END IF;
2579
2580 IF l_rsv_match = 'Y' THEN
2581 IF ( l_rsv_array(l_counter).secondary_reservation_quantity -
2582 nvl(l_rsv_array(l_counter).secondary_detailed_quantity,0) )
2583 < l_cancellation_quantity2
2584 THEN
2585 IF nvl(l_rsv_array(l_counter).secondary_detailed_quantity,0) <> 0
2586 THEN
2587 l_rsv_new.secondary_reservation_quantity := l_rsv_array(l_counter).secondary_detailed_quantity;
2588 l_rsv_new.primary_reservation_quantity := l_rsv_array(l_counter).detailed_quantity;
2589 --
2590 IF l_debug_on THEN
2591 WSH_DEBUG_SV.logmsg(l_module_name, 'l_rsv_new.secondary_reservation_quantity '||l_rsv_new.secondary_reservation_quantity );
2592 WSH_DEBUG_SV.logmsg(l_module_name, 'l_rsv_new.secondary_uom_code '||l_rsv_new.secondary_uom_code );
2593 WSH_DEBUG_SV.logmsg(l_module_name, 'l_rsv_new.secondary_ID '||l_rsv_new.secondary_uom_id );
2594 END IF;
2595 --
2596 Update_Reservation (
2597 p_query_input => l_rsv_array(l_counter),
2598 p_new_resv_rec => l_rsv_new,
2599 x_return_status => x_return_status );
2600 --
2601 IF l_debug_on THEN
2602 WSH_DEBUG_SV.log(l_module_name,'update_reservation x_return_status',x_return_status);
2603 END IF;
2604 --
2605 IF x_return_status <> fnd_api.g_ret_sts_success THEN
2606 raise cancel_failed;
2607 END IF;
2608 ELSE
2609 --
2610 IF l_debug_on THEN
2611 WSH_DEBUG_SV.logmsg(l_module_name, 'GOING TO DELETE_RESERVATION IN CANCEL_NON__STAGED_RESERVATION ' );
2612 END IF;
2613 --
2614 Delete_Reservation (
2615 p_query_input => l_rsv_array(l_counter),
2616 x_return_status => x_return_status );
2617 --
2618 IF l_debug_on THEN
2619 WSH_DEBUG_SV.log(l_module_name,'delete_reservation x_return_status',x_return_status);
2620 END IF;
2621 --
2622 IF x_return_status <> fnd_api.g_ret_sts_success THEN
2623 raise cancel_failed;
2624 END IF;
2625 END IF;
2626
2627 l_cancelled_reservation_qty :=
2628 l_rsv_array(l_counter).primary_reservation_quantity - nvl(l_rsv_array(l_counter).detailed_quantity,0);
2629 l_cancelled_reservation_qty2 :=
2630 l_rsv_array(l_counter).secondary_reservation_quantity - nvl(l_rsv_array(l_counter).secondary_detailed_quantity,0);
2631 ELSE
2632 l_rsv_new.secondary_reservation_quantity :=
2633 l_rsv_array(l_counter).secondary_reservation_quantity - l_cancellation_quantity2;
2634
2635 -- Ensure cancellation_quantity is computed in accordance with any
2636 -- lot specific calculation in play for the reservation line
2637 -- otherwise we may be mixing item level and lot specific level calculations
2638 -- For dual tracked items compute the primary cancellation qty in
2639 -- accordance with any lot specific calculation in play
2640 l_cancellation_quantity := WSH_WV_UTILS.convert_uom(
2641 item_id => l_rsv_array(l_counter).inventory_item_id
2642 , lot_number => l_rsv_array(l_counter).lot_number
2643 , org_id => l_rsv_array(l_counter).organization_id
2644 , p_max_decimal_digits => NULL -- use default precision
2645 , quantity => l_cancellation_quantity2
2646 , from_uom => l_rsv_array(l_counter).secondary_uom_code
2647 , to_uom => l_rsv_array(l_counter).primary_uom_code
2648 );
2649
2650 IF l_cancellation_quantity = 0 THEN
2651 -- conversion failed
2652 IF l_debug_on THEN
2653 WSH_DEBUG_SV.logmsg(l_module_name, 'ERROR on UOM conversion to Primary UOM : ' || l_rsv_array(l_counter).primary_uom_code );
2654 END IF;
2655 raise cancel_failed;
2656 END IF;
2657 --
2658 IF l_debug_on THEN
2659 WSH_DEBUG_SV.logmsg(l_module_name,'Going to Cancel l_cancellation_quantity: ' || l_cancellation_quantity
2660 || ', l_cancellation_quantity2:' || l_cancellation_quantity2 );
2661 WSH_DEBUG_SV.log(l_module_name,'Lot involved for conversions is ',l_rsv_array(l_counter).lot_number);
2662 END IF;
2663
2664 l_rsv_new.primary_reservation_quantity :=
2665 nvl(abs(l_rsv_array(l_counter).primary_reservation_quantity),0) - nvl(l_cancellation_quantity,0);
2666
2667 Update_Reservation (
2668 p_query_input => l_rsv_array(l_counter),
2669 p_new_resv_rec => l_rsv_new,
2670 x_return_status => x_return_status );
2671 --
2672 IF l_debug_on THEN
2673 WSH_DEBUG_SV.log(l_module_name,'update_reservation x_return_status',x_return_status);
2674 END IF;
2675 --
2676 IF x_return_status <> fnd_api.g_ret_sts_success THEN
2677 raise cancel_failed;
2678 END IF;
2679 EXIT;
2680 END IF;
2681 l_cancellation_quantity2 := l_cancellation_quantity2 - l_cancelled_reservation_qty2;
2682 END IF;
2683 END IF; -- }
2684 END LOOP;
2685
2686 --
2687 -- Debug Statements
2688 --
2689 IF l_debug_on THEN
2690 WSH_DEBUG_SV.pop(l_module_name);
2691 END IF;
2692 --
2693 EXCEPTION
2694 WHEN cancel_failed THEN
2695 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
2696 --
2697 -- Debug Statements
2698 --
2699 IF l_debug_on THEN
2700 WSH_DEBUG_SV.logmsg(l_module_name,'CANCEL_FAILED exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2701 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:CANCEL_FAILED');
2702 END IF;
2703 --
2704 WHEN others THEN
2705 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
2706 wsh_util_core.default_handler('WSH_USA_INV_PVT.cancel_nonstaged_reservation',l_module_name);
2707
2708 --
2709 -- Debug Statements
2710 --
2711 IF l_debug_on THEN
2712 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
2713 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
2714 END IF;
2715 --
2716 END cancel_nonstaged_reservation;
2717 -- bug # 9410461: Added to new out parameter x_new_rsv_id to return reservation id of the new reservation
2718 -- record created.
2719 -- This is a private procedure which wraps inv_reservation_pub.update_reservation
2720 -- or inv_reservation_pub.transfer_reservation as required
2721 -- COMMENT : p_rsv.demand_source_line_detail is required for X-dock lines
2722 -- Functionality added in R12
2723 -- Added parameter p_shipped_flag for bug 10105817
2724 PROCEDURE Reservation_split_action (
2725 p_rsv IN inv_reservation_global.mtl_reservation_rec_type,
2726 p_rsv_new IN inv_reservation_global.mtl_reservation_rec_type,
2727 p_staged IN VARCHAR2,
2728 p_released_status IN VARCHAR2,
2729 p_split_quantity IN OUT NOCOPY NUMBER,
2730 p_split_quantity2 IN OUT NOCOPY NUMBER,
2731 p_source_code IN VARCHAR2,
2732 x_new_rsv_id OUT NOCOPY NUMBER,
2733 p_shipped_flag IN VARCHAR2,
2734 -- muom
2735 p_fulfillment_base IN VARCHAR2,
2736 x_return_status OUT NOCOPY VARCHAR2)
2737
2738 IS
2739 l_msg_count NUMBER;
2740 l_msg_data VARCHAR2(240);
2741 l_error_text VARCHAR2(6000);
2742 l_new_rsv_id NUMBER;
2743 l_status VARCHAR2(1);
2744 l_quantity_to_split NUMBER;
2745 -- HW OPMCONV added qty2
2746 l_quantity2_to_split NUMBER;
2747 -- muom
2748 l_max_qty_to_split NUMBER;
2749 l_max_qty2_to_split NUMBER;
2750
2751
2752 l_detailed_quantity NUMBER;
2753 l_detailed_quantity2 NUMBER;
2754
2755 l_rsv_new inv_reservation_global.mtl_reservation_rec_type;
2756 l_dummy_sn INV_RESERVATION_GLOBAL.serial_number_tbl_type;
2757
2758 transfer_split_failed EXCEPTION;
2759 l_validation_flag VARCHAR2(1);
2760 --
2761 l_debug_on BOOLEAN;
2762 --
2763 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PACKAGE_NAME || '.' || 'RESERVATION_SPLIT_ACTION';
2764 --
2765 BEGIN
2766 --
2767 l_status := FND_API.G_RET_STS_SUCCESS;
2768 --
2769 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
2770 --
2771 IF l_debug_on IS NULL THEN
2772 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
2773 END IF;
2774 --
2775 IF l_debug_on THEN
2776 WSH_DEBUG_SV.push(l_module_name);
2777 WSH_DEBUG_SV.log(l_module_name,'P_STAGED',P_STAGED);
2778 WSH_DEBUG_SV.log(l_module_name,'P_RELEASED_STATUS',P_RELEASED_STATUS);
2779 WSH_DEBUG_SV.log(l_module_name,'P_SPLIT_QUANTITY',P_SPLIT_QUANTITY);
2780 -- HW OPMCONV - Print Qty2
2781 WSH_DEBUG_SV.log(l_module_name,'P_SPLIT_QUANTITY2',P_SPLIT_QUANTITY2);
2782 WSH_DEBUG_SV.log(l_module_name,'p_rsv.organization_id',
2783 p_rsv.organization_id);
2784 WSH_DEBUG_SV.log(l_module_name,'p_rsv.inventory_item_id',
2785 p_rsv.inventory_item_id);
2786 WSH_DEBUG_SV.log(l_module_name,'p_rsv_new.organization_id',
2787 p_rsv_new.organization_id);
2788 WSH_DEBUG_SV.log(l_module_name,'p_rsv_new.inventory_item_id',
2789 p_rsv_new.inventory_item_id);
2790 -- muom
2791 WSH_DEBUG_SV.log(l_module_name,'p_fulfillment_base',
2792 p_fulfillment_base);
2793 WSH_DEBUG_SV.log(l_module_name,'p_rsv.primary_reservation_quantity',
2794 p_rsv.primary_reservation_quantity);
2795 WSH_DEBUG_SV.log(l_module_name,'p_rsv.secondary_reservation_quantity',
2796 p_rsv.secondary_reservation_quantity);
2797 END IF;
2798
2799
2800 -- Bug 2925398: detailed quantity needs to be subtracted from primary qty
2801 -- to avoid transferring the detailed portion unless this
2802 -- detail is released to warehouse.
2803 IF p_released_status = 'S' THEN
2804 l_detailed_quantity := 0;
2805 l_detailed_quantity2 := 0;
2806 ELSE
2807 l_detailed_quantity := p_rsv.detailed_quantity;
2808 l_detailed_quantity2 := p_rsv.secondary_detailed_quantity;
2809 END IF;
2810
2811 l_quantity_to_split := least(p_split_quantity,
2812 (p_rsv.primary_reservation_quantity
2813 - l_detailed_quantity));
2814
2815 IF l_debug_on THEN
2816 WSH_DEBUG_SV.log(l_module_name, 'l_quantity_to_split', l_quantity_to_split);
2817 END IF;
2818
2819 -- Bug 16722851
2820 IF p_fulfillment_base = 'P' and NVL(l_quantity_to_split,0) = 0 THEN
2821 x_return_status := l_status;
2822 IF l_debug_on THEN
2823 WSH_DEBUG_SV.pop(l_module_name);
2824 END IF;
2825 RETURN;
2826 END IF;
2827
2828 -- muom
2829 IF p_fulfillment_base = 'S' THEN
2830 l_quantity2_to_split := least(p_split_quantity2,
2831 (p_rsv.secondary_reservation_quantity
2832 - nvl(l_detailed_quantity2,0)));
2833
2834 IF l_debug_on THEN
2835 WSH_DEBUG_SV.log(l_module_name, 'l_quantity2_to_split', l_quantity2_to_split);
2836 END IF;
2837
2838 IF NVL(l_quantity2_to_split,0) = 0 THEN
2839 x_return_status := l_status;
2840 IF l_debug_on THEN
2841 WSH_DEBUG_SV.pop(l_module_name);
2842 END IF;
2843 RETURN;
2844 END IF;
2845 END IF;
2846
2847 -- HW OPMCONV - Added qty2
2848
2849 -- KYH BUG 4259636 BEGIN
2850 --l_quantity2_to_split := least(p_split_quantity2 , p_rsv.secondary_reservation_quantity);
2851 -- This calculation is mixing item level UOM conversions (p_split_quantity2) with
2852 -- lot specific conversions (secondary_reservation_quantity).
2853 -- The wisest course of action is to compute the secondary based on the
2854 -- lot information available to us from the originating lot.
2855 -- muom
2856 IF p_fulfillment_base = 'P' THEN
2857 IF p_rsv.secondary_uom_code <> FND_API.G_MISS_CHAR THEN
2858 IF p_source_code = 'OE' THEN --Added for bug 16833534
2859
2860 IF l_debug_on THEN
2861 WSH_DEBUG_SV.log(l_module_name,'DUAL tracked item so convert for lot ',p_rsv.lot_number);
2862 END IF;
2863 l_quantity2_to_split := WSH_WV_UTILS.convert_uom(
2864 item_id => p_rsv.inventory_item_id
2865 , lot_number => p_rsv.lot_number
2866 , org_id => p_rsv.organization_id
2867 , p_max_decimal_digits => NULL -- use default precision
2868 , quantity => l_quantity_to_split
2869 , from_uom => p_rsv.primary_uom_code
2870 , to_uom => p_rsv.secondary_uom_code
2871 );
2872
2873 IF l_quantity2_to_split = 0 THEN
2874 -- conversion failed
2875 IF l_debug_on THEN
2876 WSH_DEBUG_SV.logmsg(l_module_name, 'ERROR on UOM conversion to secondary UOM : '||p_rsv_new.secondary_uom_code );
2877 END IF;
2878 raise transfer_split_failed;
2879 END IF;
2880
2881 IF l_debug_on THEN
2882 WSH_DEBUG_SV.log(l_module_name, 'l_quantity2_to_split', l_quantity2_to_split);
2883 END IF;
2884
2885 -- bug 2925398: make sure secondary quantity will not touch the detailed
2886 -- portion unless the detail is released to warehouse.
2887 l_max_qty2_to_split := (p_rsv.secondary_reservation_quantity
2888 - l_detailed_quantity2);
2889 IF l_quantity2_to_split > l_max_qty2_to_split THEN
2890 l_quantity2_to_split := l_max_qty2_to_split;
2891 IF l_debug_on THEN
2892 WSH_DEBUG_SV.log(l_module_name, 'adjusted l_quantity2_to_split', l_quantity2_to_split);
2893 END IF;
2894 END IF;
2895
2896 ELSE
2897 -- Bug 16722851: Prorate the Secondary reservation quantity based on primary quantity being split
2898 l_quantity2_to_split := p_split_quantity2;
2899 IF p_released_status <> 'Y' THEN
2900 IF (l_quantity_to_split < p_rsv.primary_reservation_quantity) THEN
2901 l_quantity2_to_split := (p_rsv.secondary_reservation_quantity * l_quantity_to_split) / p_rsv.primary_reservation_quantity;
2902 ELSE
2903 l_quantity2_to_split := p_rsv.secondary_reservation_quantity;
2904 END IF;
2905 IF l_debug_on THEN
2906 WSH_DEBUG_SV.log(l_module_name, 'adjusted l_quantity2_to_split', l_quantity2_to_split);
2907 END IF;
2908 END IF;
2909 END IF;-- End of p_source_code
2910 END IF;
2911 ELSE
2912 IF p_source_code = 'OE' THEN
2913 IF p_rsv.lot_number is not null THEN
2914 IF l_debug_on THEN
2915 WSH_DEBUG_SV.log(l_module_name,'DUAL tracked item so convert for lot ',p_rsv.lot_number);
2916 END IF;
2917 l_quantity_to_split := WSH_WV_UTILS.convert_uom(
2918 item_id => p_rsv.inventory_item_id
2919 , lot_number => p_rsv.lot_number
2920 , org_id => p_rsv.organization_id
2921 , p_max_decimal_digits => NULL -- use default precision
2922 , quantity => l_quantity2_to_split
2923 , from_uom => p_rsv.secondary_uom_code
2924 , to_uom => p_rsv.primary_uom_code
2925 );
2926
2927 IF l_quantity_to_split = 0 THEN
2928 -- conversion failed
2929 IF l_debug_on THEN
2930 WSH_DEBUG_SV.logmsg(l_module_name, 'ERROR on UOM conversion to primary UOM : '||p_rsv_new.primary_uom_code );
2931 END IF;
2932 raise transfer_split_failed;
2933 END IF;
2934
2935 IF l_debug_on THEN
2936 WSH_DEBUG_SV.log(l_module_name, 'l_quantity_to_split', l_quantity_to_split);
2937 END IF;
2938
2939 l_max_qty_to_split := (p_rsv.primary_reservation_quantity
2940 - l_detailed_quantity);
2941 IF l_quantity_to_split > l_max_qty_to_split THEN
2942 l_quantity_to_split := l_max_qty_to_split;
2943 IF l_debug_on THEN
2944 WSH_DEBUG_SV.log(l_module_name, 'adjusted l_quantity_to_split', l_quantity_to_split);
2945 END IF;
2946 END IF;
2947 END IF;
2948 ELSE
2949 -- Bug 16722851: Prorate the Primary reservation quantity based on secondary quantity being split
2950 IF p_released_status <> 'Y' THEN
2951 IF (l_quantity2_to_split < p_rsv.secondary_reservation_quantity) THEN
2952 l_quantity_to_split := (p_rsv.primary_reservation_quantity * l_quantity2_to_split) / p_rsv.secondary_reservation_quantity;
2953 ELSE
2954 l_quantity_to_split := p_rsv.primary_reservation_quantity;
2955 END IF;
2956 IF l_debug_on THEN
2957 WSH_DEBUG_SV.log(l_module_name, 'adjusted l_quantity_to_split', l_quantity_to_split);
2958 END IF;
2959 END IF;
2960 END IF;
2961 END IF;
2962 -- KYH INVCONV END
2963
2964 IF l_debug_on THEN
2965 WSH_DEBUG_SV.logmsg(l_module_name, 'IN WSH_USA_INV_PVT.RESERVATION_SPLIT_ACTION TO SPLIT : '|| L_QUANTITY_TO_SPLIT );
2966 END IF;
2967 --
2968 -- 2847687 : No More performing Update_Reservations per INV advice,
2969 -- So always calling Transfer Rsvtns.
2970 -- l_quantity_to_split will always be <=
2971 -- p_rsv.primary_reservation_quantity because of least() above
2972 --
2973 -- transfer reservation with l_quantity_to_split
2974 IF l_debug_on THEN
2975 WSH_DEBUG_SV.logmsg(l_module_name, 'QUANTITY TO SPLIT : '|| L_QUANTITY_TO_SPLIT );
2976 WSH_DEBUG_SV.logmsg(l_module_name, 'QUANTITY2 TO SPLIT : '|| L_QUANTITY2_TO_SPLIT );
2977 END IF;
2978
2979 l_rsv_new := p_rsv_new;
2980 l_rsv_new.primary_reservation_quantity := l_quantity_to_split;
2981
2982 -- HW OPMCONV Added secondary_qty2
2983 l_rsv_new.secondary_reservation_quantity := l_quantity2_to_split;
2984
2985 -- bug 2925398: corrected detailed quantity assignment.
2986 -- MOL's detailed portion should not be touched directly
2987 -- unless the line is released to warehouse
2988 IF p_released_status = 'S' THEN
2989 l_rsv_new.detailed_quantity := least(p_rsv.detailed_quantity,
2990 l_quantity_to_split);
2991 l_rsv_new.secondary_detailed_quantity :=
2992 least(p_rsv.secondary_detailed_quantity,
2993 l_quantity2_to_split);
2994 ELSE
2995 l_rsv_new.detailed_quantity := 0;
2996 IF l_rsv_new.secondary_detailed_quantity > 0 THEN
2997 l_rsv_new.secondary_detailed_quantity := 0;
2998 END IF;
2999 END IF;
3000
3001 IF l_debug_on THEN
3002 WSH_DEBUG_SV.log(l_module_name, 'l_rsv_new.detailed_quantity',
3003 l_rsv_new.detailed_quantity);
3004 WSH_DEBUG_SV.log(l_module_name, 'l_rsv_new.secondary_detailed_quantity',
3005 l_rsv_new.secondary_detailed_quantity);
3006 END IF;
3007
3008 --
3009 -- FP bug 4107648
3010 -- Bug 4092477 : Do not call INV API if the quantity to split is NULL
3011 --
3012 IF l_rsv_new.primary_reservation_quantity IS NOT NULL THEN --{
3013 --
3014 IF l_debug_on THEN
3015 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit INV_RESERVATION_PUB.TRANSFER_RESERVATION',WSH_DEBUG_SV.C_PROC_LEVEL);
3016 WSH_DEBUG_SV.log(l_module_name,'l_rsv_new.primary_reservation_quantity',
3017 l_rsv_new.primary_reservation_quantity);
3018 WSH_DEBUG_SV.log(l_module_name,'l_rsv_new.secondary_reservation_quantity',
3019 l_rsv_new.secondary_reservation_quantity);
3020 END IF;
3021 --
3022 --Added for bug 10105817
3023
3024 IF ( p_shipped_flag = 'Y' ) THEN
3025 l_validation_flag := 'N';
3026 ELSE
3027 l_validation_flag := 'Y';
3028 END IF;
3029
3030 INV_RESERVATION_PUB.transfer_reservation
3031 (p_api_version_number => 1.0,
3032 p_init_msg_lst => fnd_api.g_true,
3033 x_return_status => l_status,
3034 x_msg_count => l_msg_count,
3035 x_msg_data => l_msg_data,
3036 p_original_rsv_rec => p_rsv,
3037 p_to_rsv_rec => l_rsv_new,
3038 p_original_serial_number => l_dummy_sn, -- no serial contorl
3039 p_to_serial_number => l_dummy_sn, -- no serial control
3040 p_validation_flag => l_validation_flag,
3041 -- Bug 5099694
3042 p_over_reservation_flag =>3,
3043 x_to_reservation_id => l_new_rsv_id
3044 );
3045 IF l_debug_on THEN
3046 WSH_DEBUG_SV.log(l_module_name,'transfer_reservation l_status',l_status);
3047 END IF;
3048
3049 IF l_status = fnd_api.g_ret_sts_success THEN
3050 IF l_debug_on THEN
3051 -- HW OPMCONV - Print Qty2
3052 WSH_DEBUG_SV.logmsg(l_module_name, 'Rsvn. Transferred FOR Rsvn.ID :'
3053 ||P_RSV.RESERVATION_ID || ' : TO Rsvn.ID : '||L_NEW_RSV_ID||
3054 ' BY Qty: '||L_QUANTITY_TO_SPLIT ||
3055 ' BY Qty2: '||L_QUANTITY2_TO_SPLIT );
3056 END IF;
3057 x_new_rsv_id := l_new_rsv_id; -- bug # 9410461: Return the reservation id created.
3058 ELSE
3059 IF l_debug_on THEN
3060 WSH_DEBUG_SV.logmsg(l_module_name, 'COULD NOT TRANSFER FOR RESERVATION ID : '||P_RSV.RESERVATION_ID );
3061 END IF;
3062 FND_MESSAGE.Set_Name('WSH', 'WSH_TRANSFER_RESERVATION');
3063 IF l_msg_count = 1 THEN
3064 IF l_debug_on THEN
3065 WSH_DEBUG_SV.logmsg(l_module_name, 'ERROR: '|| L_MSG_DATA );
3066 END IF;
3067 --
3068 FND_MESSAGE.Set_Token('ERROR_TEXT',l_msg_data);
3069 ELSE
3070 FOR l_index IN 1..l_msg_count LOOP
3071 l_msg_data := fnd_msg_pub.get;
3072 IF l_debug_on THEN
3073 WSH_DEBUG_SV.logmsg(l_module_name, 'ERROR: '|| L_MSG_DATA );
3074 END IF;
3075 --
3076 l_error_text := l_error_text || l_msg_data;
3077 END LOOP;
3078 FND_MESSAGE.Set_Token('ERROR_TEXT',l_error_text);
3079 l_error_text := '';
3080 END IF;
3081 raise transfer_split_failed;
3082 END IF;
3083
3084 IF p_staged = 'Y' THEN
3085 IF l_debug_on THEN
3086 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit INV_STAGED_RESERVATION_UTIL.UPDATE_STAGED_FLAG',WSH_DEBUG_SV.C_PROC_LEVEL);
3087 END IF;
3088 --
3089 INV_STAGED_RESERVATION_UTIL.update_staged_flag
3090 ( x_return_status => l_status,
3091 x_msg_count => l_msg_count,
3092 x_msg_data => l_msg_data,
3093 p_reservation_id => l_new_rsv_id,
3094 p_staged_flag => p_staged
3095 );
3096 IF l_debug_on THEN
3097 WSH_DEBUG_SV.log(l_module_name,'update_staged_flag l_status',l_status);
3098 END IF;
3099
3100 IF l_status = fnd_api.g_ret_sts_success THEN
3101 IF l_debug_on THEN
3102 WSH_DEBUG_SV.logmsg(l_module_name, 'STAGED FLAG UPDATED FOR RESERVATION ID : '||L_NEW_RSV_ID );
3103 END IF;
3104 ELSE
3105 IF l_debug_on THEN
3106 WSH_DEBUG_SV.logmsg(l_module_name, 'COULD NOT UPDATE STAGED FLAG FOR RESERVATION ID : '||L_NEW_RSV_ID );
3107 END IF;
3108 IF l_msg_count = 1 THEN
3109 IF l_debug_on THEN
3110 WSH_DEBUG_SV.logmsg(l_module_name, 'ERROR: '|| L_MSG_DATA );
3111 END IF;
3112 ELSE
3113 FOR l_index IN 1..l_msg_count LOOP
3114 l_msg_data := fnd_msg_pub.get;
3115 IF l_debug_on THEN
3116 WSH_DEBUG_SV.logmsg(l_module_name, 'ERROR: '|| L_MSG_DATA );
3117 END IF;
3118 END LOOP;
3119 END IF;
3120 raise transfer_split_failed;
3121 END IF;
3122
3123 END IF; -- Stgd. Flag
3124
3125 p_split_quantity := p_split_quantity - l_quantity_to_split;
3126 -- HW OPMCONV -Added Qty2
3127 IF ( p_split_quantity2 IS NULL
3128 OR p_split_quantity2 = FND_API.G_MISS_NUM) THEN
3129 p_split_quantity2 :=0;
3130 ELSE
3131 p_split_quantity2 := p_split_quantity2 - l_quantity2_to_split;
3132 END IF;
3133
3134 x_return_status := l_status;
3135
3136 END IF; --} /* l_quantity_to_split IS NOT NULL */
3137
3138
3139 IF l_debug_on THEN
3140 WSH_DEBUG_SV.pop(l_module_name);
3141 END IF;
3142
3143 --
3144 EXCEPTION
3145 WHEN transfer_split_failed THEN
3146 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
3147 WSH_UTIL_CORE.add_message (x_return_status,l_module_name);
3148 IF l_debug_on THEN
3149 WSH_DEBUG_SV.logmsg(l_module_name,'TRANSFER_SPLIT_FAILED exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
3150 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:TRANSFER_SPLIT_FAILED');
3151 END IF;
3152 --
3153 WHEN others THEN
3154 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
3155 wsh_util_core.default_handler('WSH_USA_INV_PVT.reservation_split_action',l_module_name);
3156 IF l_debug_on THEN
3157 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
3158 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
3159 END IF;
3160 --
3161 END reservation_split_action;
3162
3163
3164 -- This procedure takes care that reservations get updated/transferred by the split quantity
3165 -- when an order line gets split.
3166 -- Bug 2540015: Added p_move_order_line_status. Expected values are 'TRANSFER', 'CANCEL'
3167 -- HW OPMCONV - Added p_split_quantity2
3168 -- Added parameter p_shipped_flag for bug 10105817
3169 PROCEDURE split_reservation (
3170 p_delivery_detail_split_rec IN DeliveryDetailInvRecType,
3171 p_source_code IN VARCHAR2,
3172 p_source_header_id IN NUMBER,
3173 p_original_source_line_id IN NUMBER,
3174 p_split_source_line_id IN NUMBER,
3175 p_split_quantity IN NUMBER, -- Passed requested_quantity
3176 p_split_quantity2 IN NUMBER,
3177 p_move_order_line_status IN VARCHAR2,
3178 p_direction_flag IN VARCHAR2 default 'U',
3179 p_shipped_flag IN VARCHAR2 default 'N',
3180 x_return_status OUT NOCOPY VARCHAR2)
3181 IS
3182
3183 -- bug # 9410461: Begin
3184 l_new_rsv_id NUMBER;
3185 l_mmtt_tbl INV_MO_LINE_DETAIL_UTIL.g_mmtt_tbl_type;
3186 l_temp_transaction_quantity NUMBER;
3187 l_temp_transaction_quantity2 NUMBER;
3188 -- bug # 9410461: End
3189
3190 l_rsv_new inv_reservation_global.mtl_reservation_rec_type;
3191 l_msg_count NUMBER;
3192 l_msg_data VARCHAR2(240);
3193 l_rsv_id NUMBER;
3194 l_status VARCHAR2(1);
3195 l_rsv_array inv_reservation_global.mtl_reservation_tbl_type;
3196 l_size NUMBER;
3197 l_staged_flag VARCHAR2(1);
3198 -- HW OPMCONV. Removed OPM local variables
3199
3200 l_split_quantity NUMBER;
3201 -- HW OPMCONV. Added l_split_quantity2
3202 l_split_quantity2 NUMBER ;
3203 l_sales_order_id NUMBER;
3204 l_reservation_id NUMBER;
3205
3206 l_detail_tab WSH_UTIL_CORE.id_tab_type; -- DBI Project
3207 l_dbi_rs VARCHAR2(1); -- DBI Project
3208
3209 l_wf_rs VARCHAR2(1); --Pick to POD WF Project
3210 l_organization_id NUMBER; --Pick to POD WF Project
3211
3212 l_delivery_detail_id NUMBER;
3213 split_failed EXCEPTION;
3214
3215 l_released_status WSH_DELIVERY_DETAILS.RELEASED_STATUS%TYPE;
3216 -- muom
3217 l_fulfillment_base varchar2(1);
3218
3219 --
3220 l_debug_on BOOLEAN;
3221 --
3222 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PACKAGE_NAME || '.' || 'SPLIT_RESERVATION';
3223 --
3224 BEGIN
3225 --
3226 -- Debug Statements
3227 --
3228 --
3229 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
3230 --
3231 IF l_debug_on IS NULL
3232 THEN
3233 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
3234 END IF;
3235 --
3236 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS; -- bug # 9410461: Initializing return status.
3237 --
3238 IF l_debug_on THEN
3239 WSH_DEBUG_SV.push(l_module_name);
3240 --
3241 WSH_DEBUG_SV.log(l_module_name,'P_SOURCE_CODE',P_SOURCE_CODE);
3242 WSH_DEBUG_SV.log(l_module_name,'P_SOURCE_HEADER_ID',P_SOURCE_HEADER_ID);
3243 WSH_DEBUG_SV.log(l_module_name,'P_ORIGINAL_SOURCE_LINE_ID',P_ORIGINAL_SOURCE_LINE_ID);
3244 WSH_DEBUG_SV.log(l_module_name,'P_SPLIT_SOURCE_LINE_ID',P_SPLIT_SOURCE_LINE_ID);
3245 WSH_DEBUG_SV.log(l_module_name,'P_SPLIT_QUANTITY',P_SPLIT_QUANTITY);
3246 WSH_DEBUG_SV.log(l_module_name,'P_SPLIT_QUANTITY2',P_SPLIT_QUANTITY2);
3247 WSH_DEBUG_SV.log(l_module_name,'P_SHIPPED_FLAG', P_SHIPPED_FLAG);
3248 WSH_DEBUG_SV.log(l_module_name,'p_delivery_detail_split_rec.organization_id',p_delivery_detail_split_rec.organization_id);
3249 WSH_DEBUG_SV.log(l_module_name,'p_delivery_detail_split_rec.delivery_detail_id',p_delivery_detail_split_rec.delivery_detail_id);
3250 WSH_DEBUG_SV.log(l_module_name,'p_delivery_detail_split_rec.inventory_item_id',p_delivery_detail_split_rec.inventory_item_id);
3251 END IF;
3252
3253 -- muom
3254 l_fulfillment_base := WSH_UTIL_CORE.Get_Line_Fulfillment_Base(p_source_code, p_original_source_line_id);
3255 --
3256 --
3257 -- Debug Statements
3258 -- HW OPMCONV. Removed checking for OPM org
3259
3260 --X-dock,split
3261 WSH_USA_INV_PVT.get_putaway_detail_id
3262 (p_detail_id => p_delivery_detail_split_rec.delivery_detail_id,
3263 p_released_status => p_delivery_detail_split_rec.released_status,
3264 p_move_order_line_id => p_delivery_detail_split_rec.move_order_line_id,
3265 x_detail_id => l_delivery_detail_id,
3266 x_return_status => x_return_status);
3267
3268 -- Above call populates l_delivery_detail_id and is used at multiple places in this API
3269 IF x_return_status IN (FND_API.G_RET_STS_UNEXP_ERROR,FND_API.G_RET_STS_ERROR) THEN
3270 IF l_debug_on THEN
3271 WSH_DEBUG_SV.log(l_module_name,'Exception has occured after WSHUSAIB.get_putaway_detail_id');
3272 WSH_DEBUG_SV.pop(l_module_name);
3273 END IF;
3274 RETURN;
3275 END IF;
3276 --End of X-dock,split
3277
3278 --
3279 -- Debug Statements
3280 --
3281 IF l_debug_on THEN
3282 WSH_DEBUG_SV.logmsg(l_module_name, 'IN WSH_USA_INV_PVT.SPLIT_RESERVATION TO SPLIT : '|| P_SPLIT_QUANTITY );
3283 END IF;
3284 --
3285 --{
3286 IF p_delivery_detail_split_rec.released_status = 'S' THEN
3287 --call INV s cancel move order line API with update reservation flag 'N'
3288 --this should clear out the detailed quantity for the appropriate reservation records
3289 -- Bug 2437799: Cancel the move order line or transfer it to new order line
3290 -- depending on parameter p_move_order_line_status
3291 IF l_debug_on THEN
3292 WSH_DEBUG_SV.logmsg(l_module_name, 'p_move_order_line_status is '||p_move_order_line_status);
3293 END IF;
3294 IF (p_move_order_line_status = 'CANCEL') THEN
3295 --
3296 -- HW OPMCONV. Removed forking the code
3297
3298 IF l_debug_on THEN
3299 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit INV_MO_CANCEL_PVT.CANCEL_MOVE_ORDER_LINE',WSH_DEBUG_SV.C_PROC_LEVEL);
3300 WSH_DEBUG_SV.logmsg(l_module_name, 'CALLING INV_MO_CANCEL_PVT.CANCEL_MOVE_ORDER_LINE FOR DD : '|| P_DELIVERY_DETAIL_SPLIT_REC.DELIVERY_DETAIL_ID);
3301 WSH_DEBUG_SV.logmsg(l_module_name, 'CALLING INV_MO_CANCEL_PVT.CANCEL_MOVE_ORDER_LINE FOR MOL : '|| P_DELIVERY_DETAIL_SPLIT_REC.MOVE_ORDER_LINE_ID);
3302 END IF;
3303 --
3304 -- X-dock changes, added p_delivery_detail_id
3305 INV_MO_CANCEL_PVT.Cancel_Move_Order_Line
3306 (p_line_id => p_delivery_detail_split_rec.move_order_line_id,
3307 p_delete_reservations => 'N',
3308 p_txn_source_line_id => p_original_source_line_id,
3309 p_delivery_detail_id => p_delivery_detail_split_rec.delivery_detail_id,
3310 x_return_status => x_return_status,
3311 x_msg_count => l_msg_count,
3312 x_msg_data => l_msg_data);
3313 IF l_debug_on THEN
3314 WSH_DEBUG_SV.log(l_module_name,'Cancel_Move_Order_Line x_return_status',x_return_status);
3315 END IF;
3316
3317 -- bug 5226867
3318 IF (x_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR) THEN
3319 --
3320 IF l_debug_on THEN
3321 WSH_DEBUG_SV.log(l_module_name,'Cancel_Move_Order_Line returned unexpected error');
3322 END IF;
3323
3324 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3325 --
3326 ELSIF (x_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR) THEN
3327 --
3328 IF l_debug_on THEN
3329 WSH_DEBUG_SV.log(l_module_name,'Cancel_Move_Order_Line returned error');
3330 END IF;
3331
3332 RAISE split_failed;
3333 --
3334 END IF;
3335 -- bug 5226867
3336
3337 -- HW OPMCONV. Removed code forking
3338
3339 -- For X-dock progressed line, l_delivery_detail_id will be not null,else null
3340 -- X-dock,split
3341 --{
3342 -- released_status is already checked above, should be 'S'
3343 IF p_delivery_detail_split_rec.move_order_line_id IS NOT NULL THEN
3344 IF l_debug_on THEN
3345 WSH_DEBUG_SV.log(l_module_name,'Updating released_status for detail');
3346 END IF;
3347 UPDATE wsh_delivery_details
3348 SET released_status = 'R',
3349 move_order_line_id = NULL
3350 WHERE delivery_detail_id = p_delivery_detail_split_rec.delivery_detail_id
3351 RETURNING organization_id -- done for Workflow Project
3352 INTO l_organization_id;
3353
3354 --Raise Event : Pick To Pod Workflow
3355 WSH_WF_STD.Raise_Event
3356 (p_entity_type => 'LINE',
3357 p_entity_id => p_delivery_detail_split_rec.delivery_detail_id ,
3358 p_event => 'oracle.apps.wsh.line.gen.readytorelease' ,
3359 p_organization_id => l_organization_id,
3360 x_return_status => l_wf_rs);
3361
3362 --Error Handling to be done in WSH_WF_STD.Raise_Event itself
3363 IF l_debug_on THEN
3364 WSH_DEBUG_SV.log(l_module_name,'Current Time is ',SYSDATE);
3365 wsh_debug_sv.log(l_module_name,'Return Status After Calling WSH_WF_STD.Raise_Event',l_wf_rs);
3366 END IF;
3367 --Done Raise Event: Pick To Pod Workflow
3368
3369 --
3370 -- DBI Project
3371 -- Update of wsh_delivery_details where released_status
3372 -- are changed, call DBI API after the update.
3373 -- This API will also check for DBI Installed or not
3374 IF l_debug_on THEN
3375 WSH_DEBUG_SV.log(l_module_name,'Calling DBI API.Detail id-',p_delivery_detail_split_rec.delivery_detail_id);
3376 END IF;
3377 l_detail_tab(1) := p_delivery_detail_split_rec.delivery_detail_id;
3378 WSH_INTEGRATION.DBI_Update_Detail_Log
3379 (p_delivery_detail_id_tab => l_detail_tab,
3380 p_dml_type => 'UPDATE',
3381 x_return_status => l_dbi_rs);
3382
3383 IF l_debug_on THEN
3384 WSH_DEBUG_SV.log(l_module_name,'Return Status after DBI Call-',l_dbi_rs);
3385 END IF;
3386 IF l_dbi_rs = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
3387 x_return_status := l_dbi_rs;
3388 -- just pass this return status to caller API
3389 IF l_debug_on THEN
3390 WSH_DEBUG_SV.pop(l_module_name,'DBI API Returned Unexpected error '||x_return_status);
3391 WSH_DEBUG_SV.pop(l_module_name);
3392 END IF;
3393 return;
3394 END IF;
3395 -- End of Code for DBI Project
3396 --
3397 END IF;
3398 --}
3399 -- end of X-dock,split
3400
3401 ELSIF (p_move_order_line_status IN ('TRANSFER','PTOTRANSFER') ) THEN -- bug # 9410461: consider new value 'PTOTRANSFER'
3402 -- HW OPMCONV. Removed forking the code
3403
3404 IF l_debug_on THEN
3405 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit INV_Transfer_Order_PVT.Update_Txn_Source_Line',WSH_DEBUG_SV.C_PROC_LEVEL);
3406 END IF;
3407 INV_Transfer_Order_PVT.Update_Txn_Source_Line
3408 (p_line_id => p_delivery_detail_split_rec.move_order_line_id,
3409 p_new_source_line_id => p_split_source_line_id);
3410 --
3411 -- bug # 9410461: Begin
3412 IF ( p_move_order_line_status = 'PTOTRANSFER' ) THEN
3413 --{
3414 -- bug # 9410461: Get all mmtt records for the given move order line id.
3415 -- This is required as the reservation_id of MMTT needs to updated when
3416 -- original reservation got split and transferred to new line.
3417 IF l_debug_on THEN
3418 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit inv_mo_line_detail_util.query_rows',WSH_DEBUG_SV.C_PROC_LEVEL);
3419 END IF;
3420 l_mmtt_tbl := inv_mo_line_detail_util.query_rows(p_line_id => p_delivery_detail_split_rec.move_order_line_id);
3421 --
3422 IF l_debug_on THEN
3423 WSH_DEBUG_SV.log(l_module_name,'l_mmtt_tbl count',l_mmtt_tbl.Count);
3424 END IF;
3425 --}
3426 END IF;
3427 -- bug # 9410461: end
3428
3429 -- HW OPMCONV. Removed code forking
3430
3431 END IF; -- p_move_order_line_status
3432 END IF; -- p_delivery_detail_split_rec.released_status
3433 --}
3434
3435 l_split_quantity := p_split_quantity;
3436 -- HW OPMCONV. Added split_quantity2
3437 IF ( p_split_quantity2 = 0 OR p_split_quantity2 = FND_API.G_MISS_NUM) THEN
3438 l_split_quantity2 := NULL;
3439 ELSE
3440 l_split_quantity2 := p_split_quantity2;
3441 END IF;
3442 IF l_debug_on THEN
3443 WSH_DEBUG_SV.logmsg(l_module_name, 'VALUE OF L_SPLIT_QUANTITY IN SPLIT_RESERVATION '||L_SPLIT_QUANTITY );
3444 -- HW OPMCONV. Print Qty2
3445 WSH_DEBUG_SV.logmsg(l_module_name, 'VALUE OF L_SPLIT_QUANTITY2 IN SPLIT_RESERVATION '||L_SPLIT_QUANTITY2 );
3446
3447 END IF;
3448 --
3449 -- HW OPMCONV. Removed forking the code
3450
3451 --X-dock
3452 query_reservations (
3453 p_source_code => p_source_code,
3454 p_source_header_id => p_source_header_id,
3455 p_source_line_id => p_original_source_line_id,
3456 p_organization_id => p_delivery_detail_split_rec.organization_id,
3457 p_lock_records => fnd_api.g_true,
3458 p_direction_flag => p_direction_flag ,
3459 p_delivery_detail_id => l_delivery_detail_id, -- X-dock
3460 x_mtl_reservation_tbl => l_rsv_array,
3461 x_mtl_reservation_tbl_count => l_size,
3462 x_return_status => x_return_status);
3463 IF l_debug_on THEN
3464 WSH_DEBUG_SV.log(l_module_name,'query_reservations x_return_status',x_return_status);
3465 END IF;
3466 -- bug # 9410461: When transferring reservations
3467 -- only transfer the reservations which are associated MMTT records of the
3468 -- currrent move order line. If new reservation is created due to the split
3469 -- (when reservation qty is more than the current MMTT transactions qty) then
3470 -- stamp the new reservation id created on MMTT record.
3471 IF ( p_delivery_detail_split_rec.released_status = 'S'
3472 AND p_move_order_line_status = 'PTOTRANSFER' AND l_mmtt_tbl.Count > 0 ) THEN
3473 --{
3474 IF l_debug_on THEN
3475 WSH_DEBUG_SV.logmsg(l_module_name, 'Inside the PTO reservations'||l_size);
3476 END IF;
3477 l_sales_order_id := OE_ORDER_SCH_UTIL.Get_mtl_sales_order_id(p_source_header_id);
3478 l_rsv_new.demand_source_line_id := p_split_source_line_id;
3479 l_rsv_new.demand_source_header_id := l_sales_order_id;
3480 FOR j IN 1..l_mmtt_tbl.COUNT LOOP
3481 --{
3482 -- check reservations ids needs to be transferred.
3483 FOR l_counter in 1..l_size LOOP
3484 --{
3485 IF l_mmtt_tbl(j).reservation_id = l_rsv_array(l_counter).reservation_id THEN
3486 --{ Reservation is matched. needs to transfer to new line.
3487 IF l_debug_on THEN
3488 WSH_DEBUG_SV.log(l_module_name,'move order line id ',p_delivery_detail_split_rec.move_order_line_id);
3489 WSH_DEBUG_SV.log(l_module_name, 'Reservation Id',l_mmtt_tbl(j).reservation_id);
3490 WSH_DEBUG_SV.log(l_module_name,'MMTT qty ',l_mmtt_tbl(j).transaction_quantity);
3491 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit reservation_split_action',WSH_DEBUG_SV.C_PROC_LEVEL);
3492 END IF;
3493 l_temp_transaction_quantity := l_mmtt_tbl(j).transaction_quantity; -- p_split_quantity is IN/OUT parameter and hence this is req.
3494 l_temp_transaction_quantity2 := l_mmtt_tbl(j).secondary_transaction_quantity; -- p_split_quantity is IN/OUT parameter and hence this is req.
3495 reservation_split_action (
3496 p_rsv => l_rsv_array(l_counter),
3497 p_rsv_new => l_rsv_new,
3498 p_staged => l_staged_flag,
3499 p_released_status => p_delivery_detail_split_rec.released_status,
3500 p_split_quantity => l_temp_transaction_quantity,
3501 p_split_quantity2 => l_temp_transaction_quantity2,
3502 p_source_code => p_source_code,
3503 x_new_rsv_id => l_new_rsv_id,
3504 p_shipped_flag => p_shipped_flag,
3505 -- muom
3506 p_fulfillment_base => l_fulfillment_base,
3507 x_return_status => x_return_status);
3508 IF l_debug_on THEN
3509 WSH_DEBUG_SV.log(l_module_name, 'reservation_split_action',x_return_status);
3510 END IF;
3511 IF x_return_status <> fnd_api.g_ret_sts_success THEN
3512 raise split_failed;
3513 END IF;
3514 IF l_new_rsv_id <> l_rsv_array(l_counter).reservation_id THEN
3515 --{
3516 l_mmtt_tbl(j).reservation_id := l_new_rsv_id;
3517 IF l_debug_on THEN
3518 WSH_DEBUG_SV.log(l_module_name,'new reservation Id ',l_mmtt_tbl(j).reservation_id);
3519 WSH_DEBUG_SV.log(l_module_name,' temp id ',l_mmtt_tbl(j).transaction_temp_id);
3520 WSH_DEBUG_SV.log(l_module_name,' move order line id ',l_mmtt_tbl(j).move_order_line_id);
3521 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit inv_mo_line_detail_util.update_row',WSH_DEBUG_SV.C_PROC_LEVEL);
3522 END IF;
3523 inv_mo_line_detail_util.update_row(
3524 p_mo_line_detail_rec => l_mmtt_tbl(j),
3525 x_return_status => x_return_status);
3526 IF l_debug_on THEN
3527 WSH_DEBUG_SV.log(l_module_name, 'return_status',x_return_status);
3528 END IF;
3529 IF x_return_status <> fnd_api.g_ret_sts_success THEN
3530 raise split_failed;
3531 END IF;
3532 --}
3533 END IF;
3534 EXIT;
3535 --}
3536 END IF;
3537 --}
3538 END LOOP;
3539 --}
3540 END LOOP;
3541 ELSE -- non PTOTRANSFER case..
3542 -- loop over all the reservation records in l_rsv_array
3543 FOR l_counter in 1..l_size LOOP
3544 IF l_debug_on THEN
3545 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit INV_STAGED_RESERVATION_UTIL.QUERY_STAGED_FLAG',WSH_DEBUG_SV.C_PROC_LEVEL);
3546 END IF;
3547 --
3548 INV_STAGED_RESERVATION_UTIL.query_staged_flag(
3549 x_return_status => x_return_status,
3550 x_msg_count => l_msg_count,
3551 x_msg_data => l_msg_data,
3552 x_staged_flag => l_staged_flag,
3553 p_reservation_id => l_rsv_array(l_counter).reservation_id);
3554 IF l_debug_on THEN
3555 WSH_DEBUG_SV.log(l_module_name,'query_staged_flag x_return_status',x_return_status);
3556 END IF;
3557
3558 IF l_debug_on THEN
3559 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit OE_ORDER_SCH_UTIL.GET_MTL_SALES_ORDER_ID',WSH_DEBUG_SV.C_PROC_LEVEL);
3560 END IF;
3561 --
3562 l_sales_order_id := OE_ORDER_SCH_UTIL.Get_mtl_sales_order_id(p_source_header_id);
3563
3564 l_rsv_new.demand_source_line_id := p_split_source_line_id;
3565 l_rsv_new.demand_source_header_id := l_sales_order_id;
3566 --X-dock,split
3567 IF (p_delivery_detail_split_rec.released_status = 'S' AND
3568 p_delivery_detail_split_rec.move_order_line_id IS NULL) THEN
3569 IF l_debug_on THEN
3570 WSH_DEBUG_SV.logmsg(l_module_name,'Delivery Detail-',p_delivery_detail_split_rec.delivery_detail_id);
3571 END IF;
3572 l_rsv_new.demand_source_line_detail := p_delivery_detail_split_rec.delivery_detail_id;
3573 END IF;
3574 --X-dock,split
3575
3576 IF l_debug_on THEN
3577 WSH_DEBUG_SV.logmsg(l_module_name, 'L_RSV_NEW.DEMAND_SOURCE_LINE_ID IN SPLIT_RESERV IS '||L_RSV_NEW.DEMAND_SOURCE_LINE_ID );
3578 WSH_DEBUG_SV.logmsg(l_module_name, 'L_RSV_NEW.DEMAND_SOURCE_LINE_DETAIL IN SPLIT_RESERV IS '||L_RSV_NEW.DEMAND_SOURCE_LINE_DETAIL );
3579 WSH_DEBUG_SV.logmsg(l_module_name, 'L_RSV_NEW.DEMAND_SOURCE_HEADER_ID IN SPLIT_RESERV IS '||L_RSV_NEW.DEMAND_SOURCE_HEADER_ID );
3580 WSH_DEBUG_SV.logmsg(l_module_name, 'p_delivery_detail_split_rec.released_status '||p_delivery_detail_split_rec.released_status);
3581 WSH_DEBUG_SV.logmsg(l_module_name, 'l_rsv_array(l_counter).detailed_quantity '||nvl(l_rsv_array(l_counter).detailed_quantity,0)||' l_staged_flag '||l_staged_flag);
3582 WSH_DEBUG_SV.logmsg(l_module_name, 'l_rsv_array(l_counter).primary_reservation_quantity '||l_rsv_array(l_counter).primary_reservation_quantity);
3583 -- HW OPMCONV - Print Qty2
3584 WSH_DEBUG_SV.logmsg(l_module_name, 'l_rsv_array(l_counter).secondary_detailed_quantity '||nvl(l_rsv_array(l_counter).secondary_detailed_quantity,0)||' l_staged_flag '||l_staged_flag);
3585 WSH_DEBUG_SV.logmsg(l_module_name, 'l_rsv_array(l_counter).secondary_reservation_quantity '||l_rsv_array(l_counter).secondary_reservation_quantity);
3586 END IF;
3587
3588 IF ((l_rsv_array(l_counter).primary_reservation_quantity > 0) AND
3589 (l_rsv_array(l_counter).primary_reservation_quantity >= nvl(l_rsv_array(l_counter).detailed_quantity,0))) THEN
3590 IF ( p_delivery_detail_split_rec.released_status IN ('Y','C') AND
3591 -- Bug3012297 (Included reference to parameters)
3592 check_inv_info( p_delivery_detail_split_rec => p_delivery_detail_split_rec
3593 , p_rsv => l_rsv_array(l_counter)) AND
3594 l_staged_flag = 'Y' ) OR
3595 -- We can split only staged reservation here as long as Inventory
3596 -- information match
3597 -- Bug 2540015: Added p_move_order_line_status
3598 ( p_delivery_detail_split_rec.released_status NOT IN ('Y','C') AND
3599 (p_move_order_line_status = 'TRANSFER' OR
3600 (p_move_order_line_status = 'CANCEL' AND nvl(l_rsv_array(l_counter).detailed_quantity,0) = 0)
3601 ) AND
3602 l_staged_flag <> 'Y' )
3603 -- Can split only unstaged reservations with detailed_quantity NULL
3604 -- here.
3605 -- Do we have to look at inventory information here ?
3606 -- No as talked to John (08/21)
3607 THEN
3608 IF l_debug_on THEN
3609 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit reservation_split_action',WSH_DEBUG_SV.C_PROC_LEVEL);
3610 END IF;
3611 -- HW OPMCONV. Added l_split_quantity2
3612
3613 -- 2925398: keep track of released status.
3614 l_released_status := p_delivery_detail_split_rec.released_status;
3615 IF l_released_status = 'S'
3616 AND p_move_order_line_status = 'CANCEL' THEN
3617 -- at this time, the detailed quantity belonging to MOL of
3618 -- this line would have become cancelled.
3619 l_released_status := 'R';
3620 END IF;
3621
3622 reservation_split_action (
3623 p_rsv => l_rsv_array(l_counter),
3624 p_rsv_new => l_rsv_new ,
3625 p_staged => l_staged_flag,
3626 p_released_status => l_released_status,
3627 p_split_quantity => l_split_quantity,
3628 p_split_quantity2 => l_split_quantity2,
3629 p_source_code => p_source_code,
3630 x_new_rsv_id => l_new_rsv_id, -- bug # 9410461: just for compatible.
3631 p_shipped_flag => p_shipped_flag, -- added for bug 10105817
3632 -- muom
3633 p_fulfillment_base => l_fulfillment_base,
3634 x_return_status => x_return_status);
3635 IF l_debug_on THEN
3636 WSH_DEBUG_SV.log(l_module_name, 'reservation_split_action',x_return_status);
3637 END IF;
3638 IF x_return_status <> fnd_api.g_ret_sts_success THEN
3639 raise split_failed;
3640 END IF;
3641 END IF; -- <> 'Y','C'
3642 END IF;
3643 IF l_split_quantity = 0 THEN
3644 --
3645 -- Debug Statements
3646 --
3647 IF l_debug_on THEN
3648 WSH_DEBUG_SV.logmsg(l_module_name, 'NOTHING TO SPLIT WE WILL EXIT IN SPLIT_RESERVATION' );
3649 END IF;
3650 --
3651 EXIT;
3652 END IF;
3653 END LOOP; -- Loop over reservation records
3654 -- HW OPMCONV. Removed code forking
3655 --} PTOTRANSFER case
3656 END IF; -- bug # 9410461: : End
3657 --
3658 --
3659 -- Debug Statements
3660 --
3661 IF l_debug_on THEN
3662 WSH_DEBUG_SV.pop(l_module_name);
3663 END IF;
3664 --
3665 EXCEPTION
3666 WHEN split_failed THEN
3667 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
3668 --
3669 -- Debug Statements
3670 --
3671 IF l_debug_on THEN
3672 WSH_DEBUG_SV.logmsg(l_module_name,'SPLIT_FAILED exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
3673 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:SPLIT_FAILED');
3674 END IF;
3675 --
3676 -- bug 5226867
3677 -- Added the new excpetion for unexpected error
3678 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3679 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR ;
3680 --
3681 -- Debug Statements
3682 --
3683 IF l_debug_on THEN
3684 WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
3685 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
3686 END IF;
3687 --
3688 -- bug 5226867
3689 WHEN others THEN
3690 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
3691 wsh_util_core.default_handler('WSH_USA_INV_PVT.split_reservation',l_module_name);
3692
3693 --
3694 -- Debug Statements
3695 --
3696 IF l_debug_on THEN
3697 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
3698 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
3699 END IF;
3700 --
3701 END split_reservation;
3702
3703 -- update_serial_numbers
3704
3705 PROCEDURE update_serial_numbers(
3706 p_delivery_detail_id IN NUMBER,
3707 p_serial_number IN VARCHAR2,
3708 p_transaction_temp_id IN NUMBER,
3709 x_return_status OUT NOCOPY VARCHAR2)
3710 IS
3711 CURSOR Get_Sl_Num_Ctrl_Cd IS
3712 SELECT msi.serial_number_control_code
3713 FROM mtl_system_items msi,
3714 wsh_delivery_details wdd
3715 WHERE msi.inventory_item_id = wdd.inventory_item_id
3716 AND msi.organization_id = wdd.organization_id
3717 AND wdd.delivery_detail_id = p_delivery_detail_id;
3718
3719 l_serial_number_control_code NUMBER;
3720
3721 --
3722 l_debug_on BOOLEAN;
3723 --
3724 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PACKAGE_NAME || '.' || 'UPDATE_SERIAL_NUMBERS';
3725 --
3726 BEGIN
3727 --
3728 -- Debug Statements
3729 --
3730 --
3731 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
3732 --
3733 IF l_debug_on IS NULL
3734 THEN
3735 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
3736 END IF;
3737 --
3738 IF l_debug_on THEN
3739 WSH_DEBUG_SV.push(l_module_name);
3740 --
3741 WSH_DEBUG_SV.log(l_module_name,'P_DELIVERY_DETAIL_ID',P_DELIVERY_DETAIL_ID);
3742 WSH_DEBUG_SV.log(l_module_name,'P_SERIAL_NUMBER',P_SERIAL_NUMBER);
3743 WSH_DEBUG_SV.log(l_module_name,'P_TRANSACTION_TEMP_ID',P_TRANSACTION_TEMP_ID);
3744 END IF;
3745 --
3746 --
3747 -- Debug Statements
3748 --
3749 IF l_debug_on THEN
3750 WSH_DEBUG_SV.logmsg(l_module_name, 'IN WSH_USA_INV_PVT.UPDATE_SERIAL_NUMBERS' );
3751 END IF;
3752 --
3753 IF (p_serial_number IS NULL) AND (p_transaction_temp_id IS NULL) THEN
3754 x_return_status := FND_API.G_RET_STS_SUCCESS;
3755 --
3756 -- Debug Statements
3757 --
3758 IF l_debug_on THEN
3759 WSH_DEBUG_SV.pop(l_module_name);
3760 END IF;
3761 --
3762 RETURN;
3763 ELSE
3764 OPEN Get_Sl_Num_Ctrl_Cd;
3765 FETCH Get_Sl_Num_Ctrl_Cd INTO l_serial_number_control_code;
3766 IF Get_Sl_Num_Ctrl_Cd%NOTFOUND THEN
3767 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3768 CLOSE Get_Sl_Num_Ctrl_Cd;
3769 --
3770 -- Debug Statements
3771 --
3772 IF l_debug_on THEN
3773 WSH_DEBUG_SV.pop(l_module_name);
3774 END IF;
3775 --
3776 RETURN;
3777 END IF;
3778 CLOSE Get_Sl_Num_Ctrl_Cd;
3779
3780 WSH_DELIVERY_DETAILS_INV.Unmark_Serial_Number(
3781 p_delivery_detail_id => p_delivery_detail_id,
3782 p_serial_number_code => l_serial_number_control_code,
3783 p_serial_number => p_serial_number,
3784 p_transaction_temp_id => p_transaction_temp_id,
3785 x_return_status => x_return_status);
3786 IF l_debug_on THEN
3787 WSH_DEBUG_SV.log(l_module_name,'Unmark_Serial_Number x_return_status',x_return_status);
3788 END IF;
3789 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3790 x_return_status := FND_API.G_RET_STS_ERROR;
3791 WSH_UTIL_CORE.add_message (x_return_status,l_module_name);
3792 --
3793 -- Debug Statements
3794 --
3795 IF l_debug_on THEN
3796 WSH_DEBUG_SV.pop(l_module_name);
3797 END IF;
3798 --
3799 RETURN;
3800 END IF;
3801 UPDATE wsh_delivery_details SET
3802 serial_number = NULL,
3803 to_serial_number = NULL,
3804 transaction_temp_id = NULL,
3805 shipped_quantity = 0
3806 WHERE delivery_detail_id = p_delivery_detail_id;
3807 x_return_status := FND_API.G_RET_STS_SUCCESS;
3808 END IF;
3809
3810 --
3811 -- Debug Statements
3812 --
3813 IF l_debug_on THEN
3814 WSH_DEBUG_SV.pop(l_module_name);
3815 END IF;
3816 --
3817 EXCEPTION
3818
3819 WHEN OTHERS THEN
3820 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3821 WSH_UTIL_CORE.default_handler('WSH_USA_INV_PVT.update_serial_numbers',l_module_name);
3822
3823 --
3824 -- Debug Statements
3825 --
3826 IF l_debug_on THEN
3827 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
3828 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
3829 END IF;
3830 --
3831 END update_serial_numbers;
3832
3833
3834 PROCEDURE Update_Inventory_Info(
3835 p_Changed_Attributes IN WSH_INTERFACE.ChangedAttributeTabType
3836 , x_return_status OUT NOCOPY VARCHAR2)
3837 IS
3838
3839 -- Bug 2657652 : Changed cursor to fetch selective columns instead of *
3840 -- Columns added for bug 4093619(FP-4145867) to fetch delivery grouping
3841 -- attributes
3842
3843 CURSOR C_Old_Detail (p_Counter NUMBER)
3844 IS
3845 SELECT organization_id,
3846 source_header_number,
3847 ship_from_location_id,
3848 delivery_detail_id,
3849 released_status,
3850 move_order_line_id,
3851 requested_quantity,
3852 requested_quantity_uom,
3853 requested_quantity2,
3854 picked_quantity,
3855 picked_quantity2,
3856 inventory_item_id,
3857 subinventory,
3858 locator_id,
3859 lot_number,
3860 -- HW OPMCONV - No need for sublot_number
3861 -- sublot_number,
3862 preferred_grade,
3863 revision,
3864 serial_number,
3865 transaction_temp_id,
3866 ship_set_id,
3867 top_model_line_id,
3868 source_line_number, -- Bug 3481801
3869 -- deliveryMerge
3870 pickable_flag,
3871 -- J inbound logistics --jckwok
3872 nvl(line_direction, 'O') line_direction,
3873 -- J Consolidation of Back Order Delivery Details Enhancement
3874 source_line_id,
3875 tracking_number, -- bug# 3632485
3876 nvl(ignore_for_planning,'N') ignore_for_planning,
3877 customer_id, -- Start of Bug 4093619(FP-4145867)
3878 ship_to_location_id,
3879 intmed_ship_to_location_id,
3880 fob_code,
3881 freight_terms_code,
3882 ship_method_code,
3883 deliver_to_location_id,
3884 shipping_control,
3885 mode_of_transport,
3886 carrier_id,
3887 service_level, -- End of Bug 4093619(FP-4145867)
3888 requested_quantity_uom2, --Bug# 5436033
3889 client_id, -- LSP PROJECT
3890 source_code
3891 FROM wsh_delivery_details
3892 WHERE delivery_detail_id = p_Changed_Attributes(p_Counter).delivery_detail_id ;
3893
3894 old_delivery_detail_rec C_Old_Detail%ROWTYPE;
3895
3896 -- Consolidation of Back Order Delivery Details Enhancement
3897
3898 -- Added the record to call the WSH_SHIPPING_PARAMS_PVT.Get_Global_Parameters
3899 l_global_param_rec_type WSH_SHIPPING_PARAMS_PVT.Global_Parameters_Rec_Typ;
3900
3901 -- Added tables to call the wsh_delivery_details_actions.Consolidate_Source_Lines
3902 l_Cons_Source_Line_Rec_Tab WSH_DELIVERY_DETAILS_ACTIONS.Cons_Source_Line_Rec_Tab;
3903 l_cons_dd_ids WSH_UTIL_CORE.Id_Tab_Type;
3904
3905 -- To store the shipping global parameter "Consolidate BO lines" value
3906 l_auto_consolidate VARCHAR2(1) := 'N';
3907 -- To check the consolidation happened or Not
3908 l_cons_flag VARCHAR2(1) := 'N';
3909
3910 -- End of Consolidation of Back Order Delivery Details Enhancement
3911
3912 l_changed_attributes WSH_INTERFACE.ChangedAttributeTabType;
3913 l_counter NUMBER;
3914 l_delivery_status VARCHAR2(3);
3915 l_container_instance_id NUMBER;
3916 l_number_of_shipped_details NUMBER;
3917 l_number_of_packed_details NUMBER;
3918 l_exception_return_status VARCHAR2(30);
3919 l_exception_msg_count NUMBER;
3920 l_exception_msg_data VARCHAR2(4000) := NULL;
3921 l_exception_assignment_id NUMBER;
3922 l_exception_error_message VARCHAR2(2000) := NULL;
3923 l_exception_location_id NUMBER;
3924 l_dummy_exception_id NUMBER;
3925 l_dummy_detail_id NUMBER;
3926 l_parent_detail_id NUMBER;
3927 l_container_name VARCHAR2(30);
3928 l_return_status VARCHAR2(30);
3929 l_split_quantity NUMBER;
3930 -- odaboval : Begin of OPM Changes (Pick_Confirm)
3931 l_split_quantity2 NUMBER;
3932 -- odaboval : End of OPM Changes (Pick_Confirm)
3933 l_multiple_update VARCHAR2(1);
3934 l_ship_status VARCHAR2(100);
3935 l_reject_update VARCHAR2(1);
3936 l_cont_name VARCHAR2(30);
3937 l_cont_item_id NUMBER ;
3938 l_cont_instance_id NUMBER ;
3939 l_num_containers NUMBER ;
3940 l_organization_id NUMBER ;
3941 l_delivery_detail_ids WSH_UTIL_CORE.Id_Tab_Type;
3942 l_row_id VARCHAR2(30);
3943 l_request_id NUMBER;
3944 l_msg VARCHAR2(2000) := NULL;
3945 l_item_name VARCHAR2(2000):=NULL; -- Bug 1577237 : Earlier this was 40 characters long.
3946 -- Other packages that call get_item_name store the
3947 -- result in 2000 characters long variable, so made the
3948 -- same change here .
3949 -- bug lgao 1635782
3950 -- HW OPMCONV. Removed OPM variables
3951
3952 l_update_sub VARCHAR2(1);
3953 l_update_loc VARCHAR2(1);
3954 l_update_rev VARCHAR2(1);
3955
3956 l_update_lot VARCHAR2(1);
3957 l_update_preferred_grade VARCHAR2(1);
3958 l_update_serial_number VARCHAR2(1);
3959 l_update_rel_status VARCHAR2(1);
3960 l_update_quantities VARCHAR2(1);
3961 -- Bug 2657652 : Serial Numbers enhancement
3962 l_update_transaction_temp_id VARCHAR2(1);
3963 l_update_shipped_quantity VARCHAR2(1);
3964
3965 l_copy_detail_rec WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Rec_Type;
3966 l_details_to_delete WSH_UTIL_CORE.Id_Tab_Type;
3967 l_delete_count NUMBER := 0;
3968
3969 l_overpick_rec WSH_INTERFACE.ChangedAttributeRecType;
3970 l_source_code WSH_DELIVERY_DETAILS.SOURCE_CODE%TYPE;
3971 l_new_req_quantity NUMBER;
3972 -- HW OPM added qty2
3973 l_new_req_quantity2 NUMBER;
3974 l_delivery_id NUMBER;
3975 l_planned_flag VARCHAR2(1);
3976 l_del_batch_id NUMBER;
3977
3978 l_picked_qty NUMBER;
3979
3980 l_wms_enabled_flag VARCHAR2(1); -- Bug fix: 2340652
3981
3982 l_backorder_cnt NUMBER; -- Counter for Backorder of SS/SMC lines
3983
3984 l_dummy_quantity NUMBER;
3985 -- muom
3986 l_dummy_quantity2 NUMBER;
3987
3988 -- bug 2805603 : added following variables for call to get_inv_pc_attributes and set_inv_pc_attributes
3989 l_InvPCOutRecType WSH_INTEGRATION.InvPCOutRecType;
3990 l_InvPCInRecType WSH_INTEGRATION.InvPCInRecType;
3991 l_transaction_id NUMBER;
3992 l_transaction_temp_id wsh_delivery_Details.transaction_temp_id%type;
3993 l_msg_count NUMBER;
3994 l_msg_data VARCHAR2(2000);
3995
3996 l_user_id NUMBER;
3997 l_login_id NUMBER;
3998
3999 -- Following variables added for Bug 4093619(FP-4145867) to store delivery grouping
4000 -- attributes value for container record.
4001 l_customer_id NUMBER;
4002 l_ship_to_location_id NUMBER;
4003 l_intmed_ship_to_location_id NUMBER;
4004 l_deliver_to_location_id NUMBER;
4005 l_fob_code WSH_DELIVERY_DETAILS.Fob_Code%TYPE;
4006 l_freight_terms_code WSH_DELIVERY_DETAILS.Freight_Terms_Code%TYPE;
4007 l_ship_method_code WSH_DELIVERY_DETAILS.Ship_Method_Code%TYPE;
4008 l_line_direction WSH_DELIVERY_DETAILS.line_direction%TYPE;
4009 l_ignore_for_planning WSH_DELIVERY_DETAILS.ignore_for_planning%TYPE;
4010 l_shipping_control WSH_DELIVERY_DETAILS.shipping_control%TYPE;
4011 l_mode_of_transport WSH_DELIVERY_DETAILS.mode_of_transport%TYPE;
4012 l_service_level WSH_DELIVERY_DETAILS.service_level%TYPE;
4013 l_carrier_id NUMBER;
4014 l_client_id NUMBER; -- LSP PROJECT
4015
4016 -- K LPN CONV. rvishnuv
4017 l_cont_tab wsh_util_core.id_tab_type;
4018 l_lpn_unit_weight NUMBER;
4019 l_lpn_unit_volume NUMBER;
4020 l_lpn_weight_uom_code VARCHAR2(100);
4021 l_lpn_volume_uom_code VARCHAR2(100);
4022 l_create_cnt_caller constant VARCHAR2(100) := 'WSH_PICK_RELEASE';
4023 -- K LPN CONV. rvishnuv
4024 --
4025 l_debug_on BOOLEAN;
4026 --
4027 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PACKAGE_NAME || '.' || 'UPDATE_INVENTORY_INFO';
4028 --
4029 /* 2740833 */
4030 l_rs_ignored VARCHAR2(30);
4031 l_net_weight NUMBER;
4032 l_volume NUMBER;
4033
4034 -- deliveryMerge
4035 Adjust_Planned_Flag_Err EXCEPTION;
4036 l_adjust_planned_del_tab WSH_UTIL_CORE.Id_Tab_Type;
4037 l_delivery_already_included boolean;
4038
4039 -- inbound --jckwok
4040 Delivery_Line_Direction_Err EXCEPTION;
4041 --Added for bug 5234326
4042 l_cnt_tab WSH_UTIL_CORE.Id_Tab_Type;
4043
4044 l_det_tab WSH_UTIL_CORE.Id_Tab_Type;
4045
4046 l_detail_tab WSH_UTIL_CORE.id_tab_type; -- DBI Project
4047 l_dbi_rs VARCHAR2(1); -- DBI Project
4048 l_dd_txn_id NUMBER; -- DBI Project
4049 l_txn_return_status VARCHAR2(1); -- DBI Project
4050
4051 l_wf_rs VARCHAR2(1); --Pick to POD WF Project
4052
4053 -- Bug 3390514 : Treating FND_API.G_MISS_NUM in pending_quantity as Zero
4054 l_pending_quantity NUMBER;
4055 l_backordered_item_id NUMBER;
4056 l_top_model_item_id NUMBER;
4057
4058 -- LPN CONV rv
4059 l_original_caller VARCHAR2(100) := WSH_WMS_LPN_GRP.g_caller;
4060 l_orig_callback_reqd VARCHAR2(100) := WSH_WMS_LPN_GRP.g_callback_required;
4061 -- LPN CONV rv
4062
4063 --Bug 3878429: treat fnd_api.g_miss_num in pending_quantity2 as zero
4064 l_pending_quantity2 NUMBER;
4065 -- /==Workflow Change
4066 Cursor c_get_picked_lines_count (c_delivery_detail_id NUMBER)
4067 IS
4068 SELECT count (wdd.delivery_detail_id), delivery_id
4069 FROM
4070 wsh_delivery_details wdd,
4071 wsh_delivery_assignments_v wda
4072 WHERE
4073 wdd.delivery_detail_id = wda.delivery_detail_id
4074 AND wda.delivery_id = ( SELECT delivery_id
4075 FROM wsh_delivery_assignments_v
4076 WHERE delivery_detail_id = c_delivery_detail_id )
4077 AND wdd.released_status NOT IN ('R', 'X', 'N')
4078 AND wdd.pickable_flag = 'Y'
4079 AND wdd.container_flag = 'N'
4080 GROUP BY delivery_id;
4081 l_count_picked_lines NUMBER;
4082 l_delv_id NUMBER;
4083 -- Workflow Change==/
4084
4085 l_requested_quantity2 NUMBER := NULL; -- bug# 5436033
4086 l_post_process_flag VARCHAR2(1); -- Bug # 7307755
4087 --Bug 7592072
4088 l_under_pick_post_process_flag VARCHAR2(1);
4089 l_cont_gross_weight NUMBER;
4090 l_cont_net_weight NUMBER;
4091 l_cont_volume NUMBER;
4092 l_cont_fill_pc NUMBER;
4093 --Bug 7592072
4094 -- muom
4095 l_fulfillment_base VARCHAR2(1);
4096 l_split_flag VARCHAR2(1);
4097 l_new_requested_quantity NUMBER;
4098 l_quantity NUMBER;
4099 l_unit_of_measure VARCHAR2(10);
4100 BEGIN
4101 --
4102 -- Debug Statements
4103 --
4104 --
4105 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
4106 --
4107 IF l_debug_on IS NULL
4108 THEN
4109 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
4110 END IF;
4111 --
4112 IF l_debug_on THEN
4113 WSH_DEBUG_SV.push(l_module_name);
4114 END IF;
4115 --
4116 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
4117 l_multiple_update := 'N';
4118
4119 -- deliveryMerge
4120 l_adjust_planned_del_tab.delete;
4121
4122 l_user_id := FND_GLOBAL.user_id;
4123 l_login_id := FND_GLOBAL.login_id;
4124
4125 --
4126 -- Debug Statements
4127 --
4128 IF l_debug_on THEN
4129 WSH_DEBUG_SV.logmsg(l_module_name, 'IN UPDATE_INVENTORY_INFO PROCEDURE ...' );
4130 WSH_DEBUG_SV.logmsg(l_module_name, 'Calling program unit WSH_INTEGRATION.Get_Inv_PC_Attributes' );
4131 END IF;
4132 --
4133 -- bug 2805603 : added call to get_inv_pc_attributes and set_inv_pc_attributes to get transaction_id and transaction_temp_id
4134 WSH_INTEGRATION.Get_Inv_PC_Attributes
4135 ( p_out_attributes => l_InvPCOutRecType,
4136 x_return_status => l_return_status,
4137 x_msg_count => l_msg_count,
4138 x_msg_data => l_msg_data) ;
4139 IF l_debug_on THEN
4140 WSH_DEBUG_SV.log(l_module_name,'After call to Get_Inv_PC_Attributes ',l_return_status);
4141 END IF;
4142 IF (l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
4143 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
4144 IF l_debug_on THEN
4145 WSH_DEBUG_SV.logmsg(l_module_name, 'Errored out in Get_Inv_PC_Attributes ' );
4146 END IF;
4147 ELSE
4148 l_transaction_id := l_InvPCOutRecType.transaction_id;
4149 l_transaction_temp_id := l_InvPCOutRecType.transaction_temp_id;
4150 IF l_debug_on THEN
4151 WSH_DEBUG_SV.logmsg(l_module_name, 'l_transaction_id IS ' || L_TRANSACTION_ID );
4152 WSH_DEBUG_SV.logmsg(l_module_name, 'l_transaction_temp_id IS ' || L_TRANSACTION_TEMP_ID );
4153 END IF;
4154 END IF;
4155
4156 -- Assumption : Inventory will be setting the Transaction and Transaction_Temp_Id
4157 -- and Shipping will reset both the values to Null whenever action_flag <> 'M'. This is because when
4158 -- action_flag is M, recursive call to update_inventory_info is done with action_flag as U.
4159 -- So values will be lost during the 2nd call. That is why it is not reset for action_flag as M.
4160 IF p_changed_attributes(p_changed_attributes.FIRST).action_flag <> 'M' THEN
4161 --{
4162 --Bug#5104847:Assigning default value FND_API.G_MISS_NUM to trx_id and trx_temp_id as
4163 --
4164 IF ( l_transaction_id <> FND_API.G_MISS_NUM OR l_transaction_id IS NULL
4165 OR l_transaction_temp_id <> FND_API.G_MISS_NUM OR l_transaction_temp_id IS NULL) THEN
4166 --{
4167 l_InvPCInRecType.transaction_id := FND_API.G_MISS_NUM;
4168 l_InvPCInRecType.transaction_temp_id := FND_API.G_MISS_NUM;
4169 l_InvPCInRecType.source_code := 'INV';
4170 l_InvPCInRecType.api_version_number := 1.0;
4171 --
4172 IF l_debug_on THEN
4173 WSH_DEBUG_SV.logmsg(l_module_name, 'Calling program unit WSH_INTEGRATION.Set_Inv_PC_Attributes' );
4174 END IF;
4175 --
4176 WSH_INTEGRATION.Set_Inv_PC_Attributes
4177 ( p_in_attributes => l_InvPCInRecType,
4178 x_return_status => l_return_status,
4179 x_msg_count => l_msg_count,
4180 x_msg_data => l_msg_data );
4181
4182 IF l_debug_on THEN
4183 WSH_DEBUG_SV.log(l_module_name,'After call to Set_Inv_PC_Attributes ',l_return_status);
4184 END IF;
4185 IF (l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
4186 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
4187 IF l_debug_on THEN
4188 WSH_DEBUG_SV.logmsg(l_module_name, 'Errored out in Set_Inv_PC_Attributes ' );
4189 END IF;
4190 END IF;
4191 END IF;
4192 END IF;
4193
4194 -- Assumption : Whenever Inventory calls with transaction_temp_id, they will pass only 1 record in
4195 -- p_changed_attributes. If not, return error for the transaction
4196 --Bug#5104847:transaction_temp_id default value is FND_API.G_MISS_NUM
4197 IF ( l_transaction_temp_id IS NOT NULL AND l_transaction_temp_id <> FND_API.G_MISS_NUM ) AND p_changed_attributes.COUNT > 1 THEN
4198
4199 IF l_debug_on THEN
4200 WSH_DEBUG_SV.logmsg(l_module_name, 'Number of records passed by inventory ' || p_changed_attributes.COUNT );
4201 WSH_DEBUG_SV.logmsg(l_module_name, 'Reject request as transaction_temp_id is passed for more than 1 record by inventory ');
4202 END IF;
4203 l_ship_status := 'having more than 1 record from inventory to be processed';
4204 FND_MESSAGE.Set_Name('WSH', 'WSH_REJECT_UPDATE_REQUEST');
4205 FND_MESSAGE.Set_Token('SHIP_STATUS', l_ship_status);
4206 FND_MESSAGE.Set_Token('UPDATE_ATTRIBUTE', 'transaction_temp_id');
4207 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
4208 WSH_UTIL_CORE.Add_Message(x_return_status,l_module_name);
4209 IF l_debug_on THEN
4210 WSH_DEBUG_SV.pop(l_module_name,'ERROR:REJECT INV REQUEST');
4211 END IF;
4212 RETURN;
4213 END IF;
4214
4215 FOR l_counter IN p_Changed_Attributes.FIRST .. p_Changed_Attributes.LAST
4216 LOOP
4217 l_update_sub := 'N';
4218 l_update_loc := 'N';
4219 l_update_rev := 'N';
4220 l_update_lot := 'N';
4221 l_update_preferred_grade := 'N';
4222 l_update_serial_number := 'N';
4223 l_update_rel_status := 'N';
4224 l_update_transaction_temp_id := 'N';
4225 l_update_shipped_quantity := 'N';
4226
4227 l_update_quantities := 'N';
4228 l_new_req_quantity := NULL;
4229
4230
4231 --
4232 -- Debug Statements
4233 --
4234 IF l_debug_on THEN
4235 WSH_DEBUG_SV.logmsg(l_module_name, 'L_COUNTER IS ' || L_COUNTER );
4236 WSH_DEBUG_SV.logmsg(l_module_name, 'ACTION FLAG IS ' || P_CHANGED_ATTRIBUTES ( L_COUNTER ) .ACTION_FLAG );
4237 WSH_DEBUG_SV.logmsg(l_module_name, 'DELDET ID IS ' || P_CHANGED_ATTRIBUTES ( L_COUNTER ) .DELIVERY_DETAIL_ID );
4238 WSH_DEBUG_SV.logmsg(l_module_name, 'ORDERED QTY IS ' || P_CHANGED_ATTRIBUTES ( L_COUNTER ) .ORDERED_QUANTITY );
4239 END IF;
4240
4241 -- Bug 3390514 : Treating FND_API.G_MISS_NUM in pending_quantity as Zero
4242 IF p_changed_attributes(l_counter).pending_quantity = FND_API.G_MISS_NUM THEN
4243 --{
4244 l_pending_quantity := 0;
4245 --}
4246 ELSE
4247 --{
4248 l_pending_quantity := p_changed_attributes(l_counter).pending_quantity;
4249 --}
4250 END IF;
4251
4252 --Bug 3878429.
4253 IF p_changed_attributes(l_counter).pending_quantity2 = FND_API.G_MISS_NUM THEN
4254 --{
4255 l_pending_quantity2 := 0;
4256 --}
4257 ELSE
4258 --{
4259 l_pending_quantity2 := p_changed_attributes(l_counter).pending_quantity2;
4260 --}
4261 END IF;
4262
4263 l_delivery_status := 'OK';
4264
4265 BEGIN
4266 SELECT wnd.status_code,
4267 wnd.delivery_id,
4268 wnd.planned_flag,
4269 wnd.batch_id
4270 INTO l_delivery_status,
4271 l_delivery_id,
4272 l_planned_flag,
4273 l_del_batch_id
4274 FROM wsh_new_deliveries wnd,
4275 wsh_delivery_details wdd,
4276 wsh_delivery_assignments_v wda
4277 WHERE wdd.delivery_detail_id = p_changed_attributes(l_Counter).delivery_detail_id
4278 AND wda.delivery_id = wnd.delivery_id
4279 AND wda.delivery_detail_id = wdd.delivery_detail_id ;
4280 EXCEPTION
4281 WHEN NO_DATA_FOUND THEN
4282 l_delivery_status := 'OK';
4283 l_delivery_id := NULL;
4284 l_planned_flag := 'N'; -- Bug 2573434 : changed from NULL to 'N' to check if delivery can be unassigned
4285 l_del_batch_id := NULL;
4286 END;
4287 --
4288 -- Debug Statements
4289 --
4290 IF l_debug_on THEN
4291 WSH_DEBUG_SV.logmsg(l_module_name, 'DELIVERY STATUS IS ' || L_DELIVERY_STATUS );
4292 WSH_DEBUG_SV.logmsg(l_module_name, 'DELIVERY ID IS ' || L_DELIVERY_ID );
4293 WSH_DEBUG_SV.logmsg(l_module_name, 'PLANNED FLAG IS ' || L_PLANNED_FLAG );
4294 END IF;
4295
4296 OPEN C_Old_Detail(l_counter);
4297 FETCH C_Old_Detail
4298 INTO old_delivery_detail_rec;
4299 IF c_old_detail%NOTFOUND THEN
4300 old_delivery_detail_rec.released_status := 'N';
4301 IF l_debug_on THEN
4302 WSH_DEBUG_SV.logmsg(l_module_name,
4303 'c_old_detail not found. setting status N.');
4304 END IF;
4305 END IF;
4306 CLOSE C_Old_Detail;
4307 -- J: raise an exception if line_direction is not 'outbound' or 'internal order' -- jckwok
4308 IF (old_delivery_detail_rec.line_direction NOT IN ('O', 'IO')) THEN
4309 FND_MESSAGE.Set_Name('WSH', 'WSH_DEL_LINE_DIR_INVALID');
4310 FND_MESSAGE.Set_Token('DELIVERY_DETAIL_ID', old_delivery_detail_rec.delivery_detail_id);
4311 WSH_UTIL_CORE.Add_Message(x_return_status,l_module_name);
4312 IF l_debug_on THEN
4313 WSH_DEBUG_SV.logmsg(l_module_name,'ERROR: operation is invalid for delivery line direction');
4314 END IF;
4315 raise Delivery_Line_Direction_Err;
4316 END IF;
4317 -- muom
4318 l_fulfillment_base := WSH_UTIL_CORE.Get_Line_Fulfillment_Base(old_delivery_detail_rec.source_code, old_delivery_detail_rec.source_line_id);
4319
4320 --
4321 -- Debug Statements
4322 --
4323 IF l_debug_on THEN
4324 WSH_DEBUG_SV.log(l_module_name, 'original RELEASED_STATUS', OLD_DELIVERY_DETAIL_REC.RELEASED_STATUS );
4325 WSH_DEBUG_SV.logmsg(l_module_name, 'ORGANIZATION ID IS ' || OLD_DELIVERY_DETAIL_REC.ORGANIZATION_ID );
4326 END IF;
4327
4328 -- bug 4481819: fail pick confirm if released status is 'N'
4329 -- to prevent stuck orders in Interface Trip Stop.
4330 -- message needs to be set for the caller.
4331 --
4332 -- Backordering should still be allowed.
4333 --
4334 IF OLD_DELIVERY_DETAIL_REC.RELEASED_STATUS = 'N'
4335 AND p_changed_attributes(l_Counter).action_flag <> 'B'
4336 THEN
4337
4338 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
4339
4340 FND_MESSAGE.SET_NAME('WSH', 'WSH_PICK_CONFIRM_NOT_READY');
4341
4342 FND_MESSAGE.SET_TOKEN('SOURCE_LINE_NUM',
4343 old_delivery_detail_rec.source_line_number);
4344 FND_MESSAGE.SET_TOKEN('SOURCE_ORDER_NUM',
4345 old_delivery_detail_rec.source_header_number);
4346
4347 WSH_UTIL_CORE.add_message (x_return_status, l_module_name);
4348
4349 IF l_debug_on THEN
4350 WSH_DEBUG_SV.logmsg(l_module_name, 'detail is not ready to release.');
4351 WSH_DEBUG_SV.pop(l_module_name);
4352 END IF;
4353 RETURN;
4354 END IF;
4355
4356
4357 --
4358 -- Bug fix 2340652
4359 -- We need to know if the org is wms enabled.
4360 --
4361 -- Debug Statements
4362 --
4363 IF l_debug_on THEN
4364 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_VALIDATE.CHECK_WMS_ORG',WSH_DEBUG_SV.C_PROC_LEVEL);
4365 END IF;
4366 --
4367 l_wms_enabled_flag := WSH_UTIL_VALIDATE.Check_Wms_Org(old_delivery_detail_rec.organization_id);
4368
4369 --
4370 -- Debug Statements
4371 --
4372 IF l_debug_on THEN
4373 WSH_DEBUG_SV.logmsg(l_module_name, 'WMS ENABLED FLAG IS ' || L_WMS_ENABLED_FLAG );
4374 END IF;
4375 --
4376 --Bug fix 2340652
4377
4378 --
4379 -- Debug Statements
4380 --
4381
4382 -- handle multiple updates on serial/lot number
4383 IF (p_changed_attributes(l_counter).action_flag = 'M') THEN
4384 -- { action_flag = 'M'
4385 --
4386 -- Debug Statements
4387 --
4388 IF l_debug_on THEN
4389 WSH_DEBUG_SV.logmsg(l_module_name, 'CALLED WITH MULTIPLE UPDATES' );
4390 END IF;
4391 --
4392 l_multiple_update := 'Y';
4393 l_changed_attributes(l_counter) := p_changed_attributes(l_counter);
4394
4395 --muom changes
4396 IF ( nvl(l_fulfillment_base, 'P') = 'P') then
4397 -- { fb= P
4398 IF l_debug_on THEN
4399 WSH_DEBUG_SV.logmsg(l_module_name, 'FB = P Case' );
4400 END IF;
4401 IF (p_changed_attributes(l_counter).picked_quantity = FND_API.G_MISS_NUM) THEN
4402 -- { pq = g_miss_num Start
4403 -- { pq = g_miss_num
4404
4405 -- Can l_split_quantity is null ? If yes , then we need to handle that condition here.
4406 l_split_quantity := p_changed_attributes(l_counter).ordered_quantity ;
4407
4408 -- odaboval : Begin of OPM Changes (Pick_Confirm)
4409 if ( p_changed_attributes(l_Counter).ordered_quantity2 = FND_API.G_MISS_NUM ) then
4410 l_split_quantity2 := null ;
4411 else
4412 l_split_quantity2 := p_changed_attributes(l_Counter).ordered_quantity2 ;
4413 end if ;
4414
4415 -- odaboval : End of OPM Changes (Pick_Confirm)
4416
4417 IF (l_split_quantity = old_Delivery_detail_rec.requested_quantity) THEN
4418 --
4419 -- Debug Statements
4420 --
4421 IF l_debug_on THEN
4422 WSH_DEBUG_SV.logmsg(l_module_name, 'CHANGING ACTION FLAG TO U ' );
4423 END IF;
4424 --
4425 l_changed_attributes(l_counter).action_flag := 'U';
4426 ELSE
4427 WSH_DELIVERY_DETAILS_ACTIONS.Split_Delivery_Details(
4428 p_from_detail_id => p_Changed_attributes(l_counter).delivery_detail_id,
4429 p_req_quantity => l_split_quantity,
4430 x_new_detail_id => l_dummy_detail_id,
4431 x_return_status => l_return_status,
4432 p_req_quantity2 => l_split_quantity2,
4433 p_manual_split => p_changed_attributes(l_counter).action_flag);
4434 IF l_debug_on THEN
4435 WSH_DEBUG_SV.log(l_module_name,'Split_Delivery_Details',l_return_status);
4436 END IF;
4437
4438 -- Bug 3724578 : Return back to the caller if any error occures while
4439 -- splitting the delivery detail line
4440 --- Message will be set in Split_Delivery_Details
4441 IF (l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
4442 x_return_status := l_return_status;
4443 return;
4444 END IF;
4445
4446 l_changed_attributes(l_counter).delivery_detail_id := l_dummy_detail_id;
4447 l_changed_attributes(l_counter).action_flag := 'U';
4448 END IF;
4449 /* LG BUG#:2005977 */
4450 -- } pq = g_miss_num
4451 ELSE -- picked_quantity is passed for 'M'
4452 -- { pq > 0
4453
4454 l_changed_attributes(l_counter).action_flag := 'U';
4455
4456 l_dummy_detail_id := p_changed_attributes(l_counter).delivery_detail_id;
4457 l_split_quantity := p_changed_attributes(l_counter).picked_quantity ;
4458
4459 -- begin of OPM
4460 if ( p_changed_attributes(l_Counter).picked_quantity2 = FND_API.G_MISS_NUM ) then
4461 l_split_quantity2 := null ;
4462 else
4463 l_split_quantity2 := p_changed_attributes(l_Counter).picked_quantity2 ;
4464 end if ;
4465 -- end of OPM
4466
4467 -- keep this line's picked_quantity up to date as sum of picked_quantity+pending_quantity,
4468 -- so that we can split the current picked_quantity and the old line will have pending quantity.
4469 old_delivery_detail_rec.picked_quantity := p_changed_attributes(l_counter).picked_quantity + l_pending_quantity; -- Bug#: 3390514
4470
4471 --Fix for bug 3878429
4472 --Use l_pending_quantity2 instead of p_changed_attributes(l_counter).pending_quantity2
4473 --because p_changed_attributes(l_counter).pending_quantity2 could be fnd_api.g_miss_num
4474
4475 old_delivery_detail_rec.picked_quantity2 := l_split_quantity2 + l_pending_quantity2;
4476
4477 /*
4478 old_delivery_detail_rec.picked_quantity2 := l_split_quantity2
4479 + p_changed_attributes(l_counter).pending_quantity2; */
4480
4481 UPDATE WSH_DELIVERY_DETAILS
4482 SET picked_quantity = old_delivery_detail_rec.picked_quantity,
4483 picked_quantity2 = old_delivery_detail_rec.picked_quantity2,
4484 requested_quantity_uom2 = DECODE(l_wms_enabled_flag,
4485 'Y',
4486 DECODE(p_changed_attributes(l_counter).ordered_quantity_uom2,
4487 FND_API.G_MISS_CHAR, requested_quantity_uom2,
4488 p_changed_attributes(l_counter).ordered_quantity_uom2),
4489 requested_quantity_uom2)
4490 WHERE delivery_detail_id = old_delivery_detail_rec.delivery_detail_id;
4491
4492 IF l_split_quantity < old_delivery_detail_rec.picked_quantity THEN
4493
4494 WSH_DELIVERY_DETAILS_ACTIONS.Split_Delivery_Details(
4495 p_from_detail_id => p_Changed_attributes(l_counter).delivery_detail_id,
4496 p_req_quantity => l_split_quantity,
4497 x_new_detail_id => l_dummy_detail_id,
4498 x_return_status => l_return_status,
4499 p_req_quantity2 => l_split_quantity2,
4500 p_manual_split => p_changed_attributes(l_counter).action_flag);
4501 IF l_debug_on THEN
4502 WSH_DEBUG_SV.log(l_module_name,'Split_Delivery_Details l_return_status',l_return_status);
4503 END IF;
4504
4505
4506 -- Bug 3724578 : Return back to the caller if any error occures while
4507 -- splitting the delivery detail line
4508 --- Message will be set in Split_Delivery_Details
4509 IF (l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
4510 x_return_status := l_return_status;
4511 return;
4512 END IF;
4513 END IF;
4514
4515 -- If this delivery line has requested_quantity > 0, it is not pending overpick,
4516 -- and its picked quantity columns should be NULL.
4517 UPDATE wsh_delivery_details
4518 SET picked_quantity = decode(requested_quantity, 0, picked_quantity, NULL),
4519 picked_quantity2 = decode(requested_quantity2, 0, picked_quantity2, NULL)
4520 WHERE delivery_detail_id = old_delivery_detail_rec.delivery_detail_id;
4521
4522 l_changed_attributes(l_counter).delivery_detail_id := l_dummy_detail_id;
4523 -- } pq > 0
4524 END IF; -- (p_changed_attributes(l_counter).picked_quantity = FND_API.G_MISS_NUM) for 'M'
4525 -- } pq = g_miss_num End
4526
4527 /* NC - Added - OPM Changes BUG# 1675561 */
4528 ELSE
4529 -- { fb = 'S'
4530 IF l_debug_on THEN
4531 WSH_DEBUG_SV.logmsg(l_module_name, 'FB = S Case' );
4532 END IF;
4533 IF (p_changed_attributes(l_counter).picked_quantity2 = FND_API.G_MISS_NUM) THEN
4534 -- { if pq2 = g_miss_num start
4535 --
4536 -- { if pq2 = g_miss_num
4537 l_split_quantity := p_changed_attributes(l_counter).ordered_quantity ;
4538
4539 if ( p_changed_attributes(l_Counter).ordered_quantity = FND_API.G_MISS_NUM ) then
4540 l_split_quantity := null ;
4541 else
4542 l_split_quantity := p_changed_attributes(l_Counter).ordered_quantity ;
4543 end if ;
4544
4545 -- rvtest??? no value for l_split+qty2 coming in ?? incorrect Logic here, check later (latent)
4546 IF (l_split_quantity2 = old_Delivery_detail_rec.requested_quantity2) THEN
4547 -- { splt_qty2 = old.rq2
4548 --
4549 -- Debug Statements
4550 --
4551 IF l_debug_on THEN
4552 WSH_DEBUG_SV.logmsg(l_module_name, 'CHANGING ACTION FLAG TO U ' );
4553 END IF;
4554 --
4555 l_changed_attributes(l_counter).action_flag := 'U';
4556 ELSE
4557
4558 WSH_DELIVERY_DETAILS_ACTIONS.Split_Delivery_Details(
4559 p_from_detail_id => p_Changed_attributes(l_counter).delivery_detail_id,
4560 p_req_quantity => l_split_quantity,
4561 x_new_detail_id => l_dummy_detail_id,
4562 x_return_status => l_return_status,
4563 p_req_quantity2 => l_split_quantity2,
4564 p_manual_split => p_changed_attributes(l_counter).action_flag);
4565 IF l_debug_on THEN
4566 WSH_DEBUG_SV.log(l_module_name,'Split_Delivery_Details',l_return_status);
4567 END IF;
4568
4569 -- Bug 3724578 : Return back to the caller if any error occures while
4570 -- splitting the delivery detail line
4571 --- Message will be set in Split_Delivery_Details
4572 IF (l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
4573 x_return_status := l_return_status;
4574 return;
4575 END IF;
4576
4577 l_changed_attributes(l_counter).delivery_detail_id := l_dummy_detail_id;
4578 l_changed_attributes(l_counter).action_flag := 'U';
4579 END IF;
4580 -- } splt_qty2 = old.rq2
4581
4582 /* LG BUG#:2005977 */
4583 -- } pq2 = g_miss_num
4584 ELSE -- picked_quantity is passed for 'M'
4585 -- { pq2 > 0
4586 l_changed_attributes(l_counter).action_flag := 'U';
4587
4588 l_dummy_detail_id := p_changed_attributes(l_counter).delivery_detail_id;
4589 l_split_quantity2 := p_changed_attributes(l_counter).picked_quantity2 ;
4590
4591 if ( p_changed_attributes(l_Counter).picked_quantity = FND_API.G_MISS_NUM ) then
4592 l_split_quantity := null ;
4593 else
4594 l_split_quantity := p_changed_attributes(l_Counter).picked_quantity ;
4595 end if ;
4596 -- end of OPM
4597
4598 -- keep this line's picked_quantity up to date as sum of picked_quantity+pending_quantity,
4599 -- so that we can split the current picked_quantity and the old line will have pending quantity.
4600 old_delivery_detail_rec.picked_quantity2 := p_changed_attributes(l_counter).picked_quantity2
4601 + l_pending_quantity2; -- Bug#: 3390514
4602
4603 --Fix for bug 3878429
4604 --Use l_pending_quantity instead of p_changed_attributes(l_counter).pending_quantity
4605 --because p_changed_attributes(l_counter).pending_quantity could be fnd_api.g_miss_num
4606 old_delivery_detail_rec.picked_quantity := l_split_quantity + l_pending_quantity;
4607
4608 UPDATE WSH_DELIVERY_DETAILS
4609 SET picked_quantity = old_delivery_detail_rec.picked_quantity,
4610 picked_quantity2 = old_delivery_detail_rec.picked_quantity2,
4611 requested_quantity_uom2 = DECODE(l_wms_enabled_flag,
4612 'Y',
4613 DECODE(p_changed_attributes(l_counter).ordered_quantity_uom2,
4614 FND_API.G_MISS_CHAR, requested_quantity_uom2,
4615 p_changed_attributes(l_counter).ordered_quantity_uom2),
4616 requested_quantity_uom2)
4617 WHERE delivery_detail_id = old_delivery_detail_rec.delivery_detail_id;
4618
4619
4620 IF l_split_quantity2 < old_delivery_detail_rec.picked_quantity2 THEN
4621
4622 WSH_DELIVERY_DETAILS_ACTIONS.Split_Delivery_Details(
4623 p_from_detail_id => p_Changed_attributes(l_counter).delivery_detail_id,
4624 p_req_quantity => l_split_quantity,
4625 x_new_detail_id => l_dummy_detail_id,
4626 x_return_status => l_return_status,
4627 p_req_quantity2 => l_split_quantity2,
4628 p_manual_split => p_changed_attributes(l_counter).action_flag);
4629 IF l_debug_on THEN
4630 WSH_DEBUG_SV.log(l_module_name,'Split_Delivery_Details l_return_status',l_return_status);
4631 END IF;
4632
4633 -- Bug 3724578 : Return back to the caller if any error occures while
4634 -- splitting the delivery detail line
4635 --- Message will be set in Split_Delivery_Details
4636 IF (l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
4637 x_return_status := l_return_status;
4638 return;
4639 END IF;
4640 END IF;
4641
4642 -- If this delivery line has requested_quantity > 0, it is not pending overpick,
4643 -- and its picked quantity columns should be NULL.
4644 UPDATE wsh_delivery_details
4645 SET picked_quantity = decode(requested_quantity, 0, picked_quantity, NULL),
4646 picked_quantity2 = decode(requested_quantity2, 0, picked_quantity2, NULL)
4647 WHERE delivery_detail_id = old_delivery_detail_rec.delivery_detail_id;
4648
4649 l_changed_attributes(l_counter).delivery_detail_id := l_dummy_detail_id;
4650
4651 END IF; -- (p_changed_attributes(l_counter).picked_quantity = FND_API.G_MISS_NUM) for 'M'
4652
4653 END IF;
4654
4655 ELSE
4656 IF (p_changed_attributes(l_Counter).action_flag = 'S' ) THEN
4657
4658 --
4659 -- Debug Statements
4660 --
4661 IF l_debug_on THEN
4662 WSH_DEBUG_SV.logmsg(l_module_name, 'ACTION FLAG IS S' );
4663 WSH_DEBUG_SV.log(l_module_name, 'p_changed_attributes(l_counter).picked_quantity', p_changed_attributes(l_counter).picked_quantity);
4664 WSH_DEBUG_SV.log(l_module_name, 'p_changed_attributes(l_counter).picked_quantity2', p_changed_attributes(l_counter).picked_quantity2);
4665 WSH_DEBUG_SV.log(l_module_name, 'l_pending_quantity', l_pending_quantity);
4666 WSH_DEBUG_SV.log(l_module_name, 'l_pending_quantity2', l_pending_quantity2);
4667 END IF;
4668 --
4669
4670 IF p_changed_attributes(l_counter).picked_quantity <> FND_API.G_MISS_NUM THEN
4671
4672 -- begin of OPM
4673 if ( p_changed_attributes(l_Counter).picked_quantity2 = FND_API.G_MISS_NUM ) then
4674 l_split_quantity2 := null ;
4675 else
4676 l_split_quantity2 := p_changed_attributes(l_Counter).picked_quantity2 ;
4677 end if ;
4678 -- end of OPM
4679
4680 -- keep this line's picked_quantity up to date as sum of picked_quantity+pending_quantity,
4681 old_delivery_detail_rec.picked_quantity := p_changed_attributes(l_counter).picked_quantity
4682 + l_pending_quantity; -- Bug#: 3390514
4683
4684 --Fix for bug 3878429
4685 --Use l_pending_quantity2 instead of p_changed_attributes(l_counter).pending_quantity2
4686 --because p_changed_attributes(l_counter).pending_quantity2 could be fnd_api.g_miss_num
4687
4688 old_delivery_detail_rec.picked_quantity2 := l_split_quantity2 + l_pending_quantity2;
4689
4690 /* old_delivery_detail_rec.picked_quantity2 := l_split_quantity2
4691 + p_changed_attributes(l_counter).pending_quantity2; */
4692
4693 IF l_debug_on THEN
4694 wsh_debug_sv.log(l_module_name, 'old_delivery_detail_rec.picked_quantity', old_delivery_detail_rec.picked_quantity);
4695 wsh_debug_sv.log(l_module_name, 'old_delivery_detail_rec.picked_quantity2', old_delivery_detail_rec.picked_quantity2);
4696 END IF;
4697
4698 UPDATE WSH_DELIVERY_DETAILS
4699 SET picked_quantity = old_delivery_detail_rec.picked_quantity,
4700 picked_quantity2 = old_delivery_detail_rec.picked_quantity2
4701 WHERE delivery_detail_id = old_delivery_detail_rec.delivery_detail_id;
4702
4703 l_split_quantity := l_pending_quantity; -- Bug#: 3390514
4704
4705 IF (p_changed_attributes(l_counter).pending_quantity2 = FND_API.G_MISS_NUM) THEN
4706 l_split_quantity2 := old_delivery_detail_rec.requested_quantity2;
4707 ELSE
4708 l_split_quantity2 := p_changed_attributes(l_counter).pending_quantity2;
4709 END IF;
4710
4711 ELSE
4712 -- In order to update released status correctly, I manually use
4713 -- this split quantity to have the newly create delivery detail
4714 -- to be backorder detail
4715 l_split_quantity := old_delivery_detail_rec.requested_quantity - p_Changed_attributes(l_Counter).ordered_quantity;
4716 -- odaboval : Begin of OPM Changes (Pick_Confirm)
4717 if ( p_changed_attributes(l_Counter).ordered_quantity2 = FND_API.G_MISS_NUM ) then
4718 l_split_quantity2 := old_delivery_detail_rec.requested_quantity2 ;
4719 else
4720 l_split_quantity2 := old_delivery_detail_rec.requested_quantity2 - p_changed_attributes(l_Counter).ordered_quantity2 ;
4721 end if ;
4722 END IF;
4723
4724 --
4725 -- Debug Statements
4726 --
4727 IF l_debug_on THEN
4728 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_DELIVERY_DETAILS_ACTIONS.SPLIT_DELIVERY_DETAILS',WSH_DEBUG_SV.C_PROC_LEVEL);
4729 END IF;
4730 --
4731 WSH_DELIVERY_DETAILS_ACTIONS.Split_Delivery_Details(
4732 p_from_detail_id => p_Changed_attributes(l_counter).delivery_detail_id,
4733 p_req_quantity => l_split_quantity,
4734 x_new_detail_id => l_dummy_detail_id,
4735 x_return_status => l_return_status,
4736 p_req_quantity2 => l_split_quantity2,
4737 p_manual_split => p_changed_attributes(l_counter).action_flag);
4738 -- odaboval : End of OPM Changes (Pick_Confirm)
4739 IF l_debug_on THEN
4740 WSH_DEBUG_SV.log(l_module_name,'Split_Delivery_Details l_return_status',l_return_status);
4741 END IF;
4742
4743 -- Bug 3724578 : Return back to the caller if any error occures while
4744 -- splitting the delivery detail line
4745 -- Message will be set in Split_Delivery_Details
4746 IF (l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
4747 x_return_status := l_return_status;
4748 return;
4749 END IF;
4750
4751 /* LG BUG#:2005977 */
4752
4753 IF p_changed_attributes(l_counter).picked_quantity <> FND_API.G_MISS_NUM THEN
4754 -- correct the requested quantities of the split lines.
4755 -- be sure to clear the picked quantities if line has requested_quantity > 0.
4756
4757 UPDATE wsh_delivery_details
4758 SET requested_quantity = LEAST(old_delivery_detail_rec.requested_quantity,
4759 picked_quantity),
4760 requested_quantity2 = LEAST(old_delivery_detail_rec.requested_quantity2,
4761 picked_quantity2)
4762 WHERE delivery_detail_id = old_delivery_detail_rec.delivery_detail_id
4763 RETURNING requested_quantity, requested_quantity2 INTO l_split_quantity, l_split_quantity2;
4764
4765 --
4766 -- DBI Project
4767 -- Update of wsh_delivery_details where requested_quantity
4768 -- are changed, call DBI API after the update.
4769 -- DBI API checks for DBI Installed also
4770 IF l_debug_on THEN
4771 WSH_DEBUG_SV.log(l_module_name,'Calling DBI API.Detail id-',old_delivery_detail_rec.delivery_detail_id);
4772 END IF;
4773 l_detail_tab(1) := old_delivery_detail_rec.delivery_detail_id;
4774 WSH_INTEGRATION.DBI_Update_Detail_Log
4775 (p_delivery_detail_id_tab => l_detail_tab,
4776 p_dml_type => 'UPDATE',
4777 x_return_status => l_dbi_rs);
4778
4779 IF l_debug_on THEN
4780 WSH_DEBUG_SV.log(l_module_name,'Return Status after DBI Call-',l_dbi_rs);
4781 END IF;
4782 -- DBI API can only raise unexpected error, in that case need to
4783 -- pass it to the caller API for roll back of the whole transaction
4784 -- Only need to handle Unexpected error, rest are treated as success
4785 -- Since code is not proceeding, no need to reset x_return_status
4786 IF l_dbi_rs = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
4787 x_return_status := l_dbi_rs;
4788 IF l_debug_on THEN
4789 WSH_DEBUG_SV.pop(l_module_name);
4790 END IF;
4791 RETURN;
4792 END IF;
4793
4794 -- End of Code for DBI Project
4795 --
4796
4797 l_split_quantity := GREATEST(old_delivery_detail_rec.requested_quantity - l_split_quantity, 0);
4798 l_split_quantity2 := GREATEST(old_delivery_detail_rec.requested_quantity2 - l_split_quantity2, 0);
4799 UPDATE wsh_delivery_details SET
4800 requested_quantity = l_split_quantity,
4801 requested_quantity2 = l_split_quantity2,
4802 picked_quantity = decode(l_split_quantity, 0, picked_quantity, NULL),
4803 picked_quantity2 = decode(l_split_quantity2, 0, picked_quantity2, NULL)
4804 WHERE delivery_detail_id = l_dummy_detail_id;
4805 -- bug 4416863
4806 IF l_debug_on THEN
4807 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_WV_UTILS.Detail_Weight_Volume',WSH_DEBUG_SV.C_PROC_LEVEL);
4808 END IF;
4809
4810 WSH_WV_UTILS.Detail_Weight_Volume
4811 (p_delivery_detail_id => l_dummy_detail_id,
4812 p_update_flag => 'Y',
4813 p_post_process_flag => 'Y',
4814 p_calc_wv_if_frozen => 'N',
4815 x_net_weight => l_net_weight,
4816 x_volume => l_volume,
4817 x_return_status => l_return_status);
4818 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
4819 x_return_status := l_return_status;
4820 IF l_debug_on THEN
4821 WSH_DEBUG_SV.logmsg(l_module_name,'Detail_Weight_Volume returned '|| l_return_status);
4822 WSH_DEBUG_SV.pop(l_module_name);
4823 END IF;
4824 return;
4825 END IF;
4826 -- end bug 4416863
4827
4828 ELSE
4829
4830 -- make sure the newly create detail will be released_status of 'S'
4831 UPDATE wsh_delivery_details
4832 SET released_status = 'S'
4833 WHERE delivery_detail_id = l_dummy_detail_id
4834 RETURNING organization_id
4835 INTO l_organization_id;
4836
4837 --DBI api
4838 WSH_DD_TXNS_PVT. create_dd_txn_from_dd (
4839 p_delivery_detail_id => l_dummy_detail_id,
4840 x_dd_txn_id => l_dd_txn_id,
4841 x_return_status =>l_txn_return_status
4842 );
4843
4844 IF (l_txn_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
4845 x_return_status := l_txn_return_status;
4846 return;
4847 END IF;
4848 --DBI Api
4849 --Raise Event : Pick To Pod Workflow
4850 WSH_WF_STD.Raise_Event(
4851 p_entity_type => 'LINE',
4852 p_entity_id => l_dummy_detail_id ,
4853 p_event => 'oracle.apps.wsh.line.gen.releasedtowarehouse' ,
4854 p_organization_id => l_organization_id,
4855 x_return_status => l_wf_rs ) ;
4856 IF l_debug_on THEN
4857 WSH_DEBUG_SV.log(l_module_name,'Current Time is ',SYSDATE);
4858 wsh_debug_sv.log(l_module_name,'Return Status After Calling WSH_WF_STD.Raise_Event',l_wf_rs);
4859 END IF;
4860
4861 OPEN c_get_picked_lines_count( l_dummy_detail_id );
4862 FETCH c_get_picked_lines_count into l_count_picked_lines, l_delv_id ;
4863 IF (c_get_picked_lines_count%FOUND) THEN
4864 IF ( l_count_picked_lines=1) THEN --If it is the first line in a delivery to be released
4865 WSH_WF_STD.Raise_Event(
4866 p_entity_type => 'DELIVERY',
4867 p_entity_id => l_delv_id ,
4868 p_event => 'oracle.apps.wsh.delivery.pik.pickinitiated' ,
4869 p_organization_id => l_organization_id,
4870 x_return_status => l_wf_rs ) ;
4871 IF l_debug_on THEN
4872 WSH_DEBUG_SV.log(l_module_name,'Current Time is ',SYSDATE);
4873 WSH_DEBUG_SV.log(l_module_name,'Return Status After Calling WSH_WF_STD.Raise_Event',l_wf_rs);
4874 END IF;
4875 END IF;
4876 END IF;
4877 CLOSE c_get_picked_lines_count;
4878
4879 --Done Raise Event : Pick To Pod Workflow
4880
4881 END IF;
4882 --
4883 -- DBI Project
4884 -- Update of wsh_delivery_details where requested_quantity
4885 -- are changed, call DBI API after the update.
4886 -- DBI API checks for DBI Installed also
4887 IF l_debug_on THEN
4888 WSH_DEBUG_SV.log(l_module_name,'Calling DBI API.Detail id-',l_dummy_detail_id);
4889 END IF;
4890 l_detail_tab(1) := l_dummy_detail_id;
4891 WSH_INTEGRATION.DBI_Update_Detail_Log
4892 (p_delivery_detail_id_tab => l_detail_tab,
4893 p_dml_type => 'UPDATE',
4894 x_return_status => l_dbi_rs);
4895
4896 IF l_debug_on THEN
4897 WSH_DEBUG_SV.log(l_module_name,'Return Status after DBI Call-',l_dbi_rs);
4898 END IF;
4899 -- DBI API can only raise unexpected error, in that case need to
4900 -- pass it to the caller API for roll back of the whole transaction
4901 -- Only need to handle Unexpected error, rest are treated as success
4902 -- Since code is not proceeding, no need to reset x_return_status
4903 IF l_dbi_rs = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
4904 x_return_status := l_dbi_rs;
4905 IF l_debug_on THEN
4906 WSH_DEBUG_SV.pop(l_module_name);
4907 END IF;
4908 RETURN;
4909 END IF;
4910 -- } -- End of action_flag = M
4911 -- End of Code for DBI Project
4912 --
4913 --bug# 6689448 (replenishment project): begin
4914 -- In dynamic replenishment case, WMS passes the action flag as 'R' and replenishment quantity in cycle_count_quantity attribute.
4915 ELSIF (p_changed_attributes(l_Counter).action_flag = 'R' ) THEN
4916 --{
4917 IF l_debug_on THEN
4918 WSH_DEBUG_SV.logmsg(l_module_name, 'CYCLE_COUNT_QUANTITY = ' || P_CHANGED_ATTRIBUTES ( L_COUNTER ) .CYCLE_COUNT_QUANTITY );
4919 WSH_DEBUG_SV.logmsg(l_module_name, 'L_REQUEST_ID = ' || L_REQUEST_ID );
4920
4921 END IF;
4922
4923 l_split_quantity := p_Changed_attributes(l_Counter).cycle_count_quantity;
4924 l_split_quantity2 := p_Changed_attributes(l_Counter).cycle_count_quantity2;
4925 IF l_split_quantity2 = FND_API.G_MISS_NUM THEN
4926 l_split_quantity2 := NULL;
4927 END IF;
4928
4929 IF (l_split_quantity < old_Delivery_detail_rec.requested_quantity) THEN
4930 --
4931 -- Debug Statements
4932 --
4933 IF l_debug_on THEN
4934 WSH_DEBUG_SV.logmsg(l_module_name, 'SPLIT_DELIVERY_DETAILS BEING CALLED WITH ' || TO_CHAR ( L_SPLIT_QUANTITY ) );
4935 END IF;
4936 --
4937 WSH_DELIVERY_DETAILS_ACTIONS.Split_Delivery_Details(
4938 p_from_detail_id => p_Changed_attributes(l_counter).delivery_detail_id,
4939 p_req_quantity => l_split_quantity,
4940 x_new_detail_id => l_dummy_detail_id,
4941 x_return_status => l_return_status,
4942 p_req_quantity2 => l_split_quantity2,
4943 p_manual_split => 'B');
4944 IF l_debug_on THEN
4945 WSH_DEBUG_SV.log(l_module_name,'Split_Delivery_Details l_return_status',l_return_status);
4946 WSH_DEBUG_SV.log(l_module_name,'Split_Delivery_Details is ',l_dummy_detail_id);
4947 END IF;
4948
4949 IF (l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
4950 x_return_status := l_return_status;
4951 return;
4952 END IF;
4953
4954 ELSE
4955 l_dummy_detail_id := p_Changed_attributes(l_counter).delivery_detail_id ;
4956 END IF ;
4957 -- Added Call backorder API to unassign/unpack delivery detail
4958 --
4959 -- Debug Statements
4960 --
4961 IF l_debug_on THEN
4962 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_USA_INV_PVT. BACKORDERED_DELIVERY_DETAIL' ,WSH_DEBUG_SV.C_PROC_LEVEL);
4963 END IF;
4964 --
4965 backorder_delivery_detail(
4966 p_delivery_detail_id => l_dummy_detail_id ,
4967 p_requested_quantity => NULL,
4968 p_requested_quantity2 => NULL,
4969 p_planned_flag => l_planned_flag,
4970 p_wms_enabled_flag => l_wms_enabled_flag,
4971 p_replenishment_status => 'R',
4972 p_del_batch_id => l_del_batch_id,
4973 x_split_quantity => l_split_quantity,
4974 -- muom
4975 x_split_quantity2 => l_split_quantity2,
4976 x_return_status => l_return_status
4977 );
4978 IF (l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
4979 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
4980 END IF;
4981 GOTO loop_end;
4982
4983 -- if action_flag = 'R'
4984 --bug# 6689448 (replenishment project): end
4985 ELSIF (p_changed_attributes(l_Counter).action_flag = 'B' ) THEN
4986 -- Setting Backorder Flag as TRUE so that request ends with Warning
4987 WSH_PICK_LIST.G_BACKORDERED := TRUE;
4988 --BUG#:1549665 hwahdani log exception if running from conc. request
4989 -- and action is backorder
4990 l_request_id := fnd_global.conc_request_id;
4991 -- 1729516
4992 IF ( l_request_id <> -1 OR
4993 p_changed_attributes(l_Counter).cycle_count_quantity = FND_API.G_MISS_NUM OR
4994 WSH_PICK_LIST.G_BATCH_ID IS NOT NULL ) THEN
4995 --
4996 -- Debug Statements
4997 --
4998 IF l_debug_on THEN
4999 WSH_DEBUG_SV.logmsg(l_module_name, 'CYCLE_COUNT_QUANTITY = ' || P_CHANGED_ATTRIBUTES ( L_COUNTER ) .CYCLE_COUNT_QUANTITY );
5000 WSH_DEBUG_SV.logmsg(l_module_name, 'L_REQUEST_ID = ' || L_REQUEST_ID );
5001 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_ITEM_NAME',WSH_DEBUG_SV.C_PROC_LEVEL);
5002 END IF;
5003
5004 l_item_name := WSH_UTIL_CORE.Get_Item_Name(old_delivery_detail_rec.inventory_item_id,old_delivery_detail_rec.organization_id);
5005 IF (old_delivery_detail_rec.ship_set_id IS NOT NULL) OR
5006 (old_delivery_detail_rec.top_model_line_id IS NOT NULL ) THEN
5007
5008 -- Line belongs to Ship Set / SMC
5009 --
5010 -- Debug Statements
5011 --
5012 IF l_debug_on THEN
5013 WSH_DEBUG_SV.logmsg(l_module_name, 'CHECK FOR BACKORDER OF SHIP SET / SMC LINES' );
5014 END IF;
5015 --
5016 --
5017 -- Debug Statements
5018 --
5019 IF l_debug_on THEN
5020 WSH_DEBUG_SV.logmsg(l_module_name,
5021 'SS ID = '
5022 || OLD_DELIVERY_DETAIL_REC.SHIP_SET_ID
5023 || ' , SMC ID = '
5024 || OLD_DELIVERY_DETAIL_REC.TOP_MODEL_LINE_ID
5025 || ' , G_SHIP_SET_ID = '
5026 || G_SHIP_SET_ID
5027 || ' , G_SHIP_MODEL_ID = '
5028 || G_SHIP_MODEL_ID );
5029 END IF;
5030 --
5031
5032 -- Check if Ship Set is present, if not check for SMC ; Ship set takes precedence
5033 IF old_delivery_detail_rec.ship_set_id IS NOT NULL AND
5034 ( NVL(old_delivery_detail_rec.ship_set_id,0) <> NVL(g_ship_set_id,0) ) THEN
5035
5036 --
5037 -- Debug Statements
5038 --
5039 IF l_debug_on THEN
5040 WSH_DEBUG_SV.logmsg(l_module_name, 'SHIP SET IS DIFFERENT AND ASSIGNING BEFORE LOOP ' );
5041 END IF;
5042 --
5043 g_ss_smc_found := FALSE;
5044 g_move_order_line_id := NULL ;
5045 g_delivery_detail_id := NULL ;
5046 g_ship_set_id := NULL ;
5047 g_ship_model_id := NULL ;
5048 g_backordered_item := NULL ;
5049 g_top_model_item := NULL ;
5050 g_ship_set_name := NULL ;
5051 l_backorder_cnt := WSH_INTEGRATION.G_BackorderRec_Tbl.FIRST;
5052 WHILE l_backorder_cnt IS NOT NULL LOOP
5053 --
5054 -- Debug Statements
5055 --
5056 IF l_debug_on THEN
5057 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INTEGRATION.G_BACKORDERREC_TBL',WSH_DEBUG_SV.C_PROC_LEVEL);
5058 END IF;
5059 --
5060 IF NVL(old_delivery_detail_rec.ship_set_id,0) =
5061 NVL(WSH_INTEGRATION.G_BackorderRec_Tbl(l_backorder_cnt).ship_set_id,0) THEN
5062 g_ss_smc_found := TRUE;
5063 --
5064 IF l_debug_on THEN
5065 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INTEGRATION.G_BACKORDERREC_TBL',WSH_DEBUG_SV.C_PROC_LEVEL);
5066 END IF;
5067 --
5068 g_move_order_line_id := WSH_INTEGRATION.G_BackorderRec_Tbl(l_backorder_cnt).move_order_line_id;
5069 g_delivery_detail_id := WSH_INTEGRATION.G_BackorderRec_Tbl(l_backorder_cnt).delivery_detail_id;
5070 --
5071 IF l_debug_on THEN
5072 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INTEGRATION.G_BACKORDERREC_TBL',WSH_DEBUG_SV.C_PROC_LEVEL);
5073 END IF;
5074 --
5075 g_ship_set_id := WSH_INTEGRATION.G_BackorderRec_Tbl(l_backorder_cnt).ship_set_id;
5076 g_ship_model_id := NULL;
5077 --
5078 IF g_delivery_detail_id IS NOT NULL THEN
5079 SELECT inventory_item_id
5080 INTO l_backordered_item_id
5081 FROM wsh_delivery_details
5082 WHERE delivery_detail_id = g_delivery_detail_id;
5083 ELSIF g_move_order_line_id IS NOT NULL THEN
5084 SELECT inventory_item_id
5085 INTO l_backordered_item_id
5086 FROM wsh_delivery_details
5087 WHERE move_order_line_id = g_move_order_line_id;
5088 END IF;
5089 IF g_ship_set_id IS NOT NULL THEN
5090 SELECT set_name
5091 INTO g_ship_set_name
5092 FROM oe_sets
5093 WHERE set_id = g_ship_set_id
5094 AND set_type = 'SHIP_SET';
5095 END IF;
5096
5097 IF l_debug_on THEN
5098 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_ITEM_NAME',WSH_DEBUG_SV.C_PROC_LEVEL);
5099 END IF;
5100 --
5101 g_backordered_item := WSH_UTIL_CORE.Get_Item_Name(l_backordered_item_id,old_delivery_detail_rec.organization_id);
5102 --
5103 --
5104 IF l_debug_on THEN
5105 WSH_DEBUG_SV.logmsg(l_module_name, 'FOUND NEW G_MOVE_ORDER_LINE_ID = ' || G_MOVE_ORDER_LINE_ID ||
5106 ' G_DELIVERY_DETAIL_ID = ' || G_DELIVERY_DETAIL_ID );
5107 END IF;
5108 --
5109 --
5110 -- Debug Statements
5111 --
5112 IF l_debug_on THEN
5113 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INTEGRATION.G_BACKORDERREC_TBL.DELETE',WSH_DEBUG_SV.C_PROC_LEVEL);
5114 END IF;
5115 --
5116 WSH_INTEGRATION.G_BackorderRec_Tbl.DELETE(l_backorder_cnt);
5117 EXIT;
5118 END IF;
5119 --
5120 -- Debug Statements
5121 --
5122 IF l_debug_on THEN
5123 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INTEGRATION.G_BACKORDERREC_TBL.NEXT',WSH_DEBUG_SV.C_PROC_LEVEL);
5124 END IF;
5125 --
5126 l_backorder_cnt := WSH_INTEGRATION.G_BackorderRec_Tbl.NEXT(l_backorder_cnt);
5127 END LOOP;
5128 ELSIF old_delivery_detail_rec.ship_set_id IS NULL AND
5129 ( NVL(old_delivery_detail_rec.top_model_line_id,0) <> NVL(g_ship_model_id,0) ) THEN
5130 --
5131 -- Debug Statements
5132 --
5133 IF l_debug_on THEN
5134 WSH_DEBUG_SV.logmsg(l_module_name, 'SHIP MODEL IS DIFFERENT AND ASSIGNING BEFORE LOOP ' );
5135 END IF;
5136 --
5137 g_ss_smc_found := FALSE;
5138 g_move_order_line_id := NULL ;
5139 g_delivery_detail_id := NULL ;
5140 g_ship_set_id := NULL ;
5141 g_ship_model_id := NULL ;
5142 g_backordered_item := NULL ;
5143 g_top_model_item := NULL ;
5144 g_ship_set_name := NULL ;
5145 l_backorder_cnt := WSH_INTEGRATION.G_BackorderRec_Tbl.FIRST;
5146 WHILE l_backorder_cnt IS NOT NULL LOOP
5147 --
5148 -- Debug Statements
5149 --
5150 IF l_debug_on THEN
5151 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INTEGRATION.G_BACKORDERREC_TBL',WSH_DEBUG_SV.C_PROC_LEVEL);
5152 END IF;
5153 --
5154 IF NVL(old_delivery_detail_rec.top_model_line_id,0) =
5155 NVL(WSH_INTEGRATION.G_BackorderRec_Tbl(l_backorder_cnt).ship_model_id,0) THEN
5156 -- Consider Ship Model as Ship Set is not present
5157 g_ss_smc_found := TRUE;
5158 --
5159 -- Debug Statements
5160 --
5161 IF l_debug_on THEN
5162 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INTEGRATION.G_BACKORDERREC_TBL',WSH_DEBUG_SV.C_PROC_LEVEL);
5163 END IF;
5164 --
5165 g_move_order_line_id := WSH_INTEGRATION.G_BackorderRec_Tbl(l_backorder_cnt).move_order_line_id;
5166 g_delivery_detail_id := WSH_INTEGRATION.G_BackorderRec_Tbl(l_backorder_cnt).delivery_detail_id;
5167 g_ship_set_id := NULL;
5168
5169 -- Debug Statements
5170 --
5171 IF l_debug_on THEN
5172 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INTEGRATION.G_BACKORDERREC_TBL',WSH_DEBUG_SV.C_PROC_LEVEL);
5173 WSH_DEBUG_SV.logmsg(l_module_name, 'FOUND NEW G_MOVE_ORDER_LINE_ID = ' || G_MOVE_ORDER_LINE_ID ||
5174 ' G_DELIVERY_DETAIL_ID = ' || G_DELIVERY_DETAIL_ID );
5175 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INTEGRATION.G_BACKORDERREC_TBL.DELETE',WSH_DEBUG_SV.C_PROC_LEVEL);
5176 END IF;
5177 --
5178 g_ship_model_id := WSH_INTEGRATION.G_BackorderRec_Tbl(l_backorder_cnt).ship_model_id;
5179
5180
5181 IF g_delivery_detail_id IS NOT NULL THEN
5182 SELECT inventory_item_id
5183 INTO l_backordered_item_id
5184 FROM wsh_delivery_details
5185 WHERE delivery_detail_id = g_delivery_detail_id;
5186 ELSIF g_move_order_line_id IS NOT NULL THEN
5187 SELECT inventory_item_id
5188 INTO l_backordered_item_id
5189 FROM wsh_delivery_details
5190 WHERE move_order_line_id = g_move_order_line_id;
5191 END IF;
5192 IF g_ship_model_id IS NOT NULL THEN
5193 SELECT inventory_item_id
5194 INTO l_top_model_item_id
5195 FROM oe_order_lines_all
5196 WHERE line_id = g_ship_model_id;
5197 END IF;
5198 --
5199 IF l_debug_on THEN
5200 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_UTIL_CORE.GET_ITEM_NAME',WSH_DEBUG_SV.C_PROC_LEVEL);
5201 END IF;
5202 --
5203 g_backordered_item := WSH_UTIL_CORE.Get_Item_Name(l_backordered_item_id,old_delivery_detail_rec.organization_id);
5204 --
5205 g_top_model_item := WSH_UTIL_CORE.Get_Item_Name(l_top_model_item_id,old_delivery_detail_rec.organization_id);
5206 --
5207 WSH_INTEGRATION.G_BackorderRec_Tbl.DELETE(l_backorder_cnt);
5208 EXIT;
5209 END IF;
5210 --
5211 -- Debug Statements
5212 --
5213 IF l_debug_on THEN
5214 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_INTEGRATION.G_BACKORDERREC_TBL.NEXT',WSH_DEBUG_SV.C_PROC_LEVEL);
5215 END IF;
5216 --
5217 l_backorder_cnt := WSH_INTEGRATION.G_BackorderRec_Tbl.NEXT(l_backorder_cnt);
5218 END LOOP;
5219 END IF;
5220
5221 --
5222 -- Debug Statements
5223 --
5224 IF l_debug_on THEN
5225 WSH_DEBUG_SV.logmsg(l_module_name, 'BEFORE LOGGING EXCEPTION , G_MOVE_ORDER_LINE_ID = ' || G_MOVE_ORDER_LINE_ID ||
5226 ' G_DELIVERY_DETAIL_ID = ' || G_DELIVERY_DETAIL_ID );
5227 END IF;
5228 --
5229
5230
5231 IF ( g_ss_smc_found = TRUE ) AND
5232 ( ( old_delivery_detail_rec.move_order_line_id <> NVL(g_move_order_line_id,0) ) OR
5233 ( old_delivery_detail_rec.delivery_detail_id <> NVL(g_delivery_detail_id,0) )) THEN
5234 --
5235 -- Debug Statements
5236 --
5237 IF l_debug_on THEN
5238 WSH_DEBUG_SV.logmsg(l_module_name, 'SHIPSET/SMC LINE GETTING BACKORDERED DUE TO ANOTHER LINE' );
5239 END IF;
5240 --
5241 IF g_ship_set_id IS NOT NULL THEN
5242 FND_MESSAGE.SET_NAME('WSH','WSH_PR_OTHER_SS_FAILED');
5243 FND_MESSAGE.SET_TOKEN('ITEM',l_item_name);
5244 FND_MESSAGE.SET_TOKEN('SHIP_SET_NAME',g_ship_set_name);
5245 FND_MESSAGE.SET_TOKEN('ORDER',old_delivery_detail_rec.source_header_number);
5246 FND_MESSAGE.SET_TOKEN('BACKORDER_ITEM',g_backordered_item);
5247 ELSE
5248 FND_MESSAGE.SET_NAME('WSH','WSH_PR_OTHER_SMC_FAILED');
5249 FND_MESSAGE.SET_TOKEN('ITEM',l_item_name);
5250 FND_MESSAGE.SET_TOKEN('LINE',old_delivery_detail_rec.source_line_number);
5251 FND_MESSAGE.SET_TOKEN('MODEL_ITEM',g_top_model_item);
5252 FND_MESSAGE.SET_TOKEN('ORDER',old_delivery_detail_rec.source_header_number);
5253 FND_MESSAGE.SET_TOKEN('BACKORDER_ITEM',g_backordered_item);
5254 END IF;
5255 l_msg:=FND_MESSAGE.GET;
5256 --
5257 -- Debug Statements
5258 --
5259 IF l_debug_on THEN
5260 WSH_DEBUG_SV.logmsg(l_module_name, L_MSG );
5261 END IF;
5262 --
5263 l_exception_location_id := old_delivery_detail_rec.ship_from_location_id;
5264
5265 Begin
5266 wsh_xc_util.log_exception(
5267 p_api_version => 1.0,
5268 x_return_status => l_exception_return_status,
5269 x_msg_count => l_exception_msg_count,
5270 x_msg_data => l_exception_msg_data,
5271 x_exception_id => l_dummy_exception_id ,
5272 p_logged_at_location_id => l_exception_location_id,
5273 p_exception_location_id => l_exception_location_id,
5274 p_logging_entity => 'SHIPPER',
5275 p_logging_entity_id => FND_GLOBAL.USER_ID,
5276 p_exception_name => 'WSH_PICK_BACKORDER',
5277 p_message => l_msg ,
5278 p_error_message => l_exception_error_message,
5279 p_request_id => l_request_id,
5280 -- 1729516
5281 p_batch_id => WSH_PICK_LIST.G_BATCH_ID
5282 );
5283 IF l_debug_on THEN
5284 WSH_DEBUG_SV.log(l_module_name,'log_exception l_exception_return_status',l_exception_return_status);
5285 END IF;
5286 Exception
5287 when others then
5288 --
5289 -- Debug Statements
5290 --
5291 IF l_debug_on THEN
5292 WSH_DEBUG_SV.logmsg(l_module_name, 'EXCEPTION RAISED BY LOG_EXCEPTION' );
5293 END IF;
5294 --
5295 End;
5296 --
5297 -- Debug Statements
5298 --
5299 IF l_debug_on THEN
5300 WSH_DEBUG_SV.logmsg(l_module_name, L_EXCEPTION_ERROR_MESSAGE );
5301 END IF;
5302 --
5303
5304 ELSE
5305 --
5306 -- Debug Statements
5307 --
5308 IF l_debug_on THEN
5309 WSH_DEBUG_SV.logmsg(l_module_name, 'SHIPSET/SMC LINE GETTING BACKORDERED DUE TO INSUFFICIENT QTY ' );
5310 END IF;
5311 --
5312 FND_MESSAGE.SET_NAME('WSH','WSH_PICK_BACKORDER');
5313 -- muom
5314 IF l_fulfillment_base = 'P' THEN
5315 FND_MESSAGE.SET_TOKEN('QTY',p_Changed_attributes(l_Counter).cycle_count_quantity);
5316 l_quantity := p_changed_attributes(l_Counter).cycle_count_quantity;
5317 l_unit_of_measure := old_delivery_detail_rec.requested_quantity_uom;
5318 ELSE
5319 FND_MESSAGE.SET_TOKEN('QTY',p_Changed_attributes(l_Counter).cycle_count_quantity2);
5320 l_quantity := p_changed_attributes(l_Counter).cycle_count_quantity2;
5321 l_unit_of_measure := old_delivery_detail_rec.requested_quantity_uom2;
5322 END IF;
5323 FND_MESSAGE.SET_TOKEN('ITEM',l_item_name);
5324 FND_MESSAGE.SET_TOKEN('ORDER',old_delivery_detail_rec.source_header_number);
5325 l_msg:=FND_MESSAGE.GET;
5326 --
5327 -- Debug Statements
5328 --
5329 IF l_debug_on THEN
5330 WSH_DEBUG_SV.logmsg(l_module_name, L_MSG );
5331 END IF;
5332 --
5333 l_exception_location_id := old_delivery_detail_rec.ship_from_location_id;
5334
5335 Begin
5336 wsh_xc_util.log_exception(
5337 p_api_version => 1.0,
5338 x_return_status => l_exception_return_status,
5339 x_msg_count => l_exception_msg_count,
5340 x_msg_data => l_exception_msg_data,
5341 x_exception_id => l_dummy_exception_id ,
5342 p_logged_at_location_id => l_exception_location_id,
5343 p_exception_location_id => l_exception_location_id,
5344 p_logging_entity => 'SHIPPER',
5345 p_logging_entity_id => FND_GLOBAL.USER_ID,
5346 p_exception_name => 'WSH_PICK_BACKORDER',
5347 p_message => l_msg ,
5348 p_error_message => l_exception_error_message,
5349 p_inventory_item_id => old_delivery_detail_rec.inventory_item_id,--Bug:1646466
5350 -- muom
5351 p_quantity => l_quantity,--Bug:1646466
5352 p_unit_of_measure => l_unit_of_measure, --Bug:1646466
5353 p_request_id => l_request_id,
5354 -- 1729516
5355 p_batch_id => WSH_PICK_LIST.G_BATCH_ID
5356 );
5357 IF l_debug_on THEN
5358 WSH_DEBUG_SV.log(l_module_name,'log_exception l_exception_return_status',l_exception_return_status);
5359 END IF;
5360 Exception
5361 when others then
5362 --
5363 -- Debug Statements
5364 --
5365 IF l_debug_on THEN
5366 WSH_DEBUG_SV.logmsg(l_module_name, 'EXCEPTION RAISED BY LOG_EXCEPTION' );
5367 END IF;
5368 --
5369 End;
5370 --
5371 -- Debug Statements
5372 --
5373 IF l_debug_on THEN
5374 WSH_DEBUG_SV.logmsg(l_module_name, L_EXCEPTION_ERROR_MESSAGE );
5375 END IF;
5376 --
5377
5378 END IF; -- End of Logging exceptions for Ship Sets / SMCs lines
5379
5380 ELSE
5381 -- Exception logging for Normal Lines
5382 --
5383 -- Debug Statements
5384 --
5385 IF l_debug_on THEN
5386 WSH_DEBUG_SV.logmsg(l_module_name, 'LOGGING EXCEPTIONS FOR NON SHIPSET/SMC LINES ' );
5387 END IF;
5388 --
5389 FND_MESSAGE.SET_NAME('WSH','WSH_PICK_BACKORDER');
5390 -- muom
5391 IF l_fulfillment_base = 'P' THEN
5392 FND_MESSAGE.SET_TOKEN('QTY',p_Changed_attributes(l_Counter).cycle_count_quantity);
5393 l_quantity := p_changed_attributes(l_Counter).cycle_count_quantity;
5394 l_unit_of_measure := old_delivery_detail_rec.requested_quantity_uom;
5395 ELSE
5396 FND_MESSAGE.SET_TOKEN('QTY',p_Changed_attributes(l_Counter).cycle_count_quantity2);
5397 l_quantity := p_changed_attributes(l_Counter).cycle_count_quantity2;
5398 l_unit_of_measure := old_delivery_detail_rec.requested_quantity_uom2;
5399 END IF;
5400 FND_MESSAGE.SET_TOKEN('ITEM',l_item_name);
5401 FND_MESSAGE.SET_TOKEN('ORDER',old_delivery_detail_rec.source_header_number);
5402 l_msg:=FND_MESSAGE.GET;
5403 --
5404 -- Debug Statements
5405 --
5406 IF l_debug_on THEN
5407 WSH_DEBUG_SV.logmsg(l_module_name, L_MSG );
5408 END IF;
5409 --
5410 l_exception_location_id := old_delivery_detail_rec.ship_from_location_id;
5411
5412 Begin
5413
5414 wsh_xc_util.log_exception(
5415 p_api_version => 1.0,
5416 x_return_status => l_exception_return_status,
5417 x_msg_count => l_exception_msg_count,
5418 x_msg_data => l_exception_msg_data,
5419 x_exception_id => l_dummy_exception_id ,
5420 p_logged_at_location_id => l_exception_location_id,
5421 p_exception_location_id => l_exception_location_id,
5422 p_logging_entity => 'SHIPPER',
5423 p_logging_entity_id => FND_GLOBAL.USER_ID,
5424 p_exception_name => 'WSH_PICK_BACKORDER',
5425 p_message => l_msg ,
5426 p_error_message => l_exception_error_message,
5427 p_inventory_item_id => old_delivery_detail_rec.inventory_item_id,--Bug:1646466
5428 -- muom
5429 p_quantity => l_quantity,--Bug:1646466
5430 p_unit_of_measure => l_unit_of_measure, --Bug:1646466
5431 p_request_id => l_request_id,
5432 -- 1729516
5433 p_batch_id => WSH_PICK_LIST.G_BATCH_ID
5434 );
5435 IF l_debug_on THEN
5436 WSH_DEBUG_SV.log(l_module_name,'log_exception l_exception_return_status',l_exception_return_status);
5437 END IF;
5438 Exception
5439 when others then
5440 --
5441 -- Debug Statements
5442 --
5443 IF l_debug_on THEN
5444 WSH_DEBUG_SV.logmsg(l_module_name, 'EXCEPTION RAISED BY LOG_EXCEPTION' );
5445 END IF;
5446 --
5447 End;
5448 --
5449 -- Debug Statements
5450 --
5451 IF l_debug_on THEN
5452 WSH_DEBUG_SV.logmsg(l_module_name, L_EXCEPTION_ERROR_MESSAGE );
5453 END IF;
5454 --
5455
5456 END IF; -- End of check whether line belongs to Ship Set / SMC
5457
5458 ELSE
5459 --
5460 -- Debug Statements
5461 --
5462 IF l_debug_on THEN
5463 WSH_DEBUG_SV.logmsg(l_module_name, 'L_REQUEST_ID = -1 , NOT LOGGING EXCEPTION FOR BACKORDERING' );
5464 END IF;
5465 --
5466 END IF;
5467 -- BUG#:1549665 hwahdani end of changes
5468
5469 l_split_quantity := p_Changed_attributes(l_Counter).cycle_count_quantity;
5470 l_split_quantity2 := p_Changed_attributes(l_Counter).cycle_count_quantity2;
5471 IF l_split_quantity2 = FND_API.G_MISS_NUM THEN
5472 l_split_quantity2 := NULL;
5473 END IF;
5474
5475 -- Start of Consolidation Of BO DD's.
5476
5477 l_cons_flag := 'N';
5478 -- Check the auto consolidation of back order lines only when current delivery detail id is
5479 -- not assigned to any planned delivery
5480
5481 IF ( l_planned_flag = 'N' ) THEN
5482 --{
5483 --
5484 -- Debug Statements
5485 --
5486 IF l_debug_on THEN
5487 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_SHIPPING_PARAMS_PVT. Get_Global_Parameters',WSH_DEBUG_SV.C_PROC_LEVEL);
5488 END IF;
5489 --
5490 WSH_SHIPPING_PARAMS_PVT. Get_Global_Parameters(l_global_param_rec_type,l_return_status);
5491 --
5492 IF l_debug_on THEN
5493 WSH_DEBUG_SV.logmsg(l_module_name, 'After calling Get_Global_Parameters: ' || l_return_status );
5494 END IF;
5495 --
5496 IF (l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
5497 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
5498 END IF;
5499 l_auto_consolidate := l_global_param_rec_type.consolidate_bo_lines;
5500 END IF; --}, l_planned_flag
5501
5502 --muom
5503 IF ((l_fulfillment_base = 'P' and l_split_quantity < old_Delivery_detail_rec.requested_quantity) OR
5504 (l_fulfillment_base = 'S' and l_split_quantity2 < old_Delivery_detail_rec.requested_quantity2)) THEN
5505 --{
5506 IF ( l_auto_consolidate = 'Y') THEN -- consolidate the split Quantity
5507 --{
5508 --
5509 -- Debug Statements
5510 --
5511 IF l_debug_on THEN
5512 WSH_DEBUG_SV.log(l_module_name, 'WSH_DELIVERY_DETAILS_ACTIONS.CONSOLIDATE_SOURCE_LINE being called with Del Det Id: ',p_Changed_attributes(l_counter).delivery_detail_id);
5513 END IF;
5514 --
5515 l_Cons_Source_Line_Rec_Tab(1).delivery_detail_id:= old_Delivery_detail_rec.delivery_detail_id ;
5516 l_Cons_Source_Line_Rec_Tab(1).delivery_id:= null;
5517 l_Cons_Source_Line_Rec_Tab(1).source_line_id:= old_Delivery_detail_rec.source_line_id;
5518 l_Cons_Source_Line_Rec_Tab(1).req_qty:= old_Delivery_detail_rec.requested_quantity ;
5519 l_Cons_Source_Line_Rec_Tab(1).bo_qty:= l_split_quantity;
5520 l_Cons_Source_Line_Rec_Tab(1).req_qty2:= old_Delivery_detail_rec.requested_quantity2 ;
5521 l_Cons_Source_Line_Rec_Tab(1).bo_qty2:= l_split_quantity2;
5522 -- muom
5523 l_Cons_Source_Line_Rec_Tab(1).fulfillment_base := l_fulfillment_base;
5524 -- end of 3121616
5525
5526 WSH_DELIVERY_DETAILS_ACTIONS.Consolidate_Source_Line(
5527 p_Cons_Source_Line_Rec_Tab => l_Cons_Source_Line_Rec_Tab,
5528 x_consolidate_ids => l_cons_dd_ids,
5529 x_return_status => l_return_status);
5530
5531 IF l_debug_on THEN
5532 WSH_DEBUG_SV.log(l_module_name,'After calling CONSOLIDATE_SOURCE_LINE: ',l_return_status);
5533 END IF;
5534 IF (l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
5535 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
5536 END IF;
5537 -- Checking consolidation is done or not
5538
5539 IF ( l_cons_dd_ids(1) <> p_Changed_attributes(l_counter).delivery_detail_id ) THEN
5540 l_cons_flag := 'Y';
5541 IF l_debug_on THEN
5542 WSH_DEBUG_SV.log(l_module_name,'Consolidated partial Qty for the Del Det Id: ',old_Delivery_detail_rec.delivery_detail_id);
5543 END IF;
5544
5545 l_dummy_detail_id := 0;
5546 ELSE
5547 IF l_debug_on THEN
5548 WSH_DEBUG_SV.log(l_module_name,'Consolidation not happened for the the Del Det Id: ',old_Delivery_detail_rec.delivery_detail_id);
5549 END IF;
5550 END IF;
5551 END IF; --}, l_auto_consolidate
5552
5553 -- If no consolidation for the partail quantity then Split the line
5554 IF ( l_cons_flag = 'N' ) THEN
5555 --{
5556 IF l_debug_on THEN
5557 -- muom
5558 WSH_DEBUG_SV.logmsg(l_module_name, 'SPLIT_DELIVERY_DETAILS BEING CALLED WITH ' || TO_CHAR ( L_SPLIT_QUANTITY )||' and '||TO_CHAR ( L_SPLIT_QUANTITY2 ) );
5559 END IF;
5560 --
5561 WSH_DELIVERY_DETAILS_ACTIONS.Split_Delivery_Details(
5562 p_from_detail_id => p_Changed_attributes(l_counter).delivery_detail_id,
5563 p_req_quantity => l_split_quantity,
5564 x_new_detail_id => l_dummy_detail_id,
5565 x_return_status => l_return_status,
5566 p_req_quantity2 => l_split_quantity2,
5567 p_manual_split => p_changed_attributes(l_counter).action_flag);
5568 IF l_debug_on THEN
5569 WSH_DEBUG_SV.log(l_module_name,'Split_Delivery_Details l_return_status',l_return_status);
5570 END IF;
5571
5572 -- Bug 3724578 : Return back to the caller if any error occures while
5573 -- splitting the delivery detail line
5574 -- Message will be set in Split_Delivery_Details
5575 IF (l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
5576 x_return_status := l_return_status;
5577 return;
5578 END IF;
5579
5580 END IF; --}, End of the Split Line
5581
5582 ELSE -- No split, Complete back order case
5583 l_dummy_detail_id := p_Changed_attributes(l_counter).delivery_detail_id ;
5584 END IF ; --}, l_split_quantity < old_Delivery_detail_rec.requested_quantity
5585
5586 -- Now l_dummy_detail_id contain any one value as follow
5587 -- 0 : means partial back order case and consolidation has happened for the partial quantity
5588 -- new dd id : means which created when we call split delivery detail, It needs to be back order
5589 --Current dd id : means complete back order case
5590 -- If it is complete back order case then try to consolidate it
5591 IF ( l_auto_consolidate = 'Y' AND l_dummy_detail_id = p_Changed_attributes(l_counter).delivery_detail_id) THEN
5592 --{
5593 IF l_debug_on THEN
5594 WSH_DEBUG_SV.log(l_module_name, 'WSH_DELIVERY_DETAILS_ACTIONS.CONSOLIDATE_SOURCE_LINE being called with Del Det Id: ',old_Delivery_detail_rec.delivery_detail_id);
5595 END IF;
5596 l_Cons_Source_Line_Rec_Tab(1).delivery_detail_id:= old_Delivery_detail_rec.delivery_detail_id ;
5597 l_Cons_Source_Line_Rec_Tab(1).delivery_id:= null;
5598 l_Cons_Source_Line_Rec_Tab(1).source_line_id:= old_Delivery_detail_rec.source_line_id;
5599 l_Cons_Source_Line_Rec_Tab(1).req_qty:= old_Delivery_detail_rec.requested_quantity ;
5600 l_Cons_Source_Line_Rec_Tab(1).bo_qty:= old_Delivery_detail_rec.requested_quantity;
5601 l_Cons_Source_Line_Rec_Tab(1).req_qty2:= old_Delivery_detail_rec.requested_quantity2 ;
5602 l_Cons_Source_Line_Rec_Tab(1).bo_qty2:= old_Delivery_detail_rec.requested_quantity2;
5603 -- muom
5604 l_Cons_Source_Line_Rec_Tab(1).fulfillment_base := l_fulfillment_base;
5605
5606 WSH_DELIVERY_DETAILS_ACTIONS.Consolidate_Source_Line(
5607 p_Cons_Source_Line_Rec_Tab => l_Cons_Source_Line_Rec_Tab,
5608 x_consolidate_ids => l_cons_dd_ids,
5609 x_return_status => l_return_status);
5610
5611 IF l_debug_on THEN
5612 WSH_DEBUG_SV.log(l_module_name,'After calling CONSOLIDATE_SOURCE_LINE: ',l_return_status);
5613 END IF;
5614
5615 IF (l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
5616 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
5617 END IF;
5618
5619 IF ( l_cons_dd_ids(1) <> p_Changed_attributes(l_counter).delivery_detail_id ) THEN
5620 l_cons_flag := 'Y';
5621 IF l_debug_on THEN
5622 WSH_DEBUG_SV.log(l_module_name,'Consolidated the Del Det Id: ',old_Delivery_detail_rec.delivery_detail_id);
5623 END IF;
5624 ELSE
5625 IF l_debug_on THEN
5626 WSH_DEBUG_SV.log(l_module_name,'Consolidation not happened for the the Del Det Id: ',old_Delivery_detail_rec.delivery_detail_id);
5627 END IF;
5628 END IF;
5629
5630 END IF; --}, End of consolidation for the complete back order case
5631
5632 -- Back Order the Delivery Detail which is created after split(Partial back order case)
5633 -- OR current delivery in the case of complete back order case (if consolidation done it should not back order the line)
5634
5635 IF ( l_cons_flag = 'N' ) THEN
5636
5637 /* Can this part be replaced with a call to wsh_ship_confirm_Actions2.backorder ??? */
5638 /* No because that API will immediately release the process lines to warehouse. */
5639
5640 -- Mark line as deleted if requested_quantity is 0 (when line was formerly pending overpick).
5641
5642 -- Bug 2573434 : Added Call backorder API to unassign/unpack delivery detail
5643 --
5644 -- Debug Statements
5645 --
5646
5647 IF l_debug_on THEN
5648 WSH_DEBUG_SV.log(l_module_name,'Calling program unit WSH_USA_INV_PVT. BACKORDERED_DELIVERY_DETAIL' ,WSH_DEBUG_SV.C_PROC_LEVEL);
5649 END IF;
5650 --
5651 --
5652 backorder_delivery_detail(
5653 p_delivery_detail_id => l_dummy_detail_id ,
5654 p_requested_quantity => NULL,
5655 p_requested_quantity2 => NULL,
5656 p_planned_flag => l_planned_flag,
5657 p_wms_enabled_flag => l_wms_enabled_flag,
5658 p_del_batch_id => l_del_batch_id,
5659 x_split_quantity => l_split_quantity,
5660 -- muom
5661 x_split_quantity2 => l_split_quantity2,
5662 x_return_status => l_return_status
5663 );
5664 IF (l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
5665 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
5666 END IF;
5667
5668
5669 -- muom
5670 IF (l_fulfillment_base = 'P' and l_split_quantity = 0) OR (l_fulfillment_base = 'S' and l_split_quantity2 = 0) THEN
5671 -- delete the overpick line, not backorder it.
5672 l_delete_count := l_delete_count + 1;
5673 l_details_to_delete(l_delete_count) := l_dummy_detail_id;
5674 END IF;
5675 END IF; -- End of complete Back Order case.
5676 --- END Of Consolidation of back order delivery details
5677 -- Bug 1858936
5678 GOTO loop_end;
5679
5680 END IF; -- if action_flag = 'B'
5681
5682 -- If even on line is shipped, reject user's Update request
5683 IF (l_delivery_status = 'CO') THEN
5684 l_ship_status := 'confirmed' ;
5685 l_reject_update := 'Y' ;
5686 ELSIF (l_delivery_status = 'CL') THEN
5687 l_ship_status := 'closed' ;
5688 l_reject_update := 'Y' ;
5689 ELSIF (l_delivery_status = 'IT') THEN
5690 l_ship_status := 'in-transit' ;
5691 l_reject_update := 'Y' ;
5692 END IF ;
5693
5694 BEGIN
5695 SELECT parent_delivery_detail_id
5696 INTO l_parent_detail_id
5697 FROM wsh_delivery_assignments_v
5698 WHERE delivery_detail_id = p_changed_attributes(l_Counter).delivery_detail_id
5699 AND parent_delivery_detail_id IS NOT NULL;
5700
5701 SELECT container_name
5702 INTO l_container_name
5703 FROM wsh_delivery_details
5704 WHERE delivery_detail_id = l_parent_detail_id;
5705 EXCEPTION
5706 WHEN no_data_found THEN
5707 l_parent_detail_id := NULL;
5708 l_container_name := NULL;
5709 END;
5710 --
5711 -- LSP PROJECT : debug stmt
5712 IF l_debug_on THEN
5713 WSH_DEBUG_SV.logmsg(l_module_name, 'TRANSFER LPN ID ' || p_changed_attributes(l_Counter).transfer_lpn_id);
5714 END IF;
5715 -- LSP PROJECT : end
5716 --
5717
5718 IF (p_changed_attributes(l_Counter).transfer_lpn_id <> FND_API.G_MISS_NUM ) THEN
5719
5720 --
5721 -- Debug Statements
5722 --
5723 IF l_debug_on THEN
5724 WSH_DEBUG_SV.logmsg(l_module_name, 'UPDATE TRANSFER LPN ID' );
5725 END IF;
5726 --
5727
5728 IF ( l_reject_update = 'Y' ) THEN
5729 --
5730 -- Debug Statements
5731 --
5732 IF l_debug_on THEN
5733 WSH_DEBUG_SV.logmsg(l_module_name, 'UPDATE REJECTED' );
5734 END IF;
5735 --
5736 FND_MESSAGE.Set_Name('WSH', 'WSH_REJECT_UPDATE_REQUEST');
5737 FND_MESSAGE.Set_Token('SHIP_STATUS', l_ship_status);
5738 FND_MESSAGE.Set_Token('UPDATE_ATTRIBUTE', 'transfer lpn id');
5739 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
5740 WSH_UTIL_CORE.add_message (x_return_status,l_module_name);
5741 ELSE
5742 IF (l_parent_detail_id IS NOT NULL) THEN
5743
5744 l_msg := NULL;
5745 FND_MESSAGE.SET_NAME('WSH','WSH_INVALID_PACKING');
5746 l_msg := FND_MESSAGE.GET;
5747 l_exception_location_id := old_delivery_detail_rec.ship_from_location_id;
5748
5749 --
5750 wsh_xc_util.log_exception(
5751 p_api_version => 1.0,
5752 x_return_status => l_exception_return_status,
5753 x_msg_count => l_exception_msg_count,
5754 x_msg_data => l_exception_msg_data,
5755 x_exception_id => l_dummy_exception_id ,
5756 p_logged_at_location_id => l_exception_location_id,
5757 p_exception_location_id => l_exception_location_id,
5758 p_logging_entity => 'SHIPPER',
5759 p_logging_entity_id => FND_GLOBAL.USER_ID,
5760 p_exception_name => 'WSH_INVALID_PACKING',
5761 p_message => l_msg,
5762 p_delivery_detail_id => old_delivery_detail_rec.delivery_detail_id,
5763 p_subinventory => p_changed_attributes(l_Counter).transfer_lpn_id,
5764 p_container_name => l_container_name,
5765 p_inventory_item_id => old_delivery_detail_rec.inventory_item_id,
5766 p_error_message => l_exception_error_message
5767 );
5768 IF l_debug_on THEN
5769 WSH_DEBUG_SV.log(l_module_name,'log_exception l_exception_return_status',l_exception_return_status);
5770 END IF;
5771 IF (l_exception_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
5772 --
5773 -- Debug Statements
5774 --
5775 IF l_debug_on THEN
5776 WSH_DEBUG_SV.logmsg(l_module_name, 'WSH_XC_UTIL.LOG_EXCEPTION PROCEDURE FAILED TO LOG EXCEPTION' );
5777 WSH_DEBUG_SV.logmsg(l_module_name, L_EXCEPTION_ERROR_MESSAGE );
5778 END IF;
5779 END IF;
5780
5781
5782 ELSE
5783 -- First get the details of the license_plate_number
5784 -- that is to be updated.
5785 --
5786 -- Debug Statements
5787 --
5788 IF l_debug_on THEN
5789 WSH_DEBUG_SV.logmsg(l_module_name, 'FETCHING LPN DETAILS' );
5790 END IF;
5791 --
5792
5793 -- K LPN CONV. rvishnuv
5794 /*
5795 SELECT license_plate_number ,
5796 inventory_item_id ,
5797 organization_id
5798 INTO l_cont_name ,
5799 l_cont_item_id ,
5800 l_organization_id
5801 FROM wms_license_plate_numbers
5802 WHERE lpn_id = p_Changed_Attributes(l_Counter).transfer_lpn_id ;
5803 */
5804 -- K LPN CONV. rvishnuv
5805
5806 -- Before Updating transfer_lpn_id , check if this lpn_id already
5807 -- exists
5808
5809 SELECT count(*)
5810 INTO l_num_containers
5811 FROM wsh_delivery_Details
5812 WHERE lpn_id = p_Changed_Attributes(l_Counter).transfer_lpn_id
5813 AND container_flag = 'Y'
5814 AND delivery_detail_id <> p_changed_attributes(l_Counter).delivery_detail_id
5815 AND nvl(line_direction , 'O') IN ('O', 'IO') -- J-IB-JCKWOK
5816 --LPN reuse project
5817 AND released_status = 'X'
5818 AND rownum = 1 ;
5819
5820 --
5821 -- Debug Statements
5822 --
5823 IF l_debug_on THEN
5824 WSH_DEBUG_SV.logmsg(l_module_name, TO_CHAR ( L_NUM_CONTAINERS ) || ' CONTAINER DELIVERY DETAILS FETCHED' );
5825 END IF;
5826 --
5827
5828 IF ( l_num_containers = 0 ) then--{
5829 --
5830 -- Debug Statements
5831 --
5832 IF l_debug_on THEN
5833 WSH_DEBUG_SV.logmsg(l_module_name, 'CREATING CONTAINER WITH LPN ' );
5834 END IF;
5835 --
5836 -- Create container as it does not exist.
5837 -- K LPN CONV. rvishnuv
5838 WSH_CONTAINER_ACTIONS.Create_Cont_Instance_Multi(
5839 x_cont_name => l_cont_name,
5840 p_cont_item_id => NULL,
5841 x_cont_instance_id => l_cont_instance_id,
5842 p_par_detail_id => NULL,
5843 p_organization_id => NULL,
5844 p_container_type_code => NULL,
5845 p_num_of_containers => 1,
5846 x_row_id => l_row_id,
5847 x_return_status => l_return_status,
5848 x_cont_tab => l_cont_tab,
5849 x_unit_weight => l_lpn_unit_weight,
5850 x_unit_volume => l_lpn_unit_volume,
5851 x_weight_uom_code => l_lpn_weight_uom_code,
5852 x_volume_uom_code => l_lpn_volume_uom_code,
5853 p_lpn_id => p_Changed_Attributes(l_Counter).transfer_lpn_id,
5854 p_ignore_for_planning => old_delivery_detail_rec.ignore_for_planning,
5855 p_caller => l_create_cnt_caller);
5856
5857 IF (l_cont_tab.count = 0) THEN
5858 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
5859 --
5860 -- Debug Statements
5861 --
5862 IF l_debug_on THEN
5863 WSH_DEBUG_SV.logmsg(l_module_name, 'NO CONTAINERS WERE CREATED THROUGH CREATE_CONT_INSTANCE_MULTI' );
5864 WSH_DEBUG_SV.pop(l_module_name);
5865 END IF;
5866 --
5867 RETURN;
5868 --
5869 END IF;
5870
5871 l_cont_instance_id := l_cont_tab(1);
5872
5873 IF l_debug_on THEN
5874 WSH_DEBUG_SV.log(l_module_name,'Create_Cont_Instance_Multi l_return_status',l_return_status);
5875 END IF;
5876
5877 IF (l_return_status NOT IN (WSH_UTIL_CORE.G_RET_STS_SUCCESS,
5878 WSH_UTIL_CORE.G_RET_STS_WARNING)) THEN
5879 x_return_status := l_return_status;
5880 IF l_debug_on THEN
5881 WSH_DEBUG_SV.pop(l_module_name);
5882 END IF;
5883 RETURN; -- bug 3703648: should return immediately to avoid spurious messages created by subsequent calls
5884 END IF ;
5885 -- K LPN CONV. rvishnuv
5886 --
5887
5888 ELSE
5889 --
5890 -- Debug Statements
5891 --
5892 IF l_debug_on THEN
5893 WSH_DEBUG_SV.logmsg(l_module_name, 'FETCHING DELIVERY DETAIL OF CONTAINER WITH LPN' );
5894 END IF;
5895 --
5896 -- Bug 4093619(FP-4145867): Modified following query to fetch delivery grouping
5897 -- attributes of container record
5898 SELECT delivery_Detail_id, customer_id ,
5899 ship_to_location_id, intmed_ship_to_location_id,
5900 deliver_to_location_id, fob_code,
5901 freight_terms_code, ship_method_code,
5902 nvl(line_direction,'O'),
5903 nvl(ignore_for_planning, 'N'),
5904 shipping_control,
5905 carrier_id,
5906 service_level,
5907 mode_of_transport,
5908 client_id -- LSP PROJECT
5909 INTO l_cont_instance_id, l_customer_id,
5910 l_ship_to_location_id, l_intmed_ship_to_location_id,
5911 l_deliver_to_location_id, l_fob_code,
5912 l_freight_terms_code, l_ship_method_code,
5913 l_line_direction, l_ignore_for_planning,
5914 l_shipping_control, l_carrier_id,
5915 l_service_level, l_mode_of_transport,l_client_id -- LSP PROJECT
5916 FROM wsh_Delivery_Details
5917 WHERE lpn_id = p_changed_attributes(l_Counter).transfer_lpn_id
5918 AND container_flag = 'Y'
5919 --LPN reuse project
5920 AND released_status = 'X'
5921 AND nvl(line_direction , 'O') IN ('O', 'IO'); -- J-IB-JCKWOK
5922
5923 IF l_debug_on THEN
5924 WSH_DEBUG_SV.log(l_module_name, 'l_cont_instance_id', l_cont_instance_id);
5925 WSH_DEBUG_SV.log(l_module_name, 'l_customer_id', l_customer_id);
5926 WSH_DEBUG_SV.log(l_module_name, 'l_ship_to_location_id', l_ship_to_location_id);
5927 WSH_DEBUG_SV.log(l_module_name, 'l_intmed_ship_to_location_id', l_intmed_ship_to_location_id);
5928 WSH_DEBUG_SV.log(l_module_name, 'l_deliver_to_location_id', l_deliver_to_location_id);
5929 WSH_DEBUG_SV.log(l_module_name, 'l_fob_code', l_fob_code);
5930 WSH_DEBUG_SV.log(l_module_name, 'l_freight_terms_code', l_freight_terms_code);
5931 WSH_DEBUG_SV.log(l_module_name, 'l_ship_method_code', l_ship_method_code);
5932 WSH_DEBUG_SV.log(l_module_name, 'l_line_direction', l_line_direction);
5933 WSH_DEBUG_SV.log(l_module_name, 'l_ignore_for_planning', l_ignore_for_planning);
5934 WSH_DEBUG_SV.log(l_module_name, 'l_shipping_control', l_shipping_control);
5935 WSH_DEBUG_SV.log(l_module_name, 'l_carrier_id', l_carrier_id);
5936 WSH_DEBUG_SV.log(l_module_name, 'l_service_level', l_service_level);
5937 WSH_DEBUG_SV.log(l_module_name, 'l_mode_of_transport', l_mode_of_transport);
5938 WSH_DEBUG_SV.log(l_module_name, 'l_client_id', l_client_id); -- LSP PROJECT
5939 END IF;
5940 -- End of Bug 4093619(FP-4145867)
5941
5942 END IF ;--}
5943
5944 --
5945 -- LPN CONV rv
5946 WSH_WMS_LPN_GRP.g_caller := 'WMS';
5947 WSH_WMS_LPN_GRP.g_callback_required := 'N';
5948 -- LPN CONV rv
5949 --
5950 WSH_DELIVERY_DETAILS_ACTIONS.Assign_Detail_To_Cont (
5951 p_changed_attributes(l_Counter).delivery_detail_id,
5952 l_cont_instance_id,
5953 l_return_status);
5954 IF l_debug_on THEN
5955 WSH_DEBUG_SV.log(l_module_name,'Assign_Detail_To_Cont l_return_status',l_return_status);
5956
5957 END IF;
5958 --
5959 -- LPN CONV rv
5960
5961 IF (nvl(l_num_containers,0) > 0 ) THEN
5962 --{
5963
5964 IF l_debug_on THEN
5965 WSH_DEBUG_SV.logmsg(l_module_name,'Updating the master serial number of the container onto the line');
5966 END IF;
5967
5968 UPDATE WSH_DELIVERY_DETAILS
5969 SET master_serial_number = (select master_serial_number
5970 from wsh_delivery_details
5971 where delivery_detail_id = l_cont_instance_id
5972 and container_flag = 'Y')
5973 WHERE delivery_detail_id = p_changed_attributes(l_Counter).delivery_detail_id;
5974
5975 --}
5976 END IF;
5977
5978 WSH_WMS_LPN_GRP.g_caller := l_original_caller;
5979 WSH_WMS_LPN_GRP.g_callback_required := l_orig_callback_reqd;
5980 -- LPN CONV rv
5981 --
5982 IF (l_return_status NOT IN (WSH_UTIL_CORE.G_RET_STS_SUCCESS,
5983 WSH_UTIL_CORE.G_RET_STS_WARNING)) THEN
5984 x_return_status := l_return_status;
5985 RETURN;
5986 END IF ;
5987
5988 IF l_debug_on THEN
5989 WSH_DEBUG_SV.logmsg(l_module_name, 'calling Calculate TP Dates for entity LPN' );
5990 END IF;
5991 --Modified Entity_Type and Entity_ids for bug 5234326
5992 l_cont_tab(1) := l_cont_instance_id;
5993 WSH_TP_RELEASE.calculate_cont_del_tpdates(
5994 p_entity => 'LPN',
5995 p_entity_ids => l_cnt_tab,
5996 x_return_status => l_return_status);
5997
5998 IF l_debug_on THEN
5999 WSH_DEBUG_SV.log(l_module_name,'calculate_cont_del_tpdates l_return_status',l_return_status);
6000 END IF;
6001
6002 IF (l_return_status NOT IN (WSH_UTIL_CORE.G_RET_STS_SUCCESS,
6003 WSH_UTIL_CORE.G_RET_STS_WARNING)) THEN
6004 x_return_status := l_return_status;
6005 RETURN;
6006 END IF ;
6007
6008 -- Bug 4093619(FP-4145867) : Added the condition below so that container
6009 -- hierarchy's delivery grouping attribute is not updated if it is same.
6010 IF ( nvl(old_delivery_detail_rec.customer_id, -1) <> nvl(l_customer_id, '-1')
6011 OR nvl(old_delivery_detail_rec.ship_to_location_id, -1) <> nvl(l_ship_to_location_id, '-1')
6012 OR nvl(old_delivery_detail_rec.intmed_ship_to_location_id, -1) <> nvl(l_intmed_ship_to_location_id, '-1')
6013 OR nvl(old_delivery_detail_rec.deliver_to_location_id, -1) <> nvl(l_deliver_to_location_id, '-1')
6014 OR nvl(old_delivery_detail_rec.fob_code, '-1') <> nvl(l_fob_code, '-1')
6015 OR nvl(old_delivery_detail_rec.freight_terms_code, '-1') <> nvl(l_freight_terms_code, '-1')
6016 OR nvl(old_delivery_detail_rec.ship_method_code, '-1') <> nvl(l_ship_method_code, '-1')
6017 OR nvl(old_delivery_detail_rec.line_direction, 'O') <> nvl(l_line_direction, 'O')
6018 OR nvl(old_delivery_detail_rec.ignore_for_planning, 'N') <> nvl(l_ignore_for_planning, 'N')
6019 OR nvl(old_delivery_detail_rec.shipping_control, 'N') <> nvl(l_shipping_control, 'N')
6020 OR nvl(old_delivery_detail_rec.carrier_id, -1) <> nvl(l_carrier_id, -1)
6021 OR nvl(old_delivery_detail_rec.service_level, '-1') <> nvl(l_service_level, '-1')
6022 OR nvl(old_delivery_detail_rec.mode_of_transport, '-1') <> nvl(l_mode_of_transport, '-1')
6023 OR nvl(old_delivery_detail_rec.client_id, '-1') <> nvl(l_client_id, '-1')) -- LSP PROJECT)
6024 THEN --{
6025
6026 -- Bug 2706103 - Reused container should be updated with grouping attributes
6027 -- code fix per WMS issue where grouping attributes were not updated for a reused container.
6028 -- IF (l_num_containers = 0) THEN
6029 --
6030 IF l_debug_on THEN
6031 WSH_DEBUG_SV.logmsg(l_module_name, 'Calling Update_Cont_Hierarchy as Grouping attributes do not match');
6032 END IF;
6033 WSH_CONTAINER_ACTIONS.Update_Cont_Hierarchy (
6034 p_changed_attributes(l_Counter).delivery_detail_id,
6035 NULL,
6036 l_cont_instance_id,
6037 l_return_status);
6038 IF l_debug_on THEN
6039 WSH_DEBUG_SV.log(l_module_name,'Update_Cont_Hierarchy l_return_status',l_return_status);
6040 END IF;
6041
6042 IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
6043 FND_MESSAGE.SET_NAME('WSH','WSH_CONT_UPD_ATTR_ERROR');
6044 FND_MESSAGE.SET_TOKEN('CONT_NAME',l_cont_name);
6045 WSH_UTIL_CORE.Add_Message(l_return_status,l_module_name);
6046 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
6047 END IF;
6048
6049 END IF;--}
6050
6051 -- END IF;
6052 -- end bug 1663149: update shipping attributes in the new container record
6053 END IF; -- End of if detail is packed
6054 END IF; -- End of if reject_update
6055 END IF; -- End of if transfer_lpn_id
6056
6057 -- HW OPMCONV. Removed OPM specific logic
6058 IF (p_changed_attributes(l_counter).subinventory <> FND_API.G_MISS_CHAR AND
6059 (NVL(old_delivery_detail_rec.subinventory,'-99') <> NVL(p_changed_attributes(l_Counter).subinventory,'-99'))) THEN
6060 --
6061 -- Debug Statements
6062 --
6063 IF l_debug_on THEN
6064 WSH_DEBUG_SV.logmsg(l_module_name, 'UPDATE INVENTORY' );
6065 END IF;
6066 --
6067 IF ( l_reject_update = 'Y' ) THEN
6068 FND_MESSAGE.Set_Name('WSH', 'WSH_REJECT_UPDATE_REQUEST');
6069 FND_MESSAGE.Set_Token('SHIP_STATUS', l_ship_status);
6070 FND_MESSAGE.Set_Token('UPDATE_ATTRIBUTE', 'subinventory');
6071 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6072 WSH_UTIL_CORE.add_message (x_return_status,l_module_name);
6073 ELSE
6074 -- bug 2302693: we do not log an exception if the line is packed
6075 -- and its subinventory was not null before pick confirm.
6076 -- The reason is that the item is being moved from a source subinventory
6077 -- to a stage subinventory.
6078 -- To see the original code, please look at revision 115.17.
6079 l_update_sub := 'Y';
6080 END IF; -- End of if shipped_details >= 1
6081 END IF; -- End of if subinventory
6082
6083 -- HW OPMCONV. Removed OPM specific logic
6084 IF (p_changed_attributes(l_counter).locator_id <> FND_API.G_MISS_NUM AND
6085 (NVL(old_delivery_detail_rec.locator_id,-99) <> NVL(p_changed_attributes(l_Counter).locator_id,-99))) THEN
6086 --
6087 -- Debug Statements
6088 --
6089 IF l_debug_on THEN
6090 WSH_DEBUG_SV.logmsg(l_module_name, 'UPDATE LOCATOR' );
6091 END IF;
6092 --
6093 IF (l_reject_update = 'Y') THEN
6094 -- At least one line is shipped, reject user's request
6095 l_ship_status := 'confirmed, in-transit or closed';
6096 FND_MESSAGE.Set_Name('WSH', 'WSH_REJECT_UPDATE_REQUEST');
6097 FND_MESSAGE.Set_Token('SHIP_STATUS', l_ship_status);
6098 FND_MESSAGE.Set_Token('UPDATE_ATTRIBUTE', 'locator_id');
6099 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6100 WSH_UTIL_CORE.add_message (x_return_status,l_module_name);
6101 ELSE
6102 -- bug 2302693: we do not log an exception if the line is packed
6103 -- and its inventory control was not null before pick confirm.
6104 -- The reason is that before pick confirm, we assume packing is planned.
6105 -- To see the original code, please look at revision 115.17.
6106 l_update_loc := 'Y';
6107 END IF; -- End of if shipped_details >= 1
6108 END IF; -- End of if locator_id
6109
6110 IF (p_changed_attributes(l_counter).revision <> FND_API.G_MISS_CHAR AND
6111 (NVL(old_delivery_detail_rec.revision,'-99') <> NVL(p_changed_attributes(l_Counter).revision,'-99'))) THEN
6112 --
6113 -- Debug Statements
6114 --
6115 IF l_debug_on THEN
6116 WSH_DEBUG_SV.logmsg(l_module_name, 'UPDATE REVISION' );
6117 END IF;
6118 --
6119 IF (l_reject_update = 'Y') THEN
6120 -- At least one line is shipped, reject user's request
6121 l_ship_status := 'confirmed, in-transit or closed';
6122 FND_MESSAGE.Set_Name('WSH', 'WSH_REJECT_UPDATE_REQUEST');
6123 FND_MESSAGE.Set_Token('SHIP_STATUS', l_ship_status);
6124 FND_MESSAGE.Set_Token('UPDATE_ATTRIBUTE', 'revision');
6125 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6126 WSH_UTIL_CORE.Add_Message(x_return_status,l_module_name);
6127 ELSE
6128 -- bug 2302693: we do not log an exception if the line is packed
6129 -- and its inventory control was not null before pick confirm.
6130 -- The reason is that before pick confirm, we assume packing is planned.
6131 -- To see the original code, please look at revision 115.17.
6132 l_update_rev := 'Y';
6133 END IF; -- End of if shipped_details >= 1
6134 END IF; -- End of if revision
6135
6136 -- IF (p_changed_attributes(l_counter).lot_number <> FND_API.G_MISS_CHAR AND
6137 -- ((NVL(old_delivery_detail_rec.lot_number,'-99') <> NVL(p_changed_attributes(l_Counter).lot_number,'-99')))) THEN
6138 --bug 6675904 changed if condition as Inv allows any value for lot number so -99 was
6139 --not getting updated in WDD
6140 IF ( ( ( old_delivery_detail_rec.lot_number IS NULL AND p_changed_attributes(l_Counter).lot_number IS NOT NULL ) OR
6141 ( old_delivery_detail_rec.lot_number IS NOT NULL AND p_changed_attributes(l_Counter).lot_number IS NULL ) OR
6142 ( old_delivery_detail_rec.lot_number IS NOT NULL AND p_changed_attributes(l_Counter).lot_number IS NOT NULL AND
6143 old_delivery_detail_rec.lot_number <> p_changed_attributes(l_Counter).lot_number )) and
6144 p_changed_attributes(l_counter).lot_number <> FND_API.G_MISS_CHAR) THEN
6145 --
6146 -- Debug Statements
6147 --
6148 IF l_debug_on THEN
6149 WSH_DEBUG_SV.logmsg(l_module_name, 'UPDATE LOT NUMBER' );
6150 END IF;
6151 --
6152 IF (l_reject_update = 'Y') THEN
6153 -- At least one line is shipped, reject user's request
6154 l_ship_status := 'confirmed, in-transit or closed';
6155 FND_MESSAGE.Set_Name('WSH', 'WSH_REJECT_UPDATE_REQUEST');
6156 FND_MESSAGE.Set_Token('SHIP_STATUS', l_ship_status);
6157 FND_MESSAGE.Set_Token('UPDATE_ATTRIBUTE', 'lot_number');
6158 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6159 WSH_UTIL_CORE.Add_Message(x_return_status,l_module_name);
6160 ELSE
6161 -- bug 2302693: we do not log an exception if the line is packed
6162 -- and its inventory control was not null before pick confirm.
6163 -- The reason is that before pick confirm, we assume packing is planned.
6164 -- To see the original code, please look at revision 115.17.
6165 l_update_lot := 'Y';
6166 END IF; -- End of if shipped_details >= 1
6167 END IF; -- End of if lot_number
6168
6169
6170 -- Hverddin 12-SEP-200 Start of OPM changes For Grade
6171 -- NOTE LOG EXCEPTIONS PUT VALUE INTO LOT_NUMBER UNTIL RESOLVED
6172 IF (p_changed_attributes(l_counter).preferred_grade <> FND_API.G_MISS_CHAR AND
6173 (NVL(old_delivery_detail_rec.preferred_grade,'-99') <> NVL(p_changed_attributes(l_Counter).preferred_grade,'-99'))) THEN
6174 --
6175 -- Debug Statements
6176 --
6177 IF l_debug_on THEN
6178 WSH_DEBUG_SV.logmsg(l_module_name, 'PREFERRED GRADE' );
6179 END IF;
6180 --
6181 IF (l_reject_update = 'Y') THEN
6182 -- At least one line is shipped, reject user's request
6183 l_ship_status := 'confirmed, in-transit or closed';
6184 FND_MESSAGE.Set_Name('WSH', 'WSH_REJECT_UPDATE_REQUEST');
6185 FND_MESSAGE.Set_Token('SHIP_STATUS', l_ship_status);
6186 FND_MESSAGE.Set_Token('UPDATE_ATTRIBUTE', 'preferred_grade');
6187 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6188 WSH_UTIL_CORE.Add_Message(x_return_status,l_module_name);
6189 ELSE
6190 -- bug 2302693: we do not log an exception if the line is packed
6191 -- and its inventory control was not null before pick confirm.
6192 -- The reason is that before pick confirm, we assume packing is planned.
6193 -- To see the original code, please look at revision 115.17.
6194 l_update_preferred_grade := 'Y';
6195 END IF; -- End of if shipped_details >= 1
6196 END IF; -- End of if preferred_grade
6197 -- Hverddin 12-SEP-200 End of OPM changes For Grade
6198
6199 -- Bug 2657652 : Added transaction_temp_id
6200 IF (l_transaction_temp_id <> FND_API.G_MISS_NUM AND
6201 (NVL(old_delivery_detail_rec.transaction_temp_id,-99) <> NVL(l_transaction_temp_id,-99))) THEN
6202 --
6203 -- Debug Statements
6204 --
6205 IF l_debug_on THEN
6206 WSH_DEBUG_SV.logmsg(l_module_name, 'UPDATE TRANSACTION TEMP ID with transaction_temp_id :'||
6207 l_transaction_temp_id ||
6208 ', picked_quantity :'||
6209 p_changed_attributes(l_Counter).picked_quantity );
6210 END IF;
6211 --
6212 IF (l_reject_update = 'Y') THEN
6213 -- At least one line is shipped, reject user's request
6214 l_ship_status := 'confirmed, in-transit or closed';
6215 FND_MESSAGE.Set_Name('WSH', 'WSH_REJECT_UPDATE_REQUEST');
6216 FND_MESSAGE.Set_Token('SHIP_STATUS', l_ship_status);
6217 FND_MESSAGE.Set_Token('UPDATE_ATTRIBUTE', 'transaction_temp_id');
6218 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6219 WSH_UTIL_CORE.Add_Message(x_return_status);
6220 ELSE
6221 l_update_transaction_temp_id := 'Y';
6222 END IF; -- End of if l_reject_update = 'Y'
6223 END IF; -- End of if transaction_temp_id
6224
6225 IF (p_changed_attributes(l_counter).serial_number <> FND_API.G_MISS_CHAR AND
6226 (NVL(old_delivery_detail_rec.serial_number,'-99') <> NVL(p_changed_attributes(l_Counter).serial_number,'-99'))) THEN
6227 --
6228 -- Debug Statements
6229 --
6230 IF l_debug_on THEN
6231 WSH_DEBUG_SV.logmsg(l_module_name, 'UPDATE SERIAL NUMBER' );
6232 END IF;
6233 --
6234 IF (l_reject_update = 'Y') THEN
6235 -- At least one line is shipped, reject user's request
6236 l_ship_status := 'confirmed, in-transit or closed';
6237 FND_MESSAGE.Set_Name('WSH', 'WSH_REJECT_UPDATE_REQUEST');
6238 FND_MESSAGE.Set_Token('SHIP_STATUS', l_ship_status);
6239 FND_MESSAGE.Set_Token('UPDATE_ATTRIBUTE', 'serial_number');
6240 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6241 WSH_UTIL_CORE.Add_Message(x_return_status,l_module_name);
6242 ELSE
6243 -- bug 2302693: we do not log an exception if the line is packed
6244 -- and its inventory control was not null before pick confirm.
6245 -- The reason is that before pick confirm, we assume packing is planned.
6246 -- To see the original code, please look at revision 115.17.
6247 l_update_serial_number := 'Y';
6248 END IF; -- End of if shipped_details >= 1
6249 END IF; -- End of if serial_number
6250
6251 IF (p_changed_attributes(l_counter).released_status <> FND_API.G_MISS_CHAR AND
6252 NVL(old_delivery_detail_rec.released_status, 'N') <> NVL(p_changed_attributes(l_Counter).released_status, 'N')) THEN
6253 --
6254 -- Debug Statements
6255 --
6256 IF l_debug_on THEN
6257 WSH_DEBUG_SV.logmsg(l_module_name, 'UPDATE RELEASED STATUS ' );
6258 END IF;
6259 --
6260 IF (l_reject_update = 'Y') THEN
6261 -- At least one line is shipped, reject user's request
6262 l_ship_status := 'confirmed, in-transit or closed';
6263 FND_MESSAGE.Set_Name('WSH', 'WSH_REJECT_UPDATE_REQUEST');
6264 FND_MESSAGE.Set_Token('SHIP_STATUS', l_ship_status);
6265 FND_MESSAGE.Set_Token('UPDATE_ATTRIBUTE', 'released_status');
6266 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6267 WSH_UTIL_CORE.Add_Message(x_return_status,l_module_name);
6268 ELSE
6269 l_update_rel_status := 'Y';
6270
6271 -- start overpicking logic
6272 -- If we overpick, we want to update this delivery line's requested_quantity
6273 -- in order to minimize the overpicking.
6274 --
6275 -- When that happens, we call update_ordered_quantity in order to update
6276 -- other unstaged delivery lines so that the total requested quantity will
6277 -- still match the order line's ordered quantity.
6278 IF p_changed_attributes(l_counter).picked_quantity <> FND_API.G_MISS_NUM THEN
6279
6280 DECLARE -- BLOCK for managing requested quantity changes
6281 CURSOR c_detail_info(x_delivery_detail_id IN NUMBER) IS
6282 SELECT source_line_id,
6283 source_code,
6284 organization_id, -- bug 7131800
6285 requested_quantity,
6286 requested_quantity2
6287 FROM wsh_delivery_details
6288 WHERE delivery_detail_id = x_delivery_detail_id;
6289
6290 CURSOR c_source_info(x_source_line_id IN NUMBER, x_source_code IN VARCHAR2) IS
6291 SELECT ordered_quantity,
6292 order_quantity_uom,
6293 ordered_quantity2,
6294 ordered_quantity_uom2
6295 FROM oe_order_lines_all
6296 WHERE line_id = x_source_line_id
6297 AND x_source_code = 'OE';
6298
6299 l_detail_info c_detail_info%ROWTYPE;
6300 l_source_info c_source_info%ROWTYPE;
6301 l_max_quantity NUMBER;
6302 l_avail_quantity NUMBER;
6303
6304 l_process_flag VARCHAR2(1) :=FND_API.G_FALSE;
6305 l_max_quantity2 NUMBER;
6306 l_avail_quantity2 NUMBER;
6307 l_allowed_flag VARCHAR2(1);
6308 l_rs VARCHAR2(1);
6309 l_found BOOLEAN := FALSE;
6310 --Bug 7131800
6311 l_ship_params WSH_SHIPPING_PARAMS_PVT.Parameter_Rec_Typ;
6312 l_retain_nonstaged_dd_param VARCHAR2(1);
6313 l_ret_status VARCHAR2(1);
6314 --Bug 7131800
6315
6316 BEGIN
6317 OPEN c_detail_info(p_changed_attributes(l_Counter).delivery_detail_id);
6318 FETCH c_detail_info INTO l_detail_info;
6319 l_found := c_detail_info%FOUND;
6320 CLOSE c_detail_info;
6321
6322 -- make sure this is an overpick case
6323 IF l_found
6324 -- muom
6325 AND ((l_fulfillment_base = 'P' and l_detail_info.requested_quantity < p_changed_attributes(l_counter).picked_quantity) OR
6326 (l_fulfillment_base = 'S' and l_detail_info.requested_quantity2 < p_changed_attributes(l_counter).picked_quantity2)) THEN --{
6327
6328 -- We call check_quantity_to_pick to get the available requested quantity
6329 -- that can be staged.
6330 wsh_details_validations.check_quantity_to_pick(
6331 p_order_line_id => l_detail_info.source_line_id,
6332 p_quantity_to_pick => p_changed_attributes(l_counter).picked_quantity,
6333 p_quantity2_to_pick => p_changed_attributes(l_counter).picked_quantity2,
6334 x_allowed_flag => l_allowed_flag,
6335 x_max_quantity_allowed => l_max_quantity,
6336 x_max_quantity2_allowed => l_max_quantity2,
6337 x_avail_req_quantity => l_avail_quantity,
6338 x_avail_req_quantity2 => l_avail_quantity2,
6339 x_return_status => l_rs);
6340 IF l_debug_on THEN
6341 WSH_DEBUG_SV.log(l_module_name,'check_quantity_to_pick l_rs',l_rs);
6342 WSH_DEBUG_SV.log(l_module_name,'l_detail_info.req.qty ', l_detail_info.requested_quantity);
6343 WSH_DEBUG_SV.log(l_module_name,'l_avail_qty ', l_avail_quantity);
6344 WSH_DEBUG_SV.log(l_module_name,'chgd.attr picked.qty ', p_changed_attributes(l_counter).picked_quantity);
6345 WSH_DEBUG_SV.log(l_module_name,'l_max_qty ', l_max_quantity);
6346 WSH_DEBUG_SV.log(l_module_name,'l_detail_info.req.qty2 ', l_detail_info.requested_quantity2);
6347 WSH_DEBUG_SV.log(l_module_name,'l_avail_qty2 ', l_avail_quantity2);
6348 WSH_DEBUG_SV.log(l_module_name,'chgd.attr picked.qty2 ', p_changed_attributes(l_counter).picked_quantity2);
6349 WSH_DEBUG_SV.log(l_module_name,'l_max_qty2 ', l_max_quantity2);
6350 END IF;
6351
6352 IF l_rs = WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
6353 IF l_debug_on THEN
6354 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_SHIPPING_PARAMS_PVT.GET', WSH_DEBUG_SV.C_PROC_LEVEL);
6355 END IF;
6356 wsh_shipping_params_pvt.get(
6357 p_organization_id => l_detail_info.organization_id,
6358 x_param_info => l_ship_params,
6359 x_return_status => l_ret_status);
6360
6361 IF l_debug_on THEN
6362 WSH_DEBUG_SV.log(l_module_name,'wsh_shipping_params_pvt.get l_ret_status',l_ret_status);
6363 WSH_DEBUG_SV.log(l_module_name,'l_ship_params.retain_nonstaged_det_flag',l_ship_params.retain_nonstaged_det_flag);
6364 END IF;
6365
6366 -- bug 7131800
6367 IF NOT INV_GMI_RSV_BRANCH.Process_Branch(p_organization_id => l_detail_info.organization_id) THEN
6368 l_process_flag := FND_API.G_FALSE;
6369 ELSE
6370 l_process_flag := FND_API.G_TRUE;
6371 END IF;
6372
6373 IF l_debug_on THEN
6374 WSH_DEBUG_SV.log(l_module_name,'l_process_flag',l_process_flag);
6375 END IF;
6376
6377
6378 IF l_ret_status = WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
6379 l_retain_nonstaged_dd_param := nvl(l_ship_params.retain_nonstaged_det_flag,'N');
6380 IF ( l_process_flag = FND_API.G_FALSE AND l_retain_nonstaged_dd_param = 'Y') THEN
6381 -- muom
6382 IF l_fulfillment_base = 'P' THEN
6383 l_new_req_quantity := l_detail_info.requested_quantity +
6384 (l_avail_quantity - LEAST(l_max_quantity -(p_changed_attributes(l_counter).picked_quantity - l_detail_info.requested_quantity), l_avail_quantity));
6385 l_new_req_quantity2 := nvl(LEAST(p_changed_attributes(l_counter).picked_quantity2,l_avail_quantity2),0);
6386 ELSE
6387 l_new_req_quantity2 := l_detail_info.requested_quantity2 +
6388 (l_avail_quantity2 - LEAST(l_max_quantity2 -(p_changed_attributes(l_counter).picked_quantity2 - l_detail_info.requested_quantity2), l_avail_quantity2));
6389 /*
6390 l_new_req_quantity := nvl(LEAST(p_changed_attributes(l_counter).picked_quantity,l_avail_quantity),0);
6391 */
6392 l_new_req_quantity := l_detail_info.requested_quantity +
6393 (l_avail_quantity - LEAST(l_max_quantity -(p_changed_attributes(l_counter).picked_quantity - l_detail_info.requested_quantity), l_avail_quantity));
6394 END IF;
6395 ELSE
6396 l_new_req_quantity := LEAST(p_changed_attributes(l_counter).picked_quantity, l_avail_quantity);
6397 l_new_req_quantity2 := nvl(LEAST(p_changed_attributes(l_counter).picked_quantity2,l_avail_quantity2),0);
6398 END IF;
6399 ELSE
6400 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6401 l_new_req_quantity := NULL;
6402 l_new_req_quantity2 := NULL;
6403 END IF;
6404 ELSE
6405 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6406 l_new_req_quantity := NULL;
6407 l_new_req_quantity2 := NULL;
6408 END IF;
6409 --Bug 7131800
6410 IF l_debug_on THEN
6411 -- muom
6412 WSH_DEBUG_SV.logmsg(l_module_name,'l_new_req_qty '||l_new_req_quantity||' l_new_req_quantity2 '||l_new_req_quantity2);
6413 END IF;
6414
6415 IF l_new_req_quantity > l_detail_info.requested_quantity OR nvl(l_new_req_quantity2,0) > nvl(l_detail_info.requested_quantity2,0)THEN
6416
6417 -- Because we will increase this newly staged delivery line's
6418 -- requested quantity to accomodate the picked quantity,
6419 -- we need to reduce excess requested quantity
6420 -- of unstaged delivery lines.
6421
6422 OPEN c_source_info(l_detail_info.source_line_id, l_detail_info.source_code);
6423 FETCH c_source_info INTO l_source_info;
6424 l_found := c_source_info%FOUND;
6425 CLOSE c_source_info;
6426
6427 IF l_found THEN
6428 l_update_quantities := 'Y';
6429 l_source_code := l_detail_info.source_code;
6430 l_overpick_rec.source_line_id := l_detail_info.source_line_id;
6431 l_overpick_rec.ordered_quantity := l_source_info.ordered_quantity;
6432 l_overpick_rec.order_quantity_uom := l_source_info.order_quantity_uom;
6433 l_overpick_rec.ordered_quantity2 := l_source_info.ordered_quantity2;
6434 l_overpick_rec.ordered_quantity_uom2 := l_source_info.ordered_quantity_uom2;
6435 ELSE
6436 -- fail-safe mode: do not update requested_quantity or call update_ordered_quantity
6437 l_update_quantities := 'N';
6438 l_new_req_quantity := NULL;
6439 l_new_req_quantity2 := NULL;
6440 END IF;
6441
6442 END IF; -- l_new_req_quantity > l_detail_info.requested_quantity
6443 END IF; -- l_found AND requested_quantity <> picked_quantity
6444
6445 END; -- BLOCK for managing requested quantity changes
6446 END IF; -- p_changed_attributes(l_counter).picked_quantity <> FND_API.G_MISS_NUM
6447 -- end overpicking logic
6448
6449 END IF; -- End of if shipped_details >= 1
6450 END IF; -- End of if released_status
6451
6452
6453 -- Bug 2657652 : fail safe check
6454 -- Shipping expects either transaction_temp_id or serial_number but not both
6455 -- If transaction_temp_id is passed then quantity should be > 1
6456 -- As per Bug 3764278, transaction temp id can be passed for quantity 1 as well since WMS can also specify attributes
6457 -- If serial_number is passed then quantity should be 1
6458 --
6459 -- Debug Statements
6460 --
6461 IF l_debug_on THEN
6462 WSH_DEBUG_SV.logmsg(l_module_name, ' l_update_transaction_temp_id '||l_update_transaction_temp_id||
6463 ' l_update_serial_number '||l_update_serial_number||
6464 ' p_changed_attributes(l_counter).picked_quantity '||p_changed_attributes(l_counter).picked_quantity||
6465 ' l_new_req_quantity '||l_new_req_quantity||
6466 ' l_new_req_quantity2 '||l_new_req_quantity2||
6467 ' old_delivery_detail_rec.requested_quantity '||old_delivery_detail_rec.requested_quantity );
6468 END IF;
6469 --
6470 -- Bug 3764278, allow WMS to stamp transaction temp id when quantity =1
6471 -- WMS has UI where user can enter serial number and attributes, hence this
6472 -- requirement.This API is also called during Pick Confirm, test cases for Inv.
6473 IF ((l_update_transaction_temp_id = 'Y' AND l_update_serial_number = 'Y') OR
6474 (l_update_serial_number = 'Y' AND
6475 ((p_changed_attributes(l_counter).picked_quantity = FND_API.G_MISS_NUM AND
6476 NVL(l_new_req_quantity, old_delivery_detail_rec.requested_quantity) > 1) OR
6477 (p_changed_attributes(l_counter).picked_quantity <> FND_API.G_MISS_NUM AND
6478 p_changed_attributes(l_counter).picked_quantity > 1))
6479 )
6480 ) THEN
6481
6482 OE_DEBUG_PUB.Add('REJECTING INVENTORY REQUEST');
6483 FND_MESSAGE.Set_Name('WSH', 'WSH_REJECT_INV_REQUEST');
6484 FND_MESSAGE.Set_Token('TRANSACTION_TEMP_ID', l_transaction_temp_id);
6485 FND_MESSAGE.Set_Token('SERIAL_NUMBER', p_changed_attributes(l_counter).serial_number);
6486 FND_MESSAGE.Set_Token('PICKED_QUANTITY', p_changed_attributes(l_counter).picked_quantity);
6487 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6488 WSH_UTIL_CORE.Add_Message(x_return_status);
6489
6490 END IF;
6491
6492
6493 IF ((l_update_sub = 'Y') OR
6494 (l_update_loc = 'Y') OR
6495 (l_update_rev = 'Y')
6496 OR
6497 (l_update_lot = 'Y') OR
6498 (l_update_preferred_grade = 'Y') OR
6499 (l_update_transaction_temp_id = 'Y') OR
6500 (l_update_serial_number = 'Y') OR
6501 (l_update_rel_status = 'Y')) THEN
6502 --
6503 -- Debug Statements
6504 --
6505 IF l_debug_on THEN
6506 WSH_DEBUG_SV.logmsg(l_module_name, 'UPDATE WSH_DELIVERY_DETAILS' );
6507 END IF;
6508 --
6509
6510 -- muom
6511 l_split_flag := 'Y';
6512 l_fulfillment_base := WSH_UTIL_CORE.Get_Line_Fulfillment_Base(old_delivery_detail_rec.source_code, old_delivery_detail_rec.source_line_id);
6513
6514 -- bug 2120494
6515 -- This part handles backordering of lines in the case of under picking where
6516 -- the pending quantity is zero.
6517 -- Below is a update statement which is repetition of from code where "action_flag = 'B'"
6518 -- This needs to be replaced soon with a procedure to reduce redundancy.
6519 l_under_pick_post_process_flag := 'N'; --Bug7592072
6520
6521 IF p_changed_attributes(l_counter).action_flag = 'U'
6522 -- muom
6523 AND ( (l_pending_quantity = 0 and p_Changed_Attributes(l_counter).picked_quantity < old_Delivery_detail_rec.requested_quantity
6524 and nvl(l_fulfillment_base, 'P') = 'P') OR
6525 (l_pending_quantity2 = 0 and p_Changed_Attributes(l_counter).picked_quantity2 < old_Delivery_detail_rec.requested_quantity2
6526 and l_fulfillment_base = 'S'))
6527
6528 THEN
6529 l_under_pick_post_process_flag := 'Y'; --Bug7592072
6530 -- muom
6531 IF l_debug_on THEN
6532 WSH_DEBUG_SV.log(l_module_name, 'Inside Action U ');
6533 WSH_DEBUG_SV.log(l_module_name, 'l_fulfillment+base ', l_fulfillment_base);
6534 WSH_DEBUG_SV.log(l_module_name, 'l_pending_quantity', l_pending_quantity);
6535 WSH_DEBUG_SV.log(l_module_name, 'l_pending_quantity2', l_pending_quantity2);
6536 WSH_DEBUG_SV.log(l_module_name, 'l_picked_qty ', p_Changed_Attributes(l_counter).picked_quantity);
6537 WSH_DEBUG_SV.log(l_module_name, 'l_picked_qty2 ',p_Changed_Attributes(l_counter).picked_quantity2);
6538 WSH_DEBUG_SV.log(l_module_name, 'l_pending_quantity2', l_pending_quantity2);
6539 END IF;
6540 if (l_pending_quantity2 is Null or l_pending_quantity2 = 0) and
6541 p_changed_attributes(l_counter).pending_quantity2 is not null then
6542 l_pending_quantity2 := p_changed_attributes(l_counter).pending_quantity2;
6543 end if;
6544
6545 -- muom
6546 -- {
6547 if ( nvl(l_fulfillment_base, 'P') = 'P') then
6548 l_split_quantity2 := nvl(p_Changed_attributes(l_Counter).picked_quantity2, 0);
6549 IF l_split_quantity2 = FND_API.G_MISS_NUM THEN
6550 l_split_quantity2 := NULL;
6551 END IF;
6552 l_split_quantity := p_Changed_Attributes(l_counter).picked_quantity;
6553 elsif (l_fulfillment_base = 'S' ) then
6554 if (p_Changed_Attributes(l_counter).picked_quantity2 < old_Delivery_detail_rec.requested_quantity2) then
6555 l_split_quantity2 := p_Changed_attributes(l_Counter).picked_quantity2;
6556 l_split_quantity := WSH_WV_UTILS.convert_uom(
6557 item_id => old_Delivery_detail_rec.inventory_item_id
6558 , lot_number => NULL
6559 , org_id => old_Delivery_detail_rec.organization_id
6560 , p_max_decimal_digits => NULL -- use default precision
6561 , quantity => p_Changed_attributes(l_Counter).picked_quantity2
6562 , from_uom => old_Delivery_detail_rec.requested_quantity_uom2
6563 , to_uom => old_Delivery_detail_rec.requested_quantity_uom
6564 );
6565 end if;
6566 if (nvl(p_Changed_Attributes(l_counter).picked_quantity2,0) = nvl(old_Delivery_detail_rec.requested_quantity2,0) ) then
6567 -- No Splits should take Place
6568 l_split_flag := 'N';
6569 end if;
6570 end if; -- }
6571
6572 --Start of Consolidation of BO DD's
6573
6574 l_cons_flag := 'N';
6575 -- Check the auto consolidation of back order lines only when current delivery detail id is
6576 -- not assigned to any planned delivery
6577 IF ( l_planned_flag = 'N' ) THEN
6578 --
6579 -- Debug Statements
6580 --
6581 IF l_debug_on THEN
6582 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_SHIPPING_PARAMS_PVT. Get_Global_Parameters',WSH_DEBUG_SV.C_PROC_LEVEL);
6583 END IF;
6584 --
6585 WSH_SHIPPING_PARAMS_PVT. Get_Global_Parameters(l_global_param_rec_type,l_return_status);
6586 --
6587 IF l_debug_on THEN
6588 WSH_DEBUG_SV.logmsg(l_module_name, 'After calling Get_Global_Parameters: ' || l_return_status );
6589 END IF;
6590 --
6591 IF (l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
6592 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6593 END IF;
6594 l_auto_consolidate := l_global_param_rec_type.consolidate_bo_lines;
6595 END IF;
6596
6597 IF ( l_auto_consolidate = 'Y') THEN -- consolidate the split Quantity
6598
6599 l_Cons_Source_Line_Rec_Tab(1).delivery_detail_id:= old_Delivery_detail_rec.delivery_detail_id ;
6600 l_Cons_Source_Line_Rec_Tab(1).delivery_id:= null;
6601 l_Cons_Source_Line_Rec_Tab(1).source_line_id:= old_Delivery_detail_rec.source_line_id;
6602 l_Cons_Source_Line_Rec_Tab(1).req_qty:= old_Delivery_detail_rec.requested_quantity;
6603 l_Cons_Source_Line_Rec_Tab(1).req_qty2:= old_Delivery_detail_rec.requested_quantity2;
6604 -- muom
6605 l_Cons_Source_Line_Rec_Tab(1).fulfillment_base := l_fulfillment_base;
6606
6607 --Bug# 5436033
6608 --do not calculate the qty2 - instead convert from bo_Qty Cause this is like entering a new line
6609 --and SO pad computes the sec qty from the order qty.
6610 IF l_fulfillment_base = 'P' THEN
6611 l_Cons_Source_Line_Rec_Tab(1).bo_qty:= old_Delivery_detail_rec.requested_quantity - l_split_quantity;
6612 IF l_Cons_Source_Line_Rec_Tab(1).bo_qty <> 0 AND old_Delivery_detail_rec.requested_quantity_uom2 IS NOT NULL THEN
6613 l_Cons_Source_Line_Rec_Tab(1).bo_qty2 := WSH_WV_UTILS.convert_uom(
6614 item_id => old_Delivery_detail_rec.inventory_item_id
6615 , lot_number => NULL
6616 , org_id => old_Delivery_detail_rec.organization_id
6617 , p_max_decimal_digits => NULL -- use default precision
6618 , quantity => l_Cons_Source_Line_Rec_Tab(1).bo_qty
6619 , from_uom => old_Delivery_detail_rec.requested_quantity_uom
6620 , to_uom => old_Delivery_detail_rec.requested_quantity_uom2
6621 );
6622 END IF;
6623 ELSE
6624 l_Cons_Source_Line_Rec_Tab(1).bo_qty2:= old_Delivery_detail_rec.requested_quantity2 - l_split_quantity2;
6625 IF l_Cons_Source_Line_Rec_Tab(1).bo_qty2 <> 0 THEN
6626 l_Cons_Source_Line_Rec_Tab(1).bo_qty := WSH_WV_UTILS.convert_uom(
6627 item_id => old_Delivery_detail_rec.inventory_item_id
6628 , lot_number => NULL
6629 , org_id => old_Delivery_detail_rec.organization_id
6630 , p_max_decimal_digits => NULL -- use default precision
6631 , quantity => l_Cons_Source_Line_Rec_Tab(1).bo_qty2
6632 , from_uom => old_Delivery_detail_rec.requested_quantity_uom2
6633 , to_uom => old_Delivery_detail_rec.requested_quantity_uom
6634 );
6635 END IF;
6636 END IF;
6637 --l_Cons_Source_Line_Rec_Tab(1).bo_qty2:= old_Delivery_detail_rec.requested_quantity2 - l_split_quantity2;
6638 --End Bug# 5436033
6639
6640 --
6641 -- Debug Statements
6642 --
6643 IF l_debug_on THEN
6644 WSH_DEBUG_SV.log(l_module_name, 'CONSOLIDATE_SOURCE_LINE BEING CALLED WITH FOLLOWING PARAMETERS');
6645 WSH_DEBUG_SV.log(l_module_name,'P_DELIVERY_DETAIL_ID',old_Delivery_detail_rec.delivery_detail_id);
6646 WSH_DEBUG_SV.log(l_module_name,'P_REQUESTED_QUANTITY',old_Delivery_detail_rec.requested_quantity);
6647 WSH_DEBUG_SV.log(l_module_name,'Back Order Qty:',old_Delivery_detail_rec.requested_quantity - l_split_quantity);
6648 WSH_DEBUG_SV.log(l_module_name,'P_REQUESTED_QUANTITY2',old_Delivery_detail_rec.requested_quantity2);
6649 WSH_DEBUG_SV.log(l_module_name,'Back Order Qty2:',l_Cons_Source_Line_Rec_Tab(1).bo_qty2);
6650
6651 END IF;
6652 --
6653 WSH_DELIVERY_DETAILS_ACTIONS.Consolidate_Source_Line(
6654 p_Cons_Source_Line_Rec_Tab => l_Cons_Source_Line_Rec_Tab,
6655 x_consolidate_ids => l_cons_dd_ids,
6656 x_return_status => l_return_status);
6657
6658 IF l_debug_on THEN
6659 WSH_DEBUG_SV.log(l_module_name,'After calling CONSOLIDATE_SOURCE_LINE: ',l_return_status);
6660 END IF;
6661 IF (l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
6662 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6663 END IF;
6664
6665 IF ( l_cons_dd_ids(1) <> p_Changed_attributes(l_counter).delivery_detail_id ) THEN
6666 l_cons_flag := 'Y';
6667 IF l_debug_on THEN
6668 WSH_DEBUG_SV.log(l_module_name,'Consolidated the Del Det Id: ',old_Delivery_detail_rec.delivery_detail_id);
6669 END IF;
6670 l_dummy_detail_id := p_Changed_attributes(l_counter).delivery_detail_id;
6671 ELSE
6672 IF l_debug_on THEN
6673 WSH_DEBUG_SV.log(l_module_name,'Consolidation not happened for the the Del Det Id: ',old_Delivery_detail_rec.delivery_detail_id);
6674 END IF;
6675 END IF;
6676
6677 END IF; -- End of Consolidation of BO DD's
6678
6679 -- IF no consolidation then Split the line
6680 -- muom
6681 IF ( l_cons_flag = 'N' and l_split_flag = 'Y' ) THEN
6682 IF l_debug_on THEN
6683 WSH_DEBUG_SV.log(l_module_name, 'Before Split Details API');
6684 WSH_DEBUG_SV.log(l_module_name, 'Req. Qty.', l_split_quantity);
6685 WSH_DEBUG_SV.log(l_module_name, 'Req. Qty2.', l_split_quantity2);
6686 END IF;
6687
6688 WSH_DELIVERY_DETAILS_ACTIONS.Split_Delivery_Details(
6689 p_from_detail_id => p_Changed_attributes(l_counter).delivery_detail_id,
6690 p_req_quantity => l_split_quantity,
6691 x_new_detail_id => l_dummy_detail_id,
6692 x_return_status => l_return_status,
6693 p_req_quantity2 => nvl(l_split_quantity2,0),
6694 p_manual_split => p_changed_attributes(l_counter).action_flag);
6695 IF l_debug_on THEN
6696 WSH_DEBUG_SV.log(l_module_name,'Split_Delivery_Details l_return_status',l_return_status);
6697 END IF;
6698
6699
6700 -- Bug 3724578 : Return back to the caller if any error occures while
6701 -- splitting the delivery detail line
6702 --- Message will be set in Split_Delivery_Details
6703 IF (l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
6704 x_return_status := l_return_status;
6705 return;
6706 END IF;
6707
6708 -- Bug 2573434 : Added Call backorder API to unassign/unpack delivery detail
6709 --
6710 -- Debug Statements
6711 --
6712 IF l_debug_on THEN
6713 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_USA_INV_PVT. BACKORDERED_DELIVERY_DETAIL',WSH_DEBUG_SV.C_PROC_LEVEL);
6714 END IF;
6715 --
6716 --Bug# 5436033
6717 --do not calculate the qty2 convert from bo_Qty Cause this is like entering a new line
6718 --and SO pad computes the sec qty from the order qty.
6719 -- muom
6720 IF ( nvl(l_fulfillment_base, 'P') = 'P' and
6721 old_Delivery_detail_rec.requested_quantity - p_changed_attributes(l_Counter).picked_quantity <> 0) THEN
6722 IF old_Delivery_detail_rec.requested_quantity_uom2 IS NOT NULL THEN
6723
6724 l_requested_quantity2 := WSH_WV_UTILS.convert_uom(
6725 item_id => old_Delivery_detail_rec.inventory_item_id
6726 , lot_number => NULL
6727 , org_id => old_Delivery_detail_rec.organization_id
6728 , p_max_decimal_digits => NULL -- use default precision
6729 , quantity => (old_Delivery_detail_rec.requested_quantity - p_changed_attributes(l_Counter).picked_quantity)
6730 , from_uom => old_Delivery_detail_rec.requested_quantity_uom
6731 , to_uom => old_Delivery_detail_rec.requested_quantity_uom2
6732 );
6733
6734 END IF;
6735 --End Bug# 5436033
6736
6737 backorder_delivery_detail(
6738 p_delivery_detail_id => p_changed_attributes(l_counter).delivery_detail_id,
6739 p_requested_quantity => old_Delivery_detail_rec.requested_quantity
6740 - p_changed_attributes(l_Counter).picked_quantity,
6741 p_requested_quantity2 => l_requested_quantity2,
6742 p_planned_flag => l_planned_flag,
6743 p_wms_enabled_flag => l_wms_enabled_flag,
6744 p_del_batch_id => l_del_batch_id,
6745 x_split_quantity => l_dummy_quantity,
6746 -- muom
6747 x_split_quantity2 => l_dummy_quantity2,
6748 x_return_status => l_return_status
6749 );
6750 IF (l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
6751 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6752 END IF;
6753 --End Bug# 5436033
6754 END IF;
6755 -- muom
6756 IF ( l_fulfillment_base = 'S' and
6757 old_Delivery_detail_rec.requested_quantity2 - p_changed_attributes(l_Counter).picked_quantity2 <> 0 )
6758 THEN
6759 -- need to Convert the Qty. to Primarry
6760 l_new_requested_quantity := WSH_WV_UTILS.convert_uom(
6761 item_id => old_Delivery_detail_rec.inventory_item_id
6762 , lot_number => NULL
6763 , org_id => old_Delivery_detail_rec.organization_id
6764 , p_max_decimal_digits => NULL -- use default precision
6765 , quantity => (old_Delivery_detail_rec.requested_quantity2 - p_changed_attributes(l_Counter).picked_quantity2)
6766 , from_uom => old_Delivery_detail_rec.requested_quantity_uom2
6767 , to_uom => old_Delivery_detail_rec.requested_quantity_uom
6768 );
6769 IF l_debug_on THEN
6770 WSH_DEBUG_SV.log(l_module_name, 'Before BackOrder API');
6771 WSH_DEBUG_SV.log(l_module_name, 'New Req. Qty.', l_new_requested_quantity);
6772 WSH_DEBUG_SV.log(l_module_name, 'Req. Qty2.', (old_Delivery_detail_rec.requested_quantity2 - p_changed_attributes(l_Counter).picked_quantity2) );
6773 END IF;
6774
6775 backorder_delivery_detail(
6776 p_delivery_detail_id => p_changed_attributes(l_counter).delivery_detail_id,
6777 p_requested_quantity => l_new_requested_quantity,
6778 p_requested_quantity2 => old_Delivery_detail_rec.requested_quantity2 - p_changed_attributes(l_Counter).picked_quantity2,
6779 p_planned_flag => l_planned_flag,
6780 p_wms_enabled_flag => l_wms_enabled_flag,
6781 p_del_batch_id => l_del_batch_id,
6782 x_split_quantity => l_dummy_quantity,
6783 -- muom
6784 x_split_quantity2 => l_dummy_quantity2,
6785 x_return_status => l_return_status
6786 );
6787 END IF;
6788 END IF; -- No Consolidation check.
6789 ELSE
6790 l_dummy_detail_id := p_Changed_attributes(l_counter).delivery_detail_id;
6791 END IF;
6792
6793 -- Bug 2657652: Added l_update_shipped_quantity
6794 l_update_shipped_quantity := 'N';
6795 IF (l_update_transaction_temp_id = 'Y' OR l_update_serial_number = 'Y' or l_wms_enabled_flag = 'Y' ) THEN
6796 l_update_shipped_quantity := 'Y';
6797 END IF;
6798 IF l_debug_on THEN
6799 WSH_DEBUG_SV.log(l_module_name, 'Right before update');
6800 WSH_DEBUG_SV.log(l_module_name, 'l_new_req_quantity2', l_new_req_quantity2);
6801 END IF;
6802 -- bug 2120494
6803 UPDATE wsh_delivery_details
6804 SET subinventory = decode(l_update_sub,'Y',p_Changed_Attributes(l_Counter).subinventory,subinventory),
6805 locator_id = decode(l_update_loc, 'Y',p_Changed_Attributes(l_Counter).locator_id,locator_id),
6806 revision = decode(l_update_rev ,'Y',p_Changed_Attributes(l_Counter).revision,revision),
6807 lot_number = decode(l_update_lot,'Y',p_Changed_Attributes(l_Counter).lot_number,lot_number),
6808 preferred_grade = decode(l_update_preferred_grade,'Y',p_Changed_Attributes(l_Counter).preferred_grade,preferred_grade),
6809 -- Bug 2657652: Added transaction_temp_id and modified Shipped Quantity / Cycle Count Quantity clause
6810 transaction_temp_id = decode(l_update_transaction_temp_id, 'Y',l_transaction_temp_id,transaction_temp_id),
6811 serial_number = decode(l_update_serial_number,'Y',p_Changed_Attributes(l_Counter).serial_number,serial_number),
6812 shipped_quantity = decode(l_update_shipped_quantity,
6813 'Y',decode(p_changed_attributes(l_counter).picked_quantity,
6814 FND_API.G_MISS_NUM, NVL(l_new_req_quantity, requested_quantity),
6815 p_changed_attributes(l_counter).picked_quantity),
6816 shipped_quantity),
6817 shipped_quantity2 = decode(l_update_shipped_quantity,
6818 'Y',decode(p_changed_attributes(l_counter).picked_quantity2,
6819 FND_API.G_MISS_NUM, NVL(l_new_req_quantity2, requested_quantity2),
6820 p_changed_attributes(l_counter).picked_quantity2),
6821 shipped_quantity2),
6822
6823 -- Bug 1851473 : Set backordered qty = 0 in STF
6824 cycle_count_quantity = decode(l_update_shipped_quantity,'Y',0,cycle_count_quantity),
6825 cycle_count_quantity2 = decode(l_update_shipped_quantity,'Y',0,cycle_count_quantity2),
6826 released_status = decode(l_update_rel_status,'Y',decode(pickable_flag,'Y',p_Changed_Attributes(l_Counter).released_status,'X'), released_status),
6827 requested_quantity = NVL(l_new_req_quantity, requested_quantity),
6828 requested_quantity2 = NVL(l_new_req_quantity2, requested_quantity2),
6829 picked_quantity = DECODE(p_changed_attributes(l_counter).picked_quantity, FND_API.G_MISS_NUM, NULL,
6830 p_changed_attributes(l_counter).picked_quantity),
6831 picked_quantity2 = DECODE(p_changed_attributes(l_counter).picked_quantity2, FND_API.G_MISS_NUM, NULL,
6832 p_changed_attributes(l_counter).picked_quantity2),
6833 requested_quantity_uom2 = DECODE(l_wms_enabled_flag,
6834 'Y',
6835 DECODE(p_changed_attributes(l_counter).ordered_quantity_uom2,
6836 FND_API.G_MISS_CHAR, requested_quantity_uom2,
6837 p_changed_attributes(l_counter).ordered_quantity_uom2),
6838 requested_quantity_uom2),
6839 batch_id = DECODE(batch_id, NULL, WSH_PICK_LIST.G_BATCH_ID, batch_id),
6840 last_update_date = SYSDATE,
6841 last_updated_by = l_user_id,
6842 last_update_login = l_login_id,
6843 ----Bug#5104847:transaction_id updated only when l_transaction_id is not FND_API.G_MISS_NUM (default value).
6844 transaction_id = DECODE(l_transaction_id,FND_API.G_MISS_NUM,transaction_id,l_transaction_id)
6845 ,tracking_number = old_Delivery_detail_rec.tracking_number --Bug# 3632485
6846 WHERE delivery_detail_id = l_dummy_detail_id
6847 RETURNING organization_id -- Done for Workflow Project
6848 INTO l_organization_id;
6849
6850 --Raise Event : Pick To Pod Workflow
6851 WSH_WF_STD.Raise_Event(
6852 p_entity_type => 'LINE',
6853 p_entity_id => l_dummy_detail_id ,
6854 p_event => 'oracle.apps.wsh.line.gen.staged' ,
6855 p_organization_id => l_organization_id,
6856 x_return_status => l_wf_rs ) ;
6857 IF l_debug_on THEN
6858 WSH_DEBUG_SV.log(l_module_name,'Current Time is ',SYSDATE);
6859 wsh_debug_sv.log(l_module_name,'Return Status After Calling WSH_WF_STD.Raise_Event',l_wf_rs);
6860 END IF;
6861 --Done Raise Event : Pick To Pod Workflow
6862
6863
6864 --
6865 --
6866 -- DBI Project
6867 -- Update of wsh_delivery_details where requested_quantity
6868 -- are changed, call DBI API after the update.
6869 -- DBI API checks for DBI Installed also
6870 IF l_debug_on THEN
6871 WSH_DEBUG_SV.log(l_module_name,'Calling DBI API.Detail id-',l_dummy_detail_id);
6872 END IF;
6873 l_detail_tab(1) := l_dummy_detail_id;
6874 WSH_INTEGRATION.DBI_Update_Detail_Log
6875 (p_delivery_detail_id_tab => l_detail_tab,
6876 p_dml_type => 'UPDATE',
6877 x_return_status => l_dbi_rs);
6878
6879 IF l_debug_on THEN
6880 WSH_DEBUG_SV.log(l_module_name,'Return Status after DBI Call-',l_dbi_rs);
6881 END IF;
6882 -- DBI API can only raise unexpected error, in that case need to
6883 -- pass it to the caller API for roll back of the whole transaction
6884 -- Only need to handle Unexpected error, rest are treated as success
6885 -- Since code is not proceeding, no need to reset x_return_status
6886 IF l_dbi_rs = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
6887 x_return_status := l_dbi_rs;
6888 IF l_debug_on THEN
6889 WSH_DEBUG_SV.pop(l_module_name);
6890 END IF;
6891 RETURN;
6892 END IF;
6893
6894 -- End of Code for DBI Project
6895 --
6896 -- bug 3632485 When transacted quantity is less than allocated quantity, null out tracking number for backordered delivery detail.
6897 if (old_Delivery_detail_rec.tracking_number is not null
6898 and p_Changed_attributes(l_counter).delivery_detail_id <>l_dummy_detail_id) then
6899 update wsh_delivery_details
6900 set tracking_number = NULL
6901 where delivery_detail_id = p_Changed_attributes(l_counter).delivery_detail_id;
6902 end if;
6903
6904 /* Bug 2740833: After updating the wdd with the overpick qty, the weight and the volume needs to be re-calculated.*/
6905 -- J: W/V Changes
6906 -- Bug7592072 Begin
6907 IF l_debug_on THEN
6908 WSH_DEBUG_SV.log(l_module_name,'l_under_pick_post_process_flag',l_under_pick_post_process_flag);
6909 WSH_DEBUG_SV.log(l_module_name,'p_changed_attributes(l_Counter).transfer_lpn_id',p_changed_attributes(l_Counter).transfer_lpn_id);
6910 WSH_DEBUG_SV.log(l_module_name,'l_cont_instance_id',l_cont_instance_id);
6911 WSH_DEBUG_SV.log(l_module_name,'l_wms_enabled_flag',l_wms_enabled_flag);
6912 END IF;
6913 IF ( l_under_pick_post_process_flag = 'Y' AND l_cont_instance_id IS NOT NULL AND l_wms_enabled_flag = 'Y'
6914 AND p_changed_attributes(l_Counter).transfer_lpn_id IS NOT NULL) THEN
6915 --{
6916 IF l_debug_on THEN
6917 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_WV_UTILS.CONTAINER_WEIGHT_VOLUME',WSH_DEBUG_SV.C_PROC_LEVEL);
6918 END IF;
6919 --
6920 WSH_WV_UTILS.Container_Weight_Volume (
6921 p_container_instance_id => l_cont_instance_id,
6922 p_override_flag => 'Y',
6923 p_fill_pc_flag => 'Y',
6924 p_post_process_flag => 'Y',
6925 p_calc_wv_if_frozen => 'Y',
6926 x_gross_weight => l_cont_gross_weight,
6927 x_net_weight => l_cont_net_weight,
6928 x_volume => l_cont_volume,
6929 x_cont_fill_pc => l_cont_fill_pc,
6930 x_return_status => x_return_status);
6931 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
6932 x_return_status := l_return_status;
6933 IF l_debug_on THEN
6934 WSH_DEBUG_SV.pop(l_module_name,'Container_Weight_Volume returned '||l_return_status);
6935 WSH_DEBUG_SV.pop(l_module_name);
6936 END IF;
6937 return;
6938 END IF;
6939 --}
6940 END IF;
6941 --Bug7592072 End
6942 --Bug 7307755 : No need to post weight changes to LPN records as
6943 -- WMS is taking care of populating w/v values including
6944 -- overpicked qty on LPN records.
6945 l_post_process_flag := 'Y';
6946 IF (p_changed_attributes(l_Counter).transfer_lpn_id <> FND_API.G_MISS_NUM ) THEN
6947 l_post_process_flag := 'N';
6948 END IF;
6949 --
6950 IF l_debug_on THEN
6951 WSH_DEBUG_SV.log(l_module_name,'l_post_process_flag',l_post_process_flag);
6952 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_WV_UTILS.Detail_Weight_Volume',WSH_DEBUG_SV.C_PROC_LEVEL);
6953 END IF;
6954
6955 WSH_WV_UTILS.Detail_Weight_Volume
6956 (p_delivery_detail_id =>l_dummy_detail_id,
6957 p_update_flag => 'Y',
6958 p_post_process_flag => l_post_process_flag,--Bug7307755
6959 p_calc_wv_if_frozen => 'N',
6960 x_net_weight => l_net_weight,
6961 x_volume => l_volume,
6962 x_return_status => l_return_status);
6963 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
6964 x_return_status := l_return_status;
6965 IF l_debug_on THEN
6966 WSH_DEBUG_SV.pop(l_module_name,'Detail_Weight_Volume returned '||l_return_status);
6967 WSH_DEBUG_SV.pop(l_module_name);
6968 END IF;
6969 return;
6970 END IF;
6971
6972 /* OPM Begin Bug 2671460 */
6973 /* OPM Begin Bug 2671460 */
6974
6975 IF l_update_quantities = 'Y' THEN
6976 --
6977 -- Debug Statements
6978 --
6979 IF l_debug_on THEN
6980 WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_USA_QUANTITY_PVT.UPDATE_ORDERED_QUANTITY',WSH_DEBUG_SV.C_PROC_LEVEL);
6981 END IF;
6982 --
6983 -- bug 2942655 / 2936559
6984 -- overpick normalization will avoid canceling
6985 -- lines pending overpick by passing p_context.
6986 WSH_USA_QUANTITY_PVT.Update_Ordered_Quantity(
6987 p_changed_attribute => l_overpick_rec,
6988 p_source_code => l_source_code,
6989 p_action_flag => 'U',
6990 p_context => 'OVERPICK',
6991 x_return_status => l_return_status
6992 );
6993
6994 IF (l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
6995 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6996 END IF;
6997 END IF;
6998
6999 END IF;
7000
7001 END IF; -- End of if action_flag = 'M'
7002
7003 <<loop_end>>
7004
7005
7006 -- deliveryMerge csun
7007 IF l_update_rel_status = 'Y'
7008 and old_delivery_detail_rec.pickable_flag = 'Y'
7009 and p_changed_attributes(l_counter).released_status = 'Y'
7010 and l_delivery_id is not NULL
7011 and NVL(WSH_PICK_LIST.G_AUTO_PICK_CONFIRM, 'N') <> 'Y' THEN
7012 l_delivery_already_included := false;
7013
7014 IF l_adjust_planned_del_tab.count > 0 THEN
7015 FOR i in l_adjust_planned_del_tab.FIRST .. l_adjust_planned_del_tab.LAST LOOP
7016 IF l_adjust_planned_del_tab(i) = l_delivery_id THEN
7017 l_delivery_already_included := true;
7018 END IF;
7019 END LOOP;
7020 END IF;
7021
7022 IF NOT l_delivery_already_included THEN
7023 l_adjust_planned_del_tab(l_adjust_planned_del_tab.count+1) := l_delivery_id;
7024 END IF;
7025 END IF;
7026
7027
7028 END LOOP;
7029
7030
7031
7032 IF l_details_to_delete.count > 0 THEN
7033 --
7034 WSH_INTERFACE.Delete_Details(
7035 p_details_id => l_details_to_delete,
7036 x_return_status => l_return_status);
7037 IF l_debug_on THEN
7038 WSH_DEBUG_SV.log(l_module_name,'Delete_Details l_return_status',l_return_status);
7039 END IF;
7040 IF (l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
7041 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
7042 END IF;
7043 END IF;
7044
7045
7046 -- deliveryMerge
7047 IF l_adjust_planned_del_tab.count > 0 THEN
7048 WSH_NEW_DELIVERY_ACTIONS.Adjust_Planned_Flag(
7049 p_delivery_ids => l_adjust_planned_del_tab,
7050 p_caller => 'WSH_DLMG',
7051 p_force_appending_limit => 'N',
7052 p_call_lcss => 'Y',
7053 x_return_status => l_return_status);
7054
7055 IF l_debug_on THEN
7056 WSH_DEBUG_SV.log(l_module_name,'Adjust_Planned_Flag returns ',l_return_status);
7057 END IF;
7058
7059 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
7060 raise Adjust_Planned_Flag_Err;
7061 ELSIF (l_return_status in (WSH_UTIL_CORE.G_RET_STS_WARNING, WSH_UTIL_CORE.G_RET_STS_ERROR)) and
7062 x_return_status = WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
7063 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
7064 END IF;
7065 END IF;
7066
7067
7068 <<multiple_updates>>
7069 IF (l_multiple_update = 'Y') THEN
7070 update_inventory_info(l_changed_attributes, l_return_status);
7071 --bugfix 9726107 added warning condition
7072 IF (l_return_status = WSH_UTIL_CORE.G_RET_STS_WARNING) THEN
7073 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
7074 ELSIF (l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
7075 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
7076 END IF;
7077
7078 END IF;
7079 --
7080 -- Debug Statements
7081 --
7082 IF l_debug_on THEN
7083 WSH_DEBUG_SV.log(l_module_name,'update_inventory_info procedure returns ',x_return_status);
7084 WSH_DEBUG_SV.logmsg(l_module_name,'EXITING UPDATE_INVENTORY_INFO PROCEDURE ...' );
7085 END IF;
7086 --
7087
7088 --
7089 -- Debug Statements
7090 --
7091 IF l_debug_on THEN
7092 WSH_DEBUG_SV.pop(l_module_name);
7093 END IF;
7094 --
7095 EXCEPTION
7096 -- inbound logistics --jckwok
7097 WHEN Delivery_Line_Direction_Err THEN
7098 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
7099 --
7100 -- LPN CONV rv
7101 WSH_WMS_LPN_GRP.g_caller := l_original_caller;
7102 WSH_WMS_LPN_GRP.g_callback_required := l_orig_callback_reqd;
7103 -- LPN CONV rv
7104 --
7105 IF l_debug_on THEN
7106 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:Delivery_Line_Direction_Err');
7107 END IF;
7108 -- deliveryMerge
7109 WHEN Adjust_Planned_Flag_Err THEN
7110 FND_MESSAGE.SET_NAME('WSH', 'WSH_ADJUST_PLANNED_FLAG_ERR');
7111 WSH_UTIL_CORE.add_message(l_return_status,l_module_name);
7112 x_return_status := l_return_status;
7113
7114 --
7115 -- LPN CONV rv
7116 WSH_WMS_LPN_GRP.g_caller := l_original_caller;
7117 WSH_WMS_LPN_GRP.g_callback_required := l_orig_callback_reqd;
7118 -- LPN CONV rv
7119 --
7120 IF l_debug_on THEN
7121 WSH_DEBUG_SV.logmsg(l_module_name,'Adjust_Planned_Flag_Err exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
7122 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:Adjust_Planned_Flag_Err');
7123 END IF;
7124 --
7125
7126 WHEN others THEN
7127 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
7128 wsh_util_core.default_handler('WSH_USA_INV_PVT.Update_Inventory_Info',l_module_name);
7129 --
7130 -- LPN CONV rv
7131 WSH_WMS_LPN_GRP.g_caller := l_original_caller;
7132 WSH_WMS_LPN_GRP.g_callback_required := l_orig_callback_reqd;
7133 -- LPN CONV rv
7134 --
7135 IF l_debug_on THEN
7136 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
7137 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
7138 END IF;
7139 --
7140 END Update_Inventory_Info;
7141
7142 -- Bug 2939884
7143
7144 -- HW OPMCONV Make get_detailed a procedure to pass Qty2
7145
7146 -- PROCEDURE get_detailed_quantity
7147 -- Parameters: p_mo_line_id - Move order line id
7148 -- x_detailed_qty - Primary Qty
7149 -- x_detailed_qty2 - Secondary Qty
7150 -- x_return_status - Return Status
7151
7152 -- Description: This procedure was originally a function but because of
7153 -- OPM Convergence project, it was converted to a procedure to return
7154 -- Qty1 and Qty2.
7155 -- This procedure checks if Qtys are detailed in mtl_material_transactions_temp
7156 -- for a specific move order line id
7157 --
7158 PROCEDURE get_detailed_quantity (
7159 p_mo_line_id IN NUMBER,
7160 x_detailed_qty OUT NOCOPY NUMBER,
7161 x_detailed_qty2 OUT NOCOPY NUMBER,
7162 x_return_status OUT NOCOPY VARCHAR2)
7163 IS
7164
7165 l_detailed_qty NUMBER;
7166 -- HW OPMCONV -added qty2
7167 l_detailed_qty2 NUMBER ;
7168
7169 -- HW OPMCONV added Qty2
7170 cursor c_detailed_qty(p_line_id IN NUMBER) IS
7171 select sum(abs(transaction_quantity)) detailed_quantity,
7172 sum(abs(SECONDARY_TRANSACTION_QUANTITY )) secondary_detailed_quantity
7173 from mtl_material_transactions_temp
7174 where move_order_line_id = p_line_id;
7175
7176 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PACKAGE_NAME || '.' || 'get_detailed_quantity';
7177 l_debug_on BOOLEAN;
7178 qty_not_found EXCEPTION;
7179
7180 BEGIN
7181
7182 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
7183 --
7184 IF l_debug_on IS NULL
7185 THEN
7186 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
7187 END IF;
7188 --
7189 IF l_debug_on THEN
7190 WSH_DEBUG_SV.push(l_module_name);
7191 WSH_DEBUG_SV.log(l_module_name,'p_mo_line_id',p_mo_line_id);
7192 END IF;
7193
7194 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
7195
7196 OPEN c_detailed_qty(p_mo_line_id);
7197 FETCH c_detailed_qty INTO l_detailed_qty, l_detailed_qty2;
7198 IF c_detailed_qty%NOTFOUND THEN
7199 IF l_debug_on THEN
7200 WSH_DEBUG_SV.logmsg(l_module_name,'l_detailed_qty not found');
7201 raise qty_not_found;
7202 END IF;
7203 END IF;
7204
7205 CLOSE c_detailed_qty;
7206
7207
7208 IF l_debug_on THEN
7209 WSH_DEBUG_SV.log(l_module_name,'l_detailed_qty',l_detailed_qty);
7210 -- HW OPMCONV - Print value of Qty2
7211 WSH_DEBUG_SV.log(l_module_name,'l_detailed_qty2',l_detailed_qty2);
7212 WSH_DEBUG_SV.pop(l_module_name);
7213 END IF;
7214
7215 --fp bug 5347149/5253861: return 0, instead of NULL, so that
7216 -- the callers can compute the non-null reservation quantity to transfer.
7217 x_detailed_qty := NVL(l_detailed_qty, 0);
7218 -- HW OPMCONV - Pass Qty2 as 0 if it is NULL
7219 x_detailed_qty2 := NVL(l_detailed_qty2,0);
7220
7221 EXCEPTION
7222
7223 WHEN qty_not_found THEN
7224 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
7225 IF c_detailed_qty%ISOPEN THEN
7226 CLOSE c_detailed_qty;
7227 END IF;
7228 IF l_debug_on THEN
7229 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:get_detailed_FAILED');
7230 END IF;
7231
7232
7233 WHEN OTHERS THEN
7234
7235 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7236 IF c_detailed_qty%ISOPEN THEN
7237 CLOSE c_detailed_qty;
7238 END IF;
7239 IF l_debug_on THEN
7240 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
7241 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
7242 END IF;
7243 wsh_util_core.default_handler('WSH_USA_INV_PVT.get_detailed_quantity',l_module_name);
7244
7245 END get_detailed_quantity;
7246
7247 --
7248 -- X-dock
7249 -- Function: Derive Move Order type based on move_order_line_id
7250 -- Parameters : p_move_order_line_id - Move Order Line id
7251 -- Description : If move_order_type = PUTAWAY for the input move_order_line_id
7252 -- return TRUE, else return FALSE
7253 --
7254 FUNCTION is_mo_type_putaway (p_move_order_line_id IN NUMBER) RETURN VARCHAR2 IS
7255
7256 L_mo_type NUMBER;
7257 l_is_putaway VARCHAR2(1);
7258 l_return_status VARCHAR2(1);
7259 l_mo_header_id NUMBER;
7260
7261 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PACKAGE_NAME || '.' || 'is_mo_type_putaway';
7262 l_debug_on BOOLEAN;
7263
7264 BEGIN
7265
7266 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
7267 --
7268 IF l_debug_on IS NULL THEN
7269 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
7270 END IF;
7271 --
7272 IF l_debug_on THEN
7273 WSH_DEBUG_SV.push(l_module_name);
7274 WSH_DEBUG_SV.log(l_module_name,'p_move_order_line_id',p_move_order_line_id);
7275 END IF;
7276
7277 l_is_putaway := 'N';
7278
7279 WMS_CROSSDOCK_GRP.CHK_MO_TYPE
7280 (p_mo_line_id => p_move_order_line_id,
7281 x_return_status => l_return_status,
7282 x_mo_header_id => l_mo_header_id,
7283 x_mo_type => l_mo_type,
7284 x_is_putaway_mo => l_is_putaway);
7285
7286 IF l_debug_on THEN
7287 WSH_DEBUG_SV.log(l_module_name,'l_return_status',l_return_status);
7288 WSH_DEBUG_SV.log(l_module_name,'l_mo_header_id',l_mo_header_id);
7289 WSH_DEBUG_SV.log(l_module_name,'l_mo_type',l_mo_type);
7290 WSH_DEBUG_SV.log(l_module_name,'Is Type Putaway',l_is_putaway);
7291 WSH_DEBUG_SV.pop(l_module_name);
7292 END IF;
7293
7294 RETURN l_is_putaway;
7295
7296 EXCEPTION
7297
7298 WHEN OTHERS THEN
7299 IF l_debug_on THEN
7300 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
7301 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
7302 END IF;
7303 WSH_UTIL_CORE.DEFAULT_HANDLER('WSH_USA_INV_PVT.is_mo_type_putaway',l_module_name);
7304 RETURN 'N';
7305
7306 END is_mo_type_putaway;
7307
7308 --
7309 -- Procedure : get_putaway_detail_id
7310 -- Description : Procedure to return delivery_detail_id based on move_order_type
7311 -- associated with Move Order Line id.For scenarios where released_status
7312 -- and move_order_line_id are not passed to this API, first
7313 -- derive those from wsh_delivery_details and then proceed.
7314 --
7315 PROCEDURE get_putaway_detail_id(
7316 p_detail_id IN NUMBER,
7317 p_released_status IN VARCHAR2,
7318 p_move_order_line_id IN NUMBER,
7319 x_detail_id OUT NOCOPY NUMBER,
7320 x_return_status OUT NOCOPY VARCHAR2) IS
7321
7322 CURSOR c_get_line_details IS
7323 SELECT released_status,
7324 move_order_line_id
7325 FROM wsh_delivery_details
7326 WHERE delivery_detail_id = p_detail_id;
7327
7328 l_line_details c_get_line_details%ROWTYPE;
7329 l_released_status WSH_DELIVERY_DETAILS.RELEASED_STATUS%TYPE;
7330 l_move_order_line_id WSH_DELIVERY_DETAILS.MOVE_ORDER_LINE_ID%TYPE;
7331
7332 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PACKAGE_NAME || '.' || 'get_putaway_detail_id';
7333 l_debug_on BOOLEAN;
7334
7335 BEGIN
7336
7337 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
7338 --
7339 IF l_debug_on IS NULL THEN
7340 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
7341 END IF;
7342 --
7343 IF l_debug_on THEN
7344 WSH_DEBUG_SV.push(l_module_name);
7345 WSH_DEBUG_SV.log(l_module_name,'p_detail_id',p_detail_id);
7346 WSH_DEBUG_SV.log(l_module_name,'p_released_status',p_released_status);
7347 WSH_DEBUG_SV.log(l_module_name,'p_move_order_line_id',p_move_order_line_id);
7348 END IF;
7349
7350 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
7351 -- Check if released_status and move_order_line_id have been specified
7352 -- MOL can be null even if released status is specified.
7353 IF (p_detail_id is not null AND
7354 p_released_status IS NULL
7355 ) THEN
7356
7357 OPEN c_get_line_details;
7358 FETCH c_get_line_details
7359 INTO l_line_details;
7360 CLOSE c_get_line_details;
7361
7362 l_released_status := l_line_details.released_status;
7363 l_move_order_line_id := l_line_details.move_order_line_id;
7364 ELSE
7365 l_released_status := p_released_status;
7366 l_move_order_line_id := p_move_order_line_id;
7367 END IF;
7368
7369 -- normal Inventory scenario or Planned X-dock without MOL
7370 x_detail_id := NULL;
7371
7372 --Check only for line with released_status = 'S' and MOL is not null and MO type = PUTAWAY
7373 IF p_detail_id IS NOT NULL AND
7374 l_released_status = WSH_DELIVERY_DETAILS_PKG.C_RELEASED_TO_WAREHOUSE AND
7375 l_move_order_line_id IS NOT NULL AND
7376 wsh_usa_inv_pvt.is_mo_type_putaway (l_move_order_line_id) = 'Y' THEN
7377 x_detail_id := p_detail_id;
7378 END IF;
7379
7380 IF l_debug_on THEN
7381 WSH_DEBUG_SV.log(l_module_name,'x_detail_id',x_detail_id);
7382 WSH_DEBUG_SV.pop(l_module_name);
7383 END IF;
7384
7385 EXCEPTION
7386
7387 WHEN OTHERS THEN
7388 IF c_get_line_details%ISOPEN THEN
7389 CLOSE c_get_line_details;
7390 END IF;
7391 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7392 WSH_UTIL_CORE.DEFAULT_HANDLER('WSH_USA_INV_PVT.get_putaway_detail_id',l_module_name);
7393 IF l_debug_on THEN
7394 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
7395 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
7396 END IF;
7397 END get_putaway_detail_id;
7398
7399 END WSH_USA_INV_PVT;