[Home] [Help]
PACKAGE BODY: APPS.WMS_RULE_15
Source
1 PACKAGE BODY WMS_RULE_15 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 ,NULL consist_string
80 ,NULL order_by_string
81 from PJM_PROJECT_PARAMETERS ppp
82 ,PJM_PROJECTS_ORG_V ppovs
83 ,MTL_ITEM_LOCATIONS mil
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 ((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))
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 (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))
148 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))
149 and mptdtv.PP_TRANSACTION_TEMP_ID = g_pp_transaction_temp_id
150 and mil.ORGANIZATION_ID (+) = base.ORGANIZATION_ID
151 and mil.INVENTORY_LOCATION_ID (+) = base.LOCATOR_ID
152 and ppovs.PROJECT_ID (+) = mptdtv.PROJECT_ID
153 and ppp.ORGANIZATION_ID (+) = mil.ORGANIZATION_ID
154 and ppp.PROJECT_ID (+) = mil.PROJECT_ID
155 and (
156 ppovs.PLANNING_GROUP = ppp.PLANNING_GROUP
157 )
158 order by base.CONVERSION_RATE desc
159 ;
160 Elsif (g_serial_control = 1) AND (g_detail_serial = 3) THEN
161 OPEN p_cursor FOR select base.REVISION
162 ,base.LOT_NUMBER
163 ,base.LOT_EXPIRATION_DATE
164 ,base.SUBINVENTORY_CODE
165 ,base.LOCATOR_ID
166 ,base.COST_GROUP_ID
167 ,base.UOM_CODE
168 ,decode(g_lpn_id, -9999, NULL, g_lpn_id) LPN_ID
169 ,NULL SERIAL_NUMBER
170 ,sum(base.primary_quantity)
171 ,sum(base.secondary_quantity)
172 ,base.grade_code
173 ,NULL consist_string
174 ,NULL order_by_string
175 from PJM_PROJECT_PARAMETERS ppp
176 ,PJM_PROJECTS_ORG_V ppovs
177 ,MTL_ITEM_LOCATIONS mil
178 ,WMS_TRX_DETAILS_TMP_V mptdtv
179 ,(
180 select msn.current_organization_id organization_id
181 ,msn.inventory_item_id
182 ,msn.revision
183 ,msn.lot_number
184 ,lot.expiration_date lot_expiration_date
185 ,msn.current_subinventory_code subinventory_code
186 ,msn.current_locator_id locator_id
187 ,msn.cost_group_id
188 ,msn.status_id --added status_id
189 ,msn.serial_number
190 ,msn.initialization_date date_received
191 ,1 primary_quantity
192 ,null secondary_quantity -- new
193 ,lot.grade_code grade_code -- new
194 ,sub.reservable_type
195 ,nvl(loc.reservable_type,1) locreservable -- Bug 6719290
196 ,nvl(lot.reservable_type,1) lotreservable -- Bug 6719290
197 ,nvl(loc.pick_uom_code, sub.pick_uom_code) uom_code
198 ,WMS_Rule_PVT.GetConversionRate(
199 nvl(loc.pick_uom_code, sub.pick_uom_code)
200 ,msn.current_organization_id
201 ,msn.inventory_item_id) conversion_rate
202 ,msn.lpn_id lpn_id
203 ,loc.project_id project_id
204 ,loc.task_id task_id
205 ,NULL locator_inventory_item_id
206 ,NULL empty_flag
207 ,NULL location_current_units
208 from mtl_serial_numbers msn
209 ,mtl_secondary_inventories sub
210 ,mtl_item_locations loc
211 ,mtl_lot_numbers lot
212 where msn.current_status = 3
213 and decode(g_unit_number, '-9999', 'a', '-7777', nvl(msn.end_item_unit_number, '-7777'), msn.end_item_unit_number) =
214 decode(g_unit_number, '-9999', 'a', g_unit_number)
215 and (msn.group_mark_id IS NULL or msn.group_mark_id = -1)
216 and (g_detail_serial = 3
217 OR(g_detail_any_serial = 1
218 OR (g_from_serial_number <= msn.serial_number
219 AND lengthb(g_from_serial_number) = lengthb(msn.serial_number)
220 AND g_to_serial_number >= msn.serial_number
221 AND lengthb(g_to_serial_number) = lengthb(msn.serial_number)
222 )))
223 and sub.organization_id = msn.current_organization_id
224 and sub.secondary_inventory_name = msn.current_subinventory_code
225 and loc.organization_id (+)= msn.current_organization_id
226 and loc.inventory_location_id (+)= msn.current_locator_id
227 and lot.organization_id (+)= msn.current_organization_id
228 and lot.inventory_Item_id (+)= msn.inventory_item_id
229 and lot.lot_number (+)= msn.lot_number
230 and inv_detail_util_pvt.is_serial_trx_allowed(
231 g_transaction_type_id
232 ,msn.current_organization_id
233 ,msn.inventory_item_id
234 ,msn.status_id) = 'Y' )base
235 where base.ORGANIZATION_ID = g_organization_id
236 and base.INVENTORY_ITEM_ID = g_inventory_item_id
237 and decode(g_subinventory_code, '-9999', 'a', base.SUBINVENTORY_CODE) = decode(g_subinventory_code, '-9999', 'a', g_subinventory_code)
238 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))
239 and decode(g_locator_id, -9999, 1, base.locator_id) = decode(g_locator_id,-9999, 1, g_locator_id)
240 and decode(g_revision, '-99', 'a', base.REVISION) = decode(g_revision, '-99', 'a', g_revision)
241 and decode(g_lot_number, '-9999', 'a', base.LOT_NUMBER) = decode(g_lot_number, '-9999', 'a', g_lot_number)
242 and decode(g_lpn_id, -9999, 1, base.lpn_id) = decode(g_lpn_id, -9999, 1, g_lpn_id)
243 and decode(g_cost_group_id, -9999, 1, base.cost_group_id) = decode(g_cost_group_id, -9999, 1, g_cost_group_id)
244 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))
245 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))
246 and mptdtv.PP_TRANSACTION_TEMP_ID = g_pp_transaction_temp_id
247 and mil.ORGANIZATION_ID (+) = base.ORGANIZATION_ID
248 and mil.INVENTORY_LOCATION_ID (+) = base.LOCATOR_ID
249 and ppovs.PROJECT_ID (+) = mptdtv.PROJECT_ID
250 and ppp.ORGANIZATION_ID (+) = mil.ORGANIZATION_ID
251 and ppp.PROJECT_ID (+) = mil.PROJECT_ID
252 and (
253 ppovs.PLANNING_GROUP = ppp.PLANNING_GROUP
254 )
255 group by base.ORGANIZATION_ID
256 ,base.INVENTORY_ITEM_ID
257 ,base.REVISION
258 ,base.LOT_NUMBER
259 ,base.LOT_EXPIRATION_DATE
260 ,base.SUBINVENTORY_CODE
261 ,base.LOCATOR_ID
262 ,base.COST_GROUP_ID
263 ,base.PROJECT_ID
264 ,base.TASK_ID
265 ,base.UOM_CODE
266 ,base.GRADE_CODE
267 ,base.CONVERSION_RATE
268 order by base.CONVERSION_RATE desc
269 ;
270 Elsif (g_serial_control = 1) AND (g_detail_serial = 4) THEN
271 OPEN p_cursor FOR select base.REVISION
272 ,base.LOT_NUMBER
273 ,base.LOT_EXPIRATION_DATE
274 ,base.SUBINVENTORY_CODE
275 ,base.LOCATOR_ID
276 ,base.COST_GROUP_ID
277 ,base.UOM_CODE
278 ,decode(g_lpn_id, -9999, NULL, g_lpn_id) LPN_ID
279 ,NULL SERIAL_NUMBER
280 ,sum(base.primary_quantity)
281 ,sum(base.secondary_quantity)
282 ,base.grade_code
283 ,NULL consist_string
284 ,NULL order_by_string
285 from PJM_PROJECT_PARAMETERS ppp
286 ,PJM_PROJECTS_ORG_V ppovs
287 ,MTL_ITEM_LOCATIONS mil
288 ,WMS_TRX_DETAILS_TMP_V mptdtv
289 ,(
290 select msn.current_organization_id organization_id
291 ,msn.inventory_item_id
292 ,msn.revision
293 ,msn.lot_number
294 ,lot.expiration_date lot_expiration_date
295 ,msn.current_subinventory_code subinventory_code
296 ,msn.current_locator_id locator_id
297 ,msn.cost_group_id
298 ,msn.status_id --added status_id
299 ,msn.serial_number
300 ,msn.initialization_date date_received
301 ,1 primary_quantity
302 ,null secondary_quantity -- new
303 ,lot.grade_code grade_code -- new
304 ,sub.reservable_type
305 ,nvl(loc.reservable_type,1) locreservable -- Bug 6719290
306 ,nvl(lot.reservable_type,1) lotreservable -- Bug 6719290
307 ,nvl(loc.pick_uom_code, sub.pick_uom_code) uom_code
308 ,WMS_Rule_PVT.GetConversionRate(
309 nvl(loc.pick_uom_code, sub.pick_uom_code)
310 ,msn.current_organization_id
311 ,msn.inventory_item_id) conversion_rate
312 ,msn.lpn_id lpn_id
313 ,loc.project_id project_id
314 ,loc.task_id task_id
315 ,NULL locator_inventory_item_id
316 ,NULL empty_flag
317 ,NULL location_current_units
318 from mtl_serial_numbers msn
319 ,mtl_secondary_inventories sub
320 ,mtl_item_locations loc
321 ,mtl_lot_numbers lot
322 where msn.current_status = 3
323 and decode(g_unit_number, '-9999', 'a', '-7777', nvl(msn.end_item_unit_number, '-7777'), msn.end_item_unit_number) =
324 decode(g_unit_number, '-9999', 'a', g_unit_number)
325 and (msn.group_mark_id IS NULL or msn.group_mark_id = -1)
326 and (g_detail_serial = 4
327 OR(g_detail_any_serial = 1
328 OR (g_from_serial_number <= msn.serial_number
329 AND lengthb(g_from_serial_number) = lengthb(msn.serial_number)
330 AND g_to_serial_number >= msn.serial_number
331 AND lengthb(g_to_serial_number) = lengthb(msn.serial_number)
332 )))
333 and sub.organization_id = msn.current_organization_id
334 and sub.secondary_inventory_name = msn.current_subinventory_code
335 and loc.organization_id (+)= msn.current_organization_id
336 and loc.inventory_location_id (+)= msn.current_locator_id
337 and lot.organization_id (+)= msn.current_organization_id
338 and lot.inventory_Item_id (+)= msn.inventory_item_id
339 and lot.lot_number (+)= msn.lot_number
340 )base
341 where base.ORGANIZATION_ID = g_organization_id
342 and base.INVENTORY_ITEM_ID = g_inventory_item_id
343 and decode(g_subinventory_code, '-9999', 'a', base.SUBINVENTORY_CODE) = decode(g_subinventory_code, '-9999', 'a', g_subinventory_code)
344 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))
345 and decode(g_locator_id, -9999, 1, base.locator_id) = decode(g_locator_id,-9999, 1, g_locator_id)
346 and decode(g_revision, '-99', 'a', base.REVISION) = decode(g_revision, '-99', 'a', g_revision)
347 and decode(g_lot_number, '-9999', 'a', base.LOT_NUMBER) = decode(g_lot_number, '-9999', 'a', g_lot_number)
348 and decode(g_lpn_id, -9999, 1, base.lpn_id) = decode(g_lpn_id, -9999, 1, g_lpn_id)
349 and decode(g_cost_group_id, -9999, 1, base.cost_group_id) = decode(g_cost_group_id, -9999, 1, g_cost_group_id)
350 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))
351 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))
352 and mptdtv.PP_TRANSACTION_TEMP_ID = g_pp_transaction_temp_id
353 and mil.ORGANIZATION_ID (+) = base.ORGANIZATION_ID
354 and mil.INVENTORY_LOCATION_ID (+) = base.LOCATOR_ID
355 and ppovs.PROJECT_ID (+) = mptdtv.PROJECT_ID
356 and ppp.ORGANIZATION_ID (+) = mil.ORGANIZATION_ID
357 and ppp.PROJECT_ID (+) = mil.PROJECT_ID
358 and (
359 ppovs.PLANNING_GROUP = ppp.PLANNING_GROUP
360 )
361 group by base.ORGANIZATION_ID
362 ,base.INVENTORY_ITEM_ID
363 ,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.PROJECT_ID
373 ,base.CONVERSION_RATE
370 ,base.TASK_ID
371 ,base.UOM_CODE
372 ,base.GRADE_CODE
374 order by base.CONVERSION_RATE desc
375 ;
376
377 Elsif ((g_serial_control <> 1) OR (g_detail_serial = 0)) THEN
378 OPEN p_cursor FOR select base.REVISION
379 ,base.LOT_NUMBER
380 ,base.LOT_EXPIRATION_DATE
381 ,base.SUBINVENTORY_CODE
382 ,base.LOCATOR_ID
383 ,base.COST_GROUP_ID
384 ,base.UOM_CODE
385 ,decode(g_lpn_id, -9999, NULL, g_lpn_id) LPN_ID
386 ,NULL SERIAL_NUMBER
387 ,sum(base.primary_quantity)
388 ,sum(base.secondary_quantity)
389 ,base.grade_code
390 ,NULL consist_string
391 ,NULL order_by_string
392 from PJM_PROJECT_PARAMETERS ppp
393 ,PJM_PROJECTS_ORG_V ppovs
394 ,MTL_ITEM_LOCATIONS mil
395 ,WMS_TRX_DETAILS_TMP_V mptdtv
396 ,(
397 SELECT x.organization_id organization_id
398 ,x.inventory_item_id inventory_item_id
399 ,x.revision revision
400 ,x.lot_number lot_number
401 ,x.lot_expiration_date lot_expiration_date
402 ,x.subinventory_code subinventory_code
403 ,x.locator_id locator_id
404 ,x.cost_group_id cost_group_id
405 ,x.status_id status_id
406 ,NULL serial_number
407 ,x.lpn_id lpn_id
408 ,x.project_id project_id
409 ,x.task_id task_id
410 ,x.date_received date_received
411 ,x.primary_quantity primary_quantity
412 ,x.secondary_quantity secondary_quantity
413 ,x.grade_code grade_code
414 ,x.reservable_type reservable_type
415 ,x.locreservable locreservable
416 ,x.lotreservable lotreservable
417 ,NVL(loc.pick_uom_code,sub.pick_uom_code) uom_code
418 ,WMS_Rule_PVT.GetConversionRate(
419 NVL(loc.pick_uom_code, sub.pick_uom_code)
420 ,x.organization_id
421 ,x.inventory_item_id) conversion_rate
422 ,NULL locator_inventory_item_id
423 ,NULL empty_flag
424 ,NULL location_current_units
425 FROM (
426 select x.organization_id
427 ,x.inventory_item_id
428 ,x.revision
429 ,x.lot_number
430 ,lot.expiration_date lot_expiration_date
431 ,x.subinventory_code
432 ,sub.reservable_type
433 ,nvl(x.reservable_type,1) locreservable -- Bug 6719290
434 ,nvl(lot.reservable_type,1) lotreservable -- Bug 6719290
435 ,x.locator_id
436 ,x.cost_group_id
437 ,x.status_id --added status_id
438 ,x.date_received date_received
439 ,x.primary_quantity primary_quantity
440 ,x.secondary_quantity secondary_quantity -- new
441 ,lot.grade_code grade_code -- new
442 ,x.lpn_id lpn_id
443 ,x.project_id project_id
444 ,x.task_id task_id
445 from
446 (SELECT
447 moq.organization_id
448 ,moq.inventory_item_id
449 ,moq.revision
450 ,moq.lot_number
451 ,moq.subinventory_code
452 ,moq.locator_id
453 ,moq.cost_group_id
454 ,moq.status_id --added status_id
455 ,mils.reservable_type -- Bug 6719290
456 ,min(NVL(moq.orig_date_received,
457 moq.date_received)) date_received
458 ,sum(moq.primary_transaction_quantity) primary_quantity
459 ,sum(moq.secondary_transaction_quantity) secondary_quantity -- new
460 ,moq.lpn_id lpn_id
461 ,decode(mils.project_id, mils.project_id, moq.project_id) project_id
462 ,decode(mils.task_id, mils.task_id, moq.task_id) task_id
463 FROM
464 mtl_onhand_quantities_detail moq,mtl_item_locations mils
465 WHERE
466 moq.organization_id = g_organization_id
467 AND moq.inventory_item_id = g_inventory_item_id
468 AND moq.organization_id = mils.organization_id (+)
469 AND moq.subinventory_code = mils.subinventory_code (+)
470 AND moq.locator_id = mils.inventory_location_id (+)
471 GROUP BY
472 moq.organization_id, moq.inventory_item_id
473 ,moq.revision, moq.lot_number
474 ,moq.subinventory_code, moq.locator_id --added status_id
475 ,moq.cost_group_id,moq.status_id, mils.reservable_type, moq.lpn_id -- Bug 6719290
476 ,decode(mils.project_id, mils.project_id, moq.project_id)
477 ,decode(mils.task_id, mils.task_id, moq.task_id)
478 ) x
479 ,mtl_secondary_inventories sub
480 ,mtl_lot_numbers lot
481 where x.primary_quantity > 0
482 and x.organization_id = sub.organization_id
483 and x.subinventory_code = sub.secondary_inventory_name
484 and x.organization_id = lot.organization_id (+)
485 and x.inventory_item_id = lot.inventory_item_id (+)
486 and x.lot_number = lot.lot_number (+)
487 ) x
488 ,mtl_secondary_inventories sub
492 AND sub.organization_id = x.organization_id
489 ,mtl_item_locations loc
490 WHERE x.organization_id = loc.organization_id (+)
491 AND x.locator_id = loc.inventory_location_id (+)
493 AND sub.secondary_inventory_name = x.subinventory_code
494 ) base
495 where base.ORGANIZATION_ID = g_organization_id
496 and base.INVENTORY_ITEM_ID = g_inventory_item_id
497 and decode(g_subinventory_code, '-9999', 'a', base.SUBINVENTORY_CODE) = decode(g_subinventory_code, '-9999', 'a', g_subinventory_code)
498 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))
499 and decode(g_locator_id, -9999, 1, base.locator_id) = decode(g_locator_id,-9999, 1, g_locator_id)
500 and decode(g_revision, '-99', 'a', base.REVISION) = decode(g_revision, '-99', 'a', g_revision)
501 and decode(g_lot_number, '-9999', 'a', base.LOT_NUMBER) = decode(g_lot_number, '-9999', 'a', g_lot_number)
502 and decode(g_lpn_id, -9999, 1, base.lpn_id) = decode(g_lpn_id, -9999, 1, g_lpn_id)
503 and decode(g_cost_group_id, -9999, 1, base.cost_group_id) = decode(g_cost_group_id, -9999, 1, g_cost_group_id)
504 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))
505 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))
506 and mptdtv.PP_TRANSACTION_TEMP_ID = g_pp_transaction_temp_id
507 and mil.ORGANIZATION_ID (+) = base.ORGANIZATION_ID
508 and mil.INVENTORY_LOCATION_ID (+) = base.LOCATOR_ID
509 and ppovs.PROJECT_ID (+) = mptdtv.PROJECT_ID
510 and ppp.ORGANIZATION_ID (+) = mil.ORGANIZATION_ID
511 and ppp.PROJECT_ID (+) = mil.PROJECT_ID
512 and (
513 ppovs.PLANNING_GROUP = ppp.PLANNING_GROUP
514 )
515 group by base.ORGANIZATION_ID
516 ,base.INVENTORY_ITEM_ID
517 ,base.REVISION
518 ,base.LOT_NUMBER
519 ,base.LOT_EXPIRATION_DATE
520 ,base.SUBINVENTORY_CODE
521 ,base.LOCATOR_ID
522 ,base.COST_GROUP_ID
523 ,base.PROJECT_ID
524 ,base.TASK_ID
525 ,base.UOM_CODE
526 ,base.GRADE_CODE
527 ,base.CONVERSION_RATE
528 order by base.CONVERSION_RATE desc
529 ;
530 END IF;
531
532 x_result :=1;
533
534 END open_curs;
535
536 PROCEDURE fetch_one_row(
537 p_cursor IN WMS_RULE_PVT.cv_pick_type,
538 x_revision OUT NOCOPY VARCHAR2,
539 x_lot_number OUT NOCOPY VARCHAR2,
540 x_lot_expiration_date OUT NOCOPY DATE,
541 x_subinventory_code OUT NOCOPY VARCHAR2,
542 x_locator_id OUT NOCOPY NUMBER,
543 x_cost_group_id OUT NOCOPY NUMBER,
544 x_uom_code OUT NOCOPY VARCHAR2,
545 x_lpn_id OUT NOCOPY NUMBER,
546 x_serial_number OUT NOCOPY VARCHAR2,
547 x_possible_quantity OUT NOCOPY NUMBER,
548 x_sec_possible_quantity OUT NOCOPY NUMBER,
549 x_grade_code OUT NOCOPY VARCHAR2,
550 x_consist_string OUT NOCOPY VARCHAR2,
551 x_order_by_string OUT NOCOPY VARCHAR2,
552 x_return_status OUT NOCOPY NUMBER) IS
553
554
555 BEGIN
556 IF (p_cursor%ISOPEN) THEN
557
558 FETCH p_cursor INTO
559 x_revision
560 , x_lot_number
561 , x_lot_expiration_date
562 , x_subinventory_code
563 , x_locator_id
564 , x_cost_group_id
565 , x_uom_code
566 , x_lpn_id
567 , x_serial_number
568 , x_possible_quantity
569 , x_sec_possible_quantity
570 , x_grade_code
571 , x_consist_string
572 , x_order_by_string;
573 IF p_cursor%FOUND THEN
574 x_return_status :=1;
575 ELSE
576 x_return_status :=0;
577 END IF;
578 ELSE
579 x_return_status:=0;
580 END IF;
581
582
583 END fetch_one_row;
584
585 PROCEDURE close_curs( p_cursor IN WMS_RULE_PVT.cv_pick_type) IS
586 BEGIN
587 if (p_cursor%ISOPEN) THEN
588 CLOSE p_cursor;
589 END IF;
590 END close_curs;
591
592 -- LG convergence new procedure for the new manual picking select screen
593 PROCEDURE fetch_available_rows(
594 p_cursor IN WMS_RULE_PVT.cv_pick_type,
595 x_return_status OUT NOCOPY NUMBER) IS
596
597
598 BEGIN
599 IF (p_cursor%ISOPEN) THEN
600
601 FETCH p_cursor bulk collect INTO
602 WMS_SEARCH_ORDER_GLOBALS_PVT.g_available_inv_tbl;
603 IF p_cursor%FOUND THEN
604 x_return_status :=1;
605 ELSE
606 x_return_status :=0;
607 END IF;
608 ELSE
609 x_return_status:=0;
610 END IF;
611
612
613 END fetch_available_rows;
614
615 -- end LG convergence
616
617 END WMS_RULE_15;