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