1 PACKAGE BODY inv_ui_item_sub_loc_lovs AS
2 /* $Header: INVITPSB.pls 120.34.12020000.9 2013/01/30 10:51:31 dazhong ship $ */
3
4 g_pkg_name CONSTANT VARCHAR2(30) := 'INV_UI_ITEM_SUB_LOC_LOVS';
5
6 PROCEDURE debug(p_msg VARCHAR2) IS
7
8 BEGIN
9
10 inv_mobile_helper_functions.tracelog(
11 p_err_msg => p_msg,
12 p_module => g_pkg_name,
13 p_level => 4
14 );
15
16 END debug;
17
18 PROCEDURE update_locator(p_sub_code IN VARCHAR2, p_org_id IN NUMBER, p_locator_id IN NUMBER) IS
19 l_return_status VARCHAR2(10);
20 l_msg_count NUMBER;
21 l_msg_data VARCHAR2(20);
22 l_wms_org BOOLEAN;
23 l_sub_type NUMBER;
24 l_locator_status NUMBER;
25 l_loc_type NUMBER;
26 l_status_rec inv_material_status_pub.mtl_status_update_rec_type;
27 l_picking_order NUMBER;
28 -- Bug 9572628
29 l_physical_loc_id NUMBER;
30 l_phys_loc_segs VARCHAR2(1000);
31
32 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
33 BEGIN
34 IF (l_debug = 1) THEN
35 DEBUG('In the update locator');
36 END IF;
37 -- Bug 8649041, default status of the locator should be Active.
38 l_locator_status := 1;
39
40 --To check if it is wms org
41 /*Passing p_organization_id in below call as null as passing p_org_id was checking whether organization is wms
42 enabled or not and because of the updation logic was not working properly for non wms enabled organizations.
43 Here we need to check whether wms is installed or not.Bug # 6936019 */
44 --l_wms_org := wms_install.check_install(x_return_status => l_return_status, x_msg_count => l_msg_count, x_msg_data => l_msg_data, p_organization_id => p_org_id);
45
46 l_wms_org := wms_install.check_install(x_return_status => l_return_status, x_msg_count => l_msg_count, x_msg_data => l_msg_data, p_organization_id => NULL);
47
48 IF l_return_status <> fnd_api.g_ret_sts_success THEN
49 IF (l_debug = 1) THEN
50 DEBUG('Check if WMS installed');
51 END IF;
52 --RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
53 END IF;
54
55 -- Bug 9572628: determine locator type based on physical locator
56 BEGIN
57 SELECT physical_location_id
58 INTO l_physical_loc_id
59 FROM mtl_item_locations
60 WHERE organization_id = p_org_id
61 AND inventory_location_id = p_locator_id;
62 EXCEPTION
63 WHEN OTHERS THEN
64 IF (l_debug = 1) THEN
65 DEBUG('Error querying for physical_location_id: ' || SQLERRM);
66 END IF;
67 END;
68
69 IF (l_debug = 1) THEN
70 DEBUG('Physical locator ID: ' || l_physical_loc_id);
71 END IF;
72
73 IF NVL(l_physical_loc_id,0) > 0 THEN
74 BEGIN
75 SELECT inventory_location_type
76 , concatenated_segments
77 INTO l_loc_type
78 , l_phys_loc_segs
79 FROM mtl_item_locations_kfv
80 WHERE organization_id = p_org_id
81 AND inventory_location_id = l_physical_loc_id;
82 EXCEPTION
83 WHEN OTHERS THEN
84 DEBUG('Error querying locator type: ' || SQLERRM);
85 END;
86 END IF;
87
88 DEBUG('Phys. locator type: ' || l_loc_type || ', physical locator segments: ' || l_phys_loc_segs);
89
90 IF NVL(l_loc_type,0) = 0 THEN
91 -- get the sub type and based on it set the loc_type
92 SELECT NVL(subinventory_type,1)
93 INTO l_sub_type
94 FROM mtl_secondary_inventories
95 WHERE organization_id = p_org_id
96 AND secondary_inventory_name = p_sub_code;
97
98 IF l_sub_type = 2 THEN
99 -- Receiving sub hence set the locator type to receiving
100 l_loc_type := 6;
101 IF (l_debug = 1) THEN
102 DEBUG('Receiving sub hence set the locator type to receiving = ' || l_loc_type);
103 END IF;
104 ELSE
105 -- Storage sub hence set the locator type to storage
106 l_loc_type := 3;
107 IF (l_debug = 1) THEN
108 DEBUG('Storage sub hence set the locator type to storage = ' || l_loc_type);
109 END IF;
110 END IF; -- sub type check
111 END IF;
112
113 IF (l_debug = 1) THEN
114 DEBUG('Locator type: ' || l_loc_type);
115 END IF;
116 -- End bug 9572628
117
118 --If it is a WMS org get the default status ,picking order and set the locator type and insert status history
119 IF l_wms_org THEN
120 l_locator_status := inv_material_status_pkg.get_default_locator_status(p_org_id, p_sub_code);
121 --l_loc_type := 3;
122 l_status_rec.organization_id := p_org_id;
123 l_status_rec.inventory_item_id := NULL;
124 l_status_rec.lot_number := NULL;
125 l_status_rec.serial_number := NULL;
126 l_status_rec.update_method := inv_material_status_pub.g_update_method_manual;
127 l_status_rec.status_id := l_locator_status;
128 l_status_rec.zone_code := p_sub_code;
129 l_status_rec.locator_id := p_locator_id;
130 l_status_rec.creation_date := SYSDATE;
131 l_status_rec.created_by := fnd_global.user_id;
132 l_status_rec.last_update_date := SYSDATE;
133 l_status_rec.last_update_login := fnd_global.user_id;
134 l_status_rec.initial_status_flag := 'Y';
135 l_status_rec.from_mobile_apps_flag := 'Y';
136 IF (l_debug = 1) THEN
137 DEBUG('before inserting status history');
138 END IF;
139 inv_material_status_pkg.insert_status_history(l_status_rec);
140 IF (l_debug = 1) THEN
141 DEBUG('Status history inserted');
142 END IF;
143 END IF;
144
145 --Default the picking order from the org parameters
146 SELECT default_locator_order_value
147 INTO l_picking_order
148 FROM mtl_parameters
149 WHERE organization_id = p_org_id;
150
151 --Bug 8649041, stamping the WHO columns correctly.
152 --Bug 7143077 The creation date and created by should not be null for dynamic locators
153
154 UPDATE mtl_item_locations
155 SET created_by = NVL(created_by, fnd_global.user_id)
156 , creation_date = NVL(creation_date, SYSDATE)
157 , last_updated_by = fnd_global.user_id
158 , last_update_login = fnd_global.login_id
159 , last_update_date = SYSDATE
160 , subinventory_code = p_sub_code
161 , status_id = l_locator_status
162 , inventory_location_type = l_loc_type
163 , picking_order = l_picking_order
164 WHERE organization_id = p_org_id
165 AND inventory_location_id = p_locator_id;
166 END update_locator;
167
168
169 /** Changes done for Patchset J project -Receiving Locator Support and Item Based Putaway
170 * Added two new parameters - p_location_id and p_lpn_context
171 * p_location_id will be passed from Receiving Pages in which case we will show only
172 * Receiving Type subinventories.
173 * lpn context will be passed from Putaway page where there are two requirements -
174 * i. if lpn context = 3 then show all storage as well as receiving type subs
175 * ii. if lpn context = 1 then show only inventory type subinventories
176 * Added one more new parameter - p_putaway_code
177 * PutawayDropPage will use this parameter to indicate what type of
178 * subinventory should be shown:
179 * 1 - show only storage sub (with no restrictions)
180 * 2 - show only receiving sub
181 * 3 - show only lpn-controlled and reservable storage sub (for SO xdock)
182 * 4 - show only non-lpn-controlled and non-reservable storage sub (for
183 * wip xdock)
184 * NULL - show both storage sub and rcv sub, just like how it works before
185 */
186 --- Obsoleted
187 PROCEDURE get_sub_lov_rcv(
188 x_sub OUT NOCOPY t_genref
189 , p_organization_id IN NUMBER
190 , p_item_id IN NUMBER
191 , p_sub IN VARCHAR2
192 , p_restrict_subinventories_code IN NUMBER
193 , p_transaction_type_id IN NUMBER
194 , p_wms_installed IN VARCHAR2
195 , p_location_id IN NUMBER --RCVLOCATORSSUPPORT
196 , p_lpn_context IN NUMBER
197 , p_putaway_code IN NUMBER
198 ) IS --RCVLOCATORSSUPPORT
199 l_debug NUMBER;
200 l_procedure_name VARCHAR2(30);
201 BEGIN
202
203 l_debug := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
204 l_procedure_name := 'GET_SUB_LOV_RCV';
205
206 IF l_debug > 0 THEN
207 debug(l_procedure_name);
208 debug('p_lpn_context => ' || p_lpn_context);
209 debug('p_location_id => ' || p_location_id);
210 debug('p_putaway_code => ' || p_putaway_code);
211 END IF;
212 IF p_lpn_context = 3 THEN
213
214 IF (p_item_id IS NULL OR p_restrict_subinventories_code <> 1 ) THEN
215 OPEN x_sub FOR
216 SELECT msub.secondary_inventory_name
217 , NVL(msub.locator_type, 1)
218 , msub.description
219 , msub.asset_inventory
220 , msub.lpn_controlled_flag
221 , nvl(msub.subinventory_type, 1)
222 , msub.reservable_type
223 , msub.enable_locator_alias
224 FROM mtl_secondary_inventories msub
225 WHERE msub.organization_id = p_organization_id
226 AND Nvl(subinventory_type,1) = Decode(p_putaway_code,
227 2, --Don't show any storage sub
228 -1,--if system suggested a RCV sub
229 1)
230 AND Nvl(lpn_controlled_flag,-1) = Decode(p_putaway_code,
231 3,--For SO xdock, sub must be
232 1,--LPN controlled
233 Decode(p_putaway_code,
234 4,--For WIP xdock, sub must
235 2,--NOT be LPN controlled
236 Nvl(lpn_controlled_flag,-1)))
237 AND reservable_type = Decode(p_putaway_code,
238 3,--For SO xdock, sub must be
239 1,--reservable
240 Decode(p_putaway_code,
241 4,--For WIP xdock, sub must
242 2,--not be reservable
243 reservable_type))
244 AND NVL(msub.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
245 AND msub.secondary_inventory_name LIKE (p_sub)
246 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_item_id, msub.secondary_inventory_name, NULL, NULL, NULL, 'Z') = 'Y'
247 UNION ALL
248 SELECT msub.secondary_inventory_name
249 , NVL(msub.locator_type, 1)
250 , msub.description
251 , msub.asset_inventory
252 , lpn_controlled_flag
253 , Nvl(subinventory_type, 1)
254 , reservable_type
255 , enable_locator_alias
256 FROM mtl_secondary_inventories msub
257 WHERE organization_id = p_organization_id
258 AND Nvl(subinventory_type,1) = Decode(p_putaway_code,
259 2,--Only show rcv sub if the
260 2,--system has suggested a rcv sub
261 Decode(p_putaway_code,
262 NULL,
263 2,
264 -1))
265 AND msub.secondary_inventory_name LIKE (p_sub)
266 AND (trunc(disable_date + (300*365)) >= trunc(SYSDATE) OR
267 disable_date = TO_DATE('01/01/1700','DD/MM/RRRR'))
268 ORDER BY 1;
269
270 ELSE -- It is a restricted item,
271 OPEN x_sub FOR
272 SELECT msub.secondary_inventory_name
273 , NVL(msub.locator_type, 1)
274 , msub.description
275 , msub.asset_inventory
276 , lpn_controlled_flag
277 , Nvl(subinventory_type, 1)
278 , reservable_type
279 , enable_locator_alias
280 FROM mtl_secondary_inventories msub
281 WHERE msub.organization_id = p_organization_id
282 AND NVL(msub.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
283 AND msub.secondary_inventory_name LIKE (p_sub)
284 AND Nvl(msub.subinventory_type,1) = Decode(p_putaway_code,
285 2, --Don't show any storage sub
286 -1,--if system suggested a RCV sub
287 1)
288 AND Nvl(msub.lpn_controlled_flag,-1) = Decode(p_putaway_code,
289 3,--For SO xdock, sub must be
290 1,--LPN controlled
291 Decode(p_putaway_code,
292 4,--For WIP xdock, sub must
293 2,--NOT be LPN controlled
294 Nvl(msub.lpn_controlled_flag,-1)))
295 AND msub.reservable_type = Decode(p_putaway_code,
296 3,--For SO xdock, sub must be
297 1,--reservable
298 Decode(p_putaway_code,
299 4,--For WIP xdock, sub must
300 2,--not be reservable
301 msub.reservable_type))
302
303 AND EXISTS( SELECT NULL
304 FROM mtl_item_sub_inventories mis
305 WHERE mis.organization_id = NVL(p_organization_id, mis.organization_id)
306 AND mis.inventory_item_id = p_item_id
307 AND mis.secondary_inventory = msub.secondary_inventory_name)
308 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_item_id, msub.secondary_inventory_name, NULL, NULL, NULL, 'Z') = 'Y'
309 UNION ALL
310 SELECT msub.secondary_inventory_name
311 , NVL(msub.locator_type, 1)
312 , msub.description
313 , msub.asset_inventory
314 , lpn_controlled_flag
315 , Nvl(subinventory_type, 1)
316 , reservable_type
317 , enable_locator_alias
318 FROM mtl_secondary_inventories msub
319 WHERE msub.organization_id = p_organization_id
320 AND Nvl(msub.subinventory_type,1) = Decode(p_putaway_code,
321 2,--Only show rcv sub if the
322 2,--system has suggested a rcv sub
323 Decode(p_putaway_code,
324 NULL,
325 2,
326 -1))
327 AND msub.secondary_inventory_name LIKE (p_sub)
328 AND (trunc(disable_date + (300*365)) >= trunc(SYSDATE) OR
329 disable_date = TO_DATE('01/01/1700','DD/MM/RRRR'))
330 ORDER BY 1;
331
332 END IF;
333 ELSIF (p_lpn_context IN (1,2) OR p_lpn_context IS NULL) AND p_location_id IS NULL THEN
334 IF (p_item_id IS NULL
335 OR p_restrict_subinventories_code <> 1
336 ) THEN
337 OPEN x_sub FOR
338 SELECT msub.secondary_inventory_name
339 , NVL(msub.locator_type, 1)
340 , msub.description
341 , msub.asset_inventory
342 , lpn_controlled_flag
343 , Nvl(subinventory_type, 1)
344 , reservable_type
345 , enable_locator_alias
346 FROM mtl_secondary_inventories msub
347 WHERE msub.organization_id = p_organization_id
348 AND NVL(msub.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
349 AND msub.secondary_inventory_name LIKE (p_sub)
350 AND Nvl(msub.lpn_controlled_flag,-1) = Decode(p_lpn_context,
351 2,
352 Decode(p_putaway_code,
353 3,
354 1,
355 Decode(p_putaway_code,
356 4,
357 2,
358 Nvl(msub.lpn_controlled_flag,-1))
359 ),
360 Nvl(msub.lpn_controlled_flag,-1)
361 )
362 AND msub.reservable_type = Decode(p_lpn_context,
363 2,
364 Decode(p_putaway_code,
365 3,
366 1,
367 Decode(p_putaway_code,
368 4,
369 2,
370 msub.reservable_type)
371 ),
372 msub.reservable_type
373 )
374 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_item_id, msub.secondary_inventory_name, NULL, NULL, NULL, 'Z') = 'Y'
375 ORDER BY UPPER(msub.secondary_inventory_name);
376 ELSE
377 -- It is a restricted item,
378 OPEN x_sub FOR
379 SELECT msub.secondary_inventory_name
380 , NVL(msub.locator_type, 1)
381 , msub.description
382 , msub.asset_inventory
383 , lpn_controlled_flag
384 , Nvl(subinventory_type, 1)
385 , reservable_type
386 , enable_locator_alias
387 FROM mtl_secondary_inventories msub
388 WHERE msub.organization_id = p_organization_id
389 AND NVL(msub.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
390 AND msub.secondary_inventory_name LIKE (p_sub)
391 AND Nvl(msub.lpn_controlled_flag,-1) = Decode(p_lpn_context,
392 2,
393 Decode(p_putaway_code,
394 3,-- SO XDOCK
395 1,--Must be LPN controlled
396 Decode(p_putaway_code,
397 4,--WIP XDOCK
398 2,--Must be non LPN controlled
399 Nvl(msub.lpn_controlled_flag,-1))
400 ),
401 Nvl(msub.lpn_controlled_flag,-1)
402 )
403 AND msub.reservable_type = Decode(p_lpn_context,
404 2,
405 Decode(p_putaway_code,
406 3,--SO XDOCK
407 1,--Must be reservable
408 Decode(p_putaway_code,
409 4,--WIP XDOCK
410 2,--Must be non reservable
411 msub.reservable_type)
412 ),
413 msub.reservable_type
414 )
415 AND EXISTS( SELECT NULL
416 FROM mtl_item_sub_inventories mis
417 WHERE mis.organization_id = NVL(p_organization_id, mis.organization_id)
418 AND mis.inventory_item_id = p_item_id
419 AND mis.secondary_inventory = msub.secondary_inventory_name)
420 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_item_id, msub.secondary_inventory_name, NULL, NULL, NULL, 'Z') = 'Y'
421 ORDER BY UPPER(msub.secondary_inventory_name);
422 END IF;
423 ELSIF p_location_id IS NOT NULL THEN
424 -- For Putaway, p_location_id will always be null, so no change
425 -- is needed below
426 OPEN x_sub FOR
427 SELECT msub.secondary_inventory_name
428 , NVL(msub.locator_type, 1)
429 , msub.description
430 , msub.asset_inventory
431 , lpn_controlled_flag
432 , Nvl(subinventory_type, 1)
433 , reservable_type
434 , enable_locator_alias
435 FROM mtl_secondary_inventories msub
436 WHERE organization_id = p_organization_id
437 AND subinventory_type = 2
438 AND msub.secondary_inventory_name LIKE (p_sub)
439 AND location_id = p_location_id
440 AND (trunc(disable_date + (300*365)) >= trunc(SYSDATE) OR
441 disable_date = TO_DATE('01/01/1700','DD/MM/RRRR'))
442 ORDER BY UPPER(msub.secondary_inventory_name);
443 END IF;
444 END get_sub_lov_rcv;
445
446
447 --- Start of 11884687 code
448 PROCEDURE get_exp_asn_sub_lov_rcv(
449 x_sub OUT NOCOPY t_genref
450 , p_organization_id IN NUMBER
451 , p_item_id IN NUMBER
452 , p_sub IN VARCHAR2
453 , p_restrict_subinventories_code IN NUMBER
454 , p_transaction_type_id IN NUMBER
455 , p_wms_installed IN VARCHAR2
456 , p_location_id IN NUMBER --RCVLOCATORSSUPPORT
457 , p_shipment_header_id IN NUMBER
458 , p_lpn_context IN NUMBER
459 , p_putaway_code IN NUMBER
460 ) IS --RCVLOCATORSSUPPORT
461 l_debug NUMBER;
462 l_procedure_name VARCHAR2(30);
463 BEGIN
464
465 l_debug := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
466 l_procedure_name := 'GET_SUB_LOV_RCV';
467
468 IF l_debug > 0 THEN
469 debug(l_procedure_name);
470 debug('xxxxxxxxxxxxxxxxxxxxxxxxxxxx p_lpn_context => ' || p_lpn_context);
471 debug('p_location_id => ' || p_location_id);
472 debug('p_putaway_code => ' || p_putaway_code);
473 debug('p_organization_id => ' || p_organization_id);
474 debug('p_item_id => ' || p_item_id);
475 debug('p_sub => ' || p_sub);
476 debug('p_transaction_type_id => ' || p_transaction_type_id);
477 debug('p_wms_installed => ' || p_wms_installed);
478 debug('p_putaway_code => ' || p_putaway_code);
479 debug('p_shipment_header_id => ' || p_shipment_header_id);
480 END IF;
481 IF p_lpn_context = 3 THEN
482
483 IF (p_item_id IS NULL OR p_restrict_subinventories_code <> 1 ) THEN
484 OPEN x_sub FOR
485 SELECT msub.secondary_inventory_name
486 , NVL(msub.locator_type, 1)
487 , msub.description
488 , msub.asset_inventory
489 , msub.lpn_controlled_flag
490 , nvl(msub.subinventory_type, 1)
491 , msub.reservable_type
492 , msub.enable_locator_alias
493 FROM mtl_secondary_inventories msub
494 WHERE msub.organization_id = p_organization_id
495 AND Nvl(subinventory_type,1) = Decode(p_putaway_code,
496 2, --Don't show any storage sub
497 -1,--if system suggested a RCV sub
498 1)
499 AND Nvl(lpn_controlled_flag,-1) = Decode(p_putaway_code,
500 3,--For SO xdock, sub must be
501 1,--LPN controlled
502 Decode(p_putaway_code,
503 4,--For WIP xdock, sub must
504 2,--NOT be LPN controlled
505 Nvl(lpn_controlled_flag,-1)))
506 AND reservable_type = Decode(p_putaway_code,
507 3,--For SO xdock, sub must be
508 1,--reservable
509 Decode(p_putaway_code,
510 4,--For WIP xdock, sub must
511 2,--not be reservable
512 reservable_type))
513 AND NVL(msub.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
514 AND msub.secondary_inventory_name LIKE (p_sub)
515 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_item_id, msub.secondary_inventory_name, NULL, NULL, NULL, 'Z') = 'Y'
516 UNION ALL
517 SELECT msub.secondary_inventory_name
518 , NVL(msub.locator_type, 1)
519 , msub.description
520 , msub.asset_inventory
521 , lpn_controlled_flag
522 , Nvl(subinventory_type, 1)
523 , reservable_type
524 , enable_locator_alias
525 FROM mtl_secondary_inventories msub
526 WHERE organization_id = p_organization_id
527 AND Nvl(subinventory_type,1) = Decode(p_putaway_code,
528 2,--Only show rcv sub if the
529 2,--system has suggested a rcv sub
530 Decode(p_putaway_code,
531 NULL,
532 2,
533 -1))
534 AND msub.secondary_inventory_name LIKE (p_sub)
535 AND (trunc(disable_date + (300*365)) >= trunc(SYSDATE) OR
536 disable_date = TO_DATE('01/01/1700','DD/MM/RRRR'))
537 ORDER BY 1;
538
539 ELSE -- It is a restricted item,
540 OPEN x_sub FOR
541 SELECT msub.secondary_inventory_name
542 , NVL(msub.locator_type, 1)
543 , msub.description
544 , msub.asset_inventory
545 , lpn_controlled_flag
546 , Nvl(subinventory_type, 1)
547 , reservable_type
548 , enable_locator_alias
549 FROM mtl_secondary_inventories msub
550 WHERE msub.organization_id = p_organization_id
551 AND NVL(msub.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
552 AND msub.secondary_inventory_name LIKE (p_sub)
553 AND Nvl(msub.subinventory_type,1) = Decode(p_putaway_code,
554 2, --Don't show any storage sub
555 -1,--if system suggested a RCV sub
556 1)
557 AND Nvl(msub.lpn_controlled_flag,-1) = Decode(p_putaway_code,
558 3,--For SO xdock, sub must be
559 1,--LPN controlled
560 Decode(p_putaway_code,
561 4,--For WIP xdock, sub must
562 2,--NOT be LPN controlled
563 Nvl(msub.lpn_controlled_flag,-1)))
564 AND msub.reservable_type = Decode(p_putaway_code,
565 3,--For SO xdock, sub must be
566 1,--reservable
567 Decode(p_putaway_code,
568 4,--For WIP xdock, sub must
569 2,--not be reservable
570 msub.reservable_type))
571
572 AND EXISTS( SELECT NULL
573 FROM mtl_item_sub_inventories mis
574 WHERE mis.organization_id = NVL(p_organization_id, mis.organization_id)
575 AND mis.inventory_item_id = p_item_id
576 AND mis.secondary_inventory = msub.secondary_inventory_name)
577 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_item_id, msub.secondary_inventory_name, NULL, NULL, NULL, 'Z') = 'Y'
578 UNION ALL
579 SELECT msub.secondary_inventory_name
580 , NVL(msub.locator_type, 1)
581 , msub.description
582 , msub.asset_inventory
583 , lpn_controlled_flag
584 , Nvl(subinventory_type, 1)
585 , reservable_type
586 , enable_locator_alias
587 FROM mtl_secondary_inventories msub
588 WHERE msub.organization_id = p_organization_id
589 AND Nvl(msub.subinventory_type,1) = Decode(p_putaway_code,
590 2,--Only show rcv sub if the
591 2,--system has suggested a rcv sub
592 Decode(p_putaway_code,
593 NULL,
594 2,
595 -1))
596 AND msub.secondary_inventory_name LIKE (p_sub)
597 AND (trunc(disable_date + (300*365)) >= trunc(SYSDATE) OR
598 disable_date = TO_DATE('01/01/1700','DD/MM/RRRR'))
599 ORDER BY 1;
600
601 END IF;
602 ELSIF (p_lpn_context IN (1,2) OR p_lpn_context IS NULL) AND p_location_id IS NULL THEN
603 IF (p_item_id IS NULL
604 OR p_restrict_subinventories_code <> 1
605 ) THEN
606 OPEN x_sub FOR
607 SELECT msub.secondary_inventory_name
608 , NVL(msub.locator_type, 1)
609 , msub.description
610 , msub.asset_inventory
611 , lpn_controlled_flag
612 , Nvl(subinventory_type, 1)
613 , reservable_type
614 , enable_locator_alias
615 FROM mtl_secondary_inventories msub
616 WHERE msub.organization_id = p_organization_id
617 AND NVL(msub.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
618 AND msub.secondary_inventory_name LIKE (p_sub)
619 AND Nvl(msub.lpn_controlled_flag,-1) = Decode(p_lpn_context,
620 2,
621 Decode(p_putaway_code,
622 3,
623 1,
624 Decode(p_putaway_code,
625 4,
626 2,
627 Nvl(msub.lpn_controlled_flag,-1))
628 ),
629 Nvl(msub.lpn_controlled_flag,-1)
630 )
631 AND msub.reservable_type = Decode(p_lpn_context,
632 2,
633 Decode(p_putaway_code,
634 3,
635 1,
636 Decode(p_putaway_code,
637 4,
638 2,
639 msub.reservable_type)
640 ),
641 msub.reservable_type
642 )
643 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_item_id, msub.secondary_inventory_name, NULL, NULL, NULL, 'Z') = 'Y'
644 ORDER BY UPPER(msub.secondary_inventory_name);
645 ELSE
646 -- It is a restricted item,
647 OPEN x_sub FOR
648 SELECT msub.secondary_inventory_name
649 , NVL(msub.locator_type, 1)
650 , msub.description
651 , msub.asset_inventory
652 , lpn_controlled_flag
653 , Nvl(subinventory_type, 1)
654 , reservable_type
655 , enable_locator_alias
656 FROM mtl_secondary_inventories msub
657 WHERE msub.organization_id = p_organization_id
658 AND NVL(msub.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
659 AND msub.secondary_inventory_name LIKE (p_sub)
660 AND Nvl(msub.lpn_controlled_flag,-1) = Decode(p_lpn_context,
661 2,
662 Decode(p_putaway_code,
663 3,-- SO XDOCK
664 1,--Must be LPN controlled
665 Decode(p_putaway_code,
666 4,--WIP XDOCK
667 2,--Must be non LPN controlled
668 Nvl(msub.lpn_controlled_flag,-1))
669 ),
670 Nvl(msub.lpn_controlled_flag,-1)
671 )
672 AND msub.reservable_type = Decode(p_lpn_context,
673 2,
674 Decode(p_putaway_code,
675 3,--SO XDOCK
676 1,--Must be reservable
677 Decode(p_putaway_code,
678 4,--WIP XDOCK
679 2,--Must be non reservable
680 msub.reservable_type)
681 ),
682 msub.reservable_type
683 )
684 AND EXISTS( SELECT NULL
685 FROM mtl_item_sub_inventories mis
686 WHERE mis.organization_id = NVL(p_organization_id, mis.organization_id)
687 AND mis.inventory_item_id = p_item_id
688 AND mis.secondary_inventory = msub.secondary_inventory_name)
689 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_item_id, msub.secondary_inventory_name, NULL, NULL, NULL, 'Z') = 'Y'
690 ORDER BY UPPER(msub.secondary_inventory_name);
691 END IF;
692 ELSIF p_location_id IS NOT NULL THEN
693 -- For Putaway, p_location_id will always be null, so no change
694 -- is needed below
695 OPEN x_sub FOR
696 SELECT msub.secondary_inventory_name
697 , NVL(msub.locator_type, 1)
698 , msub.description
699 , msub.asset_inventory
700 , lpn_controlled_flag
701 , Nvl(subinventory_type, 1)
702 , reservable_type
703 , enable_locator_alias
704 FROM mtl_secondary_inventories msub
705 WHERE organization_id = p_organization_id
706 AND subinventory_type = 2
707 AND msub.secondary_inventory_name LIKE (p_sub)
708 AND ((location_id = p_location_id) OR (location_id IN (SELECT distinct(hl.location_id)
709 -- into x_location_code
710 FROM hr_locations hl, rcv_shipment_lines rsl
711 WHERE hl.location_id = nvl(rsl.deliver_to_location_id,rsl.ship_to_location_id)--bug10349270 for ASN receipt,we should get the default location against RSL.ship_to_location
712 AND rsl.shipment_header_id = p_shipment_header_id
713 AND rsl.item_id = NVL(p_item_id, rsl.item_id)
714 AND rsl.to_organization_id = p_organization_id
715 --AND NVL(rsl.asn_lpn_id,-1) = NVL(p_from_lpn_id,NVL(rsl.asn_lpn_id,-1))
716 AND rsl.shipment_line_status_code IN ('EXPECTED','PARTIALLY RECEIVED'))))
717
718 AND (trunc(disable_date + (300*365)) >= trunc(SYSDATE) OR
719 disable_date = TO_DATE('01/01/1700','DD/MM/RRRR'))
720 ORDER BY UPPER(msub.secondary_inventory_name);
721 END IF;
722 END get_exp_asn_sub_lov_rcv; --End of 11884687 code
723 -- Name: GET_MO_FROMSUB_LOV
724 --
725 -- Input parameters:
726 -- p_organization_id OrgId
727 -- p_MOheader_id MoveOrder Header Id
728 -- p_subinv_code SubInventory Code
729 --
730 -- Output parameters:
731 -- x_fromsub_lov returns LOV rows as reference cursor
732 --
733 -- Functions: This API returns Transaction Reasons
734 --
735 ---- Obsolete
736 PROCEDURE get_mo_fromsub_lov(x_fromsub_lov OUT NOCOPY t_genref, p_organization_id IN NUMBER, p_moheader_id IN NUMBER, p_subinv_code IN VARCHAR) IS
737
738 BEGIN
739
740 OPEN x_fromsub_lov FOR
741 SELECT secondary_inventory_name
742 , NVL(locator_type, 1)
743 , description
744 , asset_inventory
745 , lpn_controlled_flag
746 , enable_locator_alias
747 FROM mtl_secondary_inventories
748 WHERE organization_id = p_organization_id
749 AND secondary_inventory_name IN (
750 SELECT from_subinventory_code
751 FROM mtl_txn_request_lines
752 WHERE header_id = p_moheader_id
753 )
754 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
755 AND secondary_inventory_name LIKE (p_subinv_code);
756
757 END get_mo_fromsub_lov;
758
759 -- Name: GET_MO_TOSUB_LOV
760 --
761 -- Input parameters:
762 -- p_organization_id OrgId
763 -- p_MOheader_id MoveOrder Header Id
764 -- p_subinv_code SubInventory Code
765 --
766 -- Output parameters:
767 -- x_tosub_lov returns LOV rows as reference cursor
768 --
769 -- Functions: This API returns Transaction Reasons
770 --
771 --- Obsolete
772 PROCEDURE get_mo_tosub_lov(x_tosub_lov OUT NOCOPY t_genref, p_organization_id IN NUMBER, p_moheader_id IN NUMBER, p_subinv_code IN VARCHAR) IS
773 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
774 BEGIN
775 OPEN x_tosub_lov FOR
776 SELECT secondary_inventory_name
777 , NVL(locator_type, 1)
778 , description
779 , asset_inventory
780 , lpn_controlled_flag
781 , enable_locator_alias
782 FROM mtl_secondary_inventories
783 WHERE organization_id = p_organization_id
784 AND secondary_inventory_name IN (SELECT to_subinventory_code
785 FROM mtl_txn_request_lines
786 WHERE header_id = p_moheader_id)
787 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
788 AND secondary_inventory_name LIKE (p_subinv_code);
789 END;
790
791 -- Name: GET_LOC_LOV
792 --
793 -- Input parameters:
794 -- p_Organization_Id which restricts LOV SQL to current org
795 -- p_Concatenated_Segments which restricts LOV SQL to the user input text
796 -- e.g. 1-1%
797 -- p_Inventory_item_id restrict to those item restricted locators
798 -- p_Subinventory_Code restrict to this sub
799 -- p_restrict_Locators_code item restricted locator flag
800 --
801 -- Output parameters:
802 -- x_sub returns LOV rows as reference cursor
803 --
804 -- Functions: This API is to returns locator for given org and sub
805 -- It returns different LOVs for item-restricted locator
806 --
807 PROCEDURE get_loc_lov(
808 x_locators OUT NOCOPY t_genref
809 , p_organization_id IN NUMBER
810 , p_subinventory_code IN VARCHAR2
811 , p_restrict_locators_code IN NUMBER
812 , p_inventory_item_id IN NUMBER
813 , p_concatenated_segments IN VARCHAR2
814 , p_transaction_type_id IN NUMBER
815 , p_wms_installed IN VARCHAR2
816 ) IS
817 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
818 BEGIN
819 IF (l_debug = 1) THEN
820 inv_log_util.TRACE('Im in GET_pick_LOV', 'WMS_LPN_LOVs', 9);
821 END IF;
822
823 IF p_restrict_locators_code = 1 THEN --Locators restricted to predefined list
824 OPEN x_locators FOR
825 SELECT a.inventory_location_id
826 --, a.concatenated_segments----Bug4398337:Commented this line and added below line
827 , a.locator_segments concatenated_segments
828 , a.description
829 FROM wms_item_locations_kfv a, mtl_secondary_locators b
830 WHERE b.organization_id = p_organization_id
831 AND b.inventory_item_id = p_inventory_item_id
832 AND NVL(a.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
833 AND b.subinventory_code = p_subinventory_code
834 AND a.inventory_location_id = b.secondary_locator
835 and a.organization_id = b.organization_id --13472820
836 AND a.concatenated_segments LIKE (p_concatenated_segments)
837 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, a.inventory_location_id, NULL, NULL, 'L') = 'Y'
838 ORDER BY a.concatenated_segments;
839 ELSE --Locators not restricted
840 OPEN x_locators FOR
841 SELECT inventory_location_id
842 -- , concatenated_segments--Bug4398337:Commented this line and added below line
843 , locator_segments concatenated_segments
844 , description
845 FROM wms_item_locations_kfv
846 WHERE organization_id = p_organization_id
847 AND subinventory_code = p_subinventory_code
848 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
849 AND concatenated_segments LIKE (p_concatenated_segments)
850 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, inventory_location_id, NULL, NULL, 'L') = 'Y'
851 ORDER BY concatenated_segments;
852 END IF;
853 END get_loc_lov;
854
855 -- Name: GET_LOC_LOV_PJM
856 --
857 -- Input parameters:
858 -- p_Organization_Id which restricts LOV SQL to current org
859 -- p_Concatenated_Segments which restricts LOV SQL to the user input text
860 -- e.g. 1-1%
861 -- p_Inventory_item_id restrict to those item restricted locators
862 -- p_Subinventory_Code restrict to this sub
863 -- p_restrict_Locators_code item restricted locator flag
864 --
865 -- Output parameters:
866 -- x_sub returns LOV rows as reference cursor and the concatenated segments
867 -- returned doesnt contain SEGMENT 19 and 20.
868 --
869 -- Functions: This API is to returns locator for given org and sub.
870 -- The concatenated segments returned doesnt contain SEGMENT 19 and 20.
871 -- It returns different LOVs for item-restricted locator
872 --
873
874 PROCEDURE get_loc_lov_pjm(
875 x_locators OUT NOCOPY t_genref
876 , p_organization_id IN NUMBER
877 , p_subinventory_code IN VARCHAR2
878 , p_restrict_locators_code IN NUMBER
879 , p_inventory_item_id IN NUMBER
880 , p_concatenated_segments IN VARCHAR2
881 , p_transaction_type_id IN NUMBER
882 , p_wms_installed IN VARCHAR2
883 ) IS
884 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
885 BEGIN
886 IF (l_debug = 1) THEN
887 inv_trx_util_pub.TRACE('Im in GET_LOC_LOV_PJM', 'WMS_LPN_LOVs', 9);
888 END IF;
889
890 IF p_restrict_locators_code = 1 THEN --Locators restricted to predefined list
891 OPEN x_locators FOR
892 SELECT a.inventory_location_id
893 --, a.concatenated_segments concatenated_segments--Bug4398337:Commented this line and added below line
894 , a.locator_segments concatenated_segments
895 , a.description
896 FROM wms_item_locations_kfv a, mtl_secondary_locators b
897 WHERE b.organization_id = p_organization_id
898 AND b.inventory_item_id = p_inventory_item_id
899 AND NVL(a.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
900 AND b.subinventory_code = p_subinventory_code
901 AND a.inventory_location_id = b.secondary_locator
902 and a.organization_id = b.organization_id --13472820
903 AND a.project_id IS NULL
904 AND a.task_id IS NULL
905 AND a.concatenated_segments LIKE (p_concatenated_segments)
906 AND NVL(a.physical_location_id, a.inventory_location_id) = a.inventory_location_id
907 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, a.inventory_location_id, NULL, NULL, 'L') = 'Y'
908 ORDER BY 2;
909 ELSE --Locators not restricted
910 OPEN x_locators FOR
911 SELECT inventory_location_id
912 --, concatenated_segments concatenated_segments--Bug4398337:Commented this line and added below line
913 , locator_segments concatenated_segments
914 , description
915 FROM wms_item_locations_kfv
916 WHERE organization_id = p_organization_id
917 AND subinventory_code = p_subinventory_code
918 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
919 AND concatenated_segments LIKE (p_concatenated_segments)
920 AND project_id IS NULL
921 AND task_id IS NULL
922 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, inventory_location_id, NULL, NULL, 'L') = 'Y'
923 ORDER BY 2;
924 END IF;
925 END get_loc_lov_pjm;
926
927 ------------------------------------------------
928 -- GET_INQ_LOC_LOV for inquiry form.
929 -------------------------------------------------
930 PROCEDURE get_inq_loc_lov(
931 x_locators OUT NOCOPY t_genref
932 , p_organization_id IN NUMBER
933 , p_subinventory_code IN VARCHAR2
934 , p_restrict_locators_code IN NUMBER
935 , p_inventory_item_id IN NUMBER
936 , p_concatenated_segments IN VARCHAR2
937 , p_project_id IN NUMBER := NULL
938 , p_task_id IN NUMBER := NULL
939 ) IS
940 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
941 l_ispjm_org VARCHAR2(1);
942 BEGIN
943 BEGIN
944 SELECT nvl(PROJECT_REFERENCE_ENABLED,'N')
945 INTO l_ispjm_org
946 FROM pjm_org_parameters
947 WHERE organization_id=p_organization_id;
948 EXCEPTION
949 WHEN NO_DATA_FOUND THEN
950 l_ispjm_org:='N';
951 END;
952 IF l_ispjm_org='N'THEN
953 IF p_Restrict_Locators_Code = 1 THEN --Locators restricted to predefined list
954 OPEN x_Locators FOR
955 SELECT a.inventory_location_id,
956 --a.concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
957 a.locator_segments locsegs,
958 a.description
959 FROM wms_item_locations_kfv a,
960 mtl_secondary_locators b
961 WHERE b.organization_id = p_Organization_Id
962 AND b.inventory_item_id = p_Inventory_Item_Id
963 AND b.subinventory_code = p_Subinventory_Code
964 AND a.inventory_location_id = b.secondary_locator
965 and a.organization_id = b.organization_id --13472820
966 and nvl(a.disable_date, trunc(sysdate+1)) > trunc(sysdate) /* 2915024 */
967 AND a.concatenated_segments LIKE (p_concatenated_segments )
968 /* BUG#28101405: To show only common locators in the LOV */
969 ORDER BY 2;
970
971 ELSE --Locators not restricted
972 --bug#3440453 Remove the NVL on organization_id if user passes it.
973 IF p_organization_id IS NULL THEN
974 OPEN x_Locators FOR
975 SELECT inventory_location_id,
976 -- concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
977 locator_segments locsegs,
978 description
979 FROM wms_item_locations_kfv
980 WHERE organization_id = Nvl(p_organization_id, organization_id)
981 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
982 and nvl(disable_date, trunc(sysdate+1)) > trunc(sysdate) /* 2915024 */
983 AND concatenated_segments LIKE (p_concatenated_segments)
984 ORDER BY 2;
985 ELSE -- Organization_id is not null
986 OPEN x_Locators FOR
987 SELECT inventory_location_id,
988 -- concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
989 locator_segments locsegs,
990 description
991 FROM wms_item_locations_kfv
992 WHERE organization_id = p_organization_id
993 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
994 and nvl(disable_date, trunc(sysdate+1)) > trunc(sysdate) /* 2915024 */
995 AND concatenated_segments LIKE (p_concatenated_segments)
996 ORDER BY 2;
997 END IF;
998 END IF;
999 ELSE /*PJM Org*/
1000 IF p_Restrict_Locators_Code = 1 THEN --Locators restricted to predefined list
1001 OPEN x_Locators FOR
1002 SELECT a.inventory_location_id,
1003 --a.concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
1004 a.locator_segments locsegs,
1005 a.description
1006 FROM wms_item_locations_kfv a,
1007 mtl_secondary_locators b
1008 WHERE b.organization_id = p_Organization_Id
1009 AND b.inventory_item_id = p_Inventory_Item_Id
1010 AND b.subinventory_code = p_Subinventory_Code
1011 AND a.inventory_location_id = b.secondary_locator
1012 and a.organization_id = b.organization_id --13472820
1013 and nvl(a.disable_date, trunc(sysdate+1)) > trunc(sysdate) /* 2915024 */
1014 AND a.inventory_location_id=NVL(a.physical_location_id,a.inventory_location_id)
1015 AND a.concatenated_segments LIKE (p_concatenated_segments )
1016 ORDER BY 2;
1017 ELSE --Locators not restricted
1018 --bug#3440453 Remove the NVL on organization_id if user passes it.
1019 IF p_organization_id IS NULL THEN
1020 OPEN x_Locators FOR
1021 SELECT inventory_location_id,
1022 -- concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
1023 locator_segments locsegs,
1024 description
1025 FROM wms_item_locations_kfv
1026 WHERE organization_id = Nvl(p_organization_id, organization_id)
1027 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
1028 and nvl(disable_date, trunc(sysdate+1)) > trunc(sysdate) /* 2915024 */
1029 AND concatenated_segments LIKE (p_concatenated_segments )
1030 AND inventory_location_id=NVL(physical_location_id,inventory_location_id)
1031 ORDER BY 2;
1032 ELSE -- Organization_id is not null
1033 OPEN x_Locators FOR
1034 SELECT inventory_location_id,
1035 -- concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
1036 locator_segments locsegs,
1037 description
1038 FROM wms_item_locations_kfv
1039 WHERE organization_id = p_organization_id
1040 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
1041 and nvl(disable_date, trunc(sysdate+1)) > trunc(sysdate) /* 2915024 */
1042 AND concatenated_segments LIKE (p_concatenated_segments )
1043 AND inventory_location_id=NVL(physical_location_id,inventory_location_id)
1044 ORDER BY 2;
1045 END IF;
1046 END IF;
1047 END IF;
1048 END get_inq_loc_lov;
1049 PROCEDURE get_inq_loc_lov(
1050 x_locators OUT NOCOPY t_genref
1051 , p_organization_id IN NUMBER
1052 , p_subinventory_code IN VARCHAR2
1053 , p_restrict_locators_code IN NUMBER
1054 , p_inventory_item_id IN NUMBER
1055 , p_concatenated_segments IN VARCHAR2
1056 , p_project_id IN NUMBER := NULL
1057 , p_task_id IN NUMBER := NULL
1058 , p_alias IN VARCHAR2
1059 ) IS
1060 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
1061 l_ispjm_org VARCHAR2(1);
1062 BEGIN
1063 IF p_alias IS NULL THEN
1064 get_inq_loc_lov(
1065 x_locators => x_locators
1066 , p_organization_id => p_organization_id
1067 , p_subinventory_code => p_subinventory_code
1068 , p_restrict_locators_code => p_restrict_locators_code
1069 , p_inventory_item_id => p_inventory_item_id
1070 , p_concatenated_segments => p_concatenated_segments
1071 , p_project_id => p_project_id
1072 , p_task_id => p_task_id
1073 );
1074 RETURN;
1075 END IF;
1076
1077 BEGIN
1078 SELECT nvl(PROJECT_REFERENCE_ENABLED,'N')
1079 INTO l_ispjm_org
1080 FROM pjm_org_parameters
1081 WHERE organization_id=p_organization_id;
1082 EXCEPTION
1083 WHEN NO_DATA_FOUND THEN
1084 l_ispjm_org:='N';
1085 END;
1086 IF l_ispjm_org='N'THEN
1087 IF p_Restrict_Locators_Code = 1 THEN --Locators restricted to predefined list
1088 OPEN x_Locators FOR
1089 SELECT a.inventory_location_id,
1090 --a.concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
1091 a.locator_segments locsegs,
1092 a.description
1093 FROM wms_item_locations_kfv a,
1094 mtl_secondary_locators b
1095 WHERE b.organization_id = p_Organization_Id
1096 AND b.inventory_item_id = p_Inventory_Item_Id
1097 AND b.subinventory_code = p_Subinventory_Code
1098 AND a.inventory_location_id = b.secondary_locator
1099 and a.organization_id = b.organization_id --13472820
1100 and nvl(a.disable_date, trunc(sysdate+1)) > trunc(sysdate) /* 2915024 */
1101 AND a.alias = p_alias
1102 /* BUG#28101405: To show only common locators in the LOV */
1103 ORDER BY 2;
1104
1105 ELSE --Locators not restricted
1106 --bug#3440453 Remove the NVL on organization_id if user passes it.
1107 IF p_organization_id IS NULL THEN
1108 OPEN x_Locators FOR
1109 SELECT inventory_location_id,
1110 -- concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
1111 locator_segments locsegs,
1112 description
1113 FROM wms_item_locations_kfv
1114 WHERE organization_id = Nvl(p_organization_id, organization_id)
1115 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
1116 and nvl(disable_date, trunc(sysdate+1)) > trunc(sysdate) /* 2915024 */
1117 AND alias = p_alias
1118 ORDER BY 2;
1119 ELSE -- Organization_id is not null
1120 OPEN x_Locators FOR
1121 SELECT inventory_location_id,
1122 -- concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
1123 locator_segments locsegs,
1124 description
1125 FROM wms_item_locations_kfv
1126 WHERE organization_id = p_organization_id
1127 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
1128 and nvl(disable_date, trunc(sysdate+1)) > trunc(sysdate) /* 2915024 */
1129 AND alias = p_alias
1130 ORDER BY 2;
1131 END IF;
1132 END IF;
1133 ELSE /*PJM Org*/
1134 IF p_Restrict_Locators_Code = 1 THEN --Locators restricted to predefined list
1135 OPEN x_Locators FOR
1136 SELECT a.inventory_location_id,
1137 --a.concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
1138 a.locator_segments locsegs,
1139 a.description
1140 FROM wms_item_locations_kfv a,
1141 mtl_secondary_locators b
1142 WHERE b.organization_id = p_Organization_Id
1143 AND b.inventory_item_id = p_Inventory_Item_Id
1144 AND b.subinventory_code = p_Subinventory_Code
1145 AND a.inventory_location_id = b.secondary_locator
1146 and a.organization_id = b.organization_id --13472820
1147 and nvl(a.disable_date, trunc(sysdate+1)) > trunc(sysdate) /* 2915024 */
1148 AND a.inventory_location_id=NVL(a.physical_location_id,a.inventory_location_id)
1149 AND a.alias = p_alias
1150 ORDER BY 2;
1151 ELSE --Locators not restricted
1152 --bug#3440453 Remove the NVL on organization_id if user passes it.
1153 IF p_organization_id IS NULL THEN
1154 OPEN x_Locators FOR
1155 SELECT inventory_location_id,
1156 -- concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
1157 locator_segments locsegs,
1158 description
1159 FROM wms_item_locations_kfv
1160 WHERE organization_id = Nvl(p_organization_id, organization_id)
1161 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
1162 and nvl(disable_date, trunc(sysdate+1)) > trunc(sysdate) /* 2915024 */
1163 AND alias = p_alias
1164 AND inventory_location_id=NVL(physical_location_id,inventory_location_id)
1165 ORDER BY 2;
1166 ELSE -- Organization_id is not null
1167 OPEN x_Locators FOR
1168 SELECT inventory_location_id,
1169 -- concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
1170 locator_segments locsegs,
1171 description
1172 FROM wms_item_locations_kfv
1173 WHERE organization_id = p_organization_id
1174 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
1175 and nvl(disable_date, trunc(sysdate+1)) > trunc(sysdate) /* 2915024 */
1176 AND alias = p_alias
1177 AND inventory_location_id=NVL(physical_location_id,inventory_location_id)
1178 ORDER BY 2;
1179 END IF;
1180 END IF;
1181 END IF;
1182 END get_inq_loc_lov;
1183
1184 -- This returns the locator id for an existing locator and if
1185 -- it does not exist then it creates a new one.
1186 PROCEDURE get_dynamic_locator(x_location_id OUT NOCOPY NUMBER, x_description OUT NOCOPY VARCHAR2, x_result OUT NOCOPY VARCHAR2, x_exist_or_create OUT NOCOPY VARCHAR2, p_org_id IN NUMBER, p_sub_code IN VARCHAR2, p_concat_segs IN VARCHAR2) IS
1187 l_keystat_val BOOLEAN;
1188 l_sub_default_status NUMBER;
1189 l_validity_check VARCHAR2(10);
1190 l_wms_org BOOLEAN;
1191 l_loc_type NUMBER;
1192 l_return_status VARCHAR2(10);
1193 l_msg_count NUMBER;
1194 l_msg_data VARCHAR2(20);
1195 l_label_status VARCHAR2(20);
1196 l_status_rec inv_material_status_pub.mtl_status_update_rec_type; -- bug# 1695432
1197 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
1198 BEGIN
1199 x_result := 'S';
1200 l_validity_check := 'passed';
1201
1202 BEGIN
1203 SELECT inventory_location_id
1204 , description
1205 INTO x_location_id
1206 , x_description
1207 FROM wms_item_locations_kfv
1208 WHERE organization_id = p_org_id
1209 AND subinventory_code = p_sub_code
1210 AND concatenated_segments = p_concat_segs
1211 AND ROWNUM < 2;
1212
1213 x_exist_or_create := 'EXISTS';
1214 RETURN;
1215 EXCEPTION
1216 WHEN NO_DATA_FOUND THEN
1217 l_keystat_val :=
1218 fnd_flex_keyval.validate_segs(operation => 'CREATE_COMB_NO_AT', --changed for bug1881366
1219 appl_short_name => 'INV', key_flex_code => 'MTLL', structure_number => 101, concat_segments => p_concat_segs, values_or_ids => 'V', data_set => p_org_id);
1220
1221 IF (l_keystat_val = FALSE) THEN
1222 x_result := 'E';
1223 x_exist_or_create := '';
1224 RETURN;
1225 ELSE
1226 x_location_id := fnd_flex_keyval.combination_id;
1227 x_exist_or_create := 'EXISTS';
1228
1229 IF fnd_flex_keyval.new_combination THEN
1230 x_exist_or_create := 'CREATE';
1231
1232 IF p_sub_code IS NOT NULL THEN
1233 BEGIN
1234 --- check validity
1235 SELECT 'failed'
1236 INTO l_validity_check
1237 FROM DUAL
1238 WHERE EXISTS( SELECT subinventory_code
1239 FROM wms_item_locations_kfv
1240 WHERE concatenated_segments = p_concat_segs
1241 AND p_sub_code <> subinventory_code
1242 AND organization_id = p_org_id);
1243 EXCEPTION
1244 WHEN NO_DATA_FOUND THEN
1245 NULL;
1246 END;
1247
1248 IF l_validity_check = 'failed' THEN
1249 x_result := 'E';
1250 x_exist_or_create := '';
1251 RETURN;
1252 END IF;
1253
1254 SELECT NVL(default_loc_status_id, 1)
1255 INTO l_sub_default_status
1256 FROM mtl_secondary_inventories
1257 WHERE organization_id = p_org_id
1258 AND secondary_inventory_name = p_sub_code;
1259
1260 l_wms_org := wms_install.check_install(x_return_status => l_return_status, x_msg_count => l_msg_count, x_msg_data => l_msg_data, p_organization_id => p_org_id);
1261
1262 IF l_return_status = 'S' THEN
1263 IF l_wms_org THEN
1264 l_loc_type := 3;
1265 ELSE
1266 l_loc_type := NULL;
1267 END IF;
1268 ELSE
1269 x_result := 'E';
1270 x_exist_or_create := '';
1271 RETURN;
1272 END IF;
1273
1274 UPDATE mtl_item_locations
1275 SET subinventory_code = p_sub_code
1276 , status_id = l_sub_default_status
1277 , inventory_location_type = l_loc_type
1278 WHERE organization_id = p_org_id
1279 AND inventory_location_id = x_location_id;
1280 END IF;
1281 ELSE
1282 BEGIN
1283 --- check validity
1284 SELECT 'failed'
1285 INTO l_validity_check
1286 FROM DUAL
1287 WHERE EXISTS( SELECT subinventory_code
1288 FROM mtl_item_locations_kfv
1289 WHERE concatenated_segments = p_concat_segs
1290 AND p_sub_code <> subinventory_code
1291 AND organization_id = p_org_id);
1292 EXCEPTION
1293 WHEN NO_DATA_FOUND THEN
1294 NULL;
1295 END;
1296
1297 IF l_validity_check = 'failed' THEN
1298 x_result := 'E';
1299 x_exist_or_create := '';
1300 RETURN;
1301 END IF;
1302 END IF;
1303
1304 IF x_exist_or_create = 'CREATE' THEN
1305 -- If a new locator is created then create a status history for it, bug# 1695432
1306 l_status_rec.organization_id := p_org_id;
1307 l_status_rec.inventory_item_id := NULL;
1308 l_status_rec.lot_number := NULL;
1309 l_status_rec.serial_number := NULL;
1310 l_status_rec.update_method := inv_material_status_pub.g_update_method_manual;
1311 l_status_rec.status_id := l_sub_default_status;
1312 l_status_rec.zone_code := p_sub_code;
1313 l_status_rec.locator_id := x_location_id;
1314 l_status_rec.creation_date := SYSDATE;
1315 l_status_rec.created_by := fnd_global.user_id;
1316 l_status_rec.last_update_date := SYSDATE;
1317 l_status_rec.last_update_login := fnd_global.user_id;
1318 l_status_rec.initial_status_flag := 'Y';
1319 l_status_rec.from_mobile_apps_flag := 'Y';
1320 inv_material_status_pkg.insert_status_history(l_status_rec);
1321 -- If a new locator is created, call label printing API
1322
1323 IF (l_debug = 1) THEN
1324 inv_mobile_helper_functions.tracelog(p_err_msg => 'Before calling label printing in dynamic locator generation', p_module => 'Dynamic Locator', p_level => 3);
1325 END IF;
1326 inv_label.print_label_manual_wrap(
1327 x_return_status => l_return_status
1328 , x_msg_count => l_msg_count
1329 , x_msg_data => l_msg_data
1330 , x_label_status => l_label_status
1331 , p_business_flow_code => 24
1332 , p_organization_id => p_org_id
1333 , p_subinventory_code => p_sub_code
1334 , p_locator_id => x_location_id
1335 );
1336 IF (l_debug = 1) THEN
1337 inv_mobile_helper_functions.tracelog(p_err_msg => 'After calling label printing in dynamic locator generation, status=' || l_return_status, p_module => 'Dynamic Locator', p_level => 3);
1338 END IF;
1339 END IF;
1340 END IF;
1341 END;
1342 END;
1343
1344 -- This procedure validates a locator
1345 PROCEDURE check_dynamic_locator(x_result OUT NOCOPY VARCHAR2, p_org_id IN NUMBER, p_sub_code IN VARCHAR2, p_inventory_location_id IN VARCHAR2) IS
1346 l_temp NUMBER;
1347 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
1348 BEGIN
1349 x_result := 'S';
1350
1351 BEGIN
1352 SELECT 1
1353 INTO l_temp
1354 FROM mtl_item_locations
1355 WHERE organization_id = p_org_id
1356 AND inventory_location_id = p_inventory_location_id;
1357 EXCEPTION
1358 WHEN NO_DATA_FOUND THEN
1359 x_result := 'U';
1360 END;
1361 END;
1362
1363 --
1364 --
1365 PROCEDURE get_valid_to_locs(
1366 x_locators OUT NOCOPY t_genref
1367 , p_transaction_action_id IN NUMBER
1368 , p_to_organization_id IN NUMBER
1369 , p_organization_id IN NUMBER
1370 , p_subinventory_code IN VARCHAR2
1371 , p_restrict_locators_code IN NUMBER
1372 , p_inventory_item_id IN NUMBER
1373 , p_concatenated_segments IN VARCHAR2
1374 , p_transaction_type_id IN NUMBER
1375 , p_wms_installed IN VARCHAR2
1376 ) IS
1377 l_org NUMBER;
1378 l_restrict_locators_code NUMBER;
1379 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
1380 BEGIN
1381 IF p_transaction_action_id IN (3, 21) THEN
1382 l_org := p_to_organization_id;
1383
1384 SELECT restrict_locators_code
1385 INTO l_restrict_locators_code
1386 FROM mtl_system_items
1387 WHERE inventory_item_id = p_inventory_item_id
1388 AND organization_id = l_org;
1389 ELSE
1390 l_org := p_organization_id;
1391 l_restrict_locators_code := p_restrict_locators_code;
1392 END IF;
1393
1394 get_loc_lov(x_locators, l_org, p_subinventory_code, l_restrict_locators_code, p_inventory_item_id, p_concatenated_segments, p_transaction_type_id, p_wms_installed);
1395 END;
1396
1397 -- Name: GET_MO_FROMLOC_LOV
1398 --
1399 -- Input parameters:
1400 -- p_Organization_Id which restricts LOV SQL to current org
1401 -- p_Concatenated_Segments which restricts LOV SQL to user input text
1402 -- e.g. 1-1%
1403 --
1404 -- Output parameters:
1405 -- x_Locators returns LOV rows as reference cursor
1406 --
1407 -- Functions: This API is to return "src" locator for a given MO
1408 --
1409 PROCEDURE get_mo_fromloc_lov(x_locators OUT NOCOPY t_genref, p_organization_id IN NUMBER, p_moheader_id IN NUMBER, p_concatenated_segments IN VARCHAR2, p_project_id IN NUMBER := NULL, p_task_id IN NUMBER := NULL) IS
1410 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
1411 BEGIN
1412 OPEN x_locators FOR
1413 SELECT mil.inventory_location_id
1414 --, mil.concatenated_segments conseg--Bug4398337:Commented this line and added below line
1415 , mil.locator_segments conseg
1416 , mil.description
1417 FROM wms_item_locations_kfv mil
1418 WHERE mil.organization_id = p_organization_id
1419 AND mil.inventory_location_id IN (SELECT from_locator_id
1420 FROM mtl_txn_request_lines
1421 WHERE header_id = p_moheader_id)
1422 AND mil.concatenated_segments LIKE (p_concatenated_segments)
1423 AND NVL(mil.project_id, -9999) = NVL(p_project_id, -9999)
1424 AND NVL(mil.task_id, -9999) = NVL(p_task_id, -9999);
1425 END;
1426 PROCEDURE get_mo_fromloc_lov(
1427 x_locators OUT NOCOPY t_genref,
1428 p_organization_id IN NUMBER,
1429 p_moheader_id IN NUMBER,
1430 p_concatenated_segments IN VARCHAR2,
1431 p_project_id IN NUMBER := NULL,
1432 p_task_id IN NUMBER := NULL,
1433 p_alias IN VARCHAR2
1434 ) IS
1435 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
1436 BEGIN
1437 IF p_alias IS NULL THEN
1438 get_mo_fromloc_lov(
1439 x_locators => x_locators
1440 ,p_organization_id => p_organization_id
1441 ,p_moheader_id => p_moheader_id
1442 ,p_concatenated_segments => p_concatenated_segments
1443 ,p_project_id => p_project_id
1444 ,p_task_id => p_task_id
1445 );
1446 RETURN;
1447 END IF;
1448 OPEN x_locators FOR
1449 SELECT mil.inventory_location_id
1450 --, mil.concatenated_segments conseg--Bug4398337:Commented this line and added below line
1451 , mil.locator_segments conseg
1452 , mil.description
1453 FROM wms_item_locations_kfv mil
1454 WHERE mil.organization_id = p_organization_id
1455 AND mil.inventory_location_id IN (SELECT from_locator_id
1456 FROM mtl_txn_request_lines
1457 WHERE header_id = p_moheader_id)
1458 AND mil.alias = p_alias
1459 AND NVL(mil.project_id, -9999) = NVL(p_project_id, -9999)
1460 AND NVL(mil.task_id, -9999) = NVL(p_task_id, -9999);
1461 END GET_MO_FROMLOC_LOV;
1462
1463 -- Name: GET_MO_TOLOC_LOV
1464 --
1465 -- Input parameters:
1466 -- p_Organization_Id which restricts LOV SQL to current org
1467 -- p_Concatenated_Segments which restricts LOV SQL to user input text
1468 -- e.g. 1-1%
1469 --
1470 -- Output parameters:
1471 -- x_Locators returns LOV rows as reference cursor
1472 --
1473 -- Functions: This API is to return "destination" locator for a given MO
1474 --
1475 PROCEDURE get_mo_toloc_lov(x_locators OUT NOCOPY t_genref, p_organization_id IN NUMBER, p_moheader_id IN NUMBER, p_concatenated_segments IN VARCHAR2, p_project_id IN NUMBER := NULL, p_task_id IN NUMBER := NULL) IS
1476 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
1477 BEGIN
1478 OPEN x_locators FOR
1479 SELECT mil.inventory_location_id
1480 --, mil.concatenated_segments consegs--Bug4398337:Commented this line and added below line
1481 , mil.locator_segments consegs
1482 , mil.description
1483 FROM wms_item_locations_kfv mil
1484 WHERE mil.organization_id = p_organization_id
1485 AND inventory_location_id IN (SELECT to_locator_id
1486 FROM mtl_txn_request_lines
1487 WHERE header_id = p_moheader_id)
1488 AND mil.concatenated_segments LIKE (p_concatenated_segments)
1489 AND NVL(mil.project_id, -9999) = NVL(p_project_id, -9999)
1490 AND NVL(mil.task_id, -9999) = NVL(p_task_id, -9999);
1491 END;
1492 --Bug 12356015, override get_mo_toloc_lov to add parameter p_alias
1493 --As in MSCA, while performing mo subinventory transfer, when invoking
1494 --get_mo_toloc_lov in QueryMOXferPage, we will automatically add parameter p_alias
1495 PROCEDURE get_mo_toloc_lov(
1496 x_locators OUT NOCOPY t_genref,
1497 p_organization_id IN NUMBER,
1498 p_moheader_id IN NUMBER,
1499 p_concatenated_segments IN VARCHAR2,
1500 p_project_id IN NUMBER := NULL,
1501 p_task_id IN NUMBER := NULL,
1502 p_alias IN VARCHAR2
1503 ) IS
1504 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
1505 BEGIN
1506 IF p_alias IS NULL THEN
1507 get_mo_toloc_lov(
1508 x_locators => x_locators
1509 ,p_organization_id => p_organization_id
1510 ,p_moheader_id => p_moheader_id
1511 ,p_concatenated_segments => p_concatenated_segments
1512 ,p_project_id => p_project_id
1513 ,p_task_id => p_task_id
1514 );
1515 RETURN;
1516 END IF;
1517 OPEN x_locators FOR
1518 SELECT mil.inventory_location_id
1519 , mil.locator_segments conseg
1520 , mil.description
1521 FROM wms_item_locations_kfv mil
1522 WHERE mil.organization_id = p_organization_id
1523 AND mil.inventory_location_id IN (SELECT to_locator_id
1524 FROM mtl_txn_request_lines
1525 WHERE header_id = p_moheader_id)
1526 AND mil.alias = p_alias
1527 AND NVL(mil.project_id, -9999) = NVL(p_project_id, -9999)
1528 AND NVL(mil.task_id, -9999) = NVL(p_task_id, -9999);
1529 END get_mo_toloc_lov;
1530
1531 /* PJM-WMS Integration:Return only the the physical locators.
1532 * Use the table mtl_item_locations instead of mtl_item_locations_kfv.
1533 * Use the function INV_PROJECT.get_locsegs() to retrieve the
1534 * concatenated segments.Filter the locators based on the Project
1535 * and Task passed to the procedure.
1536 */
1537 PROCEDURE get_loc_with_status(x_locators OUT NOCOPY t_genref,
1538 p_organization_id IN NUMBER,
1539 p_subinventory_code IN VARCHAR2,
1540 p_concatenated_segments IN VARCHAR2,
1541 p_project_id IN NUMBER , -- PJM_WMS Integration
1542 p_task_id IN NUMBER ) -- PJM_WMS Integration
1543 IS
1544 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
1545 BEGIN
1546 OPEN x_locators FOR
1547 SELECT mil.inventory_location_id
1548 --, mil.concatenated_segments--Bug4398337:Commented this line and added below line
1549 , mil.locator_segments concatenated_segments
1550 , mil.description
1551 , mil.status_id
1552 , mmsv.status_code
1553 FROM wms_item_locations_kfv mil, mtl_material_statuses_vl mmsv
1554 WHERE mil.organization_id = p_organization_id
1555 AND mil.subinventory_code = p_subinventory_code
1556 AND mil.concatenated_segments LIKE (p_concatenated_segments)
1557 AND mmsv.status_id = mil.status_id
1558 AND NVL(mil.project_id, -1) = NVL(p_project_id, -1)
1559 AND NVL(mil.task_id, -1) = NVL(p_task_id, -1)
1560 ORDER BY mil.concatenated_segments; -- PJM-WMS Integration
1561 END get_loc_with_status;
1562
1563 PROCEDURE get_loc_with_status(
1564 x_locators OUT NOCOPY t_genref,
1565 p_organization_id IN NUMBER,
1566 p_subinventory_code IN VARCHAR2,
1567 p_concatenated_segments IN VARCHAR2,
1568 p_project_id IN NUMBER , -- PJM_WMS Integration
1569 p_task_id IN NUMBER, -- PJM_WMS Integration
1570 p_alias IN VARCHAR2
1571 ) IS
1572 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
1573 BEGIN
1574 IF p_alias IS NULL THEN
1575 get_loc_with_status(
1576 x_locators => x_locators
1577 ,p_organization_id => p_organization_id
1578 ,p_subinventory_code => p_subinventory_code
1579 ,p_concatenated_segments => p_concatenated_segments
1580 ,p_project_id => p_project_id
1581 ,p_task_id => p_task_id
1582 );
1583 RETURN;
1584 END IF;
1585 OPEN x_locators FOR
1586 SELECT mil.inventory_location_id
1587 --, mil.concatenated_segments--Bug4398337:Commented this line and added below line
1588 , mil.locator_segments concatenated_segments
1589 , mil.description
1590 , mil.status_id
1591 , mmsv.status_code
1592 FROM wms_item_locations_kfv mil, mtl_material_statuses_vl mmsv
1593 WHERE mil.organization_id = p_organization_id
1594 AND mil.subinventory_code = p_subinventory_code
1595 AND mil.alias = p_alias
1596 AND mmsv.status_id = mil.status_id
1597 AND NVL(mil.project_id, -1) = NVL(p_project_id, -1)
1598 AND NVL(mil.task_id, -1) = NVL(p_task_id, -1)
1599 ORDER BY mil.concatenated_segments; -- PJM-WMS Integration
1600 END get_loc_with_status;
1601
1602 ---- Obsolete
1603 PROCEDURE get_from_subs(
1604 x_zones OUT NOCOPY t_genref
1605 , p_organization_id IN NUMBER
1606 , p_inventory_item_id IN NUMBER
1607 , p_restrict_subinventories_code IN NUMBER
1608 , p_secondary_inventory_name IN VARCHAR2
1609 , p_transaction_action_id IN NUMBER
1610 , p_transaction_type_id IN NUMBER
1611 , p_wms_installed IN VARCHAR2
1612 ) IS
1613 l_expense_to_asset VARCHAR2(1);
1614 l_debug NUMBER;
1615 BEGIN
1616 fnd_profile.get('INV:EXPENSE_TO_ASSET_TRANSFER', l_expense_to_asset);
1617 l_debug := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
1618
1619 IF (NVL(l_expense_to_asset, '2') = '1') THEN
1620 IF (p_transaction_action_id <> 2
1621 AND p_transaction_action_id <> 3
1622 ) THEN
1623 IF p_restrict_subinventories_code = 1 THEN
1624 OPEN x_zones FOR
1625 SELECT a.secondary_inventory_name
1626 , NVL(a.locator_type, 1)
1627 , a.description
1628 , a.asset_inventory
1629 , a.lpn_controlled_flag
1630 , a.enable_locator_alias
1631 FROM mtl_secondary_inventories a, mtl_item_sub_inventories b
1632 WHERE a.organization_id = p_organization_id
1633 AND a.organization_id = b.organization_id
1634 AND b.inventory_item_id = p_inventory_item_id
1635 AND a.secondary_inventory_name = b.secondary_inventory
1636 AND NVL(a.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
1637 AND a.secondary_inventory_name LIKE (p_secondary_inventory_name)
1638 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, a.secondary_inventory_name, NULL, NULL, NULL, 'Z') = 'Y';
1639 ELSE
1640 OPEN x_zones FOR
1641 SELECT secondary_inventory_name
1642 , NVL(locator_type, 1)
1643 , description
1644 , asset_inventory
1645 , lpn_controlled_flag
1646 , enable_locator_alias
1647 FROM mtl_secondary_inventories
1648 WHERE organization_id = p_organization_id
1649 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
1650 AND secondary_inventory_name LIKE (p_secondary_inventory_name)
1651 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, secondary_inventory_name, NULL, NULL, NULL, 'Z') = 'Y';
1652 END IF;
1653 ELSE
1654 IF p_restrict_subinventories_code = 1 THEN
1655 OPEN x_zones FOR
1656 SELECT a.secondary_inventory_name
1657 , NVL(a.locator_type, 1)
1658 , a.description
1659 , a.asset_inventory
1660 , a.lpn_controlled_flag
1661 , a.enable_locator_alias
1662 FROM mtl_secondary_inventories a, mtl_item_sub_inventories b
1663 WHERE a.organization_id = p_organization_id
1664 AND a.organization_id = b.organization_id
1665 AND a.secondary_inventory_name = b.secondary_inventory
1666 AND NVL(a.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
1667 AND b.inventory_item_id = p_inventory_item_id
1668 AND a.secondary_inventory_name LIKE (p_secondary_inventory_name)
1669 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, a.secondary_inventory_name, NULL, NULL, NULL, 'Z') = 'Y';
1670 ELSE
1671 OPEN x_zones FOR
1672 SELECT secondary_inventory_name
1673 , NVL(locator_type, 1)
1674 , description
1675 , asset_inventory
1676 , lpn_controlled_flag
1677 , enable_locator_alias
1678 FROM mtl_secondary_inventories
1679 WHERE organization_id = p_organization_id
1680 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
1681 AND secondary_inventory_name LIKE (p_secondary_inventory_name)
1682 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, secondary_inventory_name, NULL, NULL, NULL, 'Z') = 'Y';
1683 END IF;
1684 END IF;
1685 ELSE
1686 IF (p_transaction_action_id <> 2
1687 AND p_transaction_action_id <> 3
1688 ) THEN
1689 IF p_restrict_subinventories_code = 1 THEN
1690 OPEN x_zones FOR
1691 SELECT a.secondary_inventory_name
1692 , NVL(a.locator_type, 1)
1693 , a.description
1694 , a.asset_inventory
1695 , a.lpn_controlled_flag
1696 , a.enable_locator_alias
1697 FROM mtl_secondary_inventories a, mtl_item_sub_inventories b
1698 WHERE a.organization_id = p_organization_id
1699 AND a.organization_id = b.organization_id
1700 AND a.secondary_inventory_name = b.secondary_inventory
1701 AND NVL(a.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
1702 AND b.inventory_item_id = p_inventory_item_id
1703 AND a.secondary_inventory_name LIKE (p_secondary_inventory_name)
1704 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, a.secondary_inventory_name, NULL, NULL, NULL, 'Z') = 'Y';
1705 ELSE
1706 OPEN x_zones FOR
1707 SELECT secondary_inventory_name
1708 , NVL(locator_type, 1)
1709 , description
1710 , asset_inventory
1711 , lpn_controlled_flag
1712 , enable_locator_alias
1713 FROM mtl_secondary_inventories
1714 WHERE organization_id = p_organization_id
1715 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
1716 AND secondary_inventory_name LIKE (p_secondary_inventory_name)
1717 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, secondary_inventory_name, NULL, NULL, NULL, 'Z') = 'Y';
1718 END IF;
1719 ELSE
1720 IF p_restrict_subinventories_code = 1 THEN
1721 OPEN x_zones FOR
1722 SELECT a.secondary_inventory_name
1723 , NVL(a.locator_type, 1)
1724 , a.description
1725 , a.asset_inventory
1726 , a.lpn_controlled_flag
1727 , a.enable_locator_alias
1728 FROM mtl_secondary_inventories a, mtl_item_sub_inventories b
1729 WHERE a.organization_id = p_organization_id
1730 AND a.organization_id = b.organization_id
1731 AND a.secondary_inventory_name = b.secondary_inventory
1732 AND NVL(a.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
1733 AND b.inventory_item_id = p_inventory_item_id
1734 AND a.secondary_inventory_name LIKE (p_secondary_inventory_name)
1735 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, a.secondary_inventory_name, NULL, NULL, NULL, 'Z') = 'Y';
1736 ELSE
1737 OPEN x_zones FOR
1738 SELECT secondary_inventory_name
1739 , NVL(locator_type, 1)
1740 , description
1741 , asset_inventory
1742 , lpn_controlled_flag
1743 , enable_locator_alias
1744 FROM mtl_secondary_inventories
1745 WHERE organization_id = p_organization_id
1746 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
1747 AND secondary_inventory_name LIKE (p_secondary_inventory_name)
1748 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, secondary_inventory_name, NULL, NULL, NULL, 'Z') = 'Y';
1749 END IF;
1750 END IF;
1751 END IF;
1752 END get_from_subs;
1753
1754 ---obsolete
1755 PROCEDURE get_to_sub(
1756 x_to_sub OUT NOCOPY t_genref
1757 , p_organization_id IN NUMBER
1758 , p_inventory_item_id IN NUMBER
1759 , p_from_secondary_name IN VARCHAR2
1760 , p_restrict_subinventories_code IN NUMBER
1761 , p_secondary_inventory_name IN VARCHAR2
1762 , p_from_sub_asset_inventory IN VARCHAR2
1763 , p_transaction_action_id IN NUMBER
1764 , p_to_organization_id IN NUMBER
1765 , p_serial_number_control_code IN NUMBER
1766 , p_transaction_type_id IN NUMBER
1767 , p_wms_installed IN VARCHAR2
1768 ) IS
1769 l_expense_to_asset VARCHAR2(1);
1770 l_inventory_asset_flag VARCHAR2(1);
1771 l_org NUMBER;
1772 l_restrict_subinventories_code NUMBER;
1773 l_from_sub VARCHAR2(10);
1774 l_from_sub_asset_inventory VARCHAR2(1);
1775 l_debug NUMBER;
1776 BEGIN
1777
1778 l_debug := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
1779
1780 IF p_transaction_action_id IN (3, 21) THEN
1781 l_org := p_to_organization_id;
1782
1783 SELECT restrict_subinventories_code
1784 INTO l_restrict_subinventories_code
1785 FROM mtl_system_items
1786 WHERE organization_id = l_org
1787 AND inventory_item_id = p_inventory_item_id;
1788 ELSE
1789 l_org := p_organization_id;
1790 l_restrict_subinventories_code := p_restrict_subinventories_code;
1791 END IF;
1792
1793 l_from_sub := p_from_secondary_name;
1794 l_from_sub_asset_inventory := p_from_sub_asset_inventory;
1795
1796 SELECT inventory_asset_flag
1797 INTO l_inventory_asset_flag
1798 FROM mtl_system_items
1799 WHERE inventory_item_id = p_inventory_item_id
1800 AND organization_id = l_org;
1801
1802 fnd_profile.get('INV:EXPENSE_TO_ASSET_TRANSFER', l_expense_to_asset);
1803
1804 IF (NVL(l_expense_to_asset, '2') = '1') THEN
1805 IF l_restrict_subinventories_code = 1 THEN
1806 OPEN x_to_sub FOR
1807 SELECT a.secondary_inventory_name
1808 , NVL(a.locator_type, 1)
1809 , a.description
1810 , a.asset_inventory
1811 , a.lpn_controlled_flag
1812 , a.enable_locator_alias
1813 FROM mtl_secondary_inventories a, mtl_item_sub_inventories b
1814 WHERE a.organization_id = l_org
1815 AND a.organization_id = b.organization_id
1816 AND a.secondary_inventory_name = b.secondary_inventory
1817 AND NVL(a.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
1818 AND b.inventory_item_id = p_inventory_item_id
1819 AND a.secondary_inventory_name LIKE (p_secondary_inventory_name)
1820 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_to_organization_id, p_inventory_item_id, a.secondary_inventory_name, NULL, NULL, NULL, 'Z') = 'Y';
1821 ELSE
1822 OPEN x_to_sub FOR
1823 SELECT secondary_inventory_name
1824 , NVL(locator_type, 1)
1825 , description
1826 , asset_inventory
1827 , lpn_controlled_flag
1828 , enable_locator_alias
1829 FROM mtl_secondary_inventories
1830 WHERE organization_id = l_org
1831 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
1832 AND secondary_inventory_name LIKE (p_secondary_inventory_name)
1833 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_to_organization_id, p_inventory_item_id, secondary_inventory_name, NULL, NULL, NULL, 'Z') = 'Y';
1834 END IF;
1835 ELSE
1836 IF l_restrict_subinventories_code = 1 THEN
1837 IF l_inventory_asset_flag = 'Y' THEN
1838 IF l_from_sub_asset_inventory = 1 THEN
1839 OPEN x_to_sub FOR
1840 SELECT a.secondary_inventory_name
1841 , NVL(a.locator_type, 1)
1842 , a.description
1843 , a.asset_inventory
1844 , a.lpn_controlled_flag
1845 , a.enable_locator_alias
1846 FROM mtl_secondary_inventories a, mtl_item_sub_inventories b
1847 WHERE a.organization_id = l_org
1848 AND a.organization_id = b.organization_id
1849 -- and a.asset_inventory = 1
1850 AND b.inventory_item_id = p_inventory_item_id
1851 AND NVL(a.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
1852 AND a.secondary_inventory_name = b.secondary_inventory
1853 AND a.secondary_inventory_name LIKE (p_secondary_inventory_name)
1854 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_to_organization_id, p_inventory_item_id, a.secondary_inventory_name, NULL, NULL, NULL, 'Z') = 'Y';
1855 ELSE
1856 OPEN x_to_sub FOR
1857 SELECT a.secondary_inventory_name
1858 , NVL(a.locator_type, 1)
1859 , a.description
1860 , a.asset_inventory
1861 , a.lpn_controlled_flag
1862 , a.enable_locator_alias
1863 FROM mtl_secondary_inventories a, mtl_item_sub_inventories b
1864 WHERE a.organization_id = l_org
1865 AND a.organization_id = b.organization_id
1866 AND a.asset_inventory = 2
1867 AND b.inventory_item_id = p_inventory_item_id
1868 AND NVL(a.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
1869 AND a.secondary_inventory_name = b.secondary_inventory
1870 AND a.secondary_inventory_name LIKE (p_secondary_inventory_name)
1871 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_to_organization_id, p_inventory_item_id, a.secondary_inventory_name, NULL, NULL, NULL, 'Z') = 'Y';
1872 END IF;
1873 ELSE
1874 OPEN x_to_sub FOR
1875 SELECT a.secondary_inventory_name
1876 , NVL(a.locator_type, 1)
1877 , a.description
1878 , a.asset_inventory
1879 , a.lpn_controlled_flag
1880 , a.enable_locator_alias
1881 FROM mtl_secondary_inventories a, mtl_item_sub_inventories b
1882 WHERE a.organization_id = l_org
1883 AND a.organization_id = b.organization_id
1884 AND NVL(a.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
1885 AND a.secondary_inventory_name = b.secondary_inventory
1886 AND b.inventory_item_id = p_inventory_item_id
1887 AND a.secondary_inventory_name LIKE (p_secondary_inventory_name)
1888 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_to_organization_id, p_inventory_item_id, a.secondary_inventory_name, NULL, NULL, NULL, 'Z') = 'Y';
1889 END IF;
1890 ELSE
1891 IF l_inventory_asset_flag = 'Y' THEN
1892 IF l_from_sub_asset_inventory = 1 THEN
1893 OPEN x_to_sub FOR
1894 SELECT secondary_inventory_name
1895 , NVL(locator_type, 1)
1896 , description
1897 , asset_inventory
1898 , lpn_controlled_flag
1899 , enable_locator_alias
1900 FROM mtl_secondary_inventories
1901 WHERE organization_id = l_org
1902 --and asset_inventory = 1
1903 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
1904 AND secondary_inventory_name LIKE (p_secondary_inventory_name)
1905 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_to_organization_id, p_inventory_item_id, secondary_inventory_name, NULL, NULL, NULL, 'Z') = 'Y';
1906 ELSE
1907 OPEN x_to_sub FOR
1908 SELECT secondary_inventory_name
1909 , NVL(locator_type, 1)
1910 , description
1911 , asset_inventory
1912 , lpn_controlled_flag
1913 , enable_locator_alias
1914 FROM mtl_secondary_inventories
1915 WHERE organization_id = l_org
1916 AND asset_inventory = 2
1917 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
1918 AND secondary_inventory_name LIKE (p_secondary_inventory_name)
1919 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_to_organization_id, p_inventory_item_id, secondary_inventory_name, NULL, NULL, NULL, 'Z') = 'Y';
1920 END IF;
1921 ELSE
1922 OPEN x_to_sub FOR
1923 SELECT secondary_inventory_name
1924 , NVL(locator_type, 1)
1925 , description
1926 , asset_inventory
1927 , lpn_controlled_flag
1928 , enable_locator_alias
1929 FROM mtl_secondary_inventories
1930 WHERE organization_id = l_org
1931 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
1932 AND secondary_inventory_name LIKE (p_secondary_inventory_name)
1933 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_to_organization_id, p_inventory_item_id, secondary_inventory_name, NULL, NULL, NULL, 'Z') = 'Y';
1934 END IF;
1935 END IF;
1936 END IF;
1937 END get_to_sub;
1938
1939 -- Obsolete
1940 PROCEDURE get_valid_subs(
1941 x_zones OUT NOCOPY t_genref
1942 , p_organization_id IN NUMBER
1943 , p_subinventory_code IN VARCHAR2
1944 ) IS
1945 l_debug NUMBER;
1946 BEGIN
1947 l_debug := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
1948 --bug#3440453 Remove the NVL on organization_id if user passes it.
1949 IF p_organization_id IS NULL THEN
1950 OPEN x_zones FOR
1951 SELECT secondary_inventory_name
1952 , NVL(locator_type, 1)
1953 , description
1954 , asset_inventory
1955 , lpn_controlled_flag
1956 , enable_locator_alias
1957 FROM mtl_secondary_inventories
1958 WHERE organization_id = NVL(p_organization_id, organization_id)
1959 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
1960 AND secondary_inventory_name LIKE (p_subinventory_code)
1961 ORDER BY secondary_inventory_name;
1962 ELSE -- Organization_id is not null
1963 OPEN x_zones FOR
1964 SELECT secondary_inventory_name
1965 , NVL(locator_type, 1)
1966 , description
1967 , asset_inventory
1968 , lpn_controlled_flag
1969 , enable_locator_alias
1970 FROM mtl_secondary_inventories
1971 WHERE organization_id = p_organization_id
1972 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
1973 AND secondary_inventory_name LIKE (p_subinventory_code)
1974 ORDER BY secondary_inventory_name;
1975 END IF;
1976 END get_valid_subs;
1977
1978 --=Obsolete
1979 PROCEDURE get_valid_subinvs(
1980 x_zones OUT NOCOPY t_genref
1981 , p_organization_id IN NUMBER
1982 , p_subinventory_code IN VARCHAR2
1983 , p_txn_type_id IN NUMBER
1984 , p_wms_installed IN VARCHAR2
1985 ) IS
1986 l_debug NUMBER;
1987 BEGIN
1988 l_debug := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
1989 --bug#3440453 Remove the NVL on organization_id if user passes a value to it.
1990 IF p_organization_id IS NULL THEN
1991 OPEN x_zones FOR
1992 SELECT secondary_inventory_name
1993 , NVL(locator_type, 1)
1994 , description
1995 , asset_inventory
1996 , lpn_controlled_flag
1997 , enable_locator_alias
1998 FROM mtl_secondary_inventories
1999 WHERE organization_id = NVL(p_organization_id, organization_id)
2000 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
2001 AND secondary_inventory_name LIKE (p_subinventory_code)
2002 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_txn_type_id, NULL, NULL, p_organization_id, NULL, secondary_inventory_name, NULL, NULL, NULL, 'Z') = 'Y'
2003 ORDER BY secondary_inventory_name;
2004 ELSE -- Organization_id is not null
2005 OPEN x_zones FOR
2006 SELECT secondary_inventory_name
2007 , NVL(locator_type, 1)
2008 , description
2009 , asset_inventory
2010 , lpn_controlled_flag
2011 , enable_locator_alias
2012 FROM mtl_secondary_inventories
2013 WHERE organization_id = p_organization_id
2014 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
2015 AND secondary_inventory_name LIKE (p_subinventory_code)
2016 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_txn_type_id, NULL, NULL, p_organization_id, NULL, secondary_inventory_name, NULL, NULL, NULL, 'Z') = 'Y'
2017 ORDER BY secondary_inventory_name;
2018 END IF;
2019 END get_valid_subinvs;
2020
2021 FUNCTION check_loc_existence(p_organization_id IN NUMBER, p_subinventory_code IN VARCHAR2)
2022 RETURN NUMBER IS
2023 loc_control NUMBER;
2024 loc_exists NUMBER := 0;
2025 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
2026 BEGIN
2027 /* Bug #1613379
2028 SELECT 1
2029 INTO loc_exists
2030 FROM DUAL
2031 WHERE exists (select 1
2032 FROM mtl_item_locations
2033 WHERE organization_id = p_organization_id
2034 AND subinventory_code = p_subinventory_code);
2035 */
2036
2037 SELECT locator_type
2038 INTO loc_control
2039 FROM mtl_secondary_inventories
2040 WHERE organization_id = p_organization_id
2041 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
2042 AND secondary_inventory_name = p_subinventory_code;
2043
2044 IF loc_control <> 0 THEN
2045 loc_exists := 1;
2046 END IF;
2047
2048 RETURN loc_exists;
2049 EXCEPTION
2050 WHEN NO_DATA_FOUND THEN
2051 loc_exists := 0;
2052 RETURN loc_exists;
2053 END check_loc_existence;
2054
2055 /* This procedure is for the status update find page, here the locatorType
2056 in the second parameter represents if any locators exist in the current
2057 subinventory but doesnt really mean the locator control type */
2058 -- Obsolete
2059 PROCEDURE get_sub_with_loc(
2060 x_zones OUT NOCOPY t_genref
2061 , p_organization_id IN NUMBER
2062 , p_subinventory_code IN VARCHAR2
2063 ) IS
2064 l_debug NUMBER;
2065 BEGIN
2066 l_debug := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
2067 OPEN x_zones FOR
2068 SELECT secondary_inventory_name
2069 , inv_ui_item_sub_loc_lovs.check_loc_existence(p_organization_id, secondary_inventory_name)
2070 , msi.description
2071 , asset_inventory
2072 , mmsv.status_id
2073 , status_code
2074 , enable_locator_alias
2075 FROM mtl_secondary_inventories msi, mtl_material_statuses_vl mmsv
2076 WHERE organization_id = p_organization_id
2077 AND mmsv.status_id = msi.status_id
2078 AND NVL(msi.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
2079 AND secondary_inventory_name LIKE (p_subinventory_code);
2080 END get_sub_with_loc;
2081
2082 --- Obsolete
2083 PROCEDURE get_sub_lov_ship(
2084 x_sub_lov OUT NOCOPY t_genref
2085 , p_txn_dock IN VARCHAR2
2086 , p_organization_id IN NUMBER
2087 , p_dock_appointment_id IN NUMBER
2088 , p_sub IN VARCHAR2
2089 ) IS
2090 l_debug NUMBER;
2091 BEGIN
2092 l_debug := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
2093 IF (p_txn_dock = 'Y') THEN
2094 OPEN x_sub_lov FOR
2095 SELECT msub.secondary_inventory_name
2096 , NVL(msub.locator_type, 1)
2097 , msub.description
2098 , msub.asset_inventory
2099 , msub.lpn_controlled_flag
2100 , msub.enable_locator_alias
2101 FROM mtl_secondary_inventories msub
2102 WHERE msub.organization_id = p_organization_id
2103 AND NVL(msub.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
2104 AND EXISTS( SELECT wda.staging_lane_id
2105 FROM wms_dock_appointments_b wda, mtl_item_locations milk, wsh_trip_stops pickup_stop
2106 WHERE milk.inventory_location_id(+) = wda.staging_lane_id
2107 AND milk.organization_id(+) = wda.organization_id
2108 AND milk.organization_id = p_organization_id
2109 AND milk.subinventory_code = msub.secondary_inventory_name
2110 AND wda.dock_appointment_id = p_dock_appointment_id
2111 AND wda.trip_stop = pickup_stop.stop_id(+))
2112 AND msub.secondary_inventory_name LIKE (p_sub);
2113 ELSIF (p_txn_dock = 'N') THEN
2114 OPEN x_sub_lov FOR
2115 SELECT msub.secondary_inventory_name
2116 , NVL(msub.locator_type, 1)
2117 , msub.description
2118 , msub.asset_inventory
2119 , lpn_controlled_flag
2120 , enable_locator_alias
2121 FROM mtl_secondary_inventories msub
2122 WHERE msub.organization_id = p_organization_id
2123 AND NVL(msub.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
2124 AND EXISTS( SELECT milk.inventory_location_id
2125 FROM mtl_item_locations milk, wms_license_plate_numbers lpn
2126 WHERE milk.inventory_location_id(+) = lpn.locator_id
2127 AND milk.organization_id(+) = lpn.organization_id
2128 AND milk.organization_id = p_organization_id
2129 AND milk.subinventory_code = msub.secondary_inventory_name
2130 AND (lpn.lpn_context = 1
2131 OR lpn.lpn_context = 11
2132 ))
2133 AND msub.secondary_inventory_name LIKE (p_sub);
2134 END IF;
2135 END get_sub_lov_ship;
2136
2137 PROCEDURE get_to_xsubs(x_to_xsubs OUT NOCOPY t_genref, p_organization_id IN NUMBER, p_subinventory_code IN VARCHAR2) IS
2138 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
2139 BEGIN
2140 OPEN x_to_xsubs FOR
2141 SELECT secondary_inventory_name
2142 , locator_type
2143 , description
2144 , asset_inventory
2145 , lpn_controlled_flag
2146 FROM mtl_secondary_inventories
2147 WHERE organization_id = p_organization_id
2148 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
2149 AND secondary_inventory_name LIKE (p_subinventory_code)
2150 ORDER BY secondary_inventory_name;
2151 END get_to_xsubs;
2152
2153 -- Name: GET_PHYINV_SUBS
2154 --
2155 -- Input parameters:
2156 -- p_subinventory_code - restricts the subinventory to those like
2157 -- the user inputted text if given
2158 -- p_organization_id - restricts LOV SQL to current org
2159 -- p_all_sub_flag - all subinventories flag which indicates
2160 -- whether all the subs associated with the
2161 -- org are used or only those that are defined
2162 -- for that particular physical inventory
2163 -- p_physical_inventory_id - The physical inventory for which we are
2164 -- querying up the subs for
2165 --
2166 --
2167 -- Output parameters:
2168 -- x_phy_inv_sub_lov - Returns LOV rows as reference cursor
2169 --
2170 -- Functions: This API returns the valid subs associated with a
2171 -- physical inventory
2172 --
2173 --- obsolete
2174 PROCEDURE get_phyinv_subs(
2175 x_phy_inv_sub_lov OUT NOCOPY t_genref
2176 , p_subinventory_code IN VARCHAR2
2177 , p_organization_id IN NUMBER
2178 , p_all_sub_flag IN NUMBER
2179 , p_physical_inventory_id IN NUMBER
2180 ) IS
2181 --l_dynamic_tag_entry_flag NUMBER;
2182 l_debug NUMBER;
2183 BEGIN
2184
2185 l_debug := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
2186 /* bug 1727378 fix*/
2187 -- Get the dynamic tag entry flag
2188 --SELECT dynamic_tag_entry_flag
2189 -- INTO l_dynamic_tag_entry_flag
2190 -- FROM mtl_physical_inventories
2191 -- WHERE physical_inventory_id = p_physical_inventory_id
2192 -- AND organization_id = p_organization_id;
2193
2194 --IF (l_dynamic_tag_entry_flag = 1) THEN
2195 -- Dynamic tags are allowed
2196 -- OPEN x_phy_inv_sub_lov FOR
2197 -- SELECT msub.secondary_inventory_name
2198 -- , Nvl(msub.locator_type, 1)
2199 -- , msub.description
2200 -- , msub.asset_inventory
2201 -- , msub.lpn_controlled_flag
2202 -- FROM mtl_secondary_inventories msub
2203 -- WHERE msub.organization_id = p_organization_id
2204 -- AND nvl(msub.disable_date, trunc(sysdate+1)) > trunc(sysdate)
2205 -- AND msub.secondary_inventory_name LIKE (p_subinventory_code || '%')
2206 -- ORDER BY UPPER(msub.secondary_inventory_name);
2207 -- ELSE
2208 -- Dynamic tags are not allowed
2209 /* bug 1727378 fix*/
2210
2211 IF (p_all_sub_flag = 1) THEN
2212 -- All Subinventories included for this physical inventory
2213 OPEN x_phy_inv_sub_lov FOR
2214 SELECT msub.secondary_inventory_name
2215 , NVL(msub.locator_type, 1)
2216 , msub.description
2217 , msub.asset_inventory
2218 , msub.lpn_controlled_flag
2219 , msub.enable_locator_alias
2220 FROM mtl_secondary_inventories msub
2221 WHERE msub.organization_id = p_organization_id
2222 AND NVL(msub.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
2223 AND msub.secondary_inventory_name LIKE (p_subinventory_code)
2224 ORDER BY UPPER(msub.secondary_inventory_name);
2225 ELSE
2226 -- Include only those subinventories which have been explicitly
2227 -- associated with this physical inventory
2228 OPEN x_phy_inv_sub_lov FOR
2229 SELECT UNIQUE msub.secondary_inventory_name
2230 , NVL(msub.locator_type, 1)
2231 , msub.description
2232 , msub.asset_inventory
2233 , msub.lpn_controlled_flag
2234 , msub.enable_locator_alias
2235 FROM mtl_secondary_inventories msub, mtl_physical_subinventories mpsub
2236 WHERE msub.organization_id = p_organization_id
2237 AND mpsub.organization_id = p_organization_id
2238 AND mpsub.subinventory = msub.secondary_inventory_name
2239 AND mpsub.physical_inventory_id = p_physical_inventory_id
2240 AND NVL(msub.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
2241 AND msub.secondary_inventory_name LIKE (p_subinventory_code)
2242 ORDER BY UPPER(msub.secondary_inventory_name);
2243 END IF;
2244
2245 END get_phyinv_subs;
2246
2247 -- Name: GET_PHYINV_LOCS
2248 --
2249 -- Input parameters:
2250 -- p_organization_id - restricts LOV SQL to current org
2251 -- p_subinventory_code - restricts LOV to the current subinventory
2252 -- p_concatenated_segments - restricts the locator to those that are
2253 -- similar to the user inputted text.
2254 -- locators are a key flex field so this
2255 -- is how the user represents/identifies locators
2256 -- p_dynamic_entry_flag - this flag determines whether or not
2257 -- dynamic tag entries are allowed
2258 -- p_physical_inventory_id - The physical inventory for which we are
2259 -- querying up the locators for
2260 --
2261 --
2262 -- Output parameters:
2263 -- x_locators - Returns LOV rows as reference cursor
2264 --
2265 -- Functions: This API returns the valid locators associated with a
2266 -- physical inventory
2267 --
2268 PROCEDURE get_phyinv_locs
2269 (x_locators OUT NOCOPY t_genref ,
2270 p_organization_id IN NUMBER ,
2271 p_subinventory_code IN VARCHAR2 ,
2272 p_concatenated_segments IN VARCHAR2 ,
2273 p_dynamic_entry_flag IN NUMBER ,
2274 p_physical_inventory_id IN NUMBER ,
2275 p_project_id IN NUMBER := NULL ,
2276 p_task_id IN NUMBER := NULL
2277 )
2278 IS
2279 l_debug NUMBER := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
2280 BEGIN
2281 IF (p_dynamic_entry_flag = 2) THEN
2282 -- Dynamic entries are not allowed
2283 OPEN x_locators FOR
2284 SELECT UNIQUE mil.inventory_location_id
2285 --, mil.concatenated_segments--Bug4398337:Commented this line and added below line
2286 , mil.locator_segments concatenated_segments
2287 , mil.description
2288 FROM wms_item_locations_kfv mil, mtl_physical_inventory_tags mpit
2289 WHERE mil.organization_id = p_organization_id
2290 AND mil.subinventory_code = p_subinventory_code
2291 AND mil.concatenated_segments LIKE (p_concatenated_segments)
2292 AND mil.inventory_location_id = mpit.locator_id
2293 AND mpit.physical_inventory_id = p_physical_inventory_id
2294 AND mpit.organization_id = p_organization_id
2295 AND NVL(mpit.void_flag, 2) = 2
2296 -- WMS PJM Integration: Restrict Locators based on the project and task
2297 AND NVL(mil.project_id, -1) = NVL(p_project_id, -1)
2298 AND NVL(mil.task_id, -1) = NVL(p_task_id, -1)
2299 --For bug number 4885951
2300 AND NVL(mil.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
2301 AND (mpit.adjustment_id IN (SELECT adjustment_id
2302 FROM mtl_physical_adjustments
2303 WHERE physical_inventory_id = p_physical_inventory_id
2304 AND organization_id = p_organization_id
2305 AND approval_status IS NULL)
2306 OR mpit.adjustment_id is NULL); --For bug#9772069
2307 ELSE
2308 -- dynamic entries are allowed
2309 OPEN x_locators FOR
2310 SELECT inventory_location_id
2311 --, concatenated_segments--Bug4398337:Commented this line and added below line
2312 , locator_segments concatenated_segments
2313 , description
2314 FROM wms_item_locations_kfv mil
2315 WHERE organization_id = p_organization_id
2316 AND subinventory_code = p_subinventory_code
2317 AND concatenated_segments LIKE (p_concatenated_segments)
2318 -- WMS PJM Integration: Restrict Locators based on the project and task
2319 AND NVL(project_id, -1) = NVL(p_project_id, -1)
2320 AND NVL(task_id, -1) = NVL(p_task_id, -1)
2321 --For bug number 4885951
2322 AND NVL(mil.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE);
2323
2324 END IF;
2325 END get_phyinv_locs;
2326
2327 PROCEDURE get_phyinv_locs
2328 (x_locators OUT NOCOPY t_genref ,
2329 p_organization_id IN NUMBER ,
2330 p_subinventory_code IN VARCHAR2 ,
2331 p_concatenated_segments IN VARCHAR2 ,
2332 p_dynamic_entry_flag IN NUMBER ,
2333 p_physical_inventory_id IN NUMBER ,
2334 p_project_id IN NUMBER := NULL ,
2335 p_task_id IN NUMBER := NULL ,
2336 p_alias IN VARCHAR2
2337 )
2338 IS
2339 l_debug NUMBER := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
2340 BEGIN
2341
2342 IF p_alias IS NULL THEN
2343 get_phyinv_locs(
2344 x_locators => x_locators
2345 ,p_organization_id => p_organization_id
2346 ,p_subinventory_code => p_subinventory_code
2347 ,p_concatenated_segments => p_concatenated_Segments
2348 ,p_dynamic_entry_flag => p_dynamic_entry_flag
2349 ,p_physical_inventory_id => p_physical_inventory_id
2350 ,p_project_id => p_project_id
2351 ,p_task_id => p_task_id
2352 );
2353 RETURN;
2354 END IF;
2355 IF (p_dynamic_entry_flag = 2) THEN
2356 -- Dynamic entries are not allowed
2357 OPEN x_locators FOR
2358 SELECT UNIQUE mil.inventory_location_id
2359 --, mil.concatenated_segments--Bug4398337:Commented this line and added below line
2360 , mil.locator_segments concatenated_segments
2361 , mil.description
2362 FROM wms_item_locations_kfv mil, mtl_physical_inventory_tags mpit
2363 WHERE mil.organization_id = p_organization_id
2364 AND mil.subinventory_code = p_subinventory_code
2365 AND mil.alias = p_alias
2366 AND mil.inventory_location_id = mpit.locator_id
2367 AND mpit.physical_inventory_id = p_physical_inventory_id
2368 AND mpit.organization_id = p_organization_id
2369 AND NVL(mpit.void_flag, 2) = 2
2370 -- WMS PJM Integration: Restrict Locators based on the project and task
2371 AND NVL(mil.project_id, -1) = NVL(p_project_id, -1)
2372 AND NVL(mil.task_id, -1) = NVL(p_task_id, -1)
2373 --For bug number 4885951
2374 AND NVL(mil.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
2375 AND (mpit.adjustment_id IN (SELECT adjustment_id
2376 FROM mtl_physical_adjustments
2377 WHERE physical_inventory_id = p_physical_inventory_id
2378 AND organization_id = p_organization_id
2379 AND approval_status IS NULL)
2380 OR mpit.adjustment_id is NULL); --For bug#9772069
2381 ELSE
2382 -- dynamic entries are allowed
2383 OPEN x_locators FOR
2384 SELECT inventory_location_id
2385 --, concatenated_segments--Bug4398337:Commented this line and added below line
2386 , locator_segments concatenated_segments
2387 , description
2388 FROM wms_item_locations_kfv mil
2389 WHERE organization_id = p_organization_id
2390 AND subinventory_code = p_subinventory_code
2391 AND alias = p_alias
2392 -- WMS PJM Integration: Restrict Locators based on the project and task
2393 AND NVL(project_id, -1) = NVL(p_project_id, -1)
2394 AND NVL(task_id, -1) = NVL(p_task_id, -1)
2395 --For bug number 4885951
2396 AND NVL(mil.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE);
2397
2398 END IF;
2399 END get_phyinv_locs;
2400
2401 -- Name: GET_CYC_SUBS
2402 --
2403 -- Input parameters:
2404 -- p_subinventory_code - restricts the subinventory to those like
2405 -- the user inputted text if given
2406 -- p_organization_id - restricts LOV SQL to current org
2407 -- p_orientation_code - orientation code which indicates
2408 -- whether all the subs associated with the
2409 -- org are used or only those that are defined
2410 -- for that particular cycle count
2411 -- p_cycle_count_header_id - The physical inventory for which we are
2412 -- querying up the subs for
2413 --
2414 --
2415 -- Output parameters:
2416 -- x_cyc_sub_lov - Returns LOV rows as reference cursor
2417 --
2418 -- Functions: This API returns the valid subs associated with a
2419 -- cycle count
2420 --
2421 --- obsolete
2422 PROCEDURE get_cyc_subs(
2423 x_cyc_sub_lov OUT NOCOPY t_genref
2424 , p_subinventory_code IN VARCHAR2
2425 , p_organization_id IN NUMBER
2426 , p_orientation_code IN NUMBER
2427 , p_cycle_count_header_id IN NUMBER
2428 ) IS
2429 l_unscheduled_count_entry NUMBER;
2430 l_debug NUMBER;
2431 BEGIN
2432 l_debug := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
2433
2434 IF (p_orientation_code = 1) THEN
2435 -- All subinventories in the org are included for this cycle count
2436 OPEN x_cyc_sub_lov FOR
2437 SELECT msub.secondary_inventory_name
2438 , NVL(msub.locator_type, 1)
2439 , msub.description
2440 , msub.asset_inventory
2441 , msub.lpn_controlled_flag
2442 , msub.enable_locator_alias
2443 FROM mtl_secondary_inventories msub
2444 WHERE msub.organization_id = p_organization_id
2445 AND NVL(msub.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
2446 AND msub.secondary_inventory_name LIKE (p_subinventory_code)
2447 -- Bug# 2770853
2448 -- Check for material status at the subinventory level
2449 AND (INV_MATERIAL_STATUS_GRP.is_status_applicable(NULL,
2450 NULL,
2451 4,
2452 NULL,
2453 NULL,
2454 msub.organization_id,
2455 NULL,
2456 msub.secondary_inventory_name,
2457 NULL,
2458 NULL,
2459 NULL,
2460 'Z') = 'Y')
2461 ORDER BY UPPER(msub.secondary_inventory_name);
2462 ELSE
2463 -- Include only those subinventories which have been explicitly
2464 -- associated with this cycle count
2465 OPEN x_cyc_sub_lov FOR
2466 SELECT UNIQUE msub.secondary_inventory_name
2467 , NVL(msub.locator_type, 1)
2468 , msub.description
2469 , msub.asset_inventory
2470 , msub.lpn_controlled_flag
2471 , msub.enable_locator_alias
2472 FROM mtl_secondary_inventories msub, mtl_cc_subinventories mccs
2473 WHERE msub.organization_id = p_organization_id
2474 AND mccs.cycle_count_header_id = p_cycle_count_header_id
2475 AND mccs.subinventory = msub.secondary_inventory_name
2476 AND NVL(msub.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
2477 AND msub.secondary_inventory_name LIKE (p_subinventory_code)
2478 -- Bug# 2770853
2479 -- Check for material status at the subinventory level
2480 AND (INV_MATERIAL_STATUS_GRP.is_status_applicable(NULL,
2481 NULL,
2482 4,
2483 NULL,
2484 NULL,
2485 msub.organization_id,
2486 NULL,
2487 msub.secondary_inventory_name,
2488 NULL,
2489 NULL,
2490 NULL,
2491 'Z') = 'Y')
2492 ORDER BY UPPER(msub.secondary_inventory_name);
2493 END IF;
2494 END get_cyc_subs;
2495
2496
2497 -- Patchset I: WMS-PJM integration
2498 -- Name: GET_CYC_LOCS
2499 --
2500 -- Input parameters:
2501 -- p_organization_id - restricts LOV SQL to current org
2502 -- p_subinventory_code - restricts LOV to the current subinventory
2503 -- p_concatenated_segments - restricts the locator to those that are
2504 -- similar to the user inputted text.
2505 -- locators are a key flex field so this
2506 -- is how the user represents/identifies locators
2507 -- p_unscheduled_entry - this flag determines whether or not
2508 -- unscheduled count entries are allowed
2509 -- p_cycle_count_header_id - The cycle count header for which we are
2510 -- querying up the locators for.
2511 -- p_project_id - restrict LOV SQL to this Project Id(Default null)
2512 -- p_task_id - restrict LOV SQL to this Task Id(Default null)
2513 --
2514 --
2515 -- Output parameters:
2516 -- x_locators - Returns LOV rows as reference cursor
2517 --
2518 -- Functions: This API returns the valid locators associated with a
2519 -- cycle count
2520 --
2521 --
2522 --
2523 PROCEDURE get_cyc_locs
2524 (x_locators OUT NOCOPY t_genref ,
2525 p_organization_id IN NUMBER ,
2526 p_subinventory_code IN VARCHAR2 ,
2527 p_concatenated_segments IN VARCHAR2 ,
2528 p_unscheduled_entry IN NUMBER ,
2529 p_cycle_count_header_id IN NUMBER ,
2530 p_project_id IN NUMBER ,
2531 p_task_id IN NUMBER
2532 )
2533 IS
2534 l_proc_name CONSTANT VARCHAR2(30) := 'INV_UI_ITEM_SUB_LOCS';
2535 l_serial_discrepancy_option NUMBER;
2536 l_container_discrepancy_option NUMBER;
2537 l_debug NUMBER := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
2538 l_ispjm_org VARCHAR2(1);
2539 BEGIN
2540 IF (l_debug = 1) THEN
2541 Inv_log_util.trace('p_organization_id: =======> ' || p_organization_id ,l_proc_name ,9);
2542 Inv_log_util.trace('p_subinventory_code: =====> ' || p_subinventory_code , l_proc_name,9);
2543 Inv_log_util.trace('p_concatenated_segments: => ' || p_concatenated_segments , l_proc_name,9);
2544 Inv_log_util.trace('p_unscheduled_entry: =====> ' || p_unscheduled_entry , l_proc_name,9);
2545 Inv_log_util.trace('p_cycle_count_header_id: => ' || p_cycle_count_header_id , l_proc_name,9);
2546 Inv_log_util.trace('p_project_id: ============> ' || p_project_id , l_proc_name,9);
2547 Inv_log_util.trace('p_task_id: ===============> ' || p_task_id, l_proc_name,9);
2548 END IF;
2549 BEGIN
2550 SELECT nvl(PROJECT_REFERENCE_ENABLED,'N')
2551 INTO l_ispjm_org
2552 FROM pjm_org_parameters
2553 WHERE organization_id=p_organization_id;
2554 EXCEPTION
2555 WHEN NO_DATA_FOUND THEN
2556 l_ispjm_org:='N';
2557 END; -- Get the cycle count discrepancy option flags
2558 SELECT NVL(serial_discrepancy_option, 2), NVL(container_discrepancy_option, 2)
2559 INTO l_serial_discrepancy_option, l_container_discrepancy_option
2560 FROM mtl_cycle_count_headers
2561 WHERE cycle_count_header_id = p_cycle_count_header_id;
2562
2563 IF (l_debug = 1) THEN
2564 Inv_log_util.trace('l_serial_discrepancy_option: ' || l_serial_discrepancy_option , l_proc_name,9);
2565 Inv_log_util.trace('l_container_discrepancy_option: ' || l_container_discrepancy_option, l_proc_name,9);
2566 END IF;
2567
2568 IF (p_unscheduled_entry = 2 AND
2569 l_serial_discrepancy_option = 2 AND
2570 l_container_discrepancy_option = 2) THEN
2571 -- unscheduled count entries are not allowed
2572 -- and serial and container discrepancies are also not allowed
2573 OPEN x_locators FOR
2574 SELECT UNIQUE mil.inventory_location_id,
2575 --mil.concatenated_segments concatenated_segments,--Bug4398337:Commented this line and added below line
2576 mil.locator_segments concatenated_segments,
2577 mil.description
2578 FROM wms_item_locations_kfv mil, mtl_cycle_count_entries mcce
2579 WHERE mcce.cycle_count_header_id = p_cycle_count_header_id
2580 AND mil.organization_id = p_organization_id
2581 AND mil.subinventory_code = p_subinventory_code
2582 AND NVL(mil.project_id,-1) = NVL(p_project_id,-1)
2583 AND NVL(mil.task_id,-1) = NVL(p_task_id,-1)
2584 AND mil.concatenated_segments LIKE (p_concatenated_segments)
2585 AND mcce.organization_id = mil.organization_id
2586 AND mcce.subinventory = mil.subinventory_code
2587 AND mil.inventory_location_id = mcce.locator_id
2588 AND mcce.entry_status_code IN (1,3)
2589 AND NVL(mil.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE) -- bug # 4866575
2590 -- Bug# 2770853
2591 -- Check for material status at the locator level
2592 AND (INV_MATERIAL_STATUS_GRP.is_status_applicable(NULL,
2593 NULL,
2594 4,
2595 NULL,
2596 NULL,
2597 mcce.organization_id,
2598 mcce.inventory_item_id,
2599 mcce.subinventory,
2600 mcce.locator_id,
2601 NULL,
2602 NULL,
2603 'L') = 'Y')
2604 ORDER BY concatenated_segments;
2605 ELSE
2606 -- unscheduled count entries are allowed
2607 -- or serial or container discrepancy is allowed
2608
2609 IF (l_ispjm_org = 'Y' and p_project_id is not null ) then
2610 Inv_log_util.trace('p_ispjm_org = yes and p_project_id is not null' , 'INV_UI_ITEM_SUB_LOCS',9);
2611 IF ( p_task_id is not null ) then
2612 Inv_log_util.trace('task id is not null ' , 'INV_UI_ITEM_SUB_LOCS',9);
2613 OPEN x_locators FOR
2614 SELECT inventory_location_id,
2615 -- concatenated_segments, --Bug4398337:Commented this line and added below line
2616 locator_segments concatenated_segments,
2617 description
2618 FROM wms_item_locations_kfv
2619 WHERE organization_id = p_organization_id
2620 AND subinventory_code = p_subinventory_code
2621 AND concatenated_segments LIKE (p_concatenated_segments )-- inv_project.get_locsegs(inventory_location_id,organization_id) LIKE (p_concatenated_segments || '%')
2622 AND project_id = p_project_id
2623 AND task_id = p_task_id
2624 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE) -- bug # 4866575
2625 AND (INV_MATERIAL_STATUS_GRP.is_status_applicable(NULL,
2626 NULL,
2627 4,
2628 NULL,
2629 NULL,
2630 organization_id,
2631 inventory_item_id,
2632 subinventory_code,
2633 inventory_location_id,
2634 NULL,
2635 NULL,
2636 'L') = 'Y')
2637 ORDER BY 2;
2638 ELSE -- task_id is null then
2639 Inv_log_util.trace('Task is null ' , 'INV_UI_ITEM_SUB_LOCS',9);
2640
2641 OPEN x_locators FOR
2642 SELECT inventory_location_id,
2643 -- concatenated_segments ,--Bug4398337:Commented this line and added below line
2644 locator_segments concatenated_segments,
2645 description
2646 FROM wms_item_locations_kfv
2647 WHERE organization_id = p_organization_id
2648 AND subinventory_code = p_subinventory_code
2649 AND concatenated_segments LIKE (p_concatenated_segments )--inv_project.get_locsegs(inventory_location_id,organization_id) LIKE (p_concatenated_segments || '%')
2650 AND project_id = p_project_id
2651 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE) -- bug # 4866575
2652 AND (INV_MATERIAL_STATUS_GRP.is_status_applicable(NULL,
2653 NULL,
2654 4,
2655 NULL,
2656 NULL,
2657 organization_id,
2658 inventory_item_id,
2659 subinventory_code,
2660 inventory_location_id,
2661 NULL,
2662 NULL,
2663 'L') = 'Y')
2664 ORDER BY 2;
2665
2666 END IF;
2667 ELSE -- non pjm org or project is not passed
2668 Inv_log_util.trace('non pjm org or project is not passed' , 'INV_UI_ITEM_SUB_LOCS',9);
2669 OPEN x_locators FOR
2670 SELECT inventory_location_id,
2671 -- concatenated_segments, --Bug4398337:Commented this line and added below line
2672 locator_segments concatenated_segments,
2673 description
2674 FROM wms_item_locations_kfv
2675 WHERE organization_id = p_organization_id
2676 AND subinventory_code = p_subinventory_code
2677 AND concatenated_segments LIKE (p_concatenated_segments )-- inv_project.get_locsegs(inventory_location_id,organization_id) LIKE (p_concatenated_segments || '%')
2678 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE) -- bug # 4866575
2679 AND (INV_MATERIAL_STATUS_GRP.is_status_applicable(NULL,
2680 NULL,
2681 4,
2682 NULL,
2683 NULL,
2684 organization_id,
2685 inventory_item_id,
2686 subinventory_code,
2687 inventory_location_id,
2688 NULL,
2689 NULL,
2690 'L') = 'Y')
2691 ORDER BY 2;
2692 END IF;
2693 END IF;
2694 END GET_CYC_LOCS;
2695
2696 PROCEDURE get_cyc_locs
2697 (x_locators OUT NOCOPY t_genref ,
2698 p_organization_id IN NUMBER ,
2699 p_subinventory_code IN VARCHAR2 ,
2700 p_concatenated_segments IN VARCHAR2 ,
2701 p_unscheduled_entry IN NUMBER ,
2702 p_cycle_count_header_id IN NUMBER ,
2703 p_project_id IN NUMBER ,
2704 p_task_id IN NUMBER ,
2705 p_alias IN VARCHAR2
2706 )
2707 IS
2708 l_proc_name CONSTANT VARCHAR2(30) := 'INV_UI_ITEM_SUB_LOCS';
2709 l_serial_discrepancy_option NUMBER;
2710 l_container_discrepancy_option NUMBER;
2711 l_debug NUMBER := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
2712 l_ispjm_org VARCHAR2(1);
2713 BEGIN
2714 IF (l_debug = 1) THEN
2715 Inv_log_util.trace('p_organization_id: =======> ' || p_organization_id ,l_proc_name ,9);
2716 Inv_log_util.trace('p_subinventory_code: =====> ' || p_subinventory_code , l_proc_name,9);
2717 Inv_log_util.trace('p_concatenated_segments: => ' || p_concatenated_segments , l_proc_name,9);
2718 Inv_log_util.trace('p_unscheduled_entry: =====> ' || p_unscheduled_entry , l_proc_name,9);
2719 Inv_log_util.trace('p_cycle_count_header_id: => ' || p_cycle_count_header_id , l_proc_name,9);
2720 Inv_log_util.trace('p_project_id: ============> ' || p_project_id , l_proc_name,9);
2721 Inv_log_util.trace('p_task_id: ===============> ' || p_task_id, l_proc_name,9);
2722 END IF;
2723
2724 IF p_alias IS NULL THEN
2725 get_cyc_locs(
2726 x_locators => x_locators
2727 , p_organization_id => p_organization_id
2728 , p_subinventory_code => p_subinventory_code
2729 , p_concatenated_segments => p_concatenated_segments
2730 , p_unscheduled_entry => p_unscheduled_entry
2731 , p_cycle_count_header_id => p_cycle_count_header_id
2732 , p_project_id => p_project_id
2733 , p_task_id => p_task_id
2734 );
2735 RETURN;
2736 END IF;
2737 BEGIN
2738 SELECT nvl(PROJECT_REFERENCE_ENABLED,'N')
2739 INTO l_ispjm_org
2740 FROM pjm_org_parameters
2741 WHERE organization_id=p_organization_id;
2742 EXCEPTION
2743 WHEN NO_DATA_FOUND THEN
2744 l_ispjm_org:='N';
2745 END; -- Get the cycle count discrepancy option flags
2746 SELECT NVL(serial_discrepancy_option, 2), NVL(container_discrepancy_option, 2)
2747 INTO l_serial_discrepancy_option, l_container_discrepancy_option
2748 FROM mtl_cycle_count_headers
2749 WHERE cycle_count_header_id = p_cycle_count_header_id;
2750
2751 IF (l_debug = 1) THEN
2752 Inv_log_util.trace('l_serial_discrepancy_option: ' || l_serial_discrepancy_option , l_proc_name,9);
2753 Inv_log_util.trace('l_container_discrepancy_option: ' || l_container_discrepancy_option, l_proc_name,9);
2754 END IF;
2755
2756 IF (p_unscheduled_entry = 2 AND
2757 l_serial_discrepancy_option = 2 AND
2758 l_container_discrepancy_option = 2) THEN
2759 -- unscheduled count entries are not allowed
2760 -- and serial and container discrepancies are also not allowed
2761 OPEN x_locators FOR
2762 SELECT UNIQUE mil.inventory_location_id,
2763 --mil.concatenated_segments concatenated_segments,--Bug4398337:Commented this line and added below line
2764 mil.locator_segments concatenated_segments,
2765 mil.description
2766 FROM wms_item_locations_kfv mil, mtl_cycle_count_entries mcce
2767 WHERE mcce.cycle_count_header_id = p_cycle_count_header_id
2768 AND mil.organization_id = p_organization_id
2769 AND mil.subinventory_code = p_subinventory_code
2770 AND NVL(mil.project_id,-1) = NVL(p_project_id,-1)
2771 AND NVL(mil.task_id,-1) = NVL(p_task_id,-1)
2772 AND mil.alias = p_alias
2773 AND mcce.organization_id = mil.organization_id
2774 AND mcce.subinventory = mil.subinventory_code
2775 AND mil.inventory_location_id = mcce.locator_id
2776 AND mcce.entry_status_code IN (1,3)
2777 AND NVL(mil.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE) -- bug # 4866575
2778 -- Bug# 2770853
2779 -- Check for material status at the locator level
2780 AND (INV_MATERIAL_STATUS_GRP.is_status_applicable(NULL,
2781 NULL,
2782 4,
2783 NULL,
2784 NULL,
2785 mcce.organization_id,
2786 mcce.inventory_item_id,
2787 mcce.subinventory,
2788 mcce.locator_id,
2789 NULL,
2790 NULL,
2791 'L') = 'Y')
2792 ORDER BY concatenated_segments;
2793 ELSE
2794 -- unscheduled count entries are allowed
2795 -- or serial or container discrepancy is allowed
2796
2797 IF (l_ispjm_org = 'Y' and p_project_id is not null ) then
2798 Inv_log_util.trace('p_ispjm_org = yes and p_project_id is not null' , 'INV_UI_ITEM_SUB_LOCS',9);
2799 IF ( p_task_id is not null ) then
2800 Inv_log_util.trace('task id is not null ' , 'INV_UI_ITEM_SUB_LOCS',9);
2801 OPEN x_locators FOR
2802 SELECT inventory_location_id,
2803 -- concatenated_segments, --Bug4398337:Commented this line and added below line
2804 locator_segments concatenated_segments,
2805 description
2806 FROM wms_item_locations_kfv
2807 WHERE organization_id = p_organization_id
2808 AND subinventory_code = p_subinventory_code
2809 AND alias = p_alias
2810 AND project_id = p_project_id
2811 AND task_id = p_task_id
2812 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE) -- bug # 4866575
2813 AND (INV_MATERIAL_STATUS_GRP.is_status_applicable(NULL,
2814 NULL,
2815 4,
2816 NULL,
2817 NULL,
2818 organization_id,
2819 inventory_item_id,
2820 subinventory_code,
2821 inventory_location_id,
2822 NULL,
2823 NULL,
2824 'L') = 'Y')
2825 ORDER BY 2;
2826 ELSE -- task_id is null then
2827 Inv_log_util.trace('Task is null ' , 'INV_UI_ITEM_SUB_LOCS',9);
2828
2829 OPEN x_locators FOR
2830 SELECT inventory_location_id,
2831 -- concatenated_segments ,--Bug4398337:Commented this line and added below line
2832 locator_segments concatenated_segments,
2833 description
2834 FROM wms_item_locations_kfv
2835 WHERE organization_id = p_organization_id
2836 AND subinventory_code = p_subinventory_code
2837 AND alias = p_alias
2838 --inv_project.get_locsegs(inventory_location_id,organization_id) LIKE (p_concatenated_segments || '%')
2839 AND project_id = p_project_id
2840 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE) -- bug # 4866575
2841 AND (INV_MATERIAL_STATUS_GRP.is_status_applicable(NULL,
2842 NULL,
2843 4,
2844 NULL,
2845 NULL,
2846 organization_id,
2847 inventory_item_id,
2848 subinventory_code,
2849 inventory_location_id,
2850 NULL,
2851 NULL,
2852 'L') = 'Y')
2853 ORDER BY 2;
2854
2855 END IF;
2856 ELSE -- non pjm org or project is not passed
2857 Inv_log_util.trace('non pjm org or project is not passed' , 'INV_UI_ITEM_SUB_LOCS',9);
2858 OPEN x_locators FOR
2859 SELECT inventory_location_id,
2860 -- concatenated_segments, --Bug4398337:Commented this line and added below line
2861 locator_segments concatenated_segments,
2862 description
2863 FROM wms_item_locations_kfv
2864 WHERE organization_id = p_organization_id
2865 AND subinventory_code = p_subinventory_code
2866 AND alias = p_alias
2867 -- inv_project.get_locsegs(inventory_location_id,organization_id) LIKE (p_concatenated_segments || '%')
2868 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE) -- bug # 4866575
2869 AND (INV_MATERIAL_STATUS_GRP.is_status_applicable(NULL,
2870 NULL,
2871 4,
2872 NULL,
2873 NULL,
2874 organization_id,
2875 inventory_item_id,
2876 subinventory_code,
2877 inventory_location_id,
2878 NULL,
2879 NULL,
2880 'L') = 'Y')
2881 ORDER BY 2;
2882 END IF;
2883 END IF;
2884 END GET_CYC_LOCS;
2885
2886
2887 -- Consignment and VMI Changes: Added Planning Org, TP Type, Owning Org and TP Type.
2888 PROCEDURE get_valid_lpn_org_level(
2889 x_lpns OUT NOCOPY t_genref
2890 , p_organization_id IN NUMBER
2891 , p_lpn_segments IN VARCHAR2
2892 , p_planning_org_id IN NUMBER
2893 , p_planning_tp_type IN NUMBER
2894 , p_owning_org_id IN NUMBER
2895 , p_owning_tp_type IN NUMBER
2896 ) IS
2897 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
2898 BEGIN
2899 OPEN x_lpns FOR
2900 SELECT DISTINCT a.license_plate_number
2901 , a.outermost_lpn_id
2902 , a.subinventory_code
2903 , NVL(a.locator_id, 0)
2904 , NVL(b.asset_inventory, '0')
2905 , 0
2906 , inv_project.get_locsegs(a.locator_id, p_organization_id)
2907 , inv_project.get_project_id
2908 , inv_project.get_project_number
2909 , inv_project.get_task_id
2910 , inv_project.get_task_number
2911 FROM wms_license_plate_numbers a, mtl_secondary_inventories b
2912 WHERE a.organization_id = p_organization_id
2913 AND (a.lpn_context = 1 OR a.lpn_context = 11)
2914 AND b.organization_id(+) = a.organization_id
2915 AND b.secondary_inventory_name(+) = a.subinventory_code
2916 AND NVL(b.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
2917 AND a.license_plate_number LIKE (p_lpn_segments)
2918 AND a.parent_lpn_id IS NULL
2919 AND (p_owning_org_id IS NULL
2920 OR EXISTS(SELECT 1 FROM mtl_onhand_quantities_detail moqd
2921 ,wms_license_plate_numbers wlpn
2922 WHERE moqd.lpn_id in (wlpn.lpn_id)
2923 AND wlpn.outermost_lpn_id = a.outermost_lpn_id
2924 AND moqd.organization_id = a.organization_id
2925 AND moqd.owning_organization_id = p_owning_org_id
2926 AND moqd.owning_tp_type = p_owning_tp_type))
2927 AND (p_planning_org_id IS NULL
2928 OR EXISTS(SELECT 1 FROM mtl_onhand_quantities_detail moqd
2929 ,wms_license_plate_numbers wlpn
2930 WHERE moqd.lpn_id in (wlpn.lpn_id)
2931 AND wlpn.outermost_lpn_id = a.outermost_lpn_id
2932 AND moqd.organization_id = a.organization_id
2933 AND moqd.planning_organization_id = p_planning_org_id
2934 AND moqd.planning_tp_type = p_planning_tp_type));
2935 END get_valid_lpn_org_level;
2936
2937 --Bug 5512205 Introduced a new overloaded procedure that validates the LPN status before populating the LPN LOV for sub xfer
2938 PROCEDURE get_valid_lpn_org_level(
2939 x_lpns OUT NOCOPY t_genref
2940 , p_organization_id IN NUMBER
2941 , p_lpn_segments IN VARCHAR2
2942 , p_planning_org_id IN NUMBER
2943 , p_planning_tp_type IN NUMBER
2944 , p_owning_org_id IN NUMBER
2945 , p_owning_tp_type IN NUMBER
2946 , p_to_organization_id IN NUMBER
2947 , p_transaction_type_id IN NUMBER
2948 , p_wms_installed IN VARCHAR2
2949 ) IS
2950 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
2951 BEGIN
2952 OPEN x_lpns FOR
2953 SELECT DISTINCT a.license_plate_number
2954 , a.outermost_lpn_id
2955 , a.subinventory_code
2956 , NVL(a.locator_id, 0)
2957 , NVL(b.asset_inventory, '0')
2958 , 0
2959 , inv_project.get_locsegs(a.locator_id, p_organization_id)
2960 , inv_project.get_project_id
2961 , inv_project.get_project_number
2962 , inv_project.get_task_id
2963 , inv_project.get_task_number
2964 FROM wms_license_plate_numbers a, mtl_secondary_inventories b
2965 WHERE a.organization_id = p_organization_id
2966 AND (a.lpn_context = 1 OR a.lpn_context = 11)
2967 AND b.organization_id(+) = a.organization_id
2968 AND b.secondary_inventory_name(+) = a.subinventory_code
2969 AND NVL(b.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
2970 AND a.license_plate_number LIKE (p_lpn_segments)
2971 AND a.parent_lpn_id IS NULL
2972 AND vaildate_lpn_status(a.outermost_lpn_id
2973 ,a.organization_id
2974 ,p_to_organization_id
2975 ,p_wms_installed
2976 ,p_transaction_type_id) = 'Y'
2977 AND (p_owning_org_id IS NULL
2978 OR EXISTS(SELECT 1 FROM mtl_onhand_quantities_detail moqd
2979 ,wms_license_plate_numbers wlpn
2980 WHERE moqd.lpn_id in (wlpn.lpn_id)
2981 AND wlpn.outermost_lpn_id = a.outermost_lpn_id
2982 AND moqd.organization_id = a.organization_id
2983 AND moqd.owning_organization_id = p_owning_org_id
2984 AND moqd.owning_tp_type = p_owning_tp_type))
2985 AND (p_planning_org_id IS NULL
2986 OR EXISTS(SELECT 1 FROM mtl_onhand_quantities_detail moqd
2987 ,wms_license_plate_numbers wlpn
2988 WHERE moqd.lpn_id in (wlpn.lpn_id)
2989 AND wlpn.outermost_lpn_id = a.outermost_lpn_id
2990 AND moqd.organization_id = a.organization_id
2991 AND moqd.planning_organization_id = p_planning_org_id
2992 AND moqd.planning_tp_type = p_planning_tp_type));
2993 END get_valid_lpn_org_level;
2994 --End Bug 5512205
2995
2996 FUNCTION validate_lpn_for_toorg(p_lpn_id IN NUMBER, p_to_organization_id IN NUMBER, p_orgid IN NUMBER, p_transaction_type_id IN NUMBER)
2997 RETURN VARCHAR2 IS
2998 x_return VARCHAR(1);
2999 l_count NUMBER;
3000 l_item_id NUMBER;
3001 l_invalid_count NUMBER := 0;
3002
3003 CURSOR l_item_cursor IS
3004 SELECT DISTINCT inventory_item_id
3005 FROM wms_lpn_contents
3006 WHERE parent_lpn_id IN (SELECT lpn_id
3007 FROM wms_license_plate_numbers
3008 WHERE outermost_lpn_id = p_lpn_id)
3009 AND inventory_item_id IS NOT NULL;
3010 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
3011 BEGIN
3012 x_return := 'Y';
3013
3014 IF (p_orgid IS NOT NULL AND p_transaction_type_id = 3 ) THEN
3015
3016 -- bug#3440453 Split the existing SQL into 2 for performance reasons
3017 -- re-using the existing item_cursor
3018 -- checking for invalid combinations for each content in the outermost lpn
3019 -- and exitting from the loop as soon as one invalid combination is found.
3020
3021 OPEN l_item_cursor;
3022 LOOP --loop for all the contents inside the outermost LPN
3023 FETCH l_item_cursor INTO l_item_id;
3024 EXIT WHEN l_item_cursor%NOTFOUND;
3025
3026 BEGIN
3027 -- Check for invalid item control codes.
3028 SELECT 1
3029 INTO l_invalid_count
3030 FROM dual
3031 WHERE EXISTS (SELECT a.inventory_item_id
3032 FROM mtl_system_items a
3033 , mtl_system_items b
3034 WHERE a.inventory_item_id = b.inventory_item_id
3035 AND a.organization_id = p_orgid
3036 AND b.organization_id = p_to_organization_id
3037 AND a.inventory_item_id = l_item_id
3038 AND ((a.serial_number_control_code IN (1,6) AND b.serial_number_control_code IN (2,5))
3039 OR
3040 (a.revision_qty_control_code = 1 AND b.revision_qty_control_code = 2)
3041 OR
3042 (a.lot_control_code = 1 AND b.lot_control_code = 2))
3043 );
3044
3045 IF (l_invalid_count <> 0) THEN
3046 x_return := 'N';
3047 IF l_item_cursor%isopen THEN
3048 CLOSE l_item_cursor;
3049 END IF;
3050 RETURN x_return;
3051 END IF;
3052
3053 EXCEPTION
3054 WHEN no_data_found THEN
3055
3056 -- No data found can be for 2 reasons
3057 -- a. Item doesn't exist in TO Org which is a failure case
3058 -- b. The lot/serial/revision control code combinations are perfect
3059 -- We should check for scenario (a) and throw error.
3060 SELECT COUNT(*)
3061 INTO l_count
3062 FROM mtl_system_items
3063 WHERE organization_id = p_to_organization_id
3064 AND inventory_item_id = l_item_id;
3065
3066 IF l_count = 1 THEN
3067 x_return := 'Y';
3068 ELSE
3069 x_return := 'N';
3070 IF l_item_cursor%isopen THEN
3071 CLOSE l_item_cursor;
3072 END IF;
3073 RETURN x_return;
3074 END IF;
3075
3076 WHEN OTHERS THEN
3077 x_return := 'N';
3078 IF l_item_cursor%isopen THEN
3079 CLOSE l_item_cursor;
3080 END IF;
3081 RETURN x_return;
3082 END;
3083
3084 END LOOP;--loop for all the contents inside the outermost LPN
3085
3086 IF l_item_cursor%isopen THEN
3087 CLOSE l_item_cursor;
3088 END IF;
3089
3090 ELSE --Interorg transfer. Just check whether item exits in the dest org
3091
3092 OPEN l_item_cursor;
3093 LOOP
3094 FETCH l_item_cursor INTO l_item_id;
3095 EXIT WHEN l_item_cursor%NOTFOUND;
3096 l_count := 0;
3097
3098 SELECT COUNT(*)
3099 INTO l_count
3100 FROM mtl_system_items
3101 WHERE organization_id = p_to_organization_id
3102 AND inventory_item_id = l_item_id;
3103
3104 IF l_count = 1 THEN
3105 x_return := 'Y';
3106 ELSE
3107 x_return := 'N';
3108 IF l_item_cursor%isopen THEN
3109 CLOSE l_item_cursor;
3110 END IF;
3111 RETURN x_return;
3112 END IF;
3113 END LOOP;
3114
3115 IF l_item_cursor%isopen THEN
3116 CLOSE l_item_cursor;
3117 END IF;
3118 END IF;
3119
3120 RETURN x_return;
3121 END validate_lpn_for_toorg;
3122
3123 --- Obsolete
3124 PROCEDURE get_valid_lpn_tosubs(
3125 x_to_sub OUT NOCOPY t_genref
3126 , p_organization_id IN NUMBER
3127 , p_lpn_id IN NUMBER
3128 , p_from_secondary_name IN VARCHAR2
3129 , p_from_sub_asset_inventory IN VARCHAR2
3130 , p_transaction_action_id IN NUMBER
3131 , p_to_organization_id IN NUMBER
3132 , p_transaction_type_id IN NUMBER
3133 , p_wms_installed IN VARCHAR2
3134 , p_secondary_inventory_name IN VARCHAR2
3135 ) IS
3136 l_org NUMBER;
3137 l_lpn_rsvd NUMBER;
3138 l_debug NUMBER;
3139 l_procedure_name VARCHAR2(30);
3140 BEGIN
3141 l_debug := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
3142 l_procedure_name := 'GET_VALID_LPN_TOSUBS';
3143
3144 IF p_transaction_action_id IN (3, 21) THEN
3145 l_org := p_to_organization_id;
3146 ELSE
3147 l_org := p_organization_id;
3148 END IF;
3149
3150 /* LPN reservation impact */
3151 BEGIN
3152 /*SELECT COUNT(*)
3153 INTO l_lpn_rsvd
3154 FROM mtl_reservations
3155 WHERE lpn_id = p_lpn_id;*/
3156
3157 --Bug 5942895 Modified above query to consider nesting of LPNs.
3158 SELECT COUNT(*)
3159 INTO l_lpn_rsvd
3160 FROM mtl_reservations
3161 WHERE lpn_id IN (SELECT lpn_id
3162 FROM wms_license_plate_numbers
3163 WHERE outermost_lpn_id = p_lpn_id);
3164 EXCEPTION
3165 WHEN NO_DATA_FOUND THEN
3166 l_lpn_rsvd := 0;
3167 WHEN OTHERS THEN
3168 l_lpn_rsvd := 0;
3169 END;
3170
3171 IF l_lpn_rsvd = 0 THEN -- the lpn is not reserved
3172 OPEN x_to_sub FOR
3173 SELECT secondary_inventory_name
3174 , NVL(locator_type, 1)
3175 , description
3176 , asset_inventory
3177 , lpn_controlled_flag
3178 , enable_locator_alias
3179 FROM mtl_secondary_inventories
3180 WHERE organization_id = l_org
3181 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
3182 AND inv_ui_item_sub_loc_lovs.vaildate_to_lpn_sub(p_lpn_id, secondary_inventory_name, l_org, p_from_sub_asset_inventory, p_wms_installed, p_transaction_type_id) = 'Y'
3183 AND secondary_inventory_name LIKE (p_secondary_inventory_name);
3184 ELSE
3185 OPEN x_to_sub FOR
3186 SELECT secondary_inventory_name
3187 , NVL(locator_type, 1)
3188 , description
3189 , asset_inventory
3190 , lpn_controlled_flag
3191 , enable_locator_alias
3192 FROM mtl_secondary_inventories
3193 WHERE organization_id = l_org
3194 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
3195 AND inv_ui_item_sub_loc_lovs.vaildate_to_lpn_sub(p_lpn_id, secondary_inventory_name, l_org, p_from_sub_asset_inventory, p_wms_installed, p_transaction_type_id) = 'Y'
3196 AND secondary_inventory_name LIKE (p_secondary_inventory_name)
3197 AND reservable_type = 1
3198 AND lpn_controlled_flag = 1;
3199 END IF;
3200 END get_valid_lpn_tosubs;
3201
3202 FUNCTION vaildate_to_lpn_sub(p_lpn_id IN NUMBER, p_to_subinventory IN VARCHAR2, p_orgid IN NUMBER, p_from_sub_asset_inventory IN VARCHAR2, p_wms_installed IN VARCHAR2, p_transaction_type_id IN NUMBER)
3203 RETURN VARCHAR2 IS
3204 l_item_id NUMBER;
3205 l_restrict_subinventories_code NUMBER;
3206 l_inventory_asset_flag VARCHAR2(1);
3207 l_expense_to_asset VARCHAR2(1);
3208 l_count NUMBER;
3209 x_return VARCHAR2(1);
3210 l_content_type NUMBER;
3211 -- Changed for Bug 1795328
3212 l_lpn_content NUMBER;
3213
3214 CURSOR l_item_cursor IS
3215 SELECT DISTINCT inventory_item_id
3216 FROM wms_lpn_contents
3217 WHERE parent_lpn_id IN (SELECT lpn_id
3218 FROM wms_license_plate_numbers
3219 WHERE outermost_lpn_id = p_lpn_id)
3220 AND inventory_item_id IS NOT NULL;
3221 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
3222 BEGIN
3223 /*
3224 SELECT DISTINCT content_type INTO l_content_type
3225 FROM wms_lpn_contents
3226 WHERE outermost_lpn_id = p_lpn_id;
3227
3228 IF l_content_type NOT IN (1) THEN
3229 RETURN 'Y';
3230 END IF;
3231 */
3232
3233 OPEN l_item_cursor;
3234 l_lpn_content := 0;
3235
3236 LOOP
3237 FETCH l_item_cursor INTO l_item_id;
3238 EXIT WHEN l_item_cursor%NOTFOUND;
3239 l_lpn_content := 1;
3240
3241 IF inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_orgid, l_item_id, p_to_subinventory, NULL, NULL, NULL, 'Z') = 'Y' THEN
3242 SELECT restrict_subinventories_code
3243 , inventory_asset_flag
3244 INTO l_restrict_subinventories_code
3245 , l_inventory_asset_flag
3246 FROM mtl_system_items
3247 WHERE inventory_item_id = l_item_id
3248 AND organization_id = p_orgid;
3249
3250 fnd_profile.get('INV:EXPENSE_TO_ASSET_TRANSFER', l_expense_to_asset);
3251
3252 IF (NVL(l_expense_to_asset, '2') = '1') THEN
3253 IF l_restrict_subinventories_code = 1 THEN
3254 SELECT COUNT(*)
3255 INTO l_count
3256 FROM mtl_item_sub_inventories
3257 WHERE inventory_item_id = l_item_id
3258 AND organization_id = p_orgid
3259 AND secondary_inventory = p_to_subinventory;
3260
3261 IF l_count = 0 THEN
3262 x_return := 'N';
3263 RETURN x_return;
3264 ELSE
3265 x_return := 'Y';
3266 END IF;
3267 ELSE
3268 x_return := 'Y';
3269 END IF;
3270 ELSE
3271 IF l_restrict_subinventories_code = 1 THEN
3272 IF l_inventory_asset_flag = 'Y' THEN
3273 IF p_from_sub_asset_inventory = 1 THEN
3274 SELECT COUNT(*)
3275 INTO l_count
3276 FROM mtl_item_sub_inventories
3277 WHERE inventory_item_id = l_item_id
3278 AND organization_id = p_orgid
3279 AND secondary_inventory = p_to_subinventory;
3280
3281 IF l_count = 0 THEN
3282 x_return := 'N';
3283 RETURN x_return;
3284 ELSE
3285 x_return := 'Y';
3286 END IF;
3287 ELSE
3288 SELECT COUNT(*)
3289 INTO l_count
3290 FROM mtl_item_sub_exp_val_v
3291 WHERE inventory_item_id = l_item_id
3292 AND organization_id = p_orgid
3293 AND secondary_inventory_name = p_to_subinventory;
3294
3295 IF l_count = 0 THEN
3296 x_return := 'N';
3297 RETURN x_return;
3298 ELSE
3299 x_return := 'Y';
3300 END IF;
3301 END IF;
3302 ELSE
3303 SELECT COUNT(*)
3304 INTO l_count
3305 FROM mtl_item_sub_inventories
3306 WHERE inventory_item_id = l_item_id
3307 AND organization_id = p_orgid
3308 AND secondary_inventory = p_to_subinventory;
3309
3310 IF l_count = 0 THEN
3311 x_return := 'N';
3312 RETURN x_return;
3313 ELSE
3314 x_return := 'Y';
3315 END IF;
3316 END IF;
3317 ELSE
3318 --Bug#7417734.added the IF block below
3319 IF l_inventory_asset_flag = 'Y' AND p_from_sub_asset_inventory = 2 THEN
3320 SELECT COUNT(*)
3321 INTO l_count
3322 FROM mtl_secondary_inventories msi
3323 WHERE msi.organization_id = p_orgid
3324 AND msi.asset_inventory = 2
3325 AND NVL(msi.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
3326 AND msi.secondary_inventory_name = p_to_subinventory ;
3327 IF l_count = 0 THEN
3328 x_return := 'N';
3329 RETURN x_return;
3330 ELSE
3331 x_return := 'Y';
3332 RETURN x_return;
3333 END IF;
3334 END IF;
3335
3336 x_return := 'Y';
3337 END IF;
3338 --dbms_output.putline('jj');
3339 END IF;
3340 ELSE
3341 x_return := 'N';
3342 RETURN x_return;
3343 END IF;
3344 END LOOP;
3345
3346 CLOSE l_item_cursor;
3347
3348 -- Changed for 1795328
3349 IF l_lpn_content = 0 THEN
3350 x_return := 'Y';
3351 END IF;
3352
3353 --END ;
3354
3355 RETURN x_return;
3356 END vaildate_to_lpn_sub;
3357
3358 FUNCTION vaildate_lpn_toloc(p_lpn_id IN NUMBER, p_to_subinventory IN VARCHAR2, p_orgid IN NUMBER, p_locator_id IN NUMBER, p_wms_installed IN VARCHAR2, p_transaction_type_id IN NUMBER)
3359 RETURN VARCHAR2 IS
3360 l_item_id NUMBER;
3361 l_restrict_locators_code NUMBER;
3362 l_count NUMBER;
3363 x_return VARCHAR2(1);
3364 -- Changed for Bug 1795328
3365 l_lpn_content NUMBER;
3366
3367 CURSOR l_item_cursor IS
3368 SELECT DISTINCT inventory_item_id
3369 FROM wms_lpn_contents
3370 WHERE parent_lpn_id IN (SELECT lpn_id
3371 FROM wms_license_plate_numbers
3372 WHERE outermost_lpn_id = p_lpn_id)
3373 AND inventory_item_id IS NOT NULL;
3374 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
3375 BEGIN
3376 IF inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_orgid, l_item_id, p_to_subinventory, p_locator_id, NULL, NULL, 'L') = 'Y' THEN
3377 OPEN l_item_cursor;
3378 l_lpn_content := 0;
3379
3380 LOOP
3381 FETCH l_item_cursor INTO l_item_id;
3382 EXIT WHEN l_item_cursor%NOTFOUND;
3383 l_lpn_content := 1;
3384
3385 SELECT restrict_locators_code
3386 INTO l_restrict_locators_code
3387 FROM mtl_system_items
3388 WHERE inventory_item_id = l_item_id
3389 AND organization_id = p_orgid;
3390
3391 IF l_restrict_locators_code = 1 THEN
3392 SELECT COUNT(*)
3393 INTO l_count
3394 FROM mtl_secondary_locators
3395 WHERE p_locator_id = secondary_locator
3396 AND inventory_item_id = l_item_id
3397 AND organization_id = p_orgid;
3398
3399 IF l_count = 0 THEN
3400 x_return := 'N';
3401 ELSE
3402 x_return := 'Y';
3403 END IF;
3404 ELSE
3405 x_return := 'Y';
3406 END IF;
3407 END LOOP;
3408
3409 CLOSE l_item_cursor;
3410 ELSE
3411 --x_return := 'Y';
3412 -- bug 3390030, the function should return N if the material status
3413 -- does not return Y
3414 x_return := 'N';
3415 END IF;
3416
3417 -- Changed for 1795328
3418 IF l_lpn_content = 0 THEN
3419 x_return := 'Y';
3420 END IF;
3421
3422 RETURN x_return;
3423 END vaildate_lpn_toloc;
3424
3425 PROCEDURE get_lpnloc_lov(x_locators OUT NOCOPY t_genref, p_organization_id IN NUMBER, p_lpn_id IN NUMBER, p_subinventory_code IN VARCHAR2, p_concatenated_segments IN VARCHAR2, p_transaction_type_id IN NUMBER, p_wms_installed IN VARCHAR2) IS
3426 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
3427 BEGIN
3428 OPEN x_locators FOR
3429 SELECT inventory_location_id
3430 --, concatenated_segments--Bug4398337:Commented this line and added below line
3431 , locator_segments concatenated_segments
3432 , description
3433 FROM wms_item_locations_kfv
3434 WHERE organization_id = p_organization_id
3435 AND subinventory_code = p_subinventory_code
3436 AND concatenated_segments LIKE (p_concatenated_segments)
3437 AND inv_ui_item_sub_loc_lovs.vaildate_lpn_toloc(p_lpn_id, p_subinventory_code, p_organization_id, inventory_location_id, p_wms_installed, p_transaction_type_id) = 'Y';
3438 END get_lpnloc_lov;
3439
3440 FUNCTION validate_sub_loc_status(p_lpn IN VARCHAR2, p_org_id IN NUMBER, p_sub IN VARCHAR2, p_loc_id IN NUMBER, p_not_lpn_id IN VARCHAR2 := NULL, p_parent_lpn_id IN VARCHAR2 := '0', p_txn_type_id IN NUMBER)
3441 RETURN VARCHAR2 IS
3442 x_return VARCHAR2(1) := 'U';
3443 pack_sub_check VARCHAR2(1) := 'U';
3444 pack_loc_check VARCHAR2(1) := 'U';
3445 unpack_sub_check VARCHAR2(1) := 'U';
3446 unpack_loc_check VARCHAR2(1) := 'U';
3447 oth_val VARCHAR2(1) := 'U';
3448 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
3449 BEGIN
3450 BEGIN
3451 SELECT 'Y'
3452 INTO oth_val
3453 FROM DUAL
3454 WHERE EXISTS( SELECT wlpn.license_plate_number
3455 FROM wms_license_plate_numbers wlpn
3456 WHERE (wlpn.organization_id = p_org_id
3457 AND wlpn.lpn_context = 5
3458 AND license_plate_number = p_lpn
3459 )
3460 OR (wlpn.organization_id = p_org_id
3461 AND (wlpn.lpn_context = 1
3462 OR wlpn.lpn_context = 11
3463 )
3464 AND NVL(subinventory_code, '@') = NVL(p_sub, NVL(subinventory_code, '@'))
3465 AND NVL(locator_id, '0') = NVL(TO_NUMBER(p_loc_id), NVL(locator_id, '0'))
3466 AND NOT lpn_id = NVL(TO_NUMBER(p_not_lpn_id), -999)
3467 AND NVL(parent_lpn_id, 0) = NVL(TO_NUMBER(p_parent_lpn_id), NVL(parent_lpn_id, 0))
3468 AND license_plate_number = p_lpn
3469 ));
3470 EXCEPTION
3471 WHEN NO_DATA_FOUND THEN
3472 x_return := 'N';
3473 RETURN x_return;
3474 END;
3475
3476 IF oth_val <> 'Y' THEN
3477 x_return := 'N';
3478 RETURN x_return;
3479 END IF;
3480
3481 IF p_txn_type_id IN (500, 502) THEN
3482 pack_sub_check := inv_material_status_grp.is_status_applicable('TRUE', NULL, 500, NULL, NULL, p_org_id, NULL, p_sub, p_loc_id, NULL, NULL, 'Z');
3483 pack_loc_check := inv_material_status_grp.is_status_applicable('TRUE', NULL, 500, NULL, NULL, p_org_id, NULL, p_sub, p_loc_id, NULL, NULL, 'L');
3484
3485 IF pack_sub_check = 'N'
3486 OR pack_loc_check = 'N' THEN
3487 x_return := 'N';
3488 RETURN x_return;
3489 END IF;
3490 ELSIF p_txn_type_id IN (501, 502) THEN
3491 unpack_sub_check := inv_material_status_grp.is_status_applicable('TRUE', NULL, 501, NULL, NULL, p_org_id, NULL, p_sub, p_loc_id, NULL, NULL, 'Z');
3492 unpack_loc_check := inv_material_status_grp.is_status_applicable('TRUE', NULL, 501, NULL, NULL, p_org_id, NULL, p_sub, p_loc_id, NULL, NULL, 'L');
3493
3494 IF unpack_sub_check = 'N'
3495 OR unpack_loc_check = 'N' THEN
3496 x_return := 'N';
3497 RETURN x_return;
3498 END IF;
3499 END IF;
3500
3501 x_return := 'Y';
3502 RETURN x_return;
3503 END validate_sub_loc_status;
3504
3505 FUNCTION vaildate_lpn_status(p_lpn_id IN NUMBER, p_orgid IN NUMBER, p_to_org_id IN NUMBER, p_wms_installed IN VARCHAR2, p_transaction_type_id IN NUMBER)
3506 RETURN VARCHAR2 IS
3507 x_return VARCHAR2(1);
3508
3509 TYPE l_rec IS RECORD(
3510 serial_number VARCHAR2(30)
3511 -- Increased lot size to 80 Char - Mercy Thomas - B4625329
3512 , lot_number VARCHAR2(80)
3513 , inventory_item_id NUMBER
3514 , subinventory_code VARCHAR2(10)
3515 , locator_id NUMBER);
3516
3517 l_record l_rec;
3518
3519 CURSOR l_cursor IS
3520 SELECT DISTINCT wlc.serial_number
3521 , wlc.lot_number
3522 , wlc.inventory_item_id
3523 , wlpn.subinventory_code
3524 , wlpn.locator_id
3525 FROM wms_lpn_contents wlc, wms_license_plate_numbers wlpn
3526 WHERE wlc.organization_id = p_orgid
3527 AND wlc.parent_lpn_id = wlpn.lpn_id
3528 AND wlc.organization_id = wlpn.organization_id
3529 AND wlc.parent_lpn_id IN (SELECT lpn_id
3530 FROM wms_license_plate_numbers
3531 WHERE outermost_lpn_id = p_lpn_id)
3532 AND wlc.inventory_item_id IS NOT NULL
3533 UNION
3534 SELECT DISTINCT serial_number
3535 , lot_number
3536 , inventory_item_id
3537 , current_subinventory_code
3538 , current_locator_id
3539 FROM mtl_serial_numbers
3540 WHERE current_organization_id = p_orgid
3541 AND lpn_id IN (SELECT lpn_id
3542 FROM wms_license_plate_numbers
3543 WHERE outermost_lpn_id = p_lpn_id);
3544 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
3545 BEGIN
3546 OPEN l_cursor;
3547
3548 LOOP
3549 FETCH l_cursor INTO l_record;
3550 EXIT WHEN l_cursor%NOTFOUND;
3551 --Added p_lpn_id for bug 13415614
3552 IF inv_material_status_grp.is_status_applicable(p_wms_installed, NULL,
3553 p_transaction_type_id, NULL, NULL, p_orgid, l_record.inventory_item_id,
3554 l_record.subinventory_code, l_record.locator_id, l_record.lot_number, l_record.serial_number,
3555 'A',p_lpn_id) = 'Y' THEN
3556 x_return := 'Y';
3557 ELSE
3558 x_return := 'N';
3559 RETURN x_return;
3560 END IF;
3561 END LOOP;
3562
3563 x_return := 'Y';
3564 CLOSE l_cursor;
3565 RETURN x_return;
3566 END vaildate_lpn_status;
3567
3568 -- Name: GET_CGUPDATE_SUBS
3569 --
3570 -- Input parameters:
3571 -- p_subinventory_code - restricts the subinventory to those like
3572 -- the user inputted text if given
3573 -- p_organization_id - restricts LOV SQL to current org
3574 -- p_inventory_item_id - restricts the subs to only those having
3575 -- this item.
3576 -- p_revision
3577 --
3578 -- Output parameters:
3579 -- x_cgupdate_sub_lov - Returns LOV rows as reference cursor
3580 --
3581 -- Functions: This API returns the valid subs associated with
3582 -- the Cost Group Update
3583 --
3584 -- Obsolete
3585 PROCEDURE get_cgupdate_subs(
3586 x_cgupdate_sub_lov OUT NOCOPY t_genref
3587 , p_subinventory_code IN VARCHAR2
3588 , p_organization_id IN NUMBER
3589 , p_inventory_item_id IN NUMBER
3590 , p_revision IN VARCHAR2
3591 ) IS
3592 l_debug NUMBER;
3593 BEGIN
3594 l_debug := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
3595 -- Include only those subinventories which are in the current org
3596 -- and include material with the item number entered
3597 OPEN x_cgupdate_sub_lov FOR
3598 SELECT DISTINCT moq.subinventory_code
3599 , '0'
3600 , msi.description
3601 , '0'
3602 , msi.lpn_controlled_flag
3603 , msi.enable_locator_alias
3604 FROM mtl_secondary_inventories msi, MTL_ONHAND_QUANTITIES_DETAIL moq
3605 WHERE msi.secondary_inventory_name = moq.subinventory_code
3606 AND msi.organization_id = moq.organization_id
3607 AND inv_material_status_grp.is_status_applicable('TRUE', NULL, 86, NULL, NULL, p_organization_id, p_inventory_item_id, moq.subinventory_code, NULL, NULL, NULL, 'Z') = 'Y'
3608 AND moq.containerized_flag = 2
3609 AND moq.subinventory_code LIKE (p_subinventory_code)
3610 AND (moq.revision = p_revision
3611 OR (moq.revision IS NULL
3612 AND p_revision IS NULL
3613 )
3614 )
3615 AND moq.inventory_item_id = p_inventory_item_id
3616 AND moq.organization_id = p_organization_id
3617 ORDER BY moq.subinventory_code;
3618 END get_cgupdate_subs;
3619
3620 -- Name: GET_CGUPDATE_LOCS
3621 --
3622 -- Input parameters:
3623 -- p_organization_id - restricts LOV SQL to current org
3624 -- p_subinventory_code - restricts LOV to the current subinventory
3625 -- p_concatenated_segments - restricts the locator to those that are
3626 -- similar to the user inputted text.
3627 -- locators are a key flex field so this
3628 -- is how the user represents/identifies locators
3629 -- p_inventory_item_id -
3630 -- p_revision
3631 --
3632 --
3633 -- Output parameters:
3634 -- x_locators - Returns LOV rows as reference cursor
3635 --
3636 -- Functions: This API returns the valid locators associated with a
3637 -- cycle count
3638 --
3639 /* PJM-WMS Integration:Return only the the physical locators.
3640 * Use the table mtl_item_locations instead of mtl_item_locations_kfv.
3641 * Use the function INV_PROJECT.get_locsegs() to retrieve the
3642 * concatenated segments.
3643 */
3644 PROCEDURE get_cgupdate_locs(x_locators OUT NOCOPY t_genref, p_organization_id IN NUMBER, p_subinventory_code IN VARCHAR2, p_concatenated_segments IN VARCHAR2, p_inventory_item_id IN NUMBER, p_revision IN VARCHAR2) IS
3645 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
3646 BEGIN
3647 OPEN x_locators FOR
3648 SELECT moq.locator_id
3649 --, mil.concatenated_segments--Bug4398337:Commented this line and added below line
3650 , mil.locator_segments concatenated_segments
3651 , mil.description
3652 FROM wms_item_locations_kfv mil, MTL_ONHAND_QUANTITIES_DETAIL moq
3653 WHERE mil.concatenated_segments LIKE (p_concatenated_segments)
3654 AND mil.inventory_location_id = moq.locator_id
3655 AND mil.organization_id = p_organization_id
3656 -- Bug 2325664 AND mil.physical_location_id is null -- PJM-WMS Integration
3657 AND mil.project_id IS NULL
3658 AND mil.task_id IS NULL
3659 AND inv_material_status_grp.is_status_applicable('TRUE', NULL, 86, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, moq.locator_id, NULL, NULL, 'L') = 'Y'
3660 AND moq.containerized_flag = 2
3661 AND (moq.revision = p_revision
3662 OR (moq.revision IS NULL
3663 AND p_revision IS NULL
3664 )
3665 )
3666 AND moq.inventory_item_id = p_inventory_item_id
3667 AND moq.locator_id IS NOT NULL
3668 AND moq.subinventory_code = p_subinventory_code
3669 AND moq.organization_id = p_organization_id
3670 GROUP BY moq.locator_id, mil.locator_segments
3671 --mil.concatenated_segments BUG16203877 GROUP BY ISSUE
3672 , mil.description
3673 ORDER BY 2;
3674 END get_cgupdate_locs;
3675
3676 PROCEDURE get_cgupdate_locs(
3677 x_locators OUT NOCOPY t_genref,
3678 p_organization_id IN NUMBER,
3679 p_subinventory_code IN VARCHAR2,
3680 p_concatenated_segments IN VARCHAR2,
3681 p_inventory_item_id IN NUMBER,
3682 p_revision IN VARCHAR2,
3683 p_alias IN VARCHAR2
3684 ) IS
3685 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
3686 BEGIN
3687 IF p_alias IS NULL THEN
3688 get_cgupdate_locs(
3689 x_locators => x_locators
3690 ,p_organization_id => p_organization_id
3691 ,p_subinventory_code => p_subinventory_code
3692 ,p_concatenated_segments => p_concatenated_segments
3693 ,p_inventory_item_id => p_inventory_item_id
3694 ,p_revision => p_revision
3695 );
3696 RETURN;
3697 END IF;
3698 OPEN x_locators FOR
3699 SELECT moq.locator_id
3700 --, mil.concatenated_segments--Bug4398337:Commented this line and added below line
3701 , mil.locator_segments concatenated_segments
3702 , mil.description
3703 FROM wms_item_locations_kfv mil, MTL_ONHAND_QUANTITIES_DETAIL moq
3704 WHERE alias = p_alias
3705 AND mil.inventory_location_id = moq.locator_id
3706 AND mil.organization_id = p_organization_id
3707 -- Bug 2325664 AND mil.physical_location_id is null -- PJM-WMS Integration
3708 AND mil.project_id IS NULL
3709 AND mil.task_id IS NULL
3710 AND inv_material_status_grp.is_status_applicable('TRUE', NULL, 86, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, moq.locator_id, NULL, NULL, 'L') = 'Y'
3711 AND moq.containerized_flag = 2
3712 AND (moq.revision = p_revision
3713 OR (moq.revision IS NULL
3714 AND p_revision IS NULL
3715 )
3716 )
3717 AND moq.inventory_item_id = p_inventory_item_id
3718 AND moq.locator_id IS NOT NULL
3719 AND moq.subinventory_code = p_subinventory_code
3720 AND moq.organization_id = p_organization_id
3721 GROUP BY moq.locator_id, mil.concatenated_segments, mil.description
3722 ORDER BY 2;
3723 END get_cgupdate_locs;
3724
3725 -- Obsolete
3726 PROCEDURE get_with_all_subs(
3727 x_zones OUT NOCOPY t_genref
3728 , p_organization_id IN NUMBER
3729 , p_subinventory_code IN VARCHAR2
3730 ) IS
3731 l_debug NUMBER;
3732 BEGIN
3733 l_debug := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
3734 --bug#3440453 Remove the NVL on organization_id if user passes it.
3735 IF p_organization_id IS NULL THEN
3736 OPEN x_zones FOR
3737 SELECT secondary_inventory_name
3738 , NVL(locator_type, 1)
3739 , description
3740 , asset_inventory
3741 , 0 dummy
3742 , enable_locator_alias
3743 FROM mtl_secondary_inventories
3744 WHERE organization_id = NVL(p_organization_id, organization_id)
3745 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
3746 AND secondary_inventory_name LIKE (p_subinventory_code)
3747 UNION ALL
3748 SELECT 'All Subinventories'
3749 , 0
3750 , ''
3751 , 0
3752 , 1 dummy
3753 , 'N' enable_locator_alias
3754 FROM DUAL
3755 WHERE 'All Subinventories' LIKE (p_subinventory_code)
3756 ORDER BY dummy DESC, secondary_inventory_name;
3757 ELSE -- Organization_id is not null
3758 OPEN x_zones FOR
3759 SELECT secondary_inventory_name
3760 , NVL(locator_type, 1)
3761 , description
3762 , asset_inventory
3763 , 0 dummy
3764 , enable_locator_alias
3765 FROM mtl_secondary_inventories
3766 WHERE organization_id = p_organization_id
3767 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
3768 AND secondary_inventory_name LIKE (p_subinventory_code)
3769 UNION ALL
3770 SELECT 'All Subinventories'
3771 , 0
3772 , ''
3773 , 0
3774 , 1 dummy
3775 , 'N' enable_locator_alias
3776 FROM DUAL
3777 WHERE 'All Subinventories' LIKE (p_subinventory_code)
3778 ORDER BY dummy DESC, secondary_inventory_name;
3779 END IF;
3780
3781 END get_with_all_subs;
3782
3783 PROCEDURE get_with_all_loc(x_locators OUT NOCOPY t_genref, p_organization_id IN NUMBER, p_subinventory_code IN VARCHAR2, p_concatenated_segments IN VARCHAR2) IS
3784 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
3785 BEGIN
3786 OPEN x_locators FOR
3787 SELECT milv.inventory_location_id
3788 --, milv.concatenated_segments --Bug4398337:Commented this line and added below line
3789 , milv.locator_segments concatenated_segments
3790 , milv.description
3791 , 0 dummy
3792 , mmsv.status_code
3793 FROM wms_item_locations_kfv milv, mtl_material_statuses_tl mmsv
3794 WHERE milv.organization_id = p_organization_id
3795 AND milv.subinventory_code = p_subinventory_code
3796 AND milv.concatenated_segments LIKE (p_concatenated_segments)
3797 AND (mmsv.status_id(+)/*Added outer join 2918529*/ = milv.status_id )
3798 AND mmsv.language(+) = userenv('LANG')
3799 AND Nvl(milv.DISABLE_DATE,TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)/*bug#13578738 to make sure that disable Locator should not be shown in the LOV*/
3800 UNION ALL
3801 SELECT 0
3802 , 'All Locators'
3803 , ''
3804 , 1 dummy
3805 , ''
3806 FROM DUAL
3807 WHERE 'All Locators' LIKE (p_concatenated_segments)
3808 ORDER BY dummy DESC, concatenated_segments;
3809 END get_with_all_loc;
3810
3811 /* Start of fix for bug # 5166308 */
3812 /* The following overloaded procedure has been added as a part of Locator Alias Project. */
3813
3814
3815 PROCEDURE get_with_all_loc(x_locators OUT NOCOPY t_genref
3816 , p_organization_id IN NUMBER
3817 , p_subinventory_code IN VARCHAR2
3818 , p_concatenated_segments IN VARCHAR2
3819 , p_alias IN VARCHAR2) IS
3820 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
3821 BEGIN
3822 IF (l_debug = 1) THEN
3823 DEBUG('Alias is '||p_alias);
3824 END IF;
3825 IF p_alias IS NULL THEN
3826 get_with_all_loc(x_locators => x_locators
3827 , p_organization_id => p_organization_id
3828 , p_subinventory_code => p_subinventory_code
3829 , p_concatenated_segments => p_concatenated_segments);
3830 RETURN;
3831 END IF;
3832 OPEN x_locators FOR
3833 SELECT milv.inventory_location_id
3834 --, milv.concatenated_segments --Bug4398337:Commented this line and added below line
3835 , milv.locator_segments concatenated_segments
3836 , milv.description
3837 , 0 dummy
3838 , mmsv.status_code
3839 FROM wms_item_locations_kfv milv, mtl_material_statuses_tl mmsv
3840 WHERE milv.organization_id = p_organization_id
3841 AND milv.subinventory_code = p_subinventory_code
3842 AND milv.alias = p_alias
3843 AND (mmsv.status_id(+)/*Added outer join 2918529*/ = milv.status_id )
3844 AND mmsv.language(+) = userenv('LANG');
3845 END get_with_all_loc;
3846 /* End of fix for bug # 5166308 */
3847
3848 PROCEDURE update_dynamic_locator(
3849 x_msg_count OUT NOCOPY NUMBER,
3850 x_msg_data OUT NOCOPY VARCHAR2,
3851 x_result OUT NOCOPY VARCHAR2,
3852 x_exist_or_create OUT NOCOPY VARCHAR2,
3853 p_locator_id IN NUMBER,
3854 p_org_id IN NUMBER,
3855 p_sub_code IN VARCHAR2) IS
3856
3857 PRAGMA AUTONOMOUS_TRANSACTION;
3858 l_sub_default_status NUMBER;
3859 l_sub_code VARCHAR2(10);
3860 l_wms_org BOOLEAN;
3861 l_loc_type NUMBER;
3862 l_return_status VARCHAR2(10);
3863 l_msg_count NUMBER;
3864 l_msg_data VARCHAR2(20);
3865 l_label_status VARCHAR2(20);
3866 l_status_rec inv_material_status_pub.mtl_status_update_rec_type;
3867 l_required VARCHAR2(1) := 'N';
3868 l_project_id NUMBER;
3869 l_task_id NUMBER;
3870 l_picking_order NUMBER;
3871 l_return_value BOOLEAN := FALSE;
3872 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
3873 BEGIN
3874 x_result := fnd_api.g_ret_sts_success;
3875
3876 --
3877 -- The LocatorKFF does an autonomous commit
3878 -- so a record is always present in MIL
3879 -- However a new Locator has a null subinventory
3880 -- code
3881 --
3882
3883 SELECT subinventory_code
3884 , project_id
3885 , task_id
3886 INTO l_sub_code
3887 , l_project_id
3888 , l_task_id
3889 FROM mtl_item_locations
3890 WHERE inventory_location_id = p_locator_id
3891 AND organization_id = p_org_id;
3892
3893 --
3894 -- If the Locator already exists then we dont
3895 -- need to do anything. Return immediatly
3896 --
3897
3898 IF l_sub_code IS NOT NULL THEN
3899 x_exist_or_create := 'EXISTS';
3900 GOTO success;
3901 END IF;
3902
3903 --
3904 -- For a New Locator ...
3905 -- Set X_EXIST_OR_CREATE is set to 'CREATE' and
3906 --
3907 -- If WMS is installed then the Locator must be
3908 -- assigned the Default Locator Status defined
3909 -- for the Subinventory and the Locator type is
3910 -- set to 'STORAGE_LOCATOR'
3911 -- i.e. MTL_LOCATOR_TYPES (MFG_LOOKUP)
3912 --
3913 -- Also a record must be inserted into Status
3914 -- history.
3915 --
3916
3917 x_exist_or_create := 'CREATE';
3918 --
3919 -- Now that we have a complete valid row in MTL_ITEM_LOCATIONS
3920 -- we call the PJM Locator API to create the physical locator.
3921 -- This happens only if the physical locator does not already
3922 -- exist.
3923 --
3924
3925 -- Added below update for the bug 14849583
3926 BEGIN
3927 UPDATE MTL_ITEM_LOCATIONS
3928 SET SUBINVENTORY_CODE = P_SUB_CODE
3929 WHERE ORGANIZATiON_ID = P_ORG_ID
3930 AND INVENTORY_LOCATION_ID = P_LOCATOR_ID;
3931 EXCEPTION
3932 WHEN OTHERS THEN
3933 IF (L_DEBUG = 1) THEN
3934 DEBUG('Exception raised');
3935 END IF;
3936 RAISE fnd_api.g_exc_unexpected_error;
3937 END;
3938
3939 l_return_value := inv_projectlocator_pub.get_physical_location(p_organization_id => p_org_id, p_locator_id => p_locator_id);
3940
3941 IF NOT l_return_value THEN
3942 IF (l_debug = 1) THEN
3943 DEBUG('GET_PHYSICAL_LOCATION: ERROR');
3944 END IF;
3945 RAISE fnd_api.g_exc_unexpected_error;
3946 END IF;
3947
3948 update_locator(p_sub_code, p_org_id, p_locator_id);
3949 IF (l_debug = 1) THEN
3950 DEBUG('After inserting the default values');
3951 END IF;
3952
3953
3954 --
3955 -- Print the Label for the new Locator
3956 --
3957 IF (l_debug = 1) THEN
3958 DEBUG('CALLING PRINTING');
3959 END IF;
3960 inv_label.print_label_manual_wrap(
3961 x_return_status => l_return_status
3962 , x_msg_count => l_msg_count
3963 , x_msg_data => l_msg_data
3964 , x_label_status => l_label_status
3965 , p_business_flow_code => 24
3966 , p_organization_id => p_org_id
3967 , p_subinventory_code => p_sub_code
3968 , p_locator_id => p_locator_id
3969 );
3970 IF (l_debug = 1) THEN
3971 DEBUG('AFTER CALLING PRINTING');
3972 END IF;
3973
3974 --
3975 -- Do not check the returns status of above API as the
3976 -- transaction should go through even though label
3977 -- printing failed.
3978 --
3979
3980 <<success>>
3981 fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
3982 x_result := fnd_api.g_ret_sts_success;
3983 COMMIT;
3984 EXCEPTION
3985 WHEN OTHERS THEN
3986 IF (l_debug = 1) THEN
3987 DEBUG(SQLERRM);
3988 END IF;
3989 x_result := fnd_api.g_ret_sts_unexp_error;
3990 fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
3991 ROLLBACK;
3992 END update_dynamic_locator;
3993
3994 -- Obsolete
3995 PROCEDURE get_valid_lpn_controlled_subs(
3996 x_zones OUT NOCOPY t_genref
3997 , p_organization_id IN NUMBER
3998 , p_subinventory_code IN VARCHAR2
3999 , p_txn_type_id IN NUMBER
4000 , p_wms_installed IN VARCHAR2
4001 ) IS
4002 l_debug NUMBER;
4003 BEGIN
4004 l_debug := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
4005 --bug#3440453 Remove the NVL on organization_id if user passes a value to it.
4006 IF p_organization_id IS NULL THEN
4007 OPEN x_zones FOR
4008 SELECT secondary_inventory_name
4009 , NVL(locator_type, 1)
4010 , description
4011 , asset_inventory
4012 , lpn_controlled_flag
4013 , enable_locator_alias
4014 FROM mtl_secondary_inventories
4015 WHERE organization_id = NVL(p_organization_id, organization_id)
4016 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
4017 AND secondary_inventory_name LIKE (p_subinventory_code)
4018 AND lpn_controlled_flag = 1
4019 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_txn_type_id, NULL, NULL, p_organization_id, NULL, secondary_inventory_name, NULL, NULL, NULL, 'Z') = 'Y'
4020 ORDER BY secondary_inventory_name;
4021 ELSE -- Organization_id is not null
4022 OPEN x_zones FOR
4023 SELECT secondary_inventory_name
4024 , NVL(locator_type, 1)
4025 , description
4026 , asset_inventory
4027 , lpn_controlled_flag
4028 , enable_locator_alias
4029 FROM mtl_secondary_inventories
4030 WHERE organization_id = p_organization_id
4031 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
4032 AND secondary_inventory_name LIKE (p_subinventory_code)
4033 AND lpn_controlled_flag = 1
4034 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_txn_type_id, NULL, NULL, p_organization_id, NULL, secondary_inventory_name, NULL, NULL, NULL, 'Z') = 'Y'
4035 ORDER BY secondary_inventory_name;
4036 END IF;
4037
4038
4039 END get_valid_lpn_controlled_subs;
4040
4041 ------------------------------------------------
4042 -- GET_PRJ_LOC_LOV - Get Locators filtered
4043 -- on project and task
4044 ------------------------------------------------
4045 PROCEDURE get_prj_loc_lov(
4046 x_locators OUT NOCOPY t_genref
4047 , p_organization_id IN NUMBER
4048 , p_subinventory_code IN VARCHAR2
4049 , p_restrict_locators_code IN NUMBER
4050 , p_inventory_item_id IN NUMBER
4051 , p_concatenated_segments IN VARCHAR2
4052 , p_transaction_type_id IN NUMBER
4053 , p_wms_installed IN VARCHAR2
4054 , p_project_id IN NUMBER
4055 , p_task_id IN NUMBER
4056 ) IS
4057 x_return_status VARCHAR2(100);
4058 x_display VARCHAR2(100);
4059 x_project_col NUMBER;
4060 x_task_col NUMBER;
4061 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
4062 l_ispjm_org VARCHAR2(1);
4063 l_sub_type NUMBER;
4064 BEGIN
4065
4066 BEGIN
4067 SELECT nvl(PROJECT_REFERENCE_ENABLED,'N')
4068 INTO l_ispjm_org
4069 FROM pjm_org_parameters
4070 WHERE organization_id=p_organization_id;
4071 EXCEPTION
4072 WHEN NO_DATA_FOUND THEN
4073 l_ispjm_org:='N';
4074 END;
4075
4076 BEGIN
4077 SELECT Nvl(subinventory_type,1)
4078 INTO l_sub_type
4079 FROM mtl_secondary_inventories
4080 WHERE secondary_inventory_name = p_subinventory_code
4081 AND organization_id = p_organization_id;
4082 EXCEPTION
4083 WHEN OTHERS THEN
4084 l_sub_type := 1;
4085 END;
4086
4087 IF l_ispjm_org='N' THEN /*Non PJM Org*/
4088 IF p_Restrict_Locators_Code = 1 AND l_sub_type = 1 THEN --Locators restricted to predefined list
4089 OPEN x_Locators FOR
4090 select a.inventory_location_id,
4091 --a.concatenated_segments,--Bug4398337:Commented this line and added below line
4092 a.locator_segments concatenated_segments,
4093 nvl( a.description, -1)
4094 FROM wms_item_locations_kfv a,mtl_secondary_locators b
4095 WHERE b.organization_id = p_Organization_Id
4096 AND b.inventory_item_id = p_Inventory_Item_Id
4097 AND nvl(a.disable_date, trunc(sysdate+1)) > trunc(sysdate)
4098 AND b.subinventory_code = p_Subinventory_Code
4099 AND a.inventory_location_id = b.secondary_locator
4100 and a.organization_id = b.organization_id --13472820
4101 AND a.concatenated_segments LIKE (p_concatenated_segments)
4102 /* BUG#2810405: To show only common locators in the LOV */
4103 AND inv_material_status_grp.is_status_applicable
4104 ( p_wms_installed,
4105 NULL,
4106 p_transaction_type_id,
4107 NULL,
4108 NULL,
4109 p_Organization_Id,
4110 p_Inventory_Item_Id,
4111 p_Subinventory_Code,
4112 a.inventory_location_id,
4113 NULL,
4114 NULL,
4115 'L') = 'Y'
4116 ORDER BY 2;
4117
4118 ELSE --Locators not restricted
4119 OPEN x_Locators FOR
4120 select inventory_location_id,
4121 --concatenated_segments,--Bug4398337:Commented this line and added below line
4122 locator_segments concatenated_segments,
4123 description
4124 FROM wms_item_locations_kfv
4125 WHERE organization_id = p_Organization_Id
4126 AND subinventory_code = p_Subinventory_Code
4127 AND nvl(disable_date, trunc(sysdate+1)) > trunc(sysdate)
4128 AND concatenated_segments LIKE (p_concatenated_segments )
4129 /* BUG#2810405: To show only common locators in the LOV */
4130 AND inv_material_status_grp.is_status_applicable
4131 ( p_wms_installed,
4132 NULL,
4133 p_transaction_type_id,
4134 NULL,
4135 NULL,
4136 p_Organization_Id,
4137 p_Inventory_Item_Id,
4138 p_Subinventory_Code,
4139 inventory_location_id,
4140 NULL,
4141 NULL,
4142 'L') = 'Y'
4143 ORDER BY 2;
4144 END IF;
4145 ELSE /*PJM org*/
4146 IF p_Restrict_Locators_Code = 1 AND l_sub_type = 1 THEN --Locators restricted to predefined list
4147 OPEN x_Locators FOR
4148 select a.inventory_location_id,
4149 --a.concatenated_segments,--Bug4398337:Commented this line and added below line
4150 a.locator_segments concatenated_segments,
4151 nvl( a.description, -1)
4152 FROM wms_item_locations_kfv a,mtl_secondary_locators b
4153 WHERE b.organization_id = p_Organization_Id
4154 AND b.inventory_item_id = p_Inventory_Item_Id
4155 AND nvl(a.disable_date, trunc(sysdate+1)) > trunc(sysdate)
4156 AND b.subinventory_code = p_Subinventory_Code
4157 AND a.inventory_location_id = b.secondary_locator
4158 and a.organization_id = b.organization_id --13472820
4159 AND a.inventory_location_id=nvl(a.physical_location_id,a.inventory_location_id)
4160 AND a.concatenated_segments like (p_concatenated_segments )
4161 /* BUG#2810405: To show only common locators in the LOV */
4162 AND inv_material_status_grp.is_status_applicable
4163 ( p_wms_installed,
4164 NULL,
4165 p_transaction_type_id,
4166 NULL,
4167 NULL,
4168 p_Organization_Id,
4169 p_Inventory_Item_Id,
4170 p_Subinventory_Code,
4171 a.inventory_location_id,
4172 NULL,
4173 NULL,
4174 'L') = 'Y'
4175 ORDER BY 2;
4176
4177 ELSE --Locators not restricted
4178 OPEN x_Locators FOR
4179 select inventory_location_id,
4180 --concatenated_segments,--Bug4398337:Commented this line and added below line
4181 locator_segments concatenated_segments,
4182 description
4183 FROM wms_item_locations_kfv
4184 WHERE organization_id = p_Organization_Id
4185 AND subinventory_code = p_Subinventory_Code
4186 AND nvl(disable_date, trunc(sysdate+1)) > trunc(sysdate)
4187 AND inventory_location_id=NVL(physical_location_id,inventory_location_id)
4188 AND concatenated_segments LIKE (p_concatenated_segments )
4189 /* BUG#2810405: To show only common locators in the LOV */
4190 AND inv_material_status_grp.is_status_applicable
4191 ( p_wms_installed,
4192 NULL,
4193 p_transaction_type_id,
4194 NULL,
4195 NULL,
4196 p_Organization_Id,
4197 p_Inventory_Item_Id,
4198 p_Subinventory_Code,
4199 inventory_location_id,
4200 NULL,
4201 NULL,
4202 'L') = 'Y'
4203 ORDER BY 2;
4204 END IF;
4205 END IF;
4206 END get_prj_loc_lov;
4207 /**
4208 * For Locator alias project
4209 */
4210 PROCEDURE get_prj_loc_lov(
4211 x_locators OUT NOCOPY t_genref
4212 , p_organization_id IN NUMBER
4213 , p_subinventory_code IN VARCHAR2
4214 , p_restrict_locators_code IN NUMBER
4215 , p_inventory_item_id IN NUMBER
4216 , p_concatenated_segments IN VARCHAR2
4217 , p_transaction_type_id IN NUMBER
4218 , p_wms_installed IN VARCHAR2
4219 , p_project_id IN NUMBER
4220 , p_task_id IN NUMBER
4221 , p_alias IN VARCHAR2
4222 ) IS
4223 x_return_status VARCHAR2(100);
4224 x_display VARCHAR2(100);
4225 x_project_col NUMBER;
4226 x_task_col NUMBER;
4227 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
4228 l_ispjm_org VARCHAR2(1);
4229 l_sub_type NUMBER;
4230 BEGIN
4231
4232 IF (l_debug = 1) THEN
4233 DEBUG('Alias is '||p_alias);
4234 END IF;
4235 IF p_alias IS NULL THEN
4236 get_prj_loc_lov(
4237 x_locators => x_locators
4238 , p_organization_id => p_organization_id
4239 , p_subinventory_code => p_subinventory_code
4240 , p_restrict_locators_code => p_restrict_locators_code
4241 , p_inventory_item_id => p_inventory_item_id
4242 , p_concatenated_segments => p_concatenated_segments
4243 , p_transaction_type_id => p_transaction_type_id
4244 , p_wms_installed => p_wms_installed
4245 , p_project_id => p_project_id
4246 , p_task_id => p_task_id
4247 );
4248 RETURN;
4249 END IF;
4250
4251 BEGIN
4252 SELECT nvl(PROJECT_REFERENCE_ENABLED,'N')
4253 INTO l_ispjm_org
4254 FROM pjm_org_parameters
4255 WHERE organization_id=p_organization_id;
4256 EXCEPTION
4257 WHEN NO_DATA_FOUND THEN
4258 l_ispjm_org:='N';
4259 END;
4260
4261 BEGIN
4262 SELECT Nvl(subinventory_type,1)
4263 INTO l_sub_type
4264 FROM mtl_secondary_inventories
4265 WHERE secondary_inventory_name = p_subinventory_code
4266 AND organization_id = p_organization_id;
4267 EXCEPTION
4268 WHEN OTHERS THEN
4269 l_sub_type := 1;
4270 END;
4271
4272 IF l_ispjm_org='N' THEN /*Non PJM Org*/
4273 IF p_Restrict_Locators_Code = 1 AND l_sub_type = 1 THEN --Locators restricted to predefined list
4274 OPEN x_Locators FOR
4275 select a.inventory_location_id,
4276 --a.concatenated_segments,--Bug4398337:Commented this line and added below line
4277 a.locator_segments concatenated_segments,
4278 nvl( a.description, -1)
4279 FROM wms_item_locations_kfv a,mtl_secondary_locators b
4280 WHERE b.organization_id = p_Organization_Id
4281 AND b.inventory_item_id = p_Inventory_Item_Id
4282 AND nvl(a.disable_date, trunc(sysdate+1)) > trunc(sysdate)
4283 AND b.subinventory_code = p_Subinventory_Code
4284 AND a.inventory_location_id = b.secondary_locator
4285 and a.organization_id = b.organization_id --13472820
4286 -- AND a.concatenated_segments LIKE (p_concatenated_segments)
4287 AND a.alias = p_alias
4288 /* BUG#2810405: To show only common locators in the LOV */
4289 AND inv_material_status_grp.is_status_applicable
4290 ( p_wms_installed,
4291 NULL,
4292 p_transaction_type_id,
4293 NULL,
4294 NULL,
4295 p_Organization_Id,
4296 p_Inventory_Item_Id,
4297 p_Subinventory_Code,
4298 a.inventory_location_id,
4299 NULL,
4300 NULL,
4301 'L') = 'Y'
4302 ORDER BY 2;
4303
4304 ELSE --Locators not restricted
4305 OPEN x_Locators FOR
4306 select inventory_location_id,
4307 --concatenated_segments,--Bug4398337:Commented this line and added below line
4308 locator_segments concatenated_segments,
4309 description
4310 FROM wms_item_locations_kfv
4311 WHERE organization_id = p_Organization_Id
4312 AND subinventory_code = p_Subinventory_Code
4313 AND nvl(disable_date, trunc(sysdate+1)) > trunc(sysdate)
4314 -- AND concatenated_segments LIKE (p_concatenated_segments )
4315 AND alias = p_alias
4316 /* BUG#2810405: To show only common locators in the LOV */
4317 AND inv_material_status_grp.is_status_applicable
4318 ( p_wms_installed,
4319 NULL,
4320 p_transaction_type_id,
4321 NULL,
4322 NULL,
4323 p_Organization_Id,
4324 p_Inventory_Item_Id,
4325 p_Subinventory_Code,
4326 inventory_location_id,
4327 NULL,
4328 NULL,
4329 'L') = 'Y'
4330 ORDER BY 2;
4331 END IF;
4332 ELSE /*PJM org*/
4333 IF p_Restrict_Locators_Code = 1 AND l_sub_type = 1 THEN --Locators restricted to predefined list
4334 OPEN x_Locators FOR
4335 select a.inventory_location_id,
4336 --a.concatenated_segments,--Bug4398337:Commented this line and added below line
4337 a.locator_segments concatenated_segments,
4338 nvl( a.description, -1)
4339 FROM wms_item_locations_kfv a,mtl_secondary_locators b
4340 WHERE b.organization_id = p_Organization_Id
4341 AND b.inventory_item_id = p_Inventory_Item_Id
4342 AND nvl(a.disable_date, trunc(sysdate+1)) > trunc(sysdate)
4343 AND b.subinventory_code = p_Subinventory_Code
4344 AND a.inventory_location_id = b.secondary_locator
4345 and a.organization_id = b.organization_id --13472820
4346 AND a.inventory_location_id=nvl(a.physical_location_id,a.inventory_location_id)
4347 -- AND a.concatenated_segments like (p_concatenated_segments )
4348 AND a.alias = p_alias
4349 /* BUG#2810405: To show only common locators in the LOV */
4350 AND inv_material_status_grp.is_status_applicable
4351 ( p_wms_installed,
4352 NULL,
4353 p_transaction_type_id,
4354 NULL,
4355 NULL,
4356 p_Organization_Id,
4357 p_Inventory_Item_Id,
4358 p_Subinventory_Code,
4359 a.inventory_location_id,
4360 NULL,
4361 NULL,
4362 'L') = 'Y'
4363 ORDER BY 2;
4364
4365 ELSE --Locators not restricted
4366 OPEN x_Locators FOR
4367 select inventory_location_id,
4368 --concatenated_segments,--Bug4398337:Commented this line and added below line
4369 locator_segments concatenated_segments,
4370 description
4371 FROM wms_item_locations_kfv
4372 WHERE organization_id = p_Organization_Id
4373 AND subinventory_code = p_Subinventory_Code
4374 AND nvl(disable_date, trunc(sysdate+1)) > trunc(sysdate)
4375 AND inventory_location_id=NVL(physical_location_id,inventory_location_id)
4376 -- AND concatenated_segments LIKE (p_concatenated_segments )
4377 AND alias = p_alias
4378 /* BUG#2810405: To show only common locators in the LOV */
4379 AND inv_material_status_grp.is_status_applicable
4380 ( p_wms_installed,
4381 NULL,
4382 p_transaction_type_id,
4383 NULL,
4384 NULL,
4385 p_Organization_Id,
4386 p_Inventory_Item_Id,
4387 p_Subinventory_Code,
4388 inventory_location_id,
4389 NULL,
4390 NULL,
4391 'L') = 'Y'
4392 ORDER BY 2;
4393 END IF;
4394 END IF;
4395 END get_prj_loc_lov;
4396
4397 PROCEDURE get_valid_prj_to_locs(
4398 x_locators OUT NOCOPY t_genref
4399 , p_transaction_action_id IN NUMBER
4400 , p_to_organization_id IN NUMBER
4401 , p_organization_id IN NUMBER
4402 , p_subinventory_code IN VARCHAR2
4403 , p_restrict_locators_code IN NUMBER
4404 , p_inventory_item_id IN NUMBER
4405 , p_concatenated_segments IN VARCHAR2
4406 , p_transaction_type_id IN NUMBER
4407 , p_wms_installed IN VARCHAR2
4408 , p_project_id IN NUMBER
4409 , p_task_id IN NUMBER
4410 , p_alias IN VARCHAR2
4411 ) IS
4412 l_org NUMBER;
4413 l_restrict_locators_code NUMBER;
4414 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
4415 BEGIN
4416 debug('Inside INV_UI_ITEM_SUB_LOC_LOVS.get_valid_prj_to_locs');
4417 debug('p_alias : '|| p_alias);
4418 IF p_alias IS NULL THEN
4419 get_valid_prj_to_locs(
4420 x_locators => x_locators
4421 , p_transaction_action_id => p_transaction_action_id
4422 , p_to_organization_id => p_to_organization_id
4423 , p_organization_id => p_organization_id
4424 , p_subinventory_code => p_subinventory_code
4425 , p_restrict_locators_code => p_restrict_locators_code
4426 , p_inventory_item_id => p_inventory_item_id
4427 , p_concatenated_segments => p_concatenated_segments
4428 , p_transaction_type_id => p_transaction_type_id
4429 , p_wms_installed => p_wms_installed
4430 , p_project_id => p_project_id
4431 , p_task_id => p_task_id
4432 );
4433 RETURN; --Bug 8237335 Added return statement as for p_alias is null.
4434 END IF;
4435 debug('p_alias is not null case');
4436 IF p_transaction_action_id IN (3, 21) THEN
4437 l_org := p_to_organization_id;
4438
4439 SELECT restrict_locators_code
4440 INTO l_restrict_locators_code
4441 FROM mtl_system_items
4442 WHERE inventory_item_id = p_inventory_item_id
4443 AND organization_id = l_org;
4444 ELSE
4445 l_org := p_organization_id;
4446 l_restrict_locators_code := p_restrict_locators_code;
4447 END IF;
4448
4449 get_prj_loc_lov(
4450 x_locators => x_locators
4451 , p_organization_id => l_org
4452 , p_subinventory_code => p_subinventory_code
4453 , p_restrict_locators_code => l_restrict_locators_code
4454 , p_inventory_item_id => p_inventory_item_id
4455 , p_concatenated_segments => p_concatenated_segments
4456 , p_transaction_type_id => p_transaction_type_id
4457 , p_wms_installed => p_wms_installed
4458 , p_project_id => p_project_id
4459 , p_task_id => p_task_id
4460 , p_alias => p_alias
4461 );
4462 END get_valid_prj_to_locs;
4463 --
4464 --
4465 PROCEDURE get_valid_prj_to_locs(
4466 x_locators OUT NOCOPY t_genref
4467 , p_transaction_action_id IN NUMBER
4468 , p_to_organization_id IN NUMBER
4469 , p_organization_id IN NUMBER
4470 , p_subinventory_code IN VARCHAR2
4471 , p_restrict_locators_code IN NUMBER
4472 , p_inventory_item_id IN NUMBER
4473 , p_concatenated_segments IN VARCHAR2
4474 , p_transaction_type_id IN NUMBER
4475 , p_wms_installed IN VARCHAR2
4476 , p_project_id IN NUMBER
4477 , p_task_id IN NUMBER
4478 ) IS
4479 l_org NUMBER;
4480 l_restrict_locators_code NUMBER;
4481 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
4482 BEGIN
4483 debug('Inside INV_UI_ITEM_SUB_LOC_LOVS.get_valid_prj_to_locs :Overloaded');
4484 debug('p_transaction_action_id : '|| p_transaction_action_id);
4485 debug('p_to_organization_id : '|| p_to_organization_id);
4486 debug('p_organization_id : '|| p_organization_id);
4487 debug('p_subinventory_code : '|| p_subinventory_code);
4488 debug('p_restrict_locators_code : '|| p_restrict_locators_code);
4489 debug('p_inventory_item_id : '|| p_inventory_item_id);
4490 debug('p_concatenated_segments : '|| p_concatenated_segments);
4491 debug('p_transaction_type_id :' || p_transaction_type_id);
4492 debug('p_wms_installed : '|| p_wms_installed);
4493 debug('p_project_id : '|| p_project_id);
4494 debug('p_task_id : '|| p_task_id);
4495
4496 IF p_transaction_action_id IN (3, 21) THEN
4497 l_org := p_to_organization_id;
4498
4499 SELECT restrict_locators_code
4500 INTO l_restrict_locators_code
4501 FROM mtl_system_items
4502 WHERE inventory_item_id = p_inventory_item_id
4503 AND organization_id = l_org;
4504 ELSE
4505 l_org := p_organization_id;
4506 l_restrict_locators_code := p_restrict_locators_code;
4507 END IF;
4508 debug('l_restrict_locators_code : '|| l_restrict_locators_code);
4509
4510 --Commented following call and instead called new procedure get_prj_to_loc_lov for bug 8237335
4511 /*get_prj_loc_lov(
4512 x_locators => x_locators
4513 , p_organization_id => l_org
4514 , p_subinventory_code => p_subinventory_code
4515 , p_restrict_locators_code => l_restrict_locators_code
4516 , p_inventory_item_id => p_inventory_item_id
4517 , p_concatenated_segments => p_concatenated_segments
4518 , p_transaction_type_id => p_transaction_type_id
4519 , p_wms_installed => p_wms_installed
4520 , p_project_id => p_project_id
4521 , p_task_id => p_task_id
4522 ); */
4523
4524 debug('Calling get_prj_to_loc_lov ');
4525 get_prj_to_loc_lov(
4526 x_locators => x_locators
4527 , p_organization_id => l_org
4528 , p_subinventory_code => p_subinventory_code
4529 , p_restrict_locators_code => l_restrict_locators_code
4530 , p_inventory_item_id => p_inventory_item_id
4531 , p_concatenated_segments => p_concatenated_segments
4532 , p_transaction_type_id => p_transaction_type_id
4533 , p_wms_installed => p_wms_installed
4534 , p_project_id => p_project_id
4535 , p_task_id => p_task_id
4536 );
4537 END get_valid_prj_to_locs;
4538
4539 --
4540 --
4541 PROCEDURE get_prj_lpnloc_lov(
4542 x_locators OUT NOCOPY t_genref
4543 , p_organization_id IN NUMBER
4544 , p_lpn_id IN NUMBER
4545 , p_subinventory_code IN VARCHAR2
4546 , p_concatenated_segments IN VARCHAR2
4547 , p_transaction_type_id IN NUMBER
4548 , p_wms_installed IN VARCHAR2
4549 , p_project_id IN NUMBER
4550 , p_task_id IN NUMBER
4551 ) IS
4552 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
4553 BEGIN
4554 /*Bug 2769628: Restricted the LOV to list only common locators and anot logical locators*/
4555 OPEN x_locators FOR
4556 SELECT inventory_location_id
4557 --, concatenated_segments--Bug4398337:Commented this line and added below line
4558 , locator_segments concatenated_segments
4559 , description
4560 FROM wms_item_locations_kfv
4561 WHERE organization_id = p_organization_id
4562 AND subinventory_code = p_subinventory_code
4563 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
4564 AND concatenated_segments LIKE (p_concatenated_segments)
4565 AND inventory_location_id=nvl(physical_location_id,inventory_location_id)
4566 AND inv_ui_item_sub_loc_lovs.vaildate_lpn_toloc(p_lpn_id, p_subinventory_code, p_organization_id, inventory_location_id, p_wms_installed, p_transaction_type_id) = 'Y';
4567 END get_prj_lpnloc_lov;
4568 PROCEDURE get_prj_lpnloc_lov(
4569 x_locators OUT NOCOPY t_genref
4570 , p_organization_id IN NUMBER
4571 , p_lpn_id IN NUMBER
4572 , p_subinventory_code IN VARCHAR2
4573 , p_concatenated_segments IN VARCHAR2
4574 , p_transaction_type_id IN NUMBER
4575 , p_wms_installed IN VARCHAR2
4576 , p_project_id IN NUMBER
4577 , p_task_id IN NUMBER
4578 , p_alias IN VARCHAR2
4579 ) IS
4580 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
4581 BEGIN
4582
4583 IF p_alias IS NULL THEN
4584 get_prj_lpnloc_lov(
4585 x_locators => x_locators
4586 , p_organization_id => p_organization_id
4587 , p_lpn_id => p_lpn_id
4588 , p_subinventory_code => p_subinventory_code
4589 , p_concatenated_segments => p_concatenated_segments
4590 , p_transaction_type_id => p_transaction_type_id
4591 , p_wms_installed => p_wms_installed
4592 , p_project_id => p_project_id
4593 , p_task_id => p_task_id
4594 );
4595 RETURN;
4596 END IF;
4597 /*Bug 2769628: Restricted the LOV to list only common locators and anot logical locators*/
4598 OPEN x_locators FOR
4599 SELECT inventory_location_id
4600 --, concatenated_segments--Bug4398337:Commented this line and added below line
4601 , locator_segments concatenated_segments
4602 , description
4603 FROM wms_item_locations_kfv
4604 WHERE organization_id = p_organization_id
4605 AND subinventory_code = p_subinventory_code
4606 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
4607 AND alias = p_alias
4608 AND inventory_location_id=nvl(physical_location_id,inventory_location_id)
4609 AND inv_ui_item_sub_loc_lovs.vaildate_lpn_toloc(p_lpn_id, p_subinventory_code, p_organization_id, inventory_location_id, p_wms_installed, p_transaction_type_id) = 'Y';
4610 END get_prj_lpnloc_lov;
4611
4612
4613 -- This procedure is used for user directed putaway
4614 -- to get the LOV cursor for the Subinventory
4615 --- obsolete
4616 PROCEDURE get_userput_subs(
4617 x_sub OUT NOCOPY t_genref
4618 , p_organization_id IN NUMBER
4619 , p_subinventory_code IN VARCHAR2
4620 , p_lpn_id IN NUMBER
4621 , p_lpn_context IN NUMBER
4622 , p_rcv_sub_only IN NUMBER
4623 ) IS
4624 l_debug NUMBER;
4625 BEGIN
4626 l_debug := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
4627 IF (l_debug = 1) THEN
4628 DEBUG('Entering get_userput_subs:');
4629 DEBUG(' p_rcv_sub_only ====> ' || p_rcv_sub_only);
4630 END IF;
4631
4632 IF (p_lpn_context in (2,3)) THEN
4633 IF (p_rcv_sub_only = 2) THEN
4634 -- Include both RCV and INV subs, with no restriction on INV subs
4635 OPEN x_sub FOR
4636 SELECT secondary_inventory_name
4637 , NVL(locator_type, 1)
4638 , description
4639 , asset_inventory
4640 , lpn_controlled_flag
4641 , Nvl(subinventory_type,1)
4642 , reservable_type
4643 , enable_locator_alias
4644 FROM mtl_secondary_inventories
4645 WHERE organization_id = p_organization_id
4646 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
4647 AND secondary_inventory_name LIKE (p_subinventory_code)
4648 AND inv_ui_item_sub_loc_lovs.validate_lpn_sub(p_organization_id,
4649 secondary_inventory_name,
4650 p_lpn_id) = 'Y'
4651 UNION ALL
4652 SELECT msub.secondary_inventory_name
4653 , NVL(msub.locator_type, 1)
4654 , msub.description
4655 , msub.asset_inventory
4656 , lpn_controlled_flag
4657 , Nvl(subinventory_type,1)
4658 , reservable_type
4659 , enable_locator_alias
4660 FROM mtl_secondary_inventories msub
4661 WHERE organization_id = p_organization_id
4662 AND Nvl(subinventory_type,1) = 2
4663 AND msub.secondary_inventory_name LIKE (p_subinventory_code)
4664 AND (trunc(disable_date + (300*365)) >= trunc(SYSDATE) OR
4665 disable_date = TO_DATE('01/01/1700','DD/MM/RRRR'))
4666 ORDER BY 1;
4667 ELSIF (p_rcv_sub_only = 1 OR p_rcv_sub_only IS NULL) THEN
4668 -- Only include RCV subs.
4669 OPEN x_sub FOR
4670 SELECT msub.secondary_inventory_name
4671 , NVL(msub.locator_type, 1)
4672 , msub.description
4673 , msub.asset_inventory
4674 , lpn_controlled_flag
4675 , Nvl(subinventory_type,1)
4676 , reservable_type
4677 , enable_locator_alias
4678 FROM mtl_secondary_inventories msub
4679 WHERE organization_id = p_organization_id
4680 AND Nvl(subinventory_type,1) = 2
4681 AND msub.secondary_inventory_name LIKE (p_subinventory_code)
4682 AND (trunc(disable_date + (300*365)) >= trunc(SYSDATE) OR
4683 disable_date = TO_DATE('01/01/1700','DD/MM/RRRR'))
4684 ORDER BY 1;
4685 ELSIF (p_rcv_sub_only = 3) THEN
4686 -- Only include inventory subs, with no restrictions
4687 OPEN x_sub FOR
4688 SELECT secondary_inventory_name
4689 , NVL(locator_type, 1)
4690 , description
4691 , asset_inventory
4692 , lpn_controlled_flag
4693 , Nvl(subinventory_type,1)
4694 , reservable_type
4695 , enable_locator_alias
4696 FROM mtl_secondary_inventories
4697 WHERE organization_id = p_organization_id
4698 AND Nvl(subinventory_type,1) = 1
4699 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
4700 AND secondary_inventory_name LIKE (p_subinventory_code)
4701 AND inv_ui_item_sub_loc_lovs.validate_lpn_sub(p_organization_id,
4702 secondary_inventory_name,
4703 p_lpn_id) = 'Y';
4704 ELSIF (p_rcv_sub_only = 4) THEN
4705 -- SO XDOCK
4706 -- Only include inventory subs that are reservable and LPN controlled
4707 OPEN x_sub FOR
4708 SELECT secondary_inventory_name
4709 , NVL(locator_type, 1)
4710 , description
4711 , asset_inventory
4712 , lpn_controlled_flag
4713 , Nvl(subinventory_type,1)
4714 , reservable_type
4715 , enable_locator_alias
4716 FROM mtl_secondary_inventories
4717 WHERE organization_id = p_organization_id
4718 AND Nvl(subinventory_type,1) = 1
4719 AND lpn_controlled_flag = 1
4720 AND reservable_type = 1
4721 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
4722 AND secondary_inventory_name LIKE (p_subinventory_code)
4723 AND inv_ui_item_sub_loc_lovs.validate_lpn_sub(p_organization_id,
4724 secondary_inventory_name,
4725 p_lpn_id) = 'Y';
4726 ELSIF (p_rcv_sub_only = 5) THEN
4727 -- Only include INV Subs that are non-reservable and non-LPN-Controlled
4728 OPEN x_sub FOR
4729 SELECT secondary_inventory_name
4730 , NVL(locator_type, 1)
4731 , description
4732 , asset_inventory
4733 , lpn_controlled_flag
4734 , Nvl(subinventory_type,1)
4735 , reservable_type
4736 , enable_locator_alias
4737 FROM mtl_secondary_inventories
4738 WHERE organization_id = p_organization_id
4739 AND Nvl(subinventory_type,1) = 1
4740 AND lpn_controlled_flag = 2
4741 AND reservable_type = 2
4742 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
4743 AND secondary_inventory_name LIKE (p_subinventory_code)
4744 AND inv_ui_item_sub_loc_lovs.validate_lpn_sub(p_organization_id,
4745 secondary_inventory_name,
4746 p_lpn_id) = 'Y';
4747
4748 ELSIF (p_rcv_sub_only = 6) THEN
4749 -- Include RCV Subs and INV subs that are reservable and LPN Controlled
4750 OPEN x_sub FOR
4751 SELECT secondary_inventory_name
4752 , NVL(locator_type, 1)
4753 , description
4754 , asset_inventory
4755 , lpn_controlled_flag
4756 , Nvl(subinventory_type,1)
4757 , reservable_type
4758 , enable_locator_alias
4759 FROM mtl_secondary_inventories
4760 WHERE organization_id = p_organization_id
4761 AND Nvl(subinventory_type,1) = 1
4762 AND lpn_controlled_flag = 1
4763 AND reservable_type = 1
4764 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
4765 AND secondary_inventory_name LIKE (p_subinventory_code)
4766 AND inv_ui_item_sub_loc_lovs.validate_lpn_sub(p_organization_id,
4767 secondary_inventory_name,
4768 p_lpn_id) = 'Y'
4769 UNION ALL
4770 SELECT msub.secondary_inventory_name
4771 , NVL(msub.locator_type, 1)
4772 , msub.description
4773 , msub.asset_inventory
4774 , lpn_controlled_flag
4775 , Nvl(subinventory_type,1)
4776 , reservable_type
4777 , enable_locator_alias
4778 FROM mtl_secondary_inventories msub
4779 WHERE organization_id = p_organization_id
4780 AND Nvl(subinventory_type,1) = 2
4781 AND msub.secondary_inventory_name LIKE (p_subinventory_code)
4782 AND (trunc(disable_date + (300*365)) >= trunc(SYSDATE) OR
4783 disable_date = TO_DATE('01/01/1700','DD/MM/RRRR'))
4784 ORDER BY 1;
4785 ELSIF (p_rcv_sub_only = 7) THEN
4786 -- Include RCV Subs and INV subs that are non-reservable and non-LPN-Controlled
4787 OPEN x_sub FOR
4788 SELECT secondary_inventory_name
4789 , NVL(locator_type, 1)
4790 , description
4791 , asset_inventory
4792 , lpn_controlled_flag
4793 , Nvl(subinventory_type,1)
4794 , reservable_type
4795 , enable_locator_alias
4796 FROM mtl_secondary_inventories
4797 WHERE organization_id = p_organization_id
4798 AND Nvl(subinventory_type,1) = 1
4799 AND lpn_controlled_flag = 2
4800 AND reservable_type = 2
4801 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
4802 AND secondary_inventory_name LIKE (p_subinventory_code)
4803 AND inv_ui_item_sub_loc_lovs.validate_lpn_sub(p_organization_id,
4804 secondary_inventory_name,
4805 p_lpn_id) = 'Y'
4806 UNION ALL
4807 SELECT msub.secondary_inventory_name
4808 , NVL(msub.locator_type, 1)
4809 , msub.description
4810 , msub.asset_inventory
4811 , lpn_controlled_flag
4812 , Nvl(subinventory_type,1)
4813 , reservable_type
4814 , enable_locator_alias
4815 FROM mtl_secondary_inventories msub
4816 WHERE organization_id = p_organization_id
4817 AND Nvl(subinventory_type,1) = 2
4818 AND msub.secondary_inventory_name LIKE (p_subinventory_code)
4819 AND (trunc(disable_date + (300*365)) >= trunc(SYSDATE) OR
4820 disable_date = TO_DATE('01/01/1700','DD/MM/RRRR'))
4821 ORDER BY 1;
4822 END IF;
4823 ELSE
4824 -- Non-receiving LPN case
4825 OPEN x_sub FOR
4826 SELECT secondary_inventory_name
4827 , NVL(locator_type, 1)
4828 , description
4829 , asset_inventory
4830 , lpn_controlled_flag
4831 , Nvl(subinventory_type,1)
4832 , reservable_type
4833 , enable_locator_alias
4834 FROM mtl_secondary_inventories
4835 WHERE organization_id = p_organization_id
4836 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
4837 AND secondary_inventory_name LIKE (p_subinventory_code)
4838 AND inv_ui_item_sub_loc_lovs.validate_lpn_sub(p_organization_id,
4839 secondary_inventory_name,
4840 p_lpn_id) = 'Y'
4841 ORDER BY UPPER(secondary_inventory_name);
4842 END IF;
4843
4844 END get_userput_subs;
4845
4846
4847 -- This function will validate the LPN for item/sub restrictions
4848 -- and also for sub material status for each move order line transaction.
4849 -- This function should only be called from the procedure
4850 -- get_userput_subs in this package: INV_UI_ITEM_SUB_LOC_LOVS
4851 FUNCTION validate_lpn_sub(
4852 p_organization_id IN NUMBER
4853 , p_subinventory_code IN VARCHAR2
4854 , p_lpn_id IN NUMBER)
4855 RETURN VARCHAR2 IS
4856 x_return VARCHAR(1);
4857 l_item_id NUMBER;
4858 l_restrict_sub NUMBER;
4859 l_transaction_type NUMBER;
4860 l_count NUMBER;
4861
4862 CURSOR l_item_cursor IS
4863 SELECT DISTINCT wlc.inventory_item_id
4864 , msi.restrict_subinventories_code
4865 FROM wms_lpn_contents wlc, mtl_system_items msi
4866 WHERE wlc.parent_lpn_id IN(SELECT lpn_id
4867 FROM wms_license_plate_numbers
4868 WHERE outermost_lpn_id = p_lpn_id)
4869 AND wlc.inventory_item_id IS NOT NULL
4870 AND wlc.inventory_item_id = msi.inventory_item_id
4871 AND msi.organization_id = p_organization_id;
4872
4873 CURSOR l_item_txn_cursor IS
4874 SELECT inventory_item_id
4875 , transaction_type_id
4876 FROM mtl_txn_request_lines
4877 WHERE organization_id = p_organization_id
4878 AND lpn_id = p_lpn_id;
4879
4880 l_debug NUMBER := nvl(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
4881 BEGIN
4882 -- Initialize the return variable
4883 x_return := 'Y';
4884 -- Loop through each item packed within the LPN
4885 OPEN l_item_cursor;
4886
4887 LOOP
4888 FETCH l_item_cursor INTO l_item_id, l_restrict_sub;
4889 EXIT WHEN l_item_cursor%NOTFOUND;
4890
4891 -- If the item restricts subinventories,
4892 -- check that the sub is allowed
4893 IF (l_restrict_sub = 1) THEN
4894 SELECT COUNT(*)
4895 INTO l_count
4896 FROM mtl_item_sub_inventories
4897 WHERE organization_id = p_organization_id
4898 AND inventory_item_id = l_item_id
4899 AND secondary_inventory = p_subinventory_code;
4900
4901 -- No rows returned so the sub is not valid
4902 -- for the current item
4903 IF (l_count = 0) THEN
4904 x_return := 'N';
4905 EXIT;
4906 END IF;
4907 END IF;
4908 END LOOP;
4909
4910 CLOSE l_item_cursor;
4911
4912 -- Sub has already failed item/sub restrictions
4913 -- so no need to do any further validation.
4914 IF (x_return = 'N') THEN
4915 RETURN x_return;
4916 END IF;
4917
4918 -- Loop through each move order line for the LPN
4919 OPEN l_item_txn_cursor;
4920
4921 LOOP
4922 FETCH l_item_txn_cursor INTO l_item_id, l_transaction_type;
4923 EXIT WHEN l_item_txn_cursor%NOTFOUND;
4924 -- Check if the sub's material status is valid
4925 -- for the current move order line's transaction type
4926 x_return := inv_material_status_grp.is_status_applicable(p_wms_installed => 'TRUE', p_trx_status_enabled => NULL, p_trx_type_id => l_transaction_type
4927 , p_lot_status_enabled => NULL, p_serial_status_enabled => NULL, p_organization_id => p_organization_id
4928 , p_inventory_item_id => l_item_id, p_sub_code => p_subinventory_code, p_locator_id => NULL, p_lot_number => NULL
4929 , p_serial_number => NULL, p_object_type => 'Z');
4930
4931 -- The function returned 'N' so the sub is not valid
4932 -- for the transaction type in the current move order line
4933 IF (x_return = 'N') THEN
4934 EXIT;
4935 END IF;
4936 END LOOP;
4937
4938 CLOSE l_item_txn_cursor;
4939 -- If all of the items in the LPN passed validation
4940 -- for the given sub, the return variable should be 'Y'
4941 RETURN x_return;
4942 EXCEPTION
4943 WHEN OTHERS THEN
4944 IF (l_debug = 1) THEN
4945 DEBUG('Exception occurred in function validate_lpn_sub!');
4946 END IF;
4947
4948 x_return := 'N';
4949 RETURN x_return;
4950 END validate_lpn_sub;
4951
4952
4953 PROCEDURE get_userput_locs
4954 (x_locators OUT NOCOPY t_genref ,
4955 p_organization_id IN NUMBER ,
4956 p_subinventory_code IN VARCHAR2 ,
4957 p_concatenated_segments IN VARCHAR2 ,
4958 p_project_id IN NUMBER ,
4959 p_task_id IN NUMBER ,
4960 p_lpn_id IN NUMBER ,
4961 p_alias IN VARCHAR2
4962 ) IS
4963 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
4964 BEGIN
4965 /*Bug 2769628:To list all the common locators and not the logical locators*/
4966 IF p_alias IS NULL THEN
4967 get_userput_locs(
4968 x_locators => x_locators
4969 ,p_organization_id => p_organization_id
4970 ,p_subinventory_code => p_subinventory_code
4971 ,p_concatenated_segments => p_concatenated_segments
4972 ,p_project_id => p_project_id
4973 ,p_task_id => p_task_id
4974 ,p_lpn_id => p_lpn_id
4975 );
4976 RETURN;
4977 END IF;
4978 OPEN x_locators FOR
4979 SELECT inventory_location_id
4980 -- , concatenated_segments--Bug4398337:Commented this line and added below line
4981 , locator_segments concatenated_segments
4982 , description
4983 , inventory_location_type
4984 FROM wms_item_locations_kfv
4985 WHERE organization_id = p_organization_id
4986 AND subinventory_code = p_subinventory_code
4987 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
4988 AND alias = p_alias
4989 AND inventory_location_id=nvl(physical_location_id,inventory_location_id)
4990 AND inv_ui_item_sub_loc_lovs.validate_lpn_loc(p_organization_id,
4991 p_subinventory_code,
4992 inventory_location_id,
4993 p_lpn_id) = 'Y'
4994 ORDER BY 2;
4995 END get_userput_locs;
4996 PROCEDURE get_userput_locs
4997 (x_locators OUT NOCOPY t_genref ,
4998 p_organization_id IN NUMBER ,
4999 p_subinventory_code IN VARCHAR2 ,
5000 p_concatenated_segments IN VARCHAR2 ,
5001 p_project_id IN NUMBER ,
5002 p_task_id IN NUMBER ,
5003 p_lpn_id IN NUMBER
5004 ) IS
5005 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
5006 BEGIN
5007 /*Bug 2769628:To list all the common locators and not the logical locators*/
5008 OPEN x_locators FOR
5009 SELECT inventory_location_id
5010 -- , concatenated_segments--Bug4398337:Commented this line and added below line
5011 , locator_segments concatenated_segments
5012 , description
5013 , inventory_location_type
5014 FROM wms_item_locations_kfv
5015 WHERE organization_id = p_organization_id
5016 AND subinventory_code = p_subinventory_code
5017 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5018 AND concatenated_segments LIKE (p_concatenated_segments)
5019 AND inventory_location_id=nvl(physical_location_id,inventory_location_id)
5020 AND inv_ui_item_sub_loc_lovs.validate_lpn_loc(p_organization_id,
5021 p_subinventory_code,
5022 inventory_location_id,
5023 p_lpn_id) = 'Y'
5024 ORDER BY 2;
5025 END get_userput_locs;
5026
5027
5028 -- This function will validate the LPN for item/sub/loc restrictions
5029 -- and also for locator material status for each move order line transaction.
5030 -- This function should only be called from the procedure
5031 -- get_userput_locs in this package: INV_UI_ITEM_SUB_LOC_LOVS
5032 FUNCTION validate_lpn_loc(p_organization_id IN NUMBER ,
5033 p_subinventory_code IN VARCHAR2 ,
5034 p_locator_id IN NUMBER ,
5035 p_lpn_id IN NUMBER)
5036 RETURN VARCHAR2 IS
5037 x_return VARCHAR(1);
5038 l_item_id NUMBER;
5039 l_restrict_loc NUMBER;
5040 l_transaction_type NUMBER;
5041 l_count NUMBER;
5042 CURSOR l_item_cursor IS
5043 SELECT DISTINCT wlc.inventory_item_id, msi.restrict_locators_code
5044 FROM wms_lpn_contents wlc, mtl_system_items msi
5045 WHERE wlc.parent_lpn_id IN (SELECT lpn_id
5046 FROM wms_license_plate_numbers
5047 WHERE outermost_lpn_id = p_lpn_id)
5048 AND wlc.inventory_item_id IS NOT NULL
5049 AND wlc.inventory_item_id = msi.inventory_item_id
5050 AND msi.organization_id = p_organization_id;
5051 CURSOR l_item_txn_cursor IS
5052 SELECT inventory_item_id, transaction_type_id
5053 FROM mtl_txn_request_lines
5054 WHERE organization_id = p_organization_id
5055 AND lpn_id = p_lpn_id;
5056 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
5057 l_sub_type NUMBER;
5058 BEGIN
5059 -- Initialize the return variable
5060 x_return := 'Y';
5061
5062 -- get the sub type and based on it set the loc_type
5063 BEGIN
5064 SELECT nvl(subinventory_type,1)
5065 INTO l_sub_type
5066 FROM mtl_secondary_inventories
5067 WHERE organization_id = p_organization_id
5068 AND secondary_inventory_name = p_subinventory_code;
5069 EXCEPTION
5070 WHEN OTHERS THEN
5071 l_sub_type := 1;
5072 END;
5073
5074 --Only if it is a storage sub then we need to do the
5075 --following validation
5076 IF l_sub_type = 1 THEN
5077 -- Loop through each item packed within the LPN
5078 OPEN l_item_cursor;
5079 LOOP
5080 FETCH l_item_cursor INTO l_item_id, l_restrict_loc;
5081 EXIT WHEN l_item_cursor%NOTFOUND;
5082
5083 -- If the item restricts locators,
5084 -- check that the locator is allowed
5085 IF (l_restrict_loc = 1) THEN
5086 SELECT COUNT(*)
5087 INTO l_count
5088 FROM mtl_secondary_locators
5089 WHERE organization_id = p_organization_id
5090 AND inventory_item_id = l_item_id
5091 AND subinventory_code = p_subinventory_code
5092 AND secondary_locator = p_locator_id;
5093 -- No rows returned so the loc is not valid
5094 -- for the current item
5095 IF (l_count = 0) THEN
5096 x_return := 'N';
5097 EXIT;
5098 END IF;
5099 END IF;
5100 END LOOP;
5101 CLOSE l_item_cursor;
5102 END IF;
5103
5104 -- Loc has already failed item/sub/loc restrictions
5105 -- so no need to do any further validation.
5106 IF (x_return = 'N') THEN
5107 RETURN x_return;
5108 END IF;
5109
5110 -- Loop through each move order line for the LPN
5111 OPEN l_item_txn_cursor;
5112 LOOP
5113 FETCH l_item_txn_cursor INTO l_item_id, l_transaction_type;
5114 EXIT WHEN l_item_txn_cursor%NOTFOUND;
5115
5116 -- Check if the loc's material status is valid
5117 -- for the current move order line's transaction type
5118 x_return := inv_material_status_grp.is_status_applicable
5119 (p_wms_installed => 'TRUE',
5120 p_trx_status_enabled => NULL,
5121 p_trx_type_id => l_transaction_type,
5122 p_lot_status_enabled => NULL,
5123 p_serial_status_enabled => NULL,
5124 p_organization_id => p_organization_id,
5125 p_inventory_item_id => l_item_id,
5126 p_sub_code => p_subinventory_code,
5127 p_locator_id => p_locator_id,
5128 p_lot_number => NULL,
5129 p_serial_number => NULL,
5130 p_object_type => 'L');
5131 -- The function returned 'N' so the loc is not valid
5132 -- for the transaction type in the current move order line
5133 IF (x_return = 'N') THEN
5134 EXIT;
5135 END IF;
5136 END LOOP;
5137 CLOSE l_item_txn_cursor;
5138
5139 -- If all of the items in the LPN passed validation
5140 -- for the given loc, the return variable should be 'Y'
5141 RETURN x_return;
5142
5143 EXCEPTION
5144 WHEN OTHERS THEN
5145 IF (l_debug = 1) THEN
5146 DEBUG('Exception occurred in function validate_lpn_loc!');
5147 END IF;
5148 x_return := 'N';
5149 RETURN x_return;
5150 END validate_lpn_loc;
5151
5152
5153 PROCEDURE get_pickload_loc_lov(
5154 x_locators OUT NOCOPY t_genref
5155 , p_organization_id IN NUMBER
5156 , p_subinventory_code IN VARCHAR2
5157 , p_restrict_locators_code IN NUMBER
5158 , p_inventory_item_id IN NUMBER
5159 , p_concatenated_segments IN VARCHAR2
5160 , p_transaction_type_id IN NUMBER
5161 , p_wms_installed IN VARCHAR2
5162 , p_project_id IN NUMBER
5163 , p_task_id IN NUMBER
5164 , p_alias IN VARCHAR2
5165 ) IS
5166
5167 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
5168 l_ispjm_org VARCHAR2(1);
5169 /*Bug 2902336:Modfied the select clauses for performance enhancements*/
5170 BEGIN
5171
5172 IF p_alias IS NULL THEN
5173 get_pickload_loc_lov(
5174 x_locators => x_locators
5175 , p_organization_id => p_organization_id
5176 , p_subinventory_code => p_subinventory_code
5177 , p_restrict_locators_code => p_restrict_locators_code
5178 , p_inventory_item_id => p_inventory_item_id
5179 , p_concatenated_segments => p_concatenated_segments
5180 , p_transaction_type_id => p_transaction_type_id
5181 , p_wms_installed => p_wms_installed
5182 , p_project_id => p_project_id
5183 , p_task_id => p_task_id
5184 );
5185 RETURN;
5186 END IF;
5187 BEGIN
5188 SELECT nvl(PROJECT_REFERENCE_ENABLED,'N')
5189 INTO l_ispjm_org
5190 FROM pjm_org_parameters
5191 WHERE organization_id=p_organization_id;
5192 EXCEPTION
5193 WHEN NO_DATA_FOUND THEN
5194 l_ispjm_org:='N';
5195 END;
5196 IF (l_ispjm_org='N') THEN/*Non PJM org*/
5197 IF p_restrict_locators_code=1 THEN
5198 OPEN x_locators FOR
5199 SELECT a.inventory_location_id
5200 --, a.concatenated_segments--Bug4398337:Commented this line and added below line
5201 , a.locator_segments
5202 , NVL(a.description, -1)
5203 FROM wms_item_locations_kfv a, mtl_secondary_locators b
5204 WHERE b.organization_id = p_organization_id
5205 AND b.inventory_item_id = p_inventory_item_id
5206 AND NVL(a.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5207 AND b.subinventory_code = p_subinventory_code
5208 AND a.inventory_location_id = b.secondary_locator
5209 and a.organization_id = b.organization_id --13472820
5210 /*AND inv_project.get_locsegs(a.inventory_location_id, p_organization_id) LIKE (p_concatenated_segments)*/
5211 AND a.alias = p_alias
5212 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, a.inventory_location_id, NULL, NULL, 'L') = 'Y'
5213 ORDER BY 2;
5214 ELSE --Locators not restricted
5215 OPEN x_locators FOR
5216 SELECT inventory_location_id
5217 --, concatenated_segments--Bug4398337:Commented this line and added below line
5218 , locator_segments concatenated_segments
5219 , description
5220 FROM wms_item_locations_kfv
5221 WHERE organization_id = p_organization_id
5222 AND subinventory_code = p_subinventory_code
5223 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5224 --AND inv_project.get_locsegs(inventory_location_id, p_organization_id) LIKE (p_concatenated_segments)
5225 AND alias = p_alias
5226 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, inventory_location_id, NULL, NULL, 'L') = 'Y'
5227 ORDER BY 2;
5228 END IF;
5229 ELSE /*PJM org*/
5230 IF p_project_id IS NULL THEN
5231 IF p_restrict_locators_code=1 THEN
5232 OPEN x_locators FOR
5233 SELECT a.inventory_location_id
5234 --, a.concatenated_segments--Bug4398337:Commented this line and added below line
5235 , a.locator_segments concatenated_segments
5236 , NVL(a.description, -1)
5237 FROM wms_item_locations_kfv a, mtl_secondary_locators b
5238 WHERE b.organization_id = p_organization_id
5239 AND b.inventory_item_id = p_inventory_item_id
5240 AND NVL(a.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5241 AND b.subinventory_code = p_subinventory_code
5242 AND a.inventory_location_id = b.secondary_locator
5243 and a.organization_id = b.organization_id --13472820
5244 AND a.inventory_location_id=nvl(a.physical_location_id,a.inventory_location_id)
5245 AND a.alias = p_alias
5246 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, a.inventory_location_id, NULL, NULL, 'L') = 'Y'
5247 ORDER BY 2;
5248 ELSE --Locators not restricted
5249 OPEN x_locators FOR
5250 SELECT inventory_location_id
5251 --, concatenated_segments--Bug4398337:Commented this line and added below line
5252 , locator_segments concatenated_segments
5253 , description
5254 FROM wms_item_locations_kfv
5255 WHERE organization_id = p_organization_id
5256 AND subinventory_code = p_subinventory_code
5257 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5258 AND inventory_location_id=nvl(physical_location_id,inventory_location_id)
5259 AND alias = p_alias
5260 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, inventory_location_id, NULL, NULL, 'L') = 'Y'
5261 ORDER BY 2;
5262 END IF;
5263 ELSE /*PJM org:Project id not null */
5264 IF p_restrict_locators_code = 1 THEN --Locators restricted to predefined list
5265 OPEN x_locators FOR
5266 SELECT a.inventory_location_id
5267 --, a.concatenated_segments--Bug4398337:Commented this line and added below line
5268 , a.locator_segments concatenated_segments
5269 , NVL(a.description, -1)
5270 FROM wms_item_locations_kfv a, mtl_secondary_locators b
5271 WHERE b.organization_id = p_organization_id
5272 AND b.inventory_item_id = p_inventory_item_id
5273 AND NVL(a.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5274 AND b.subinventory_code = p_subinventory_code
5275 AND a.inventory_location_id = b.secondary_locator
5276 and a.organization_id = b.organization_id --13472820
5277 --AND inv_project.get_locsegs(a.inventory_location_id, p_organization_id) LIKE (p_concatenated_segments)
5278 AND a.alias = p_alias
5279 AND a.project_id = p_project_id
5280 AND NVL(a.task_id, -1) = NVL(p_task_id, -1)
5281 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, a.inventory_location_id, NULL, NULL, 'L') = 'Y'
5282 ORDER BY 2;
5283 ELSE --Locators not restricted
5284 OPEN x_locators FOR
5285 SELECT inventory_location_id
5286 --, concatenated_segments--Bug4398337:Commented this line and added below line
5287 , locator_segments concatenated_segments
5288 , description
5289 FROM wms_item_locations_kfv
5290 WHERE organization_id = p_organization_id
5291 AND subinventory_code = p_subinventory_code
5292 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5293 --AND inv_project.get_locsegs(inventory_location_id, p_organization_id) LIKE (p_concatenated_segments)
5294 AND alias = p_alias
5295 AND project_id = p_project_id
5296 AND NVL(task_id, -1) = NVL(p_task_id, -1)
5297 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, inventory_location_id, NULL, NULL, 'L') = 'Y'
5298 ORDER BY 2;
5299 END IF;
5300 END IF;
5301 END IF;
5302 END get_pickload_loc_lov;
5303 /* Bug 2769628: Procedure to list the locators during Pick Load as they have to be restricted by project and task*/
5304 PROCEDURE get_pickload_loc_lov(
5305 x_locators OUT NOCOPY t_genref
5306 , p_organization_id IN NUMBER
5307 , p_subinventory_code IN VARCHAR2
5308 , p_restrict_locators_code IN NUMBER
5309 , p_inventory_item_id IN NUMBER
5310 , p_concatenated_segments IN VARCHAR2
5311 , p_transaction_type_id IN NUMBER
5312 , p_wms_installed IN VARCHAR2
5313 , p_project_id IN NUMBER
5314 , p_task_id IN NUMBER) IS
5315
5316 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
5317 l_ispjm_org VARCHAR2(1);
5318 /*Bug 2902336:Modfied the select clauses for performance enhancements*/
5319 BEGIN
5320 BEGIN
5321 SELECT nvl(PROJECT_REFERENCE_ENABLED,'N')
5322 INTO l_ispjm_org
5323 FROM pjm_org_parameters
5324 WHERE organization_id=p_organization_id;
5325 EXCEPTION
5326 WHEN NO_DATA_FOUND THEN
5327 l_ispjm_org:='N';
5328 END;
5329 IF (l_ispjm_org='N') THEN/*Non PJM org*/
5330 IF p_restrict_locators_code=1 THEN
5331 OPEN x_locators FOR
5332 SELECT a.inventory_location_id
5333 --, a.concatenated_segments--Bug4398337:Commented this line and added below line
5334 , a.locator_segments
5335 , NVL(a.description, -1)
5336 FROM wms_item_locations_kfv a, mtl_secondary_locators b
5337 WHERE b.organization_id = p_organization_id
5338 AND b.inventory_item_id = p_inventory_item_id
5339 AND NVL(a.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5340 AND b.subinventory_code = p_subinventory_code
5341 AND a.inventory_location_id = b.secondary_locator
5342 and a.organization_id = b.organization_id --13472820
5343 /*AND inv_project.get_locsegs(a.inventory_location_id, p_organization_id) LIKE (p_concatenated_segments)*/
5344 AND a.concatenated_segments LIKE (p_concatenated_segments)
5345 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, a.inventory_location_id, NULL, NULL, 'L') = 'Y'
5346 ORDER BY 2;
5347 ELSE --Locators not restricted
5348 OPEN x_locators FOR
5349 SELECT inventory_location_id
5350 --, concatenated_segments--Bug4398337:Commented this line and added below line
5351 , locator_segments concatenated_segments
5352 , description
5353 FROM wms_item_locations_kfv
5354 WHERE organization_id = p_organization_id
5355 AND subinventory_code = p_subinventory_code
5356 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5357 --AND inv_project.get_locsegs(inventory_location_id, p_organization_id) LIKE (p_concatenated_segments)
5358 AND concatenated_segments LIKE (p_concatenated_segments)
5359 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, inventory_location_id, NULL, NULL, 'L') = 'Y'
5360 ORDER BY 2;
5361 END IF;
5362 ELSE /*PJM org*/
5363 IF p_project_id IS NULL THEN
5364 IF p_restrict_locators_code=1 THEN
5365 OPEN x_locators FOR
5366 SELECT a.inventory_location_id
5367 --, a.concatenated_segments--Bug4398337:Commented this line and added below line
5368 , a.locator_segments concatenated_segments
5369 , NVL(a.description, -1)
5370 FROM wms_item_locations_kfv a, mtl_secondary_locators b
5371 WHERE b.organization_id = p_organization_id
5372 AND b.inventory_item_id = p_inventory_item_id
5373 AND NVL(a.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5374 AND b.subinventory_code = p_subinventory_code
5375 AND a.inventory_location_id = b.secondary_locator
5376 and a.organization_id = b.organization_id --13472820
5377 AND a.inventory_location_id=nvl(a.physical_location_id,a.inventory_location_id)
5378 AND a.concatenated_segments LIKE (p_concatenated_segments)
5379 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, a.inventory_location_id, NULL, NULL, 'L') = 'Y'
5380 ORDER BY 2;
5381 ELSE --Locators not restricted
5382 OPEN x_locators FOR
5383 SELECT inventory_location_id
5384 --, concatenated_segments--Bug4398337:Commented this line and added below line
5385 , locator_segments concatenated_segments
5386 , description
5387 FROM wms_item_locations_kfv
5388 WHERE organization_id = p_organization_id
5389 AND subinventory_code = p_subinventory_code
5390 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5391 AND inventory_location_id=nvl(physical_location_id,inventory_location_id)
5392 AND concatenated_segments LIKE (p_concatenated_segments)
5393 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, inventory_location_id, NULL, NULL, 'L') = 'Y'
5394 ORDER BY 2;
5395 END IF;
5396 ELSE /*PJM org:Project id not null */
5397 IF p_restrict_locators_code = 1 THEN --Locators restricted to predefined list
5398 OPEN x_locators FOR
5399 SELECT a.inventory_location_id
5400 --, a.concatenated_segments--Bug4398337:Commented this line and added below line
5401 , a.locator_segments concatenated_segments
5402 , NVL(a.description, -1)
5403 FROM wms_item_locations_kfv a, mtl_secondary_locators b
5404 WHERE b.organization_id = p_organization_id
5405 AND b.inventory_item_id = p_inventory_item_id
5406 AND NVL(a.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5407 AND b.subinventory_code = p_subinventory_code
5408 AND a.inventory_location_id = b.secondary_locator
5409 and a.organization_id = b.organization_id --13472820
5410 --AND inv_project.get_locsegs(a.inventory_location_id, p_organization_id) LIKE (p_concatenated_segments)
5411 AND a.concatenated_segments LIKE (p_concatenated_segments)
5412 AND a.project_id = p_project_id
5413 AND NVL(a.task_id, -1) = NVL(p_task_id, -1)
5414 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, a.inventory_location_id, NULL, NULL, 'L') = 'Y'
5415 ORDER BY 2;
5416 ELSE --Locators not restricted
5417 OPEN x_locators FOR
5418 SELECT inventory_location_id
5419 --, concatenated_segments--Bug4398337:Commented this line and added below line
5420 , locator_segments concatenated_segments
5421 , description
5422 FROM wms_item_locations_kfv
5423 WHERE organization_id = p_organization_id
5424 AND subinventory_code = p_subinventory_code
5425 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5426 --AND inv_project.get_locsegs(inventory_location_id, p_organization_id) LIKE (p_concatenated_segments)
5427 AND concatenated_segments LIKE (p_concatenated_segments)
5428 AND project_id = p_project_id
5429 AND NVL(task_id, -1) = NVL(p_task_id, -1)
5430 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, inventory_location_id, NULL, NULL, 'L') = 'Y'
5431 ORDER BY 2;
5432 END IF;
5433 END IF;
5434 END IF;
5435 END get_pickload_loc_lov;
5436
5437 /* The following procedure is added for bug 4990550. Since the locator field in pick load page is no longer an LOV
5438 from 11510,the new procedure is added to validate the locator field. */
5439 PROCEDURE get_pickload_loc(
5440 x_locators OUT NOCOPY t_genref
5441 , p_organization_id IN NUMBER
5442 , p_subinventory_code IN VARCHAR2
5443 , p_restrict_locators_code IN NUMBER
5444 , p_inventory_item_id IN NUMBER
5445 , p_concatenated_segments IN VARCHAR2
5446 , p_transaction_type_id IN NUMBER
5447 , p_wms_installed IN VARCHAR2
5448 , p_project_id IN NUMBER
5449 , p_task_id IN NUMBER) IS
5450
5451 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
5452 l_ispjm_org VARCHAR2(1);
5453 /*Bug 2902336:Modfied the select clauses for performance enhancements*/
5454 BEGIN
5455 BEGIN
5456 SELECT nvl(PROJECT_REFERENCE_ENABLED,'N')
5457 INTO l_ispjm_org
5458 FROM pjm_org_parameters
5459 WHERE organization_id=p_organization_id;
5460 EXCEPTION
5461 WHEN NO_DATA_FOUND THEN
5462 l_ispjm_org:='N';
5463 END;
5464 IF (l_ispjm_org='N') THEN/*Non PJM org*/
5465 IF p_restrict_locators_code=1 THEN
5466 OPEN x_locators FOR
5467 SELECT a.inventory_location_id
5468 , a.concatenated_segments -- Bug 4398336
5469 --, a.locator_segments concatenated_segments
5470 , NVL(a.description, -1)
5471 FROM wms_item_locations_kfv a, mtl_secondary_locators b
5472 WHERE b.organization_id = p_organization_id
5473 AND b.inventory_item_id = p_inventory_item_id
5474 AND NVL(a.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5475 AND b.subinventory_code = p_subinventory_code
5476 AND a.inventory_location_id = b.secondary_locator
5477 and a.organization_id = b.organization_id --13472820
5478 /*AND inv_project.get_locsegs(a.inventory_location_id, p_organization_id) LIKE (p_concatenated_segments)*/
5479 AND a.concatenated_segments LIKE (p_concatenated_segments)
5480 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, a.inventory_location_id, NULL, NULL, 'L') = 'Y'
5481 ORDER BY 2;
5482 ELSE --Locators not restricted
5483 OPEN x_locators FOR
5484 SELECT inventory_location_id
5485 , concatenated_segments -- Bug 4398336
5486 --, locator_segments concatenated_segments
5487 , description
5488 FROM wms_item_locations_kfv
5489 WHERE organization_id = p_organization_id
5490 AND subinventory_code = p_subinventory_code
5491 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5492 --AND inv_project.get_locsegs(inventory_location_id, p_organization_id) LIKE (p_concatenated_segments)
5493 AND concatenated_segments LIKE (p_concatenated_segments)
5494 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, inventory_location_id, NULL, NULL, 'L') = 'Y'
5495 ORDER BY 2;
5496 END IF;
5497 ELSE /*PJM org*/
5498 IF p_project_id IS NULL THEN
5499 IF p_restrict_locators_code=1 THEN
5500 OPEN x_locators FOR
5501 SELECT a.inventory_location_id
5502 , a.concatenated_segments -- Bug 4398336
5503 --, a.locator_segments concatenated_segments
5504 , NVL(a.description, -1)
5505 FROM wms_item_locations_kfv a, mtl_secondary_locators b
5506 WHERE b.organization_id = p_organization_id
5507 AND b.inventory_item_id = p_inventory_item_id
5508 AND NVL(a.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5509 AND b.subinventory_code = p_subinventory_code
5510 AND a.inventory_location_id = b.secondary_locator
5511 and a.organization_id = b.organization_id --13472820
5512 -- AND a.inventory_location_id=nvl(a.physical_location_id,a.inventory_location_id)
5513 AND a.project_id is null
5514 AND a.concatenated_segments LIKE (p_concatenated_segments)
5515 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, a.inventory_location_id, NULL, NULL, 'L') = 'Y'
5516 ORDER BY 2;
5517 ELSE --Locators not restricted
5518 OPEN x_locators FOR
5519 SELECT inventory_location_id
5520 , concatenated_segments -- Bug 4398336
5521 --, locator_segments concatenated_segments
5522 , description
5523 FROM wms_item_locations_kfv
5524 WHERE organization_id = p_organization_id
5525 AND subinventory_code = p_subinventory_code
5526 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5527 -- AND inventory_location_id=nvl(physical_location_id,inventory_location_id)
5528 AND project_id is null
5529 AND concatenated_segments LIKE (p_concatenated_segments)
5530 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, inventory_location_id, NULL, NULL, 'L') = 'Y'
5531 ORDER BY 2;
5532 END IF;
5533 ELSE /*PJM org:Project id not null */
5534 IF p_restrict_locators_code = 1 THEN --Locators restricted to predefined list
5535 OPEN x_locators FOR
5536 SELECT a.inventory_location_id
5537 , a.concatenated_segments -- Bug 4398336
5538 --, a.locator_segments concatenated_segments
5539 , NVL(a.description, -1)
5540 FROM wms_item_locations_kfv a, mtl_secondary_locators b
5541 WHERE b.organization_id = p_organization_id
5542 AND b.inventory_item_id = p_inventory_item_id
5543 AND NVL(a.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5544 AND b.subinventory_code = p_subinventory_code
5545 AND a.inventory_location_id = b.secondary_locator
5546 and a.organization_id = b.organization_id --13472820
5547 --AND inv_project.get_locsegs(a.inventory_location_id, p_organization_id) LIKE (p_concatenated_segments)
5548 AND a.concatenated_segments LIKE (p_concatenated_segments)
5549 AND a.project_id = p_project_id
5550 AND NVL(a.task_id, -1) = NVL(p_task_id, -1)
5551 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, a.inventory_location_id, NULL, NULL, 'L') = 'Y'
5552 ORDER BY 2;
5553 ELSE --Locators not restricted
5554 OPEN x_locators FOR
5555 SELECT inventory_location_id
5556 , concatenated_segments -- Bug 4398336
5557 --, locator_segments concatenated_segments
5558 , description
5559 FROM wms_item_locations_kfv
5560 WHERE organization_id = p_organization_id
5561 AND subinventory_code = p_subinventory_code
5562 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5563 --AND inv_project.get_locsegs(inventory_location_id, p_organization_id) LIKE (p_concatenated_segments)
5564 AND concatenated_segments LIKE (p_concatenated_segments)
5565 AND project_id = p_project_id
5566 AND NVL(task_id, -1) = NVL(p_task_id, -1)
5567 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, inventory_location_id, NULL, NULL, 'L') = 'Y'
5568 ORDER BY 2;
5569 END IF;
5570 END IF;
5571 END IF;
5572 END get_pickload_loc;
5573
5574
5575 -- Bug #3075665. ADDED IN PATCHSET J PROJECT ADVANCED PICKLOAD
5576 -- Patchset J: Procedure used to get the locs including project locs
5577 -- Procedure Name: get_pickload_all_loc_lov
5578 --
5579 -- Input parameters:
5580 -- p_organization_id - Organization Id
5581 --
5582 -- Output value:
5583 -- x_locators Ref. cursor
5584 --
5585 PROCEDURE GET_APL_PRJ_LOC_LOV(
5586 x_locators OUT NOCOPY t_genref
5587 , p_organization_id IN NUMBER
5588 , p_subinventory_code IN VARCHAR2
5589 , p_restrict_locators_code IN NUMBER
5590 , p_inventory_item_id IN NUMBER
5591 , p_concatenated_segments IN VARCHAR2
5592 , p_transaction_type_id IN NUMBER
5593 , p_wms_installed IN VARCHAR2
5594 , p_project_id IN NUMBER
5595 , p_task_id IN NUMBER) IS
5596
5597 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
5598 l_ispjm_org VARCHAR2(1);
5599 BEGIN
5600 BEGIN
5601 SELECT nvl(PROJECT_REFERENCE_ENABLED,'N')
5602 INTO l_ispjm_org
5603 FROM pjm_org_parameters
5604 WHERE organization_id=p_organization_id;
5605 EXCEPTION
5606 WHEN NO_DATA_FOUND THEN
5607 l_ispjm_org:='N';
5608 END;
5609 IF (l_ispjm_org='N') THEN/*Non PJM org*/
5610 IF p_restrict_locators_code=1 THEN
5611 OPEN x_locators FOR
5612 SELECT a.inventory_location_id
5613 --, a.concatenated_segments--Bug4398337:Commented this line and added below line
5614 , a.locator_segments concatenated_segments
5615 , NVL(a.description, -1)
5616 , a.subinventory_code
5617 FROM wms_item_locations_kfv a, mtl_secondary_locators b
5618 WHERE b.organization_id = p_organization_id
5619 AND b.inventory_item_id = p_inventory_item_id
5620 AND NVL(a.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5621 AND b.subinventory_code = p_subinventory_code
5622 AND a.inventory_location_id = b.secondary_locator
5623 and a.organization_id = b.organization_id --13472820
5624 /*AND inv_project.get_locsegs(a.inventory_location_id, p_organization_id) LIKE (p_concatenated_segments)*/
5625 AND a.concatenated_segments LIKE (p_concatenated_segments)
5626 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, a.inventory_location_id, NULL, NULL, 'L') = 'Y'
5627 ORDER BY 2;
5628 ELSE --Locators not restricted
5629 OPEN x_locators FOR
5630 SELECT inventory_location_id
5631 -- , concatenated_segments--Bug4398337:Commented this line and added below line
5632 , locator_segments concatenated_segments
5633 , description
5634 , subinventory_code
5635 FROM wms_item_locations_kfv
5636 WHERE organization_id = p_organization_id
5637 AND subinventory_code = p_subinventory_code
5638 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5639 --AND inv_project.get_locsegs(inventory_location_id, p_organization_id) LIKE (p_concatenated_segments)
5640 AND concatenated_segments LIKE (p_concatenated_segments)
5641 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, inventory_location_id, NULL, NULL, 'L') = 'Y'
5642 ORDER BY 2;
5643 END IF;
5644 ELSE /*PJM org*/
5645 IF p_project_id IS NULL THEN
5646 IF p_restrict_locators_code=1 THEN
5647 OPEN x_locators FOR
5648 SELECT a.inventory_location_id
5649 --, a.concatenated_segments--Bug4398337:Commented this line and added below line
5650 , a.locator_segments concatenated_segments
5651 , NVL(a.description, -1)
5652 , a.subinventory_code
5653 FROM wms_item_locations_kfv a, mtl_secondary_locators b
5654 WHERE b.organization_id = p_organization_id
5655 AND b.inventory_item_id = p_inventory_item_id
5656 AND NVL(a.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5657 AND b.subinventory_code = p_subinventory_code
5658 AND a.inventory_location_id = b.secondary_locator
5659 and a.organization_id = b.organization_id --13472820
5660 /*AND inv_project.get_locsegs(a.inventory_location_id, p_organization_id) LIKE (p_concatenated_segments)*/
5661 AND a.inventory_location_id=nvl(a.physical_location_id,a.inventory_location_id)
5662 AND a.concatenated_segments LIKE (p_concatenated_segments)
5663 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, a.inventory_location_id, NULL, NULL, 'L') = 'Y'
5664 ORDER BY 2;
5665 ELSE --Locators not restricted
5666 OPEN x_locators FOR
5667 SELECT inventory_location_id
5668 -- , concatenated_segments--Bug4398337:Commented this line and added below line
5669 , locator_segments concatenated_segments
5670 , description
5671 , subinventory_code
5672 FROM wms_item_locations_kfv
5673 WHERE organization_id = p_organization_id
5674 AND subinventory_code = p_subinventory_code
5675 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5676 --AND inv_project.get_locsegs(inventory_location_id, p_organization_id) LIKE (p_concatenated_segments)
5677 AND inventory_location_id=nvl(physical_location_id,inventory_location_id)
5678 AND concatenated_segments LIKE (p_concatenated_segments)
5679 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, inventory_location_id, NULL, NULL, 'L') = 'Y'
5680 ORDER BY 2;
5681 END IF;
5682 ELSE /*PJM org:Project id not null */
5683 IF p_restrict_locators_code = 1 THEN --Locators restricted to predefined list
5684 OPEN x_locators FOR
5685 SELECT a.inventory_location_id
5686 --, a.concatenated_segments--Bug4398337:Commented this line and added below line
5687 , a.locator_segments concatenated_segments
5688 , NVL(a.description, -1)
5689 , a.subinventory_code
5690 FROM wms_item_locations_kfv a, mtl_secondary_locators b
5691 WHERE b.organization_id = p_organization_id
5692 AND b.inventory_item_id = p_inventory_item_id
5693 AND NVL(a.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5694 AND b.subinventory_code = p_subinventory_code
5695 AND a.inventory_location_id = b.secondary_locator
5696 and a.organization_id = b.organization_id --13472820
5697 --AND inv_project.get_locsegs(a.inventory_location_id, p_organization_id) LIKE (p_concatenated_segments)
5698 AND a.concatenated_segments LIKE (p_concatenated_segments)
5699 AND a.project_id = p_project_id
5700 AND NVL(a.task_id, -1) = NVL(p_task_id, -1)
5701 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, a.inventory_location_id, NULL, NULL, 'L') = 'Y'
5702 ORDER BY 2;
5703 ELSE --Locators not restricted
5704 OPEN x_locators FOR
5705 SELECT inventory_location_id
5706 -- , concatenated_segments--Bug4398337:Commented this line and added below line
5707 , locator_segments concatenated_segments
5708 , description
5709 , subinventory_code
5710 FROM wms_item_locations_kfv
5711 WHERE organization_id = p_organization_id
5712 AND subinventory_code = p_subinventory_code
5713 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5714 --AND inv_project.get_locsegs(inventory_location_id, p_organization_id) LIKE (p_concatenated_segments)
5715 AND concatenated_segments LIKE (p_concatenated_segments)
5716 AND project_id = p_project_id
5717 AND NVL(task_id, -1) = NVL(p_task_id, -1)
5718 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, p_subinventory_code, inventory_location_id, NULL, NULL, 'L') = 'Y'
5719 ORDER BY 2;
5720 END IF;
5721 END IF;
5722 END IF;
5723 END GET_APL_PRJ_LOC_LOV;
5724
5725 /* Bug #3075665. ADDED IN PATCHSET J PROJECT ADVANCED PICKLOAD
5726 * All the locators for the given org are selected, not restricting on the subinventory
5727 */
5728 -- Patchset J: Procedure used to get all the locs in the org
5729 -- restricted by proj, task if passed and
5730 -- NOT restricted by subinventory
5731 -- Procedure Name: get_pickload_all_loc_lov
5732 --
5733 -- Input parameters:
5734 -- p_organization_id - Organization Id
5735 --
5736 -- Output value:
5737 -- x_locators Ref. cursor
5738 --
5739 PROCEDURE get_pickload_all_loc_lov(
5740 x_locators OUT NOCOPY t_genref
5741 , p_organization_id IN NUMBER
5742 , p_restrict_locators_code IN NUMBER
5743 , p_inventory_item_id IN NUMBER
5744 , p_concatenated_segments IN VARCHAR2
5745 , p_transaction_type_id IN NUMBER
5746 , p_wms_installed IN VARCHAR2
5747 , p_project_id IN NUMBER
5748 , p_task_id IN NUMBER) IS
5749
5750 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
5751 l_ispjm_org VARCHAR2(1);
5752 /*Bug 2902336:Modfied the select clauses for performance enhancements*/
5753 BEGIN
5754 BEGIN
5755 SELECT nvl(PROJECT_REFERENCE_ENABLED,'N')
5756 INTO l_ispjm_org
5757 FROM pjm_org_parameters
5758 WHERE organization_id=p_organization_id;
5759 EXCEPTION
5760 WHEN NO_DATA_FOUND THEN
5761 l_ispjm_org:='N';
5762 END;
5763 IF (l_ispjm_org='N') THEN/*Non PJM org*/
5764 IF p_restrict_locators_code=1 THEN
5765 OPEN x_locators FOR
5766 SELECT a.inventory_location_id
5767 -- , a.concatenated_segments--Bug4398337:Commented this line and added below line
5768 , a.locator_segments concatenated_segments
5769 , NVL(a.description, -1)
5770 , a.subinventory_code
5771 FROM wms_item_locations_kfv a, mtl_secondary_locators b
5772 WHERE b.organization_id = p_organization_id
5773 AND b.inventory_item_id = p_inventory_item_id
5774 AND NVL(a.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5775 /*AND b.subinventory_code = p_subinventory_code*/ /*Removed Subinventory restriction, displayes all locs in the org*/
5776 AND a.inventory_location_id = b.secondary_locator
5777 and a.organization_id = b.organization_id --13472820
5778 AND a.concatenated_segments LIKE (p_concatenated_segments)
5779 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, NULL, a.inventory_location_id, NULL, NULL, 'L') = 'Y'
5780 ORDER BY 2;
5781 ELSE --Locators not restricted
5782 OPEN x_locators FOR
5783 SELECT inventory_location_id
5784 --, concatenated_segments--Bug4398337:Commented this line and added below line
5785 , locator_segments concatenated_segments
5786 , description
5787 , subinventory_code
5788 FROM wms_item_locations_kfv
5789 WHERE organization_id = p_organization_id
5790 /*AND subinventory_code = p_subinventory_code*//*Removed Subinventory restriction, displayes all locs in the org*/
5791 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5792 AND concatenated_segments LIKE (p_concatenated_segments)
5793 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, NULL, inventory_location_id, NULL, NULL, 'L') = 'Y'
5794 ORDER BY 2;
5795 END IF;
5796 ELSE /*PJM org*/
5797 IF p_project_id IS NULL THEN
5798 IF p_restrict_locators_code=1 THEN
5799 OPEN x_locators FOR
5800 SELECT a.inventory_location_id
5801 -- , a.concatenated_segments--Bug4398337:Commented this line and added below line
5802 , a.locator_segments concatenated_segments
5803 , NVL(a.description, -1)
5804 ,a.subinventory_code
5805 FROM wms_item_locations_kfv a, mtl_secondary_locators b
5806 WHERE b.organization_id = p_organization_id
5807 AND b.inventory_item_id = p_inventory_item_id
5808 AND NVL(a.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5809 /*AND b.subinventory_code = p_subinventory_code*//*Removed Subinventory restriction, displayes all locs in the org*/
5810 AND a.inventory_location_id = b.secondary_locator
5811 and a.organization_id = b.organization_id --13472820
5812 AND a.inventory_location_id=nvl(a.physical_location_id,a.inventory_location_id)
5813 AND a.concatenated_segments LIKE (p_concatenated_segments)
5814 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, NULL, a.inventory_location_id, NULL, NULL, 'L') = 'Y'
5815 ORDER BY 2;
5816 ELSE --Locators not restricted
5817 OPEN x_locators FOR
5818 SELECT inventory_location_id
5819 -- , concatenated_segments--Bug4398337:Commented this line and added below line
5820 , locator_segments concatenated_segments
5821 , description
5822 , subinventory_code
5823 FROM wms_item_locations_kfv
5824 WHERE organization_id = p_organization_id
5825 /*AND subinventory_code = p_subinventory_code*//*Removed Subinventory restriction, displayes all locs in the org*/
5826 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5827 AND inventory_location_id=nvl(physical_location_id,inventory_location_id)
5828 AND concatenated_segments LIKE (p_concatenated_segments)
5829 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, NULL, inventory_location_id, NULL, NULL, 'L') = 'Y'
5830 ORDER BY 2;
5831 END IF;
5832 ELSE /*PJM org:Project id not null */
5833 IF p_restrict_locators_code = 1 THEN --Locators restricted to predefined list
5834 OPEN x_locators FOR
5835 SELECT a.inventory_location_id
5836 -- , a.concatenated_segments--Bug4398337:Commented this line and added below line
5837 , a.locator_segments concatenated_segments
5838 , NVL(a.description, -1)
5839 , a.subinventory_code
5840 FROM wms_item_locations_kfv a, mtl_secondary_locators b
5841 WHERE b.organization_id = p_organization_id
5842 AND b.inventory_item_id = p_inventory_item_id
5843 AND NVL(a.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5844 /*AND b.subinventory_code = p_subinventory_code*//*Removed Subinventory restriction, displayes all locs in the org*/
5845 AND a.inventory_location_id = b.secondary_locator
5846 and a.organization_id = b.organization_id --13472820
5847 AND a.concatenated_segments LIKE (p_concatenated_segments)
5848 AND a.project_id = p_project_id
5849 AND NVL(a.task_id, -1) = NVL(p_task_id, -1)
5850 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, NULL, a.inventory_location_id, NULL, NULL, 'L') = 'Y'
5851 ORDER BY 2;
5852 ELSE --Locators not restricted
5853 OPEN x_locators FOR
5854 SELECT inventory_location_id
5855 -- , concatenated_segments--Bug4398337:Commented this line and added below line
5856 , locator_segments concatenated_segments
5857 , description
5858 , subinventory_code
5859 FROM wms_item_locations_kfv
5860 WHERE organization_id = p_organization_id
5861 /*AND subinventory_code = p_subinventory_code*//*Removed Subinventory restriction, displayes all locs in the org*/
5862 AND NVL(disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
5863 AND concatenated_segments LIKE (p_concatenated_segments)
5864 AND project_id = p_project_id
5865 AND NVL(task_id, -1) = NVL(p_task_id, -1)
5866 AND inv_material_status_grp.is_status_applicable(p_wms_installed, NULL, p_transaction_type_id, NULL, NULL, p_organization_id, p_inventory_item_id, NULL, inventory_location_id, NULL, NULL, 'L') = 'Y'
5867 ORDER BY 2;
5868 END IF;
5869 END IF;
5870 END IF;
5871 END get_pickload_all_loc_lov;
5872
5873 PROCEDURE validate_pickload_loc
5874 (p_organization_id IN NUMBER,
5875 p_subinventory_code IN VARCHAR2,
5876 p_restrict_locators_code IN NUMBER,
5877 p_inventory_item_id IN NUMBER,
5878 p_locator IN VARCHAR2,
5879 p_transaction_type_id IN NUMBER,
5880 p_project_id IN NUMBER,
5881 p_task_id IN NUMBER,
5882 x_is_valid_locator OUT nocopy VARCHAR2,
5883 x_locator_id OUT nocopy NUMBER)
5884 IS
5885
5886 TYPE loc_record_type IS RECORD
5887 (locator_id NUMBER,
5888 locator VARCHAR2(204),
5889 description VARCHAR2(50));
5890
5891 loc_rec loc_record_type;
5892 l_locators t_genref;
5893 l_project_id NUMBER;
5894 l_task_id NUMBER;
5895
5896 BEGIN
5897 x_is_valid_locator := 'N';
5898
5899 IF p_project_id = 0 THEN
5900 l_project_id := NULL;
5901 END IF;
5902
5903 IF p_task_id = 0 THEN
5904 l_task_id := NULL;
5905 END IF;
5906
5907 get_pickload_loc_lov(x_locators => l_locators,
5908 p_organization_id => p_organization_id,
5909 p_subinventory_code => p_subinventory_code,
5910 p_restrict_locators_code => p_restrict_locators_code,
5911 p_inventory_item_id => p_inventory_item_id,
5912 p_concatenated_segments => p_locator,
5913 p_transaction_type_id => p_transaction_type_id,
5914 p_wms_installed => 'Y',
5915 p_project_id => l_project_id,
5916 p_task_id => l_task_id);
5917
5918 LOOP
5919 FETCH l_locators INTO loc_rec;
5920 EXIT WHEN l_locators%notfound;
5921
5922 IF loc_rec.locator = p_locator THEN
5923 x_is_valid_locator := 'Y';
5924 x_locator_id := loc_rec.locator_id;
5925 EXIT;
5926 END IF;
5927
5928 END LOOP;
5929
5930 END;
5931
5932 PROCEDURE get_inq_prj_loc_lov(
5933 x_Locators OUT NOCOPY t_genref,
5934 p_Organization_Id IN NUMBER,
5935 p_Subinventory_Code IN VARCHAR2,
5936 p_Restrict_Locators_Code IN NUMBER,
5937 p_Inventory_Item_Id IN NUMBER,
5938 p_Concatenated_Segments IN VARCHAR2,
5939 p_project_id IN NUMBER := NULL,
5940 p_task_id IN NUMBER := NULL
5941 -- p_alias IN VARCHAR2 := NULL
5942 -- p_suggestion IN VARCHAR2 := NULL
5943 ) IS
5944 l_ispjm_org VARCHAR2(1);
5945 BEGIN
5946 BEGIN
5947 SELECT nvl(PROJECT_REFERENCE_ENABLED,'N')
5948 INTO l_ispjm_org
5949 FROM pjm_org_parameters
5950 WHERE organization_id=p_organization_id;
5951 EXCEPTION
5952 WHEN NO_DATA_FOUND THEN
5953 l_ispjm_org:='N';
5954 END;
5955
5956 IF l_ispjm_org='N' THEN /*Non PJM Org*/
5957 IF p_Restrict_Locators_Code = 1 THEN --Locators restricted to predefined list
5958 OPEN x_Locators FOR
5959 SELECT a.inventory_location_id,
5960 -- a.concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
5961 a.locator_segments locsegs,
5962 a.description
5963 FROM wms_item_locations_kfv a,
5964 mtl_secondary_locators b
5965 WHERE b.organization_id = p_Organization_Id
5966 AND b.inventory_item_id = p_Inventory_Item_Id
5967 AND b.subinventory_code = p_Subinventory_Code
5968 AND a.inventory_location_id = b.secondary_locator
5969 and a.organization_id = b.organization_id --13472820
5970 AND a.concatenated_segments LIKE (p_concatenated_segments )
5971 -- AND a.concatenated_segments = nvl(p_suggestion, a.concatenated_segments)
5972 /* BUG#28101405: To show only common locators in the LOV */
5973 ORDER BY 2;
5974 ELSE --Locators not restricted
5975 --bug#3440453 Remove the NVL on organization_id if user passes it.
5976 IF p_organization_id IS NULL THEN
5977 OPEN x_Locators FOR
5978 SELECT inventory_location_id,
5979 --concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
5980 locator_segments locsegs,
5981 description
5982 FROM wms_item_locations_kfv
5983 WHERE organization_id = Nvl(p_organization_id, organization_id)
5984 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
5985 AND concatenated_segments LIKE (p_concatenated_segments )
5986 -- AND concatenated_segments = nvl(p_suggestion, concatenated_segments)
5987 ORDER BY 2;
5988 ELSE -- Organization_id is not null
5989 OPEN x_Locators FOR
5990 SELECT inventory_location_id,
5991 --concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
5992 locator_segments locsegs,
5993 description
5994 FROM wms_item_locations_kfv
5995 WHERE organization_id = p_organization_id
5996 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
5997 AND concatenated_segments LIKE (p_concatenated_segments )
5998 -- AND alias = nvl(p_alias, alias)
5999 -- AND concatenated_segments = nvl(p_suggestion, concatenated_segments)
6000 ORDER BY 2;
6001 END IF;
6002 END IF;
6003 ELSE /*PJM org*/
6004 IF p_project_id IS NOT NULL THEN
6005
6006 IF p_Restrict_Locators_Code = 1 THEN --Locators restricted to predefined list
6007 OPEN x_Locators FOR
6008 SELECT a.inventory_location_id,
6009 --a.concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6010 a.locator_segments locsegs,
6011 a.description
6012 FROM wms_item_locations_kfv a,
6013 mtl_secondary_locators b
6014 WHERE b.organization_id = p_Organization_Id
6015 AND b.inventory_item_id = p_Inventory_Item_Id
6016 AND b.subinventory_code = p_Subinventory_Code
6017 AND a.inventory_location_id = b.secondary_locator
6018 and a.organization_id = b.organization_id --13472820
6019 AND a.concatenated_segments LIKE (p_concatenated_segments )
6020 -- AND a.concatenated_segments = nvl(p_suggestion, a.concatenated_segments)
6021 /* BUG#28101405: To show only common locators in the LOV */
6022 AND a.project_id = p_project_id
6023 AND NVL(a.task_id, -9999) = NVL(p_task_id, -9999)
6024 ORDER BY 2;
6025
6026 ELSE --Locators not restricted
6027 --bug#3440453 Remove the NVL on organization_id if user passes it.
6028 IF p_organization_id IS NULL THEN
6029 OPEN x_Locators FOR
6030 SELECT inventory_location_id,
6031 -- concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6032 locator_segments locsegs,
6033 description
6034 FROM wms_item_locations_kfv
6035 WHERE organization_id = Nvl(p_organization_id, organization_id)
6036 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
6037 AND concatenated_segments LIKE (p_concatenated_segments )
6038 -- AND concatenated_segments = nvl(p_suggestion, concatenated_segments)
6039 AND project_id = p_project_id
6040 AND NVL(task_id, -1) = NVL(p_task_id, -1)
6041 ORDER BY 2;
6042 ELSE -- Organization_id is not null
6043 OPEN x_Locators FOR
6044 SELECT inventory_location_id,
6045 --concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6046 locator_segments locsegs,
6047 description
6048 FROM wms_item_locations_kfv
6049 WHERE organization_id = p_organization_id
6050 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
6051 AND concatenated_segments LIKE (p_concatenated_segments )
6052 -- AND concatenated_segments = nvl(p_suggestion, concatenated_segments)
6053 AND project_id = p_project_id
6054 AND NVL(task_id, -1) = NVL(p_task_id, -1)
6055 ORDER BY 2;
6056 END IF;
6057 END IF;
6058
6059 ELSE /*PJM org project id null*/
6060
6061 IF p_Restrict_Locators_Code = 1 THEN --Locators restricted to predefined list
6062 OPEN x_Locators FOR
6063 SELECT a.inventory_location_id,
6064 --a.concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6065 a.locator_segments locsegs,
6066 a.description
6067 FROM wms_item_locations_kfv a,
6068 mtl_secondary_locators b
6069 WHERE b.organization_id = p_Organization_Id
6070 AND b.inventory_item_id = p_Inventory_Item_Id
6071 AND b.subinventory_code = p_Subinventory_Code
6072 AND a.inventory_location_id = b.secondary_locator
6073 and a.organization_id = b.organization_id --13472820
6074 AND a.concatenated_segments LIKE (p_concatenated_segments )
6075 -- AND a.concatenated_segments = nvl(p_suggestion, a.concatenated_segments)
6076 AND a.inventory_location_id=NVL(a.physical_location_id,a.inventory_location_id)
6077 /* BUG#28101405: To show only common locators in the LOV */
6078 ORDER BY 2;
6079
6080 ELSE --Locators not restricted
6081 --bug#3440453 Remove the NVL on organization_id if user passes it.
6082 IF p_organization_id IS NULL THEN
6083 OPEN x_Locators FOR
6084 SELECT inventory_location_id,
6085 -- concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6086 locator_segments locsegs,
6087 description
6088 FROM wms_item_locations_kfv
6089 WHERE organization_id = Nvl(p_organization_id, organization_id)
6090 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
6091 AND concatenated_segments LIKE (p_concatenated_segments )
6092 AND inventory_location_id=nvl(physical_location_id,inventory_location_id)
6093 -- AND concatenated_segments = nvl(p_suggestion, concatenated_segments)
6094 ORDER BY 2;
6095 ELSE -- Organization_id is not null
6096 OPEN x_Locators FOR
6097 SELECT inventory_location_id,
6098 --concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6099 locator_segments locsegs,
6100 description
6101 FROM wms_item_locations_kfv
6102 WHERE organization_id = p_organization_id
6103 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
6104 AND concatenated_segments LIKE (p_concatenated_segments )
6105 -- AND concatenated_segments = nvl(p_suggestion, concatenated_segments)
6106 AND inventory_location_id=nvl(physical_location_id,inventory_location_id)
6107 ORDER BY 2;
6108 END IF;
6109 END IF;
6110 END IF;
6111 END IF;
6112 END get_inq_prj_loc_lov;
6113
6114 PROCEDURE get_inq_prj_loc_lov(
6115 x_Locators OUT NOCOPY t_genref,
6116 p_Organization_Id IN NUMBER,
6117 p_Subinventory_Code IN VARCHAR2,
6118 p_Restrict_Locators_Code IN NUMBER,
6119 p_Inventory_Item_Id IN NUMBER,
6120 p_Concatenated_Segments IN VARCHAR2,
6121 p_project_id IN NUMBER := NULL,
6122 p_task_id IN NUMBER := NULL,
6123 p_alias IN VARCHAR2
6124 ) IS
6125 l_ispjm_org VARCHAR2(1);
6126 BEGIN
6127 IF p_alias IS NULL THEN
6128 get_inq_prj_loc_lov(
6129 x_Locators => x_locators
6130 ,p_Organization_Id => p_organization_id
6131 ,p_Subinventory_Code => p_subinventory_code
6132 ,p_Restrict_Locators_Code => p_restrict_locators_code
6133 ,p_Inventory_Item_Id => p_inventory_item_id
6134 ,p_Concatenated_Segments => p_concatenated_segments
6135 ,p_project_id => p_project_id
6136 ,p_task_id => p_task_id
6137 );
6138 RETURN;
6139 END IF;
6140 BEGIN
6141 SELECT nvl(PROJECT_REFERENCE_ENABLED,'N')
6142 INTO l_ispjm_org
6143 FROM pjm_org_parameters
6144 WHERE organization_id=p_organization_id;
6145 EXCEPTION
6146 WHEN NO_DATA_FOUND THEN
6147 l_ispjm_org:='N';
6148 END;
6149
6150 IF l_ispjm_org='N' THEN /*Non PJM Org*/
6151 IF p_Restrict_Locators_Code = 1 THEN --Locators restricted to predefined list
6152 OPEN x_Locators FOR
6153 SELECT a.inventory_location_id,
6154 -- a.concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6155 a.locator_segments locsegs,
6156 a.description
6157 FROM wms_item_locations_kfv a,
6158 mtl_secondary_locators b
6159 WHERE b.organization_id = p_Organization_Id
6160 AND b.inventory_item_id = p_Inventory_Item_Id
6161 AND b.subinventory_code = p_Subinventory_Code
6162 AND a.inventory_location_id = b.secondary_locator
6163 and a.organization_id = b.organization_id --13472820
6164 AND a.alias = p_alias
6165 -- AND a.concatenated_segments = nvl(p_suggestion, a.concatenated_segments)
6166 /* BUG#28101405: To show only common locators in the LOV */
6167 ORDER BY 2;
6168 ELSE --Locators not restricted
6169 --bug#3440453 Remove the NVL on organization_id if user passes it.
6170 IF p_organization_id IS NULL THEN
6171 OPEN x_Locators FOR
6172 SELECT inventory_location_id,
6173 --concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6174 locator_segments locsegs,
6175 description
6176 FROM wms_item_locations_kfv
6177 WHERE organization_id = Nvl(p_organization_id, organization_id)
6178 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
6179 AND alias = p_alias
6180 -- AND concatenated_segments = nvl(p_suggestion, concatenated_segments)
6181 ORDER BY 2;
6182 ELSE -- Organization_id is not null
6183 OPEN x_Locators FOR
6184 SELECT inventory_location_id,
6185 --concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6186 locator_segments locsegs,
6187 description
6188 FROM wms_item_locations_kfv
6189 WHERE organization_id = p_organization_id
6190 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
6191 AND alias = p_alias
6192 ORDER BY 2;
6193 END IF;
6194 END IF;
6195 ELSE /*PJM org*/
6196 IF p_project_id IS NOT NULL THEN
6197
6198 IF p_Restrict_Locators_Code = 1 THEN --Locators restricted to predefined list
6199 OPEN x_Locators FOR
6200 SELECT a.inventory_location_id,
6201 --a.concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6202 a.locator_segments locsegs,
6203 a.description
6204 FROM wms_item_locations_kfv a,
6205 mtl_secondary_locators b
6206 WHERE b.organization_id = p_Organization_Id
6207 AND b.inventory_item_id = p_Inventory_Item_Id
6208 AND b.subinventory_code = p_Subinventory_Code
6209 AND a.inventory_location_id = b.secondary_locator
6210 and a.organization_id = b.organization_id --13472820
6211 AND a.alias = p_alias
6212 -- AND a.concatenated_segments = nvl(p_suggestion, a.concatenated_segments)
6213 /* BUG#28101405: To show only common locators in the LOV */
6214 AND a.project_id = p_project_id
6215 AND NVL(a.task_id, -9999) = NVL(p_task_id, -9999)
6216 ORDER BY 2;
6217
6218 ELSE --Locators not restricted
6219 --bug#3440453 Remove the NVL on organization_id if user passes it.
6220 IF p_organization_id IS NULL THEN
6221 OPEN x_Locators FOR
6222 SELECT inventory_location_id,
6223 -- concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6224 locator_segments locsegs,
6225 description
6226 FROM wms_item_locations_kfv
6227 WHERE organization_id = Nvl(p_organization_id, organization_id)
6228 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
6229 AND alias = p_alias
6230 -- AND concatenated_segments = nvl(p_suggestion, concatenated_segments)
6231 AND project_id = p_project_id
6232 AND NVL(task_id, -1) = NVL(p_task_id, -1)
6233 ORDER BY 2;
6234 ELSE -- Organization_id is not null
6235 OPEN x_Locators FOR
6236 SELECT inventory_location_id,
6237 --concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6238 locator_segments locsegs,
6239 description
6240 FROM wms_item_locations_kfv
6241 WHERE organization_id = p_organization_id
6242 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
6243 AND alias = p_alias
6244 -- AND concatenated_segments = nvl(p_suggestion, concatenated_segments)
6245 AND project_id = p_project_id
6246 AND NVL(task_id, -1) = NVL(p_task_id, -1)
6247 ORDER BY 2;
6248 END IF;
6249 END IF;
6250
6251 ELSE /*PJM org project id null*/
6252
6253 IF p_Restrict_Locators_Code = 1 THEN --Locators restricted to predefined list
6254 OPEN x_Locators FOR
6255 SELECT a.inventory_location_id,
6256 --a.concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6257 a.locator_segments locsegs,
6258 a.description
6259 FROM wms_item_locations_kfv a,
6260 mtl_secondary_locators b
6261 WHERE b.organization_id = p_Organization_Id
6262 AND b.inventory_item_id = p_Inventory_Item_Id
6263 AND b.subinventory_code = p_Subinventory_Code
6264 AND a.inventory_location_id = b.secondary_locator
6265 and a.organization_id = b.organization_id --13472820
6266 AND a.alias = p_alias
6267 -- AND a.concatenated_segments = nvl(p_suggestion, a.concatenated_segments)
6268 AND a.inventory_location_id=NVL(a.physical_location_id,a.inventory_location_id)
6269 /* BUG#28101405: To show only common locators in the LOV */
6270 ORDER BY 2;
6271
6272 ELSE --Locators not restricted
6273 --bug#3440453 Remove the NVL on organization_id if user passes it.
6274 IF p_organization_id IS NULL THEN
6275 OPEN x_Locators FOR
6276 SELECT inventory_location_id,
6277 -- concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6278 locator_segments locsegs,
6279 description
6280 FROM wms_item_locations_kfv
6281 WHERE organization_id = Nvl(p_organization_id, organization_id)
6282 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
6283 AND alias = p_alias
6284 AND inventory_location_id=nvl(physical_location_id,inventory_location_id)
6285 -- AND concatenated_segments = nvl(p_suggestion, concatenated_segments)
6286 ORDER BY 2;
6287 ELSE -- Organization_id is not null
6288 OPEN x_Locators FOR
6289 SELECT inventory_location_id,
6290 --concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6291 locator_segments locsegs,
6292 description
6293 FROM wms_item_locations_kfv
6294 WHERE organization_id = p_organization_id
6295 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
6296 AND alias = p_alias
6297 -- AND concatenated_segments = nvl(p_suggestion, concatenated_segments)
6298 AND inventory_location_id=nvl(physical_location_id,inventory_location_id)
6299 ORDER BY 2;
6300 END IF;
6301 END IF;
6302 END IF;
6303 END IF;
6304 END get_inq_prj_loc_lov;
6305
6306
6307
6308
6309
6310 PROCEDURE get_inq_prj_loc_lov_nvl
6311 (x_Locators OUT NOCOPY t_genref,
6312 p_Organization_Id IN NUMBER,
6313 p_Subinventory_Code IN VARCHAR2,
6314 p_Restrict_Locators_Code IN NUMBER,
6315 p_Inventory_Item_Id IN NUMBER,
6316 p_Concatenated_Segments IN VARCHAR2,
6317 p_project_id IN NUMBER := NULL,
6318 p_task_id IN NUMBER := NULL)
6319 IS
6320 l_ispjm_org VARCHAR2(1);
6321 BEGIN
6322 BEGIN
6323 SELECT nvl(PROJECT_REFERENCE_ENABLED,'N')
6324 INTO l_ispjm_org
6325 FROM pjm_org_parameters
6326 WHERE organization_id=p_organization_id;
6327 EXCEPTION
6328 WHEN NO_DATA_FOUND THEN
6329 l_ispjm_org:='N';
6330 END;
6331
6332 IF l_ispjm_org='N' THEN /*Non PJM Org*/
6333 IF p_Restrict_Locators_Code = 1 THEN --Locators restricted to predefined list
6334 OPEN x_Locators FOR
6335 SELECT a.inventory_location_id,
6336 --a.concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6337 a.locator_segments locsegs,
6338 a.description
6339 FROM wms_item_locations_kfv a,
6340 mtl_secondary_locators b
6341 WHERE b.organization_id = p_Organization_Id
6342 AND b.inventory_item_id = nvl(p_Inventory_Item_Id, b.inventory_item_id)
6343 AND b.subinventory_code = p_Subinventory_Code
6344 AND a.inventory_location_id = b.secondary_locator
6345 and a.organization_id = b.organization_id --13472820
6346 AND a.concatenated_segments LIKE (p_concatenated_segments )
6347 /* BUG#28101405: To show only common locators in the LOV */
6348 ORDER BY 2;
6349 ELSE --Locators not restricted
6350 --bug#3440453 Remove the NVL on organization_id if user passes it.
6351 IF p_organization_id IS NULL THEN
6352 OPEN x_Locators FOR
6353 SELECT inventory_location_id,
6354 --concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6355 locator_segments locsegs,
6356 description
6357 FROM wms_item_locations_kfv
6358 WHERE organization_id = Nvl(p_organization_id, organization_id)
6359 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
6360 AND concatenated_segments LIKE (p_concatenated_segments )
6361 ORDER BY 2;
6362 ELSE -- Organization_id is not null
6363 OPEN x_Locators FOR
6364 SELECT inventory_location_id,
6365 -- concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6366 locator_segments locsegs,
6367 description
6368 FROM wms_item_locations_kfv
6369 WHERE organization_id = p_organization_id
6370 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
6371 AND concatenated_segments LIKE (p_concatenated_segments )
6372 ORDER BY 2;
6373 END IF;
6374 END IF;
6375 ELSE /*PJM org*/
6376 IF p_project_id IS NOT NULL THEN
6377
6378 IF p_Restrict_Locators_Code = 1 THEN --Locators restricted to predefined list
6379 OPEN x_Locators FOR
6380 SELECT a.inventory_location_id,
6381 --a.concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6382 a.locator_segments locsegs,
6383 a.description
6384 FROM wms_item_locations_kfv a,
6385 mtl_secondary_locators b
6386 WHERE b.organization_id = p_Organization_Id
6387 AND b.inventory_item_id = nvl(p_Inventory_Item_Id, b.inventory_item_id)
6388 AND b.subinventory_code = p_Subinventory_Code
6389 AND a.inventory_location_id = b.secondary_locator
6390 and a.organization_id = b.organization_id --13472820
6391 AND a.concatenated_segments LIKE (p_concatenated_segments )
6392 /* BUG#28101405: To show only common locators in the LOV */
6393 AND a.project_id = p_project_id
6394 AND NVL(a.task_id, -9999) = NVL(p_task_id, -9999)
6395 ORDER BY 2;
6396
6397 ELSE --Locators not restricted
6398 --bug#3440453 Remove the NVL on organization_id if user passes it.
6399 IF p_organization_id IS NULL THEN
6400 OPEN x_Locators FOR
6401 SELECT inventory_location_id,
6402 --concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6403 locator_segments locsegs,
6404 description
6405 FROM wms_item_locations_kfv
6406 WHERE organization_id = Nvl(p_organization_id, organization_id)
6407 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
6408 AND concatenated_segments LIKE (p_concatenated_segments )
6409 AND project_id = p_project_id
6410 AND NVL(task_id, -1) = NVL(p_task_id, -1)
6411 ORDER BY 2;
6412 ELSE -- Organization_id is not null
6413 OPEN x_Locators FOR
6414 SELECT inventory_location_id,
6415 -- concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6416 locator_segments locsegs,
6417 description
6418 FROM wms_item_locations_kfv
6419 WHERE organization_id = p_organization_id
6420 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
6421 AND concatenated_segments LIKE (p_concatenated_segments )
6422 AND project_id = p_project_id
6423 AND NVL(task_id, -1) = NVL(p_task_id, -1)
6424 ORDER BY 2;
6425 END IF;
6426 END IF;
6427
6428 ELSE /*PJM org project id null*/
6429
6430 IF p_Restrict_Locators_Code = 1 THEN --Locators restricted to predefined list
6431 OPEN x_Locators FOR
6432 SELECT a.inventory_location_id,
6433 --a.concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6434 a.locator_segments locsegs,
6435 a.description
6436 FROM wms_item_locations_kfv a,
6437 mtl_secondary_locators b
6438 WHERE b.organization_id = p_Organization_Id
6439 AND b.inventory_item_id = nvl(p_Inventory_Item_Id, b.inventory_item_id)
6440 AND b.subinventory_code = p_Subinventory_Code
6441 AND a.inventory_location_id = b.secondary_locator
6442 and a.organization_id = b.organization_id --13472820
6443 AND a.concatenated_segments LIKE (p_concatenated_segments )
6444 AND a.inventory_location_id=NVL(a.physical_location_id,a.inventory_location_id)
6445 /* BUG#28101405: To show only common locators in the LOV */
6446 ORDER BY 2;
6447
6448 ELSE --Locators not restricted
6449 --bug#3440453 Remove the NVL on organization_id if user passes it.
6450 IF p_organization_id IS NULL THEN
6451 OPEN x_Locators FOR
6452 SELECT inventory_location_id,
6453 --concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6454 locator_segments locsegs,
6455 description
6456 FROM wms_item_locations_kfv
6457 WHERE organization_id = Nvl(p_organization_id, organization_id)
6458 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
6459 AND concatenated_segments LIKE (p_concatenated_segments )
6460 AND inventory_location_id=nvl(physical_location_id,inventory_location_id)
6461 ORDER BY 2;
6462 ELSE -- Organization_id is not null
6463 OPEN x_Locators FOR
6464 SELECT inventory_location_id,
6465 -- concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6466 locator_segments locsegs,
6467 description
6468 FROM wms_item_locations_kfv
6469 WHERE organization_id = p_organization_id
6470 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
6471 AND concatenated_segments LIKE (p_concatenated_segments )
6472 AND inventory_location_id=nvl(physical_location_id,inventory_location_id)
6473 ORDER BY 2;
6474 END IF;
6475 END IF;
6476 END IF;
6477 END IF;
6478 END get_inq_prj_loc_lov_nvl;
6479 PROCEDURE get_inq_prj_loc_lov_nvl(
6480 x_Locators OUT NOCOPY t_genref,
6481 p_Organization_Id IN NUMBER,
6482 p_Subinventory_Code IN VARCHAR2,
6483 p_Restrict_Locators_Code IN NUMBER,
6484 p_Inventory_Item_Id IN NUMBER,
6485 p_Concatenated_Segments IN VARCHAR2,
6486 p_project_id IN NUMBER := NULL,
6487 p_task_id IN NUMBER := NULL,
6488 p_alias IN VARCHAR2)
6489 IS
6490 l_ispjm_org VARCHAR2(1);
6491 BEGIN
6492 IF p_alias IS NULL THEN
6493 get_inq_prj_loc_lov_nvl(
6494 x_Locators => x_locators
6495 ,p_Organization_Id => p_organization_id
6496 ,p_Subinventory_Code => p_subinventory_code
6497 ,p_Restrict_Locators_Code => p_restrict_locators_code
6498 ,p_Inventory_Item_Id => p_inventory_item_id
6499 ,p_Concatenated_Segments => p_concatenated_segments
6500 ,p_project_id => p_project_id
6501 ,p_task_id => p_task_id
6502 );
6503 RETURN;
6504 END IF;
6505 BEGIN
6506 SELECT nvl(PROJECT_REFERENCE_ENABLED,'N')
6507 INTO l_ispjm_org
6508 FROM pjm_org_parameters
6509 WHERE organization_id=p_organization_id;
6510 EXCEPTION
6511 WHEN NO_DATA_FOUND THEN
6512 l_ispjm_org:='N';
6513 END;
6514
6515 IF l_ispjm_org='N' THEN /*Non PJM Org*/
6516 IF p_Restrict_Locators_Code = 1 THEN --Locators restricted to predefined list
6517 OPEN x_Locators FOR
6518 SELECT a.inventory_location_id,
6519 --a.concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6520 a.locator_segments locsegs,
6521 a.description
6522 FROM wms_item_locations_kfv a,
6523 mtl_secondary_locators b
6524 WHERE b.organization_id = p_Organization_Id
6525 AND b.inventory_item_id = nvl(p_Inventory_Item_Id, b.inventory_item_id)
6526 AND b.subinventory_code = p_Subinventory_Code
6527 AND a.inventory_location_id = b.secondary_locator
6528 and a.organization_id = b.organization_id --13472820
6529 AND a.alias = p_alias
6530 /* BUG#28101405: To show only common locators in the LOV */
6531 ORDER BY 2;
6532 ELSE --Locators not restricted
6533 --bug#3440453 Remove the NVL on organization_id if user passes it.
6534 IF p_organization_id IS NULL THEN
6535 OPEN x_Locators FOR
6536 SELECT inventory_location_id,
6537 --concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6538 locator_segments locsegs,
6539 description
6540 FROM wms_item_locations_kfv
6541 WHERE organization_id = Nvl(p_organization_id, organization_id)
6542 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
6543 AND alias = p_alias
6544 ORDER BY 2;
6545 ELSE -- Organization_id is not null
6546 OPEN x_Locators FOR
6547 SELECT inventory_location_id,
6548 -- concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6549 locator_segments locsegs,
6550 description
6551 FROM wms_item_locations_kfv
6552 WHERE organization_id = p_organization_id
6553 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
6554 AND alias = p_alias
6555 ORDER BY 2;
6556 END IF;
6557 END IF;
6558 ELSE /*PJM org*/
6559 IF p_project_id IS NOT NULL THEN
6560
6561 IF p_Restrict_Locators_Code = 1 THEN --Locators restricted to predefined list
6562 OPEN x_Locators FOR
6563 SELECT a.inventory_location_id,
6564 --a.concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6565 a.locator_segments locsegs,
6566 a.description
6567 FROM wms_item_locations_kfv a,
6568 mtl_secondary_locators b
6569 WHERE b.organization_id = p_Organization_Id
6570 AND b.inventory_item_id = nvl(p_Inventory_Item_Id, b.inventory_item_id)
6571 AND b.subinventory_code = p_Subinventory_Code
6572 AND a.inventory_location_id = b.secondary_locator
6573 and a.organization_id = b.organization_id --13472820
6574 AND a.alias = p_alias
6575 /* BUG#28101405: To show only common locators in the LOV */
6576 AND a.project_id = p_project_id
6577 AND NVL(a.task_id, -9999) = NVL(p_task_id, -9999)
6578 ORDER BY 2;
6579
6580 ELSE --Locators not restricted
6581 --bug#3440453 Remove the NVL on organization_id if user passes it.
6582 IF p_organization_id IS NULL THEN
6583 OPEN x_Locators FOR
6584 SELECT inventory_location_id,
6585 --concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6586 locator_segments locsegs,
6587 description
6588 FROM wms_item_locations_kfv
6589 WHERE organization_id = Nvl(p_organization_id, organization_id)
6590 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
6591 AND alias = p_alias
6592 AND project_id = p_project_id
6593 AND NVL(task_id, -1) = NVL(p_task_id, -1)
6594 ORDER BY 2;
6595 ELSE -- Organization_id is not null
6596 OPEN x_Locators FOR
6597 SELECT inventory_location_id,
6598 -- concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6599 locator_segments locsegs,
6600 description
6601 FROM wms_item_locations_kfv
6602 WHERE organization_id = p_organization_id
6603 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
6604 AND alias = p_alias
6605 AND project_id = p_project_id
6606 AND NVL(task_id, -1) = NVL(p_task_id, -1)
6607 ORDER BY 2;
6608 END IF;
6609 END IF;
6610
6611 ELSE /*PJM org project id null*/
6612
6613 IF p_Restrict_Locators_Code = 1 THEN --Locators restricted to predefined list
6614 OPEN x_Locators FOR
6615 SELECT a.inventory_location_id,
6616 --a.concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6617 a.locator_segments locsegs,
6618 a.description
6619 FROM wms_item_locations_kfv a,
6620 mtl_secondary_locators b
6621 WHERE b.organization_id = p_Organization_Id
6622 AND b.inventory_item_id = nvl(p_Inventory_Item_Id, b.inventory_item_id)
6623 AND b.subinventory_code = p_Subinventory_Code
6624 AND a.inventory_location_id = b.secondary_locator
6625 and a.organization_id = b.organization_id --13472820
6626 AND a.alias = p_alias
6627 AND a.inventory_location_id=NVL(a.physical_location_id,a.inventory_location_id)
6628 /* BUG#28101405: To show only common locators in the LOV */
6629 ORDER BY 2;
6630
6631 ELSE --Locators not restricted
6632 --bug#3440453 Remove the NVL on organization_id if user passes it.
6633 IF p_organization_id IS NULL THEN
6634 OPEN x_Locators FOR
6635 SELECT inventory_location_id,
6636 --concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6637 locator_segments locsegs,
6638 description
6639 FROM wms_item_locations_kfv
6640 WHERE organization_id = Nvl(p_organization_id, organization_id)
6641 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
6642 AND alias = p_alias
6643 AND inventory_location_id=nvl(physical_location_id,inventory_location_id)
6644 ORDER BY 2;
6645 ELSE -- Organization_id is not null
6646 OPEN x_Locators FOR
6647 SELECT inventory_location_id,
6648 -- concatenated_segments locsegs,--Bug4398337:Commented this line and added below line
6649 locator_segments locsegs,
6650 description
6651 FROM wms_item_locations_kfv
6652 WHERE organization_id = p_organization_id
6653 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
6654 AND alias = p_alias
6655 AND inventory_location_id=nvl(physical_location_id,inventory_location_id)
6656 ORDER BY 2;
6657 END IF;
6658 END IF;
6659 END IF;
6660 END IF;
6661 END get_inq_prj_loc_lov_nvl;
6662
6663
6664
6665
6666
6667 /*Bug #3075665 - FOR PATCHSET J PROJECT - ADVANCED PICK LOAD
6668 * This procedure gets the locator details - concat segs, loc desc,
6669 * project, task, sub for a given org id, loc id.
6670 * The procedure also returns if the given locator exists or not.
6671 */
6672 PROCEDURE GET_PICKLOAD_LOC_DETAILS(
6673 p_organization_id IN NUMBER
6674 , p_inventory_location_id IN NUMBER
6675 , x_subinventory_code OUT NOCOPY VARCHAR2
6676 , x_concatenated_segments OUT NOCOPY VARCHAR2
6677 , x_description OUT NOCOPY VARCHAR2
6678 , x_project_id OUT NOCOPY NUMBER
6679 , x_task_id OUT NOCOPY NUMBER
6680 , x_loc_exists OUT NOCOPY VARCHAR
6681 , x_msg_count OUT NOCOPY NUMBER
6682 , x_msg_data OUT NOCOPY VARCHAR2
6683 , x_return_status OUT NOCOPY VARCHAR2 ) IS
6684 BEGIN
6685 x_loc_exists := 'Y';
6686 BEGIN
6687 DEBUG('INV_UI_ITEM_SUB_LOC_LOVS.GET_PICKLOAD_LOC_DETAILS');
6688 DEBUG('p_inventory_location_id -> '||p_inventory_location_id);
6689 DEBUG('p_organization_id -> '||p_organization_id);
6690 SELECT subinventory_code
6691 , CONCATENATED_SEGMENTS
6692 , DESCRIPTION
6693 , project_id
6694 , task_id
6695 INTO x_subinventory_code
6696 , x_concatenated_segments
6697 , x_description
6698 , x_project_id
6699 , x_task_id
6700 FROM wms_item_locations_kfv
6701 WHERE inventory_location_id = p_inventory_location_id
6702 AND organization_id = p_organization_id;
6703 EXCEPTION
6704 WHEN NO_DATA_FOUND THEN
6705 x_loc_exists := 'N';
6706 END;
6707
6708 IF(x_subinventory_code IS NULL) THEN
6709 x_loc_exists := 'N';
6710 END IF;
6711 DEBUG('x_loc_exists -> '||x_loc_exists);
6712
6713 END GET_PICKLOAD_LOC_DETAILS;
6714
6715
6716
6717 --
6718 ----------------------------------
6719 -- Name: GET_LOCATION_TYPE_LOCATORS
6720 -- To query locators of a sub and org without status check
6721 -- that is also filtered by mtl_item_locations.inventory_location_type
6722 -- Input Parameter:
6723 -- p_organization_id: Organization ID
6724 -- p_subinventory_code Sub
6725 -- p_inventory_location_type Location Type: Dock Door, Staging, Storage
6726 -- p_concatenated_segments LOV
6727 --
6728 PROCEDURE Get_Location_Type_Locators(
6729 x_locators OUT NOCOPY t_genref
6730 , p_organization_id IN NUMBER
6731 , p_subinventory_code IN VARCHAR2
6732 , p_inventory_location_type IN NUMBER
6733 , p_concatenated_segments IN VARCHAR2
6734 ) IS
6735 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
6736 l_ispjm_org VARCHAR2(1);
6737 BEGIN
6738 BEGIN
6739 SELECT nvl(PROJECT_REFERENCE_ENABLED,'N')
6740 INTO l_ispjm_org
6741 FROM pjm_org_parameters
6742 WHERE organization_id=p_organization_id;
6743 EXCEPTION
6744 WHEN NO_DATA_FOUND THEN
6745 l_ispjm_org:='N';
6746 END;
6747
6748 IF ( l_ispjm_org = 'N' )THEN
6749 OPEN x_Locators FOR
6750 SELECT inventory_location_id
6751 , locator_segments locsegs
6752 , description
6753 FROM wms_item_locations_kfv
6754 WHERE organization_id = p_organization_id
6755 AND subinventory_code = NVL(p_Subinventory_Code ,subinventory_code)
6756 AND inventory_location_type = p_inventory_location_type
6757 AND NVL(disable_date, trunc(sysdate+1)) > trunc(sysdate)
6758 AND concatenated_segments LIKE (p_concatenated_segments)
6759 ORDER BY 2;
6760 ELSE --PJM Org
6761 OPEN x_Locators FOR
6762 SELECT inventory_location_id
6763 , locator_segments locsegs
6764 , description
6765 FROM wms_item_locations_kfv
6766 WHERE organization_id = p_organization_id
6767 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
6768 AND inventory_location_type = p_inventory_location_type
6769 AND NVL(disable_date, trunc(sysdate+1)) > trunc(sysdate)
6770 AND concatenated_segments LIKE (p_concatenated_segments )
6771 AND inventory_location_id = NVL(physical_location_id,inventory_location_id)
6772 ORDER BY 2;
6773 END IF;
6774 END Get_Location_Type_Locators;
6775
6776 PROCEDURE Get_Location_Type_Locators(
6777 x_locators OUT NOCOPY t_genref
6778 , p_organization_id IN NUMBER
6779 , p_subinventory_code IN VARCHAR2
6780 , p_inventory_location_type IN NUMBER
6781 , p_concatenated_segments IN VARCHAR2
6782 , p_alias IN VARCHAR2
6783 ) IS
6784 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
6785 l_ispjm_org VARCHAR2(1);
6786 BEGIN
6787
6788 IF p_alias IS NULL THEN
6789 Get_Location_Type_Locators(
6790 x_locators => x_locators
6791 , p_organization_id => p_organization_id
6792 , p_subinventory_code => p_subinventory_code
6793 , p_inventory_location_type => p_inventory_location_type
6794 , p_concatenated_segments => p_concatenated_segments
6795 );
6796 RETURN;
6797 END IF;
6798 BEGIN
6799 SELECT nvl(PROJECT_REFERENCE_ENABLED,'N')
6800 INTO l_ispjm_org
6801 FROM pjm_org_parameters
6802 WHERE organization_id=p_organization_id;
6803 EXCEPTION
6804 WHEN NO_DATA_FOUND THEN
6805 l_ispjm_org:='N';
6806 END;
6807
6808 IF ( l_ispjm_org = 'N' )THEN
6809 OPEN x_Locators FOR
6810 SELECT inventory_location_id
6811 , locator_segments locsegs
6812 , description
6813 FROM wms_item_locations_kfv
6814 WHERE organization_id = p_organization_id
6815 AND subinventory_code = NVL(p_Subinventory_Code ,subinventory_code)
6816 AND inventory_location_type = p_inventory_location_type
6817 AND NVL(disable_date, trunc(sysdate+1)) > trunc(sysdate)
6818 AND alias = p_alias
6819 ORDER BY 2;
6820 ELSE --PJM Org
6821 OPEN x_Locators FOR
6822 SELECT inventory_location_id
6823 , locator_segments locsegs
6824 , description
6825 FROM wms_item_locations_kfv
6826 WHERE organization_id = p_organization_id
6827 AND subinventory_code = Nvl(p_Subinventory_Code ,subinventory_code)
6828 AND inventory_location_type = p_inventory_location_type
6829 AND NVL(disable_date, trunc(sysdate+1)) > trunc(sysdate)
6830 AND inventory_location_id = NVL(physical_location_id,inventory_location_id)
6831 AND alias = p_alias
6832 ORDER BY 2;
6833 END IF;
6834 END Get_Location_Type_Locators;
6835
6836 PROCEDURE get_value_from_alias(
6837 x_return_status OUT NOCOPY VARCHAR2
6838 ,x_msg_data OUT NOCOPY VARCHAR2
6839 ,x_msg_count OUT NOCOPY NUMBER
6840 ,x_match OUT NOCOPY VARCHAR2
6841 ,x_value OUT NOCOPY VARCHAR2
6842 ,p_org_id IN NUMBER
6843 ,p_sub_code IN VARCHAR2
6844 ,p_alias IN VARCHAR2
6845 ,p_suggested IN VARCHAR2
6846 ) IS
6847 BEGIN
6848
6849 x_return_status := 'S';
6850 x_value := NULL;
6851 x_match := NULL;
6852 x_msg_data := NULL;
6853 x_msg_count := 0;
6854
6855 SELECT locator_segments
6856 INTO x_value
6857 FROM wms_item_locations_kfv
6858 WHERE alias = p_alias
6859 AND organization_id = p_org_id
6860 AND subinventory_code = p_sub_code
6861 AND project_id IS NULL
6862 AND task_id IS NULL;
6863
6864 EXCEPTION
6865 WHEN NO_DATA_FOUND THEN
6866 x_match := 'NONE';
6867 WHEN TOO_MANY_ROWS THEN
6868 IF p_suggested IS NOT NULL THEN
6869 BEGIN
6870 SELECT locator_segments
6871 INTO x_value
6872 FROM wms_item_locations_kfv
6873 WHERE alias = p_alias
6874 AND organization_id = p_org_id
6875 AND subinventory_code = p_sub_code
6876 AND locator_segments = p_suggested
6877 AND project_id IS NULL
6878 AND task_id IS NULL;
6879 EXCEPTION
6880 WHEN NO_DATA_FOUND THEN
6881 x_match := 'MULTIPLE';
6882 WHEN OTHERS THEN
6883 x_return_status := 'U';
6884 x_value := NULL;
6885 x_match := NULL;
6886 x_msg_data := SQLERRM;
6887 x_msg_count := 1;
6888 END;
6889 ELSE
6890 x_match := 'MULTIPLE';
6891 END IF;
6892 WHEN OTHERS THEN
6893 x_return_status := 'U';
6894 x_value := NULL;
6895 x_match := NULL;
6896 x_msg_data := SQLERRM;
6897 x_msg_count := 1;
6898 END get_value_from_alias;
6899
6900 /* Added following procdure for bug 8237335 */
6901 PROCEDURE get_prj_to_loc_lov(
6902 x_locators OUT NOCOPY t_genref
6903 , p_organization_id IN NUMBER
6904 , p_subinventory_code IN VARCHAR2
6905 , p_restrict_locators_code IN NUMBER
6906 , p_inventory_item_id IN NUMBER
6907 , p_concatenated_segments IN VARCHAR2
6908 , p_transaction_type_id IN NUMBER
6909 , p_wms_installed IN VARCHAR2
6910 , p_project_id IN NUMBER
6911 , p_task_id IN NUMBER
6912 ) IS
6913 x_return_status VARCHAR2(100);
6914 x_display VARCHAR2(100);
6915 x_project_col NUMBER;
6916 x_task_col NUMBER;
6917 l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
6918 l_ispjm_org VARCHAR2(1);
6919 l_sub_type NUMBER;
6920 BEGIN
6921 debug('Inside INV_UI_ITEM_SUB_LOC_LOVS.get_prj_to_loc_lov');
6922 debug('p_organization_id : ' || p_organization_id);
6923 debug('p_subinventory_code : ' || p_subinventory_code);
6924 debug('p_restrict_locators_code : ' || p_restrict_locators_code);
6925 debug('p_inventory_item_id : ' || p_inventory_item_id);
6926 debug('p_concatenated_segments : ' || p_concatenated_segments);
6927 debug('p_transaction_type_id : ' || p_transaction_type_id);
6928 debug('p_wms_installed : ' || p_wms_installed);
6929 debug('p_project_id : ' || p_project_id);
6930 debug('p_task_id : ' || p_task_id);
6931
6932 BEGIN
6933 SELECT nvl(PROJECT_REFERENCE_ENABLED,'N')
6934 INTO l_ispjm_org
6935 FROM pjm_org_parameters
6936 WHERE organization_id=p_organization_id;
6937 EXCEPTION
6938 WHEN NO_DATA_FOUND THEN
6939 l_ispjm_org:='N';
6940 END;
6941 debug('l_ispjm_org : ' || l_ispjm_org);
6942
6943 BEGIN
6944 SELECT Nvl(subinventory_type,1)
6945 INTO l_sub_type
6946 FROM mtl_secondary_inventories
6947 WHERE secondary_inventory_name = p_subinventory_code
6948 AND organization_id = p_organization_id;
6949 EXCEPTION
6950 WHEN OTHERS THEN
6951 l_sub_type := 1;
6952 END;
6953 debug('l_sub_type : ' || l_sub_type);
6954
6955 IF l_ispjm_org='N' THEN /*Non PJM Org*/
6956 IF p_Restrict_Locators_Code = 1 AND l_sub_type = 1 THEN --Locators restricted to predefined list
6957 OPEN x_Locators FOR
6958 select a.inventory_location_id,
6959 a.locator_segments concatenated_segments,
6960 nvl( a.description, -1)
6961 FROM wms_item_locations_kfv a,mtl_secondary_locators b
6962 WHERE b.organization_id = p_Organization_Id
6963 AND b.inventory_item_id = p_Inventory_Item_Id
6964 AND nvl(a.disable_date, trunc(sysdate+1)) > trunc(sysdate)
6965 AND b.subinventory_code = p_Subinventory_Code
6966 AND a.inventory_location_id = b.secondary_locator
6967 and a.organization_id = b.organization_id --13472820
6968 AND a.concatenated_segments LIKE (p_concatenated_segments)
6969 ORDER BY 2;
6970 ELSE --Locators not restricted
6971 OPEN x_Locators FOR
6972 select inventory_location_id,
6973 locator_segments concatenated_segments,
6974 description
6975 FROM wms_item_locations_kfv
6976 WHERE organization_id = p_Organization_Id
6977 AND subinventory_code = p_Subinventory_Code
6978 AND nvl(disable_date, trunc(sysdate+1)) > trunc(sysdate)
6979 AND concatenated_segments LIKE (p_concatenated_segments )
6980 ORDER BY 2;
6981 END IF;
6982 ELSE /*PJM org*/
6983 IF p_Restrict_Locators_Code = 1 AND l_sub_type = 1 THEN --Locators restricted to predefined list
6984 OPEN x_Locators FOR
6985 select a.inventory_location_id,
6986 a.locator_segments concatenated_segments,
6987 nvl( a.description, -1)
6988 FROM wms_item_locations_kfv a,mtl_secondary_locators b
6989 WHERE b.organization_id = p_Organization_Id
6990 AND b.inventory_item_id = p_Inventory_Item_Id
6991 AND nvl(a.disable_date, trunc(sysdate+1)) > trunc(sysdate)
6992 AND b.subinventory_code = p_Subinventory_Code
6993 AND a.inventory_location_id = b.secondary_locator
6994 and a.organization_id = b.organization_id --13472820
6995 AND a.inventory_location_id=nvl(a.physical_location_id,a.inventory_location_id)
6996 AND a.concatenated_segments like (p_concatenated_segments )
6997 ORDER BY 2;
6998 ELSE --Locators not restricted
6999 OPEN x_Locators FOR
7000 select inventory_location_id,
7001 locator_segments concatenated_segments,
7002 description
7003 FROM wms_item_locations_kfv
7004 WHERE organization_id = p_Organization_Id
7005 AND subinventory_code = p_Subinventory_Code
7006 AND nvl(disable_date, trunc(sysdate+1)) > trunc(sysdate)
7007 AND inventory_location_id=NVL(physical_location_id,inventory_location_id)
7008 AND concatenated_segments LIKE (p_concatenated_segments )
7009 ORDER BY 2;
7010 END IF;
7011 END IF;
7012 END get_prj_to_loc_lov;
7013
7014 /*9022877*/
7015 PROCEDURE get_restricted_subs(
7016 x_zones OUT NOCOPY t_genref
7017 , p_organization_id IN NUMBER
7018 , p_subinventory_code IN VARCHAR2
7019 , p_inventory_item_id IN NUMBER
7020 ) IS
7021 BEGIN
7022 OPEN x_zones FOR
7023 SELECT secondary_inventory_name
7024 , NVL(locator_type, 1)
7025 , description
7026 , asset_inventory
7027 , lpn_controlled_flag
7028 , enable_locator_alias
7029 FROM mtl_secondary_inventories msi,
7030 mtl_item_sub_inventories misi
7031 WHERE msi.organization_id = p_organization_id
7032 AND msi.organization_id = misi.organization_id
7033 AND msi.secondary_inventory_name = misi.secondary_inventory
7034 AND misi.inventory_item_id = p_inventory_item_id
7035 AND NVL(msi.disable_date, TRUNC(SYSDATE + 1)) > TRUNC(SYSDATE)
7036 AND msi.secondary_inventory_name LIKE (p_subinventory_code)
7037 ORDER BY secondary_inventory_name;
7038 END get_restricted_subs;
7039
7040 -- Procedure to find out the given locator segment combination is already available in any other subinventory
7041 -- 14849583
7042
7043 PROCEDURE LOC_EXISTS_PROC(
7044 P_SUBINV IN VARCHAR2,
7045 P_LOCATOR IN VARCHAR2,
7046 P_ORG_ID IN NUMBER,
7047 P_LOC_EXISTS OUT NOCOPY VARCHAR2
7048 )
7049 IS
7050 L_LOCATOR VARCHAR2(1000);
7051 L_WHERE_CLAUSE VARCHAR2(3000) := '';
7052 L_DELIMITER VARCHAR2(10);
7053 L_DEL_POS NUMBER;
7054 L_SEGMENT VARCHAR2(1000);
7055 NO_OF_DELIMITERS NUMBER;
7056 L_SEGMENT_COUNT NUMBER;
7057 L_STMT VARCHAR2(3000);
7058 ROWS_PROCESSED NUMBER;
7059 C INTEGER;
7060 LOC_COUNT NUMBER;
7061
7062 CURSOR C1 IS
7063 select application_column_name
7064 from fnd_id_flex_segments
7065 where application_id = 401
7066 and id_flex_code = 'MTLL'
7067 and id_flex_num = 101
7068 and application_column_name not in ('SEGMENT19','SEGMENT20')
7069 AND NVL(ENABLED_FLAG, 'N') = 'Y'
7070 order by segment_num;
7071
7072 BEGIN
7073
7074 L_LOCATOR:= P_LOCATOR;
7075
7076 SELECT COUNT(*)
7077 into l_segment_count
7078 from fnd_id_flex_segments
7079 where application_id = 401
7080 and id_flex_code = 'MTLL'
7081 and id_flex_num = 101
7082 and application_column_name not in ('SEGMENT19','SEGMENT20')
7083 AND NVL(ENABLED_FLAG, 'N') = 'Y'
7084 order by segment_num;
7085
7086 SELECT CONCATENATED_SEGMENT_DELIMITER
7087 INTO L_DELIMITER
7088 from FND_ID_FLEX_STRUCTURES
7089 WHERE ID_FLEX_CODE = 'MTLL'
7090 AND ID_FLEX_NUM = '101';
7091
7092 /*SELECT LENGTH(REGEXP_REPLACE(L_LOCATOR, '[^[:punct:]]')) / LENGTH(L_Delimiter)
7093 into no_of_delimiters
7094 from dual;*/
7095
7096 Select (Length(L_Locator) - Length(Replace(L_Locator, L_Delimiter)))
7097 into no_of_delimiters
7098 From Dual;
7099
7100 IF L_SEGMENT_COUNT <> NO_OF_DELIMITERS+1
7101 THEN
7102 P_LOC_EXISTS := 'Y'; --This will throw error in LocatorKFF.java page because delimiters are not same as number of segment passed.
7103 else
7104
7105 FOR C1REC IN C1 LOOP
7106
7107 SELECT INSTR(L_LOCATOR,L_DELIMITER )
7108 INTO L_DEL_POS
7109 FROM DUAL;
7110
7111 IF L_DEL_POS <> 0
7112 THEN
7113 IF L_DEL_POS = 1 THEN
7114 L_WHERE_CLAUSE := L_WHERE_CLAUSE || C1REC.APPLICATION_COLUMN_NAME||' is null ';
7115 SELECT SUBSTR(L_LOCATOR,L_DEL_POS+1)
7116 INTO L_LOCATOR
7117 FROM DUAL;
7118 IF L_LOCATOR IS NOT NULL THEN
7119 L_WHERE_CLAUSE := L_WHERE_CLAUSE ||' and ' ;
7120 end if;
7121 else
7122 SELECT SUBSTR(L_LOCATOR,1,L_DEL_POS-1) , SUBSTR(L_LOCATOR,L_DEL_POS+1)
7123 INTO L_SEGMENT , L_LOCATOR
7124 FROM DUAL;
7125
7126 L_WHERE_CLAUSE := L_WHERE_CLAUSE || C1REC.APPLICATION_COLUMN_NAME||' = '|| ''''||L_SEGMENT ||''''|| ' and ';
7127 end if;
7128 ELSE
7129 --L_WHERE_CLAUSE := L_WHERE_CLAUSE || C1REC.APPLICATION_COLUMN_NAME||' = '||''''||L_LOCATOR||'''';
7130 --comment the above code because it is creating the incorrect where clause
7131 IF L_LOCATOR IS NULL THEN
7132 L_WHERE_CLAUSE := L_WHERE_CLAUSE || C1REC.APPLICATION_COLUMN_NAME||' is null ';
7133
7134 ELSE
7135 L_WHERE_CLAUSE := L_WHERE_CLAUSE || C1REC.APPLICATION_COLUMN_NAME||' = '||''''||L_LOCATOR||'''';
7136
7137 END IF;
7138 end if;
7139
7140 END LOOP;
7141
7142 l_stmt := l_stmt || 'SELECT COUNT(*) from mtl_item_locations where organization_id = '||P_ORG_ID||' and nvl(subinventory_code,''@@@'') <> '''|| P_SUBINV ||''' and '|| L_WHERE_CLAUSE ;
7143
7144 --dbms_output.put_line('l_stmt: '||l_stmt);
7145
7146 c := dbms_sql.open_cursor;
7147
7148 DBMS_SQL.PARSE(C, L_STMT, DBMS_SQL.NATIVE);
7149 dbms_sql.define_column(c,1,loc_count);
7150
7151 rows_processed := dbms_sql.execute(c);
7152
7153 --dbms_output.put_line('rows_processed:'||rows_processed);
7154
7155 IF DBMS_SQL.FETCH_ROWS(C)> 0 THEN
7156 DBMS_SQL.COLUMN_VALUE(C,1,LOC_COUNT);
7157 dbms_output.put_line('LOC_COUNT:'||LOC_COUNT);
7158 end if;
7159
7160 DBMS_SQL.CLOSE_CURSOR(C);
7161
7162 IF LOC_COUNT > 0 THEN
7163 P_LOC_EXISTS := 'Y';
7164 else
7165 P_LOC_EXISTS := 'N';
7166 END IF;
7167
7168 END IF;
7169
7170
7171 END LOC_EXISTS_PROC;
7172
7173 END inv_ui_item_sub_loc_lovs;