[Home] [Help]
PACKAGE BODY: APPS.WMS_RULE_2
Source
1 PACKAGE BODY WMS_RULE_2 AS
2
3 PROCEDURE open_curs
4 (
5 p_cursor IN OUT NOCOPY WMS_RULE_PVT.cv_pick_type,
6 p_organization_id IN NUMBER,
7 p_inventory_item_id IN NUMBER,
8 p_transaction_type_id IN NUMBER,
9 p_revision IN VARCHAR2,
10 p_lot_number IN VARCHAR2,
11 p_subinventory_code IN VARCHAR2,
12 p_locator_id IN NUMBER,
13 p_cost_group_id IN NUMBER,
14 p_pp_transaction_temp_id IN NUMBER,
15 p_serial_controlled IN NUMBER,
16 p_detail_serial IN NUMBER,
17 p_detail_any_serial IN NUMBER,
18 p_from_serial_number IN VARCHAR2,
19 p_to_serial_number IN VARCHAR2,
20 p_unit_number IN VARCHAR2,
21 p_lpn_id IN NUMBER,
22 p_project_id IN NUMBER,
23 p_task_id IN NUMBER,
24 x_result OUT NOCOPY NUMBER
25 ) IS
26 g_organization_id NUMBER;
27 g_inventory_item_id NUMBER;
28 g_transaction_type_id NUMBER;
29 g_revision VARCHAR2(3);
30 g_lot_number VARCHAR2(80);
31 g_subinventory_code VARCHAR2(10);
32 g_locator_id NUMBER;
33 g_cost_group_id NUMBER;
34 g_pp_transaction_temp_id NUMBER;
35 g_serial_control NUMBER;
36 g_detail_serial NUMBER;
37 g_detail_any_serial NUMBER;
38 g_from_serial_number VARCHAR2(30);
39 g_to_serial_number VARCHAR2(30);
40 g_unit_number VARCHAR2(30);
41 g_lpn_id NUMBER;
42 g_project_id NUMBER;
43 g_task_id NUMBER;
44 l_allow_expired_lot_txn NUMBER := 0;
45
46
47 BEGIN
48 g_organization_id :=p_organization_id;
49 g_inventory_item_id := p_inventory_item_id;
50 g_transaction_type_id := p_transaction_type_id;
54 g_locator_id := p_locator_id;
51 g_revision := p_revision;
52 g_lot_number := p_lot_number;
53 g_subinventory_code :=p_subinventory_code;
55 g_cost_group_id := p_cost_group_id;
56 g_pp_transaction_temp_id := p_pp_transaction_temp_id;
57 g_serial_control:= p_serial_controlled;
58 g_detail_serial := p_detail_serial;
59 g_detail_any_serial := p_detail_any_serial;
60 g_from_serial_number := p_from_serial_number;
61 g_to_serial_number := p_to_serial_number;
62 g_unit_number := p_unit_number;
63 g_lpn_id := p_lpn_id;
64 g_project_id := p_project_id;
65 g_task_id := p_task_id;
66
67 IF (g_serial_control = 1) AND (g_detail_serial in (1,2)) THEN
68 OPEN p_cursor FOR select base.REVISION
69 ,base.LOT_NUMBER
70 ,base.LOT_EXPIRATION_DATE
71 ,base.SUBINVENTORY_CODE
72 ,base.LOCATOR_ID
73 ,base.COST_GROUP_ID
74 ,base.UOM_CODE
75 ,decode(g_lpn_id, -9999, NULL, g_lpn_id) LPN_ID
76 ,base.SERIAL_NUMBER
77 ,base.primary_quantity
78 ,base.secondary_quantity
79 ,base.grade_code
80 ,NULL consist_string
81 ,base.DATE_RECEIVED order_by_string
82 from
83 MTL_LOT_NUMBERS mlna ,
84 WMS_TRX_DETAILS_TMP_V mptdtv
85 ,(
86 select msn.current_organization_id organization_id
87 ,msn.inventory_item_id
88 ,msn.revision
89 ,msn.lot_number
90 ,lot.expiration_date lot_expiration_date
91 ,msn.current_subinventory_code subinventory_code
92 ,msn.current_locator_id locator_id
93 ,msn.cost_group_id
94 ,msn.status_id --added status_id
95 ,msn.serial_number
96 ,msn.initialization_date date_received
97 ,1 primary_quantity
98 ,null secondary_quantity -- new
99 ,lot.grade_code grade_code -- new
100 ,sub.reservable_type
101 ,nvl(loc.reservable_type,1) locreservable -- Bug 6719290
102 ,nvl(lot.reservable_type,1) lotreservable -- Bug 6719290
103 ,nvl(loc.pick_uom_code, sub.pick_uom_code) uom_code
104 ,WMS_Rule_PVT.GetConversionRate(
105 nvl(loc.pick_uom_code, sub.pick_uom_code)
106 ,msn.current_organization_id
107 ,msn.inventory_item_id) conversion_rate
108 ,msn.lpn_id lpn_id
109 ,loc.project_id project_id
110 ,loc.task_id task_id
111 ,NULL locator_inventory_item_id
112 ,NULL empty_flag
113 ,NULL location_current_units
114 from mtl_serial_numbers msn
115 ,mtl_secondary_inventories sub
116 ,mtl_item_locations loc
117 ,mtl_lot_numbers lot
118 where msn.current_status = 3
119 and decode(g_unit_number, '-9999', 'a', '-7777', nvl(msn.end_item_unit_number, '-7777'), msn.end_item_unit_number) =
120 decode(g_unit_number, '-9999', 'a', g_unit_number)
121 and (msn.group_mark_id IS NULL or msn.group_mark_id = -1)
122 --and (g_detail_serial IN ( 1,2)
123 and ( g_detail_any_serial = 2 or (g_detail_any_serial = 1
124 and g_from_serial_number <= msn.serial_number
125 and lengthb(g_from_serial_number) = lengthb(msn.serial_number)
126 and g_to_serial_number >= msn.serial_number
127 and lengthb(g_to_serial_number) = lengthb(msn.serial_number))
128 or ( g_from_serial_number is null or g_to_serial_number is null)
129 )
130 and sub.organization_id = msn.current_organization_id
131 and sub.secondary_inventory_name = msn.current_subinventory_code
132 and loc.organization_id (+)= msn.current_organization_id
133 and loc.inventory_location_id (+)= msn.current_locator_id
134 and lot.organization_id (+)= msn.current_organization_id
135 and lot.inventory_Item_id (+)= msn.inventory_item_id
136 and lot.lot_number (+)= msn.lot_number
137 )base
138 where base.ORGANIZATION_ID = g_organization_id
139 and base.INVENTORY_ITEM_ID = g_inventory_item_id
140 and decode(g_subinventory_code, '-9999', 'a', base.SUBINVENTORY_CODE) = decode(g_subinventory_code, '-9999', 'a', g_subinventory_code)
141 and decode(g_subinventory_code, '-9999', base.RESERVABLE_TYPE, 1) = 1
142 and decode(g_locator_id, -9999, 1, base.locator_id) = decode(g_locator_id,-9999, 1, g_locator_id)
143 and decode(g_revision, '-99', 'a', base.REVISION) = decode(g_revision, '-99', 'a', g_revision)
144 and decode(g_lot_number, '-9999', 'a', base.LOT_NUMBER) = decode(g_lot_number, '-9999', 'a', g_lot_number)
145 and decode(g_lpn_id, -9999, 1, base.lpn_id) = decode(g_lpn_id, -9999, 1, g_lpn_id)
146 and decode(g_cost_group_id, -9999, 1, base.cost_group_id) = decode(g_cost_group_id, -9999, 1, g_cost_group_id)
147 and mptdtv.PP_TRANSACTION_TEMP_ID = g_pp_transaction_temp_id
148 and Wms_Rule_Pvt.Match_Planning_Group(base.ORGANIZATION_ID,base.locator_id, g_project_id, mptdtv.project_id, mptdtv.task_id,g_transaction_type_id,g_inventory_item_id,base.project_id,base.task_id) = 1
149 and mlna.ORGANIZATION_ID (+) = base.ORGANIZATION_ID
150 and mlna.INVENTORY_ITEM_ID (+) = base.INVENTORY_ITEM_ID
151 and mlna.LOT_NUMBER (+) = base.LOT_NUMBER
152 and ( mlna.EXPIRATION_DATE is NULL OR mlna.EXPIRATION_DATE > sysdate OR wms_rule_pvt.g_allow_expired_lot_txn = 'Y' ) order by decode(base.project_id,g_project_id,1,NULL,2,3) asc,base.DATE_RECEIVED desc
153 ,base.SERIAL_NUMBER asc,base.CONVERSION_RATE desc
154 ;
155 Elsif (g_serial_control = 1) AND (g_detail_serial = 3) THEN
156 OPEN p_cursor FOR select base.REVISION
157 ,base.LOT_NUMBER
158 ,base.LOT_EXPIRATION_DATE
159 ,base.SUBINVENTORY_CODE
160 ,base.LOCATOR_ID
161 ,base.COST_GROUP_ID
162 ,base.UOM_CODE
163 ,decode(g_lpn_id, -9999, NULL, g_lpn_id) LPN_ID
164 ,NULL SERIAL_NUMBER
165 ,sum(base.primary_quantity)
166 ,sum(base.secondary_quantity)
167 ,base.grade_code
168 ,NULL consist_string
172 WMS_TRX_DETAILS_TMP_V mptdtv
169 ,base.DATE_RECEIVED order_by_string
170 from
171 MTL_LOT_NUMBERS mlna ,
173 ,(
174 select msn.current_organization_id organization_id
175 ,msn.inventory_item_id
176 ,msn.revision
177 ,msn.lot_number
178 ,lot.expiration_date lot_expiration_date
179 ,msn.current_subinventory_code subinventory_code
180 ,msn.current_locator_id locator_id
181 ,msn.cost_group_id
182 ,msn.status_id --added status_id
183 ,msn.serial_number
184 ,msn.initialization_date date_received
185 ,1 primary_quantity
186 ,null secondary_quantity -- new
187 ,lot.grade_code grade_code -- new
188 ,sub.reservable_type
189 ,nvl(loc.reservable_type,1) locreservable -- Bug 6719290
190 ,nvl(lot.reservable_type,1) lotreservable -- Bug 6719290
191 ,nvl(loc.pick_uom_code, sub.pick_uom_code) uom_code
192 ,WMS_Rule_PVT.GetConversionRate(
193 nvl(loc.pick_uom_code, sub.pick_uom_code)
194 ,msn.current_organization_id
195 ,msn.inventory_item_id) conversion_rate
196 ,msn.lpn_id lpn_id
197 ,loc.project_id project_id
198 ,loc.task_id task_id
199 ,NULL locator_inventory_item_id
200 ,NULL empty_flag
201 ,NULL location_current_units
202 from mtl_serial_numbers msn
203 ,mtl_secondary_inventories sub
204 ,mtl_item_locations loc
205 ,mtl_lot_numbers lot
206 where msn.current_status = 3
207 and decode(g_unit_number, '-9999', 'a', '-7777', nvl(msn.end_item_unit_number, '-7777'), msn.end_item_unit_number) =
208 decode(g_unit_number, '-9999', 'a', g_unit_number)
209 and (msn.group_mark_id IS NULL or msn.group_mark_id = -1)
210 and (g_detail_serial = 3
211 OR(g_detail_any_serial = 1
212 OR (g_from_serial_number <= msn.serial_number
213 AND lengthb(g_from_serial_number) = lengthb(msn.serial_number)
214 AND g_to_serial_number >= msn.serial_number
215 AND lengthb(g_to_serial_number) = lengthb(msn.serial_number)
216 )))
217 and sub.organization_id = msn.current_organization_id
218 and sub.secondary_inventory_name = msn.current_subinventory_code
219 and loc.organization_id (+)= msn.current_organization_id
220 and loc.inventory_location_id (+)= msn.current_locator_id
221 and lot.organization_id (+)= msn.current_organization_id
222 and lot.inventory_Item_id (+)= msn.inventory_item_id
223 and lot.lot_number (+)= msn.lot_number
224 and inv_detail_util_pvt.is_serial_trx_allowed(
225 g_transaction_type_id
226 ,msn.current_organization_id
227 ,msn.inventory_item_id
228 ,msn.status_id) = 'Y' )base
229 where base.ORGANIZATION_ID = g_organization_id
230 and base.INVENTORY_ITEM_ID = g_inventory_item_id
231 and decode(g_subinventory_code, '-9999', 'a', base.SUBINVENTORY_CODE) = decode(g_subinventory_code, '-9999', 'a', g_subinventory_code)
232 and decode(g_subinventory_code, '-9999', base.RESERVABLE_TYPE, 1) = 1
233 and decode(g_locator_id, -9999, 1, base.locator_id) = decode(g_locator_id,-9999, 1, g_locator_id)
234 and decode(g_revision, '-99', 'a', base.REVISION) = decode(g_revision, '-99', 'a', g_revision)
235 and decode(g_lot_number, '-9999', 'a', base.LOT_NUMBER) = decode(g_lot_number, '-9999', 'a', g_lot_number)
236 and decode(g_lpn_id, -9999, 1, base.lpn_id) = decode(g_lpn_id, -9999, 1, g_lpn_id)
237 and decode(g_cost_group_id, -9999, 1, base.cost_group_id) = decode(g_cost_group_id, -9999, 1, g_cost_group_id)
238 and mptdtv.PP_TRANSACTION_TEMP_ID = g_pp_transaction_temp_id
239 and Wms_Rule_Pvt.Match_Planning_Group(base.ORGANIZATION_ID,base.locator_id, g_project_id, mptdtv.project_id, mptdtv.task_id,g_transaction_type_id,g_inventory_item_id,base.project_id,base.task_id) = 1
240 and mlna.ORGANIZATION_ID (+) = base.ORGANIZATION_ID
241 and mlna.INVENTORY_ITEM_ID (+) = base.INVENTORY_ITEM_ID
242 and mlna.LOT_NUMBER (+) = base.LOT_NUMBER
243 and ( mlna.EXPIRATION_DATE is NULL OR mlna.EXPIRATION_DATE > sysdate OR wms_rule_pvt.g_allow_expired_lot_txn = 'Y' ) group by base.ORGANIZATION_ID
244 ,base.INVENTORY_ITEM_ID
245 ,base.REVISION
246 ,base.LOT_NUMBER
247 ,base.LOT_EXPIRATION_DATE
248 ,base.SUBINVENTORY_CODE
249 ,base.LOCATOR_ID
250 ,base.COST_GROUP_ID
251 ,base.PROJECT_ID
252 ,base.TASK_ID
253 ,base.UOM_CODE
254 ,base.GRADE_CODE
255 ,base.DATE_RECEIVED,base.SERIAL_NUMBER,base.CONVERSION_RATE
256 ,base.DATE_RECEIVED
257 order by decode(base.project_id,g_project_id,1,NULL,2,3) asc,base.DATE_RECEIVED desc
258 ,base.SERIAL_NUMBER asc,base.CONVERSION_RATE desc
259 ;
260 Elsif (g_serial_control = 1) AND (g_detail_serial = 4) THEN
261 OPEN p_cursor FOR select base.REVISION
262 ,base.LOT_NUMBER
263 ,base.LOT_EXPIRATION_DATE
264 ,base.SUBINVENTORY_CODE
265 ,base.LOCATOR_ID
266 ,base.COST_GROUP_ID
267 ,base.UOM_CODE
268 ,decode(g_lpn_id, -9999, NULL, g_lpn_id) LPN_ID
269 ,NULL SERIAL_NUMBER
270 ,sum(base.primary_quantity)
271 ,sum(base.secondary_quantity)
272 ,base.grade_code
273 ,NULL consist_string
274 ,base.DATE_RECEIVED order_by_string
275 from
276 MTL_LOT_NUMBERS mlna ,
277 WMS_TRX_DETAILS_TMP_V mptdtv
278 ,(
279 select msn.current_organization_id organization_id
280 ,msn.inventory_item_id
281 ,msn.revision
282 ,msn.lot_number
283 ,lot.expiration_date lot_expiration_date
284 ,msn.current_subinventory_code subinventory_code
285 ,msn.current_locator_id locator_id
289 ,msn.initialization_date date_received
286 ,msn.cost_group_id
287 ,msn.status_id --added status_id
288 ,msn.serial_number
290 ,1 primary_quantity
291 ,null secondary_quantity -- new
292 ,lot.grade_code grade_code -- new
293 ,sub.reservable_type
294 ,nvl(loc.reservable_type,1) locreservable -- Bug 6719290
295 ,nvl(lot.reservable_type,1) lotreservable -- Bug 6719290
296 ,nvl(loc.pick_uom_code, sub.pick_uom_code) uom_code
297 ,WMS_Rule_PVT.GetConversionRate(
298 nvl(loc.pick_uom_code, sub.pick_uom_code)
299 ,msn.current_organization_id
300 ,msn.inventory_item_id) conversion_rate
301 ,msn.lpn_id lpn_id
302 ,loc.project_id project_id
303 ,loc.task_id task_id
304 ,NULL locator_inventory_item_id
305 ,NULL empty_flag
306 ,NULL location_current_units
307 from mtl_serial_numbers msn
308 ,mtl_secondary_inventories sub
309 ,mtl_item_locations loc
310 ,mtl_lot_numbers lot
311 where msn.current_status = 3
312 and decode(g_unit_number, '-9999', 'a', '-7777', nvl(msn.end_item_unit_number, '-7777'), msn.end_item_unit_number) =
313 decode(g_unit_number, '-9999', 'a', g_unit_number)
314 and (msn.group_mark_id IS NULL or msn.group_mark_id = -1)
315 and (g_detail_serial = 4
316 OR(g_detail_any_serial = 1
317 OR (g_from_serial_number <= msn.serial_number
318 AND lengthb(g_from_serial_number) = lengthb(msn.serial_number)
319 AND g_to_serial_number >= msn.serial_number
320 AND lengthb(g_to_serial_number) = lengthb(msn.serial_number)
321 )))
322 and sub.organization_id = msn.current_organization_id
323 and sub.secondary_inventory_name = msn.current_subinventory_code
324 and loc.organization_id (+)= msn.current_organization_id
325 and loc.inventory_location_id (+)= msn.current_locator_id
326 and lot.organization_id (+)= msn.current_organization_id
327 and lot.inventory_Item_id (+)= msn.inventory_item_id
328 and lot.lot_number (+)= msn.lot_number
329 )base
330 where base.ORGANIZATION_ID = g_organization_id
331 and base.INVENTORY_ITEM_ID = g_inventory_item_id
332 and decode(g_subinventory_code, '-9999', 'a', base.SUBINVENTORY_CODE) = decode(g_subinventory_code, '-9999', 'a', g_subinventory_code)
333 and decode(g_subinventory_code, '-9999', base.RESERVABLE_TYPE, 1) = 1
334 and decode(g_locator_id, -9999, 1, base.locator_id) = decode(g_locator_id,-9999, 1, g_locator_id)
335 and decode(g_revision, '-99', 'a', base.REVISION) = decode(g_revision, '-99', 'a', g_revision)
336 and decode(g_lot_number, '-9999', 'a', base.LOT_NUMBER) = decode(g_lot_number, '-9999', 'a', g_lot_number)
337 and decode(g_lpn_id, -9999, 1, base.lpn_id) = decode(g_lpn_id, -9999, 1, g_lpn_id)
338 and decode(g_cost_group_id, -9999, 1, base.cost_group_id) = decode(g_cost_group_id, -9999, 1, g_cost_group_id)
339 and mptdtv.PP_TRANSACTION_TEMP_ID = g_pp_transaction_temp_id
340 and Wms_Rule_Pvt.Match_Planning_Group(base.ORGANIZATION_ID,base.locator_id, g_project_id, mptdtv.project_id, mptdtv.task_id,g_transaction_type_id,g_inventory_item_id,base.project_id,base.task_id) = 1
341 and mlna.ORGANIZATION_ID (+) = base.ORGANIZATION_ID
342 and mlna.INVENTORY_ITEM_ID (+) = base.INVENTORY_ITEM_ID
343 and mlna.LOT_NUMBER (+) = base.LOT_NUMBER
344 and ( mlna.EXPIRATION_DATE is NULL OR mlna.EXPIRATION_DATE > sysdate OR wms_rule_pvt.g_allow_expired_lot_txn = 'Y' ) group by base.ORGANIZATION_ID
345 ,base.INVENTORY_ITEM_ID
346 ,base.REVISION
347 ,base.LOT_NUMBER
348 ,base.LOT_EXPIRATION_DATE
349 ,base.SUBINVENTORY_CODE
350 ,base.LOCATOR_ID
351 ,base.COST_GROUP_ID
352 ,base.PROJECT_ID
353 ,base.TASK_ID
354 ,base.UOM_CODE
355 ,base.GRADE_CODE
356 ,base.DATE_RECEIVED,base.SERIAL_NUMBER,base.CONVERSION_RATE
357 ,base.DATE_RECEIVED
358 order by decode(base.project_id,g_project_id,1,NULL,2,3) asc,base.DATE_RECEIVED desc
359 ,base.SERIAL_NUMBER asc,base.CONVERSION_RATE desc
360 ;
361
362 Elsif ((g_serial_control <> 1) OR (g_detail_serial = 0)) THEN
363 OPEN p_cursor FOR select base.REVISION
364 ,base.LOT_NUMBER
365 ,base.LOT_EXPIRATION_DATE
366 ,base.SUBINVENTORY_CODE
367 ,base.LOCATOR_ID
368 ,base.COST_GROUP_ID
369 ,base.UOM_CODE
370 ,decode(g_lpn_id, -9999, NULL, g_lpn_id) LPN_ID
371 ,NULL SERIAL_NUMBER
372 ,sum(base.primary_quantity)
373 ,sum(base.secondary_quantity)
374 ,base.grade_code
375 ,NULL consist_string
376 ,base.DATE_RECEIVED order_by_string
377 from
378 MTL_LOT_NUMBERS mlna ,
379 WMS_TRX_DETAILS_TMP_V mptdtv
380 ,(
381 SELECT x.organization_id organization_id
382 ,x.inventory_item_id inventory_item_id
383 ,x.revision revision
384 ,x.lot_number lot_number
385 ,x.lot_expiration_date lot_expiration_date
386 ,x.subinventory_code subinventory_code
387 ,x.locator_id locator_id
388 ,x.cost_group_id cost_group_id
389 ,x.status_id status_id
390 ,NULL serial_number
391 ,x.lpn_id lpn_id
392 ,x.project_id project_id
393 ,x.task_id task_id
394 ,x.date_received date_received
395 ,x.primary_quantity primary_quantity
396 ,x.secondary_quantity secondary_quantity
400 ,x.lotreservable lotreservable
397 ,x.grade_code grade_code
398 ,x.reservable_type reservable_type
399 ,x.locreservable locreservable
401 ,NVL(loc.pick_uom_code,sub.pick_uom_code) uom_code
402 ,WMS_Rule_PVT.GetConversionRate(
403 NVL(loc.pick_uom_code, sub.pick_uom_code)
404 ,x.organization_id
405 ,x.inventory_item_id) conversion_rate
406 ,NULL locator_inventory_item_id
407 ,NULL empty_flag
408 ,NULL location_current_units
409 FROM (
410 select x.organization_id
411 ,x.inventory_item_id
412 ,x.revision
413 ,x.lot_number
414 ,lot.expiration_date lot_expiration_date
415 ,x.subinventory_code
416 ,sub.reservable_type
417 ,nvl(x.reservable_type,1) locreservable -- Bug 6719290
418 ,nvl(lot.reservable_type,1) lotreservable -- Bug 6719290
419 ,x.locator_id
420 ,x.cost_group_id
421 ,x.status_id --added status_id
422 ,x.date_received date_received
423 ,x.primary_quantity primary_quantity
424 ,x.secondary_quantity secondary_quantity -- new
425 ,lot.grade_code grade_code -- new
426 ,x.lpn_id lpn_id
427 ,x.project_id project_id
428 ,x.task_id task_id
429 from
430 (SELECT
431 moq.organization_id
432 ,moq.inventory_item_id
433 ,moq.revision
434 ,moq.lot_number
435 ,moq.subinventory_code
436 ,moq.locator_id
437 ,moq.cost_group_id
438 ,moq.status_id --added status_id
439 ,mils.reservable_type -- Bug 6719290
440 ,min(NVL(moq.orig_date_received,
441 moq.date_received)) date_received
442 ,sum(moq.primary_transaction_quantity) primary_quantity
443 ,sum(moq.secondary_transaction_quantity) secondary_quantity -- new
444 ,moq.lpn_id lpn_id
445 ,decode(mils.project_id, mils.project_id, moq.project_id) project_id
446 ,decode(mils.task_id, mils.task_id, moq.task_id) task_id
447 FROM
448 mtl_onhand_quantities_detail moq,mtl_item_locations mils
449 WHERE
450 moq.organization_id = g_organization_id
451 AND moq.inventory_item_id = g_inventory_item_id
452 AND moq.organization_id = mils.organization_id (+)
453 AND moq.subinventory_code = mils.subinventory_code (+)
454 AND moq.locator_id = mils.inventory_location_id (+)
455 GROUP BY
456 moq.organization_id, moq.inventory_item_id
457 ,moq.date_received --bug 6648984
458 ,moq.revision, moq.lot_number
459 ,moq.subinventory_code, moq.locator_id --added status_id
460 ,moq.cost_group_id,moq.status_id, mils.reservable_type, moq.lpn_id -- Bug 6719290
461 ,decode(mils.project_id, mils.project_id, moq.project_id)
462 ,decode(mils.task_id, mils.task_id, moq.task_id)
463 HAVING
464 sum(moq.primary_transaction_quantity) > 0 -- high volume project 8546026
465 ) x
466 ,mtl_secondary_inventories sub
467 ,mtl_lot_numbers lot
468 where
469 -- x.primary_quantity > 0 and -- high volume project 8546026
470 x.organization_id = sub.organization_id
471 and x.subinventory_code = sub.secondary_inventory_name
472 and x.organization_id = lot.organization_id (+)
473 and x.inventory_item_id = lot.inventory_item_id (+)
474 and x.lot_number = lot.lot_number (+)
475 ) x
476 ,mtl_secondary_inventories sub
477 ,mtl_item_locations loc
478 WHERE x.organization_id = loc.organization_id (+)
479 AND x.locator_id = loc.inventory_location_id (+)
480 AND sub.organization_id = x.organization_id
481 AND sub.secondary_inventory_name = x.subinventory_code
482 ) base
483 where base.ORGANIZATION_ID = g_organization_id
484 and base.INVENTORY_ITEM_ID = g_inventory_item_id
485 and decode(g_subinventory_code, '-9999', 'a', base.SUBINVENTORY_CODE) = decode(g_subinventory_code, '-9999', 'a', g_subinventory_code)
486 and decode(g_subinventory_code, '-9999', base.RESERVABLE_TYPE, 1) = 1
487 and decode(g_locator_id, -9999, 1, base.locator_id) = decode(g_locator_id,-9999, 1, g_locator_id)
488 and decode(g_revision, '-99', 'a', base.REVISION) = decode(g_revision, '-99', 'a', g_revision)
489 and decode(g_lot_number, '-9999', 'a', base.LOT_NUMBER) = decode(g_lot_number, '-9999', 'a', g_lot_number)
490 and decode(g_lpn_id, -9999, 1, base.lpn_id) = decode(g_lpn_id, -9999, 1, g_lpn_id)
491 and decode(g_cost_group_id, -9999, 1, base.cost_group_id) = decode(g_cost_group_id, -9999, 1, g_cost_group_id)
492 and mptdtv.PP_TRANSACTION_TEMP_ID = g_pp_transaction_temp_id
493 and Wms_Rule_Pvt.Match_Planning_Group(base.ORGANIZATION_ID,base.locator_id, g_project_id, mptdtv.project_id, mptdtv.task_id,g_transaction_type_id,g_inventory_item_id,base.project_id,base.task_id) = 1
494 and mlna.ORGANIZATION_ID (+) = base.ORGANIZATION_ID
495 and mlna.INVENTORY_ITEM_ID (+) = base.INVENTORY_ITEM_ID
496 and mlna.LOT_NUMBER (+) = base.LOT_NUMBER
497 and ( mlna.EXPIRATION_DATE is NULL OR mlna.EXPIRATION_DATE > sysdate OR wms_rule_pvt.g_allow_expired_lot_txn = 'Y' ) group by base.ORGANIZATION_ID
498 ,base.INVENTORY_ITEM_ID
499 ,base.REVISION
500 ,base.LOT_NUMBER
501 ,base.LOT_EXPIRATION_DATE
502 ,base.SUBINVENTORY_CODE
503 ,base.LOCATOR_ID
507 ,base.UOM_CODE
504 ,base.COST_GROUP_ID
505 ,base.PROJECT_ID
506 ,base.TASK_ID
508 ,base.GRADE_CODE
509 ,base.DATE_RECEIVED,base.SERIAL_NUMBER,base.CONVERSION_RATE
510 ,base.DATE_RECEIVED
511 order by decode(base.project_id,g_project_id,1,NULL,2,3) asc,base.DATE_RECEIVED desc
512 ,base.SERIAL_NUMBER asc,base.CONVERSION_RATE desc
513 ;
514 END IF;
515
516 x_result :=1;
517
518 END open_curs;
519
520 PROCEDURE fetch_one_row(
521 p_cursor IN WMS_RULE_PVT.cv_pick_type,
522 x_revision OUT NOCOPY VARCHAR2,
523 x_lot_number OUT NOCOPY VARCHAR2,
524 x_lot_expiration_date OUT NOCOPY DATE,
525 x_subinventory_code OUT NOCOPY VARCHAR2,
526 x_locator_id OUT NOCOPY NUMBER,
527 x_cost_group_id OUT NOCOPY NUMBER,
528 x_uom_code OUT NOCOPY VARCHAR2,
529 x_lpn_id OUT NOCOPY NUMBER,
530 x_serial_number OUT NOCOPY VARCHAR2,
531 x_possible_quantity OUT NOCOPY NUMBER,
532 x_sec_possible_quantity OUT NOCOPY NUMBER,
533 x_grade_code OUT NOCOPY VARCHAR2,
534 x_consist_string OUT NOCOPY VARCHAR2,
535 x_order_by_string OUT NOCOPY VARCHAR2,
536 x_return_status OUT NOCOPY NUMBER) IS
537
538
539 BEGIN
540 IF (p_cursor%ISOPEN) THEN
541
542 FETCH p_cursor INTO
543 x_revision
544 , x_lot_number
545 , x_lot_expiration_date
546 , x_subinventory_code
547 , x_locator_id
548 , x_cost_group_id
549 , x_uom_code
550 , x_lpn_id
551 , x_serial_number
552 , x_possible_quantity
553 , x_sec_possible_quantity
554 , x_grade_code
555 , x_consist_string
556 , x_order_by_string;
557 IF p_cursor%FOUND THEN
558 x_return_status :=1;
559 ELSE
560 x_return_status :=0;
561 END IF;
562 ELSE
563 x_return_status:=0;
564 END IF;
565
566
567 END fetch_one_row;
568
569 PROCEDURE close_curs( p_cursor IN WMS_RULE_PVT.cv_pick_type) IS
570 BEGIN
571 if (p_cursor%ISOPEN) THEN
572 CLOSE p_cursor;
573 END IF;
574 END close_curs;
575
576 -- LG convergence new procedure for the new manual picking select screen
577 PROCEDURE fetch_available_rows(
578 p_cursor IN WMS_RULE_PVT.cv_pick_type,
579 x_return_status OUT NOCOPY NUMBER) IS
580
581 /* Fix for Bug#8360804 . Added temp variable of type available_inventory_tbl */
582
583 l_available_inv_tbl WMS_SEARCH_ORDER_GLOBALS_PVT.available_inventory_tbl;
584 l_count number ;
585
586
587 BEGIN
588 IF (p_cursor%ISOPEN) THEN
589
590 /* Fix for bug#8360804. Collect into temp variable and then add it to g_available_inv_tbl */
591
592 FETCH p_cursor bulk collect INTO l_available_inv_tbl;
593
594 IF p_cursor%FOUND THEN
595 x_return_status :=1;
596 ELSE
597 x_return_status :=0;
598 END IF;
599
600 IF (WMS_SEARCH_ORDER_GLOBALS_PVT.g_available_inv_tbl.exists(1)) THEN
601
602 l_count := WMS_SEARCH_ORDER_GLOBALS_PVT.g_available_inv_tbl.LAST ;
603
604 FOR i in l_available_inv_tbl.FIRST..l_available_inv_tbl.LAST LOOP
605 l_count := l_count + 1 ;
606 WMS_SEARCH_ORDER_GLOBALS_PVT.g_available_inv_tbl(l_count) := l_available_inv_tbl(i) ;
607 END LOOP ;
608
609 ELSE
610 WMS_SEARCH_ORDER_GLOBALS_PVT.g_available_inv_tbl := l_available_inv_tbl ;
611 END IF ;
612 ELSE
613 x_return_status:=0;
614 END IF;
615
616
617 END fetch_available_rows;
618
619 -- end LG convergence
620
621 END WMS_RULE_2;