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